aboutsummaryrefslogtreecommitdiffstats
path: root/ardor3d-jogl
diff options
context:
space:
mode:
authorJulien Gouesse <[email protected]>2015-09-20 19:39:43 +0200
committerJulien Gouesse <[email protected]>2015-09-20 19:39:43 +0200
commitc17c6772cdb8fd35b4fb245149297182239eb4fa (patch)
treeb8f3efe82ad0786c28718ff84ca325145f76053d /ardor3d-jogl
parentefde70918e072ed6081f8beac193293d48059630 (diff)
Moves the classes of the JOGL backend depending on AWT into ardor3d-jogl-awt
Diffstat (limited to 'ardor3d-jogl')
-rw-r--r--ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglAwtCanvas.java113
-rw-r--r--ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglAwtInitializerRunnable.java41
-rw-r--r--ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglCanvas.java285
-rw-r--r--ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglNewtAwtCanvas.java114
-rw-r--r--ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglSwingCanvas.java117
-rw-r--r--ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglSwingInitializerRunnable.java41
6 files changed, 0 insertions, 711 deletions
diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglAwtCanvas.java b/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglAwtCanvas.java
deleted file mode 100644
index b4f2c3b..0000000
--- a/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglAwtCanvas.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/**
- * Copyright (c) 2008-2010 Ardor Labs, Inc.
- *
- * This file is part of Ardor3D.
- *
- * Ardor3D is free software: you can redistribute it and/or modify it
- * under the terms of its license which may be found in the accompanying
- * LICENSE file or at <http://www.ardor3d.com/LICENSE>.
- */
-
-package com.ardor3d.framework.jogl;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.concurrent.CountDownLatch;
-
-import com.jogamp.opengl.GLAutoDrawable;
-import com.jogamp.opengl.GLRunnable;
-import com.jogamp.opengl.awt.GLCanvas;
-import javax.swing.SwingUtilities;
-
-import com.ardor3d.annotation.MainThread;
-import com.ardor3d.framework.Canvas;
-import com.ardor3d.framework.DisplaySettings;
-
-/**
- * Ardor3D JOGL AWT heavyweight canvas, AWT component for the OpenGL rendering of Ardor3D with JOGL that supports the
- * AWT input system directly and its abstraction in Ardor3D (com.ardor3d.input.awt)
- *
- */
-public class JoglAwtCanvas extends GLCanvas implements Canvas {
-
- private static final long serialVersionUID = 1L;
-
- private final JoglCanvasRenderer _canvasRenderer;
- private boolean _inited = false;
-
- private final DisplaySettings _settings;
-
- private final JoglDrawerRunnable _drawerGLRunnable;
-
- private final JoglAwtInitializerRunnable _initializerRunnable;
-
- public JoglAwtCanvas(final DisplaySettings settings, final JoglCanvasRenderer canvasRenderer) {
- this(settings, canvasRenderer, new CapsUtil());
- }
-
- public JoglAwtCanvas(final DisplaySettings settings, final JoglCanvasRenderer canvasRenderer,
- final CapsUtil capsUtil) {
- super(capsUtil.getCapsForSettings(settings));
- _drawerGLRunnable = new JoglDrawerRunnable(canvasRenderer);
- _initializerRunnable = new JoglAwtInitializerRunnable(this, settings);
- _settings = settings;
- _canvasRenderer = canvasRenderer;
-
- setFocusable(true);
- requestFocus();
- setSize(_settings.getWidth(), _settings.getHeight());
- setIgnoreRepaint(true);
- setAutoSwapBufferMode(false);
- }
-
- @Override
- @MainThread
- public void init() {
- if (_inited) {
- return;
- }
-
- // Calling setVisible(true) on the GLCanvas not from the AWT-EDT can freeze the Intel GPU under Windows
- if (!SwingUtilities.isEventDispatchThread()) {
- try {
- SwingUtilities.invokeAndWait(_initializerRunnable);
- } catch (final InterruptedException ex) {
- ex.printStackTrace();
- } catch (final InvocationTargetException ex) {
- ex.printStackTrace();
- }
- } else {
- _initializerRunnable.run();
- }
-
- _inited = isRealized();
- }
-
- @Override
- public void draw(final CountDownLatch latch) {
- if (!_inited) {
- init();
- }
-
- if (isShowing()) {
- invoke(true, _drawerGLRunnable);
- }
- if (latch != null) {
- latch.countDown();
- }
- }
-
- @Override
- public JoglCanvasRenderer getCanvasRenderer() {
- return _canvasRenderer;
- }
-
- public void setVSyncEnabled(final boolean enabled) {
- invoke(true, new GLRunnable() {
- @Override
- public boolean run(final GLAutoDrawable glAutoDrawable) {
- glAutoDrawable.getGL().setSwapInterval(enabled ? 1 : 0);
- return false;
- }
- });
- }
-}
diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglAwtInitializerRunnable.java b/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglAwtInitializerRunnable.java
deleted file mode 100644
index 3a7153d..0000000
--- a/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglAwtInitializerRunnable.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- * Copyright (c) 2008-2014 Ardor Labs, Inc.
- *
- * This file is part of Ardor3D.
- *
- * Ardor3D is free software: you can redistribute it and/or modify it
- * under the terms of its license which may be found in the accompanying
- * LICENSE file or at <http://www.ardor3d.com/LICENSE>.
- */
-
-package com.ardor3d.framework.jogl;
-
-import com.ardor3d.framework.DisplaySettings;
-
-public class JoglAwtInitializerRunnable implements Runnable {
-
- private final JoglAwtCanvas _joglAwtCanvas;
-
- private final DisplaySettings _settings;
-
- public JoglAwtInitializerRunnable(final JoglAwtCanvas joglAwtCanvas, final DisplaySettings settings) {
- _joglAwtCanvas = joglAwtCanvas;
- _settings = settings;
- }
-
- @Override
- public void run() {
- // Make the window visible to realize the OpenGL surface.
- _joglAwtCanvas.setVisible(true);
- // Force the realization
- _joglAwtCanvas.display();
- if (_joglAwtCanvas.getDelegatedDrawable().isRealized()) {
- // Request the focus here as it cannot work when the window is not visible
- _joglAwtCanvas.requestFocus();
- // The OpenGL context has been created after the realization of the surface
- _joglAwtCanvas.getCanvasRenderer().setContext(_joglAwtCanvas.getContext());
- // As the canvas renderer knows the OpenGL context, it can be initialized
- _joglAwtCanvas.getCanvasRenderer().init(_settings, true);
- }
- }
-} \ No newline at end of file
diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglCanvas.java b/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglCanvas.java
deleted file mode 100644
index 9874730..0000000
--- a/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglCanvas.java
+++ /dev/null
@@ -1,285 +0,0 @@
-/**
- * Copyright (c) 2008-2010 Ardor Labs, Inc.
- *
- * This file is part of Ardor3D.
- *
- * Ardor3D is free software: you can redistribute it and/or modify it
- * under the terms of its license which may be found in the accompanying
- * LICENSE file or at <http://www.ardor3d.com/LICENSE>.
- */
-
-package com.ardor3d.framework.jogl;
-
-import java.awt.Dimension;
-import java.awt.DisplayMode;
-import java.awt.Frame;
-import java.awt.GraphicsDevice;
-import java.awt.GraphicsEnvironment;
-import java.awt.Toolkit;
-import java.awt.event.FocusListener;
-import java.awt.event.KeyListener;
-import java.awt.event.MouseListener;
-import java.awt.event.MouseMotionListener;
-import java.awt.event.MouseWheelListener;
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
-import java.util.concurrent.CountDownLatch;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import com.jogamp.opengl.GLContext;
-import com.jogamp.opengl.GLException;
-
-import com.ardor3d.annotation.MainThread;
-import com.ardor3d.framework.CanvasRenderer;
-import com.ardor3d.framework.DisplaySettings;
-import com.ardor3d.framework.NativeCanvas;
-import com.ardor3d.image.Image;
-import com.ardor3d.renderer.jogl.JoglPbufferTextureRenderer;
-
-/**
- * A canvas implementation for use with AWT JOGL windows.
- */
-public class JoglCanvas extends Frame implements NativeCanvas {
-
- private static final long serialVersionUID = 1L;
-
- private static final Logger logger = Logger.getLogger(JoglCanvas.class.getName());
-
- private final DisplaySettings _settings;
- private boolean _inited = false;
- private boolean _isClosing = false;
-
- private JoglAwtCanvas _glCanvas;
-
- public JoglCanvas(final JoglCanvasRenderer canvasRenderer, final DisplaySettings settings) {
- _settings = settings;
-
- // Create the OpenGL canvas
- _glCanvas = new JoglAwtCanvas(_settings, canvasRenderer);
-
- // Default is not-resizeable. If you turn on resizeable, know what you are doing.
- setResizable(false);
- }
-
- @Override
- public synchronized void addKeyListener(final KeyListener l) {
- _glCanvas.addKeyListener(l);
- }
-
- @Override
- public synchronized void addMouseListener(final MouseListener l) {
- _glCanvas.addMouseListener(l);
- }
-
- @Override
- public synchronized void addMouseMotionListener(final MouseMotionListener l) {
- _glCanvas.addMouseMotionListener(l);
- }
-
- @Override
- public synchronized void addMouseWheelListener(final MouseWheelListener l) {
- _glCanvas.addMouseWheelListener(l);
- }
-
- @Override
- public synchronized void addFocusListener(final FocusListener l) {
- _glCanvas.addFocusListener(l);
- }
-
- @Override
- @MainThread
- public void init() {
- privateInit();
- }
-
- @MainThread
- protected void privateInit() {
- if (_inited) {
- return;
- }
-
- // FIXME: remove need for directly setting _parentContext.
- JoglPbufferTextureRenderer._parentContext = _glCanvas.getContext();
-
- this.add(_glCanvas);
-
- final boolean isDisplayModeModified;
- final GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
- // Get the current display mode
- final DisplayMode previousDisplayMode = gd.getDisplayMode();
- // Handle full screen mode if requested.
- if (_settings.isFullScreen()) {
- setUndecorated(true);
- // Check if the full-screen mode is supported by the OS
- boolean isFullScreenSupported = gd.isFullScreenSupported();
- if (isFullScreenSupported) {
- gd.setFullScreenWindow(this);
- // Check if display mode changes are supported by the OS
- if (gd.isDisplayChangeSupported()) {
- // Get all available display modes
- final DisplayMode[] displayModes = gd.getDisplayModes();
- DisplayMode multiBitsDepthSupportedDisplayMode = null;
- DisplayMode refreshRateUnknownDisplayMode = null;
- DisplayMode multiBitsDepthSupportedAndRefreshRateUnknownDisplayMode = null;
- DisplayMode matchingDisplayMode = null;
- DisplayMode currentDisplayMode;
- // Look for the display mode that matches with our parameters
- // Look for some display modes that are close to these parameters
- // and that could be used as substitutes
- // On some machines, the refresh rate is unknown and/or multi bit
- // depths are supported. If you try to force a particular refresh
- // rate or a bit depth, you might find no available display mode
- // that matches exactly with your parameters
- for (int i = 0; i < displayModes.length && matchingDisplayMode == null; i++) {
- currentDisplayMode = displayModes[i];
- if (currentDisplayMode.getWidth() == _settings.getWidth()
- && currentDisplayMode.getHeight() == _settings.getHeight()) {
- if (currentDisplayMode.getBitDepth() == _settings.getColorDepth()) {
- if (currentDisplayMode.getRefreshRate() == _settings.getFrequency()) {
- matchingDisplayMode = currentDisplayMode;
- } else if (currentDisplayMode.getRefreshRate() == DisplayMode.REFRESH_RATE_UNKNOWN) {
- refreshRateUnknownDisplayMode = currentDisplayMode;
- }
- } else if (currentDisplayMode.getBitDepth() == DisplayMode.BIT_DEPTH_MULTI) {
- if (currentDisplayMode.getRefreshRate() == _settings.getFrequency()) {
- multiBitsDepthSupportedDisplayMode = currentDisplayMode;
- } else if (currentDisplayMode.getRefreshRate() == DisplayMode.REFRESH_RATE_UNKNOWN) {
- multiBitsDepthSupportedAndRefreshRateUnknownDisplayMode = currentDisplayMode;
- }
- }
- }
- }
- DisplayMode nextDisplayMode = null;
- if (matchingDisplayMode != null) {
- nextDisplayMode = matchingDisplayMode;
- } else if (multiBitsDepthSupportedDisplayMode != null) {
- nextDisplayMode = multiBitsDepthSupportedDisplayMode;
- } else if (refreshRateUnknownDisplayMode != null) {
- nextDisplayMode = refreshRateUnknownDisplayMode;
- } else if (multiBitsDepthSupportedAndRefreshRateUnknownDisplayMode != null) {
- nextDisplayMode = multiBitsDepthSupportedAndRefreshRateUnknownDisplayMode;
- } else {
- isFullScreenSupported = false;
- }
- // If we have found a display mode that approximatively matches
- // with the input parameters, use it
- if (nextDisplayMode != null) {
- gd.setDisplayMode(nextDisplayMode);
- isDisplayModeModified = true;
- } else {
- isDisplayModeModified = false;
- }
- } else {
- isDisplayModeModified = false;
- // Resize the canvas if the display mode cannot be changed
- // and the screen size is not equal to the canvas size
- final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
- if (screenSize.width != _settings.getWidth() || screenSize.height != _settings.getHeight()) {
- _glCanvas.setSize(screenSize);
- }
- }
- } else {
- isDisplayModeModified = false;
- }
-
- // Software windowed full-screen mode
- if (!isFullScreenSupported) {
- final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
- // Resize the canvas
- _glCanvas.setSize(screenSize);
- // Resize the frame so that it occupies the whole screen
- this.setSize(screenSize);
- // Set its location at the top left corner
- this.setLocation(0, 0);
- }
- }
- // Otherwise, center the window on the screen.
- else {
- isDisplayModeModified = false;
- pack();
-
- int x, y;
- x = (Toolkit.getDefaultToolkit().getScreenSize().width - _settings.getWidth()) / 2;
- y = (Toolkit.getDefaultToolkit().getScreenSize().height - _settings.getHeight()) / 2;
- this.setLocation(x, y);
- }
-
- addWindowListener(new WindowAdapter() {
- @Override
- public void windowClosing(final WindowEvent e) {
- _isClosing = true;
- // If required, restore the previous display mode
- if (isDisplayModeModified) {
- gd.setDisplayMode(previousDisplayMode);
- }
- // If required, get back to the windowed mode
- if (gd.getFullScreenWindow() == JoglCanvas.this) {
- gd.setFullScreenWindow(null);
- }
- }
- });
-
- // Make the window visible to realize the OpenGL surface.
- setVisible(true);
-
- _glCanvas.init(); // true - do swap in renderer.
- _inited = true;
- }
-
- @Override
- public void draw(final CountDownLatch latch) {
- if (!_inited) {
- privateInit();
- }
-
- _glCanvas.draw(latch);
- }
-
- @Override
- public CanvasRenderer getCanvasRenderer() {
- return _glCanvas.getCanvasRenderer();
- }
-
- @Override
- public void close() {
- try {
- if (GLContext.getCurrent() != null) {
- // Release the OpenGL resources.
- GLContext.getCurrent().release();
- }
- } catch (final GLException releaseFailure) {
- logger.log(Level.WARNING, "Failed to release OpenGL Context: " + _glCanvas, releaseFailure);
- } finally {
- _glCanvas = null;
- }
-
- // Dispose of any window resources.
- dispose();
- }
-
- @Override
- public boolean isActive() {
- return hasFocus();
- }
-
- @Override
- public boolean isClosing() {
- return _isClosing;
- }
-
- @Override
- public void moveWindowTo(final int locX, final int locY) {
- setLocation(locX, locY);
- }
-
- @Override
- public void setIcon(final Image[] iconImages) {
- // not implemented, not supported by AWT anyway
- }
-
- @Override
- public void setVSyncEnabled(final boolean enabled) {
- _glCanvas.setVSyncEnabled(enabled);
- }
-}
diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglNewtAwtCanvas.java b/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglNewtAwtCanvas.java
deleted file mode 100644
index ee195b8..0000000
--- a/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglNewtAwtCanvas.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/**
- * Copyright (c) 2008-2012 Ardor Labs, Inc.
- *
- * This file is part of Ardor3D.
- *
- * Ardor3D is free software: you can redistribute it and/or modify it
- * under the terms of its license which may be found in the accompanying
- * LICENSE file or at <http://www.ardor3d.com/LICENSE>.
- */
-
-package com.ardor3d.framework.jogl;
-
-import java.util.concurrent.CountDownLatch;
-
-import com.jogamp.opengl.GLAutoDrawable;
-import com.jogamp.opengl.GLRunnable;
-
-import com.ardor3d.annotation.MainThread;
-import com.ardor3d.framework.Canvas;
-import com.ardor3d.framework.DisplaySettings;
-import com.jogamp.newt.awt.NewtCanvasAWT;
-import com.jogamp.newt.opengl.GLWindow;
-
-public class JoglNewtAwtCanvas extends NewtCanvasAWT implements Canvas, NewtWindowContainer {
-
- private static final long serialVersionUID = 1L;
-
- private final JoglCanvasRenderer _canvasRenderer;
- private boolean _inited = false;
-
- private final DisplaySettings _settings;
-
- private final JoglDrawerRunnable _drawerGLRunnable;
-
- public JoglNewtAwtCanvas(final DisplaySettings settings, final JoglCanvasRenderer canvasRenderer) {
- this(settings, canvasRenderer, new CapsUtil());
- }
-
- public JoglNewtAwtCanvas(final DisplaySettings settings, final JoglCanvasRenderer canvasRenderer,
- final CapsUtil capsUtil) {
- super(GLWindow.create(capsUtil.getCapsForSettings(settings)));
- _drawerGLRunnable = new JoglDrawerRunnable(canvasRenderer);
- getNewtWindow().setUndecorated(true);
- _settings = settings;
- _canvasRenderer = canvasRenderer;
-
- setFocusable(true);
- setSize(_settings.getWidth(), _settings.getHeight());
- setIgnoreRepaint(true);
- getNewtWindow().setAutoSwapBufferMode(false);
- }
-
- @Override
- @MainThread
- public void init() {
- if (_inited) {
- return;
- }
-
- // Make the window visible to realize the OpenGL surface.
- setVisible(true);
- if (getNewtWindow().isRealized()) {
- // Request the focus here as it cannot work when the window is not visible
- requestFocus();
- /**
- * I do not understand why I cannot get the context earlier, I failed in getting it from addNotify() and
- * setVisible(true)
- * */
- _canvasRenderer.setContext(getNewtWindow().getContext());
- getNewtWindow().invoke(true, new GLRunnable() {
- @Override
- public boolean run(final GLAutoDrawable glAutoDrawable) {
- _canvasRenderer.init(_settings, true);// true - do swap in renderer.
- return true;
- }
- });
- _inited = true;
- }
- }
-
- @Override
- public void draw(final CountDownLatch latch) {
- if (!_inited) {
- init();
- }
-
- if (isShowing()) {
- getNewtWindow().invoke(true, _drawerGLRunnable);
- }
- if (latch != null) {
- latch.countDown();
- }
- }
-
- @Override
- public JoglCanvasRenderer getCanvasRenderer() {
- return _canvasRenderer;
- }
-
- @Override
- public GLWindow getNewtWindow() {
- return (GLWindow) getNEWTChild();
- }
-
- public void setVSyncEnabled(final boolean enabled) {
- getNewtWindow().invoke(true, new GLRunnable() {
- @Override
- public boolean run(final GLAutoDrawable glAutoDrawable) {
- glAutoDrawable.getGL().setSwapInterval(enabled ? 1 : 0);
- return false;
- }
- });
- }
-}
diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglSwingCanvas.java b/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglSwingCanvas.java
deleted file mode 100644
index 45c2974..0000000
--- a/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglSwingCanvas.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/**
- * Copyright (c) 2008-2010 Ardor Labs, Inc.
- *
- * This file is part of Ardor3D.
- *
- * Ardor3D is free software: you can redistribute it and/or modify it
- * under the terms of its license which may be found in the accompanying
- * LICENSE file or at <http://www.ardor3d.com/LICENSE>.
- */
-
-package com.ardor3d.framework.jogl;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.concurrent.CountDownLatch;
-
-import javax.swing.SwingUtilities;
-
-import com.ardor3d.annotation.MainThread;
-import com.ardor3d.framework.Canvas;
-import com.ardor3d.framework.DisplaySettings;
-import com.jogamp.opengl.GLAutoDrawable;
-import com.jogamp.opengl.GLRunnable;
-import com.jogamp.opengl.awt.GLJPanel;
-
-/**
- * Ardor3D JOGL Swing lightweight canvas, Swing component for the OpenGL rendering of Ardor3D with JOGL that supports
- * the AWT input system directly and its abstraction in Ardor3D (com.ardor3d.input.awt). As this canvas is generally
- * slower and heavier (in term of memory footprint) than JoglAwtCanvas, use it if and only if you have some problems
- * when mixing heavyweight and lightweight components.
- *
- * N.B: This canvas uses GLSL internally when it is available and supported, setting the property jogl.gljpanel.noglsl
- * to true is recommended to avoid any conflicts with the effects based on GLSL including the bloom effect.
- */
-public class JoglSwingCanvas extends GLJPanel implements Canvas {
-
- private static final long serialVersionUID = 1L;
-
- private final JoglCanvasRenderer _canvasRenderer;
- private boolean _inited = false;
-
- private final DisplaySettings _settings;
-
- private final JoglDrawerRunnable _drawerGLRunnable;
-
- private final JoglSwingInitializerRunnable _initializerRunnable;
-
- public JoglSwingCanvas(final DisplaySettings settings, final JoglCanvasRenderer canvasRenderer) {
- this(settings, canvasRenderer, new CapsUtil());
- }
-
- public JoglSwingCanvas(final DisplaySettings settings, final JoglCanvasRenderer canvasRenderer,
- final CapsUtil capsUtil) {
- super(capsUtil.getCapsForSettings(settings));
- _drawerGLRunnable = new JoglDrawerRunnable(canvasRenderer);
- _initializerRunnable = new JoglSwingInitializerRunnable(this, settings);
- _settings = settings;
- _canvasRenderer = canvasRenderer;
-
- setFocusable(true);
- requestFocus();
- setSize(_settings.getWidth(), _settings.getHeight());
- setIgnoreRepaint(true);
- setAutoSwapBufferMode(false);
- }
-
- @Override
- @MainThread
- public void init() {
- if (_inited) {
- return;
- }
-
- // Calling setVisible(true) on the GLCanvas not from the AWT-EDT can freeze the Intel GPU under Windows
- if (!SwingUtilities.isEventDispatchThread()) {
- try {
- SwingUtilities.invokeAndWait(_initializerRunnable);
- } catch (final InterruptedException ex) {
- ex.printStackTrace();
- } catch (final InvocationTargetException ex) {
- ex.printStackTrace();
- }
- } else {
- _initializerRunnable.run();
- }
-
- _inited = isRealized();
- }
-
- @Override
- public void draw(final CountDownLatch latch) {
- if (!_inited) {
- init();
- }
-
- if (isShowing()) {
- invoke(true, _drawerGLRunnable);
- }
- if (latch != null) {
- latch.countDown();
- }
- }
-
- @Override
- public JoglCanvasRenderer getCanvasRenderer() {
- return _canvasRenderer;
- }
-
- public void setVSyncEnabled(final boolean enabled) {
- invoke(true, new GLRunnable() {
- @Override
- public boolean run(final GLAutoDrawable glAutoDrawable) {
- glAutoDrawable.getGL().setSwapInterval(enabled ? 1 : 0);
- return false;
- }
- });
- }
-}
diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglSwingInitializerRunnable.java b/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglSwingInitializerRunnable.java
deleted file mode 100644
index c50039b..0000000
--- a/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglSwingInitializerRunnable.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- * Copyright (c) 2008-2014 Ardor Labs, Inc.
- *
- * This file is part of Ardor3D.
- *
- * Ardor3D is free software: you can redistribute it and/or modify it
- * under the terms of its license which may be found in the accompanying
- * LICENSE file or at <http://www.ardor3d.com/LICENSE>.
- */
-
-package com.ardor3d.framework.jogl;
-
-import com.ardor3d.framework.DisplaySettings;
-
-public class JoglSwingInitializerRunnable implements Runnable {
-
- private final JoglSwingCanvas _joglSwingCanvas;
-
- private final DisplaySettings _settings;
-
- public JoglSwingInitializerRunnable(final JoglSwingCanvas joglSwingCanvas, final DisplaySettings settings) {
- _joglSwingCanvas = joglSwingCanvas;
- _settings = settings;
- }
-
- @Override
- public void run() {
- // Make the window visible to realize the OpenGL surface.
- _joglSwingCanvas.setVisible(true);
- // Force the realization
- _joglSwingCanvas.display();
- if (_joglSwingCanvas.getDelegatedDrawable().isRealized()) {
- // Request the focus here as it cannot work when the window is not visible
- _joglSwingCanvas.requestFocus();
- // The OpenGL context has been created after the realization of the surface
- _joglSwingCanvas.getCanvasRenderer().setContext(_joglSwingCanvas.getContext());
- // As the canvas renderer knows the OpenGL context, it can be initialized
- _joglSwingCanvas.getCanvasRenderer().init(_settings, true);
- }
- }
-} \ No newline at end of file