Skip to main content
gamedev.net
🔒 Locked

GL_VERTEX_ARRAY_RANGE_NV

Started by Gammastrahler Apr 19, 2002 at 4:55 AM 6 replies 950+ views
Original Post
Gammastrahler
Gammastrahler
hello everybody, i have read a tutorial about using the VAR NV extension. so i know i should only allocate one memory chunk. but how can i use more than one buffer? i need a vertex, a texture, a normal, and a color buffer, instead of just only a vertex buffer! how can i realise this, the only way i can think of is splitting the memory chunk into four pices? or it is even unrealisable? any help would be welcome! thanks, gammastrahler!
Yann L
Yann L
Generally, the AP is right, but:

never use standard malloc on VAR. It won''t give you any speedup, and the allocation of the range might fail, dpepending on drivers. *Always* use wglAllocateMemoryNV. The floating point parameters should be (0,0,0.5) to get AGP memory, or (0,0,1) to get video memory.

CVA''s will be totally ignored, if called on VAR.

As said, you need to manage your VAR memory chunk yourself. Just subdivide it into smaller pieces, for your different arrays. Don''t forget to adjust gl*Pointer() calls accordingly.

/ Yann
Gammastrahler
Gammastrahler
ok thanks, but one question left is:

if i call

glVertexPointer(3, GL_FLOAT, 0, data);

and then

glTexCoordPointer(2, GL_FLOAT, 0, data+startOfTexCoords);

only the start location of the data is known, not the
length!

how should i handle this?
Yann L
Yann L
OpenGL does not need to know the length when you set the starting pointers. It just uses the indexed offsets from your glDrawElements() call, starting with the memory address you gave him.

VAR explicitely needs the global length of your VAR buffer, but you already defined that in the glVertexArrayRangeNV() call.

So, your two gl*Pointer() calls are absolutely correct, and will work. Just make sure, your offsets (plus the length of the contained data) never pass over the end of the allocated VAR memory range, or you will get undefined vertices.

/ Yann


[edited by - Yann L on April 19, 2002 12:23:33 PM]
sbennett
sbennett
Personally, I would interleave the arrays, so that all the data for each vertex is together, using glInterleavedArrays. That way, it really doesn''t matter how many vertices you have, as long as they all fit in the allocated memory.
Salec
Salec
When using the VAR NV extension, people generally tend to use the NV FENCE extension as well. This is because it allows to you use multiple chunks rather than one chunk. The NVidia developer site has a very nice presentation on using the two together.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.