LWJGL Forum

Programming => OpenGL => Topic started by: Whackjack on November 30, 2005, 22:20:03

Title: glColor4f not setting alpha value
Post by: Whackjack on November 30, 2005, 22:20:03
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?
Title: glColor4f not setting alpha value
Post by: CaseyB on November 30, 2005, 23:31:22
Did you enable blending?
Title: glColor4f not setting alpha value
Post by: Whackjack on December 01, 2005, 16:00:48
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.
Title: glColor4f not setting alpha value
Post by: Whackjack on December 01, 2005, 16:07:54
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!!
Title: glColor4f not setting alpha value
Post by: CaseyB on December 01, 2005, 16:13:13
Glad I could Help!!  :D