PDA

View Full Version : VBO: gl*Pointer invalid after dereferencing?



stephanh
01-16-2004, 03:35 AM
Hi,

in order to speed up the vertexbuffer wrapper we use i tried to reduce the calls to gl*Pointer as suggested by the nvidia whitepaper on VBOs. But seems that it isn't sufficient to do the offset setup via the gl*Pointer calls once for a VBO.
When doing multipass rendering with VBO, do i have to re-setup the VBO memory via gl*Pointer?
Do the offsets become invalid after dereferencing/rendering?

regards,
Stephan

Relic
01-16-2004, 05:18 AM
Code please.
gl*Pointer needs to be called to associate a vertex attribute array with a VBO. Means if you have called glBindBuffer for the first time you have not associated any gl*Pointer with that buffer and must call gl*Pointer to set offsets into that buffer.
If you have multiple VBOs, offsets are not reassociated until you call gl*Pointer.
This is designed that way to be able to use multiple VBOs to store different vertex attribute arrays. E.g. you can keep the static ones in a different buffer that way and only update the data in the dynamic attrib array.

[This message has been edited by Relic (edited 01-16-2004).]

stephanh
01-16-2004, 10:07 AM
Originally posted by Relic:
Code please.
gl*Pointer needs to be called to associate a vertex attribute array with a VBO. Means if you have called glBindBuffer for the first time you have not associated any gl*Pointer with that buffer and must call gl*Pointer to set offsets into that buffer.

ok. that's obvious.


If you have multiple VBOs, offsets are not reassociated until you call gl*Pointer.
This is designed that way to be able to use multiple VBOs to store different vertex attribute arrays. E.g. you can keep the static ones in a different buffer that way and only update the data in the dynamic attrib array.

That means, since the offset are not associated to the bound buffer, the offsets are valid as long as i don't bind a new buffer?

Ostsol
01-16-2004, 10:15 AM
The offsets are accociated with the buffer that was bound with the offsets were defined. My terrain renderer, for example, uses two buffers: one that contains texture coordinates and 2d vertex coordinates (representing the x and y coordinates of each point on the terrain), and another buffer that contains the height value for each vertex (stored as a 1d texture coordinate), the vertex colours, and the vertex normals. (The 2d vertex coordinate is combined with the height value in the a vertex program.) The first buffer needs only to be bound and the offsets defined once each frame, regardless of how many consecutive terrain segments I render.