PDA

View Full Version : VBO problem :(



Asshen
10-08-2003, 07:01 AM
Hello.

I've been messing with VBO's http://www.opengl.org/discussion_boards/ubb/smile.gif

First I use VBO to render the static scene data.
Second I try using normal vertex arrays for the dynamic objects.

But they don't show...
When I use glDeleteBuffersARB before using my normal vertex arrays, then they do render just fine....
Rendering using immediate mode works fine too.

Is there a way to make them show up without having to call glDeleteBuffers for every frame ? This is a huge performance drop of course http://www.opengl.org/discussion_boards/ubb/tongue.gif
Isn't there something like glUnBufferARB ???
Or how is it done ?

Thanks.
Kris.

Asshen
10-08-2003, 07:13 AM
Maybe this could be helpful:




void CKGLLevel::RenderLevelVBO(void)
{
if(!VBOactive) GenerateVBO();

EnableArrays();

//vertex buffer
glBindBufferARB(GL_ARRAY_BUFFER_ARB, vbuffer);
glVertexPointer(3, GL_FLOAT, 0, BUFFER_OFFSET(0));

//normal buffer
glBindBufferARB(GL_ARRAY_BUFFER_ARB, nbuffer);
glNormalPointer(GL_FLOAT, 0, BUFFER_OFFSET(0));

//texcoord buffer
glBindBufferARB(GL_ARRAY_BUFFER_ARB, tbuffer);
glTexCoordPointer(2, GL_FLOAT, 0, BUFFER_OFFSET(0));


//draw it damnit http://www.opengl.org/discussion_boards/ubb/tongue.gif
for(int h=0; h<QT_Height; h++)
{
for(int w=0; w<QT_Width; w++)
{
meshCursor = QT[w][h].Start;
while(meshCursor->next)
{
meshCursor=meshCursor->next;

TexDB->BindTexture(meshCursor->TexID);
glDrawElements(GL_TRIANGLES, meshCursor->IAsize, GL_UNSIGNED_INT, meshCursor->IA);
}
}
}


//draw dynamic objects
for(h=0; h<QT_Height; h++)
{
for(int w=0; w<QT_Width; w++)
{
dynObjIDCursor = QT[w][h].DynObjIDs;
while(dynObjIDCursor->next)
{
dynObjIDCursor = dynObjIDCursor->next;

RenderDynObj(dynObjIDCursor->ID);
}
}
}

DisableArrays();
}

void CKGLLevel::RenderDynObj(int ID)
{
dynObjCursor = DynObjects;
while(dynObjCursor->next)
{
dynObjCursor = dynObjCursor->next;
if(dynObjCursor->ID == ID)
{
glPushMatrix();
glTranslatef(dynObjCursor->translation[0],dynObjCursor->translation[1],dynObjCursor->translation[2]);
//texture
TexDB->BindTexture(dynObjCursor->TexID);

//if(!glIsEnabled(GL_VERTEX_ARRAY)) {Message("Arrays not enabled");exit(0);}
//texcoord buffer
glTexCoordPointer(2, GL_FLOAT, 0, dynObjCursor->TexcData);
//normal buffer
glNormalPointer(GL_FLOAT, 0, dynObjCursor->NormData);
//vertex buffer
glVertexPointer(3, GL_FLOAT, 0, dynObjCursor->VertData);

//draw
glDrawArrays(GL_TRIANGLES, 0, dynObjCursor->amount);
/*
int nv=0;
int t=0;
glBegin(GL_TRIANGLES);
for(int i=0; i<dynObjCursor->amount;i++)
{
glTexCoord2f(dynObjCursor->TexcData[t+0], dynObjCursor->TexcData[t+1]);
t+=2;
glNormal3f( dynObjCursor->NormData[nv+0], dynObjCursor->NormData[nv+1], dynObjCursor->NormData[nv+2] );
glVertex3f( dynObjCursor->VertData[nv+0], dynObjCursor->VertData[nv+1], dynObjCursor->VertData[nv+2] );
nv+=3;
}
glEnd();
*/
glPopMatrix();
}
}
}

TheSillyJester
10-08-2003, 07:30 AM
glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
before switching from VBO to VA.
Else you work with the last binded VBO.

Asshen
10-08-2003, 07:42 AM
Whoooooooooohoooooooooooooooo http://www.opengl.org/discussion_boards/ubb/tongue.gif
Thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you ...

Oops, didn't mean to spam http://www.opengl.org/discussion_boards/ubb/smile.gif
I've been looking for a solution almost all day http://www.opengl.org/discussion_boards/ubb/smile.gif

Thank you very much.
It works now http://www.opengl.org/discussion_boards/ubb/smile.gif

Kris