Hi,
can somebody please tell me how I can let objects fade after a certain time or after a certain event?
I have already tried it in the following way :
for (double i=0;i<360;i+=10)
{
gl.glLoadIdentity();
gl.glTranslated(sceneCenterPoint[0],sceneCenterPoint[1],sceneCenterPoint[2]);
gl.glRotated(i,0.0,0.0,1.0);
gl.glBegin(GL.GL_LINES);
gl.glColor4d(0.0,0.0,1.0,transparencyFactor);
gl.glVertex3d(0.0,0.0,0.0);
gl.glVertex3d(1.0,0.0,0.0);
gl.glEnd();
}
As you can see the transparency should be defined in the variable “transparencyFactor”. I have got a button in whose “onClick”-method this variable is decreased.
But unfortunately clicking this button does not have any effect!
My init-method of the GLEventListener looks like this :
public void init(GLDrawable drawable)
{
this.drawable = drawable;
gl = this.drawable.getGL();
glu = this.drawable.getGLU(); //OpenGL utility library enthält Werte für GLU_FILL usw.
sphere = glu.gluNewQuadric(); //GLU-Körper anfordern -> obj zeigt jetzt auf diesen Körper
gl.glMatrixMode(GL.GL_PROJECTION);
gl.glLoadIdentity();
gl.glShadeModel(GL.GL_SMOOTH); // Enable Smooth Shading
gl.glClearColor(0.0f, 0.0f, 0.0f, 0.5f); // Black Background
gl.glClearDepth(1.0f); // Depth Buffer Setup
gl.glEnable(GL.GL_DEPTH_TEST); // Enables Depth Testing
gl.glDepthFunc(GL.GL_LEQUAL); // The Type Of Depth Testing To Do
gl.glHint(GL.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST); // Really Nice Perspective Calculations
gl.glEnable(GL.GL_BLEND);
}
I thought that the transparencyeffect is enabled with the code “gl.glEnable(GL.GL_BLEND);”. But apparently this is not enough. What have I got to do in addition to that?
???