diff options
Diffstat (limited to 'ardor3d-jogl-swt/src')
-rw-r--r-- | ardor3d-jogl-swt/src/main/java/com/ardor3d/framework/jogl/swt/JoglNewtSwtCanvas.java | 173 | ||||
-rw-r--r-- | ardor3d-jogl-swt/src/main/java/com/ardor3d/framework/jogl/swt/JoglSwtCanvas.java | 159 |
2 files changed, 179 insertions, 153 deletions
diff --git a/ardor3d-jogl-swt/src/main/java/com/ardor3d/framework/jogl/swt/JoglNewtSwtCanvas.java b/ardor3d-jogl-swt/src/main/java/com/ardor3d/framework/jogl/swt/JoglNewtSwtCanvas.java index e8813be..4b50b06 100644 --- a/ardor3d-jogl-swt/src/main/java/com/ardor3d/framework/jogl/swt/JoglNewtSwtCanvas.java +++ b/ardor3d-jogl-swt/src/main/java/com/ardor3d/framework/jogl/swt/JoglNewtSwtCanvas.java @@ -3,7 +3,7 @@ * * This file is part of Ardor3D. * - * Ardor3D is free software: you can redistribute it and/or modify it + * 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>. */ @@ -24,6 +24,7 @@ import com.ardor3d.framework.jogl.CapsUtil; import com.ardor3d.framework.jogl.JoglCanvasRenderer; import com.ardor3d.framework.jogl.JoglDrawerRunnable; import com.ardor3d.framework.jogl.NewtWindowContainer; +import com.ardor3d.input.MouseManager; import com.jogamp.newt.opengl.GLWindow; import com.jogamp.newt.swt.NewtCanvasSWT; @@ -34,84 +35,96 @@ import com.jogamp.newt.swt.NewtCanvasSWT; */ public class JoglNewtSwtCanvas extends NewtCanvasSWT implements Canvas, NewtWindowContainer { - private final JoglCanvasRenderer _canvasRenderer; - private boolean _inited = false; - - private final DisplaySettings _settings; - - private final JoglDrawerRunnable _drawerGLRunnable; - - public JoglNewtSwtCanvas(final DisplaySettings settings, final JoglCanvasRenderer canvasRenderer, - final Composite composite, final int style) { - this(settings, canvasRenderer, new CapsUtil(), composite, style); - } - - public JoglNewtSwtCanvas(final DisplaySettings settings, final JoglCanvasRenderer canvasRenderer, - final CapsUtil capsUtil, final Composite composite, final int style) { - super(composite, style, GLWindow.create(capsUtil.getCapsForSettings(settings))); - _drawerGLRunnable = new JoglDrawerRunnable(canvasRenderer); - getNewtWindow().setUndecorated(true); - _settings = settings; - _canvasRenderer = canvasRenderer; - - setSize(_settings.getWidth(), _settings.getHeight()); - 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()) { - _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 (isVisible()) { - 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; - } - }); - } + private final JoglCanvasRenderer _canvasRenderer; + private boolean _inited = false; + + private final DisplaySettings _settings; + + private final JoglDrawerRunnable _drawerGLRunnable; + + public JoglNewtSwtCanvas(final DisplaySettings settings, final JoglCanvasRenderer canvasRenderer, + final Composite composite, final int style) { + this(settings, canvasRenderer, new CapsUtil(), composite, style); + } + + public JoglNewtSwtCanvas(final DisplaySettings settings, final JoglCanvasRenderer canvasRenderer, + final CapsUtil capsUtil, final Composite composite, final int style) { + super(composite, style, GLWindow.create(capsUtil.getCapsForSettings(settings))); + _drawerGLRunnable = new JoglDrawerRunnable(canvasRenderer); + getNewtWindow().setUndecorated(true); + _settings = settings; + _canvasRenderer = canvasRenderer; + + setSize(_settings.getWidth(), _settings.getHeight()); + 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()) { + _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 (isVisible()) { + getNewtWindow().invoke(true, _drawerGLRunnable); + } + if (latch != null) { + latch.countDown(); + } + } + + @Override + public JoglCanvasRenderer getCanvasRenderer() { + return _canvasRenderer; + } + + protected MouseManager _manager; + + @Override + public MouseManager getMouseManager() { + return _manager; + } + + @Override + public void setMouseManager(final MouseManager manager) { + _manager = manager; + } + + @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-swt/src/main/java/com/ardor3d/framework/jogl/swt/JoglSwtCanvas.java b/ardor3d-jogl-swt/src/main/java/com/ardor3d/framework/jogl/swt/JoglSwtCanvas.java index 666169f..26ba602 100644 --- a/ardor3d-jogl-swt/src/main/java/com/ardor3d/framework/jogl/swt/JoglSwtCanvas.java +++ b/ardor3d-jogl-swt/src/main/java/com/ardor3d/framework/jogl/swt/JoglSwtCanvas.java @@ -3,7 +3,7 @@ * * This file is part of Ardor3D. * - * Ardor3D is free software: you can redistribute it and/or modify it + * 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>. */ @@ -24,6 +24,7 @@ import com.ardor3d.framework.DisplaySettings; import com.ardor3d.framework.jogl.CapsUtil; import com.ardor3d.framework.jogl.JoglCanvasRenderer; import com.ardor3d.framework.jogl.JoglDrawerRunnable; +import com.ardor3d.input.MouseManager; import com.jogamp.opengl.swt.GLCanvas; /** @@ -32,77 +33,89 @@ import com.jogamp.opengl.swt.GLCanvas; */ public class JoglSwtCanvas extends GLCanvas implements Canvas { - private final JoglCanvasRenderer _canvasRenderer; - private boolean _inited = false; - - private final DisplaySettings _settings; - - private final JoglDrawerRunnable _drawerGLRunnable; - - private final JoglSwtInitializerRunnable _initializerRunnable; - - public JoglSwtCanvas(final DisplaySettings settings, final JoglCanvasRenderer canvasRenderer, - final Composite composite, final int style) { - this(settings, canvasRenderer, new CapsUtil(), composite, style); - } - - public JoglSwtCanvas(final DisplaySettings settings, final JoglCanvasRenderer canvasRenderer, - final CapsUtil capsUtil, final Composite composite, final int style) { - super(composite, style, capsUtil.getCapsForSettings(settings), null); - _drawerGLRunnable = new JoglDrawerRunnable(canvasRenderer); - _initializerRunnable = new JoglSwtInitializerRunnable(this, settings); - _settings = settings; - _canvasRenderer = canvasRenderer; - - setFocus(); - setSize(_settings.getWidth(), _settings.getHeight()); - setAutoSwapBufferMode(false); - } - - @Override - @MainThread - public void init() { - if (_inited) { - return; - } - - // if we aren't on SWT user interface thread - if (Display.getCurrent() == null) { - Display.getDefault().syncExec(_initializerRunnable); - } else { - _initializerRunnable.run(); - } - - _inited = isRealized(); - } - - @Override - public void draw(final CountDownLatch latch) { - if (!_inited) { - init(); - } - - if (isVisible()) { - 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; - } - }); - } + private final JoglCanvasRenderer _canvasRenderer; + private boolean _inited = false; + + private final DisplaySettings _settings; + + private final JoglDrawerRunnable _drawerGLRunnable; + + private final JoglSwtInitializerRunnable _initializerRunnable; + + public JoglSwtCanvas(final DisplaySettings settings, final JoglCanvasRenderer canvasRenderer, + final Composite composite, final int style) { + this(settings, canvasRenderer, new CapsUtil(), composite, style); + } + + public JoglSwtCanvas(final DisplaySettings settings, final JoglCanvasRenderer canvasRenderer, + final CapsUtil capsUtil, final Composite composite, final int style) { + super(composite, style, capsUtil.getCapsForSettings(settings), null); + _drawerGLRunnable = new JoglDrawerRunnable(canvasRenderer); + _initializerRunnable = new JoglSwtInitializerRunnable(this, settings); + _settings = settings; + _canvasRenderer = canvasRenderer; + + setFocus(); + setSize(_settings.getWidth(), _settings.getHeight()); + setAutoSwapBufferMode(false); + } + + @Override + @MainThread + public void init() { + if (_inited) { + return; + } + + // if we aren't on SWT user interface thread + if (Display.getCurrent() == null) { + Display.getDefault().syncExec(_initializerRunnable); + } else { + _initializerRunnable.run(); + } + + _inited = isRealized(); + } + + @Override + public void draw(final CountDownLatch latch) { + if (!_inited) { + init(); + } + + if (isVisible()) { + invoke(true, _drawerGLRunnable); + } + if (latch != null) { + latch.countDown(); + } + } + + @Override + public JoglCanvasRenderer getCanvasRenderer() { + return _canvasRenderer; + } + + protected MouseManager _manager; + + @Override + public MouseManager getMouseManager() { + return _manager; + } + + @Override + public void setMouseManager(final MouseManager manager) { + _manager = manager; + } + + 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; + } + }); + } } |