Jump to content
  • Advertisement
Sign in to follow this  
SpaceRanger

OpenGL Losing Text Color when I combine Text and 2D Images

This topic is 4108 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

Any insight on this problem would be greatly appreciated. I can render 2D Images and OpenGL Text, but when I do them both at the same time, the color of the text changes. For example: - Loading 2, 2D Images, everything works fine. - Displaying some Blue text, everything works fine. - When I render the Blue Text (Title of my Screen) with the 2 images, the Text turns white/off white. I am failing to figure out how my Draw Image functions are effecting my OpenGL text rendering. I have listed some code below. Here is my DrawScene func: void COpenGL::DrawScene(void) { float fXShift =0.0f; float fYShift =0.0f; glPushMatrix(); glLineWidth(10.0); glColor3f( 0.1f, 0.1f, 1.0f ); // BLUE glTranslatef( -2.0f, 1.0f, 0.0f ); glScalef( 0.003, 0.003, 0.003 ); renderStrokeString( GLUT_STROKE_ROMAN, "Page TITLE:" ); glLineWidth(2.0); glPopMatrix(); m_imgTex1.Draw(); m_imgTex2.Draw(); } Here is the renderStrokeString func: void COpenGL::renderStrokeString( void *font, char *string ) { int i; int len = (int) strlen(string); for (i = 0; i < len; i++ ) { glutStrokeCharacter(font, string); } } And here is my Image Draw func: void CImage2D::Draw() { glEnable(GL_TEXTURE_2D); this->m_glTextureImg.SetActive(); float fXShift = this->m_fX; float fYShift = this->m_fY; glBegin(GL_QUADS); glTexCoord2f(0.0, 0.0);glVertex3f( -0.5f + fXShift, -0.5f + fYShift, 0.0f ); glTexCoord2f(0.0, 1.0);glVertex3f( -0.5f + fXShift, 0.5f + fYShift, 0.0f ); glTexCoord2f(1.0, 1.0);glVertex3f( 0.5f + fXShift, 0.5f + fYShift, 0.0f ); glTexCoord2f(1.0, 0.0); glVertex3f( 0.5f + fXShift, -0.5f + fYShift, 0.0f ); glEnd(); } The SetActive Func just Binds the Image.

Share this post


Link to post
Share on other sites
Advertisement
Maybe it's just me but I guess you would want to disable texture mapping and push the colour attribute stack before you render a primitive that is not supposed to be texture mapped ( i.e. the GL_LINES which glutStrokeCharacter fabricates ), don't you?

Share this post


Link to post
Share on other sites
Thank You.

I put glDisable(GL_TEXTURE_2D); at the end of the Image Draw function and that fixed my color issues.

As far as pushing the Color Attributes, I am sure what you mean there.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!