PDA

View Full Version : basic blending



hoshi55
07-12-2001, 01:35 AM
this is probably very very basic and i've done this a million times ago but in my latest project, openGL refuses to do any blending for me.
i think i've initialized everything correctly and all function calls do what they're supposed to do but all alpha components i specify (in textures and in glColor4f) are simply ignored and set to 1.0.
did i forget to initialize anything? here's my init code..

// light vars
GLfloat litediff[] = { 1.0, 1.0, 1.0, 1.0 };
GLfloat litespec[] = { 1.0, 1.0, 1.0, 1.0 };
GLfloat liteamb[] = { 0.2, 0.2, 0.2, 0.2 };
GLfloat litedir[] = { 1.0, 1.0, 1.0, 0.0 };

glClearColor(0.0, 0.0, 0.0, 0.0);
glShadeModel(GL_SMOOTH);

// lighting stuff
glLightfv(GL_LIGHT0, GL_DIFFUSE, litediff);
glLightfv(GL_LIGHT0, GL_SPECULAR, litespec);
glLightfv(GL_LIGHT0, GL_AMBIENT, liteamb);
glLightfv(GL_LIGHT0, GL_POSITION, litedir);

glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);

// blending stuff
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);

glHint(GL_POINT_SMOOTH_HINT,GL_NICEST); // Really Nice Point Smoothing
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );

// texture mapping stuff
glPixelStorei(GL_UNPACK_ALIGNMENT,1); // determine pixel storage format
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);

// enable environment mapping
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);