Font is a class that is initialized in the init!!
Print function for font
glPushMatrix();
glColor4f(r, g, b, a);
glLoadIdentity();
glTranslatef(0.0f, 0.0f, -1.0f);
if (xpos == 0.0 && ypos == 0.0 && zpos == 0.0)
glRasterPos2i(screenX, screenY);
else
glRasterPos3f(xpos, ypos, zpos);
glPushAttrib(GL_LIST_BIT);
glListBase(callList - 32);
glCallLists(strlen(text), GL_UNSIGNED_BYTE, text);
glPopAttrib();
glPopMatrix();
*******
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
input.getInput();
//Using font class from OpenGl Game Programming Ch.21
glDisable(GL_TEXTURE_2D);
font.SetPos3D(0.0f,0.0f,-1.0f);
font.SetRGB(0.9f,0.0f,0.0f);
font.Print("FPS: %2.0f", timer.getFps());
glEnable(GL_TEXTURE_2D);
//Draw scene
glPushMatrix();
glBindTexture(GL_TEXTURE_2D, CubeImage.ID);
//code to draw cube and textures it
//removed cause we all know how to do this and code is long
glPopMatrix();
glFlush();
Anyone know why my textures all become red? If I remove the font code everything works fine.
Thanks,
/*dimebag*/
colored texture after font
I have a problem after calling my font to be displayed in which all my textures have the font color. I have tried using glPush-Pop method as well as glLoadIdentity(). This is my code:
Using glColor outside of a glBegin/glEnd block will apply that colour to all objects that do not have their own colour attribute. The simplest way to correct this is to simply call glColor3f(1.0f,1.0f,1.0f,1.0f) after you finish rendering the text.
BTW: glPushMatrix, glPopMatrix, and glLoadIdentity have no effect on colour. The only thing they affect is the currently active matrix.
BTW: glPushMatrix, glPopMatrix, and glLoadIdentity have no effect on colour. The only thing they affect is the currently active matrix.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement