Skip to main content
gamedev.net
🔒 Locked

VBO problem

Started by Fear411 Mar 4, 2009 at 12:57 PM 1 replies 700+ views
Original Post
Fear411
Fear411
I implemented VBO in my Engine. But when i draw them they look very weird. Here is a Screen: This is the generation of the VBO

// Generate And Bind The Vertex Buffer
Graphics::CGLExtManager::glGenBuffers(1, &mesh->VBOIDv);
Graphics::CGLExtManager::glBindBuffer(GL_ARRAY_BUFFER, mesh->VBOIDv);
Graphics::CGLExtManager::glBufferData(GL_ARRAY_BUFFER, mesh->getVertexCount()*sizeof(Graphics::SVertex), mesh->getVertices()[0].position, GL_STATIC_DRAW);

// Generate And Bind The Texture Coordinate Buffer
Graphics::CGLExtManager::glGenBuffers(1, &mesh->VBOIDt);
Graphics::CGLExtManager::glBindBuffer(GL_ARRAY_BUFFER, mesh->VBOIDt);
Graphics::CGLExtManager::glBufferData(GL_ARRAY_BUFFER, mesh->getVertexCount()*sizeof(Graphics::SVertex), mesh->getVertices()[0].uv, GL_STATIC_DRAW);
And so i am drawing them:

glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);

CGLExtManager::glBindBuffer(GL_ARRAY_BUFFER, entity->rendermesh->VBOIDv);
glVertexPointer( 3, GL_FLOAT, 0, (char *) NULL );
CGLExtManager::glBindBuffer(GL_ARRAY_BUFFER, entity->rendermesh->VBOIDt);
glTexCoordPointer( 2, GL_FLOAT, 0, (char *) NULL );

glDrawArrays(GL_TRIANGLES, 0, entity->rendermesh->getVertexCount());

glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
Can anyone help?
Fear411
Fear411
anyone?
Ashaman73
Ashaman73
What is the size of Graphics::SVertex ?
In both of your uploads you load the same vertex size but use different sizes while specifying the pointers with glVertexPointer( 3 ...) and glTexCoordPointer( 2 ... ).

If your SVertex just consists of 3 floats this would result in corrupted texture coords, if it consists of 4 floats it will results in corrupted position. Your screenshot looks like the latter one.

--
Ashaman

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.