0
\$\begingroup\$

I draw game HUD after drawing 3D scene. When I move the camera quickly, HUD starts flickering. I noticed that it happens only if the distance between the camera and an object its looking at changes after camera's position transformation.It does not happen if there is no mesh in front of the camera. I use separate shader program for HUD rendering. Have tried to enable/disable depth test, blending already. Using VBOs to draw stuff.

Render code:

 def render()
{

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)

    glEnable(GL_DEPTH_TEST)
    glDepthFunc(GL_LESS)
    glEnable(GL_CULL_FACE)


    Shader.setCurrentShader(Shader.SHADER_VOXEL)
    Shader.currentShader().enable()
    set3DMatrices()
    updateShaderVOXEL()
    val world = WorldRegistry.getWorldByID(0)
    world.renderWorld()
    Shader.currentShader().disable()

    Shader.setCurrentShader(Shader.SHADER_SIMPLE)
    Shader.currentShader().enable()
    set3DMatrices()
    ManagerRegistry.renderManagerSceneBoundingBox.render()
    ManagerRegistry.renderManagerSceneRectangle.render()
    ManagerRegistry.renderManagerSceneLine.render()
    Shader.currentShader().disable()


    glDepthMask(false)
    glDisable(GL_DEPTH_TEST)
    glDisable(GL_CULL_FACE)


    Shader.setCurrentShader(Shader.SHADER_HUD)
    Shader.currentShader().enable()
    set2DMatrices()
    GL13.glActiveTexture(GL13.GL_TEXTURE0) // Texture unit 0
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, Texture.getTexture("screen/cursor/default.png"))
    HUDRenderRegistry.HUDRender.render()
    Shader.currentShader().disable()

    glDepthMask(true)

    glfwSwapBuffers(window)
}

EDIT

I made a video(captured on the phone, so the quality is bad, sorry) and the rectangle in it is actually fully red, not yellow. https://youtu.be/HhHEfrgsfiU

\$\endgroup\$
  • \$\begingroup\$ Is the flickering like "triangular speckling"? Or like "stroboscopic flashing"? (or something else...) Speckling could be z-fighting (though you're right, disabling depth test should cure it), and strobing could be no-redrawing and still swapping. \$\endgroup\$ – david van brink Jul 16 '15 at 20:07
  • \$\begingroup\$ @david I tried to screen record my problem. But on the recorded video HUD renders properly although when recording, on my screen it was glitchy !????? \$\endgroup\$ – Russoul Jul 17 '15 at 9:24
  • \$\begingroup\$ wow... that is more mysterious! I wonder if the screen recording is capturing alternate frames... or some OS subtlety... :-/ not very satisfying speculations... \$\endgroup\$ – david van brink Jul 17 '15 at 23:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.