Created
September 28, 2014 20:27
-
-
Save terryjsmith/ffb678e3d39aee51bf95 to your computer and use it in GitHub Desktop.
Evolution RenderSystem 1.1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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