PDA

View Full Version : Orthographic queston



Ace_Man
01-03-2001, 11:29 AM
Hi
I'm pretty confused (still) over the whole orthographic/gluPerspective projections (as well as modelview/projection). Up untill now I've just been sort of winging it without really understanding when to change what and why.

Well now I have a problem that I can't fix becuause of my lack of a clear understanding on when and why to use what and the proper way to go back and forth between these things..


I've written a font library that texture maps fonts I've created onto quads (for some reason I couldn't get the NeHe tutorials to work. I wonder If it's b/c I'm using GLUT)

Anyway,I want to use it in my little 3D world. I want to be able to place my text as an overlay to my 3D space. So if I walk up to a character, that I can display my textures at the bottom of the screen.

I'm sure this whole thing is as simple as a few lines of code in my draw function, but I don't know what they are...

I got this from a tutorial but I can't seem to control how big or where the textures appear on the screen.

glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glOrtho(0, width, 0, height, 0, 0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glRasterPos2f(0,0);
drawText("ACE?");
glColor3f(0,1,1);
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);

This code will get my letters on the screen but they are blown up and I can't seem to change that.

So, if any of you out there could offer a code snippet for this (even better would be a simple explanation into the idea of overlaying 2D text on a 3D world) I would greatly appreciate this.

Thanks so much

zed
01-03-2001, 12:18 PM
this aint necessary but it allows u to place things closer and further away from the camera.
glOrtho(0, width, 0, height, -100, 100);

change the width of the quads of the text in drawText(..)

DFrey
01-03-2001, 03:47 PM
Ummm, zmin and zmax in glOrtho only affect the z value. Not the perspective of the primitives drawn since in an orthographic projection, there is no perspective. You control the placement of the text by translating the modelview matrix. You can control the size by scaling the modelview matrix, simple as that.

[This message has been edited by DFrey (edited 01-04-2001).]

zed
01-04-2001, 01:49 PM
doooh. dont know what i was thinking :eek: