Click here to Skip to main content
15,886,806 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi every body
I have an texture in a quad. but it's picture have transparent. OpenGL show that like this :

http://upload.tehran98.com/img1/roc36xty7n84mavubhzj.png[^]

what can I do ? ( i work with sdl )
Posted
Comments
Abhishek Pant 19-Dec-12 10:54am    
use photoshop!

1 solution

In OpenGL texture mapping, Transparency can be implemented through alpha blending. You can use GL_RGBA8 texture format to create Alpha enabled texture. Provide proper alpha values to get transparency. To get get opaque image, provide 255 as alpha value and to get fully transparent pixel provide 0 as alpha value. For semi-transparent pixels provide 128 as the alpha value.

On texture mapping enable blending to get transparent effect to the drawn image.

C#
// This function render the image with alpha blending to display only the alpha pixels.
    glEnable( GL_BLEND );
    glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
// Texture mapping code... 
// On drawing texture image, color of texel will be multiplied with the existing image.
// and it will provide transparent effect.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900