Jump to content
  • Advertisement
Sign in to follow this  

OpenGL Using 2x color modulation in FFP

This topic is 1268 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello guys


Im asking this question for a friend of mine. He has an old program thats still using the FFP for rendering in OpenGL. Right now it still all works but there is a new feature hed like to implement. Every vertex has a color value. But its modulated in a different way. In GLSL in the fragment shader it would be like:

gl_FragColor = input_color.rgb * 2 * texture_color;

So essentially a color value of 0x7F7F7F7F would just return the texture color whereas 0xFFFFFFFF would double all channels of the texture.


The color values are bound to a buffer and sent to the FFP using glColorPointer. In DirectX i remember there was some kind of texture sampler state that allowed to specify MODULATE_2X as color operation. Is there something similar in OpenGL?




Share this post

Link to post
Share on other sites

The good news is yes, there is.


It's part of the GL_ARB_texture_env_combine extension, or is core in IIRC GL1.4, so if one's hardware meets those requirements then one can do it.


The basic setup is:




Note that though the API appears otherwise, by specification the only legal values for GL_RGB_SCALE are 1, 2 or 4.  If you come across hardware or drivers that accept other values, be aware that it's non-standard behaviour.


Also be aware that the GL_RGB_SCALE value seems to "stick" for other GL_TEXTURE_ENV_MODEs on some (most?/all?) drivers, so you should also reset it to 1.0f when done.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!