chore: delete redundant class
chore: remove redundant include chore: remove redundant declaration
This commit is contained in:
parent
f22fcee399
commit
0ce3d54139
|
@ -27,7 +27,6 @@ endif()
|
|||
add_executable(${PROJECT_NAME}
|
||||
src/hello.cpp
|
||||
src/io.cpp
|
||||
src/triangle.cpp
|
||||
src/icosphere.cpp
|
||||
src/gfx.cpp
|
||||
)
|
||||
|
|
|
@ -44,7 +44,6 @@
|
|||
#include <string>
|
||||
|
||||
#include "gfx.hpp"
|
||||
#include "triangle.hpp"
|
||||
#include "icosphere.hpp"
|
||||
|
||||
#include <cmath>
|
||||
|
@ -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);
|
||||
|
|
|
@ -1,33 +0,0 @@
|
|||
#include "triangle.hpp"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
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);
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include <GL/glew.h>
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
class Triangle
|
||||
{
|
||||
public:
|
||||
Triangle();
|
||||
void render(float time);
|
||||
|
||||
~Triangle();
|
||||
|
||||
private:
|
||||
GLuint _vbo;
|
||||
GLuint _vao;
|
||||
|
||||
std::vector<float> _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);
|
||||
};
|
Loading…
Reference in New Issue