I’m trying to set up Vertex buffer objects in order to render a terrain, so would understand all functions about vbos…

I read specifications about glVertexPointer() but there are still some points that I don’t understand.

In an example Code I have seen this:

glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer);
glVertexPointer(3, GL_FIXED,0,NULL);

before drawing a VBO, and I don’t understand why I have to put NULL to the pointer ( last argument) in the function glVertexPointer.

In my opinion, it would be more logical to put the the pointer m_mesh.geometry ( the adress of vertices array) at the last argument of this function…

However, I have seen in the same code:

when we don’t want to use the VBO! So someone could explain me this?

thank you.

Read the VBO specs carefully. When using VBO you put the offset relative to the first element in the array, not a pointer. You can’t put a pointer just because VBO are sent to the graphic memory, so you can’t have its address back. If you don’t use VBO, then give the pointer but don’t bind the VBO before doing that.

Thank you for your reply, I better understand with your explanation…but this is what I have read about glVertexPointer:

glVertexPointer spec

They speak about a pointer for the last argument, but your explanation seems to be more logical…

It remains something that I dont understand if the last argument is not a pointer. Why in the case where I don’t use VBO, I have found a pointer towards the vertex array?

thank you.

It is a pointer, always, but in the case where you use VBO, it is seen as a memory offset.

About extensions, you really should read these ones instead of XFree ones (I don’t say they are good or bad but might not be always up to date):


Read the examples here:


stride is an offset but matches the offset between two consecutive values for the array. It is generally always 0 but if you use interleaved arrays.
The last argument of VertexPointer is always a pointer but as VBO buffers are set in the graphic memory and there’s a single VertexPointer function, when a VBO is bound it is seen as a memory offset (just giving 0 here will tell GL to start at the first element stored in memory for the bound VBO).

It remains something that I dont understand if the last argument is not a pointer. Why in the case where I don’t use VBO, I have found a pointer towards the vertex array?

Can you explain more what you want to mean here ? I don’t understand.

thank you very much! Now it is very clear.

In the last sentence I asked an explanation about the case:


But now I understand with your explanation, because in this case I don’t bind the VBO with:
glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer);

so the last argument of glVertexPointer is seen as a pointer on the vertex array that is not in the graphic memory.

You’re right.

Btw, use GL_FLOAT for the type of your vertex array elements but if you critically need something else. Floating points values are generally optimized.

If you can use VBO instead of ‘normal’ arrays, use them each time. They are generally available on all cards but very old ones.

Yes I use in fact GL_FLOAT.
This code line was taken from a tutorial and moreover I don’t know what is the tpye GL_FIXED…

And I intend to use the VBO each time it is possible.

Thank you very much for your help!