aboutsummaryrefslogtreecommitdiffstats
path: root/ardor3d-jogl/src/main/java/com
diff options
context:
space:
mode:
Diffstat (limited to 'ardor3d-jogl/src/main/java/com')
-rw-r--r--ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglNewtAwtCanvas.java33
-rw-r--r--ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglNewtWindow.java74
2 files changed, 55 insertions, 52 deletions
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
index c164eef..fa91851 100644
--- a/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglNewtAwtCanvas.java
+++ b/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglNewtAwtCanvas.java
@@ -53,22 +53,23 @@ public class JoglNewtAwtCanvas extends NewtCanvasAWT implements Canvas, NewtWind
// Make the window visible to realize the OpenGL surface.
setVisible(true);
- // 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 = getNewtWindow().isRealized();
+ 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;
+ }
}
public void draw(final CountDownLatch latch) {
diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglNewtWindow.java b/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglNewtWindow.java
index 9117eea..a7cb777 100644
--- a/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglNewtWindow.java
+++ b/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglNewtWindow.java
@@ -140,46 +140,48 @@ public class JoglNewtWindow implements NativeCanvas, NewtWindowContainer {
return;
}
- _newtWindow.addWindowListener(new WindowAdapter() {
- @Override
- public void windowDestroyNotify(final WindowEvent e) {
- _isClosing = true;
- }
-
- // public void windowResized(final WindowEvent e) {
- // _newtWindow.invoke(true, new GLRunnable() {
- //
- // @Override
- // public boolean run(GLAutoDrawable glAutoDrawable) {
- // _canvasRenderer._camera.resize(_newtWindow.getWidth(), _newtWindow.getHeight());
- // _canvasRenderer._camera.setFrustumPerspective(_canvasRenderer._camera.getFovY(),
- // (float) _newtWindow.getWidth() / (float) _newtWindow.getHeight(),
- // _canvasRenderer._camera.getFrustumNear(),
- // _canvasRenderer._camera.getFrustumFar());
- // return true;
- // }
- // });
- // }
- });
-
// Set the size very early to prevent the default one from being used (typically when exiting full screen mode)
setSize(_settings.getWidth(), _settings.getHeight());
// Make the window visible to realize the OpenGL surface.
setVisible(true);
- // Request the focus here as it cannot work when the window is not visible
- _newtWindow.requestFocus();
- applySettings();
-
- _canvasRenderer.setContext(getContext());
-
- _newtWindow.invoke(true, new GLRunnable() {
- @Override
- public boolean run(final GLAutoDrawable glAutoDrawable) {
- _canvasRenderer.init(_settings, true);// true - do swap in renderer.
- return true;
- }
- });
- _inited = _newtWindow.isRealized();
+ if (_newtWindow.isRealized()) {
+ _newtWindow.addWindowListener(new WindowAdapter() {
+ @Override
+ public void windowDestroyNotify(final WindowEvent e) {
+ _isClosing = true;
+ }
+
+ // public void windowResized(final WindowEvent e) {
+ // _newtWindow.invoke(true, new GLRunnable() {
+ //
+ // @Override
+ // public boolean run(GLAutoDrawable glAutoDrawable) {
+ // _canvasRenderer._camera.resize(_newtWindow.getWidth(), _newtWindow.getHeight());
+ // _canvasRenderer._camera.setFrustumPerspective(_canvasRenderer._camera.getFovY(),
+ // (float) _newtWindow.getWidth() / (float) _newtWindow.getHeight(),
+ // _canvasRenderer._camera.getFrustumNear(),
+ // _canvasRenderer._camera.getFrustumFar());
+ // return true;
+ // }
+ // });
+ // }
+ });
+
+ // Request the focus here as it cannot work when the window is not visible
+ _newtWindow.requestFocus();
+ applySettings();
+
+ _canvasRenderer.setContext(getContext());
+
+ _newtWindow.invoke(true, new GLRunnable() {
+ @Override
+ public boolean run(final GLAutoDrawable glAutoDrawable) {
+ _canvasRenderer.init(_settings, true);// true - do swap in renderer.
+ return true;
+ }
+ });
+ _inited = true;
+ }
}
public void draw(final CountDownLatch latch) {