fix: bind VAO before VBO

Failing to do this causes issues when trying to render multiple objects
This commit is contained in:
Cat Flynn 2023-08-02 00:59:46 +02:00
parent 829baa4b53
commit 31b58c48b2
1 changed files with 2 additions and 2 deletions

View File

@ -14,7 +14,7 @@ Triangle::Triangle(GLuint shaderProgram)
glBindVertexArray(_vao);
glBindBuffer(GL_ARRAY_BUFFER, _vbo);
glBufferData(GL_ARRAY_BUFFER, sizeof(_vertices), &_vertices[0], GL_STATIC_DRAW);
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);
@ -46,8 +46,8 @@ void Triangle::render(float time)
float timeValue = time;
glUniform1f(timeLocation, timeValue);
glBindBuffer(GL_ARRAY_BUFFER, _vbo);
glBindVertexArray(_vao);
glBindBuffer(GL_ARRAY_BUFFER, _vbo);
glDrawArrays(GL_TRIANGLES, 0, 3);
}