Advertisement Jump to content


This topic is now archived and is closed to further replies.


OpenGL Masked texture colors in OpenGL?

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

Is it possible to set a bitmask on a texture in OpenGL? I have a RGBA texture and I want to suddenly mask out the blue and green (11111111 on the red, 00000000 on the other 2). Is there a function for this or would I have to use other means?

Share this post

Link to post
Share on other sites
This is a guess, I''ve never done anything with the glLogicOp before, but you might be able to use it to AND the source (texture) and destination (polygon to be textured). I''m doing this under the impression that when a texture is applied to a fragment, it goes through framebuffer testing/operations before being written. With this in mind, you could try something like this:

glColor3f(1.0, 0.0, 0.0);

Assuming you have COLOR_MATERIAL enabled in someway.

Sorry if this doesn''t work, but maybe it''s worth a try.

Share this post

Link to post
Share on other sites
If you want to apply a texture on a polygon and filter the color components (I''ve understood?) you have to change the texture environment.


where X = possible values : GL_REPLACE (normal texture mapping), GL_BLEND, GL_MODULATE and GL_DECAL.

You should see some help because it''s very difficult to remember every function (try to use all of them).

For example (I think) if you set GL_BLEND
and set glColor3f(0.0f, 0.0f, 1.0f);
you filter RED and GREEN component

For every pixel OpenGL combines the color you choose with the texel (you can use RGB or RGBA format).
Try to change the color and mode...


Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!