Texture Alpha Channel

Member
Posts: 142
Joined: 2002.11
Post: #1
I'm working off the nehe basecode:

What do I need to do so that the alpha channel in my targa texture's will draw as transparent? Right now they're completely ignored. I've been at this for days and just can't figure out whats wrong. Shouldn't I just have to call:

glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_NOTEQUAL, 0.0);

What else is it I need to do?

I put an NSLog in the texture loading function so I can verify that it is recognizing it as having an alpha channel and storing it as RGBA.

If need be, I'll post the source on the net.
Quote this message in a reply
Sage
Posts: 1,232
Joined: 2002.10
Post: #2
Quote:Originally posted by Holmes

I've been at this for days and just can't figure out whats wrong.

Step 1: read the manual.
http://www.opengl.org/developers/documen...index.html

In particular, "Per-Fragment Operations:Blending."

Quote:
What else is it I need to do?


Step 2: turn on blending.
glEnable(GL_BLEND)

Step 3: pick a blending function.
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
Quote this message in a reply
Member
Posts: 142
Joined: 2002.11
Post: #3
I have blending enabled, with that same mode you stated too.

I have the red book so I do indeed read the manual. I find it little help at all at most times. The red book is quite cryptic in that sometimes it doesn't even define its own terms, and it rarely adresses real world situations. I'll read what you suggested, however, and report back.
Quote this message in a reply
Member
Posts: 142
Joined: 2002.11
Post: #4
I fixed the problem. Turns out Nehe's texture loading code doesn't actually handle alpha...Anyway, I fixed it by writing up some code that handles TGA files specifically.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  OpenGL Alpha Channel Problem Moganza 1 3,134 Jan 19, 2013 08:25 AM
Last Post: sealfin
  Pasting an image with alpha mask on a texture Najdorf 10 5,915 Jun 24, 2008 03:23 PM
Last Post: Najdorf
  Trouble writing PNGs with 16 bits per channel using libpng flash 2 3,833 Aug 28, 2006 11:01 AM
Last Post: flash
  Using 8-bit greyscale texture as an alpha channel? TomorrowPlusX 12 4,997 Apr 10, 2006 08:43 AM
Last Post: TomorrowPlusX
  Alpha Channel Woes GraySupreme 5 4,272 Jul 26, 2005 01:24 PM
Last Post: NYGhost