views:

185

answers:

1

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  A: 

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.

McWafflestix