• Advertisement

Archived

This topic is now archived and is closed to further replies.

colored texture after font

This topic is 5034 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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:
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*/

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites

  • Advertisement