PDA

View Full Version : Help with Bottleneck



HemiMG
10-26-2000, 07:00 PM
Hi,
I'm having a bit of a problem finding out what is causing my code to be so slow. I have a model rotating with vertex shading and am only getting about 11 FPS. (The model has 7121 faces so that is about 79,000 polygons per second). The thing is I have tried it at resolutions from 320x240 up to 800x600 and the framerate is always the same, so my rendering code shouldn't be the problem, correct? Further evidence that it is not the rendering code causing the problem is that I switched from a for loop that calls glcolor, glnormal, and glvertex one time for each face, to using glDrawArrays and didn't notice any improvement whatsoever in framerate. The problem is that there is very little in the form of non-gl code in the main loop. The main loop looks like this:

for(i = 0; i < 100; i++){
glViewport (0, 0, (GLsizei) W, (GLsizei) H);
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
glFrustum (-1.0, 1.0, -1.0, 1.0, MinDepth, MaxDepth);
glMatrixMode (GL_MODELVIEW);

glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

i3dTranslate(-Camera->position[VALUE_X],-Camera->position[VALUE_Y],-Camera->position[VALUE_Z]);
i3dRotate(-Camera->angle[VALUE_X],-Camera->angle[VALUE_Y], -Camera->angle[VALUE_Z]);

/* I'll explain this next line later */
i3dDrawObject(nimitz);

/*I'm using SDL, not Glut */
SDL_GL_SwapBuffers();

Nimitz->angle[VALUE_Y] += 2.0;
}

i3dDrawObjects is of course a function I wrote, in actuality the main loop has more of my functions than that, but I just expanded them so you'd know exactly what is going on.
i3dDrawObject has an if statement that checks for things like texturing, lighting, etc. so that I be sure to pass the right set of normals and such. But the main rendering part is here:

glColorPointer(4, GL_FLOAT, 0, Object->colorarray);
glNormalPointer(GL_FLOAT, 0, Object->vnormalarray);
glVertexPointer(3, GL_FLOAT, 0, Object->vertexarray);
glDrawArrays(I3DRenderType, 0, (Object->facecount * 3));

I've actually commented out everything but that to be sure that it wasn't the if statemnents giving me trouble and still got the same framerate. Any ideas on what it could be? I've even commented out the code that adds to the angle of the model. The only thing left is required GL code. I'd appreciate any help.

HemiMG
10-26-2000, 07:05 PM
Oops, I forgot to expand i3dTranslate and i3dRotate, but I guess you can figure out which gl calls they make ;-)
There is nothing but gl calls in those functions.

niko
10-26-2000, 08:49 PM
Try removing glViewport and glFrustum from main loop. Those subs are usually called when creating or resizing viewport, not everytime scene is rendered.
Also try using GLUT when swapping buffers, just to see if that makes any
difference. What hw are you using?

Regards,
Niko

HemiMG
10-26-2000, 09:17 PM
I removed glFrustum and glViewport from the main loop and didn't get any speed increase. Commenting them out completely sped it up but of course then I couldn't see anything haha.
I haven't tried it with glut yet, but I did comment out my double buffer swap call, and aside from not being able to see anything it was still going at 11 fps, so I don't think that that is the bottleneck. (Besides, near as I can figure Loki uses SDL for at least some of their commercial OpenGL ports, so it should be fairly decent, performance-wise).
I am using a Voodoo2. I thought I said that in the first message, I remember typing it, but it must have been deleted when I revised some of the paragraphs.

niko
10-27-2000, 02:58 AM
Well, you have to call those at least once, just do not do it in mainloop but before.
Anyways, actually 11FPS feels like the hw acceleration does not kick in. Try updating your drivers.

Regards,
Niko

HemiMG
10-27-2000, 11:12 AM
Actually my HW Acceleration works fine, QuakeIII, Unreal TE, Solier of Fortune all work fine, as do TuxRacer, TuxKart, Tuxedo T Penguin: A Quest for Herring, and various other free games out there (I use Linux)