diff options
author | Sven Gothel <[email protected]> | 2014-09-14 01:14:38 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2014-09-14 01:21:19 +0200 |
commit | fa6ba9d70d4fe47f05facc72608fb10c889f9d09 (patch) | |
tree | 2d8a52b2480414824769a9e91e665012d468f6b5 /src/test | |
parent | b084083a3d61f4e7a6a33c0c12ac529f0464f4a8 (diff) |
GLJPanel: Allow reconfiguration of offscreen's GLCapabilitiesImmutable
Offscreen's GLCapabilitiesImmutable reconfiguration will dispose a realized instance
and issues recreation via initializeBackendImpl() immedietly.
Implementation performs operation on AWT-EDT.
Tests:
- TestGearsES2GLJPanelAWT:
- Toggle MSAA via 'm'
- TestGearsGLJPanelAWT:
- Toggle MSAA via 'm'
- Toggle Bitmap via 'b'
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2GLJPanelAWT.java | 19 | ||||
-rw-r--r-- | src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/TestGearsGLJPanelAWT.java | 51 |
2 files changed, 70 insertions, 0 deletions
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2GLJPanelAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2GLJPanelAWT.java index dd16b88cc..9841bb35e 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2GLJPanelAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2GLJPanelAWT.java @@ -213,6 +213,25 @@ public class TestGearsES2GLJPanelAWT extends UITestCase { hasSurfacePixelScale1[0]+"x"+hasSurfacePixelScale1[1]+" (has)"); setTitle(frame, glJPanel, caps); Assert.assertArrayEquals(hasSurfacePixelScale0, hasSurfacePixelScale1); + } else if(e.getKeyChar()=='m') { + final GLCapabilitiesImmutable capsPre = glJPanel.getChosenGLCapabilities(); + final GLCapabilities capsNew = new GLCapabilities(capsPre.getGLProfile()); + capsNew.copyFrom(capsPre); + final boolean msaa; + if( capsPre.getSampleBuffers() ) { + capsNew.setSampleBuffers(false); + msaa = false; + } else { + capsNew.setSampleBuffers(true); + capsNew.setNumSamples(4); + msaa = true; + } + System.err.println("[set MSAA "+msaa+" Caps had]: "+capsPre); + System.err.println("[set MSAA "+msaa+" Caps new]: "+capsNew); + System.err.println("XXX-A1: "+animator.toString()); + glJPanel.setRequestedGLCapabilities(capsNew); + System.err.println("XXX-A2: "+animator.toString()); + System.err.println("XXX: "+glJPanel.toString()); } } }; new AWTKeyAdapter(kl, glJPanel).addTo(glJPanel); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/TestGearsGLJPanelAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/TestGearsGLJPanelAWT.java index 3650e4955..f47a9b794 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/TestGearsGLJPanelAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/TestGearsGLJPanelAWT.java @@ -30,6 +30,7 @@ package com.jogamp.opengl.test.junit.jogl.demos.gl2.awt; import javax.media.opengl.*; +import com.jogamp.newt.event.KeyEvent; import com.jogamp.newt.event.TraceKeyAdapter; import com.jogamp.newt.event.TraceWindowAdapter; import com.jogamp.newt.event.awt.AWTKeyAdapter; @@ -121,6 +122,56 @@ public class TestGearsGLJPanelAWT extends UITestCase { new AWTKeyAdapter(new TraceKeyAdapter(quitAdapter), glJPanel).addTo(glJPanel); new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter), glJPanel).addTo(frame); + final com.jogamp.newt.event.KeyListener kl = new com.jogamp.newt.event.KeyAdapter() { + @Override + public void keyPressed(final KeyEvent e) { + if( e.isAutoRepeat() ) { + return; + } + if(e.getKeyChar()=='m') { + final GLCapabilitiesImmutable capsPre = glJPanel.getChosenGLCapabilities(); + final GLCapabilities capsNew = new GLCapabilities(capsPre.getGLProfile()); + capsNew.copyFrom(capsPre); + final boolean msaa; + if( capsPre.getSampleBuffers() ) { + capsNew.setSampleBuffers(false); + capsNew.setDoubleBuffered(false); + msaa = false; + } else { + capsNew.setSampleBuffers(true); + capsNew.setNumSamples(4); + msaa = true; + } + System.err.println("[set MSAA "+msaa+" Caps had]: "+capsPre); + System.err.println("[set MSAA "+msaa+" Caps new]: "+capsNew); + System.err.println("XXX-A1: "+animator.toString()); + glJPanel.setRequestedGLCapabilities(capsNew); + System.err.println("XXX-A2: "+animator.toString()); + System.err.println("XXX: "+glJPanel.toString()); + } else if(e.getKeyChar()=='b') { + final GLCapabilitiesImmutable capsPre = glJPanel.getChosenGLCapabilities(); + final GLCapabilities capsNew = new GLCapabilities(capsPre.getGLProfile()); + capsNew.copyFrom(capsPre); + final boolean bmp; + if( capsPre.isBitmap() ) { + capsNew.setBitmap(false); // auto-choose + bmp = false; + } else { + capsNew.setBitmap(true); + capsNew.setFBO(false); + capsNew.setPBuffer(false); + bmp = true; + } + System.err.println("[set Bitmap "+bmp+" Caps had]: "+capsPre); + System.err.println("[set Bitmap "+bmp+" Caps new]: "+capsNew); + System.err.println("XXX-A1: "+animator.toString()); + glJPanel.setRequestedGLCapabilities(capsNew); + System.err.println("XXX-A2: "+animator.toString()); + System.err.println("XXX: "+glJPanel.toString()); + } + } }; + new AWTKeyAdapter(kl, glJPanel).addTo(glJPanel); + final long t0 = System.currentTimeMillis(); long t1 = t0; boolean triggerSnap = false; |