In heavy content worlds (ie 5000+ sets of triangle arrays) we’re getting some pretty mad flashing when using manual context management on several different types of video cards and system setups. This suggests we’re doing something wrong with the way JOGL wants to interact with AWT. All the demos around use the listener method, which is not what we’re doing. Wondering if anyone has some ideas about what to tweak as the setup?
Our basic rendering loop has its own thread that looks something along the lines of the following psuedo code:
public void run() {
while(true) {
glContext.makeCurrent();
GL gl = glContext.getGL();
gl.drawthings....
glContext.release();
... some time later
glDrawable.swapBuffers();
}
}
The GLCanvas is setup as follows:
canvas = new GLCanvas(caps, chooser, shared_context, null);
((GLCanvas)canvas).setAutoSwapBufferMode(false);
((Component)canvas).setIgnoreRepaint(true);
canvasContext = ((GLAutoDrawable)canvas).getContext();
canvasContext.setSynchronized(true);
What this results in is a flash of what appears to be the screen blanking to black followed by the drawing of the scene. It seems like something else is also messing with the context and doing its own clear somewhere else. The strange thing is that if we manually limit the frame rate to about 30fps, we don’t see any flash at all - it’s only once we let it start to run up near 50 FPS that the flashing starts occuring. We’re not making use of the Threading class for scheduling on the “openGL thread” because we are the open gl thread, so we control precisely when all the drawing is happening.
Anyone have some ideas on what to do about this? (This code is using JOGL JSR beta 4)
Edit:
I should add that the flashing only occurs if there is some amount of time between the release() and swapBuffers() calls. If I put them one after the other, there is no flashing. For example:
glContext.release();
glDrawable.swapBuffers();
and
glDrawable.swapBuffers();
glContext.release();
Both result in no flashing. It’s only when there’s a few milliseconds of time between the two, (eg processing application logic before the swap) that the flashing occurs. Everything is guaranteed to be on the same rendering thread.