Jump to content
  • Advertisement


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


Textured image color

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

Hello, I draw a textured quad. Then I proceed to draw a textured quad using GL_TRIANGLES and the last vertex I color blue. The strange thing is that my textured quad now has a blue tint; rather annoying. Here is my render code:
//  Update the angle variable according to how much time has passed

	pos += 10.0f*deltaTime;

	if(pos >= 30.0f)			//  If the angle has gone in a circle

		pos = -30.0f;			//  Reset the angle

	//  Render the OpenGL scene

	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);	//  Clear the screen

	glLoadIdentity();									//  Reset the origin back to the center

	glTranslatef(pos, -pos, -30.0f);

	glEnable (GL_TEXTURE_2D);			//  Enable texture mapping

	glBindTexture (GL_TEXTURE_2D, 13);	//  Bind the texture 13 so we can use it

    glBegin (GL_QUADS);
        glTexCoord2f (0.0f,0.0f);			//  Lower left corner of image

        glVertex3f (-10.0f, -10.0f, 0.0f);
        glTexCoord2f (1.0f, 0.0f);			//  Lower right corner of image

        glVertex3f (10.0f, -10.0f, 0.0f);
        glTexCoord2f (1.0f, 1.0f);			//  Upper right corner of image

        glVertex3f (10.0f, 10.0f, 0.0f);
        glTexCoord2f (0.0f, 1.0f);			//  Upper left corner of image

        glVertex3f (-10.0f, 10.0f, 0.0f);
    glEnd ();

	glDisable (GL_TEXTURE_2D); //  Disable texture mapping

	glTranslatef(0.0f, 0.0f, -30.0f);

		glColor3f(1.0f, 0.0f, 0.0f);
		glVertex3f(5.0f, 5.0f, 0.0f);
		glColor3f(0.0f, 1.0f, 0.0f);
		glVertex3f(-5.0f, 5.0f, 0.0f);
		glColor3f(0.0f, 0.0f, 1.0f);
		glVertex3f(0.0f, -5.0f, 0.0f);



	//  Swap the buffers (double-buffering)


Share this post

Link to post
Share on other sites
I think can tell you exactly why it''s happening.

The last call to glColor... you make is setting the color to blue. I don''t see it anywhere in your code, but I''ll assume you don''t call any glTexEnv... functions. What appears to be happening is that you are in GL_MODULATE mode. That way, the texture is multipled by the current color, which in your case is blue--so you get a blue version of the image. If you want to use the texture''s color data instead of "mixing" it, you can either call glColor... beforehand and set the color to full intensity, or make a call somewhere to:


That way, instead of each texel being multipled by the current color, their native values will be used.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!