diff options
author | Sven Gothel <[email protected]> | 2011-03-01 03:05:12 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2011-03-01 03:05:12 +0100 |
commit | c1e542ad0150e5327b1ed9d9980d4eeb81720cde (patch) | |
tree | 024764bdc43b4762443782e3d20c5e2b9e7dae05 /src | |
parent | 9d28b54913bc4a50d642a86614d0e69d6d3f3192 (diff) |
Tolerate pending/lazy native context creation at 1st makeCurrent (OSX).
This allows SWT on OSX to work properly.
Diffstat (limited to 'src')
-rw-r--r-- | src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWT02GLn.java | 43 |
1 files changed, 29 insertions, 14 deletions
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWT02GLn.java b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWT02GLn.java index 14b70ad19..b3d167b80 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWT02GLn.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWT02GLn.java @@ -119,7 +119,6 @@ public class TestSWT02GLn extends UITestCase { // at the wrong times (we use glClear for this instead) final Canvas canvas = new Canvas( composite, SWT.NO_BACKGROUND); Assert.assertNotNull( canvas ); - System.err.println("*** canvas: " + canvas); SWTAccessor.setRealized(canvas, true); AbstractGraphicsDevice device = SWTAccessor.getDevice(canvas); @@ -134,21 +133,30 @@ public class TestSWT02GLn extends UITestCase { final GLDrawable drawable = factory.createGLDrawable(proxySurface); Assert.assertNotNull( drawable ); drawable.setRealized(true); + System.err.println("*** Drawable: " + drawable); Assert.assertTrue( drawable.isRealized() ); final GLContext glcontext = drawable.createContext(null); // trigger native creation .. - glcontext.makeCurrent(); - glcontext.release(); + if( GLContext.CONTEXT_NOT_CURRENT < glcontext.makeCurrent() ) { + glcontext.release(); + } + + final boolean[] sizeMissing = new boolean[] { false }; // fix the viewport when the user resizes the window canvas.addListener( SWT.Resize, new Listener() { public void handleEvent( Event event ) { Rectangle rectangle = canvas.getClientArea(); - glcontext.makeCurrent(); - GL2 gl = glcontext.getGL().getGL2(); - OneTriangle.setup( gl, rectangle ); - glcontext.release(); - System.err.println("resize"); + boolean glok=false; + if( GLContext.CONTEXT_NOT_CURRENT < glcontext.makeCurrent() ) { + glok=true; + GL2 gl = glcontext.getGL().getGL2(); + OneTriangle.setup( gl, rectangle ); + glcontext.release(); + } else { + sizeMissing[0] = true; + } + System.err.println("resize: glok " + glok); } }); @@ -156,12 +164,19 @@ public class TestSWT02GLn extends UITestCase { canvas.addPaintListener( new PaintListener() { public void paintControl( PaintEvent paintevent ) { Rectangle rectangle = canvas.getClientArea(); - glcontext.makeCurrent(); - GL2 gl = glcontext.getGL().getGL2(); - OneTriangle.render( gl, rectangle ); - drawable.swapBuffers(); - glcontext.release(); - System.err.println("paint"); + boolean glok=false; + if( GLContext.CONTEXT_NOT_CURRENT < glcontext.makeCurrent() ) { + glok=true; + GL2 gl = glcontext.getGL().getGL2(); + if(sizeMissing[0]) { + OneTriangle.setup( gl, rectangle ); + sizeMissing[0] = false; + } + OneTriangle.render( gl, rectangle ); + drawable.swapBuffers(); + glcontext.release(); + } + System.err.println("paint: glok " + glok); } }); |