diff --git a/examples/debug/main.cpp b/examples/debug/main.cpp index 94c3625..b282035 100644 --- a/examples/debug/main.cpp +++ b/examples/debug/main.cpp @@ -65,7 +65,7 @@ int main(int argc, char** argv) }; // Make a square - oglu::VertexArray square = oglu::MakeVertexArray(vertices, sizeof(vertices), indices, sizeof(indices), topology, sizeof(topology)); + oglu::Object square(vertices, sizeof(vertices), indices, sizeof(indices), topology, sizeof(topology)); // Create a shader oglu::Shader shader; @@ -83,17 +83,12 @@ int main(int argc, char** argv) oglu::Texture crate = oglu::MakeTexture("assets/crate.jpg"); oglu::Texture opengl = oglu::MakeTexture("assets/opengl.png"); - oglu::Transformable model; - //model.SetRotation(-55.0f, 0.0f, 0.0f); - glm::mat4 view = glm::mat4(1.0f); view = glm::translate(view, glm::vec3(0.0f, 0.0f, -3.0f)); glm::mat4 projection; projection = glm::perspective(glm::radians(45.f), 1.0f, 0.1f, 100.0f); - glm::mat4 test = glm::make_mat4(model.GetMatrix()); - // Window loop while (!glfwWindowShouldClose(window)) { @@ -101,16 +96,16 @@ int main(int argc, char** argv) oglu::ClearScreen(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT, oglu::Color(0.29f, 0.13f, 0.23f)); - model.Rotate(6.0f, 0.0f, 0.0f); + square.Rotate(6.0f, 0.0f, 0.0f); shader->Use(); shader->SetUniform("texture1", crate, 0); shader->SetUniform("texture2", opengl, 1); - shader->SetUniformMatrix4fv("model", 1, GL_FALSE, model.GetMatrix()); + shader->SetUniformMatrix4fv("model", 1, GL_FALSE, square.GetMatrix()); shader->SetUniformMatrix4fv("view", 1, GL_FALSE, glm::value_ptr(view)); shader->SetUniformMatrix4fv("projection", 1, GL_FALSE, glm::value_ptr(projection)); - square->BindAndDraw(); + square.Render(); glfwSwapBuffers(window); glfwPollEvents(); diff --git a/include/object.hpp b/include/object.hpp new file mode 100644 index 0000000..0e7c0a4 --- /dev/null +++ b/include/object.hpp @@ -0,0 +1,24 @@ +#ifndef OBJECT_HPP +#define OBJECT_HPP + +#include +#include +#include + +namespace oglu +{ + class OGLU_API Object : public Transformable + { + public: + Object(const GLfloat* vertices, size_t verticesSize, const GLuint* indices, size_t indicesSize, const VertexAttribute* topology, size_t topologySize); + Object(const Object& other); + ~Object(); + + void Render(); + + private: + VertexArray VAO; + }; +} + +#endif \ No newline at end of file diff --git a/include/openglu.hpp b/include/openglu.hpp index ec6559c..fa1f442 100644 --- a/include/openglu.hpp +++ b/include/openglu.hpp @@ -12,6 +12,7 @@ #include #include #include +#include namespace oglu { diff --git a/include/vertexArray.hpp b/include/vertexArray.hpp index 0152031..e9b970f 100644 --- a/include/vertexArray.hpp +++ b/include/vertexArray.hpp @@ -16,7 +16,7 @@ namespace oglu /** * @brief Structure to store topology data. */ - OGLU_API struct VertexAttribute { + struct OGLU_API VertexAttribute { /*@{*/ GLuint index; ///< Index of the vertex attribute GLint size; ///< Number of elements in this attribute diff --git a/src/object.cpp b/src/object.cpp new file mode 100644 index 0000000..9e76a70 --- /dev/null +++ b/src/object.cpp @@ -0,0 +1,23 @@ +#include "object.hpp" + +namespace oglu +{ + Object::Object(const GLfloat* vertices, size_t verticesSize, const GLuint* indices, size_t indicesSize, const VertexAttribute* topology, size_t topologySize) : + VAO(MakeVertexArray(vertices, verticesSize, indices, indicesSize, topology, topologySize)) + { + } + + Object::Object(const Object& other) : + VAO(other.VAO) + { + } + + Object::~Object() + { + } + + void Object::Render() + { + VAO->BindAndDraw(); + } +}