I'm on Mac OS X 10.9.2 with Oracle Java 1.7.0_51-b13 and JOGL 2.1.3.
I create a simple JFrame > NewtCanvasAWT > GLWindow and color the background red. When the window pops up, this works:
However, if I resize the window, the OpenGL drawing area sticks in the lower left corner of the window:
I only observe this behavior with the above setup. On the Windows or Linux machines that I have tested, the window is always entirely red.
I've searched the forums and found issues which sound similar:
http://forum.jogamp.org/Issue-with-Java-3D-under-OpenJDK-7-Mac-OS-X-td4025259i80.htmlhttp://forum.jogamp.org/Mac-OS-X-10-7-Oracle-JRE-7-Swing-integration-issues-td4027780.htmlBut they're all about a year old and seem to have supposedly been fixed.
Should the code below work? Am I missing something? Or is this a bug? Any insight would be appreciated.
Here's the simple test case that I'm using:
import javax.media.opengl.GL;
import javax.media.opengl.GL2;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLEventListener;
import javax.media.opengl.GLProfile;
import javax.swing.JFrame;
import com.jogamp.newt.awt.NewtCanvasAWT;
import com.jogamp.newt.opengl.GLWindow;
public class Test2
{
public static void main( String[] args )
{
GLProfile glp = GLProfile.getDefault( );
GLCapabilities caps = new GLCapabilities( glp );
GLWindow window = GLWindow.create( caps );
NewtCanvasAWT glCanvas = new NewtCanvasAWT( window );
JFrame frame = new JFrame( );
window.addGLEventListener( new GLEventListener( )
{
@Override public void init( GLAutoDrawable drawable ) { }
@Override public void dispose( GLAutoDrawable drawable ) { }
@Override public void reshape( GLAutoDrawable drawable, int x, int y, int width, int height ) { }
@Override
public void display( GLAutoDrawable drawable )
{
GL gl = drawable.getContext( ).getGL( );
gl.glClearColor( 1.0f, 0.0f, 0.0f, 1.0f );
gl.glClear( GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT );
}
});
frame.add( glCanvas );
frame.setSize( 800, 800 );
frame.setVisible( true );
}
}