From 496263aac829dd0837ba65997b41ef2851022b3c Mon Sep 17 00:00:00 2001 From: Joshua Slack Date: Fri, 29 Sep 2017 17:25:24 -0500 Subject: Added centerOn method to UIComponent to make it simpler to center a component on another component or the hud. Fixed issue in sliders when min value is not 0. Clean up warnings. --- .../src/main/java/com/ardor3d/renderer/jogl/JoglRenderer.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'ardor3d-jogl/src/main/java') diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglRenderer.java b/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglRenderer.java index 1e15e65..cf0ffc5 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglRenderer.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglRenderer.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 . */ @@ -109,7 +109,7 @@ import com.jogamp.opengl.util.GLBuffers; /** * JoglRenderer provides an implementation of the Renderer interface using the JOGL API. - * + * * @see com.ardor3d.renderer.Renderer */ public class JoglRenderer extends AbstractRenderer { @@ -856,7 +856,6 @@ public class JoglRenderer extends AbstractRenderer { enabledTextures |= (2 << i); } - @SuppressWarnings("null") final FloatBufferData textureBufferData = textureCoords.get(i); final FloatBuffer textureBuffer = textureBufferData.getBuffer(); @@ -1160,7 +1159,6 @@ public class JoglRenderer extends AbstractRenderer { checkAndSetTextureArrayUnit(i, gl, rendRecord, caps); // grab a vboID and make sure it exists and is up to date. - @SuppressWarnings("null") final FloatBufferData data = textureCoords.get(i); final int vboID = setupVBO(data, context); @@ -1338,7 +1336,6 @@ public class JoglRenderer extends AbstractRenderer { } } - @SuppressWarnings("null") private void initializeInterleavedVBO(final RenderContext context, final FloatBufferData interleaved, final FloatBufferData vertexCoords, final FloatBufferData normalCoords, final FloatBufferData colorCoords, final List textureCoords, final int bufferSize) { @@ -1879,7 +1876,7 @@ public class JoglRenderer extends AbstractRenderer { /** * Start a new display list. All further renderer commands that can be stored in a display list are part of this new * list until {@link #endDisplayList()} is called. - * + * * @return id of new display list */ @Override -- cgit v1.2.3 From ca262978b95add2dae3434c5760ba6f2f1039325 Mon Sep 17 00:00:00 2001 From: Joshua Slack Date: Mon, 16 Oct 2017 10:48:44 -0500 Subject: Added some additional caps detection + divorced UIContainer standin texture size from camera. This should help in serveral situations such as window size being tiny during init, or different contexts having different window sizes. --- .../com/ardor3d/renderer/ContextCapabilities.java | 73 ++++++++++++++++------ .../renderer/jogl/JoglContextCapabilities.java | 11 +++- .../renderer/lwjgl/LwjglContextCapabilities.java | 12 +++- .../java/com/ardor3d/extension/ui/UIContainer.java | 35 ++++++----- 4 files changed, 93 insertions(+), 38 deletions(-) (limited to 'ardor3d-jogl/src/main/java') diff --git a/ardor3d-core/src/main/java/com/ardor3d/renderer/ContextCapabilities.java b/ardor3d-core/src/main/java/com/ardor3d/renderer/ContextCapabilities.java index 9599e0e..dd28ee6 100644 --- a/ardor3d-core/src/main/java/com/ardor3d/renderer/ContextCapabilities.java +++ b/ardor3d-core/src/main/java/com/ardor3d/renderer/ContextCapabilities.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 . */ @@ -76,6 +76,15 @@ public class ContextCapabilities { /** The max side of a texture supported. */ protected int _maxTextureSize = -1; + /** The max width of a viewport supported. */ + protected int _maxViewportWidth = -1; + + /** The max height of a viewport supported. */ + protected int _maxViewportHeight = -1; + + /** The max height of a viewport supported. */ + protected int _maxRenderBufferSize = -1; + protected float _maxAnisotropic = -1.0f; /** True if multitexturing is supported. */ @@ -159,6 +168,9 @@ public class ContextCapabilities { _maxGLSLVertexAttribs = source._maxGLSLVertexAttribs; _maxTextureLodBias = source._maxTextureLodBias; _maxTextureSize = source._maxTextureSize; + _maxViewportWidth = source._maxViewportWidth; + _maxViewportHeight = source._maxViewportHeight; + _maxRenderBufferSize = source._maxRenderBufferSize; _maxUserClipPlanes = source._maxUserClipPlanes; _numAuxDrawBuffers = source._numAuxDrawBuffers; _numFixedTexUnits = source._numFixedTexUnits; @@ -391,7 +403,7 @@ public class ContextCapabilities { /** * getNumberOfAuxiliaryDrawBuffers returns the total number of available auxiliary draw buffers this * context supports. - * + * * @return the number of available auxiliary draw buffers supported by the context. */ public int getNumberOfAuxiliaryDrawBuffers() { @@ -400,7 +412,7 @@ public class ContextCapabilities { /** * getTotalNumberOfUnits returns the total number of texture units this context supports. - * + * * @return the total number of texture units supported by the context. */ public int getTotalNumberOfUnits() { @@ -410,7 +422,7 @@ public class ContextCapabilities { /** * getNumberOfFixedUnits returns the number of texture units this context supports, for use in the * fixed pipeline. - * + * * @return the number units. */ public int getNumberOfFixedTextureUnits() { @@ -420,7 +432,7 @@ public class ContextCapabilities { /** * getNumberOfVertexUnits returns the number of texture units available to a vertex shader that this * context supports. - * + * * @return the number of units. */ public int getNumberOfVertexUnits() { @@ -430,7 +442,7 @@ public class ContextCapabilities { /** * getNumberOfFragmentUnits returns the number of texture units available to a fragment shader that * this context supports. - * + * * @return the number of units. */ public int getNumberOfFragmentTextureUnits() { @@ -440,7 +452,7 @@ public class ContextCapabilities { /** * getNumberOfFragmentTexCoordUnits returns the number of texture coordinate sets available that this * context supports. - * + * * @return the number of units. */ public int getNumberOfFragmentTexCoordUnits() { @@ -454,9 +466,30 @@ public class ContextCapabilities { return _maxTextureSize; } + /** + * @return the max width of viewport that this context supports. + */ + public int getMaxViewportWidth() { + return _maxViewportWidth; + } + + /** + * @return the max height of viewport that this context supports. + */ + public int getMaxViewportHeight() { + return _maxViewportHeight; + } + + /** + * @return the max size (in terms of # pixels) of renderbuffer that this context supports. + */ + public int getMaxRenderBufferSize() { + return _maxRenderBufferSize; + } + /** * getNumberOfTotalUnits returns the number of texture units this context supports. - * + * * @return the number of units. */ public int getNumberOfTotalTextureUnits() { @@ -465,7 +498,7 @@ public class ContextCapabilities { /** * getMaxFBOColorAttachments returns the MAX_COLOR_ATTACHMENTS for FBOs that this context supports. - * + * * @return the number of buffers. */ public int getMaxFBOColorAttachments() { @@ -474,7 +507,7 @@ public class ContextCapabilities { /** * Returns the maximum anisotropic filter. - * + * * @return The maximum anisotropic filter. */ public float getMaxAnisotropic() { @@ -525,7 +558,7 @@ public class ContextCapabilities { /** * Returns if S3TC compression is available for textures. - * + * * @return true if S3TC is available. */ public boolean isS3TCSupported() { @@ -534,7 +567,7 @@ public class ContextCapabilities { /** * Returns if LATC compression is available for textures. - * + * * @return true if LATC is available. */ public boolean isLATCSupported() { @@ -543,7 +576,7 @@ public class ContextCapabilities { /** * Returns if generic (non-specific) compression is available for textures. - * + * * @return true if available. */ public boolean isGenericTCSupported() { @@ -552,7 +585,7 @@ public class ContextCapabilities { /** * Returns if Texture3D is available for textures. - * + * * @return true if Texture3D is available. */ public boolean isTexture3DSupported() { @@ -561,7 +594,7 @@ public class ContextCapabilities { /** * Returns if TextureCubeMap is available for textures. - * + * * @return true if TextureCubeMap is available. */ public boolean isTextureCubeMapSupported() { @@ -570,7 +603,7 @@ public class ContextCapabilities { /** * Returns if AutomaticMipmap generation is available for textures. - * + * * @return true if AutomaticMipmap generation is available. */ public boolean isAutomaticMipmapsSupported() { @@ -652,7 +685,7 @@ public class ContextCapabilities { /** * Returns the vendor of the graphics adapter - * + * * @return The vendor of the graphics adapter */ public String getDisplayVendor() { @@ -661,7 +694,7 @@ public class ContextCapabilities { /** * Returns renderer details of the adapter - * + * * @return The adapter details */ public String getDisplayRenderer() { @@ -670,7 +703,7 @@ public class ContextCapabilities { /** * Returns the version supported - * + * * @return The version supported */ public String getDisplayVersion() { @@ -679,7 +712,7 @@ public class ContextCapabilities { /** * Returns the supported shading language version. Needs OpenGL 2.0 support to query. - * + * * @return The shading language version supported */ public String getShadingLanguageVersion() { diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglContextCapabilities.java b/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglContextCapabilities.java index 5ee1cb8..1151533 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglContextCapabilities.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglContextCapabilities.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 . */ @@ -126,6 +126,15 @@ public class JoglContextCapabilities extends ContextCapabilities { gl.glGetIntegerv(GL.GL_MAX_TEXTURE_SIZE, buf); _maxTextureSize = buf.get(0); + // max texture size. + gl.glGetIntegerv(GL.GL_MAX_RENDERBUFFER_SIZE, buf); + _maxRenderBufferSize = buf.get(0); + + // max viewport size. + gl.glGetIntegerv(GL.GL_MAX_VIEWPORT_DIMS, buf); + _maxViewportWidth = buf.get(0); + _maxViewportHeight = buf.get(1); + // Check for support of multitextures. _supportsMultiTexture = gl.isExtensionAvailable("GL_ARB_multitexture"); diff --git a/ardor3d-lwjgl/src/main/java/com/ardor3d/renderer/lwjgl/LwjglContextCapabilities.java b/ardor3d-lwjgl/src/main/java/com/ardor3d/renderer/lwjgl/LwjglContextCapabilities.java index fcc3758..9b2c762 100644 --- a/ardor3d-lwjgl/src/main/java/com/ardor3d/renderer/lwjgl/LwjglContextCapabilities.java +++ b/ardor3d-lwjgl/src/main/java/com/ardor3d/renderer/lwjgl/LwjglContextCapabilities.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 . */ @@ -22,6 +22,7 @@ import org.lwjgl.opengl.EXTTextureFilterAnisotropic; import org.lwjgl.opengl.EXTTextureLODBias; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL20; +import org.lwjgl.opengl.GL30; import com.ardor3d.renderer.ContextCapabilities; import com.ardor3d.util.geom.BufferUtils; @@ -115,6 +116,15 @@ public class LwjglContextCapabilities extends ContextCapabilities { GL11.glGetInteger(GL11.GL_MAX_TEXTURE_SIZE, buf); _maxTextureSize = buf.get(0); + // max texture size. + GL11.glGetInteger(GL30.GL_MAX_RENDERBUFFER_SIZE, buf); + _maxRenderBufferSize = buf.get(0); + + // max viewport size. + GL11.glGetInteger(GL11.GL_MAX_VIEWPORT_DIMS, buf); + _maxViewportWidth = buf.get(0); + _maxViewportHeight = buf.get(1); + // Check for support of multitextures. _supportsMultiTexture = caps.GL_ARB_multitexture; diff --git a/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/UIContainer.java b/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/UIContainer.java index 5b597f0..1e2091b 100644 --- a/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/UIContainer.java +++ b/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/UIContainer.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 . */ @@ -17,11 +17,11 @@ import java.util.logging.Logger; import com.ardor3d.extension.ui.layout.RowLayout; import com.ardor3d.extension.ui.layout.UILayout; import com.ardor3d.extension.ui.util.UIQuad; -import com.ardor3d.image.Texture2D; -import com.ardor3d.image.TextureStoreFormat; import com.ardor3d.image.Texture.MagnificationFilter; import com.ardor3d.image.Texture.MinificationFilter; import com.ardor3d.image.Texture.WrapMode; +import com.ardor3d.image.Texture2D; +import com.ardor3d.image.TextureStoreFormat; import com.ardor3d.math.ColorRGBA; import com.ardor3d.math.Matrix3; import com.ardor3d.math.Rectangle2; @@ -33,10 +33,10 @@ import com.ardor3d.renderer.TextureRenderer; import com.ardor3d.renderer.TextureRendererFactory; import com.ardor3d.renderer.queue.RenderBucketType; import com.ardor3d.renderer.state.BlendState; -import com.ardor3d.renderer.state.TextureState; import com.ardor3d.renderer.state.BlendState.DestinationFunction; import com.ardor3d.renderer.state.BlendState.SourceFunction; import com.ardor3d.renderer.state.BlendState.TestFunction; +import com.ardor3d.renderer.state.TextureState; import com.ardor3d.scenegraph.Spatial; import com.ardor3d.scenegraph.hint.CullHint; import com.ardor3d.scenegraph.hint.LightCombineMode; @@ -49,6 +49,7 @@ import com.ardor3d.scenegraph.hint.TextureCombineMode; */ public abstract class UIContainer extends UIComponent { private static final Logger _logger = Logger.getLogger(UIContainer.class.getName()); + public static int STANDIN_TEXTURE_SIZE = 4096; /** Layout responsible for managing the size and position of this container's contents. */ private UILayout _layout = new RowLayout(true); @@ -87,7 +88,7 @@ public abstract class UIContainer extends UIComponent { /** * Checks to see if a given UIComponent is in this container. - * + * * @param component * the component to look for * @return true if the given component is in this container. @@ -98,7 +99,7 @@ public abstract class UIContainer extends UIComponent { /** * Checks to see if a given UIComponent is in this container or (if instructed) its subcontainers. - * + * * @param component * the component to look for * @param recurse @@ -121,7 +122,7 @@ public abstract class UIContainer extends UIComponent { /** * Add a component to this container. - * + * * @param component * the component to add */ @@ -137,7 +138,7 @@ public abstract class UIContainer extends UIComponent { /** * Remove a component from this container. - * + * * @param component * the component to remove */ @@ -152,7 +153,7 @@ public abstract class UIContainer extends UIComponent { /** * Removes all UI components from this container. If other types of Spatials are attached to this container, they * are ignored. - * + * * @param comp * the component to remove */ @@ -438,16 +439,18 @@ public abstract class UIContainer extends UIComponent { /** * Build our standin quad and (as necessary) a texture renderer. - * + * * @param renderer * the renderer to use if we need to generate a texture renderer */ private void buildStandin(final Renderer renderer) { // Check for and create a texture renderer if none exists yet. if (UIContainer._textureRenderer == null) { - final Camera cam = Camera.getCurrentCamera(); - UIContainer._textureRenderer = TextureRendererFactory.INSTANCE.createTextureRenderer(cam.getWidth(), cam - .getHeight(), renderer, ContextManager.getCurrentContext().getCapabilities()); + final int maxRBS = ContextManager.getCurrentContext().getCapabilities().getMaxRenderBufferSize(); + final int size = maxRBS > 0 ? Math.min(UIContainer.STANDIN_TEXTURE_SIZE, maxRBS) + : UIContainer.STANDIN_TEXTURE_SIZE; + UIContainer._textureRenderer = TextureRendererFactory.INSTANCE.createTextureRenderer(size, size, 8, 0, + renderer, ContextManager.getCurrentContext().getCapabilities()); if (UIContainer._textureRenderer != null) { UIContainer._textureRenderer.setBackgroundColor(new ColorRGBA(0f, 1f, 0f, 0f)); UIContainer._textureRenderer.setMultipleTargets(true); @@ -548,7 +551,7 @@ public abstract class UIContainer extends UIComponent { } /** - * + * * @param doClip * true (default) if we want this container to clip the drawing of its contents to the dimensions of its * content area. @@ -575,7 +578,7 @@ public abstract class UIContainer extends UIComponent { } /** - * + * * @return true if we should use a cached texture copy to draw this container. * @see #setUseStandin(boolean) */ @@ -592,7 +595,7 @@ public abstract class UIContainer extends UIComponent { /** * Set the minification filter for the standin. - * + * * @param filter */ public void setMinificationFilter(final MinificationFilter filter) { -- cgit v1.2.3 From 667f946d11b29f9d6618b46d7b821099f6a83b77 Mon Sep 17 00:00:00 2001 From: Joshua Slack Date: Wed, 18 Oct 2017 22:58:42 -0500 Subject: Fixed bug with caps in Jogl recently introduced. --- .../java/com/ardor3d/renderer/jogl/JoglContextCapabilities.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'ardor3d-jogl/src/main/java') diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglContextCapabilities.java b/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglContextCapabilities.java index 1151533..78d6023 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglContextCapabilities.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglContextCapabilities.java @@ -21,6 +21,7 @@ import javax.media.opengl.GL2ES3; import javax.media.opengl.GLAutoDrawable; import com.ardor3d.renderer.ContextCapabilities; +import com.ardor3d.util.geom.BufferUtils; import com.ardor3d.util.geom.jogl.DirectNioBuffersSet; public class JoglContextCapabilities extends ContextCapabilities { @@ -131,9 +132,10 @@ public class JoglContextCapabilities extends ContextCapabilities { _maxRenderBufferSize = buf.get(0); // max viewport size. - gl.glGetIntegerv(GL.GL_MAX_VIEWPORT_DIMS, buf); - _maxViewportWidth = buf.get(0); - _maxViewportHeight = buf.get(1); + final IntBuffer dimsBuf = BufferUtils.createIntBuffer(2); + gl.glGetIntegerv(GL.GL_MAX_VIEWPORT_DIMS, dimsBuf); + _maxViewportWidth = dimsBuf.get(0); + _maxViewportHeight = dimsBuf.get(1); // Check for support of multitextures. _supportsMultiTexture = gl.isExtensionAvailable("GL_ARB_multitexture"); -- cgit v1.2.3 From ec71ecdbbb1437dd57a0f47a1f70d36a25529038 Mon Sep 17 00:00:00 2001 From: Joshua Slack Date: Mon, 15 Jan 2018 12:05:59 -0600 Subject: Added new method to Canvas interface providing a way to store and retrieve the mouse manager for a given canvas. --- .../main/java/com/ardor3d/framework/Canvas.java | 16 ++++- .../main/java/com/ardor3d/example/ExampleBase.java | 72 +++++++++++----------- .../com/ardor3d/example/applet/JoglBaseApplet.java | 35 ++++++----- .../ardor3d/example/applet/LwjglBaseApplet.java | 36 ++++++----- .../example/canvas/JoglAwtDesktopExample.java | 3 +- .../com/ardor3d/example/canvas/JoglAwtExample.java | 3 +- .../ardor3d/example/canvas/JoglNewtAwtExample.java | 1 + .../ardor3d/example/canvas/JoglNewtSwtExample.java | 3 +- .../com/ardor3d/example/canvas/JoglSwtExample.java | 3 +- .../ardor3d/example/canvas/LwjglAwtExample.java | 3 +- .../ardor3d/example/canvas/LwjglSwtExample.java | 3 +- .../com/ardor3d/framework/jogl/JoglAwtCanvas.java | 17 ++++- .../com/ardor3d/framework/jogl/JoglCanvas.java | 13 ++++ .../ardor3d/framework/jogl/JoglNewtAwtCanvas.java | 13 ++++ .../ardor3d/framework/jogl/JoglNewtSwtCanvas.java | 15 ++++- .../com/ardor3d/framework/jogl/JoglNewtWindow.java | 13 ++++ .../com/ardor3d/framework/jogl/JoglSwtCanvas.java | 15 ++++- .../ardor3d/framework/lwjgl/LwjglAwtCanvas.java | 20 +++++- .../com/ardor3d/framework/lwjgl/LwjglCanvas.java | 13 ++++ .../framework/lwjgl/LwjglDisplayCanvas.java | 15 ++++- .../java/com/ardor3d/framework/swt/SwtCanvas.java | 21 +++++-- 21 files changed, 245 insertions(+), 88 deletions(-) (limited to 'ardor3d-jogl/src/main/java') diff --git a/ardor3d-core/src/main/java/com/ardor3d/framework/Canvas.java b/ardor3d-core/src/main/java/com/ardor3d/framework/Canvas.java index 444a3ce..2658c86 100644 --- a/ardor3d-core/src/main/java/com/ardor3d/framework/Canvas.java +++ b/ardor3d-core/src/main/java/com/ardor3d/framework/Canvas.java @@ -13,6 +13,7 @@ package com.ardor3d.framework; import java.util.concurrent.CountDownLatch; import com.ardor3d.annotation.MainThread; +import com.ardor3d.input.MouseManager; /** * This interface defines the View, and should maybe be called the ViewUpdater. It owns the rendering phase, and @@ -29,7 +30,7 @@ public interface Canvas { /** * Ask the canvas to render itself. Note that this may occur in another thread and therefore a latch is given so the * caller may know when the draw has completed. - * + * * @param latch * a counter that should be decremented once drawing has completed. */ @@ -40,4 +41,17 @@ public interface Canvas { * @return the CanvasRenderer associated with this Canvas. */ CanvasRenderer getCanvasRenderer(); + + /** + * @return the MouseManager associated with this Canvas, if any + */ + MouseManager getMouseManager(); + + /** + * Sets a MouseManager to be associated with this Canvas. + * + * @param manager + * the manager to associate + */ + void setMouseManager(MouseManager manager); } diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/ExampleBase.java b/ardor3d-examples/src/main/java/com/ardor3d/example/ExampleBase.java index 4f24172..97912de 100644 --- a/ardor3d-examples/src/main/java/com/ardor3d/example/ExampleBase.java +++ b/ardor3d-examples/src/main/java/com/ardor3d/example/ExampleBase.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 . */ @@ -239,7 +239,7 @@ public abstract class ExampleBase implements Runnable, Updater, Scene { // Execute updateQueue item GameTaskQueueManager.getManager(_canvas.getCanvasRenderer().getRenderContext()).getQueue(GameTaskQueue.UPDATE) - .execute(); + .execute(); /** Call simpleUpdate in any derived classes of ExampleBase. */ updateExample(timer); @@ -263,7 +263,7 @@ public abstract class ExampleBase implements Runnable, Updater, Scene { public boolean renderUnto(final Renderer renderer) { // Execute renderQueue item GameTaskQueueManager.getManager(_canvas.getCanvasRenderer().getRenderContext()).getQueue(GameTaskQueue.RENDER) - .execute(renderer); + .execute(renderer); // Clean up card garbage such as textures, vbos, etc. ContextGarbageCollector.doRuntimeCleanup(renderer); @@ -347,14 +347,14 @@ public abstract class ExampleBase implements Runnable, Updater, Scene { prefs.getFrequency(), // alpha _minAlphaBits != -1 ? _minAlphaBits : prefs.getAlphaBits(), - // depth - _minDepthBits != -1 ? _minDepthBits : prefs.getDepthBits(), - // stencil - _minStencilBits != -1 ? _minStencilBits : prefs.getStencilBits(), - // samples - prefs.getSamples(), - // other - prefs.isFullscreen(), _stereo); + // depth + _minDepthBits != -1 ? _minDepthBits : prefs.getDepthBits(), + // stencil + _minStencilBits != -1 ? _minStencilBits : prefs.getStencilBits(), + // samples + prefs.getSamples(), + // other + prefs.isFullscreen(), _stereo); example._settings = settings; @@ -363,18 +363,20 @@ public abstract class ExampleBase implements Runnable, Updater, Scene { try { SharedLibraryLoader.load(true); } catch (Exception e) {e.printStackTrace();} - + final LwjglCanvasRenderer canvasRenderer = new LwjglCanvasRenderer(example); example._canvas = new LwjglCanvas(settings, canvasRenderer); example._physicalLayer = new PhysicalLayer(new LwjglKeyboardWrapper(), new LwjglMouseWrapper(), new LwjglControllerWrapper(), (LwjglCanvas) example._canvas); example._mouseManager = new LwjglMouseManager(); + example._canvas.setMouseManager(example._mouseManager); TextureRendererFactory.INSTANCE.setProvider(new LwjglTextureRendererProvider()); } else if (prefs.getRenderer().startsWith("JOGL")) { final JoglCanvasRenderer canvasRenderer = new JoglCanvasRenderer(example); example._canvas = new JoglNewtWindow(canvasRenderer, settings); final JoglNewtWindow canvas = (JoglNewtWindow) example._canvas; example._mouseManager = new JoglNewtMouseManager(canvas); + example._canvas.setMouseManager(example._mouseManager); example._physicalLayer = new PhysicalLayer(new JoglNewtKeyboardWrapper(canvas), new JoglNewtMouseWrapper( canvas, example._mouseManager), DummyControllerWrapper.INSTANCE, new JoglNewtFocusWrapper(canvas)); TextureRendererFactory.INSTANCE.setProvider(new JoglTextureRendererProvider()); @@ -460,17 +462,17 @@ public abstract class ExampleBase implements Runnable, Updater, Scene { _logicalLayer.registerTrigger(new InputTrigger(new MouseButtonClickedCondition(MouseButton.RIGHT), new TriggerAction() { - public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { - - final Vector2 pos = Vector2.fetchTempInstance().set( - inputStates.getCurrent().getMouseState().getX(), - inputStates.getCurrent().getMouseState().getY()); - final Ray3 pickRay = new Ray3(); - _canvas.getCanvasRenderer().getCamera().getPickRay(pos, false, pickRay); - Vector2.releaseTempInstance(pos); - doPick(pickRay); - } - }, "pickTrigger")); + public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { + + final Vector2 pos = Vector2.fetchTempInstance().set( + inputStates.getCurrent().getMouseState().getX(), + inputStates.getCurrent().getMouseState().getY()); + final Ray3 pickRay = new Ray3(); + _canvas.getCanvasRenderer().getCamera().getPickRay(pos, false, pickRay); + Vector2.releaseTempInstance(pos); + doPick(pickRay); + } + }, "pickTrigger")); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.ESCAPE), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputState, final double tpf) { @@ -535,20 +537,20 @@ public abstract class ExampleBase implements Runnable, Updater, Scene { _logicalLayer.registerTrigger(new InputTrigger(new MouseButtonPressedCondition(MouseButton.LEFT), new TriggerAction() { - public void perform(final Canvas source, final TwoInputStates inputState, final double tpf) { - if (_mouseManager.isSetGrabbedSupported()) { - _mouseManager.setGrabbed(GrabbedState.GRABBED); - } - } - })); + public void perform(final Canvas source, final TwoInputStates inputState, final double tpf) { + if (_mouseManager.isSetGrabbedSupported()) { + _mouseManager.setGrabbed(GrabbedState.GRABBED); + } + } + })); _logicalLayer.registerTrigger(new InputTrigger(new MouseButtonReleasedCondition(MouseButton.LEFT), new TriggerAction() { - public void perform(final Canvas source, final TwoInputStates inputState, final double tpf) { - if (_mouseManager.isSetGrabbedSupported()) { - _mouseManager.setGrabbed(GrabbedState.NOT_GRABBED); - } - } - })); + public void perform(final Canvas source, final TwoInputStates inputState, final double tpf) { + if (_mouseManager.isSetGrabbedSupported()) { + _mouseManager.setGrabbed(GrabbedState.NOT_GRABBED); + } + } + })); _logicalLayer.registerTrigger(new InputTrigger(new AnyKeyCondition(), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputState, final double tpf) { diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/applet/JoglBaseApplet.java b/ardor3d-examples/src/main/java/com/ardor3d/example/applet/JoglBaseApplet.java index 0c3f726..7952c5f 100644 --- a/ardor3d-examples/src/main/java/com/ardor3d/example/applet/JoglBaseApplet.java +++ b/ardor3d-examples/src/main/java/com/ardor3d/example/applet/JoglBaseApplet.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 . */ @@ -197,7 +197,7 @@ public abstract class JoglBaseApplet extends Applet implements Scene { // Execute updateQueue item GameTaskQueueManager.getManager(_glCanvas.getCanvasRenderer().getRenderContext()) - .getQueue(GameTaskQueue.UPDATE).execute(); + .getQueue(GameTaskQueue.UPDATE).execute(); updateAppletScene(_timer); // Update controllers/render states/transforms/bounds for rootNode. @@ -213,6 +213,7 @@ public abstract class JoglBaseApplet extends Applet implements Scene { protected void initInput() { _mouseManager = new JoglNewtMouseManager(_glCanvas); + _glCanvas.setMouseManager(_mouseManager); _logicalLayer = new LogicalLayer(); _physicalLayer = new PhysicalLayer(new JoglNewtKeyboardWrapper(_glCanvas), new JoglNewtMouseWrapper(_glCanvas, _mouseManager), new JoglNewtFocusWrapper(_glCanvas)); @@ -258,23 +259,23 @@ public abstract class JoglBaseApplet extends Applet implements Scene { _logicalLayer.registerTrigger(new InputTrigger(new MouseButtonPressedCondition(MouseButton.LEFT), new TriggerAction() { - public void perform(final com.ardor3d.framework.Canvas source, final TwoInputStates inputState, - final double tpf) { - if (_mouseManager.isSetGrabbedSupported()) { - _mouseManager.setGrabbed(GrabbedState.GRABBED); - } - } - })); + public void perform(final com.ardor3d.framework.Canvas source, final TwoInputStates inputState, + final double tpf) { + if (_mouseManager.isSetGrabbedSupported()) { + _mouseManager.setGrabbed(GrabbedState.GRABBED); + } + } + })); _logicalLayer.registerTrigger(new InputTrigger(new MouseButtonReleasedCondition(MouseButton.LEFT), new TriggerAction() { - public void perform(final com.ardor3d.framework.Canvas source, final TwoInputStates inputState, - final double tpf) { - if (_mouseManager.isSetGrabbedSupported()) { - _mouseManager.setGrabbed(GrabbedState.NOT_GRABBED); - } - } - })); + public void perform(final com.ardor3d.framework.Canvas source, final TwoInputStates inputState, + final double tpf) { + if (_mouseManager.isSetGrabbedSupported()) { + _mouseManager.setGrabbed(GrabbedState.NOT_GRABBED); + } + } + })); } protected void initBaseScene() { @@ -305,7 +306,7 @@ public abstract class JoglBaseApplet extends Applet implements Scene { public boolean renderUnto(final Renderer renderer) { // Execute renderQueue item GameTaskQueueManager.getManager(_glCanvas.getCanvasRenderer().getRenderContext()) - .getQueue(GameTaskQueue.RENDER).execute(renderer); + .getQueue(GameTaskQueue.RENDER).execute(renderer); // Clean up card garbage such as textures, vbos, etc. ContextGarbageCollector.doRuntimeCleanup(renderer); diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/applet/LwjglBaseApplet.java b/ardor3d-examples/src/main/java/com/ardor3d/example/applet/LwjglBaseApplet.java index ab1d9f9..99eb59f 100644 --- a/ardor3d-examples/src/main/java/com/ardor3d/example/applet/LwjglBaseApplet.java +++ b/ardor3d-examples/src/main/java/com/ardor3d/example/applet/LwjglBaseApplet.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 . */ @@ -191,7 +191,7 @@ public abstract class LwjglBaseApplet extends Applet implements Scene { // Execute updateQueue item GameTaskQueueManager.getManager(_glCanvas.getCanvasRenderer().getRenderContext()) - .getQueue(GameTaskQueue.UPDATE).execute(); + .getQueue(GameTaskQueue.UPDATE).execute(); updateAppletScene(_timer); @@ -218,6 +218,8 @@ public abstract class LwjglBaseApplet extends Applet implements Scene { protected void initInput() { _mouseManager = new LwjglMouseManager(); + _glCanvas.setMouseManager(_mouseManager); + _logicalLayer = new LogicalLayer(); _physicalLayer = new PhysicalLayer(new LwjglKeyboardWrapper(), new LwjglMouseWrapper(), new LwjglControllerWrapper(), _glCanvas); @@ -265,23 +267,23 @@ public abstract class LwjglBaseApplet extends Applet implements Scene { _logicalLayer.registerTrigger(new InputTrigger(new MouseButtonPressedCondition(MouseButton.LEFT), new TriggerAction() { - public void perform(final com.ardor3d.framework.Canvas source, final TwoInputStates inputState, - final double tpf) { - if (_mouseManager.isSetGrabbedSupported()) { - _mouseManager.setGrabbed(GrabbedState.GRABBED); - } - } - })); + public void perform(final com.ardor3d.framework.Canvas source, final TwoInputStates inputState, + final double tpf) { + if (_mouseManager.isSetGrabbedSupported()) { + _mouseManager.setGrabbed(GrabbedState.GRABBED); + } + } + })); _logicalLayer.registerTrigger(new InputTrigger(new MouseButtonReleasedCondition(MouseButton.LEFT), new TriggerAction() { - public void perform(final com.ardor3d.framework.Canvas source, final TwoInputStates inputState, - final double tpf) { - if (_mouseManager.isSetGrabbedSupported()) { - _mouseManager.setGrabbed(GrabbedState.NOT_GRABBED); - } - } - })); + public void perform(final com.ardor3d.framework.Canvas source, final TwoInputStates inputState, + final double tpf) { + if (_mouseManager.isSetGrabbedSupported()) { + _mouseManager.setGrabbed(GrabbedState.NOT_GRABBED); + } + } + })); } protected void initBaseScene() { @@ -312,7 +314,7 @@ public abstract class LwjglBaseApplet extends Applet implements Scene { public boolean renderUnto(final Renderer renderer) { // Execute renderQueue item GameTaskQueueManager.getManager(_glCanvas.getCanvasRenderer().getRenderContext()) - .getQueue(GameTaskQueue.RENDER).execute(renderer); + .getQueue(GameTaskQueue.RENDER).execute(renderer); // Clean up card garbage such as textures, vbos, etc. ContextGarbageCollector.doRuntimeCleanup(renderer); diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/JoglAwtDesktopExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/JoglAwtDesktopExample.java index 57128bf..b0044ed 100644 --- a/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/JoglAwtDesktopExample.java +++ b/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/JoglAwtDesktopExample.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 . */ @@ -152,6 +152,7 @@ public class JoglAwtDesktopExample { final AwtFocusWrapper focusWrapper = new AwtFocusWrapper(theCanvas); final AwtMouseManager mouseManager = new AwtMouseManager(theCanvas); final AwtMouseWrapper mouseWrapper = new AwtMouseWrapper(theCanvas, mouseManager); + theCanvas.setMouseManager(mouseManager); final ControllerWrapper controllerWrapper = new DummyControllerWrapper(); final PhysicalLayer pl = new PhysicalLayer(keyboardWrapper, mouseWrapper, controllerWrapper, focusWrapper); diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/JoglAwtExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/JoglAwtExample.java index 9b902f1..99dad6e 100644 --- a/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/JoglAwtExample.java +++ b/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/JoglAwtExample.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 . */ @@ -163,6 +163,7 @@ public class JoglAwtExample { final AwtFocusWrapper focusWrapper = new AwtFocusWrapper(theCanvas); final AwtMouseManager mouseManager = new AwtMouseManager(theCanvas); final AwtMouseWrapper mouseWrapper = new AwtMouseWrapper(theCanvas, mouseManager); + theCanvas.setMouseManager(mouseManager); final ControllerWrapper controllerWrapper = new DummyControllerWrapper(); final PhysicalLayer pl = new PhysicalLayer(keyboardWrapper, mouseWrapper, controllerWrapper, focusWrapper); diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/JoglNewtAwtExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/JoglNewtAwtExample.java index b3778f6..61de00d 100644 --- a/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/JoglNewtAwtExample.java +++ b/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/JoglNewtAwtExample.java @@ -165,6 +165,7 @@ public class JoglNewtAwtExample { final JoglNewtFocusWrapper focusWrapper = new JoglNewtFocusWrapper(theCanvas); final JoglNewtMouseManager mouseManager = new JoglNewtMouseManager(theCanvas); final JoglNewtMouseWrapper mouseWrapper = new JoglNewtMouseWrapper(theCanvas, mouseManager); + theCanvas.setMouseManager(mouseManager); final ControllerWrapper controllerWrapper = new DummyControllerWrapper(); final PhysicalLayer pl = new PhysicalLayer(keyboardWrapper, mouseWrapper, controllerWrapper, focusWrapper); diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/JoglNewtSwtExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/JoglNewtSwtExample.java index 59f54b6..c93fcad 100644 --- a/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/JoglNewtSwtExample.java +++ b/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/JoglNewtSwtExample.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 . */ @@ -204,6 +204,7 @@ public class JoglNewtSwtExample { final JoglNewtFocusWrapper focusWrapper = new JoglNewtFocusWrapper(canvas1); final JoglNewtMouseManager mouseManager = new JoglNewtMouseManager(canvas1); final JoglNewtMouseWrapper mouseWrapper = new JoglNewtMouseWrapper(canvas1, mouseManager); + canvas1.setMouseManager(mouseManager); final ControllerWrapper controllerWrapper = new DummyControllerWrapper(); final PhysicalLayer pl = new PhysicalLayer(keyboardWrapper, mouseWrapper, controllerWrapper, focusWrapper); diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/JoglSwtExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/JoglSwtExample.java index 3026828..8062a57 100644 --- a/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/JoglSwtExample.java +++ b/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/JoglSwtExample.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 . */ @@ -208,6 +208,7 @@ public class JoglSwtExample { final SwtMouseWrapper mouseWrapper = new SwtMouseWrapper(canvas1); final SwtFocusWrapper focusWrapper = new SwtFocusWrapper(canvas1); final SwtMouseManager mouseManager = new SwtMouseManager(canvas1); + canvas1.setMouseManager(mouseManager); final ControllerWrapper controllerWrapper = new DummyControllerWrapper(); final PhysicalLayer pl = new PhysicalLayer(keyboardWrapper, mouseWrapper, controllerWrapper, focusWrapper); diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/LwjglAwtExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/LwjglAwtExample.java index a45df8f..b12b3b4 100644 --- a/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/LwjglAwtExample.java +++ b/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/LwjglAwtExample.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 . */ @@ -163,6 +163,7 @@ public class LwjglAwtExample { final AwtFocusWrapper focusWrapper = new AwtFocusWrapper(theCanvas); final AwtMouseManager mouseManager = new AwtMouseManager(theCanvas); final AwtMouseWrapper mouseWrapper = new AwtMouseWrapper(theCanvas, mouseManager); + theCanvas.setMouseManager(mouseManager); final ControllerWrapper controllerWrapper = new DummyControllerWrapper(); final PhysicalLayer pl = new PhysicalLayer(keyboardWrapper, mouseWrapper, controllerWrapper, focusWrapper); diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/LwjglSwtExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/LwjglSwtExample.java index e564393..2d6fb5b 100644 --- a/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/LwjglSwtExample.java +++ b/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/LwjglSwtExample.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 . */ @@ -222,6 +222,7 @@ public class LwjglSwtExample { final SwtMouseWrapper mouseWrapper = new SwtMouseWrapper(canvas1); final SwtFocusWrapper focusWrapper = new SwtFocusWrapper(canvas1); final SwtMouseManager mouseManager = new SwtMouseManager(canvas1); + canvas1.setMouseManager(mouseManager); final ControllerWrapper controllerWrapper = new DummyControllerWrapper(); final PhysicalLayer pl = new PhysicalLayer(keyboardWrapper, mouseWrapper, controllerWrapper, focusWrapper); diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglAwtCanvas.java b/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglAwtCanvas.java index cc233c8..ef65a82 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglAwtCanvas.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglAwtCanvas.java @@ -21,14 +21,15 @@ import javax.swing.SwingUtilities; import com.ardor3d.annotation.MainThread; import com.ardor3d.framework.Canvas; import com.ardor3d.framework.DisplaySettings; +import com.ardor3d.input.MouseManager; /** * Ardor3D JOGL AWT heavyweight canvas, AWT component for the OpenGL rendering of Ardor3D with JOGL that supports the * AWT input system directly and its abstraction in Ardor3D (com.ardor3d.input.awt) - * + * * FIXME there is still a deadlock when using several instances of this class in the same container, see JOGL bug 572 * Rather use JoglNewtAwtCanvas in this case. - * + * */ public class JoglAwtCanvas extends GLCanvas implements Canvas { @@ -104,6 +105,18 @@ public class JoglAwtCanvas extends GLCanvas implements Canvas { 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 diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglCanvas.java b/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglCanvas.java index 9ca4c89..5bc1320 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglCanvas.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglCanvas.java @@ -35,6 +35,7 @@ import com.ardor3d.framework.CanvasRenderer; import com.ardor3d.framework.DisplaySettings; import com.ardor3d.framework.NativeCanvas; import com.ardor3d.image.Image; +import com.ardor3d.input.MouseManager; import com.ardor3d.renderer.jogl.JoglPbufferTextureRenderer; /** @@ -241,6 +242,18 @@ public class JoglCanvas extends Frame implements NativeCanvas { return _glCanvas.getCanvasRenderer(); } + protected MouseManager _manager; + + @Override + public MouseManager getMouseManager() { + return _manager; + } + + @Override + public void setMouseManager(final MouseManager manager) { + _manager = manager; + } + @Override public void close() { try { 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 b56e6c1..f1f8808 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 @@ -18,6 +18,7 @@ import javax.media.opengl.GLRunnable; import com.ardor3d.annotation.MainThread; import com.ardor3d.framework.Canvas; import com.ardor3d.framework.DisplaySettings; +import com.ardor3d.input.MouseManager; import com.jogamp.newt.awt.NewtCanvasAWT; import com.jogamp.newt.opengl.GLWindow; @@ -97,6 +98,18 @@ public class JoglNewtAwtCanvas extends NewtCanvasAWT implements Canvas, NewtWind 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(); diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglNewtSwtCanvas.java b/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglNewtSwtCanvas.java index 66436d3..09b4184 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglNewtSwtCanvas.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/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 . */ @@ -20,6 +20,7 @@ import org.eclipse.swt.widgets.Composite; import com.ardor3d.annotation.MainThread; import com.ardor3d.framework.Canvas; import com.ardor3d.framework.DisplaySettings; +import com.ardor3d.input.MouseManager; import com.jogamp.newt.opengl.GLWindow; import com.jogamp.newt.swt.NewtCanvasSWT; @@ -95,6 +96,18 @@ public class JoglNewtSwtCanvas extends NewtCanvasSWT implements Canvas, NewtWind 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(); 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 938a53e..901814c 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 @@ -22,6 +22,7 @@ import com.ardor3d.annotation.MainThread; import com.ardor3d.framework.DisplaySettings; import com.ardor3d.framework.NativeCanvas; import com.ardor3d.image.Image; +import com.ardor3d.input.MouseManager; import com.jogamp.newt.MonitorDevice; import com.jogamp.newt.MonitorMode; import com.jogamp.newt.event.KeyListener; @@ -215,6 +216,18 @@ public class JoglNewtWindow implements NativeCanvas, NewtWindowContainer { return _canvasRenderer; } + protected MouseManager _manager; + + @Override + public MouseManager getMouseManager() { + return _manager; + } + + @Override + public void setMouseManager(final MouseManager manager) { + _manager = manager; + } + @Override public void close() { _newtWindow.destroy(); diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglSwtCanvas.java b/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglSwtCanvas.java index a659d49..936beb4 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglSwtCanvas.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/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 . */ @@ -21,6 +21,7 @@ import org.eclipse.swt.widgets.Display; import com.ardor3d.annotation.MainThread; import com.ardor3d.framework.Canvas; import com.ardor3d.framework.DisplaySettings; +import com.ardor3d.input.MouseManager; import com.jogamp.opengl.swt.GLCanvas; /** @@ -92,6 +93,18 @@ public class JoglSwtCanvas extends GLCanvas implements Canvas { 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 diff --git a/ardor3d-lwjgl/src/main/java/com/ardor3d/framework/lwjgl/LwjglAwtCanvas.java b/ardor3d-lwjgl/src/main/java/com/ardor3d/framework/lwjgl/LwjglAwtCanvas.java index e3387f2..f7aeddb 100644 --- a/ardor3d-lwjgl/src/main/java/com/ardor3d/framework/lwjgl/LwjglAwtCanvas.java +++ b/ardor3d-lwjgl/src/main/java/com/ardor3d/framework/lwjgl/LwjglAwtCanvas.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 . */ @@ -19,6 +19,7 @@ import org.lwjgl.opengl.PixelFormat; import com.ardor3d.annotation.MainThread; import com.ardor3d.framework.Canvas; import com.ardor3d.framework.DisplaySettings; +import com.ardor3d.input.MouseManager; public class LwjglAwtCanvas extends AWTGLCanvas implements Canvas { @@ -35,8 +36,8 @@ public class LwjglAwtCanvas extends AWTGLCanvas implements Canvas { public LwjglAwtCanvas(final DisplaySettings settings, final LwjglCanvasRenderer canvasRenderer) throws LWJGLException { - super(new PixelFormat(settings.getColorDepth(), settings.getAlphaBits(), settings.getDepthBits(), settings - .getStencilBits(), settings.getSamples()).withStereo(settings.isStereo())); + super(new PixelFormat(settings.getColorDepth(), settings.getAlphaBits(), settings.getDepthBits(), + settings.getStencilBits(), settings.getSamples()).withStereo(settings.isStereo())); _settings = settings; _canvasRenderer = canvasRenderer; _canvasRenderer.setCanvasCallback(new LwjglCanvasCallback() { @@ -107,4 +108,17 @@ public class LwjglAwtCanvas extends AWTGLCanvas implements Canvas { public LwjglCanvasRenderer getCanvasRenderer() { return _canvasRenderer; } + + protected MouseManager _manager; + + @Override + public MouseManager getMouseManager() { + return _manager; + } + + @Override + public void setMouseManager(final MouseManager manager) { + _manager = manager; + } + } diff --git a/ardor3d-lwjgl/src/main/java/com/ardor3d/framework/lwjgl/LwjglCanvas.java b/ardor3d-lwjgl/src/main/java/com/ardor3d/framework/lwjgl/LwjglCanvas.java index 7fe8b9f..7e9c8f7 100644 --- a/ardor3d-lwjgl/src/main/java/com/ardor3d/framework/lwjgl/LwjglCanvas.java +++ b/ardor3d-lwjgl/src/main/java/com/ardor3d/framework/lwjgl/LwjglCanvas.java @@ -28,6 +28,7 @@ import com.ardor3d.image.Image; import com.ardor3d.image.ImageDataFormat; import com.ardor3d.image.PixelDataType; import com.ardor3d.input.FocusWrapper; +import com.ardor3d.input.MouseManager; import com.ardor3d.util.Ardor3dException; import com.ardor3d.util.geom.BufferUtils; @@ -151,6 +152,18 @@ public class LwjglCanvas implements NativeCanvas, FocusWrapper { return _canvasRenderer; } + protected MouseManager _manager; + + @Override + public MouseManager getMouseManager() { + return _manager; + } + + @Override + public void setMouseManager(final MouseManager manager) { + _manager = manager; + } + /** * @return a DisplayMode object that has the requested settings. If there is no mode that supports a * requested resolution, null is returned. diff --git a/ardor3d-lwjgl/src/main/java/com/ardor3d/framework/lwjgl/LwjglDisplayCanvas.java b/ardor3d-lwjgl/src/main/java/com/ardor3d/framework/lwjgl/LwjglDisplayCanvas.java index efacc46..c539c28 100644 --- a/ardor3d-lwjgl/src/main/java/com/ardor3d/framework/lwjgl/LwjglDisplayCanvas.java +++ b/ardor3d-lwjgl/src/main/java/com/ardor3d/framework/lwjgl/LwjglDisplayCanvas.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 . */ @@ -21,6 +21,7 @@ import org.lwjgl.opengl.PixelFormat; import com.ardor3d.framework.Canvas; import com.ardor3d.framework.DisplaySettings; import com.ardor3d.input.FocusWrapper; +import com.ardor3d.input.MouseManager; import com.ardor3d.util.Ardor3dException; /** @@ -123,6 +124,18 @@ public class LwjglDisplayCanvas implements Canvas, FocusWrapper { 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) { Display.setVSyncEnabled(enabled); } diff --git a/ardor3d-swt/src/main/java/com/ardor3d/framework/swt/SwtCanvas.java b/ardor3d-swt/src/main/java/com/ardor3d/framework/swt/SwtCanvas.java index 97aebf3..dfda434 100644 --- a/ardor3d-swt/src/main/java/com/ardor3d/framework/swt/SwtCanvas.java +++ b/ardor3d-swt/src/main/java/com/ardor3d/framework/swt/SwtCanvas.java @@ -21,6 +21,7 @@ import com.ardor3d.annotation.MainThread; import com.ardor3d.framework.Canvas; import com.ardor3d.framework.CanvasRenderer; import com.ardor3d.framework.DisplaySettings; +import com.ardor3d.input.MouseManager; /** * A canvas for embedding into SWT applications. @@ -55,10 +56,26 @@ public class SwtCanvas extends GLCanvas implements Canvas { return rVal; } + public CanvasRenderer getCanvasRenderer() { + return _canvasRenderer; + } + public void setCanvasRenderer(final CanvasRenderer renderer) { _canvasRenderer = renderer; } + protected MouseManager _manager; + + @Override + public MouseManager getMouseManager() { + return _manager; + } + + @Override + public void setMouseManager(final MouseManager manager) { + _manager = manager; + } + @MainThread private void privateInit() { // tell our parent to lay us out so we have the right starting size. @@ -97,8 +114,4 @@ public class SwtCanvas extends GLCanvas implements Canvas { latch.countDown(); } - - public CanvasRenderer getCanvasRenderer() { - return _canvasRenderer; - } } -- cgit v1.2.3 From 2817b5e3a39ca1c9fe42bdfe344db3400ff83264 Mon Sep 17 00:00:00 2001 From: Joshua Slack Date: Mon, 15 Jan 2018 12:06:45 -0600 Subject: Update to mouse manager allowing null to be passed to setCursor to signify clearing the cursor --- .../src/main/java/com/ardor3d/input/awt/AwtMouseManager.java | 2 +- .../src/main/java/com/ardor3d/input/jogl/JoglNewtMouseManager.java | 6 +++++- .../src/main/java/com/ardor3d/input/lwjgl/LwjglMouseManager.java | 2 +- .../src/main/java/com/ardor3d/input/swt/SwtMouseManager.java | 6 +++--- 4 files changed, 10 insertions(+), 6 deletions(-) (limited to 'ardor3d-jogl/src/main/java') diff --git a/ardor3d-awt/src/main/java/com/ardor3d/input/awt/AwtMouseManager.java b/ardor3d-awt/src/main/java/com/ardor3d/input/awt/AwtMouseManager.java index 194b729..9f5a816 100644 --- a/ardor3d-awt/src/main/java/com/ardor3d/input/awt/AwtMouseManager.java +++ b/ardor3d-awt/src/main/java/com/ardor3d/input/awt/AwtMouseManager.java @@ -62,7 +62,7 @@ public class AwtMouseManager implements MouseManager { } public void setCursor(final MouseCursor cursor) { - if (cursor == MouseCursor.SYSTEM_DEFAULT) { + if (cursor == MouseCursor.SYSTEM_DEFAULT || cursor == null) { if (_grabbedState == GrabbedState.GRABBED) { _pregrabCursor = Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR); } else { diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/input/jogl/JoglNewtMouseManager.java b/ardor3d-jogl/src/main/java/com/ardor3d/input/jogl/JoglNewtMouseManager.java index 10ca249..ae5692f 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/input/jogl/JoglNewtMouseManager.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/input/jogl/JoglNewtMouseManager.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 . */ @@ -45,6 +45,10 @@ public class JoglNewtMouseManager implements MouseManager { } private PointerIcon createJoglCursor(final MouseCursor cursor) { + if (cursor == MouseCursor.SYSTEM_DEFAULT || cursor == null) { + return null; // setting the cursor to null in JOGL means using the system default one + } + final Image image = cursor.getImage(); final DimensionImmutable size = new Dimension(image.getWidth(), image.getHeight()); final ByteBuffer pixels = image.getData(0); diff --git a/ardor3d-lwjgl/src/main/java/com/ardor3d/input/lwjgl/LwjglMouseManager.java b/ardor3d-lwjgl/src/main/java/com/ardor3d/input/lwjgl/LwjglMouseManager.java index b689841..0b2a64a 100644 --- a/ardor3d-lwjgl/src/main/java/com/ardor3d/input/lwjgl/LwjglMouseManager.java +++ b/ardor3d-lwjgl/src/main/java/com/ardor3d/input/lwjgl/LwjglMouseManager.java @@ -63,7 +63,7 @@ public class LwjglMouseManager implements MouseManager { } private Cursor createLwjglCursor(final MouseCursor cursor) throws LWJGLException { - if (cursor == MouseCursor.SYSTEM_DEFAULT) { + if (cursor == MouseCursor.SYSTEM_DEFAULT || cursor == null) { return null; // setting the cursor to null in LWJGL means using the system default one } diff --git a/ardor3d-swt/src/main/java/com/ardor3d/input/swt/SwtMouseManager.java b/ardor3d-swt/src/main/java/com/ardor3d/input/swt/SwtMouseManager.java index 8918263..012766d 100644 --- a/ardor3d-swt/src/main/java/com/ardor3d/input/swt/SwtMouseManager.java +++ b/ardor3d-swt/src/main/java/com/ardor3d/input/swt/SwtMouseManager.java @@ -49,15 +49,15 @@ public class SwtMouseManager implements MouseManager { } public void setCursor(final MouseCursor cursor) { - if (cursor == MouseCursor.SYSTEM_DEFAULT) { + if (cursor == MouseCursor.SYSTEM_DEFAULT || cursor == null) { _control.setCursor(null); return; } final ImageData imageData = SWTImageUtil.convertToSWT(cursor.getImage()).get(0); - final Cursor swtCursor = new Cursor(_control.getDisplay(), imageData, cursor.getHotspotX(), cursor - .getHotspotY()); + final Cursor swtCursor = new Cursor(_control.getDisplay(), imageData, cursor.getHotspotX(), + cursor.getHotspotY()); _control.setCursor(swtCursor); } -- cgit v1.2.3