Results 1 to 4 of 4

Thread: 2d interface in a 3d world

  1. #1
    Junior Member Newbie
    Join Date
    Apr 2005
    Posts
    26

    2d interface in a 3d world

    Hey all.

    Lots of people have hit on the 2d/3d thing and I've looked into all the posts, but I'm still stuck on something... perhaps it's how I'm thinking about it...

    In a 3d game, I want to build a 2d interface. You can't (as per the redbook) switch at will between 2d (ortho) and 3d (perspective/frustrum) projection.
    If I had a window that's 640x480, how could I draw a box that's say 200 px tall and 100 px wide using a 3d point system?

    It seems clunky to use Project/Unproject to do this as it was designed for mouse coordinates, and (again as per the redbook) there are inherant problems at the conceptual level doing project/unproject calculations.

    If there are no transformations in my matrices, is there a simple algorithm that I can use to calculate real world pixel information from/to 3d world points?

    I did have the thought that perhaps I could make the z coord a large negative, so that the x,y coords matched real world pixels... is that a solution? Is there a better one?
    Anyone know how the "pros" do it?

    Also, in a normal 3d environment, is it possible to make the origin (0,0) the bottom left hand side of the screen?

    Thanks so much for any insight you can provide!

    j

  2. #2
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,574

    Re: 2d interface in a 3d world

    Who said you can't switch between ortho and perspective ???

    glMatrixMode (GL_PROJECTION);
    glLoadIdentity ();
    glFrustum(...) / gluPerpective(...)
    [draw 3D stuff]

    glMatrixMode (GL_PROJECTION);
    glLoadIdentity ();
    gluOrtho2D (0, windowWidth, 0, windowHeight);
    [draw 2D stuff with pixel coordinates]

    The FAQ about this :
    http://www.opengl.org/resources/faq/...s.htm#tran0030

  3. #3
    Junior Member Newbie
    Join Date
    Apr 2005
    Posts
    26

    Re: 2d interface in a 3d world

    (blushes)

    whoops must have mis-read.

    Thank you very much!

  4. #4
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,574

    Re: 2d interface in a 3d world

    hehe, no problem

Similar Threads

  1. Cad interface
    By ertanatalar in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 09-10-2018, 06:31 AM
  2. Continuous World / World Wrapping
    By MicahBrening in forum OpenGL: Basic Coding
    Replies: 13
    Last Post: 02-24-2007, 06:46 PM
  3. vp fp interface
    By Nil_z in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 09-29-2004, 07:16 PM
  4. vp&fp interface
    By Nil_z in forum OpenGL: Advanced Coding
    Replies: 2
    Last Post: 09-29-2004, 03:10 PM
  5. gl interface
    By wildwheel in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 11-26-2002, 07:50 AM

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