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);
Either you store the last alpha value you sent using glColor4f
, either you use:
float currentColor[4];
glGetFloatv(GL_CURRENT_COLOR,currentColor);
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.
精彩评论