Results 1 to 5 of 5

Thread: 3D+2D

  1. #1
    Junior Member Newbie
    Join Date
    Mar 2001
    Location
    Newark, DE
    Posts
    16

    3D+2D

    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.

  2. #2
    Member Contributor
    Join Date
    Oct 2000
    Location
    london, england
    Posts
    76

    Re: 3D+2D

    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
    Later

    Zee

  3. #3
    Junior Member Newbie
    Join Date
    Mar 2001
    Location
    Newark, DE
    Posts
    16

    Re: 3D+2D

    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...

  4. #4
    Senior Member Frequent Contributor
    Join Date
    Apr 2000
    Location
    Adelaide, South Australia, Australia
    Posts
    763

    Re: 3D+2D

    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

  5. #5
    Junior Member Newbie
    Join Date
    Mar 2001
    Location
    Newark, DE
    Posts
    16

    Re: 3D+2D

    Holy dumb question Batman...

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

    Thanks for the info.

    regards

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean