aboutsummaryrefslogtreecommitdiffstats
path: root/ardor3d-jogl/src/main
diff options
context:
space:
mode:
authorJulien Gouesse <[email protected]>2013-03-09 12:40:43 +0100
committerJulien Gouesse <[email protected]>2013-03-09 12:40:43 +0100
commitd2373e66e61f0d8e0b0e6f8e08379a9794bbc107 (patch)
tree589006d48b040e34d655184f72c623d5eec096c4 /ardor3d-jogl/src/main
parent7b20617dbfa5ffa549cd164a895353545949f58e (diff)
Doesn't assume that the drawable is realized
Diffstat (limited to 'ardor3d-jogl/src/main')
-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) {