PDA

View Full Version : hard slow down when adding poly'S



mcbastian
11-16-2000, 06:55 AM
HI!
I have a problem with OpenGL. I Use MS-VC6
and a RIVA TNT2 with ELSA relevator-driver.
I have a scene where a wave is displayed.
(sorry for my bad english!)

i use:

before display is called within the OnIdle event:

glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glLoadIdentity ();

glLookAt(......);


// function not complete
float x,y,z,k,x1......;
int i,j;
void display()
{
k+=0.05;

// for each little square.....

for (i=0;i<10;i++)
{
for (j=0;j<10;j++)
{
// here are 8 sine and cosine-calls
// standard-math.h
// not optimized.....
// it's a square in x-z, splitted in many
// triangles. in this cut off part, the y-
// part is calculated....
// triangle 1
glBegin(GL_TRIANGLES);
glvertex3f(x1,y1,z1)
glvertex3f(x2,y2,z2)
glvertex3f(x3,y3,z3)
glEnd();

/* the big square is split in 100 little squares, and every little square is split in 2 triangles, to get a smoth wave. it's a sine in x-direction and a cosine in z-direction.
if you whish, i can post the whole code.
*/
// triangle 2
glBegin(GL_TRIANGLES);
glvertex3f(x1,y1,z1)
glvertex3f(x4,y4,z4)
glvertex3f(x3,y3,z3)
glEnd();

/* this will run very fast and good, but if i add the following, the speed is slowed down a lot...
btw: I use LIGHTNING with 1 lightsource
the polygones are filled.
when the polygon-mode is set from GL_FILL to GL_LINE it runs as fast as without the following....
*/

//
glBegin(GL_QUADS);
glvertex3f(-1,1,-2);
glvertex3f(-1,-1,-2);
glvertex3f(1,-1,-2);
glvertex3f(1,1,-2);
glend();
}
}
}
if i comment out the last glbegin-glend statements the program will run much faster. but why? adding a single fixed polygon slows down so much ?????

thanx 4 help!

Bastian.

Michael Steinberg
11-16-2000, 10:22 AM
Just for info:
This problem is done on the beginner board.