glColor4f not setting alpha value

Started by Whackjack, November 30, 2005, 22:20:03

Previous topic - Next topic

Whackjack

I've got this in my code:

GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
GL11.glRecti(100, 100, 200, 200);
GL11.glColor4f(1.0f, 1.0f, 1.0f, 0.25f);
GL11.glRecti(150, 150, 250, 250);


So, we have a white rectangle with a semi transparent rectangle slightly overlapping in the top right corner.  However, the second rectangle is not semi transparent.  It seems to be ignoring the alpha value altogether.  Is there something that I failed to set up correctly?

CaseyB


Whackjack

Hmmm... I thought I read in another thread that blending didn't need to be enabled when using glColor4f.  I'll go ahead and try that and post my results.  Thanks, CaseyB.

Whackjack

Consulting the Redbook, I found some blending code and added the following to my program

GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);


And it works perfectly!  Thanks again, CaseyB!!

CaseyB