Problems drawing to a bitmap

I’m trying to draw to a bitmap. The idea is drawing directly to a bitmap in memory, without displaying any window on the screen.

I set OpenGL using glut, with glutCreateWindow, passing a parameter SW_HIDE to avoid the display on screen. After that I create a compatible DC and a compatible bitmap, set an appropiate pixel format and create and make current a rendering context.

My simple scene is a cube with a different color in each face. Faces are GL_QUADS.
The rendering works (colors, size, clipping planes, etc), but in every face you can see a diagonal in a different color.

Drawing the scene directly to a window gives correct results (no visible diagonal). I can’t see any difference in the code executed for the two cases.

Any idea ??

Check if you have glEnable(GL_POLYGON_SMOOTH) in your code and remove it. That option is of very limited use and results in such artefacts if not used correctly.
If you need that, you must switch off depth testing and draw you geometry sorted from front to back with the alpha saturation blending mode and destination alpha planes.

Be aware that rendering directly to a bitmap will normally not use the same OpenGL implementation than your windowed drawing (Bitmap: Microsoft SW OpenGL, Window: Hardware accelerated by your graphics board.) Capabilities between these implementations are vastly different (OpenGL 1.1 vs. OpenGL 2.0).

Yes. Removing glEnable(GL_POLYGON_SMOOTH)worked !!!
Thank you very much. After reading your post I searched a bit and found that rendering in OpenGL is more complicated than I thought. But for the simple things that I’m doing now, your simple solution is enough.
Thanks again.