flickering problem in opengl

Started by prich, November 01, 2009, 19:24:33

Previous topic - Next topic

prich

hello there!

i'm having some problems with my opengl app (2D). Basically it is working without any problems, but when i start to move my character the whole screen starts to flicker (see image from a screenshot). Without moving everything is rendered properly!

I read about this issue using scissorstest, but i don't use any scissors...

I also read that this might happen if i'm not rendering to the backbuffer. How can i check where i render, or do i have to setup opengl in a different way to use backbuffer?

does someone have a useful advice or do you need some more infos?

thx prich



broumbroum

You may show how you initialize your screen and how you paint on the screen.
I had a similar issue when putting the GL screen into a ScrollPane... the 2D components caused the texture to overlap like shown on the shot...

prich

Display.setTitle(title);
		Display.setFullscreen(false);
		if (!DEBUG)
			Display.setVSyncEnabled(true);
		
		Display.setDisplayMode(new DisplayMode(w, h));

		Display.create();

		GL11.glMatrixMode(GL11.GL_PROJECTION);
		GL11.glLoadIdentity();
		GL11.glOrtho(0.0, Display.getDisplayMode().getWidth(), Display
				.getDisplayMode().getHeight(), 0.0, Integer.MIN_VALUE,
				Integer.MAX_VALUE);
		GL11.glMatrixMode(GL11.GL_MODELVIEW);
		GL11.glLoadIdentity();
		GL11.glViewport(0, 0, Display.getDisplayMode().getWidth(), Display
				.getDisplayMode().getHeight());

		// GL11.glFrustum(0, Display.getDisplayMode().getWidth(),
		// Display.getDisplayMode().getHeight(), 0 , 1, 2);

		GL11.glEnable(GL11.GL_TEXTURE_2D);
		GL11.glShadeModel(GL11.GL_SMOOTH);
		GL11.glDisable(GL11.GL_LIGHTING);

		GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
		GL11.glClearDepth(1);


I paint using VBOs and deathbuffer. A frame is like this:
first i fill my VBO with ts coordinats + xyz + color + normals and save it in the context with the texture (so i have to bind every texture only once).
Then i bind my texture and render quads in my vbo.

you need more?

prich

it's funny because flushing the rendering pipeline (GL11.glFlush(); ) seems to fix all problems :)
but i still do not know why...

Ciardhubh

Quote from: prich on November 02, 2009, 18:13:09
it's funny because flushing the rendering pipeline (GL11.glFlush(); ) seems to fix all problems :)
but i still do not know why...

Did you call glClear(...) before and Display.update() after drawing each frame? Display.update() implies glFlush() as far as I know.

broumbroum

then flush it... :)
Quotefirst i fill my VBO with ts coordinats + xyz + color + normals and save it in the context with the texture (so i have to bind every texture only once).
you're unnecessarily calling glcleardepth(1)... there's something wrong with the depth testing. e.g. if you render everything at the same z-location.
see http://www.opengl.org/resources/faq/technical/depthbuffer.htm 1st issue, glenable(GL_DEPTH_TEST)