tags:

views:

43

answers:

3

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 ?

+1  A: 

According to this thread, You could call Display.setVSyncEnabled(true); during initialization.

Rekin
A: 

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.

Markus Kull
Without vsync this could also give flickering.
Rekin
LWJGL work by default with double buffering, so you don't have to worry about this. (http://lwjgl.org/forum/index.php?topic=1187.0)
Mr_Qqn
+1  A: 

The solution was to add the SWT.NO_BACKGROUND style in the Opengl canvas creation.

Manuel Selva