Alpha blending problem

OK, so I’m doing something stupid, but I don’t know what it is: I’m trying to draw a set of bodies that are translucent, and then draw a set of axes at their center. That way, even if the axes are completely inside the object, the user will be able to see them. What I am getting instead is just the regular, depth-buffered view (ie. - no blending). What gives?

glEnable (GL_DEPTH_TEST);
glEnable (GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

//

glDepthMask(GL_TRUE);
double dblLineWidth;
glGetDoublev (GL_LINE_WIDTH, &dblLineWidth);
glLineWidth (2.0);
glBegin (GL_LINES);
glColor3f(0,1,0);
glVertex3f(0,0,0);
glVertex3f(temp, 0, 0);

  glColor3f(0,0,1);
  glVertex3f(0,0,0);
    glVertex3f(0, temp, 0);

  glColor3f(1,0,0);
  glVertex3f(0,0,0);
    glVertex3f(0, 0, temp);
glEnd ();

glDepthMask (GL_FALSE);
double dbl4Color[4];
glTranslatef (-fltXCenter, -fltYCenter, -fltZCenter);
for (vector <CADObject *>::iterator i = m_vecObjects.begin();
i != m_vecObjects.end(); i++)
{
(*i)->GetGridColor (dbl4Color);
glColor4dv (dbl4Color);
dbl4Color[3] = .3333; // Set the transparency of the body to 1/3
glCallList ((*i)->GetBaseDisplayList());
}
glDepthMask(GL_TRUE);

I cant remember but you have to either draw the translucent objects first or last…I see that you are drawing the translucent one last so maybe it has to be the other way?

I’m not sure about this, but it seems that you are assigning the color value to an array
(*i)->GetGridColor (dbl4Color);
glColor4dv (dbl4Color);
dbl4Color[3] = .3333; // Set the transparency of the body to 1/3
but you never call glColor4fv(dbl4Color);
I assume that you call this in your display list, but if I remember correctly all vertex data including color is stored in the display list, it will use whatever value of dbl4Color was used when the list was compiled. Try moving the color command out of the list and calling glColor4fv() before glCallList

Thanks, guys - chowe6685 was right - I was just being stupid. it doesn’t work so well if you call glColor() and then set the array to the value you want in it!! Doh!!

Chris

This is not actually related to you problem but may came as a suggestion :

Instead of Drawing Translucid Objects in order to view the axes you could do something like this :
glEnable(GL_DEPTH_TEST);
DrawYour Objects;
glDisable(GL_DEPTH_TEST);
DrawAxes; (they will be drawn in front of the objects )
glEnable(GL_DEPTH_TEST); ( Just in case you draw something after and forget to enable the Depth test )

I have done such a implementation and it works just fine ( like in 3DSmax & others )

Hope this helps,
Clau