GL/GLUT texture alpha problem

Posts: 2
Joined: 2010.11
Post: #1
I am having a problem with my alpha in my textures. It was a bit more screwey than this, but I messed around a bit and this is what my textures look like where they should be transparent:
[Image: problem2.gif]
I know that the alpha in the textures works because earlier when I had a different problem ( the stars in the background came through. My GL stuff is set up like this:
glEnable (GL_LINE_SMOOTH);
    glAlphaFunc(GL_GREATER, 0.0f);
and my reshape function is:
void reshape(int width, int height)
    glViewport(0, 0, width, height);
    glOrtho(0, 1024, 0, 768, -1024, 1024);
    gluPerspective(45, width/height, 1024, 1024);

Has anyone had a problem with semi non-functional alpha before? This is strange because although the alpha works(the cutout around the shapes), it doesn't blend at all.
Quote this message in a reply
Posts: 1,563
Joined: 2003.10
Post: #2
Judging by the screenshot, it looks like you're drawing things in the wrong order. In order for alpha blending to work correctly, you have to draw the objects in the scene in order of backmost to frontmost, relative to the viewer.

Alex Diener
Quote this message in a reply
Posts: 1,487
Joined: 2002.09
Post: #3
I'm pretty sure you don't want to enable the alpha test. I've never actually used it. But I think that it's used as a threshold for the alpha. Try disabling that.

Scott Lembcke - Howling Moon Software
Author of Chipmunk Physics - A fast and simple rigid body physics library in C.
Quote this message in a reply
Posts: 776
Joined: 2003.04
Post: #4
Alpha test basically says: if this condition is met, don't draw a pixel. The reason why you can see thru fully transparent areas but without blending on the edges is that the edges (and the inside) are drawn before the background, and the depth buffer too, so when you want to draw something behind it, the depth buffer will filter it because it is behind!

So, yes, leave alpha test enabled (for performance reasons), leave blending enabled AND draw using the painter's algorithm (far to nearest).
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  OpenGL Alpha Channel Problem Moganza 1 5,745 Jan 19, 2013 08:25 AM
Last Post: sealfin
  Texture coordinate problem Oddity007 0 3,144 Jan 21, 2009 06:20 PM
Last Post: Oddity007
  Alpha Masking Problem bonanza 5 6,009 Jun 29, 2008 11:58 AM
Last Post: maximile
  Pasting an image with alpha mask on a texture Najdorf 10 9,154 Jun 24, 2008 03:23 PM
Last Post: Najdorf
  Porting SDL to Cocoa OpenGL view--texture problem smittyz 7 8,847 Jul 21, 2007 07:53 PM
Last Post: smittyz