# Performance

This topic is 4621 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## 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
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

1. 1
2. 2
Rutin
19
3. 3
4. 4
5. 5

• 13
• 26
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
633736
• Total Posts
3013598
×