Jump to content
  • Advertisement
Sign in to follow this  
LordSputnik

glColor3f()

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

Hi there. I have a problem with glColor3f() - I'm using two viewports, one orthographic, and one perspective. I draw a colored quad in the perspective viewpoint, and then switch to orthographic and draw a textured quad. The problem is, when I switch the buffers, the textured quad is textured, but it has the color of the last glColor3f() overlayed! Code:
//Switch operations to second window.
GL3DScene((213*resmultiplierx),(201*resmultipliery),(811*resmultiplierx), (567*resmultipliery));

glTranslatef(0.0f,0.0f,-2.0f);						// Move 2 Units Into The Screen
glRotatef(-45.0f,1.0f,0.0f,0.0f);					// Tilt The Quad Below Back 45 Degrees.
glRotatef(30/1.5f,0.0f,0.0f,1.0f);					// Rotate By zrot/1.5 On The Z-Axis*/

glBegin(GL_QUADS);							// Begin Drawing A Single Quad	
    glColor3f(1.0f, 0.0f, 0.0f); glVertex3f( 1.0f,  1.0f, 0.0f);
    glColor3f(1.0f, 0.0f, 1.0f); glVertex3f(-1.0f,  1.0f, 0.0f);
    glColor3f(0.0f, 1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 0.0f);
    glColor3f(1.0f, 1.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 0.0f);
glEnd();

///////////////
//2D WINDOW! //
///////////////
glViewport (0, 0, (1024*resmultipliery), (768*resmultipliery));
glMatrixMode (GL_PROJECTION);						// Select The Projection Matrix
glLoadIdentity ();							// Reset The Projection Matrix
			// Set Up Ortho Mode To Fit 1/4 The Screen (Size Of A Viewport)
gluOrtho2D(0, (1024*resmultiplierx), (768*resmultipliery), 0);
	
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();

LoadTexture(helpover);
DrawRect(58,307,104,332);

LoadTexture loads the texture, and DrawRect draws a quad. I'll post links to images that display the problem: What's actually happening What it should look like Many thanks for your help! Sputty.

Share this post


Link to post
Share on other sites
Advertisement
You'll want to set your colour back to white right before drawing the textured quad with glcolor3f(1.0f, 1.0f, 1.0f).

Share this post


Link to post
Share on other sites
In your texture setup code you probably have (or don't have) this call:

glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);

which will modulate texture fragments with the colour fragments. To prevent this, you can replace GL_MODULATE with GL_DECAL.

Share this post


Link to post
Share on other sites
Quote:
Original post by LordSputnik
Will that work with lighting? I read somewhere that it needed to be Modulate for textures to work with lights...

It won't work with lighting in the sense that the surface won't be lit, just as it won't be coloured/tinted either.
You don't usually want to have screen aligned sprites affected by lighting though, you could add a flag to your texture function to tell it whether it's loading a UI texture or a scene texture - or, as V-man said, keep control of the current colour.

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!