PDA

View Full Version : Diplaying text on orthgraphic projection



lordmonkey
11-21-2010, 03:51 PM
hello,
I have a problem with displaying text with glutBitmapCharacter(font, *c)
as I use this function :

void renderBitmapString(
float x,
float y,
float z,
void *font,
char *string)
{
// switch to projection mode
glMatrixMode(GL_PROJECTION);

// save previous matrix which contains the
//settings for the perspective projection
glPushMatrix();

// reset matrix
glLoadIdentity();

// set a 2D orthographic projection
glOrtho(0, 600, 0, 600, -600, 600);

// switch back to modelview mode
glMatrixMode(GL_MODELVIEW);
glDisable(GL_TEXTURE_2D);
char *c;

//glRasterPos3f(x, y,z);
glRasterPos2f(x, y);
for (c = string; *c != '\0'; c++)
{
glutBitmapCharacter(font, *c);
}
glEnable(GL_TEXTURE_2D);
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
}

my text is generally printed OK but as I rotate around (e.g. with respect to y axis) text moves a little bit and disappear when I look at z+ axis ( I hope you can imagine that)

and second question is about
glOrtho(0, 600, 0, 600, -600, 600);

How can I assure that text is always visible instead of passing e.g. -600 , 600 as zFar and zNear ??

lordmonkey
11-21-2010, 05:13 PM
ok everything it's working . I just put the functino call after gltransforms and rotatates