TIP: JOGL + Swing flicker

Some of you may have GLCanvas (a heavyweight)
contained inside Swing containers. It definitely
works and you get the speed of GLCanvas with
the convenience of Swing. However, you may notice
GLCanvas flickering badly when resizing it via
a Swing container. I found a method that helps
remove that flicker a great deal:

System.setProperty(“sun.awt.noerasebackground”, “true”);

It turns off automatic background filling of
AWT components. Have fun :slight_smile:

.rex

Thanks, that’s a useful tip. What platform are you seeing the flickering on? If you’re on Windows, are you running with -Dsun.java2d.noddraw=true? Do you have a test case for this? The GLCanvas already overrides the paint() method to not clear the component using Java2D and I would have thought that no matter what the containing component did it shouldn’t affect the contents of the GLCanvas.

I’m on Windows XP with nVidia 6600GT.
The flickering is seen when embedding
a GLCanvas inside a Swing container.
Basically I have a docking windows UI
that has up to 6 levels of containment.
While resizing the container that has the
GLCanvas, the GLCanvas is being resized
in real-time while rendering in its own
thread and I see flickering that looks like
GLCanvas clearing its own background.
I do have -Dsun.java2d.noddraw=true set
and the flickering is still there so I don’t
think it’s a Swing issue. I also made sure
that the Swing components that are
underneath the GLCanvas are not painting
themselves. And so by setting that AWT
flag, I noticed flickering reduce dramatically.
The remaining flickers are due to the
glViewport() being changed in real-time,
which is a minor issue.

.rex

thanx rex, i’ve been setting the background of my swing component to the same background color of my canvas to avoid that flickering problem.