Hi,
I’m having a problem when texturing a quad with a png with aplha values.
The problem is that the part of the quad with alpha values are
appearing as white instead of no appearing at all.
Here’s some of the code.
------Loading of the png.------
SDL_Surface *tmp = IMG_Load(“img.png”);
SDL_SetAlpha (tmp, SDL_SRCALPHA, 0);
SDL_Surface *surf = SDL_DisplayFormatAlpha(tmp);
//Load the texture
glGenTextures(1, &theTexture);
glBindTexture(GL_TEXTURE_2D, theTexture);
glTexImage2D (GL_TEXTURE_2D, 0, 4, surf->w, surf->h, 0, GL_BGRA_EXT,
GL_UNSIGNED_BYTE, surf->pixels);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
GL_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
GL_NEAREST);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
glEnable(GL_TEXTURE_2D);
//--------------------------------------------------------
//--------------------------------------------------------
//------------ here’s some code of how I init OpenGL ----------------
glEnable(GL_BLEND);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_ALPHA_TEST);
glAlphaFunc (GL_GREATER, 0.0f);
//---------- END ----------------------
I believe the mistake must be somewhere over here.
Thanks in advance.
David.