Note that there are some explanatory texts on larger screens.

plurals
  1. POLWJGL - screen flickering on rendering cycle
    primarykey
    data
    text
    <p>I am developing a 3D visualization application using LWJGL 2.8.5. After reading the first tutorials from the project home page I also went deeper in my analysis reading an OpenGL book. I see the typical procedure in OpenGL is drawing the scene in the init function, then simply calling the update of display in a loop.</p> <p>However, when I try this with LWJGL I get a flickering effect in the display. The only way to eliminate the flickering is to redraw the scene in the display updating cycle. Why is this happening?</p> <p>To better explain my problem I have created a simple class reproducing the problem. It simply draws a quad in the center of the screen, then it goes into the endless screen update loop.</p> <p>Note that if I uncomment the draw call within the cycle, then flickering disappears everything works. Why?</p> <p>Is there anything wrong with my expectation to only draw the objects once and just move the camera to get a different view of a static scene? </p> <p>Here it is the code:</p> <pre><code>package test; import org.lwjgl.LWJGLException; import org.lwjgl.opengl.Display; import org.lwjgl.opengl.DisplayMode; import org.lwjgl.opengl.GL11; import org.lwjgl.util.glu.GLU; import static org.lwjgl.opengl.GL11.*; public class DisplayTest { public static void initGL() { GL11.glViewport(0, 0, 640, 480); glMatrixMode(GL_PROJECTION); GLU.gluPerspective(45.0f, 640f/480f,0.1f, 100.0f); draw(); } public static void draw() { glMatrixMode(GL_MODELVIEW); GL11.glLoadIdentity(); // Reset The Current Modelview Matrix GL11.glTranslatef(0, 0, -6.0f);//Place at the center at -6 depth units //Start drawing a quad //-------------------------------------------------- GL11.glBegin(GL11.GL_QUADS); int size=1; GL11.glColor3f(.3f, .5f, .8f); GL11.glVertex3f(-size/2f,-size/2f,+size/2f); GL11.glVertex3f(+size/2f,-size/2f,+size/2f); GL11.glVertex3f(+size/2f,+size/2f,+size/2f); GL11.glVertex3f(-size/2f,+size/2f,+size/2f); glEnd(); } public static void main(String[] args) { try { // Sets the width of the display to 640 and the height to 480 Display.setDisplayMode(new DisplayMode(640, 480)); // Sets the title of the display Display.setTitle("Drawing a quad"); // Creates and shows the display Display.create(); } catch (LWJGLException e) { e.printStackTrace(); Display.destroy(); System.exit(1); } initGL(); // While we aren't pressing the red button on the display while (!Display.isCloseRequested()) { //draw(); // Update the contents of the display and check for input Display.update(); // Wait until we reach 60 frames-per-second Display.sync(60); } // Destroy the display and render it invisible Display.destroy(); System.exit(0); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload