Original Post
Hi, I'm having a problem learning how to do blending. I have drawn my model in the center of the canvas, then I translate to the lower left corner and try to draw a small black semi-transparent rectangle and then I draw my x, y, and z axis (on top?) to show the direction that the model is rotated in. My problem is that, I can't figure out how to shade the part of the model that should be behind the rectangle so that the axis shows up better, and the other problem is that the rectangle clips the part of my rotation axis that is behind it. Of course if I remove gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_FILL), then x, y, and z in front of the GL_FILL on the axis shows up fine, but ... I still have the transparency problem. Can anyone help with what I'm doing wrong?
public void init(GLAutoDrawable drawable) {
...
gl.glEnable(GL.GL_BLEND);
gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
...
}
public void display(GLAutoDrawable drawable) {
...
// draw model here
...
// draw transparent pane and axis
gl.glLoadIdentity();
gl.glTranslatef((float) (-(height / 2) * 0.8), (float) -((height / 2) * 0.8), 0.0f);
drawTransparentPane(drawable, viewPort);
gl.glMultMatrixf(transf);
drawAxis(drawable, viewPort);
...
}
public void drawTransparentPane(GLAutoDrawable drawable, ViewPort viewPort) {
GL gl = drawable.getGL();
gl.glColor3f(0.0f, 0.0f, 0.0f);
gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_FILL);
gl.glBegin(GL.GL_POLYGON);
gl.glVertex3f((float) -((viewPort.width / 2) * .2), (float) -((viewPort.height / 2) * .2), 0.0f);
gl.glVertex3f((float) -((viewPort.width / 2) * .2), (float) ((viewPort.height / 2) * .2), 0.0f);
gl.glVertex3f((float) ((viewPort.width / 2) * .2), (float) ((viewPort.height / 2) * .2), 0.0f);
gl.glVertex3f((float) ((viewPort.width / 2) * .2), (float) -((viewPort.height / 2) * .2), 0.0f);
gl.glEnd();
}
public void drawAxis(GLAutoDrawable drawable, ViewPort viewPort) {
// draw x, y, and z lines
}