View Full Version : Vertex Array in GL
05-14-2001, 06:39 AM
I got a question and really want the answer.
when glArrayElement , my vertex array is translated to GL . but how ?
for example, I got 1,000,000 vertex,
all in :
float v[1000000*3] ;
when I use glEnableClientState(GL_VERTEX_ARRAY)
then use glVertexPointer(...,..v ),Does it only give OPENGL the pointer "v" ?
or translate all vertex (1000000*3 floats)
to OPENGL ?
05-14-2001, 06:55 AM
When you call glVertexPointer(..., v) it gives OpenGL the address of your data. You then call one of glArrayElement(), glDrawElements(), glDrawRangeElements() or glDrawArrays() to draw your data. OpenGL uses the information in those functions to pull your data from main memory onto the graphics card for rendering. It doesn't pull all those floats onto the card - only the vertices that you specify with the 4 functions above.
Hope that helps.
[This message has been edited by ffish (edited 05-14-2001).]
05-14-2001, 07:12 AM
Thank you !it's very helpful.
in Q3's pipe , ID said they only use
1024 vertex buffer per DrawElement .
why not put all vertices in one
float Q3VertexBuffer[allvertsInBSP*3] ,
then caculate elems index to call
DrawElement only once in the BSP rendering?
05-14-2001, 07:45 AM
They probably also do put all their vertices in one bit list.
But there's a breakeven point for glDraw* - i.e that after some point, one of the processors sits idle.
You need to make them all work at the same time - as much as possible.
05-14-2001, 10:11 AM
and they cant render the whole scene with one function call, they have to switch textures http://www.opengl.org/discussion_boards/ubb/wink.gif ( and very much, up to 4 passes per triangle.. ) and like that there is no chance for doing it at once..
on the other hand, i think they use CVA, too.. and there you say how big the array is, and it then put the whole to the gpu and does the transformation&lighting part on the vertices, then it simply accesses the preprocessed vertices and can like that gain some speed ( ok nvidia hates CVA and like that there you should use VAR's instead.. blahblah http://www.opengl.org/discussion_boards/ubb/wink.gif )
05-14-2001, 10:39 AM
Quake locks the vertex array. This is to work around a previous big hole in the GL API: nowhere do you tell GL how big your array is; it's implicit in the call to DrawArrays or the actual index values in DrawElements. This make some efficient implementations hard to create; they'd have to scan your index array on demand to figure out which range is actually used (min/max). DrawRangeElements was an addition to make this more efficient, but didn't fix the problem for multi-pass rendering, which is why the LockArrays extension was added.
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.