• ### Popular Now

• 12
• 12
• 9
• 10
• 13

#### Archived

This topic is now archived and is closed to further replies.

# ARB Vertex Buffer Objects and textures

This topic is 5370 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I'm having some problems getting VBO's to work. Whenever I try to use a texture it crashes. I put the vertex data in a static draw buffer using glBindBufferARB and glBufferDataARB and I use glDrawElements to draw it. My array of indicies is in system memory, as is my tex coord array. It works fine when I don't use textures although I don't notice any speed increase. my code basically looks like this, am I do something wrong?
#define BUFFER_OFFSET(i) ((char *)NULL + (i))

glBindBufferARB(GL_ARRAY_BUFFER_ARB, 1);
glBufferDataARB(GL_ARRAY_BUFFER_ARB, width*height*3*sizeof(GLfloat), vertexData, GL_STATIC_DRAW_ARB);

while (drawing)
{
glBindBufferARB(GL_ARRAY_BUFFER_ARB, 1);
glVertexPointer(3, GL_FLOAT, 0, BUFFER_OFFSET(0));
glTexCoordPointer(2,GL_FLOAT,0, texCoordData);

glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);

glDrawElements(GL_TRIANGLE_STRIP, numElements, GL_UNSIGNED_INT, indexData);

glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
}

Sorry the code is so bunched up, I cant seem to put blank lines in it.

##### Share on other sites
You should add a glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); before pointing the texcoords, since that tells opengl that now it should use system memory and not VBO:s

##### Share on other sites
ah that makes sense. Thanks for the help.