VBO, array indices and mapping

Hi!

I have a strange problem with VBO, making my openGL library to crash.

What I want to do is to map into the client’s address space an “array indices”.

Here is my code:
glGenBuffersARB(1,&data);
glBindBufferARB(GL_ARRAY_BUFFER_ARB,&data);
glBufferDataARB(GL_ARRAY_BUFFER_ARB, 1000, bufferData, GL_DYNAMIC_DRAW_ARB);

pData = glMapBufferARB(GL_ARRAY_BUFFER_ARB,GL_READ_WRITE_ARB);
// Everything is fine!
glUnmapBufferARB(GL_ARRAY_BUFFER_ARB);
glBindBufferARB(GL_ARRAY_BUFFER_ARB,0);

glGenBuffersARB(1,&index);
glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB,&index);
glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 100, bufferIndex, GL_DYNAMIC_DRAW_ARB);

// Here I have a crash
pIndices = glMapBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB,GL_READ_WRITE_ARB);
//

What am I doing wrong? Is there a bug in my driver?

Thanks

Originally posted by Evan Meakyl:
What am I doing wrong?

When you declare something like :
GLuint data;
the value of this data is ‘data’ and the pointer is ‘&data’, right ?

So, what you wrote here is correct :
glGenBuffersARB(1,&data);

But what you wrote here is NOT correct :
glBindBufferARB(GL_ARRAY_BUFFER_ARB,&data);

You may write instead :
glBindBufferARB(GL_ARRAY_BUFFER_ARB,data);

Note that you’ve done the same mistake in both vertex buffer objects. If it works for the first and crashes for the second, it’s just a matter of chance because both is incorrect.

[This message has been edited by vincoof (edited 09-03-2003).]

You’re right - but it is a typo mistake in the example I gave you (It’s not my real program…) :expressionless:

I found that when I do a
glGetBufferParameterivARB( GL_ELEMENT_ARRAY_BUFFER_ARB, GL_BUFFER_SIZE_ARB, &Size );
just after the glBufferDataARB, the size is 0…

But in the registry we can read:
“BufferDataARB returns no value and sets OUT_OF_MEMORY if the buffer could not be created”.

In this case, I think the buffer isn’t created, because its size is 0 which is a bit different from what I wanted… but I have no OpenGL error (I’ve checked).

Am I misinterpreting?

Aren’t you using the linux NVIDIA driver on GF2 or GF4MX ? I’ve seen exactly the same problem on this configuration.

Not really … I am using ATI openGL library on Windows, with my All In Wonder Radeon 32 Mo ddr.

For me, it was a bug in the driver, but if you’ve got the same result with another implementation, it looks like it’s us who are doing something wrong…

I have also found a program which uses VBO and GL_ELEMENT_ARRAY ( on Codesampler : http://www.codesampler.com/source/ogl_vertex_buffer_objects.zip) )
and I also have an error!

[This message has been edited by Evan Meakyl (edited 09-03-2003).]

This example works on my Radeon8500 with the latest drivers, under Win2000.
I get no error, no crash, no problem of any kind.

ok I will report to ATI… (I have the latest drivers installed)

Thanks a lot vincoof!

[This message has been edited by Evan Meakyl (edited 09-04-2003).]