Where am I losing performance?

Hey folks. Just found this sight, could be a godsend for me.

Anyway, 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

You want to push your geometry into one of the on-card structures such as vertex arrays or VBOs. Anything between a begin/end pair is going to be a performance hit very quickly. Also, in the long run, you’ll need to implement things like culling and state sorting. In the navigation side of things, picking is going to be a big resource consumer, so build optimal structures for that. There are a lot of other things to consider as well. You would be best served by picking up one of the game programming books around. Even stuff in C will be just as useful for you as the Java ones, so long as you find something that is easy to read for you.

Thanks a lot. I confess that culling and state sorting mean nothing to me. Can you give me enough of a head start that I can figure it out, or perhaps a link to a resource? Don’t know what a VBO is either. Honestly, I’m only vaguely sure what you mean by vertex array., but I bet I can google my way through that.

I’m guessing that state sorting/culling has something to do with drawing the furthest walls first- my assumtion was that z-buffering covered that.