1
\$\begingroup\$

Surely OpenGL has a way to set the vertex color mode. By default it is multiplication.

When I have an existing texture on a quad to represent a player in my game, I want to add color to it. As of now, doing so only multiplies the color with the texels on the quad. So if I have a color that represents bright light say (128,128,128) what I want is additive behavior: take the color in the texel and add the channels together.

I have not found anything to do this automatically in OpenGL without the use of shaders or including a second draw step on one sprite with a different blend mode to simulate this.

\$\endgroup\$
  • \$\begingroup\$ Are you talking about the fixed function pipeline? Most modern games will use shaders instead, which gives you great control over the exact effect you want, and also great performance because it's the pathway that modern graphics cards & drivers expect to get heavy use. \$\endgroup\$ – DMGregory Sep 23 '18 at 18:47
  • \$\begingroup\$ I wish to add color to a textured quad, not multiply color as is default behavior. I wish to do this without shaders. \$\endgroup\$ – Maverick Sep 23 '18 at 19:45
2
\$\begingroup\$

The default (multiply) is specified by using (via the old fixed pipeline):

glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);

To change this to add, use:

glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_ADD);

Some things to note.

  • GL_ADD is not available in OpenGL 1.1; if you're limiting yourself to that version you will not be able to use this.
  • This is almost certainly not what you actually wish to do; I'd encourage you to try it anyway, see what it looks like, and understand what happens and why; then come back and ask a follow-up question outlining your requirement.
\$\endgroup\$
  • \$\begingroup\$ this sounds exactly what I'm looking for according to the docs. I'll give it a go. \$\endgroup\$ – Maverick Sep 23 '18 at 19:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.