Hello, I am designing a game in which I want text to be displayed over certain objects to indicate to the user what to do next.
Sadly, when I was messing around a few weeks ago I got text to appear in the environment when I didnt want it to, now I forget what cause it.
Here is my text drawing function, it works fine for my current menu which is done displaying messages on the users HUD.
This draws text on the screen which follows the camera, if I callCode:...
void setOrthographicProjection()
{
// 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
gluOrtho2D(0, win_width, 0, win_height);
// invert the y axis, down is positive
glScalef(1, -1, 1);
// mover the origin from the bottom left corner
// to the upper left corner
glTranslatef(0, -win_height, 0);
glMatrixMode(GL_MODELVIEW);
}
void resetPerspectiveProjection()
{
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
}
void renderBitmapString(float x, float y, float z, void *font, char *string) {
char *c;
glRasterPos3f(x, y, z);
for (c=string; *c != '\0'; c++) {
glutBitmapCharacter(font, *c);
}
}
glPushMatrix();
setOrthographicProjection();
glLoadIdentity();
renderBitmapString(30,30,0,(void *)font,"Hello World ");
resetPerspectiveProjection();
glPopMatrix();
at some random coordinate, it isnt displayed in my 3d world. I have a feeling i am missing some matrix multiplication, which I admit I am not quite sure what is needed here.Code:renderBitmapString(5,3,7,(void *)font,"Hello World ");
As well I want this text to face the player, or in a particular direction...but one issue at a time.
Any advice would be greatly appreciated.