Weird bug with glColor3f

Started by EB5473, December 28, 2012, 06:01:16

Previous topic - Next topic

EB5473

Hello all you wonderful people!
Whilst screwing around with the nightmare that is image loading, i noticed an odd little quirk.
For some odd reason, this:
        glBegin(GL_QUADS);
		//render red back
		glColor3f(1f,0f,0f);
		glVertex2f(0,0);
		glVertex2f(0 + 100, 0);
		glVertex2f(0 + 100, 0 + 25);
		glVertex2f(0 , 0 + 25);
		
		//render green front, variable
		glColor3f(0f,1f,0f);
		glVertex2f(0,0);
		glVertex2f(0 + game.ph * 2, 0);
		glVertex2f(0 + game.ph * 2, 0 + 25);
		glVertex2f(0 , 0 + 25);
		[b]...[/b]


Which normally displays a green bar on top of a red bar, was now displaying a yellow bar on top of a red bar! Playing with the values, it looked as if
the first glColor3f statement was adding to the second! (E.G: glColor3f(1,0,0) and glColor3f(0,1,1) would make the last one glColor3f(1,1,1))

Any advice as to what might be going on here? Code can be provided upon request.
Coder, Mastermind, Friend

quew8

Firstly, what values do you have for glBlendFunc and glBlendEquation? Also, you say you were screwing around with image loading, does that mean GL_TEXTURE_2D is enabled? You should never have GL_TEXTURE_2D enables if all you are doing is solid colour primitives. You suggested that it was working before enabling texturing so that is probably your problem.
Finally, do you have any reason to not have both red and green bars variable so that there is no overlap? Although this doesn't get to the root of the problem, it would seem to be more efficient (less fragments to draw) and easier on you.

EB5473

*facepalm*
Thank you very much! 'twas the GL_BLEND that caused my woes. And yes, as strange as the overlap sounds, it's more of a way to show maximum(red) and current (green).
Thank you!
Coder, Mastermind, Friend

quew8

My Pleasure.
We all do at least 2 stupid things every day. It's just a shame when it happens while we are programming.