Click here to Skip to main content
12,457,938 members (50,510 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C++ OpenGL Texture2D
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 19-Dec-12 1:42am
Comments
Abhishek Pant 19-Dec-12 10:54am
   
use photoshop!

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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.

// 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.
  Permalink  

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160826.1 | Last Updated 19 Dec 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100