Skip to main content
GameDev.net gamedev.net
🔒 Locked

Background images?

Started by Drooling Iguana Aug 10, 2003 at 11:43 AM 6 replies 950+ views
Original Post
Drooling Iguana
Drooling Iguana
Is there any way to have a bitmap that''s always displayed behind the objects in my scene in OpenGL? I don''t want to have to create a big giant textured quad with my background image on it and stick it behind all the other objects in my scene.
skremon
skremon
You have to wrap the bitmap texture with something! If you require a big quad then do it! nothing wrong with a huge quad. Skyboxes use the largest quad available in a 3D world
(Remon) M. Sazzad Karim
azimuth
azimuth
What you probably want is to disable lighting and z-buffering and place several quads with a chopped-up texture in front of the camera. Do this before camera rotations/translations. Then you can re-enable lightning and z-buffering to draw your 3d objects.

Hope this helps.
exa_einstein
exa_einstein
look:

glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();

glOrtho2D(0,1,0,1,-1,1);
//possible to swap 3. and 4. arg, when you see nothing...

glMatrixMode(GL_MODELVIEW);

glPushMatrix();
glLoadIdentity();
glRasterPos2i(0,0);
glDrawPixels(1024,768,GL_RGB,GL_UNSIGNED_BYTE,image);
glPopMatrix();

glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);


I don't know whether it is without errors, i haven't my help here, so glDrawPixels may have bad num of arguments, or such problem.

(image is a pointer to loaded 24bit RGB bitmap flipped upside down, here with size of 1024*768*3 bytes)

[edited by - exa_einstein on August 11, 2003 10:09:16 AM]
When I was younger, I used to solve problems with my AK-47. Times have changed. I must use something much more effective, killing, percise, pernicious, efficient, lethal and operative. C++ is my choice.
Drooling Iguana
Drooling Iguana
azimuth: How would I disable Z-buffering? I imagine that it''s glDisable(something), but I don''t know what flag to put in place of "something" to disable Z-buffering.

exa_einstein: I tried your code but my compiler complains that glOrtho2D() doesn''t exist.
llyod
llyod
quote:
exa_einstein: I tried your code but my compiler complains that glOrtho2D() doesn''t exist.


Try glOrtho()
exa_einstein
exa_einstein
you can disable WRITES to the z-buffer with glDepthMask(0);
(and enable with glDpMsk(1); 1 is default)

Depth testing you can glEnable/glDisable with arg. GL_DEPTH_TEST

also you have glDepthFunc(GL_ALWAYS/EQUAL/LESS/LEQUAL/GREATER/GEQUAL/NEVER);

and if you want to completely remove z-buffer, you must set pixelformatdescriptor.DepthBits to 0 (i don't know whether it really exact ident pfd.DepthBits, so try msdn)

[edited by - exa_einstein on August 12, 2003 5:57:06 AM]
When I was younger, I used to solve problems with my AK-47. Times have changed. I must use something much more effective, killing, percise, pernicious, efficient, lethal and operative. C++ is my choice.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.