Jump to content
  • Advertisement
Sign in to follow this  
lyen

OpenGL Set transparent color in RGB image

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

I am new to OpenGL ES, hopefully someone could kindly help me out. I have a RGB image with pink color set as transparency color. While in Direct3D, we can easily set the modulate color while creating the texture, my question is, how do we set up a transparency modulate color in OpenGL ES? In another word, how can I tell the graphic unit not to draw pink color when it's processing the texture. Thanks in advance.

Share this post


Link to post
Share on other sites
Advertisement
Hi lyen!

I haven't used OpenGL ES, but IMO, it's easier to apply the alpha layer in any graphics program (like Phothoshop), and save the image as png.

Share this post


Link to post
Share on other sites
Thanks for the reply and your suggestion, Juanxo.

I know what you suggested is a viable solution, but the programmer in me would like to know if there is a solution to programatically handle such issue =).

Share this post


Link to post
Share on other sites
I don't think OpenGL has a function for this (possibly some obscure extension that I don't know of though).

To do this you can either use a shader, or loop through the texture on CPU replacing pink with alpha before uploading.

The latter is probably the best idea as its a one time hit, and the branching required to implement this in a shader may not be very efficient.

Share this post


Link to post
Share on other sites
After a day of research, looks like Karwosts' suggestion is the most feasible.

DirectX does this for programmer during texture creation, I think OpenGL just wants us work a bit harder =).

Thanks all for your suggestions and help!

Share this post


Link to post
Share on other sites
Quote:
Original post by lyen
After a day of research, looks like Karwosts' suggestion is the most feasible.

DirectX does this for programmer during texture creation, I think OpenGL just wants us work a bit harder =).

Thanks all for your suggestions and help!


You are thinking of D3DX, the utility library.
The equivalent of the D3DX are some libraries at the Alternative Game Lib forum
here on gamedev.
A lot of stuff for doing math, quaternion, image manipulation.
Perhaps DevIL do what you want (DevIL = Developer Image Library)

Share this post


Link to post
Share on other sites
Sign in to follow this  

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