Hi. I’d like to know of any common approaches for accomplishing the following.
A program loads a texture with glTexImage2D, and then later calls glBindTexture when drawing on a rectangle. Say someone has “slider” type of GUI that controls the alpha value of the texture. If the slider was all the way to the right, the texture would be opaque, and all the way to the left would be transparent, and in between would be some semi-transparent.
One way would be to recall glTexImage2D each time the slider is moved in order to change the transparency values.
Another way might be to use some kind of GL_MODULATE and change the alpha value of the rectangle using glColor4f?
Secondly, what if instead of a simple range from transparent to opaque, the user wanted to apply some algorithm based on the values in the texture. For example, suppose the user specified 2 values (high and low) and the user wanted all the pixels in the texture that had red values above high to be opaque, and all the pixels with red values below low to be transparent, and all the pixels with red values in between high and low to be a range of transaparency from opaque to transparent.
The same as #1 above
Thank you for your time.