Original Post
Hi ppl i have problem with alpha blending.. i succesfully blend bitmap.bmp
and bitmapalpha.bmp for the first time when it is drawed... but every other
time i call my list Tree or any other it doesn''t blend correctly..Plz if
anyone can help here is the code i use...
GLvoid BuildLists()
{
Tree=glGenLists(2);
glNewList(Tree, GL_COMPILE);
glBindTexture(GL_TEXTURE_2D, texture[3]);
glBegin(GL_QUADS); // Start Drawing A Textured Quad
glTexCoord2f(0.0f, 0.0f); glVertex3f(-0.2f, -0.2f, 0.0f); // Bottom
Left
glTexCoord2f(1.0f, 0.0f); glVertex3f( 0.2f, -0.2f, 0.0f); // Bottom
Right
glTexCoord2f(1.0f, 1.0f); glVertex3f( 0.2f, 0.2f, 0.0f); // Top Right
glTexCoord2f(0.0f, 1.0f); glVertex3f(-0.2f, 0.2f, 0.0f); // Top Left
glEnd();
glBlendFunc(GL_ONE, GL_ONE);
glBindTexture(GL_TEXTURE_2D, texture[4]);
glBegin(GL_QUADS); // Start Drawing A Textured Quad
glTexCoord2f(0.0f, 0.0f); glVertex3f(-0.2f, -0.2f, 0.0f); // Bottom
Left
glTexCoord2f(1.0f, 0.0f); glVertex3f( 0.2f, -0.2f, 0.0f); // Bottom
Right
glTexCoord2f(1.0f, 1.0f); glVertex3f( 0.2f, 0.2f, 0.0f); // Top Right
glTexCoord2f(0.0f, 1.0f); glVertex3f(-0.2f, 0.2f, 0.0f); // Top Left
glEnd();
glEndList();
}
int DrawGLScene(GLvoid) // Here''s Where We Do All The Drawing
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glBlendFunc(GL_DST_COLOR,GL_ZERO); // Blend Screen Color With Zero
(Black)
glEnable(GL_BLEND); // Enable Blending
glDisable(GL_DEPTH_TEST); // Disable Depth Testing
glLoadIdentity();
glTranslatef(0.5f,0.15f,-2.0f);
glCallList(Tree);
glLoadIdentity();
glTranslatef(-0.5f,0.7f,-2.0f);
glCallList(Tree);
glEnable(GL_DEPTH_TEST); // Enable Depth Testing
glDisable(GL_BLEND);
}