I've been trying to make an application with OpenGL on Java under Eclipse, using JOGL.
I want to make a 3D head transparent in order to make the tongue and the oral cavity visible.
Even if I enable glColor and set the alpha value to 0.5f , the program seems to ignore that and consider all the alphas 1.
After digging a little bit more, I found out that, if I use ONE_MINUS_SRC_ALPHA for the destination the result I get is the same one as if I hadn't enabled blending at all. So, only depth test gets disabled, and the glEnable(GL2.GL_BLEND) statement is ignored. The objects are visible depending on the order they are drawn, even if I've chosen them to be 50% transparent. It's as if they are all opaque. The program ignores the glColorf4 statement I wrote.
If I use gl.glBlendFunc(GL2.GL_SRC_ALPHA,GL2.GL_ONE) I get the same result I would have got if I used gl.glBlendFunc(GL2.GL_ONE,GL2.GL_ONE) instead. So this shows me the program considers alpha is always equal to 1.
Am I forgetting something? I know I have enabled color.
Code :gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT ); gl.glClearDepth(1.0); gl.glEnable(GL.GL_DEPTH_TEST); gl.glDepthFunc(GL.GL_LEQUAL); gl.glShadeModel(GL2.GL_SMOOTH); gl.glEnable(GL2.GL_CULL_FACE); gl.glBlendFunc(GL2.GL_SRC_ALPHA,GL2.GL_ONE_MINUS_SRC_ALPHA); gl.glDisable(GL.GL_DEPTH_TEST); gl.glDepthMask(false); gl.glEnable(GL.GL_BLEND); gl.glEnable(GL2.GL_COLOR); gl.glColor4f(0.5f, 0.5f, 0.5f, 0.5f); .............// <-- draw transparent 3D model here, with texture gl.glDisable(GL.GL_BLEND); gl.glEnable(GL2.GL_DEPTH_TEST); gl.glDepthMask(true);
I hope someone could help me a bit here. I'm sure it's something very simple.
Thank you very much!