Avoid Flickering with LWJGL
Question
In the context of a Java Rubik's Cube application I am trying to animate the cube actions performed by the end user.
To do that I am just using rotations and many redraws as following:
GL11.glRotatef(zRotate, 0.0f, 0.0f, 1.0f);
the zRotate variable is icremented from 0 to 90 and I am performing redraws every 20 miliseconds.
It works perfectly but I see flickering on the screen .. How can I avoid that ?
Solution 2
The solution was to add the SWT.NO_BACKGROUND style in the Opengl canvas creation.
OTHER TIPS
According to this thread, You could call Display.setVSyncEnabled(true);
during initialization.
Use Double buffering.
http://en.wikipedia.org/wiki/Double_buffer#Double_buffering_in_computer_graphics
I dont have any experience with LWJGL, but a common technique is to draw into a bitmap and to redraw the screen/window with the bitmap in one step.