Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get current color

Tags:

c++

opengl

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);
like image 284
ronag Avatar asked Oct 26 '10 22:10

ronag


People also ask

What is current color?

The currentcolor keyword represents the value of an element's color property. This lets you use the color value on properties that do not receive it by default. If currentcolor is used as the value of the color property, it instead takes its value from the inherited value of the color property.

How do I change the current color in CSS?

If you need to change the color, you only need to do it in one place (i.e. on the color property). All the currentcolor references will automatically use the new color. That probably looks like a pretty useless example, as the text and background are now the same color. You won't be able to see the text.

What does fill Currentcolor mean?

currentColor is useful when you want a certain color to be consistent in an element. For example, if you want an element to have a border color that's the same as the element's text color, using currentColor makes a lot of sense because then if you decide the main text color you can change the value at only one place.

Is color a keyword in JavaScript?

The currentcolor keyword refers to the value of the color property of an element.


1 Answers

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

float currentColor[4];
glGetFloatv(GL_CURRENT_COLOR,currentColor);
like image 106
tibur Avatar answered Oct 02 '22 12:10

tibur