Bug 24

Summary: GLCanvas does not honor layout
Product: [JogAmp] Jogl Reporter: Sven Gothel <sgothel>
Component: coreAssignee: Sven Gothel <sgothel>
Status: VERIFIED FIXED    
Severity: normal    
Priority: P3    
Version: 1   
Hardware: All   
OS: macosx   
Type: DEFECT SCM Refs:
Workaround: ---

Description Sven Gothel 2010-03-24 07:45:35 CET


---- Reported by chadseld 2003-07-11 13:21:17 ----

A GLCanvas occupies all the space in a Frame/JFrame. There is no way to place a GLCanvas 
inside or next to a Panel/JPanel and keep it in a specific area of a Frame. The GLCanvas will 
always display itself over the entire Frame. The following pseudo code example works with 
gl4java, and (I'm told) with jogl for Windows, but in broken in jogl for Mac OS X.

public class Panels implements GLEventListener
{
    private Frame frame;
    private JPanel panel = new JPanel();
    private JLabel label = new JLabel("foo");
    private GLCanvas canvas;
    
    public static void main(String[] args)
    {
        Panels app = new Panels();
    }
    
    
    public Panels()
    {
        try
        {
            // Create GL Canvas
            canvas = GLDrawableFactory.getFactory().createGLCanvas(new GLCapabilities());
            canvas.addGLEventListener(this);
            
            // Frame
            frame = new Frame("Simple Test World");
            frame.setSize(1024,1024);
            panel.setPreferredSize(new Dimension(64, 400));
            frame.add(canvas, BorderLayout.CENTER);
            frame.add(panel, BorderLayout.EAST);
            frame.add(label, BorderLayout.SOUTH);
            frame.addWindowListener(new WindowAdapter() {
                public void windowClosing(WindowEvent e) {
                    System.exit(0);
                }
            });            
            frame.show();
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
    }
    
    
    public void init(GLDrawable drawable)
    {
        GLFunc gl = drawable.getGL();
        
        // This Will Clear The Background Color To light blue
        gl.glClearColor(0.8f, 0.8f, 0.99f, 0.0f);
        gl.glClearDepth(1.0);
        
        // Misc
        ...
        
        // Set up the viewport
        gl.glViewport(0,0, 10,10);// Toying with these bounds doesn't change anything
                                                
        
        // Prep for first draw
        gl.glMatrixMode(GLEnum.GL_MODELVIEW);
        gl.glLoadIdentity();
        gl.glClear(GLEnum.GL_DEPTH_BUFFER_BIT);
    }
    
    public void reshape(GLDrawable drawable, int x, int y, int width, int height)
    {
        ...
    }

    public void display(GLDrawable drawable)
    {
        GLFunc gl = drawable.getGL();
        GLUFunc glu = drawable.getGLU();
        
        //Clear The Screen And The Depth Buffer
        gl.glClear(GLEnum.GL_COLOR_BUFFER_BIT | GLEnum.GL_DEPTH_BUFFER_BIT);
    }
}


The entire frame will be drawn a pleasant light blue.



---- Additional Comments From kbr 2003-07-14 22:54:31 ----

There's no difference at the AWT level between the GLCanvas on Mac OS X and the
GLCanvas on any other platform. It would be great if you could submit another
test case showing what the output should look like. Currently I'm not succeeding
in getting this test to run with a GLJPanel replacing the GLCanvas.




---- Additional Comments From kbr 2003-11-05 10:44:13 ----

The submitter has indicated that this issue has been fixed with the latest
version of Java on Mac OS X.




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

This bug was previously known as _bug_ 24 at https://jogl.dev.java.net/bugs/show_bug.cgi?id=24