PDA

View Full Version : blending big trouble



Visualc++
08-22-2002, 07:15 PM
hi again.... i try to use blend effect and the code is:
void SelectMaterialAguaG(int i)
{
//
// Define the reflective properties of the 3D Object faces.
//
glEnd();
GLfloat alpha=materialsAguaG[i].alpha;
MyMaterialAguaG (GL_AMBIENT, materialsAguaG[i].ambient,alpha);
MyMaterialAguaG (GL_DIFFUSE, materialsAguaG[i].diffuse,alpha);
MyMaterialAguaG (GL_SPECULAR, materialsAguaG[i].specular,alpha);
MyMaterialAguaG (GL_EMISSION, materialsAguaG[i].emission,alpha);
glMaterialf (GL_FRONT_AND_BACK,GL_SHININESS,materialsAguaG[i].phExp);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glColor4f(1,1,1,0.5f);
glEnd();
if(materialsAguaG[i].texture>-1)
{
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D,texture_mapsAguaG[materialsAguaG[i].texture].id);
}
else
glDisable(GL_TEXTURE_2D);
glBegin(GL_TRIANGLES);

glBegin(GL_TRIANGLES);

};

blend effect affect all the elements in the scene except the water, this water is a simple plane with a texture that emulating the water, this plane and this texture is only element in this scene but the blend effect not affect.... there is something bad in this code?, the plane required more subdivisions?, the texture is bad?, i try with others textures even other the examples where if it work.. a little help please... (sorry for my english)

Pentagram
08-22-2002, 11:56 PM
I didn't really look at your code but has your texture an alpha channel? Your blending is correct by not making the texture tranparent if you don't have an alpha channel.