Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9171391
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:09:22+00:00 2026-06-17T16:09:22+00:00

I am developing a 3D visualization application using LWJGL 2.8.5. After reading the first

  • 0

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.

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?

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.

Note that if I uncomment the draw call within the cycle, then flickering disappears everything works.
Why?

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?

Here it is the 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);
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T16:09:23+00:00Added an answer on June 17, 2026 at 4:09 pm

    By default OpenGL maintains two buffers: a front buffer and a back buffer. The front buffer is what is displayed while the back buffer is what you draw on. This is called double buffering and prevents partially rendered scenes from being shown to the user. Whenever you call Display.update(), lwjgl tells opengl to move the content of the back buffer to the front buffer for display. This is either done by copying the data, or by marking the old front buffer as new back buffer and the old back buffer as new front buffer (the buffers are swaped).

    This is geared towards the normal situation e.g. in games where you want to draw something new like 60 times a second. Now if you don’t actually draw anything, but still call Display.update() (e.g. to get Input), the buffers are still moved. Now depending on how this is implemented, either you still see your old image (if the data is simply copied, because your back buffer then still contains the data you rendered), or you alternate with each Display.update() between the buffer you have drawn on and the buffer that was the front buffer at the time that you rendered (which is likely just black). This leads to the flickering you are seeing, as the image is only shown every second frame (original back buffer), and every other frame the black original front buffer is seen.

    With some driver implementations (e.g. from Nvidia), it seems that Windows can even draw on the active front buffer, so dialog boxes can show up and be displayed even after are closed if you don’t redraw the scene.

    The cleanest solution to this is to simply render to a texture (works since OpenGL 1.1) or a renderbuffer (introduced in OpenGL 3.0) in your init, and then render this texture each frame. This is really the solution that the OpenGL designers had in mind for this type of thing.

    Edit: Either you uncomment the draw method in the above code, or in case that is no option because of render time, you have to render to a texture. Using OpenGL 3 or above you would need to put something like this in your init:

    fbo = GL30.glGenFramebuffers();
    GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, fbo);
    
    rbo = GL30.glGenRenderbuffers();
    GL30.glBindRenderbuffer(GL30.GL_RENDERBUFFER, rbo);
    GL30.glRenderbufferStorage(GL30.GL_RENDERBUFFER, GL11.GL_RGBA8, 640, 480);
    GL30.glFramebufferRenderbuffer(GL30.GL_FRAMEBUFFER, GL30.GL_COLOR_ATTACHMENT0, GL30.GL_RENDERBUFFER, rbo);
    
    assert(GL30.glCheckFramebufferStatus(GL30.GL_FRAMEBUFFER) == GL30.GL_FRAMEBUFFER_COMPLETE);
    
    GL30.glBindFramebuffer(GL30.GL_DRAW_FRAMEBUFFER, fbo);
    GL20.glDrawBuffers(GL30.GL_COLOR_ATTACHMENT0);
    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
    
    drawScene(); //draw here
    

    your draw method to call every frame would then be simplified to a simple and fast copy from the framebuffer fbo:

    GL30.glBindFramebuffer(GL30.GL_READ_FRAMEBUFFER, fbo);
    GL11.glReadBuffer(GL30.GL_COLOR_ATTACHMENT0);
    GL30.glBindFramebuffer(GL30.GL_DRAW_FRAMEBUFFER, 0);
    GL20.glDrawBuffers(GL11.GL_BACK_LEFT);
    
    GL30.glBlitFramebuffer(0, 0, 640, 480, 0, 0, 640, 480, GL11.GL_COLOR_BUFFER_BIT, GL11.GL_NEAREST);
    GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, 0);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm developing a JavaScript application using Google Visualization API. I wrote a event listener
While developing an application using gwt in ecliplse crashed. Now the server is running
I'm developing an iOS application that's a manager/viewer for another project. The idea is
Developing an application using SWT to work in both Linux and Windows. I created
Developing an ASP.NET MVC 3 application (my first) and running into some trouble with
I'm developing Silverlight 4 LOB application and need to provide correct visualization of process
Developing sample download application,My application contains 3 activities.When the first activity starts, the download
developing a web application using java. I have SQL queries with more than 40
I'm in the process of developing a visualization engine for the company I work
Developing a project of mine I realize I have a need for some level

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.