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.
Well, you can get the last value set with
glColor4fby usingglGetwithGL_CURRENT_COLOR, but I wouldn’t recommend it;glGetoperations are generally bad for your performance, so try not to do it too often.A better idea would be to maintain a local copy of the last value you sent to
glColor4f, so that you have the data client-side instead of having to request it from the opengl driver.There’s no way to add or subtract from the current color that I’m aware of.Edit: Actually I just looked up and see this function called
glSecondaryColorwhich may do what you want. You can supply a second RBG color, and then enable GL_COLOR_SUM, and the two colors get added together.