Archived

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

Viscous-Flow

Textured image color

Recommended Posts

Viscous-Flow    122
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

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

	glBegin(GL_TRIANGLES);
	
		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);

	glEnd();

	glFlush();

	//  Swap the buffers (double-buffering)

	SwapBuffers(window->hDC);
  

Share this post


Link to post
Share on other sites
Omaha    100
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:

glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);

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