Performance

Recommended Posts

I appologize for a vague and hard-to-answer question, but I'ma give it a shot. I'm trying to make a first person game. All I have so far is a freely moving camera, and walls which consist of 5 quads ( no bottom ). I find that with as few as 10 walls, performance is slowing to really choppy. I figure I'll post as much code as I think is relevent, and if anyone sees anything that pops out at them, it'd be great. Otherwise, if some great soul could suggest other parts of my code that might be relevent, that'd also be great. I'd love to say more about where the problem might be, but I'm a bit of a neophyte. Oh, also: it mostly is pretty smooth. It seems like there are patches of very slowness, mostly around walls. I init like this:
gl.glShadeModel(GL.GL_SMOOTH);
gl.glEnable( GL.GL_DEPTH_TEST );
gl.glDepthFunc( GL.GL_LEQUAL );
gl.glHint( GL.GL_PERSPECTIVE_CORRECTION_HINT , GL.GL_NICEST );

gl.glEnable( GL.GL_COLOR_MATERIAL );

gl.glLightfv( GL.GL_LIGHT1 , GL.GL_AMBIENT  , ambient  );
gl.glLightfv( GL.GL_LIGHT1 , GL.GL_DIFFUSE  , diffuse  );
gl.glLightfv( GL.GL_LIGHT1 , GL.GL_POSITION , position );

gl.glEnable( GL.GL_LIGHTING );
gl.glEnable( GL.GL_LIGHT1 );


My light variables are
private float[] ambient =  { .6f , .6f , .6f , 1 };
private float[] diffuse =  { .2f , .2f , .2f , 1 };
private float[] position = { 0f , 0f , 0f , 1 };


I draw my walls like this:
gl.glPushMatrix();
gl.glColor3f( .7f , .7f , .7f );

gl.glTranslatef( x1 , y1 , 0 );
gl.glRotatef( theta * Util.TO_DEG , 0 , 0 , 1 );

gl.glEnd();
gl.glPopMatrix();


A thousand thanks for anyone who reads this. -Upton

Share on other sites
anist    100
well, it sounds like you're not hardware accelerated. Most likely, the OpenGL wrapper you're using has no hardware support. You need to post what wrapper you are using and on what video card. drawing that should be fine unless you have no hardware acceleration at all.

Share on other sites
I'm using JoGL, on a NVidia GEFORCE FX 5200. How do I make it hardware accelerate?

Share on other sites
perhaps this is relevant:

my capabilities look like this:

GLCapabilities capabilities=new GLCapabilities();capabilities.setHardwareAccelerated(true);capabilities.setDoubleBuffered(true);

Share on other sites
How do the JOGL demos run?

If they run well then its something in your code that's wrong. If they run choppily as well try updating your version of JOGL and your video card drivers to the latest versions. There have been many fixes recently for the JSR231 version of JOGL which may help you.

One thing that could also be slowing your app down is if you aren't sorting your walls for depth before drawing. If, for example, your view contained all 10 walls and each wall covered 75% of the screen, that means you could be repainting the entire screen ~7 times each frame.

Cheers,
Brett

Share on other sites
Interesting. Is that a manual sort, or a gl.glEnable( SORT_ME_BLEEDIN_WALLS )?

Thanks.

Share on other sites
On what basis do I sort the walls? Distance to nearest endpoint? Farthest? Distance to line?

Thanks,
Upton

Share on other sites
wonder if I can bump this one more time...

Share on other sites
The simplest way is to just sort them (manually :) front to back within the view then render them in order. The z-culling should take care of the overdraw as long as you have depth testing enabled.

(btw sorry I disappeared, MUCH work to do)

Edit:
You might also want to ask this over at Javagaming where the people who actually work on JOGL answer questions.

Cheers,
Brett

Share on other sites
I really hate to sound dim, and I appreciate all your help, but on what basis sholud I sort my walls? If a wall is two vertecies, should I sort on distance to line? I'd like to avoid using something like a BSP tree.

Thanks

Share on other sites
If you're just trying to do it simply, sort on the position of the centre of the wall. Sorting on the line should work as well. You just need something to tell you that one wall is closer to the camera than another.

Cheers,
Brett

Share on other sites
Meganan    100
It's funny that your doing this now cause i'm doing the exact same thing. But I can have about 100 walls before it gets really bad. 10 walls is good in my program. I'm just wondering if you have considered using the:

glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);

style code. I found that using this really upped my performance when used on the bottom of the floor and the inside of the walls (which you should never see). Seriously this about doubled my FPS.

I'm now looking at ways to up my performance and so i'm interested to see where this topic goes.

Share on other sites
zedzeek    528
try glGetString( GL_VENDOR ) and see what that saiz
the gffx 5200, whilst being a good card doesnt have much fillrate. thus at resolutions of > 800x600 it might stuggle with even pretty basic scenes