Transparent

I have this simple code

void display(void) {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glDepthMask(GL_TRUE);
glDisable(GL_BLEND);
draw_opaque_geometry();
glDepthMask(GL_FALSE);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); draw_translucent_geometry();
glutSwapBuffers();}

It is working nicely, but I have some questioned but I don’t really understand, I hope you can help me …
Let say, the opaque object is a cone and the translucent object is the tube/cylinder. Actually, there is a list of cone and cover with the tube. Now, I want to play with the opacity of the object. Firstly, I changed the opacity of the tube and it is look good. so, I can see the cone inside properly. Secondly, I want to change the opacity of cone then it does not look like transparent because the cone was changed but it is not transparent like white color. Can you tell me what is the problem about ?

i don’t know if you enabled GL_DEPTH_TEST or not… i suppose not.

each primitive (note, primitive, not object) you want to be translucent, should rendered in depth order from far to near… painter’s algorithm.

translucency, well every blending operation, is by its nature incremental: they rely on what already is in the frame buffer to achieve the effect.

if you render object A, then object B, you’ll get the right effect only if the transparent object is B, because A sees through B since A was rendered before… but if you wish A to be as transparent in your case, you should see the back side of B through A… wich is impossible since you’re drawing B now, and not before A.

i don’t know if a general solution exist, but i would take your objects, split them into the building primitives (tris quads lines …) sort them in far-to-near order and then render them with blending enabled.

this needs supporting structures and algorithms but it is not that difficult…