Alpha blending? 32 bit .tiff? Photoshop? WTF

Hey anyone have any luck with alpha blending? My whole game is textured but when I try to blend the color it just gets lighter. I think I need to have GL_RGBA in my gluBuild2DMipMaps function but when I do that it crashes(windows dosen’t like it)
When I use GL_RGB it works but no alpha blending with the background. I have been fooling around with photoshop but am starting to think it is in vien. Any ideas if it is my .tiff formating or what?

Which “BlendFunc” do you use ?
I use

glBlendFunc(GL_SRC_ALPHA,GL_ONE);



glTexImage2D(GL_TEXTURE_2D,0,
4,                               //important
width, height, 0, 
GL_RGBA,                          //important
GL_UNSIGNED_BYTE, data);

hope that is right :smiley:

PS: My format is PNG, that is great :wink:

Most probably your tif loader is broken for RGBA.
Try a debugger, on a super simple 4 pixel rgba texture (each texel with very different values for easier debug), and check the data which is passed to gluBuild2DMipMaps.

DarkShadow44, instead of 4 as internal format, I advise using the more correct GL_RGBA8, as explained here :
http://www.opengl.org/sdk/docs/man/xhtml/glTexImage2D.xml

Ok I think ZbuffeR is right as I might be runinng here before I can walk as my loader is just cut and paste. About to just keep my HUD display solid, this is my loader below it must be inadequate. changeing to GL_RGB works fine btw

GLuint LoadTexture( const char * filename, int width, int height )
{
GLuint texture;
unsigned char * data; // load in bytes of the pictures
FILE * file;
file = fopen( filename, “rb” );
if ( file == NULL ) return 0;
data = (unsigned char *)malloc( width * height * 3 );
fread( data, width * height * 3, 1, file );
fclose( file );
glGenTextures( 1, &texture );
glBindTexture( GL_TEXTURE_2D, texture );
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); // set the details of the texture settings
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
gluBuild2DMipmaps(GL_TEXTURE_2D, 4, width, height, GL_RGBA8, GL_UNSIGNED_BYTE, data);
return texture;
}

Yikes my eyes :
data = (unsigned char *)malloc( width * height * 3 );
fread( data, width * height * 3, 1, file );

GL_RGBA8 needs 4 byte per pixel, not 3 ! No wonder it crashes.

Hey thanks, why don’t you come over and sit on my couch for when I need help. (That would be awesome to have a guru handy, lol)