From 0ce3d541390ed881091ba2c9088f75b6406c8dc4 Mon Sep 17 00:00:00 2001 From: Cat Flynn Date: Thu, 3 Aug 2023 00:57:26 +0200 Subject: [PATCH] chore: delete redundant class chore: remove redundant include chore: remove redundant declaration --- CMakeLists.txt | 1 - src/hello.cpp | 5 +---- src/triangle.cpp | 33 --------------------------------- src/triangle.hpp | 28 ---------------------------- 4 files changed, 1 insertion(+), 66 deletions(-) delete mode 100644 src/triangle.cpp delete mode 100644 src/triangle.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 2ab45ef..4571f45 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,7 +27,6 @@ endif() add_executable(${PROJECT_NAME} src/hello.cpp src/io.cpp - src/triangle.cpp src/icosphere.cpp src/gfx.cpp ) diff --git a/src/hello.cpp b/src/hello.cpp index 1cb19ce..9cb92fe 100644 --- a/src/hello.cpp +++ b/src/hello.cpp @@ -44,7 +44,6 @@ #include #include "gfx.hpp" -#include "triangle.hpp" #include "icosphere.hpp" #include @@ -136,8 +135,7 @@ int main() return -1; GLuint shaderProgram = compileShaderProgram(); - Triangle triangle; - Icosphere sphere(0); + Icosphere sphere(2); // Wireframe glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); @@ -157,7 +155,6 @@ int main() updateModelViewProjectionMatrix(shaderProgram, time); // Render objects - triangle.render(time); sphere.render(time); glfwSwapBuffers(window); diff --git a/src/triangle.cpp b/src/triangle.cpp deleted file mode 100644 index 84b5223..0000000 --- a/src/triangle.cpp +++ /dev/null @@ -1,33 +0,0 @@ -#include "triangle.hpp" - -#include - -Triangle::Triangle() -{ - glGenVertexArrays(1, &_vao); - glGenBuffers(1, &_vbo); - - glBindVertexArray(_vao); - - glBindBuffer(GL_ARRAY_BUFFER, _vbo); - glBufferData(GL_ARRAY_BUFFER, _vertices.size() * sizeof(float), &_vertices[0], GL_STATIC_DRAW); - - glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), (void*)0); - glEnableVertexAttribArray(0); - - glBindBuffer(GL_ARRAY_BUFFER, 0); - glBindVertexArray(0); -} - -void Triangle::render(float time) -{ - glBindVertexArray(_vao); - glBindBuffer(GL_ARRAY_BUFFER, _vbo); - glDrawArrays(GL_TRIANGLES, 0, 3); -} - -Triangle::~Triangle() -{ - glDeleteVertexArrays(1, &_vao); - glDeleteBuffers(1, &_vbo); -} \ No newline at end of file diff --git a/src/triangle.hpp b/src/triangle.hpp deleted file mode 100644 index 62661ab..0000000 --- a/src/triangle.hpp +++ /dev/null @@ -1,28 +0,0 @@ -#pragma once - -#include - -#include -#include - -class Triangle -{ -public: - Triangle(); - void render(float time); - - ~Triangle(); - -private: - GLuint _vbo; - GLuint _vao; - - std::vector _vertices = - { - -0.5, -0.5, 0.0, // left - 0.5, -0.5, 0.0, // right - 0.0, 0.5, 0.0 // top - }; - - GLint getShaderUniformLocation(const std::string& uniformName); -}; \ No newline at end of file