Background images?
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.
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
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.
Hope this helps.
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]
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]
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.
exa_einstein: I tried your code but my compiler complains that glOrtho2D() doesn''t exist.
quote:exa_einstein: I tried your code but my compiler complains that glOrtho2D() doesn''t exist.
Try glOrtho()
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]
(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]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement