Removed..

Removed…

I have not really analysed you code, but maybe you’ll find an answer in the nehe masking tutorial: http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=20

Btw. the game looks really nice, although I was a bit lost, what to do… can you shoot or anything?

Removed…

The things that slow down OpenGL-Performance are state changes and communicating with the OpenGL driver in general. Try the following:

o) I think you can safely move


gl.glTexEnvi(GL.GL_TEXTURE_ENV, GL.GL_TEXTURE_ENV_MODE, GL.GL_REPLACE);

to your init-method

o) Don’t use


gl.glTranslatef( -2.8f+bb+(scrx%0.2f), -2.8f+aa+(scry%0.2f), -2.0f+zdist );

but calculate the coordinates to glVertex3f directly, since glTranslatef uses matrix math.

o) You can then move


gl.glLoadIdentity();

to the top of your _render()-method.

o) Move


TextureCoords coords = text0.getImageTexCoords();
TextureCoords coords = text1.getImageTexCoords();

to your init()-method like:


public class Render_JOGLScroll implements GLEventListener
{
   TextureCoords coords0 = text0.getImageTexCoords();
   TextureCoords coords1 = text1.getImageTexCoords();

   // other stuff
   (...)

   public void init(GLAutoDrawable drawable)
   {
      // init stuff
      (...)
      
      // this goes after your texture loading
      coords0 = text0.getImageTexCoords();
      coords1 = text1.getImageTexCoords();
   }
}

and use coords0 and coords1 where you need them

o) Don’t enable and disable the textures inside your inner loop, do the following instead:


for ( int cc = 0; cc < 2; ++cc )
{
     if( cc == 0 )
     {
            text0.enable ();
            text0.bind ();
     }
     else
     {
            text1.enable ();
            text1.bind ();
     }
     for ( float aa = 0f; aa < 5.6f; aa+=0.2f )
     for ( float bb = 0f; bb < 5.6f; bb+=0.2f )
     {
            // your rendering code here
            (...) 
     }
     if( cc == 0 )
     {
            text0.disable();
     }
     else
     {
            text1.disable();
     }
}

o) Head over to http://nehe.gamedev.net/ and look into tutorial 12 for display lists.

o) Also you might get better performance by using masking instead of blending.

I bet you get decent performance in 1600x1200 windowed mode after this changes.

Very nicely done! Reminds me a lot of XPilot. Luckily you can’t die yet or I would have been splattered over those walls countless times already :wink: