Masked texture colors in OpenGL?
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?
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.
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.
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[
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[
IpSeDiXiT
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement