The problem :
I want to put some text on my scene. If I choose a projection Ortho I can draw text well in my window even if it's resolution are 320x400 or 1024x768. But when I use a perspective projection, the position of the text change cause the perspective change...
I just want to ajust the text coord depend the size of the my windows. Is it possible to get the perspective dimension of my scene, depend the size of my windows, and also compute the righ position to draw the my text message ?

why not just push the projection matrix, load an ortho view draw your text, then pop the matrix?

Erakis

12-12-2001, 07:04 AM

It's will not affect the view/proportion of scene to swap between Perspective and Ortho ?

chowe6685

12-12-2001, 09:45 AM

changing a matrix will only change primitives draw after the change, if you draw your scene with perspective, and then want to add text via ortho, you can just switch to an ortho projection and it will work fine

Erakis

12-13-2001, 04:44 AM

I've tried your tips but I'm not sure if I'm do it well ?
So I have to :
Activate the Projection matrix
Push it (so save it..)
Load a different type of projection (glOrtho)
Activate the Modelview matrix (To draw the text)
Move/Scale and draw my text
Reactivate the Projection matrix
Give it the old projection type (gluPerspective)
Pop the matrix (Reload this old one)
Activate the Modelview matrix to draw the rest of my scene....
__________________________________________________ ___________________________________
glMatrixMode( GL_PROJECTION );
glPushMatrix();
glOrtho( -5.0, 5.0, -5.0, 5.0, 0.1, 500.0 );

.....DRAW_THE_TEXT........
glMatrixMode( GL_PROJECTION );
gluPerspective( 45, ClientWidth / ClientHeight, 0.1, 500.0 ); //if you have already loaded the perspective matrix above this is unnecessary, just pop the matrix and it will return to a perspective projection
glPopMatrix();

glMatrixMode( GL_MODELVIEW );

what you have is correct, just look at my comments, you can probably eliminate the gluPerspective call, also, you may want to push the modelview matrix before transforming, then pop it later, otherwise the transformations you applied to the text will be applied to the rest of your scene