[QUOTE=Carmine;1243062]I’ve seen artifacts like yours in some of my programs. I eliminated them by following the advice in the Redbook - particularly the DepthMask stuff shown below.[/QUOTE]Uh, this time it’s me that has to be sorry for the long waiting time before I reply back. I checked for an answer but suddely I got called in to a lot of work-related meetings and stuff to do after work, or else I normally try to answer people who help me ASAP - also for helping other people (for the record/archives).
Are your polygons two sided? If so, try culling the backfaces. Note that with Classic GL you are not going to be able to make transparency work correctly for lots (i.e. more than 2) objects. You could probably do that with shaders.
Hmm. That was hard questions for a guy like me. I frankly don’t know if my polygons are two-sided or not and I once remember doing something with culling, long ago. In any case: I’m really really grateful, because you’ve helped me solve my problem using the depthmask stuff you show below. Thank you very much for that - it seems to completely solve my problem!
I don’t understand the comment about: “not going to be able to make transparency work correctly for lots (i.e. more than 2) objects” - looks correct to me… Or maybe I’m not using classic GL ? Also, shaders - I’ve heard/read a lot about them but never really tried them because opengl is not my primary work. I work more with physics and reaction forces (in Matlab) on a daily basis. OpenGL is in my sparetime. Anyway, I think I’m getting better and better now, especially thanks to helpful people like you. I’ll not look into shaders for the moment - maybe in 1/2 year I’ll try working with them… Right now, I calculate some physics (position, velocity and acceleration) with Matlab and then I load the results into python using scipy and then I use openGL to show it. Impressingly enough, I’ve now found out how to import *.obj files from my CAD-program and show it in the openGL program that you just helped me with! So this is what I play with at the moment - later, shaders sounds like fun and I’ll also learn that within the next 12 months, I hope
void display (void)
{
GLfloat mat_solid[] = { 0.75, 0.75, 0.0, 1.0 };
GLfloat mat_zero[] = { 0.0, 0.0, 0.0, 1.0 };
GLfloat mat_transparent[] = { 0.0, 0.8, 0.8, 0.6 };
GLfloat mat_emission[] = { 0.0, 0.3, 0.3, 0.6 };
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix ();
glTranslatef (-0.15, -0.15, solidZ);
glMaterialfv(GL_FRONT, GL_EMISSION, mat_zero);
glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_solid);
glCallList (sphereList);
glPopMatrix ();
glPushMatrix ();
glTranslatef (0.15, 0.15, transparentZ);
glRotatef (15.0, 1.0, 1.0, 0.0);
glRotatef (30.0, 0.0, 1.0, 0.0);
glMaterialfv(GL_FRONT, GL_EMISSION, mat_emission);
glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_transparent);
glEnable (GL_BLEND);
glDepthMask (GL_FALSE);
glBlendFunc (GL_SRC_ALPHA, GL_ONE);
glCallList (cubeList);
glDepthMask (GL_TRUE);
glDisable (GL_BLEND);
glPopMatrix ();
glutSwapBuffers();
}
You’re completely right. For the record: Just using DepthMask (false) before drawing my object and DepthMask (true) after, solved my problem…
Thank you SO much, openGL friend ! I really appreciate your time to help me solve this… I’ll now read in redbook and play around with this for the whole sunday, where I have nothing else to do
I’m grateful because I would probably never have figured out this solution myself
Thanks for a great forum.