views:

48

answers:

1

I'm using OpenGL with JOGL. My project is getting sort of slow. I'm new to OpenGL. What are some of the best ways to optimize it? What are some good tools to profile? (I'm using Eclipse.)

I recently switched from using one static Texture object for a whole bunch of models, to each one having its own Texture object. This appeared to slow it down.

Other ideas to optimize:

  • Avoid using trig in the update call to simulate the moon's orbit
  • Using more with display lists
  • Sort models by texture to reduce texture switching
  • Sort models by rotation to avoid rotation matrices
  • Sort models by [characteristic X] to avoid [operation Y]

What are some common problematic values of X and Y above?

It seems like display lists help performance. What can I do in display lists? Is there anything that must be done at draw-time, or can it all be precomputed?

Being new to OpenGL, I don't have a great instinct for what to do here.

A: 

As far as optimizing your OpenGL parts of the code goes, I'd recommend using OpenGL technologies that cut down on the client<->server data transfer (ie. data xfer between CPU and GPU). Display lists definitely help performance as they can quite dramatically reduce the data sent from client to server (system to GPU). Display lists and vertex arrays are a good start to improve performance over immediate mode, but there have been more improvements such as buffer objects and shaders.

I suggest you take a look at SongHo's OpenGL pages. They give an excellent explanation and implementation of several of the aforementioned topics with full code samples.

Edit: I forgot to mention his examples are in C++, but the OpenGL calls should all be the same, if not, highly similar.

jay.lee
jogle example: http://www.java-tips.org/other-api-tips/jogl/how-to-create-a-display-list-in-jogl.html
Ray Tayek