Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: JOGL Transparency Problem

  1. #1
    Newbie Newbie
    Join Date
    Sep 2013
    Posts
    2

    JOGL Transparency Problem

    Hello,
    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!
    Last edited by mihai23; 09-11-2013 at 01:51 AM.

  2. #2
    Newbie Newbie
    Join Date
    Sep 2013
    Posts
    2
    OK, I've solved the problem. I should have replaced GL_COLOR with GL_COLOR_MATERIAL, since lighting was on. Actually, it was THAT simple.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •