Performance

Started by
11 comments, last by zedzeek 18 years ago
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.glBegin( GL.GL_QUADS );

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


A thousand thanks for anyone who reads this. -Upton
Advertisement
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.

As your leader, I encourage you from time to time, and always in a respectful manner, to question my logic. If you're unconvinced that a particular plan of action I've decided is the wisest, tell me so, but allow me to convince you and I promise you right here and now, no subject will ever be taboo. Except, of course, the subject that was just under discussion. The price you pay for bringing up either my Chinese or American heritage as a negative is - I collect your f***ing head.
I'm using JoGL, on a NVidia GEFORCE FX 5200. How do I make it hardware accelerate?
perhaps this is relevant:

my capabilities look like this:

GLCapabilities capabilities=new GLCapabilities();capabilities.setHardwareAccelerated(true);capabilities.setDoubleBuffered(true);   
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
Interesting. Is that a manual sort, or a gl.glEnable( SORT_ME_BLEEDIN_WALLS )?

Thanks.
On what basis do I sort the walls? Distance to nearest endpoint? Farthest? Distance to line?

Thanks,
Upton
wonder if I can bump this one more time...
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
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

This topic is closed to new replies.

Advertisement