Bug 148 - Swing Component Shadow on GLJPanel
Summary: Swing Component Shadow on GLJPanel
Status: VERIFIED FIXED
Alias: None
Product: Jogl
Classification: JogAmp
Component: core (show other bugs)
Version: 1
Hardware: All windows
: P3 normal
Assignee: Sven Gothel
URL:
Depends on:
Blocks:
 
Reported: 2005-03-21 07:43 CET by Sven Gothel
Modified: 2010-03-24 07:47 CET (History)
0 users

See Also:
Type: DEFECT
SCM Refs:
Workaround: ---


Attachments
Test case that works with 1.4.2 (click button to exhibit bug) (2.93 KB, text/plain)
2005-04-09 17:22 CEST, Sven Gothel
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sven Gothel 2010-03-24 07:47:39 CET


---- Reported by gdbolin 2005-03-21 19:43:32 ----

http://www.javagaming.org/cgi-bin/JGNetForums/YaBB.cgi?board=jogl;action=display;num=1111184067;start=0#4

I have a triangle that rotates on a GLJPanel.  It is on a JFrame in the center.
 In the WEST coord of the frame I have a panel with a single button.
 
When I scroll my mouse onto and off of the JButton, it brieflly appears in the
GL Context for some reason.

Here is the test code

 public class Main {
 
    public Main(){
 
   JFrame frame = new JFrame("Test Frame");
   frame.setBounds(10, 10, 500, 500);
   frame.setLayout(new BorderLayout());
 
   GLCapabilities glCaps = new GLCapabilities();
   glCaps.setRedBits(8);
   glCaps.setBlueBits(8);
   glCaps.setGreenBits(8);
   glCaps.setAlphaBits(8);
 
   GLJPanel panel = GLDrawableFactory.getFactory().createGLJPanel(glCaps);
   frame.add(panel, BorderLayout.CENTER);
   JPanel p = new JPanel(new FlowLayout());
   JButton b = new JButton("Test Me");
   p.add(b);
   frame.add(p, BorderLayout.WEST);
   panel.addGLEventListener(new GLContextRenderer());
 
   final Animator animator = new Animator(panel);
   frame.addWindowListener(new WindowAdapter() {
  public void windowClosing(WindowEvent e) {
    animator.stop();
    System.exit(0);
  }
   });
   frame.setVisible(true);
   animator.start();    
    }
 
    public static void main(String[] args) {
   new Main();
    }
} 

 public class GLContextRenderer implements GLEventListener {
 
    GL gl;
    GLDrawable glDrawable;
    float xRot;
 
    public void init(GLDrawable glDrawable) {
   this.gl = glDrawable.getGL();
   this.glDrawable = glDrawable;
   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_TEXTURE_2D);
 
    }
 
    public void display(GLDrawable glDrawable) {
   gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT );
   gl.glLoadIdentity();
 
   gl.glTranslatef(0.0f, 0.0f, -6.0f);
   gl.glColor3f(1.0f, 0.0f, 0.0f );
   gl.glRotatef(xRot, 1.0f, 0.0f, 0.0f);
 
   gl.glBegin( GL.GL_TRIANGLES );
  gl.glVertex3f( 0.0f, 0.0f, 0.0f );
  gl.glVertex3f( 1.0f, 0.0f, 0.0f );
  gl.glVertex3f( 1.0f, 1.0f, 0.0f );
   gl.glEnd();
   xRot += .2f;
    }
 
    public void reshape(GLDrawable glDrawable, int x, int y, int width, int
height) {
   final GLU glu = glDrawable.getGLU();
 
    if (height <= 0) // avoid a divide by zero error!
      height = 1;
    final float h = (float)width / (float)height;
    gl.glViewport(0, 0, width, height);
    gl.glMatrixMode(GL.GL_PROJECTION);
    gl.glLoadIdentity();
    glu.gluPerspective(45.0f, h, 1.0, 20.0);
    gl.glMatrixMode(GL.GL_MODELVIEW);
    gl.glLoadIdentity();
    }
 
    public void displayChanged(GLDrawable glDrawable, boolean b, boolean b1) {
   //To change body of implemented methods use File | Settings | File Templates.
    }
}



---- Additional Comments From kbr 2005-04-09 17:22:23 ----

Created an attachment
Test case that works with 1.4.2 (click button to exhibit bug)




---- Additional Comments From kbr 2005-04-09 17:34:30 ----

The test case specifies alpha bits in the GLCapabilities, which caused the
GLJPanel to create a TYPE_INT_ARGB BufferedImage to store the results of the
readback of the frame buffer for rendering into the GLJPanel. This appears to
not be the correct thing to do, because it causes this BufferedImage to be
alpha-blended with whatever other rendering is performed into Java2D's backing
store. Therefore when the button was redrawn, its image would show up in this
backing store alpha-blended with the OpenGL rendering results since both were
redrawn simultaneously. I believe the correct solution is to never create a
BufferedImage with an alpha component for the framebuffer readback even if alpha
bits are specified in the GLCapabilities. This is what has been implemented in
the JOGL source base.




--- Bug imported by sgothel@jausoft.com 2010-03-24 07:47 EDT  ---

This bug was previously known as _bug_ 148 at https://jogl.dev.java.net/bugs/show_bug.cgi?id=148
Imported an attachment (id=44)

The original submitter of attachment 44 [details] is unknown.
   Reassigning to the person who moved it here: sgothel@jausoft.com.