LWJGL Forum

Programming => OpenGL => Topic started by: eeeeeeeee on April 07, 2015, 15:38:45

Title: Flickering when rendering with lwjgl
Post by: eeeeeeeee on April 07, 2015, 15:38:45
When I render a mesh with lwjgl on windows 8.1 I get some weird flickering.

Video: https://www.youtube.com/watch?v=xgQK-KLI_6U (https://www.youtube.com/watch?v=xgQK-KLI_6U)

But when I run the same code on my macbook it works fine.
So what causes this flickering and how can I fix it?

Here is my render loop:

while(!Display.isCloseRequested()){
        camera.move(16);
                renderer.prepare(camera);
                renderer.render(dragon);
                Display.update();
if(Keyboard.isKeyDown(Keyboard.KEY_T))System.exit(0);
}


And here is the function where i set up my display:

public static void setUpDisplay(){
ContextAttribs attribs = new ContextAttribs(4,0);
attribs.withForwardCompatible(true);
attribs.withProfileCore(true);
try {

Display.setDisplayMode(new DisplayMode(WIDTH,HEIGHT));
Display.setTitle("Test");
Display.create(new PixelFormat(), attribs);
} catch (LWJGLException e) {
e.printStackTrace();
}
glViewport(0, 0, WIDTH, HEIGHT);
glEnable(GL_DEPTH_TEST);
}


My GPU is from Nvidia (gtx 970), I have updated to the newest drivers.
Title: Re: Flickering when rendering with lwjgl
Post by: abcdef on April 08, 2015, 08:35:51
I watched the short video but couldn't see anything flickering, which bit was meant to flicker? (I saw a white patchy bit but that was the only different thing)

My initial assumption for why you would get flickering would be because you are drawing 2 things in the same space and the depth buffer has issues. If this were the case I would increase the depth component when creating a new PixelFormat. I once had the same issue in reverse and that resolved it.
Title: Re: Flickering when rendering with lwjgl
Post by: eeeeeeeee on April 08, 2015, 19:11:46
Well its not that easy to see but in the video there are like black spots at the edge of the specular highlight.

I dont think its the depth buffer because it only occurs when i move the camera, afaik z-fighting would be visible all the time.

But anyways thanks for the help.
Title: Re: Flickering when rendering with lwjgl
Post by: quew8 on April 10, 2015, 10:14:46
No, z-fighting will happen when you move the camera. Graphics cards I find tend to produce the same output for exactly the same input. So if you don't change anything it won't flicker.

Saying that I can't see the flickering in the video either.