开发者

Get current color

开发者 https://www.devze.com 2023-01-22 16:12 出处:网络
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?

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消