Jump to content
  • Advertisement
Sign in to follow this  
EmrldDrgn

OpenGL Drawing textures with masking

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

How can I draw a texture on a quad with masking? Is there a way that I can tell OpenGL not to draw any pixels in my texture that have a color value of 0, 255, 0?

Share this post


Link to post
Share on other sites
Advertisement
Create an alpha channel for your texture. Create a new buffer with 4 bytes per pixel and copy your texture data to it. For each pixel, copy over the color data from the old texture in the first 3 bytes and set the 4th (alpha) byte to 0 or 255. Use 0 for pixels that match the mask color, 255 otherwise. Load the new texture data into your ogl texture using an rgba texture format. Then set up the alpha test to discard pixels with an alpha value less than 255.

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!