diff options
author | Julien Gouesse <[email protected]> | 2018-01-27 16:40:51 +0100 |
---|---|---|
committer | Julien Gouesse <[email protected]> | 2018-01-27 16:40:51 +0100 |
commit | 484a7bc1b7354f80027e45d0fd0d97473cc454dd (patch) | |
tree | 8522c4fa7d8759c0b89d6bdf478a57469edb9642 /ardor3d-jogl-swt/src | |
parent | b476eeed7ebee18a310ba02b3a740fe34b87cec2 (diff) | |
parent | 3725d8321774e80b84f302eb16089dde387822e1 (diff) |
Merges several Renanse's commits
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; + } + }); + } } |