Created
April 20, 2012 04:24
-
-
Save jzrake/2425995 to your computer and use it in GitHub Desktop.
OpenGL VBO example
This file contains 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 draw_vbo() | |
{ | |
GLuint vbo,ibo; | |
GLfloat verts[8][3] = {{0.0, 0.0, 0.0}, | |
{0.0, 0.0, 0.1}, | |
{0.0, 0.1, 0.0}, | |
{0.0, 0.1, 0.1}, | |
{0.1, 0.0, 0.0}, | |
{0.1, 0.0, 0.1}, | |
{0.1, 0.1, 0.0}, | |
{0.1, 0.1, 0.1}}; | |
GLubyte ind[8] = {0,3,6,9,12,15,18,21}; | |
glGenBuffers(1, &vbo); | |
glGenBuffers(1, &ibo); | |
glBindBuffer(GL_ARRAY_BUFFER, vbo); | |
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo); | |
glBufferData(GL_ARRAY_BUFFER, 24*sizeof(GLfloat), verts, GL_STATIC_DRAW); | |
glBufferData(GL_ELEMENT_ARRAY_BUFFER, 8*sizeof(GLubyte), ind, | |
GL_STATIC_DRAW); | |
glEnableClientState(GL_VERTEX_ARRAY); | |
glVertexPointer(3, GL_FLOAT, sizeof(GLfloat), 0); | |
glDrawElements(GL_LINE_STRIP, 8, GL_UNSIGNED_BYTE, 0); | |
glDisableClientState(GL_VERTEX_ARRAY); | |
glDeleteBuffers(1, &vbo); | |
glDeleteBuffers(1, &ibo); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment