Hi,
I have a problem with my semi-transparent planes. If I draw the red one first, then the blue one, the blue one is not drawn where they overlap.
My DrawFunc
GLvoid MyClass: :DrawMyStuff()
glEnable(GL_DEPTH_TEST);
glMaterialfv(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE,mat_ambient);
if(drawPoly)
ObjList->Draw(GL_TRIANGLE_STRIP);if(drawConnected) ObjList->Draw(GL_LINE_STRIP); glMaterialfv(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE,mat_ones); if(drawPoints) { glPointSize(2.0f); ObjList->Draw(GL_POINTS); }
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);if(VPlane1) DrawVPlane(VPlane1Pos); if(VPlane2) DrawVPlane(VPlane2Pos); if(HPlane1) DrawHPlane(HPlane1Pos); if(HPlane2) DrawHPlane(HPlane2Pos); glDisable(GL_BLEND);
}
GLvoid MyClass: :DrawHPlane(int pos)
{
GLfloat mat = { 1.0, 0.0, 0.0, 0.5 };
glBegin(GL_QUADS);
glColor3d(0.75f, 0.0f, 0.25);
glMaterialfv(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE,mat);
glVertex3d(-400.0, pos, -300.0);
glVertex3d(-400.0, pos, 300.0);
glVertex3d(400.0, pos, 300.0);
glVertex3d(400.0, pos, -300.0);
glEnd();
}GLvoid MyClass: :DrawVPlane(int pos)
{
GLfloat mat = { 0.0, 0.0, 1.0, 0.75 };
glBegin(GL_QUADS);
glColor3d(0.25f, 0.0f, 0.75);
glMaterialfv(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE,mat);
glVertex3d( pos,-10.0, -300.0);
glVertex3d( pos,-10.0, 300.0);
glVertex3d( pos, 1200.0, 300.0);
glVertex3d( pos, 1200.0, -300.0);
glEnd();
}
Could you guys tell me what’s wrong about this??
Thanks,
Martin
[This message has been edited by mphanke (edited 04-22-2002).]