OpenGL background dissappears with certain Polygon Modes

我怕爱的太早我们不能终老 提交于 2019-12-11 06:37:06

问题


I am creating a simple gradient background by drawing a quad as follows:

 glMatrixMode GL.GL_PROJECTION
 glLoadIdentity

 glMatrixMode GL.GL_MODELVIEW
 glLoadIdentity

 ***glPolygonMode GL_FRONT_AND_BACK, GL_LINE*** 

 glDisable glcDepthTest

   glBegin bmQuads

     glColor4d 1, 0, 0, 1

     glVertex2i -1, -1
     glVertex2i 1, -1

     glColor4d 0, 0, 1, 1

     glVertex2i 1, 1
     glVertex2i -1, 1

    GL.glEnd

  GL.glEnable glcDepthTest

I then set up my viewing matrices and draw my 3D scene. This works as expected when the polygon mode (of the scene) is set to GL_FILL, but when I set the polygon mode (of the scene) to GL_LINE or GL_POINT, the background quad disappears and the background is drawn as the color specified in glClearColor.

I have tried several different blending options (including disabling it altogether), so I don't think the problem is blend mode related.

EDIT: Adding the following polygon mode to above code solves this issue!

glPolygonMode GL_FRONT_AND_BACK, GL_LINE


回答1:


You need to push the polygon mode of GL_FILL onto the stack before drawing your background polygon, then pop it back off the stack.



来源:https://stackoverflow.com/questions/1064840/opengl-background-dissappears-with-certain-polygon-modes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!