Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Gammastrahler

GL_VERTEX_ARRAY_RANGE_NV

This topic is 5933 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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!

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
I had the same questions when first reading about VAR.
You have to see the VAR as one big chunk of memory, like you would do a

char *ptr=(char*)malloc(MANY_MEGS);

You can now use this memory for your vertices, colors, texcoords, normals and what ever. You can of course store multiple objects inside the VAR. Before rendering them you have to call glVertexPointer,glTexCoordPointer etc as usual (but this time pointing to adresses inside the VAR). You can even use CVA´s lock and unlock (although its told that it won´t give speedup in conjunction with VAR). One Exception are the indices which should be stored in conventional system memory.

If you only have allocated one VAR, you need to call

glVertexArrayRangeNV(size,ptr);
glEnableClientState(GL_VERTEX_ARRAY_RANGE_NV);

only once after allocating the memory. This way you tell OpenGL "Here´s a big chunk of special allocated AGP/video memory, I promise that future calls to glVertexPointer and its friends will all point somewhere inside this memory range". OpenGL will then know that it can access the vertex data in a more optimal fashion as it could when using usual client-memory.
The enabled vertex array range will also alter the semantic of glDrawElements. From now on glDrawElements will return immediately, even if not all the vertexdata got pulled by the gfx card. You have to be careful when overwriing vertex-data that was given to ogl recently. In order to be sure, use synchronization via glFenceNV().

skynet

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Of course you should not use malloc, that would be complete nonsense!

I just wanted to show that the VAR is just like a big chunk of usual memory, but with special properties. If I did more confusion than bringing clarity, I apologize :-)

skynet

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!