About Alpha Blending...

Started by
3 comments, last by Arlo13 22 years, 9 months ago
My initializing is similar to the Tut33, and my code for render a .tga with alpha blending test is :
  

glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
glEnable(GL_TEXTURE_2D);				
glEnable(GL_CULL_FACE);	

   glBindTexture(GL_TEXTURE_2D, texture[0].texID);
   glBegin(GL_QUADS);
      glNormal3f( 0.0, 0.0, 1.0);
      glTexCoord2f(0.0, 0.0); glVertex3f(-1.0, -1.0,  1.0);
      glTexCoord2f(1.0, 0.0); glVertex3f( 1.0, -1.0,  1.0);
      glTexCoord2f(1.0, 1.0); glVertex3f( 1.0,  1.0,  1.0);
      glTexCoord2f(0.0, 1.0); glVertex3f(-1.0,  1.0,  1.0);
   glEnd();

glDisable(GL_CULL_FACE);
glDisable(GL_BLEND); 

  
Why doesn''t it work with the lesson33''s texture ?? The alpha test doesn''t work and I can see the quad border ! Thanks a lot ! PS: Scuze my english, I''m living in France :p "Software is like sex, it''''s better when it''''s free !"
"Software is like sex, it''s better when it''s free !"
Advertisement
How are you loading your texture? The setup / drawing looks ok.
You didn''t make the Depth Mask read only before rendering to the screen. If you don''t, the new drawing will overwrite the pixels in the depth buffer before they can be blended. Therefore the alpha will not show.

Call this to make the Depth Buffer read only
glDepthMask(GL_FALSE);

Call this to restore the Depth Buffer
glDepthMask(GL_TRUE);

Note that you need to draw all your opaque objects first, then draw your transparent objects.

-Blackstream

Will you, won''t you, will you, won''t you, won''t you take my virus?

-The Mad Hacker

Blackstream''s Webpage
-Blackstream Will you, won't you, will you, won't you, won't you take my virus?-The Mad HackerBlackstream's Webpage
For loading my texture, I use the functions of the lesson 34.
And it doesn''t work....
I have try to put the glDepthMask to false but no results...

It''s very strange because when I try to render a 32bits TGA Texture, it''s doesn''t work! My texture is very strange, with a lot a little RGB quad ...

Please help me

"Software is like sex, it''''s better when it''''s free !"
"Software is like sex, it''s better when it''s free !"
Hi,

On my site, I''ve a simple example who display a tree with and without alpha blending.

The texture is a TGA file with a alpha chanel.

Please, send me feedback.

"Download" section on my site.

========================
Leyder Dylan
http://ibelgique.ifrance.com/Slug-Production/
========================Leyder Dylan (dylan.leyder@slug-production.be.tf http://users.skynet.be/fa550206/Slug-Production/Index.htm/

This topic is closed to new replies.

Advertisement