Color keys in OpenGL
Is there a way to make a specific color completely transparent?
I see plenty about alpha blending, but nothing about specific colors being transparent.
It''s not supported by the hardware. You''ll have to fake it by an alpha mask or using regcoms.
search this forum for ''colourkey'' btw u cant do it in opengl but it should give the answer u want
http://uk.geocities.com/sloppyturds/gotterdammerung.html
http://uk.geocities.com/sloppyturds/gotterdammerung.html
You can use AlphaTest
glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GREATER,GL_ZERO);
to simulate a colorkey. This is very fast
but you must have a spezial alpha channal
(GL_RGBA) because this function only draws
the texture pixel with an alpha value greater
then zero.
It is better then Alphblending because
it is much faster and you have no problem
with lightning which appears on blending
parts too.
glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GREATER,GL_ZERO);
to simulate a colorkey. This is very fast
but you must have a spezial alpha channal
(GL_RGBA) because this function only draws
the texture pixel with an alpha value greater
then zero.
It is better then Alphblending because
it is much faster and you have no problem
with lightning which appears on blending
parts too.
Here''s what I did. I used set a color key to the SDL_Surface, used SDL_DisplayFormatAlpha() to get a surface with an alpha channel with the keyed color set to alpha of 0. Then I created a texture from the alpha surface with the GL_BGRA (SDL loads bitmaps in BGR format) thing set.
it ALMOST worked. Now, instead of the color key color, I get black. Any ideas?
it ALMOST worked. Now, instead of the color key color, I get black. Any ideas?
I got it to work a little better. Now the color keyed color is transparent, but it leaves 1 pixel of black along the right edge of whatever it''s drawing. Like, if I''m drawing text, it makes the text look bold. like this: 0 = 0).
And ideas?
And ideas?
That''s caused by the bilinear interpolation of the alpha channel. If you use an alpha-test to get it transparent, then instead of testing for > 0, test for > threshold. Threshold is a value between 0 and 254, that will cut the black border at different positions, try some values until you got a good result. Another possibility is to stay with > 0, but turn off filtering on text.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement