Jump to content
  • Advertisement

Archived

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

Elixir

OpenGL Masked texture colors in OpenGL?

This topic is 6735 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
Advertisement
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:

glEnable(GL_COLOR_LOGIC_OP);
glLogicOp(GL_AND);
glColor3f(1.0, 0.0, 0.0);
glBegin();
.
.
glEnd();

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.

glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, X );

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...

]Andrea[



Share this post


Link to post
Share on other sites

  • 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!