Commit 4766b5ec authored by Bastian Krayer's avatar Bastian Krayer

updated some cvk files

parent 5fc3f29e
......@@ -37,7 +37,7 @@ class Cone : public CVK::Geometry {
/**
* Standard Destructor for Cone
*/
~Cone();
~Cone() override;
/**
* @brief Standard Getter for position of the base
......
......@@ -19,7 +19,7 @@ class Geometry {
/**
* Standard Destructor for Geometry
*/
~Geometry();
virtual ~Geometry();
/**
* @brief Getter for geometry type
* @return the geometry type of this object
......@@ -73,6 +73,26 @@ class Geometry {
*/
std::vector<glm::vec3>* getTangents();
/**
* @brief Standard Getter for the vao
* @return the vao handle
*/
GLuint getVAO() const;
/**
* @brief Standard Getter for the number of indices
* @return the number of indices
*/
int getNumIndices() const;
/**
* @brief Standard Getter for the number of vertex attributes (e.g.
* tangents,
* ...)
* @return the number of vertex attributes
*/
int getNumVertexAttrib() const;
protected:
int m_geotype =
CVK_GEOMETRY; //!< Information for the geometry type (f.e. sphere)
......@@ -91,6 +111,8 @@ class Geometry {
int m_points = 0; //!< Number of all vertices
int m_indices = 0; //!< Number of all indices
int m_num_attribs = 0; //!< Number of vertex attributes
std::vector<glm::vec4> m_vertices; //!< A list of all vertex positions
std::vector<glm::vec3> m_normals; //!< A list of all vertex normals
std::vector<glm::vec2> m_uvs; //!< A list of all vertex uv coordinates
......
......@@ -40,7 +40,7 @@ class Plane : public CVK::Geometry {
/**
* Standard Destructor for Plane
*/
~Plane();
~Plane() override;
/**
* @brief Setter for vertex positions
......
......@@ -22,6 +22,8 @@ class ShaderPostProcessing : public CVK::ShaderSet {
* @param shaderPaths Array of paths to shader files
*/
ShaderPostProcessing(GLuint shader_mask, const char** shaderPaths);
ShaderPostProcessing(GLuint shader_mask,
const std::vector<std::string>& shaderPaths);
/**
* Sets rendering dependent variables in Shader. None used in
......
......@@ -35,7 +35,7 @@ class ShaderSet {
/**
* Standard Destructor for ShaderSet
*/
~ShaderSet();
virtual ~ShaderSet();
/**
* Loads the shader files to strings and compiles them with OpenGL
......
......@@ -5,6 +5,9 @@
#include <CVK_2/CVK_ShaderPostProcessing.h>
#include <CVK_2/CVK_State.h>
#include <string>
#include <vector>
namespace CVK {
/**
......@@ -17,10 +20,12 @@ class ShaderSimpleTexture : public CVK::ShaderPostProcessing {
/**
* Constructor for ShaderSimpleTexture with given parameters. Collects
* uniform locations for all used variables from Shader Program.
* @param shader_mask Describes which shader files are used
* @param shaderMask Describes which shader files are used
* @param shaderPaths Array of paths to shader files
*/
ShaderSimpleTexture(GLuint shader_mask, const char** shaderPaths);
ShaderSimpleTexture(GLuint shaderMask, const char** shaderPaths);
ShaderSimpleTexture(GLuint shader_mask,
const std::vector<std::string>& shaderPaths);
/**
* Sets rendering dependent variables in Shader. Namely the first texture
......
......@@ -42,7 +42,7 @@ class Sphere : public CVK::Geometry {
/**
* Standard Destructor for Sphere
*/
~Sphere();
~Sphere() override;
/**
* @brief Standard Getter for center position
......
......@@ -18,7 +18,7 @@ class Teapot : public CVK::Geometry {
/**
* Standard Destructor for the Teapot
*/
~Teapot();
~Teapot() override;
private:
/**
......
......@@ -2,7 +2,7 @@
CVK::Camera::Camera(GLFWwindow* window) : m_window(window) {}
CVK::Camera::~Camera() {}
CVK::Camera::~Camera() = default;
glm::mat4* CVK::Camera::getView() { return &m_viewmatrix; }
......
......@@ -35,7 +35,7 @@ CVK::Cone::Cone(glm::vec3 basepoint, glm::vec3 apexpoint, float baseradius,
create();
}
CVK::Cone::~Cone() {}
CVK::Cone::~Cone() = default;
glm::vec3* CVK::Cone::getBasepoint() { return &m_basepoint; }
......@@ -59,7 +59,6 @@ void CVK::Cone::create() {
float radius, phi;
glm::vec3 q;
int offset = 0, i, j;
glm::vec3 n1, n2, n;
m_v = m_apexpoint - m_basepoint;
m_height = glm::length(m_v);
......
......@@ -63,26 +63,32 @@ void CVK::Geometry::createBuffers() {
glBindVertexArray(m_vao);
m_num_attribs = 0;
if (m_vertexbuffer != 0) {
glBindBuffer(GL_ARRAY_BUFFER, m_vertexbuffer);
glEnableVertexAttribArray(VERTICES);
glVertexAttribPointer(VERTICES, 4, GL_FLOAT, GL_FALSE, 0, nullptr);
m_num_attribs++;
}
if (m_normalbuffer != 0) {
glBindBuffer(GL_ARRAY_BUFFER, m_normalbuffer);
glEnableVertexAttribArray(NORMALS);
glVertexAttribPointer(NORMALS, 3, GL_FLOAT, GL_FALSE, 0, nullptr);
m_num_attribs++;
}
if (m_uvbuffer != 0) {
glBindBuffer(GL_ARRAY_BUFFER, m_uvbuffer);
glEnableVertexAttribArray(TEXTURECOORDS);
glVertexAttribPointer(TEXTURECOORDS, 2, GL_FLOAT, GL_FALSE, 0, nullptr);
m_num_attribs++;
}
if (m_tangentbuffer != 0) {
glBindBuffer(GL_ARRAY_BUFFER, m_tangentbuffer);
glEnableVertexAttribArray(TANGENTS);
glVertexAttribPointer(TANGENTS, 3, GL_FLOAT, GL_FALSE, 0, nullptr);
m_num_attribs++;
}
if (m_indexlist != 0) {
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_indexlist);
......@@ -145,3 +151,6 @@ std::vector<glm::vec2>* CVK::Geometry::getUVs() { return &m_uvs; }
std::vector<unsigned int>* CVK::Geometry::getIndex() { return &m_index; }
std::vector<glm::vec3>* CVK::Geometry::getTangents() { return &m_tangents; }
GLuint CVK::Geometry::getVAO() const { return m_vao; }
int CVK::Geometry::getNumIndices() const { return m_indices; }
int CVK::Geometry::getNumVertexAttrib() const { return m_num_attribs; }
#include <CVK_2/CVK_ShaderPostProcessing.h>
CVK::ShaderPostProcessing::ShaderPostProcessing(GLuint shader_mask,
const char** shaderPaths) {
// generate shader program
GenerateShaderProgramm(shader_mask, shaderPaths);
const char** shaderPaths)
: ShaderSet(shader_mask, shaderPaths) {
m_screenFillingQuad.set_Points(
glm::vec3(-1.f, 1.f, 0.f), glm::vec3(-1.f, -1.f, 0.f),
glm::vec3(1.f, -1.f, 0.f), glm::vec3(1.f, 1.f, 0.f));
......@@ -12,3 +12,11 @@ CVK::ShaderPostProcessing::ShaderPostProcessing(GLuint shader_mask,
void CVK::ShaderPostProcessing::update() {}
void CVK::ShaderPostProcessing::render() { m_screenFillingQuad.render(); }
CVK::ShaderPostProcessing::ShaderPostProcessing(
GLuint shader_mask, const std::vector<std::string>& shaderPaths)
: ShaderSet(shader_mask, shaderPaths) {
m_screenFillingQuad.set_Points(
glm::vec3(-1.f, 1.f, 0.f), glm::vec3(-1.f, -1.f, 0.f),
glm::vec3(1.f, -1.f, 0.f), glm::vec3(1.f, 1.f, 0.f));
}
#include <CVK_2/CVK_ShaderSimpleTexture.h>
CVK::ShaderSimpleTexture::ShaderSimpleTexture(GLuint shader_mask,
CVK::ShaderSimpleTexture::ShaderSimpleTexture(GLuint shaderMask,
const char** shaderPaths)
: CVK::ShaderPostProcessing(shader_mask, shaderPaths) {
: CVK::ShaderPostProcessing(shaderMask, shaderPaths) {
m_colorTextureID = glGetUniformLocation(m_ProgramID, "colortexture");
}
......@@ -13,3 +13,8 @@ void CVK::ShaderSimpleTexture::update() {
glBindTexture(GL_TEXTURE_2D, m_textures[0]);
}
}
CVK::ShaderSimpleTexture::ShaderSimpleTexture(
GLuint shader_mask, const std::vector<std::string>& shaderPaths)
: ShaderPostProcessing(shader_mask, shaderPaths) {
m_colorTextureID = glGetUniformLocation(m_ProgramID, "colortexture");
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment