PDA

View Full Version : Texture Alpha Channel


Holmes
2003.04.06, 11:39 PM
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.

arekkusu
2003.04.06, 11:58 PM
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/documentation/index.html

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


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);

Holmes
2003.04.07, 12:32 AM
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.

Holmes
2003.04.07, 01:17 AM
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.