Jump to content
  • Advertisement
Sign in to follow this  
pixelhead

glColorPointer and per model alpha

This topic is 3866 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

Hi - I'm reading in model data with per-vertex color as RGB. In the program, I need to interactively change the alpha. The alpha is per model so each vertex would have the same alpha value. I was wondering if there is an easy way to do it using vertex arrays and glColorPointer() without having to loop through each color array element to set the alpha, like a single glColor() call. Also, I'm guessing that when GL_COLOR_ARRAY is enabled, all glColor calls are ignored? Thanks, Daren

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by pixelhead
Also, I'm guessing that when GL_COLOR_ARRAY is enabled, all glColor calls are ignored?


Yep, if you use client vertex arrays to specify an attribute, it overrides the immediate mode state for that attribute.

First off, the easiest way to do what you want is with a shader. However, you should also be able to do it with texture combiners. I'm not sure what other texturing you are doing, but you could do something like:

Set COMBINE_RGB to REPLACE, use GL_PRIMARY_COLOR for arg0, use SRC_COLOR for the operand.

Set COMBINE_ALPHA to REPLACE, use GL_CONSTANT for arg0, use SRC_ALPHA for the operand.

Set the texture environment alpha color to the alpha value you want.

If you want texturing, then set up the COMBINE_RGB as needed.

Share this post


Link to post
Share on other sites
Thanks for the hint about texture combiners. It's actually a one-liner:

glTexEnvf( GL_TEXTURE_ENV, GL_ALPHA_SCALE, fAlpha );

Works like a charm.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!