Skip to content

Instantly share code, notes, and snippets.

@agrif
Created December 30, 2012 01:52
Show Gist options
  • Select an option

  • Save agrif/4410502 to your computer and use it in GitHub Desktop.

Select an option

Save agrif/4410502 to your computer and use it in GitHub Desktop.
/* create and populate a VBO and VAO */
glGenBuffers(1, &vbo);
glGenVertexArrays(1, &vao);
glBindVertexArray(vao);
glBindBuffer(GL_ARRAY_BUFFER, vbo);
glBufferData(GL_ARRAY_BUFFER, sizeof(OILVertex) * vertices_length, vertices, GL_STATIC_DRAW);
glVertexPointer(3, GL_FLOAT, sizeof(OILVertex), (void *)offsetof(OILVertex, x));
glTexCoordPointer(2, GL_FLOAT, sizeof(OILVertex), (void *)offsetof(OILVertex, s));
glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(OILVertex), (void *)offsetof(OILVertex, color));
/* draw */
glDrawElements(GL_TRIANGLES, indices_length, GL_UNSIGNED_INT, indices);
/* free our VBO and VAO */
glDeleteVertexArrays(1, &vao);
glDeleteBuffers(1, &vbo);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment