PDA

View Full Version : performance tips



Interface
06-13-2004, 12:13 PM
I ran into some performance troubels. To picture what i'm doing: loading in 2 md2 models, put them on the screen (one next to the other), i have texturing and 2 lights (one red one green) shining on them.
I use vertex/normal/textcoord arrays and drawelements() to render.
my render loop looks like:

glMatrixMode(GL_MODELVIEW);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glColor3f(1.0f,1.0f,1.0f);
glLoadIdentity();
gluLookAt(X,Y,Z, viewX,viewY,viewZ, viewUpX,viewUpY,viewUpZ);

then loop the models, in this case 2 times:

glPushMatrix();
translate+drawmodel
glPopMatrix();

i tried taking out the matrixmode call, and the loadidentity and glulookat by doing it all in the beginnen and then pushing the matrix, but it has little or no effect.
on the radeon9800 it runs @ 1500+ fps, but on a geforce2 it only has 25fps!!
when i drag the window below the screen, so only the window title bar is visible, the fps rises upto 205fps... does that mean it's just the rendering going slow and my main loop coding is good?

any thoughts? (i'm using c++)

06-13-2004, 12:42 PM
that's very odd. without seeing the rest of the code, i can only speculate. could be you have some freaky state that's forcing a software path. are you getting any errors from glGetError()? i have played with md2 models on a gf2 with no trouble. could be driver version, could be lots of things. 25 fps seems very, very slow, even for a gf2.

Interface
06-13-2004, 11:14 PM
Exactly... The 205fps i get when moving the window out of sight is more what i would expect.
I have installed Quake3 to test it, and even in windowed mode Quake3 runs very smooth on the gf2, so there should really be something wrong with the program...

the missing code is (translate+drawmodel):

glTranslatef(X,Y,Z);
glRotatef(rotationY,0.0f,1.0f,0.0f);
glVertexPointer (3, GL_FLOAT, 0, frame->verts);
glNormalPointer (GL_FLOAT, 0, frame->norms);
glTexCoordPointer (2, GL_FLOAT, 0, frame->texts);
glBindTexture(GL_TEXTURE_2D,frame->textureId);
glDrawElements(GL_TRIANGLES,frame->numPolygons*3,GL_UNSIGNED_SHORT,frame->polys);

06-13-2004, 11:31 PM
that looks fine to me. have you tried unsigned int indices instead of the shorts? just a guess... do the models look ok? any artifacts?

Interface
06-14-2004, 08:17 AM
models look ok... ( http://users.pandora.be/interface/droid_robot.jpg ) only the textures are sometimes a bit stretched, but i think it's just because i need to use text coords between 0 and 1 so i divide all the coords by the height/width of the texture...

i really have no idea
help :)

Interface
06-14-2004, 12:34 PM
i just tried disabling texturing... the fps just stays the same, sometimes goes one up (26, yay!).

06-14-2004, 02:44 PM
sometimes goes one up (26, yay!).heck, call it a day :D .

hmmm, as a test, i would build a list of 1000 simple triangles, and render them using exactly the same technique. but don't use tex coords or normals, just the indexed verts. disable blending, texturing, alpha test, depth test, stencil test, cull face, lighting, ... everything. once you get the triangle code up to speed, add the states back one at a time, and test.