public void setDemo(String demo) { setTitle("Jogl Demo: " + demo); if (animator == null) { animator = new Animator(); animator.setIgnoreExceptions(true); } // stop(); if (drawable != null) { gradientPanel.remove(drawable); animator.remove(drawable); drawable = null; } if (demo.equals("gears")) { drawable = new JGears(); type = GEARS; } // else if(demo.equals("graphics")){ // type=GRAPHICS; // drawable=new JGLGraphics(); // } if (drawable != null) { gradientPanel.add(drawable, BorderLayout.CENTER); animator.add(drawable); } }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); String[] urls0 = new String[] { System.getProperty("jnlp.media0_url2"), System.getProperty("jnlp.media0_url1"), System.getProperty("jnlp.media0_url0") }; final URLConnection urlConnection0 = getResource(urls0, 0); if (null == urlConnection0) { throw new RuntimeException("no media reachable: " + Arrays.asList(urls0)); } // also initializes JOGL final GLCapabilities capsMain = new GLCapabilities(GLProfile.getGL2ES2()); capsMain.setBackgroundOpaque(false); // screen for layout params .. final com.jogamp.newt.Display dpy = NewtFactory.createDisplay(null); final com.jogamp.newt.Screen scrn = NewtFactory.createScreen(dpy, 0); scrn.addReference(); try { final Animator animator = new Animator(); // Main final MovieCube demoMain = new MovieCube( urlConnection0, GLMediaPlayer.STREAM_ID_AUTO, GLMediaPlayer.STREAM_ID_AUTO, -2.3f, 0f, 0f); final GLWindow glWindowMain = GLWindow.create(scrn, capsMain); glWindowMain.setFullscreen(true); setContentView(getWindow(), glWindowMain); glWindowMain.addMouseListener(showKeyboardMouseListener); glWindowMain.addGLEventListener(demoMain); animator.add(glWindowMain); glWindowMain.setVisible(true); // animator.setUpdateFPSFrames(60, System.err); animator.setUpdateFPSFrames(-1, null); animator.resetFPSCounter(); } catch (IOException e) { e.printStackTrace(); } scrn.removeReference(); Log.d(TAG, "onCreate - X"); }
public static void main(String[] args) { GLProfile glp = GLProfile.getGL2ES2(); GLCapabilities caps = new GLCapabilities(glp); caps.setAlphaBits(4); caps.setSampleBuffers(true); caps.setNumSamples(4); System.out.println("Requested: " + caps); final GLWindow window = GLWindow.create(caps); window.setPosition(10, 10); window.setSize(800, 400); window.setTitle("GPU UI Newt Demo 01"); RenderState rs = RenderState.createRenderState(new ShaderState(), SVertex.factory()); UIGLListener01 uiGLListener = new UIGLListener01(rs, DEBUG, TRACE); uiGLListener.attachInputListenerTo(window); window.addGLEventListener(uiGLListener); window.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err); window.setVisible(true); final Animator animator = new Animator(); animator.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err); animator.add(window); window.addKeyListener( new KeyAdapter() { public void keyPressed(KeyEvent arg0) { if (arg0.getKeyCode() == KeyEvent.VK_F4) { window.destroy(); } } }); window.addWindowListener( new WindowAdapter() { public void windowDestroyed(WindowEvent e) { animator.stop(); } }); animator.start(); }
public void testImpl( final int sceneMSAASamples, final int graphMSAASamples, final int graphVBAASamples) throws InterruptedException { GLProfile glp = GLProfile.get(GLProfile.GL2ES2); GLCapabilities caps = new GLCapabilities(glp); caps.setAlphaBits(4); if (0 < sceneMSAASamples) { caps.setSampleBuffers(true); caps.setNumSamples(sceneMSAASamples); } System.err.println( "Requested: " + caps + ", graph[msaaSamples " + graphMSAASamples + ", vbaaSamples " + graphVBAASamples + "]"); GLWindow window = createWindow( "text-gvbaa" + graphVBAASamples + "-gmsaa" + graphMSAASamples + "-smsaa" + sceneMSAASamples, caps, 1024, 640); window.display(); System.err.println("Chosen: " + window.getChosenGLCapabilities()); if (WaitStartEnd) { UITestCase.waitForKey("Start"); } final RenderState rs = RenderState.createRenderState(SVertex.factory()); final int renderModes, sampleCount; if (graphVBAASamples > 0) { renderModes = Region.VBAA_RENDERING_BIT; sampleCount = graphVBAASamples; } else if (graphMSAASamples > 0) { renderModes = Region.MSAA_RENDERING_BIT; sampleCount = graphMSAASamples; } else { renderModes = 0; sampleCount = 0; } final TextRendererGLEL textGLListener = new TextRendererGLEL(rs, renderModes, sampleCount); System.err.println(textGLListener.getFontInfo()); window.addGLEventListener(textGLListener); Animator anim = new Animator(); anim.add(window); anim.start(); anim.setUpdateFPSFrames(60, null); sleep(); window.invoke( true, new GLRunnable() { @Override public boolean run(GLAutoDrawable drawable) { try { textGLListener.printScreen( renderModes, drawable, "./", "TestTextRendererNEWT00-snap" + screenshot_num, false); screenshot_num++; } catch (Exception e) { e.printStackTrace(); } return true; } }); anim.stop(); if (WaitStartEnd) { UITestCase.waitForKey("Stop"); } destroyWindow(window); }
public void asyncEachOneAnimator(final boolean destroyCleanOrder) throws InterruptedException, InvocationTargetException { final Frame f1 = new Frame(); final Animator a1 = new Animator(); final GearsES2 g1 = new GearsES2(0); final GLCanvas c1 = createGLCanvas(f1, 0, 0, g1); a1.add(c1); a1.start(); // f1.setVisible(true); // we do this post f2 .. to test pending creation! final Frame f2 = new Frame(); final Animator a2 = new Animator(); final GearsES2 g2 = new GearsES2(0); g2.setSharedGears(g1); final GLCanvas c2 = createGLCanvas(f2, f1.getX() + width, f1.getY() + 0, g2); c2.setSharedAutoDrawable(c1); a2.add(c2); a2.start(); javax.swing.SwingUtilities.invokeAndWait( new Runnable() { public void run() { f2.setVisible(true); } }); Thread.sleep(200); // wait a while .. javax.swing.SwingUtilities.invokeAndWait( new Runnable() { public void run() { f1.setVisible(true); // test pending creation of f2 } }); final Frame f3 = new Frame(); final Animator a3 = new Animator(); final GearsES2 g3 = new GearsES2(0); g3.setSharedGears(g1); final GLCanvas c3 = createGLCanvas(f3, f1.getX() + 0, f1.getY() + height, g3); c3.setSharedAutoDrawable(c1); a3.add(c3); a3.start(); javax.swing.SwingUtilities.invokeAndWait( new Runnable() { public void run() { f3.setVisible(true); } }); Thread.sleep( 1000 / 60 * 10); // wait ~10 frames giving a chance to create (blocking until master share is // valid) Assert.assertTrue(AWTRobotUtil.waitForRealized(c1, true)); Assert.assertTrue(AWTRobotUtil.waitForVisible(c1, true)); Assert.assertTrue(AWTRobotUtil.waitForContextCreated(c1, true)); Assert.assertTrue("Gears1 not initialized", g1.waitForInit(true)); Assert.assertTrue(AWTRobotUtil.waitForRealized(c2, true)); Assert.assertTrue(AWTRobotUtil.waitForVisible(c2, true)); Assert.assertTrue(AWTRobotUtil.waitForContextCreated(c2, true)); Assert.assertTrue("Gears2 not initialized", g2.waitForInit(true)); Assert.assertTrue(AWTRobotUtil.waitForRealized(c3, true)); Assert.assertTrue(AWTRobotUtil.waitForVisible(c3, true)); Assert.assertTrue(AWTRobotUtil.waitForContextCreated(c3, true)); Assert.assertTrue("Gears3 not initialized", g3.waitForInit(true)); final GLContext ctx1 = c1.getContext(); final GLContext ctx2 = c2.getContext(); final GLContext ctx3 = c3.getContext(); { final List<GLContext> ctx1Shares = ctx1.getCreatedShares(); final List<GLContext> ctx2Shares = ctx2.getCreatedShares(); final List<GLContext> ctx3Shares = ctx3.getCreatedShares(); MiscUtils.dumpSharedGLContext("XXX-C-3.1", ctx1); MiscUtils.dumpSharedGLContext("XXX-C-3.2", ctx2); MiscUtils.dumpSharedGLContext("XXX-C-3.3", ctx3); Assert.assertTrue("Ctx1 is not shared", ctx1.isShared()); Assert.assertTrue("Ctx2 is not shared", ctx2.isShared()); Assert.assertTrue("Ctx3 is not shared", ctx3.isShared()); Assert.assertEquals("Ctx1 has unexpected number of created shares", 2, ctx1Shares.size()); Assert.assertEquals("Ctx2 has unexpected number of created shares", 2, ctx2Shares.size()); Assert.assertEquals("Ctx3 has unexpected number of created shares", 2, ctx3Shares.size()); } Assert.assertTrue("Gears1 is shared", !g1.usesSharedGears()); Assert.assertTrue("Gears2 is not shared", g2.usesSharedGears()); Assert.assertTrue("Gears3 is not shared", g3.usesSharedGears()); try { Thread.sleep(duration); } catch (final Exception e) { e.printStackTrace(); } // Stopped animator allows native windowing system 'repaint' event // to trigger GLAD 'display' a1.stop(); Assert.assertEquals(false, a1.isAnimating()); a2.stop(); Assert.assertEquals(false, a2.isAnimating()); a3.stop(); Assert.assertEquals(false, a3.isAnimating()); if (destroyCleanOrder) { System.err.println("XXX Destroy in clean order NOW"); } else { System.err.println( "XXX Destroy in creation order NOW - Driver Impl. Ma trigger driver Bug i.e. not postponing GL ctx destruction after releasing all refs."); } javax.swing.SwingUtilities.invokeAndWait( new Runnable() { public void run() { try { if (destroyCleanOrder) { f3.dispose(); } else { f1.dispose(); } } catch (final Throwable t) { throw new RuntimeException(t); } } }); javax.swing.SwingUtilities.invokeAndWait( new Runnable() { public void run() { try { f2.dispose(); } catch (final Throwable t) { throw new RuntimeException(t); } } }); javax.swing.SwingUtilities.invokeAndWait( new Runnable() { public void run() { try { if (destroyCleanOrder) { f1.dispose(); } else { f3.dispose(); } } catch (final Throwable t) { throw new RuntimeException(t); } } }); Assert.assertTrue(AWTRobotUtil.waitForRealized(c1, false)); Assert.assertTrue(AWTRobotUtil.waitForRealized(c2, false)); Assert.assertTrue(AWTRobotUtil.waitForRealized(c3, false)); }
public void testImpl() throws InterruptedException { final JFrame frame = new JFrame(this.getSimpleTestName(".")); // // GLDrawableFactory factory = GLDrawableFactory.getFactory(GLProfile.get(GLProfile.GL2)); // GLContext sharedContext = factory.getOrCreateSharedContext(factory.getDefaultDevice()); // final GLCapabilities glCapabilities = new GLCapabilities(GLProfile.get(GLProfile.GL2)); glCapabilities.setSampleBuffers(true); glCapabilities.setNumSamples(4); final GearsES2 eventListener1 = new GearsES2(0); final GearsES2 eventListener2 = new GearsES2(1); final Component openGLComponent1; final Component openGLComponent2; final GLAutoDrawable openGLAutoDrawable1; final GLAutoDrawable openGLAutoDrawable2; final GLWindow glWindow1 = GLWindow.create(glCapabilities); final NewtCanvasAWT newtCanvasAWT1 = new NewtCanvasAWT(glWindow1); newtCanvasAWT1.setPreferredSize(new Dimension(640, 480)); glWindow1.addGLEventListener(eventListener1); // final GLWindow glWindow2 = GLWindow.create(glCapabilities); final NewtCanvasAWT newtCanvasAWT2 = new NewtCanvasAWT(glWindow2); newtCanvasAWT2.setPreferredSize(new Dimension(640, 480)); glWindow2.addGLEventListener(eventListener2); openGLComponent1 = newtCanvasAWT1; openGLComponent2 = newtCanvasAWT2; openGLAutoDrawable1 = glWindow1; openGLAutoDrawable2 = glWindow2; // group both OpenGL canvases / windows into a horizontal panel final JPanel openGLPanel = new JPanel(); openGLPanel.setLayout(new BoxLayout(openGLPanel, BoxLayout.LINE_AXIS)); openGLPanel.add(openGLComponent1); openGLPanel.add(Box.createHorizontalStrut(5)); openGLPanel.add(openGLComponent2); final JPanel mainPanel = (JPanel) frame.getContentPane(); mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.LINE_AXIS)); mainPanel.add(Box.createHorizontalGlue()); mainPanel.add(openGLPanel); mainPanel.add(Box.createHorizontalGlue()); final Animator animator = new Animator(Thread.currentThread().getThreadGroup()); animator.setUpdateFPSFrames(1, null); animator.add(openGLAutoDrawable1); animator.add(openGLAutoDrawable2); // make the window visible using the EDT SwingUtilities.invokeLater( new Runnable() { public void run() { frame.pack(); frame.setVisible(true); } }); Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame, true)); Assert.assertEquals(true, AWTRobotUtil.waitForRealized(openGLComponent1, true)); Assert.assertEquals(true, AWTRobotUtil.waitForRealized(openGLComponent2, true)); animator.start(); // sleep for test duration, then request the window to close, wait for the window to close,s and // stop the animation while (animator.isAnimating() && animator.getTotalFPSDuration() < durationPerTest) { Thread.sleep(100); } animator.stop(); // ask the EDT to dispose of the frame; // if using newt, explicitly dispose of the canvases because otherwise it seems our destroy // methods are not called SwingUtilities.invokeLater( new Runnable() { public void run() { newtCanvasAWT1.destroy(); // removeNotify does not destroy GLWindow newtCanvasAWT2.destroy(); // removeNotify does not destroy GLWindow frame.dispose(); } }); Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame, false)); Assert.assertEquals(true, AWTRobotUtil.waitForRealized(openGLComponent1, false)); Assert.assertEquals(true, AWTRobotUtil.waitForRealized(openGLComponent2, false)); }
protected void runTestGL( final GLCapabilities caps, final FrameLayout frameLayout, final boolean twoCanvas, final boolean resizeByComp) throws InterruptedException, InvocationTargetException { final JFrame frame = new JFrame("Bug816: " + this.getTestMethodName()); Assert.assertNotNull(frame); final Container framePane = frame.getContentPane(); final GLCanvas glCanvas1 = new GLCanvas(caps); Assert.assertNotNull(glCanvas1); final GLCanvas glCanvas2; if (twoCanvas) { glCanvas2 = new GLCanvas(caps); Assert.assertNotNull(glCanvas2); } else { glCanvas2 = null; } final Dimension glcDim = new Dimension(width / 2, height); final Dimension frameDim = new Dimension(twoCanvas ? width + 64 : width / 2 + 64, height + 64); setComponentSize(null, glCanvas1, glcDim, glCanvas2, glcDim); switch (frameLayout) { case None: { framePane.add(glCanvas1); } break; case Flow: { final Container c = new Container(); c.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); c.add(glCanvas1); if (twoCanvas) { c.add(glCanvas2); } framePane.add(c); } break; case DoubleBorderCenterSurrounded: { final Container c = new Container(); c.setLayout(new BorderLayout()); c.add(new Button("north"), BorderLayout.NORTH); c.add(new Button("south"), BorderLayout.SOUTH); c.add(new Button("east"), BorderLayout.EAST); c.add(new Button("west"), BorderLayout.WEST); if (twoCanvas) { final Container c2 = new Container(); c2.setLayout(new GridLayout(1, 2)); c2.add(glCanvas1); c2.add(glCanvas2); c.add(c2, BorderLayout.CENTER); } else { c.add(glCanvas1, BorderLayout.CENTER); } framePane.setLayout(new BorderLayout()); framePane.add(new Button("NORTH"), BorderLayout.NORTH); framePane.add(new Button("SOUTH"), BorderLayout.SOUTH); framePane.add(new Button("EAST"), BorderLayout.EAST); framePane.add(new Button("WEST"), BorderLayout.WEST); framePane.add(c, BorderLayout.CENTER); } break; case Box: { final Container c = new Container(); c.setLayout(new BoxLayout(c, BoxLayout.X_AXIS)); c.add(glCanvas1); if (twoCanvas) { c.add(glCanvas2); } framePane.add(c); } break; case Split: { final Dimension sbDim = new Dimension(16, 16); final JScrollPane vsp = new JScrollPane( ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); { final JScrollBar vsb = vsp.getVerticalScrollBar(); vsb.setPreferredSize(sbDim); final BoundedRangeModel model = vsb.getModel(); model.setMinimum(0); model.setMaximum(100); model.setValue(50); model.setExtent(1); vsb.setEnabled(true); } final JScrollPane hsp = new JScrollPane( ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); { final JScrollBar hsb = hsp.getHorizontalScrollBar(); hsb.setPreferredSize(sbDim); final BoundedRangeModel model = hsb.getModel(); model.setMinimum(0); model.setMaximum(100); model.setValue(50); model.setExtent(1); hsb.setEnabled(true); } final JSplitPane horizontalSplitPane = new JSplitPane( JSplitPane.HORIZONTAL_SPLIT, true, twoCanvas ? glCanvas2 : vsp, glCanvas1); horizontalSplitPane.setResizeWeight(0.5); final JSplitPane verticalSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true, horizontalSplitPane, hsp); verticalSplitPane.setResizeWeight(0.5); framePane.add(verticalSplitPane); } break; } final GearsES2 demo1 = new GearsES2(swapInterval); glCanvas1.addGLEventListener(demo1); if (twoCanvas) { final RedSquareES2 demo2 = new RedSquareES2(swapInterval); glCanvas2.addGLEventListener(demo2); } final Animator animator = new Animator(); animator.add(glCanvas1); if (twoCanvas) { animator.add(glCanvas2); } final QuitAdapter quitAdapter = new QuitAdapter(); new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter), glCanvas1).addTo(frame); javax.swing.SwingUtilities.invokeAndWait( new Runnable() { public void run() { if (resizeByComp) { frame.pack(); } else { setFrameSize(frame, true, frameDim); } frame.setVisible(true); } }); Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame, true)); Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glCanvas1, true)); if (twoCanvas) { Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glCanvas2, true)); } animator.start(); Assert.assertTrue(animator.isStarted()); Assert.assertTrue(animator.isAnimating()); System.err.println( "canvas1 pos/siz: " + glCanvas1.getX() + "/" + glCanvas1.getY() + " " + glCanvas1.getSurfaceWidth() + "x" + glCanvas1.getSurfaceHeight()); if (twoCanvas) { System.err.println( "canvas2 pos/siz: " + glCanvas2.getX() + "/" + glCanvas2.getY() + " " + glCanvas2.getSurfaceWidth() + "x" + glCanvas2.getSurfaceHeight()); } Thread.sleep(Math.max(1000, duration / 2)); if (null != rwsize) { final Dimension compRSizeHalf = new Dimension(rwsize.width / 2, rwsize.height); final Dimension frameRSizeHalf = new Dimension(twoCanvas ? rwsize.width + 64 : rwsize.width / 2 + 64, rwsize.height + 64); if (resizeByComp) { setComponentSize(frame, glCanvas1, compRSizeHalf, glCanvas2, compRSizeHalf); } else { setFrameSize(frame, true, frameRSizeHalf); } System.err.println( "resize canvas1 pos/siz: " + glCanvas1.getX() + "/" + glCanvas1.getY() + " " + glCanvas1.getSurfaceWidth() + "x" + glCanvas1.getSurfaceHeight()); if (twoCanvas) { System.err.println( "resize canvas2 pos/siz: " + glCanvas2.getX() + "/" + glCanvas2.getY() + " " + glCanvas2.getSurfaceWidth() + "x" + glCanvas2.getSurfaceHeight()); } } final long t0 = System.currentTimeMillis(); long t1 = t0; while (!quitAdapter.shouldQuit() && t1 - t0 < duration) { Thread.sleep(100); t1 = System.currentTimeMillis(); } Assert.assertNotNull(frame); Assert.assertNotNull(glCanvas1); if (twoCanvas) { Assert.assertNotNull(glCanvas2); } else { Assert.assertNull(glCanvas2); } Assert.assertNotNull(animator); animator.stop(); Assert.assertFalse(animator.isAnimating()); Assert.assertFalse(animator.isStarted()); javax.swing.SwingUtilities.invokeAndWait( new Runnable() { public void run() { frame.setVisible(false); } }); Assert.assertEquals(false, frame.isVisible()); javax.swing.SwingUtilities.invokeAndWait( new Runnable() { public void run() { frame.remove(glCanvas1); if (twoCanvas) { frame.remove(glCanvas2); } frame.dispose(); } }); }
public void init(ThreadGroup tg, final GLWindow glWindow) { isValid = false; this.glWindow = glWindow; this.glWindow.addWindowListener( new WindowAdapter() { // Closing action: back to parent! @Override public void windowDestroyNotify(WindowEvent e) { if (isValid() && WindowClosingMode.DO_NOTHING_ON_CLOSE == glWindow.getDefaultCloseOperation()) { if (null == glWindow.getParent()) { // we may be called directly by the native EDT new Thread( new Runnable() { @Override public void run() { if (glWindow.isNativeValid()) { glWindow.reparentWindow(awtParent); } } }) .start(); } } } }); glEventListener = createInstance(glEventListenerClazzName); if (null == glEventListener) { return; } try { if (!setField(glEventListener, "window", glWindow)) { setField(glEventListener, "glWindow", glWindow); } glWindow.addGLEventListener(this); glWindow.addGLEventListener(glEventListener); if (glEventListener instanceof WindowListener) { glWindow.addWindowListener((WindowListener) glEventListener); } if (glEventListener instanceof MouseListener) { glWindow.addMouseListener((MouseListener) glEventListener); } if (glEventListener instanceof KeyListener) { glWindow.addKeyListener((KeyListener) glEventListener); } if (!noDefaultKeyListener) { glWindow.addKeyListener(this); } glWindow.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err); // glAnimator = new FPSAnimator(canvas, 60); glAnimator = new Animator(); glAnimator.setModeBits( false, Animator.MODE_EXPECT_AWT_RENDERING_THREAD); // No AWT thread involved! glAnimator.setThreadGroup(tg); glAnimator.add(glWindow); glAnimator.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, null); } catch (Throwable t) { throw new RuntimeException(t); } isValid = true; }
/** * Constructor for this class. Sets up the window and enables common features like anti-aliasing * and hardware acceleration. * * @param forceGL2ES2 Force GL2ES2 support (default on), currently Unused * @param inputHandler A predefined InputHandler that is added as event handler for input events. * @param glEventListener A predefined GLEventListener that is added as event handler for openGL * events. * @param width The initial window width. * @param height The initial window height. * @param windowTitle The window title. */ public ESightNewtWindow( boolean forceGL2ES2, InputHandler inputHandler, final GLEventListener glEventListener, int width, int height, String windowTitle) { final GLProfile glp; // if (forceGL2ES2) { // glp = GLProfile.get(GLProfile.GL2ES2); // } else { glp = GLProfile.get(GLProfile.GL3); // } // Set up the GL context final GLCapabilities caps = new GLCapabilities(glp); caps.setBackgroundOpaque(true); caps.setHardwareAccelerated(true); caps.setDoubleBuffered(true); // Add Anti-Aliasing caps.setSampleBuffers(true); caps.setAlphaBits(4); caps.setNumSamples(4); // Create the Newt Window Display dpy = NewtFactory.createDisplay(null); Screen screen = NewtFactory.createScreen(dpy, screenIdx); final GLWindow glWindow = GLWindow.create(screen, caps); glWindow.setTitle(windowTitle); // Add listeners glWindow.addMouseListener(inputHandler); glWindow.addKeyListener(inputHandler); // glWindow.setFullscreen(true); WindowListener[] listeners = glWindow.getWindowListeners(); final WindowListener original = listeners[0]; glWindow.addWindowListener( 0, new WindowAdapter() { @Override public void windowDestroyNotify(WindowEvent arg0) { glWindow.getAnimator().stop(); System.exit(0); } @Override public void windowDestroyed(WindowEvent arg0) { glWindow.getAnimator().stop(); System.exit(0); } @Override public void windowGainedFocus(WindowEvent arg0) { original.windowGainedFocus(arg0); } @Override public void windowLostFocus(WindowEvent arg0) { original.windowLostFocus(arg0); } @Override public void windowMoved(WindowEvent arg0) { original.windowMoved(arg0); } @Override public void windowRepaint(WindowUpdateEvent arg0) { original.windowRepaint(arg0); } @Override public void windowResized(WindowEvent arg0) { original.windowResized(arg0); } }); glWindow.addGLEventListener(glEventListener); // Create the Animator final Animator animator = new Animator(); animator.add(glWindow); animator.start(); glWindow.setSize(width, height); glWindow.setVisible(true); }