faster method?
i found on http://jdobry.webpark.cz/opengl/opengl_maximum_performance.html#cva
a programm which test different methods for rendering triangles.
1)Classic : with glBegin(GL_TRIANGLES) ...
2)Triangle Strips
3)Vertex Arrays & Compiled Vertex Array Extension
4)Draw Elements - Triangles : utilise la fct glDrawElements();
a)vertex array locked
b)vertex array non locked
5)Draw Elements - Triangle Strips : idem
a)vertex array locked
b)vertex array non locked
for him it''s 5)a which is the VERY best but for me it''s the VERY worst (but he has a Nvidia Riva TNT graphic card and he use glLockArraysEXT() and glUnlockArraysEXT to lock and unlock array IS IT FOR THAT?)
For me the best method is 4)a. Will be the case on the most graphic card? (exept the Nvidia)
I have a matrix of 512*512 points (x,y,z) that i have to render as a 3D object
so if 4)a is really the best method, have i to do : (???)
1)ennabeling vertex array
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY); //for light
2)store with
glVertexPointer(3, GL_FLOAT, 0, Coords);
glNormalPointer(3, GL_FLOAT,GL_UNSIGNED_BYTE, 0, Normals);
(where Coord and Normals are vectors of 512*512
typedef struct {
double x,y,z;
} XYZ; is it good? )
then can i do
3)fill an array of (511*511*2)*3 values where i say 3 by 3 the indices of vertex for each triangle to draw.
EX.: indices[1,2,3,4,5,6,7,8,9....] ->draw triangle with vertex 1,2 and 3, draw triangle with vertex 4,5 and 6 ...
4)and then do
glLockArraysEXT(0, count); //lock the 2 arrays
glDrawElements(GL_TRIANGLES, 511*511*2*3, GL_UNSIGNED_BYTE, indices); //draw all the triangles
glUnlockArraysEXT; //unlock the 2 arrays
glDisableClientState(GL_COLOR_ARRAY); //tout a la fin
glDisableClientState(GL_NORMAL_ARRAY);
Can you response to all my question and tell me what''s wrong?
Thanks in advance.
I got that from NVIDIAs OGL Performance FAQ, so it´s only for NV cards I´d say
.
1. DrawElements/DrawArrays Using wglAllocateMemoryNV(size,0,0,1)
2. DrawElements/DrawArrays Using wglAllocateMemoryNV(size,0,0,.5)
3. Display Lists
4. DrawElements using Compiled Vertex Arrays (glLockArraysEXT)
5. DrawElements and DrawArrays using Vertex Arrays with Common Data Formats
6. Immediate Mode
7. All Other Vertex Arrays
http://developer.nvidia.com/view.asp?IO=ogl_performance_faq (pretty good read)
Diapolo

1. DrawElements/DrawArrays Using wglAllocateMemoryNV(size,0,0,1)
2. DrawElements/DrawArrays Using wglAllocateMemoryNV(size,0,0,.5)
3. Display Lists
4. DrawElements using Compiled Vertex Arrays (glLockArraysEXT)
5. DrawElements and DrawArrays using Vertex Arrays with Common Data Formats
6. Immediate Mode
7. All Other Vertex Arrays
http://developer.nvidia.com/view.asp?IO=ogl_performance_faq (pretty good read)
Diapolo
March 11, 2002 08:16 AM
ioda, triangle strips should be faster on most hardware, since there are less vertexes to be pushed around the GPU.
Which graphics card are you using that is getting different results?
Which graphics card are you using that is getting different results?
you say to use glDrawElements(GL_TRIANGLE_STRIP, 511*511*2*3, GL_UNSIGNED_BYTE, indices);
instead of
glDrawElements(GL_TRIANGLES, 511*511*2*3, GL_UNSIGNED_BYTE, indices); ?
?
i have a voodoo3.
normaly triangle strip is faster but the test program says no.
The test prog is perhaps false : it''s not a commercial and certified work.
the rest of my method(first message) is good?
to lock the vertex array is it the good function?
instead of
glDrawElements(GL_TRIANGLES, 511*511*2*3, GL_UNSIGNED_BYTE, indices); ?
?
i have a voodoo3.
normaly triangle strip is faster but the test program says no.
The test prog is perhaps false : it''s not a commercial and certified work.
the rest of my method(first message) is good?
to lock the vertex array is it the good function?
March 11, 2002 08:53 AM
quote:
Original post by ioda
you say to use glDrawElements(GL_TRIANGLE_STRIP, 511*511*2*3, GL_UNSIGNED_BYTE, indices);
instead of
glDrawElements(GL_TRIANGLES, 511*511*2*3, GL_UNSIGNED_BYTE, indices); ?
?
Well, if your triangles are in strips, then you should have less indicies in the call, since strips share vertices. So a glDrawElements(GL_TRIANGLE_STRIP, 511*511*2*3, GL_UNSIGNED_BYTE, indices); is actually drawing _more_ triangles than glDrawElements(GL_TRIANGLES, 511*511*2*3, GL_UNSIGNED_BYTE, indices); is.
For a fair test, you need to something like 511*511*2*2+1 in the strips call.
This may be a moot point if you can''t easily make strips from your vertices. Quake3 just uses GL_TRIANGLES, for instance.
quote:
i have a voodoo3.
normaly triangle strip is faster but the test program says no.
The test prog is perhaps false : it''s not a commercial and certified work.
I kind of suspected you had a voodoo. The voodoo3 is kind of an oddball card. It has different results than a lot of other cards on the market. You have to watch out for this sort of thing, specially with voodoo or kyro cards.
quote:
the rest of my method(first message) is good?
to lock the vertex array is it the good function?
Yep, that''s the function for locking and unlocking the vertex array.
thanks
yes for the number of triangle in
glDrawElements(GL_TRIANGLE_STRIP.. ) i forgot to change the number of triangles.
i have a voodoo3 but the programm i''m trying to do has to work on various 3D card so if glDrawElements(GL_TRIANGLE_STRIP.. ) is the best method in general, i will use it.
In the array indice (to say how to do triangle strip), opengl will see when the first strip(first line) is finished and when the second begain(second line)?
yes for the number of triangle in
glDrawElements(GL_TRIANGLE_STRIP.. ) i forgot to change the number of triangles.
i have a voodoo3 but the programm i''m trying to do has to work on various 3D card so if glDrawElements(GL_TRIANGLE_STRIP.. ) is the best method in general, i will use it.
In the array indice (to say how to do triangle strip), opengl will see when the first strip(first line) is finished and when the second begain(second line)?
March 11, 2002 09:11 AM
quote:
Original post by ioda
In the array indice (to say how to do triangle strip), opengl will see when the first strip(first line) is finished and when the second begain(second line)?
No, openGL is going to treat that as one long strip. If you want to break it up, you will need to use multiple glDrawElements calls. If you''ve got lots of small strips, it may actually be faster to use GL_TRIANGLES.
in my case, i have 511 strips (because matrix of 512*512)(i made 2 triangles from each square of 4 consecutive points)
I do :
1) one call to glDrawElements(GL_TRIANGLE_STRIP, ..)
or 2)511 call to glDrawElements(GL_TRIANGLE_STRIP, ..)
or 3)one call to glDrawElements(GL_TRIANGLE,..)
or 4)other?
in the case of 1) is the best, is there an order to define the strips in the array indices? (beginning of first line -> end of first line then beginning of second line -> end of second line....
or beginning of first line -> end of first line then end of second line -> beginning of second line then beginning of third line ->....
?
I do :
1) one call to glDrawElements(GL_TRIANGLE_STRIP, ..)
or 2)511 call to glDrawElements(GL_TRIANGLE_STRIP, ..)
or 3)one call to glDrawElements(GL_TRIANGLE,..)
or 4)other?
in the case of 1) is the best, is there an order to define the strips in the array indices? (beginning of first line -> end of first line then beginning of second line -> end of second line....
or beginning of first line -> end of first line then end of second line -> beginning of second line then beginning of third line ->....
?
March 11, 2002 10:12 AM
quote:
Original post by ioda
in my case, i have 511 strips (because matrix of 512*512)(i made 2 triangles from each square of 4 consecutive points)
I do :
1) one call to glDrawElements(GL_TRIANGLE_STRIP, ..)
or 2)511 call to glDrawElements(GL_TRIANGLE_STRIP, ..)
or 3)one call to glDrawElements(GL_TRIANGLE,..)
or 4)other?
in the case of 1) is the best, is there an order to define the strips in the array indices? (beginning of first line -> end of first line then beginning of second line -> end of second line....
or beginning of first line -> end of first line then end of second line -> beginning of second line then beginning of third line ->....
?
OpenGL has no way to know where you think a strip is beginning or ending, so there''s no way to define a set of strips in one array.
So you''re drawing a big square, like a terrain or something? If you don''t want to mess around, you can just do 2), 511 glDrawElement calls.
Or you could change your indexes around so that you are drawing one big strip. If you''re doing a square patch, you can do this by sweeping back and forth. That is, row one goes right, row 2 goes left, etc. There''s a little bit of funny ordering involved in turning the corners, but you could work it out.
However, if you _are_ doing a terrain, I''d stick with the 511 strips for now, or even GL_TRIANGLES. Chances are you''ll soon find that big terrains are not fast enough this way, and you''ll be working on terrain LOD. And it''s difficult to use strips with level of detail.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement