From 4dd9c6ac78919d2cdc79c83f4e76344c279dc1a5 Mon Sep 17 00:00:00 2001 From: Julien Gouesse Date: Sun, 20 Sep 2015 23:28:02 +0200 Subject: Uses some less misleading package names in ardor3d-jogl-awt and ardor3d-jogl-swt, renames JoglCanvas JoglAwtWindow --- .../ardor3d/framework/jogl/JoglNewtSwtCanvas.java | 113 -------------------- .../com/ardor3d/framework/jogl/JoglSwtCanvas.java | 105 ------------------ .../framework/jogl/JoglSwtInitializerRunnable.java | 42 -------- .../framework/jogl/swt/JoglNewtSwtCanvas.java | 117 +++++++++++++++++++++ .../ardor3d/framework/jogl/swt/JoglSwtCanvas.java | 108 +++++++++++++++++++ .../jogl/swt/JoglSwtInitializerRunnable.java | 42 ++++++++ 6 files changed, 267 insertions(+), 260 deletions(-) delete mode 100644 ardor3d-jogl-swt/src/main/java/com/ardor3d/framework/jogl/JoglNewtSwtCanvas.java delete mode 100644 ardor3d-jogl-swt/src/main/java/com/ardor3d/framework/jogl/JoglSwtCanvas.java delete mode 100644 ardor3d-jogl-swt/src/main/java/com/ardor3d/framework/jogl/JoglSwtInitializerRunnable.java create mode 100644 ardor3d-jogl-swt/src/main/java/com/ardor3d/framework/jogl/swt/JoglNewtSwtCanvas.java create mode 100644 ardor3d-jogl-swt/src/main/java/com/ardor3d/framework/jogl/swt/JoglSwtCanvas.java create mode 100644 ardor3d-jogl-swt/src/main/java/com/ardor3d/framework/jogl/swt/JoglSwtInitializerRunnable.java (limited to 'ardor3d-jogl-swt/src') diff --git a/ardor3d-jogl-swt/src/main/java/com/ardor3d/framework/jogl/JoglNewtSwtCanvas.java b/ardor3d-jogl-swt/src/main/java/com/ardor3d/framework/jogl/JoglNewtSwtCanvas.java deleted file mode 100644 index 22f52fa..0000000 --- a/ardor3d-jogl-swt/src/main/java/com/ardor3d/framework/jogl/JoglNewtSwtCanvas.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 . - */ - -package com.ardor3d.framework.jogl; - -import java.util.concurrent.CountDownLatch; - -import com.jogamp.opengl.GLAutoDrawable; -import com.jogamp.opengl.GLRunnable; - -import org.eclipse.swt.widgets.Composite; - -import com.ardor3d.annotation.MainThread; -import com.ardor3d.framework.Canvas; -import com.ardor3d.framework.DisplaySettings; -import com.jogamp.newt.opengl.GLWindow; -import com.jogamp.newt.swt.NewtCanvasSWT; - -/** - * Ardor3D JOGL SWT lightweight canvas, SWT control for the OpenGL rendering of Ardor3D with JOGL that supports both - * NEWT and SWT input systems directly and their abstractions in Ardor3D (com.ardor3d.input.jogl and - * com.ardor3d.input.swt) - */ -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; - } - }); - } - -} diff --git a/ardor3d-jogl-swt/src/main/java/com/ardor3d/framework/jogl/JoglSwtCanvas.java b/ardor3d-jogl-swt/src/main/java/com/ardor3d/framework/jogl/JoglSwtCanvas.java deleted file mode 100644 index fbdf1bb..0000000 --- a/ardor3d-jogl-swt/src/main/java/com/ardor3d/framework/jogl/JoglSwtCanvas.java +++ /dev/null @@ -1,105 +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 . - */ - -package com.ardor3d.framework.jogl; - -import java.util.concurrent.CountDownLatch; - -import com.jogamp.opengl.GLAutoDrawable; -import com.jogamp.opengl.GLRunnable; - -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; - -import com.ardor3d.annotation.MainThread; -import com.ardor3d.framework.Canvas; -import com.ardor3d.framework.DisplaySettings; -import com.jogamp.opengl.swt.GLCanvas; - -/** - * Ardor3D JOGL SWT heavyweight canvas, SWT control for the OpenGL rendering of Ardor3D with JOGL that supports the SWT - * input system directly and its abstraction in Ardor3D (com.ardor3d.input.swt) - */ -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; - } - }); - } - -} diff --git a/ardor3d-jogl-swt/src/main/java/com/ardor3d/framework/jogl/JoglSwtInitializerRunnable.java b/ardor3d-jogl-swt/src/main/java/com/ardor3d/framework/jogl/JoglSwtInitializerRunnable.java deleted file mode 100644 index f580221..0000000 --- a/ardor3d-jogl-swt/src/main/java/com/ardor3d/framework/jogl/JoglSwtInitializerRunnable.java +++ /dev/null @@ -1,42 +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 . - */ - -package com.ardor3d.framework.jogl; - -import com.ardor3d.framework.DisplaySettings; - -public class JoglSwtInitializerRunnable implements Runnable { - - private final JoglSwtCanvas _joglSwtCanvas; - - private final DisplaySettings _settings; - - public JoglSwtInitializerRunnable(final JoglSwtCanvas joglSwtCanvas, final DisplaySettings settings) { - _joglSwtCanvas = joglSwtCanvas; - _settings = settings; - } - - @Override - public void run() { - // Make the window visible to realize the OpenGL surface. - _joglSwtCanvas.setVisible(true); - // Force the realization - _joglSwtCanvas.display(); - if (_joglSwtCanvas.getDelegatedDrawable().isRealized()) { - // Request the focus here as it cannot work when the window is not visible - _joglSwtCanvas.setFocus(); - // The OpenGL context has been created after the realization of the surface - _joglSwtCanvas.getCanvasRenderer().setContext(_joglSwtCanvas.getContext()); - // As the canvas renderer knows the OpenGL context, it can be initialized - _joglSwtCanvas.getCanvasRenderer().init(_settings, true); - } - } - -} 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 new file mode 100644 index 0000000..62f0244 --- /dev/null +++ b/ardor3d-jogl-swt/src/main/java/com/ardor3d/framework/jogl/swt/JoglNewtSwtCanvas.java @@ -0,0 +1,117 @@ +/** + * 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 . + */ + +package com.ardor3d.framework.jogl.swt; + +import java.util.concurrent.CountDownLatch; + +import com.jogamp.opengl.GLAutoDrawable; +import com.jogamp.opengl.GLRunnable; + +import org.eclipse.swt.widgets.Composite; + +import com.ardor3d.annotation.MainThread; +import com.ardor3d.framework.Canvas; +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.framework.jogl.NewtWindowContainer; +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.newt.swt.NewtCanvasSWT; + +/** + * Ardor3D JOGL SWT lightweight canvas, SWT control for the OpenGL rendering of Ardor3D with JOGL that supports both + * NEWT and SWT input systems directly and their abstractions in Ardor3D (com.ardor3d.input.jogl and + * com.ardor3d.input.swt) + */ +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; + } + }); + } + +} 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 new file mode 100644 index 0000000..666169f --- /dev/null +++ b/ardor3d-jogl-swt/src/main/java/com/ardor3d/framework/jogl/swt/JoglSwtCanvas.java @@ -0,0 +1,108 @@ +/** + * 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 . + */ + +package com.ardor3d.framework.jogl.swt; + +import java.util.concurrent.CountDownLatch; + +import com.jogamp.opengl.GLAutoDrawable; +import com.jogamp.opengl.GLRunnable; + +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; + +import com.ardor3d.annotation.MainThread; +import com.ardor3d.framework.Canvas; +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.jogamp.opengl.swt.GLCanvas; + +/** + * Ardor3D JOGL SWT heavyweight canvas, SWT control for the OpenGL rendering of Ardor3D with JOGL that supports the SWT + * input system directly and its abstraction in Ardor3D (com.ardor3d.input.swt) + */ +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; + } + }); + } + +} diff --git a/ardor3d-jogl-swt/src/main/java/com/ardor3d/framework/jogl/swt/JoglSwtInitializerRunnable.java b/ardor3d-jogl-swt/src/main/java/com/ardor3d/framework/jogl/swt/JoglSwtInitializerRunnable.java new file mode 100644 index 0000000..c4268bc --- /dev/null +++ b/ardor3d-jogl-swt/src/main/java/com/ardor3d/framework/jogl/swt/JoglSwtInitializerRunnable.java @@ -0,0 +1,42 @@ +/** + * 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 . + */ + +package com.ardor3d.framework.jogl.swt; + +import com.ardor3d.framework.DisplaySettings; + +public class JoglSwtInitializerRunnable implements Runnable { + + private final JoglSwtCanvas _joglSwtCanvas; + + private final DisplaySettings _settings; + + public JoglSwtInitializerRunnable(final JoglSwtCanvas joglSwtCanvas, final DisplaySettings settings) { + _joglSwtCanvas = joglSwtCanvas; + _settings = settings; + } + + @Override + public void run() { + // Make the window visible to realize the OpenGL surface. + _joglSwtCanvas.setVisible(true); + // Force the realization + _joglSwtCanvas.display(); + if (_joglSwtCanvas.getDelegatedDrawable().isRealized()) { + // Request the focus here as it cannot work when the window is not visible + _joglSwtCanvas.setFocus(); + // The OpenGL context has been created after the realization of the surface + _joglSwtCanvas.getCanvasRenderer().setContext(_joglSwtCanvas.getContext()); + // As the canvas renderer knows the OpenGL context, it can be initialized + _joglSwtCanvas.getCanvasRenderer().init(_settings, true); + } + } + +} -- cgit v1.2.3