Skip to content

Instantly share code, notes, and snippets.

@terryjsmith
Created September 28, 2014 20:27
Show Gist options
  • Save terryjsmith/ffb678e3d39aee51bf95 to your computer and use it in GitHub Desktop.
Save terryjsmith/ffb678e3d39aee51bf95 to your computer and use it in GitHub Desktop.
Evolution RenderSystem 1.1
void RenderSystem::Update(float elapsed) {
// Loop through all of our renderables and render them
for(int i = 0; i < m_bucketSize; i++) {
if(m_components[i]) {
// Cast to a Renderable we can use
Renderable* component = (Renderable*)m_components[i];
// Bind the vertex attribute object, which will bind the buffers and attributes for us
glBindVertexArray(component->vertexAttribObject);
// Attach the shader program
glUseProgram(component->program);
// Either draw from vertex array or indices if defined
if(component->indexBuffer == 0)
glDrawArrays(GL_TRIANGLES, 0, component->numTriangles * 3);
else
glDrawElements(GL_TRIANGLES, component->numTriangles * 3, GL_UNSIGNED_INT, 0);
glBindVertexArray(0);
glUseProgram(0);
}
}
// Swap OpenGL buffers
glfwSwapBuffers(m_window);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment