Opengl drawing a 2d overlay on a 3d scene problem

后端 未结 6 933
深忆病人
深忆病人 2020-12-05 09:02

I have a moving 3d scene set up, and I want to make a stationary 2d GUI overlay that is always on top, when I try making 2d shapes I don\'t see anything. When I call: glMatr

6条回答
  •  广开言路
    2020-12-05 09:11

    Make sure your geometry ( specifically the z coordinates of your geometry, in terms of your 2d UI ) is greater than the near plane ( behind the near plane on the z-axis ), otherwise, any rendering which takes place in front of the near-plane will not be seen. I'm assuming you have defined your view frustum somewhere else in the code ( this is where the near-plane is defined ).

    If the near-plane is 0.01f, then your vertex definitions could be

    glVertex3f(-5.0f, 5.0f, -0.02f); 
    glVertex3f(-5.0f, -5.0f, -0.02f); 
    glVertex3f(5.0f, -5.0f, -0.02f); 
    glVertex3f(5.0f, 5.0f, -0.02f); 
    

    I believe in the MatrixMode( GL_MODELVIEW ) you are always looking into the -Z Axis. I hope this helps.

    I may be wrong but i think the DEPTH_TEST refers to the z-buffering of your final rendered object, i don't think it disables the near-plane value.

提交回复
热议问题