I am working with VBO's for a new project, I want to use flexible maaped VBO's which are similar to the Direct3D Lock() Unlock() mechanism. I have written some code below, which Maps and Unmaps the vertex data on the fly in the same way as the D3D lock, but it overwrites over the previous VBO vertex data... Here is the rough brief example of what i'm implementing...

//MAPPING FUNCTION MEANT TO WORK LIKE LOCK FUNCTION IN DIRECT3D, BUT SHORTENED TO MAKE IT ONLY WRITE TO VERTEX BUFFER
void* MapBuffer()
{
glBindBufferARB(GL_ARRAY_BUFFER_ARB,ID);
return glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY_ARB);
}

Now if I render and bind VBOs, the only vertex buffer that renders is the second binded vertex mesh during both instances... Could anyone give me advice on how to map it the same way as D3D.

Jan

12-21-2008, 07:04 AM

Hm, i just quickly glanced at it, but one thing that could be a problem, is that you call glVertexPointer as the first thing to set up your arrays. Make it the LAST function to be called, most drivers do all the vertex array setup in that function call, so maybe that's the reaseon, that it only works properly the second time.

Jan.

dletozeun

12-21-2008, 03:14 PM

I did not look deeply in your code, but I do not understand why you see something with the 2nd VBO. Does this one uses texture mapping?
I have seen something that is wrong to me, you use texture coordinates buffer objects but you do not set which vertex array client state to be modified by glTexCoordPointer. You have to call glClientActiveTexture, this way, before drawing something: