Skip to content

Instantly share code, notes, and snippets.

@chrisforbes
Created August 3, 2015 20:07
Show Gist options
  • Save chrisforbes/e82eaa5fb2f2af0d6c51 to your computer and use it in GitHub Desktop.
Save chrisforbes/e82eaa5fb2f2af0d6c51 to your computer and use it in GitHub Desktop.
#define MAX_DRAW_SIZE 16384
void
draw_mesh(hw_mesh *m)
{
glBindVertexArray(m->vao);
GLuint indices = m->num_indices;
GLuint offset = 0;
while(indices > 3 * MAX_DRAW_SIZE) {
glDrawElements(GL_TRIANGLES, 3 * MAX_DRAW_SIZE, GL_UNSIGNED_INT, (GLvoid const *)offset);
offset += 3 * MAX_DRAW_SIZE * sizeof(GLuint);
indices -= 3 * MAX_DRAW_SIZE;
}
glDrawElements(GL_TRIANGLES, indices, GL_UNSIGNED_INT, (GLvoid const *)offset);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment