question triangle strip vertex array and display list
i have a matrix of 512*512 points in 3d.
In order to render the 3d surface represented with the points in the matrix i would like to draw 2 triangles on each square of consecutive points. (511*511*2 triangles)
To speed up this i would like to use (compiled?)vertex array, triangle strip.
Is it possible to combine vertex array and triangle strip? (and is it good?)
i have to put light (and so normals) and to rotate... the 3d object.
thx for response
Edited by - ioda on March 6, 2002 7:06:28 PM
I think that the solution involves the following functions:
I've never used them, so I can't tell you how. I'm going to read the my Win32 SDK Reference file. If I figure it out, I'll share the answer with you. If not, uh, don't hold your breath.
[EDIT]
You also need to call
Edited by - smart_idiot on March 6, 2002 1:26:33 PM
void glVertexPointer(GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer);void glNormalPointer(GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); void glTexCoordPointer(GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer);void glDrawArrays(GLenum mode, GLint first, GLsizei count);
I've never used them, so I can't tell you how. I'm going to read the my Win32 SDK Reference file. If I figure it out, I'll share the answer with you. If not, uh, don't hold your breath.
[EDIT]
You also need to call
glEnableClientState(GL_VERTEX_ARRAY);
along with GL_COLOR_ARRAY, GL_EDGE_FLAG_ARRAY, GL_INDEX_ARRAY, GL_NORMAL_ARRAY,
or GL_TEXTURE_COORD_ARRAY
to make it work.Edited by - smart_idiot on March 6, 2002 1:26:33 PM
Chess is played by three people. Two people play the game; the third provides moral support for the pawns. The object of the game is to kill your opponent by flinging captured pieces at his head. Since the only piece that can be killed is a pawn, the two armies agree to meet in a pawn-infested area (or even a pawn shop) and kill as many pawns as possible in the crossfire. If the game goes on for an hour, one player may legally attempt to gouge out the other player's eyes with his King.
you can combine VA with triangle strips. In fact that''s one of the fastest ways to draw geometry. CVA''s are good only if you have multiple passes. If your geometry is static try using display lists with VA and trangle strips.
There are more worlds than the one that you hold in your hand...
There are more worlds than the one that you hold in your hand...
You should never let your fears become the boundaries of your dreams.
Yes, combining (multi)texturing, vertex arrays, normal arrays, and triangle strip(s) in a display list is a good way to achieve speedy rendering. In fact when you start rendering hundreds of thousands of polygons the speed increase over just drawing a bunch of GL_TRIANGLES is very noticable.
Edited by - Chromebender on March 6, 2002 4:12:31 PM
Edited by - Chromebender on March 6, 2002 4:12:31 PM
thx for the first responses
if i understand all, i have to combine vertex array, triangle strip and display list?
i do
glEnableClientState(GL_NORMAL_ARRAY); /*for light*/
glEnableClientState(GL_VERTEX_ARRAY);
then use this
void glVertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
void glNormalPointer(GLenum type, GLsizei stride,const GLvoid *pointer);
void glArrayElement(GLint ith);
if have the coordonate (x,y,z for all the point) in a vector pxyz[0...512*512-1] of
typedef struct {
GL_DOUBLE x,y,z;
} XYZ;
how do i fill the argument of
glVertexPointer(3,GL_DOUBLE,0?,pxyz?) correct?
i have to calculate 1 normal for each vertex? (what the best method?)
and then use glNormalPointer.
Then for EACH LINE of the matrix (512*512) do triangle strip of display list?
like this?
glNewlist(1,GL_COMPILE);
glBegin(GL_TRIANGLE_STRIP);
glArrayElement(0 +(512*i)) i is the number of the ligne
glArrayElement(1+(512*i)) (0,1,2,3 are not the good indices to make triangle strip it's only for exemple)
glArrayElement(2+(512*i))
glArrayElement(1+(512*i))
glArrayElement(3+(512*i))
.... for all the lines but i have to use an indice i for exemple to make line (1...511) (is it permit in display list?)
glEnd();
glEndList();
and then
i=0;
while(i<511)
{
glCallList(1);
i++;
}
all this is correct? i'm not sure the display list has to contain this.
and i have problem with the methode for calculing normal...
thanks for responses
Edited by - ioda on March 7, 2002 8:43:05 AM
if i understand all, i have to combine vertex array, triangle strip and display list?
i do
glEnableClientState(GL_NORMAL_ARRAY); /*for light*/
glEnableClientState(GL_VERTEX_ARRAY);
then use this
void glVertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
void glNormalPointer(GLenum type, GLsizei stride,const GLvoid *pointer);
void glArrayElement(GLint ith);
if have the coordonate (x,y,z for all the point) in a vector pxyz[0...512*512-1] of
typedef struct {
GL_DOUBLE x,y,z;
} XYZ;
how do i fill the argument of
glVertexPointer(3,GL_DOUBLE,0?,pxyz?) correct?
i have to calculate 1 normal for each vertex? (what the best method?)
and then use glNormalPointer.
Then for EACH LINE of the matrix (512*512) do triangle strip of display list?
like this?
glNewlist(1,GL_COMPILE);
glBegin(GL_TRIANGLE_STRIP);
glArrayElement(0 +(512*i)) i is the number of the ligne
glArrayElement(1+(512*i)) (0,1,2,3 are not the good indices to make triangle strip it's only for exemple)
glArrayElement(2+(512*i))
glArrayElement(1+(512*i))
glArrayElement(3+(512*i))
.... for all the lines but i have to use an indice i for exemple to make line (1...511) (is it permit in display list?)
glEnd();
glEndList();
and then
i=0;
while(i<511)
{
glCallList(1);
i++;
}
all this is correct? i'm not sure the display list has to contain this.
and i have problem with the methode for calculing normal...
thanks for responses
Edited by - ioda on March 7, 2002 8:43:05 AM
I'm still don't know what I'm doing, but I think I read that you can't use vertex arrays in display lists.
[EDIT:]
Nevermind I'm an idiot.
Edited by - smart_idiot on March 7, 2002 9:40:48 AM
[EDIT:]
Nevermind I'm an idiot.
quote:
You can include glDrawArrays in display lists. When you include glDrawArrays in a display list, the necessary array data, determined by the array pointers and the enables, are generated and entered in the display list. The values of array pointers and enables are determined during the creation of display lists.
Edited by - smart_idiot on March 7, 2002 9:40:48 AM
Chess is played by three people. Two people play the game; the third provides moral support for the pawns. The object of the game is to kill your opponent by flinging captured pieces at his head. Since the only piece that can be killed is a pawn, the two armies agree to meet in a pawn-infested area (or even a pawn shop) and kill as many pawns as possible in the crossfire. If the game goes on for an hour, one player may legally attempt to gouge out the other player's eyes with his King.
so i use only array vertex with triangle strip and i DON''T use display list?
any idea to calculate normal to put in void glNormalPointer(GLenum type, GLsizei stride,const GLvoid *pointer); ?
any idea to calculate normal to put in void glNormalPointer(GLenum type, GLsizei stride,const GLvoid *pointer); ?
quote:
Original post by ioda
so i use only array vertex with triangle strip and i DON''T use display list?
any idea to calculate normal to put in void glNormalPointer(GLenum type, GLsizei stride,const GLvoid *pointer); ?
You want to calculate the cross product. It''s somewhere in this page .
Chess is played by three people. Two people play the game; the third provides moral support for the pawns. The object of the game is to kill your opponent by flinging captured pieces at his head. Since the only piece that can be killed is a pawn, the two armies agree to meet in a pawn-infested area (or even a pawn shop) and kill as many pawns as possible in the crossfire. If the game goes on for an hour, one player may legally attempt to gouge out the other player's eyes with his King.
> so i use only array vertex with triangle strip and i DON''T use display list?
Yes. Never use VAs together with display lists. It''s one or the other. In your case, VAs would be the perfect choice.
And BTW: on modern cards (GF2+, Radeon) there is no speed difference between triangle strips and a simple triangle list. The hardware setup for both is exactly the same. And using the vertex cache, triangle lists can also share vertices (even more than normal tristrips). The only difference is the number of indices transfered over the AGP. Tristrips need less information, so transfer is faster. But tristrips will require more individual render calls, if complex meshes are used, whereas triangle lists only need a single one. You should test it with your particular geometry, sometime strips are faster, sometimes lists are. If you are using some kind of LOD scheme, then triangle lists will almost always be faster, for a simple raw heighmap, tristrips will be better.
And *never ever* use degenerated triangles to connect individual strips ! According to nVidia, it''s the worst thing you can do, in terms of performance.
Yes. Never use VAs together with display lists. It''s one or the other. In your case, VAs would be the perfect choice.
And BTW: on modern cards (GF2+, Radeon) there is no speed difference between triangle strips and a simple triangle list. The hardware setup for both is exactly the same. And using the vertex cache, triangle lists can also share vertices (even more than normal tristrips). The only difference is the number of indices transfered over the AGP. Tristrips need less information, so transfer is faster. But tristrips will require more individual render calls, if complex meshes are used, whereas triangle lists only need a single one. You should test it with your particular geometry, sometime strips are faster, sometimes lists are. If you are using some kind of LOD scheme, then triangle lists will almost always be faster, for a simple raw heighmap, tristrips will be better.
And *never ever* use degenerated triangles to connect individual strips ! According to nVidia, it''s the worst thing you can do, in terms of performance.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement