Sign in to follow this  

Performance

This topic is 4256 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
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
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
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 this post


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


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

Share this post


Link to post
Share on other sites

This topic is 4256 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this