diff --git a/README.md b/README.md new file mode 100644 index 0000000..61a7f30 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +#Spherical Harmonics \ No newline at end of file diff --git a/src/Model.cpp b/src/Model.cpp index 3c00dd2..d0619a3 100644 --- a/src/Model.cpp +++ b/src/Model.cpp @@ -21,6 +21,7 @@ Model::Model(std::vector&& vertices, std::vector&& indices) Model::~Model() { + } void Model::Draw() @@ -35,18 +36,23 @@ void Model::CreateVAO() glBindVertexArray(vao); glGenBuffers(1, &vbo); - glBindBuffer(GL_ARRAY_BUFFER, vbo); - glBufferData(GL_ARRAY_BUFFER, vertices.size() * sizeof(float), vertices.data(), GL_STATIC_DRAW); - glGenBuffers(1, &ebo); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ebo); - glBufferData(GL_ELEMENT_ARRAY_BUFFER, indices.size() * sizeof(unsigned int), indices.data(), GL_STATIC_DRAW); + UpdateBufferData(); DefineVAOLayout(); glBindVertexArray(0); } +void Model::UpdateBufferData() +{ + glBindBuffer(GL_ARRAY_BUFFER, vbo); + glBufferData(GL_ARRAY_BUFFER, vertices.size() * sizeof(float), vertices.data(), GL_STATIC_DRAW); + + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ebo); + glBufferData(GL_ELEMENT_ARRAY_BUFFER, indices.size() * sizeof(unsigned int), indices.data(), GL_STATIC_DRAW); +} + void Model::DefineVAOLayout() { glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), (void*)0); diff --git a/src/Model.hpp b/src/Model.hpp index c2ec79c..0cdbb91 100644 --- a/src/Model.hpp +++ b/src/Model.hpp @@ -14,6 +14,7 @@ public: protected: void CreateVAO(); + void UpdateBufferData(); virtual void DefineVAOLayout(); protected: diff --git a/src/main.cpp b/src/main.cpp index 7057094..d6e7f98 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5,7 +5,6 @@ #include #include -#include "Model.hpp" #include "Orbital.hpp" #include "Shader.hpp" #include "Camera.hpp" @@ -55,40 +54,7 @@ int main(int argc, char** argv) return -1; } - Model triangle( - { - -1.0f, -1.0f, 1.0f, // Front Bottom, Left - -1.0f, 1.0f, 1.0f, // Front Top Left - 1.0f, 1.0f, 1.0f, // Front Top Right - 1.0f, -1.0f, 1.0f, // Front Bottom Right - - -1.0f, -1.0f, -1.0f, // Back Bottom, Left - -1.0f, 1.0f, -1.0f, // Back Top Left - 1.0f, 1.0f, -1.0f, // Back Top Right - 1.0f, -1.0f, -1.0f, // Back Bottom Right - }, - { - 0, 1, 2, - 0, 2, 3, - - 3, 2, 6, - 3, 6, 7, - - 4, 5, 1, - 4, 1, 0, - - 1, 5, 6, - 1, 6, 2, - - 4, 0, 3, - 4, 3, 7, - - 7, 6, 5, - 7, 5, 4 - } - ); - - Orbital orbital(4, 2); + Orbital orbital(2, 1); glm::mat4 modelMatrix = glm::mat4(1.0f); modelMatrix = glm::rotate(modelMatrix, glm::radians(90.0f), glm::vec3(1.0f, 0.0f, 0.0f));