Jump to content
  • Advertisement
Sign in to follow this  
UptonSinclair

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.

If you intended to correct an error in the post then please contact us.

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.glBegin( GL.GL_QUADS );

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


A thousand thanks for anyone who reads this. -Upton

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
perhaps this is relevant:

my capabilities look like this:


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

Share this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!