View Full Version : is it possible to display a background image ?

01-19-2004, 09:13 AM
is it possible to replace the background color by an image, loaded from any bitmap file for instance or from a HBITMAP created elsewhere ? i mean, without having to load a texture from a bitmap of a 2power-dimension and to put it far on the Z-axis ...

01-19-2004, 09:39 AM
Yes, use the "glDrawPixels" function to write the image data to the frame buffer.

(In the event that you wanted to use a texture, you could switch to an ortho-graphic projection [2D view] so you don't need to put it "far" on the Z-axis. "glOrtho" or "gluOrtho2D" can create ortho-graphic projections).

01-19-2004, 03:33 PM
...and remember to either disable depth buffer writing when you draw the quad, or clear the depth buffer after drawing it.

No, there's no specific OpenGL concept of a background image. But as Guest points out, it's a really easy thing to do yourself.

01-21-2004, 04:56 PM
Have you researched glOrtho2D? nehe.gamedev.net has a good tutorial on it - you'll get much, much, much faster performance if you draw a textured quad in ortho mode than if you use glDrawPixels. The only drawback is you have to play around a bit with depth testing and depth masking to get it to work. My city demo kind of does that at http://daltxcoltsfan.tripod.com - check DoOrthoModeRendering in main.cpp. I had code in there to draw a quad on the screen that's commented out.