Strange flickering effect

I’m writing a few very simple demos for a presentation I’m about to do. I have a single quad which I animate by rotating around all its axis. The problem is that I get a very annoying flickering at the edges of the quad when animating the scene. I’ve tried several variations on this with the same result. I use a GLCanvas in an AWT Frame (with the background color set to the same as in the one I use in glGlearColor) and the recommended VM-parameters (-Dsun.java2d.opengl=true -Dsun.java2d.noddraw=true -Dsun.awt.noerasebackground=true). I guess I’m missing something here but I just can’t figure out what I’m doing wrong.

I’ve attached the code so that you can see what I’m doing. Very simple demo, pressing space will start/stop the rotation and escape will quit. Any suggestions for avoiding the flickering at the edges would be appreciated.

I can’t reproduce the flickering effect you describe. It is unnecessary to set the background color of either the Frame or the Canvas. Also, -Dsun.java2d.noddraw=true (on Windows) is the only recommended command-line option in your situation. What JDK version are you running, what OS, and what graphics card? Have you tried upgrading to the latest set of graphics drivers for your card?

On both Java 5 and 6 I was able to get some sort of flickering; the flickering Myolp is describing is tearing, from not having the framerate sync to the vertical refresh rate of his monitor. Odd, 'cause I always thought that Java 6 defaulted to double-buffering in it’s AWT components.

Anyway, Myolp, you’ve used an FPSAnimator and set the framerate to 25fps, which isn’t a framerate to maintain v-sync with my monitor (75Hz refresh rate), so I got the tearing. By switching to just the plain Animator (and reducing the rotation rate), I was able to get a much smoother spinning quad, without flickering edges.

Ok, now I’m getting somewhere. Testing it on a computer with a CRT (with a 75Hz refresh rate) I’ve eliminated the effect. However, on my computers with LCD-displays (60 Hz refresh rate) I still get the problem regardless which animator I use. Tried using the plain Animator and the FPSAnimator with a framerate of a multiple of 60 (30, 60, 90, 120 etc). Printing the choosen GLCapabilities shows that I use both hardware acceleration and doublebuffering. The tearing effect is still there.

The effect also occurs in the Gears-demo but not in the Grand Canyon Demo or moving around in the Infinite Shadow Volumes demo. I guess I need to force the application maintain the v-sync, but is that possible in Java?

How about the video card settings? Is it set to adhere to the refresh rate in OpenGL applications? (Now that I mention that, I can’t seem to find any v-sync settings for my work laptop. It seems to be stuck on ‘V-sync Off’. I was at my home computer, which has a lot more V-sync control options, when I last replied)

I’m running with an LCD and don’t see the flickering. Try calling GL.setSwapInterval(1) in your GLEventListener.init() method.

Ok, my gfx-card sucks big time. My computer also sucks since I can’t upgrade the drivers (company laptop with “you ass is owned by IT support”-extensions installed). However, when increasing the rotation with a lower value and time the entire thing using System.nanoTime() I solved the problem.

I’m going to experiment a little more with this tearing-effect and see if I can find out when and why it really happens. :slight_smile: