• Advertisement

Archived

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

Transparency?? Masking?? WTF :)

This topic is 5527 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 am currently working on creating the main menu of my opengl/c++ project. I have created a Button class that I can use in the game gui and menus. Currently I create a quad and draw a oval shaped texture on it, along with the texture''s white background). Now I know when drawing bitmaps on the screen you can select a color that will not be drawn to create transparency, but what about textures. Ive looked into masking a bit on Nehe''s site an think that may be the answer, but im not sure if i want to use it as you need to create the extra black and white texture for each image you want to mask. So is masking the only solution to having textures with transparency? What about the alpha channel, does that control the ENTIRE image''s translucency or can i use that to create some sort of texture with transparent areas. Basicly what options do i have when creating a texture with transparency so i can create odd-shaped buttons?? Thanks!

Share this post


Link to post
Share on other sites
Advertisement
Use your favorite photo editor to add an alpha channel to your texture. That way you can control which parts of your texture should be transparent, which should be opaque and which should be in between. Both Paint Shop Pro and Photoshop support alpha channels. Save your texture as a TGA or another format that has built-in alphachannel support. Then, just set up your glBlendFunc to SRC_ALPHA, ONE_MINUS_SRC_ALPHA, and enable GL_BLEND.

Share this post


Link to post
Share on other sites
Cool, that sounds simple enough. I am currently using bmps for my images, but it''ll be no problem switching formats. So when I use those blending settings will those texture areas elimenated by the alpha channel show clear or will they show the quad''s regular color (I assume it does, but cant test it at the moment). If this is the case then why do people bother to use masking?? Is it if they want to use a file format without an alpha channel??? Why!!!

Share this post


Link to post
Share on other sites
I do it differently.
I have a function that loads BMPs (8bpp) both as rgb and alpha. The alpha is set by the luminosity of each pixel. Black means 0 alpha, white means 255 alpha (and values in between, of couse).
Then, I use:

glEnable(GL_ALPHA_TEST);//enable alpha filtering, so we have some alpha key
glAlphaFunc(GL_GREATER,0.1f);

Share this post


Link to post
Share on other sites
What I have d3d8 do for me(you can do this yourself) is that I choose pink color as my transparent. Then I ask d3d to convert pink in the bitmap or image into alpha channel(my source image is w/o alpha channel, internally my destination surface has added alpha channel) at load time. I then do alpha test and I'm done. The reason why I don't use alpha channel is because the mfc api handles bmp only. Though the idea of creating two bmp one with alpha is interesting, though storage space increases with each bitmap.

[edited by - JD on December 4, 2002 3:11:09 AM]

Share this post


Link to post
Share on other sites

  • Advertisement