PDA

View Full Version : 3D+2D



phenotic
02-28-2001, 12:41 PM
What is the best way to overlay a 2D picture over a 3D graphics world. ie only the 3D world changes when the camera is moved?

Thanks in advance.

ZeeBoy
02-28-2001, 01:00 PM
the easyest way to do this would be to have ur 2d art as a texture and place that over a quad or any shape needed.

now u could either place code to draw this at the toc of ur display method in which case it will not be affected by any transformation calls later or u can place it anywhere in the display method if u use the glPopMatrix() and glPushMatrix() calls and place your quad in between these 2 calls this will stop any previouse transformations to effect the quad.

or u could draw your 3d world first the use glLoadIdentity() and then draw the quad


Zee

phenotic
02-28-2001, 03:48 PM
How efficient would that be? This 2D art is pretty trivial so the less time the machine spends on the 2D... Although I'm have some fairly decent experience with 3D engines I'm new to Open GL which leads me to another question. How does this viewport thing work (not transformations) I hear it is possible to have multiple in the same window. How is this possible and what are the limitations of this? The 2D art is seperate from the 3D. Would it be possible to put the 2D stuff on one viewport and have the 3D occupy the other viewport?

Thanks for your time...

john
02-28-2001, 06:22 PM
Hello,

er, overlay planes, you mean? That'd work, but only if your window manager supports overlays. There is nothing stopping you from changing projection matricies, btw. You don't HAVE to commit to a single projection matrix:

glMatrixMode(GL_PROJECTION);
glLoadIdenity();
gluPerpsective(...);
glMatrixMode(GL_MODELVIEW);

/* 3d stuff */
glutSolidTeapot(...);

glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
gluOrtho2D(...);
glMatrixMode(GL_MODELVIEW);

/* 2d stuff */
glRasterPos2i(...);
glDrawPixels(...);

glMatrixMode(GL_PROJECTION_MATRIX);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);

/* back to 3D */

and so on.

cheers,
John

phenotic
02-28-2001, 08:26 PM
Holy dumb question Batman...

A little trip to the library and some books goes a long way eh?

Thanks for the info. http://www.opengl.org/discussion_boards/ubb/smile.gif

regards