PDA

View Full Version : what...???



mike j
11-15-2000, 09:49 PM
you mean there is no such thing as -
glEnable(GL_HW_TNL) ...???

j/k (of course)

few questions:

if its automatic and certain optimizations
are needed in order to take advantage of it
what are some of the most important ones ?

which primitive is the most optimized
GL_TRIANGLES OR GL_TRIANGLE_STRIP ?

is it better to send 4float or 3floats ?

etc.. etc..

is there a FAQ that goes into depth about TnL
optimizations ?


-btw
is there any good stuff on intel's developer site ?

11-15-2000, 10:58 PM
The less data you send, the less bus
bandwidth is used and the more you can cram
through in the same amount of time.

The nVidia developer web site has some good
papers and presentations if you want to go
more in detail. The Intel developer site
has some useful information, such as MMX
and SSE programming references, but not much
related to OpenGL and hardware rasterization
at all (they want you to do it all using
their expensive Pentium cycles, no doubt :-)

There really isn't a "more optimized"
primitive as far as I know; transforming
less vertexes per primitive seems to be the
main thing to do, so triangle strips fit the
bill pretty well. Also, glVertexPointer(),
glNormalPointer() and friends should give
the driver ample opportunity to download the
vertexes efficiently, even if you don't go
through the EXT_vertex_array extension to put
your geometry in AGP (or card) memory.

BK
11-15-2000, 11:33 PM
Vertex ordering is important as well, if you want to hit the vertex cache. (assuming one exists)

There is a OpenGL performance FAQ somewhere that lists the primitives in order of efficiency, it doesn't mention the actual differences in effiecency though.

Michael Steinberg
11-16-2000, 10:25 AM
As far as I know, if one gave a pointer to the strip array of a model (and it usually contains more than just 1 strip) you have to do a glDrawArray for any strip.
Where is the point (ie: which strip size) when using a for(; http://www.opengl.org/discussion_boards/ubb/wink.gif for many strips is more effective than simply using GL_TRIANGLES?

mandroka
11-16-2000, 03:30 PM
Hi,

here are some results on rendering 131kpolys. I just simply put it out (see code below):

tnt2
triangles : 3.44 fps
v_triangles: 4.43 fps
tristrips1 : 11.53 fps
tristrips3: 14.32fps

geforce2
triangles : 12.65 fps
v_triangles: 17.56 fps
tristrips1 : 33.64 fps
tristrips3: 46.9fps

voodoo5
triangles : 2.97 fps
v_triangles: 8.72 fps
tristrips1 : 7.33 fps
tristrips3: 14.32fps


----
Here's the code I use to render this. I know one of the strip generators is buggy, but I left it in:





float * vertexek=NULL; //vertex coordinates
float * szinek =NULL; //color values (r,g,b,a)

...

void display(int type)
{
int a=0,b=0;
switch(type)
{
case DISP_TRIANGLES:

for(x=0; x<255; x++)
for(z=0; z<255; z++)
{
glBegin(GL_TRIANGLES);
glColor3fv(&amp;szinek[(x*256+z)*3+0]);
glVertex3fv(&amp;vertexek[(x*256+z)*3+0]);

glColor3fv(&amp;szinek[((x+1)*256+z)*3+0]);
glVertex3fv(&amp;vertexek[((x+1)*256+z)*3+0]);

glColor3fv(&amp;szinek[(x*256+(z+1))*3+0]);
glVertex3fv(&amp;vertexek[(x*256+(z+1))*3+0]);

glColor3fv(&amp;szinek[((x+1)*256+z)*3+0]);
glVertex3fv(&amp;vertexek[((x+1)*256+z)*3+0]);

glColor3fv(&amp;szinek[((x+1)*256+(z+1))*3+0]);
glVertex3fv(&amp;vertexek[((x+1)*256+(z+1))*3+0]);

glColor3fv(&amp;szinek[((x)*256+(z+1))*3+0]);
glVertex3fv(&amp;vertexek[((x)*256+(z+1))*3+0]);

glEnd();
}
break;

case DISP_TRISTRIPS:

for(x=0; x<255; x++)
{
glBegin(GL_TRIANGLE_STRIP);
for(z=0; z<256; z++)
{

glColor3fv(&amp;szinek[(x*256+z)*3+0]);
glVertex3fv(&amp;vertexek[(x*256+z)*3+0]);

glColor3fv(&amp;szinek[((x+1)*256+z)*3+0]);
glVertex3fv(&amp;vertexek[((x+1)*256+z)*3+0]);


}
glEnd();
}
break;

case DISP_TRISTRIPS1:
glBegin(GL_TRIANGLE_STRIP);
x=0;
while(x<256)
{

for(z=0; z<256; z++)
{
glColor3fv(&amp;szinek[(x*256+z)*3+0]);
glVertex3fv(&amp;vertexek[(x*256+z)*3+0]);

glColor3fv(&amp;szinek[((x+1)*256+z)*3+0]);
glVertex3fv(&amp;vertexek[((x+1)*256+z)*3+0]);


}
x++;

for(z=0; z<256; z++)
{
if(z!=0)
{
glColor3fv(&amp;szinek[(x*256+(255-z))*3+0]);
glVertex3fv(&amp;vertexek[(x*256+(255-z))*3+0]);
}

if(z!=255)
{
glColor3fv(&amp;szinek[((x+1)*256+(255-z))*3+0]);
glVertex3fv(&amp;vertexek[((x+1)*256+(255-z))*3+0]);
}

}
x++;
}

glEnd();
break;

case DISP_TRIANGLES_V:
glDrawElements (GL_TRIANGLES,elementnum,GL_UNSIGNED_INT,indices1) ;
break;

//this is what I use
case DISP_TRIANGLESTRIPS_V:
for(int x=0; x<255; x++)
{
glDrawElements (GL_TRIANGLE_STRIP,512,GL_UNSIGNED_INT,&amp;indices2[x*512]);
}

break;
}

}