# Thread: 2d interface in a 3d world

1. ## 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. ## Re: 2d interface in a 3d world

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

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

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

http://www.opengl.org/resources/faq/...s.htm#tran0030

3. ## Re: 2d interface in a 3d world

(blushes)

Thank you very much!

4. ## Re: 2d interface in a 3d world

hehe, no problem

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•