I’m using OpenGL 3.30 with Shaders (with HW instancing) but I’ve got a flickering effect on whole scene when I’m trying to execute occlusion queries during high framerates (usually > 100). More pfs I get, then more flickers I get.
With 60 or less fps I get no flickering effect.
YouTube video: - YouTube
Pseudo-Code:
[ol]
[li]Enable off screen rendering to FrameBufferObject[/li][li]glColorMask(0,0,0,0)[/li][li]glDepthMask(0)[/li][li]for each object to render {[/li][LIST=1]
[li]Bind VertexBufferObject() to Shader[/li][li]glBeginQuery(GL_SAMPLES_PASSED)[/li][li]save QUERY_ID and OBJECT_ID for later use[/li][li]glDrawArraysInstanced(…)[/li][li]glEndQuery(GL_SAMPLES_PASSED)[/li][/ol]
[li]}[/li][li]while glGetQueryObjectuiv(GL_QUERY_RESULT_AVAILABLE) == 0 {…}[/li][li]verify if QUERY_ID is visible and set OBJECT_ID the same[/li][li]glDepthMask(1)[/li][li]glColorMask(1,1,1,1)[/li][li]Disable off screen rendering and return to default FrameBuffer[/li][li]normal Rendering Pass which renders only objects which had QUERY_ID passed as “visible”[/li][/LIST]
I know this is not the good way to “wait” (list point #6) Querie results, but I don’t understand why rendering “off screen” (to a FrameBufferObject) starts to flickering in default Framebuffer…Even if I exchange list point #6 with a delay Sleep(500) I get no flickering effect, so the problem is not caused due to wait Query results.
Any idea?
PS: If i remove those piece of code (firsts 10 list points) I get no flickering
PS2: left-bottom text is rendered outside rendering pass