tags:

views:

39

answers:

2
+3  Q: 

Get current color

Im using glColor4f(1.0f, 1.0f, 1.0f, alpha_); to set transparency to primitives I'm drawing.

However I'd like to be able to read the current opengl alpha value. Is that possible?

e.g.

float current_alpha = glGetAlpha(); //???
glColor4f(1.0f, 1.0f, 1.0f, alpha_*current_alpha);
+2  A: 

Either you store the last alpha value you sent using glColor4f, either you use:

float currentColor[4];
glGetFloatv(GL_CURRENT_COLOR,currentColor);
tibur
+1  A: 

Do you mean the alpha value of the fragment you're drawing on (which would explain why you want alpha_ * current_alpha)? If so, remember that reading a fragment back from the pipeline is expensive.

If you're rendering back to front, consider using the GL_SRC_ALPHA + GL_ONE_MINUS_SRC_ALPHA trick.

Frédéric Hamidi
Thank you. I'm trying to do something similar.
ronag