PDA

View Full Version : OpenGL Background BMP



12-07-2000, 08:31 PM
Is there a way to place a bmp file as a background image for an opengl application? Any help would be appreciated. Thanks.

Gabriel
12-07-2000, 08:58 PM
You need to set a orthographic projection (glOrtho or gluOrto2D) the load a bitmap file in a texture (this is the tricky part)... Set vertex coordinates to match those of your projection, load identity matrix in model view and display a quad that cover the screen at the fartest possible position in z.

Kilam Malik
12-08-2000, 04:08 AM
Thats correct so far, but instead of drawing far away you could also disable depth buffering and draw it before anything else. That spares you some time needed to fill the backbuffer.

Kilam.



[This message has been edited by Kilam Malik (edited 12-08-2000).]

Moz
12-08-2000, 05:49 AM
I've written a small program to demonstrate how to do that. It uses glut. If you want, I can send you the source code.
Note that if you want to use a textured quad for your background, you'll need to specify an image with power of 2 dimensions (no OGL implementation supports non power of 2 dimensions yet). If you want to use any size for the background image, you can use glDrawPixels to draw the background, but that is much slower because the image is still in your RAM and not in the texture memory of your HW accelerator. If you don't have a HW accelerator though, I don't think that there will be too much difference between the use of a textured quad or glDrawPixels.