Performance Issues with LWJGL

Started by DeX, July 02, 2005, 20:54:32

Previous topic - Next topic

DeX

Wow that's great, thanks very much Matzon. And thanks for taking the time to look through the code. The Java version does run just as fast as the C++ version now. :D

I don't understand exactly what that code is doing though. I used it originally to get rid of the back side of the box faces so that you could still see the balls as the box rotated. Now, I guess that removing that line means that the back face of the spheres are not drawn but the back faces of the box are still drawn. How can make it so I can see through the box's back faces?

Orangy Tang

'fill' mode is the default, so the first line is probably not having any effect, it'll be the second line that's causing the problems I'll guess. I have seen some rediculous slow down with 'line' fill mode before (for quick and easy wireframe) so I wouldn't be too surprised to see 'point' mode being similarly slow.

For lines I found that actually using line primatives (specified in your draw calls) didn't suffer from this strange slowdown, I'd expect points to be the same.

I'm not quite sure what you're after, but it sounds like you should leave the fill mode alone and instead tinker with the face culling:

glEnable(GL_CULL_FACE);
glCullFace(GL_FRONT); // Doesn't draw front faces
glCullFace(GL_BACK); // Doesn't draw back faces

And make sure your geometry has the correct winding order set (via glFrontFace, default is usually correct).

DeX

Thanks again, the cull back face is what I wanted to acheive.

funsheep

Quote from: "Orangy Tang"... If you draw with vertex arrays you'd likely see near identical performance.

However an easier way would be to still use the glu sphere and stick it in a display list (and likewise for your C++ version) ...

In this context, i am wondering, which is faster, to pack all my code:
glBegin(GL_TRIANGLES);
    glVertex(...)*
    glNormal(...)*
    glColor(...)*
    .
    .
    .
glEnd();


in a displaylist, or to render with vertex arrays, or both vertex arrays packed in displaylists?

Optus

Basically there's a little rule of thumb to decide what to use.  First, never ever use both, putting a vertex array inside a display list could actually slow things down.  Basically, you need to decide, does your data change?  In the case of a pool game, it seems like it would not.  You are rendering some spheres, or the pool table, or the pool cue.  None of these things are animated, the same vertex/texcoord/color/etc data will always be used.  Thus, the easiest and fastest way to render would be using Display Lists.  If the data were to change, you would have to recompile the Display List which can be pretty slow.  As an example of when to use Vertex Arrays, I use them for skeletal animation, because the vertex data is updated every frame based on the time passed and animation data.  It's faster to create a buffer for all of the updated vertices, and upload them to OpenGL all with one call using vertex arrays, rather then the potentially large amount of calls it would take to recompile the display list.