2

With a method like glColor4f(0f, 0f, 0f, 0f);, it sets the values to whatever parameters one puts in. However, what I would like to do is only slightly change a color. Is there any existing OpenGL method that will add or subtract its parameters to the existing colors it has?

The only other way of doing this that I can come up with is first getting its color values, then editing those how I want to, and finally sending them back with glColor4f().

So, in closing, I would like to know if there is either a method for editing existing RGBA, or at least retrieving an existing RGBA.

4

1 回答 1

2

好吧,您可以glColor4f使用glGetwith获得最后一个设置的值GL_CURRENT_COLOR,但我不推荐它;glGet操作通常对你的表现不利,所以尽量不要太频繁。

一个更好的主意是维护您发送到的最后一个值的本地副本glColor4f,以便您拥有数据客户端,而不必从 opengl 驱动程序请求它。

没有办法从我知道的当前颜色中添加或减去。

编辑:实际上我只是抬头看到这个函数glSecondaryColor,它可能会做你想做的事。您可以提供第二种 RBG 颜色,然后启用 GL_COLOR_SUM,这两种颜色会加在一起。

于 2012-06-16T05:01:08.253 回答