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 | |
parent | b476eeed7ebee18a310ba02b3a740fe34b87cec2 (diff) | |
parent | 3725d8321774e80b84f302eb16089dde387822e1 (diff) |
Merges several Renanse's commits
Diffstat (limited to 'ardor3d-jogl')
5 files changed, 60 insertions, 28 deletions
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 e72f593..148db60 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 @@ -19,6 +19,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.nativewindow.ScalableSurface; import com.jogamp.nativewindow.util.Dimension; import com.jogamp.nativewindow.util.DimensionImmutable; @@ -105,7 +106,7 @@ public class JoglNewtWindow implements NativeCanvas, NewtWindowContainer { /** * Applies all settings not related to OpenGL (screen resolution, screen size, etc...) - * */ + */ protected void applySettings() { _newtWindow.setUndecorated(_settings.isFullScreen()); if (_settings.isFullScreen()) { @@ -374,6 +375,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/input/jogl/JoglNewtMouseManager.java b/ardor3d-jogl/src/main/java/com/ardor3d/input/jogl/JoglNewtMouseManager.java index 72c31d5..6327bde 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 @@ -44,6 +44,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-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglContextCapabilities.java b/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglContextCapabilities.java index 2459c9b..285626a 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 @@ -135,6 +135,16 @@ 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. + final IntBuffer twoIntBuf = directNioBuffersSet.getDualIntBuffer(); + gl.glGetIntegerv(GL.GL_MAX_VIEWPORT_DIMS, twoIntBuf); + _maxViewportWidth = twoIntBuf.get(0); + _maxViewportHeight = twoIntBuf.get(1); + // Check for support of multitextures. _supportsMultiTexture = gl.isExtensionAvailable("GL_ARB_multitexture"); 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 70dfe2d..fa6c954 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 @@ -828,16 +828,15 @@ public class JoglRenderer extends AbstractRenderer { final TextureState ts = (TextureState) context.getCurrentState(RenderState.StateType.Texture); int enabledTextures = rendRecord.getEnabledTextures(); final boolean valid = rendRecord.isTexturesValid(); - boolean isOn, wasOn; + boolean wasOn; if (ts != null) { final int max = caps.isMultitextureSupported() ? Math.min(caps.getNumberOfFragmentTexCoordUnits(), TextureState.MAX_TEXTURES) : 1; for (int i = 0; i < max; i++) { wasOn = (enabledTextures & (2 << i)) != 0; - isOn = textureCoords != null && i < textureCoords.size() && textureCoords.get(i) != null - && textureCoords.get(i).getBuffer() != null; - if (!isOn) { + if (textureCoords == null || i >= textureCoords.size() || textureCoords.get(i) == null + || textureCoords.get(i).getBuffer() == null) { if (valid && !wasOn) { continue; } else { @@ -866,7 +865,6 @@ public class JoglRenderer extends AbstractRenderer { enabledTextures |= (2 << i); } - @SuppressWarnings("null") final FloatBufferData textureBufferData = textureCoords.get(i); final FloatBuffer textureBuffer = textureBufferData.getBuffer(); @@ -1146,15 +1144,14 @@ public class JoglRenderer extends AbstractRenderer { final TextureState ts = (TextureState) context.getCurrentState(RenderState.StateType.Texture); int enabledTextures = rendRecord.getEnabledTextures(); final boolean valid = rendRecord.isTexturesValid(); - boolean exists, wasOn; + boolean wasOn; if (ts != null) { final int max = caps.isMultitextureSupported() ? Math.min(caps.getNumberOfFragmentTexCoordUnits(), TextureState.MAX_TEXTURES) : 1; for (int i = 0; i < max; i++) { wasOn = (enabledTextures & (2 << i)) != 0; - exists = textureCoords != null && i < textureCoords.size(); - if (!exists) { + if (textureCoords == null || i >= textureCoords.size()) { if (valid && !wasOn) { continue; } else { @@ -1174,7 +1171,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); @@ -1352,7 +1348,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<FloatBufferData> textureCoords, final int bufferSize) { @@ -1397,12 +1392,14 @@ public class JoglRenderer extends AbstractRenderer { } final FloatBufferData textureBufferData = textureCoords.get(i); - final FloatBuffer textureBuffer = textureBufferData != null ? textureBufferData.getBuffer() : null; - if (textureBuffer != null) { - textureBuffer.rewind(); - gl.glBufferSubData(GL.GL_ARRAY_BUFFER, offset, textureBufferData.getBufferLimit() * 4, - textureBuffer); - offset += textureBufferData.getBufferLimit() * 4; + if (textureBufferData != null) { + final FloatBuffer textureBuffer = textureBufferData.getBuffer(); + if (textureBuffer != null) { + textureBuffer.rewind(); + gl.glBufferSubData(GL.GL_ARRAY_BUFFER, offset, textureBufferData.getBufferLimit() * 4, + textureBuffer); + offset += textureBufferData.getBufferLimit() * 4; + } } } } diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/util/geom/jogl/DirectNioBuffersSet.java b/ardor3d-jogl/src/main/java/com/ardor3d/util/geom/jogl/DirectNioBuffersSet.java index dd61350..84af8a7 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/util/geom/jogl/DirectNioBuffersSet.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/util/geom/jogl/DirectNioBuffersSet.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>. */ @@ -43,6 +43,8 @@ public final class DirectNioBuffersSet { private final IntBuffer singleIntBuffer; + private final IntBuffer dualIntBuffer; + private final FloatBuffer singleFloatBuffer; private final FloatBuffer transformBuffer; @@ -59,22 +61,24 @@ public final class DirectNioBuffersSet { slicedByteBuffer = BufferUtils.createByteBuffer(slicedByteBufferMaxSize); slicedByteBuffer.position(0).limit(slicedByteBuffer.position() + Buffers.SIZEOF_INT); singleIntBuffer = slicedByteBuffer.slice().order(ByteOrder.nativeOrder()).asIntBuffer(); + slicedByteBuffer.position(slicedByteBuffer.limit()).limit(slicedByteBuffer.position() + Buffers.SIZEOF_INT * 2); + dualIntBuffer = slicedByteBuffer.slice().order(ByteOrder.nativeOrder()).asIntBuffer(); slicedByteBuffer.position(slicedByteBuffer.limit()).limit(slicedByteBuffer.position() + Buffers.SIZEOF_FLOAT); singleFloatBuffer = slicedByteBuffer.slice().order(ByteOrder.nativeOrder()).asFloatBuffer(); - slicedByteBuffer.position(slicedByteBuffer.limit()).limit( - slicedByteBuffer.position() + (Buffers.SIZEOF_FLOAT * transformBufferMaxSize)); + slicedByteBuffer.position(slicedByteBuffer.limit()) + .limit(slicedByteBuffer.position() + (Buffers.SIZEOF_FLOAT * transformBufferMaxSize)); transformBuffer = slicedByteBuffer.slice().order(ByteOrder.nativeOrder()).asFloatBuffer(); - slicedByteBuffer.position(slicedByteBuffer.limit()).limit( - slicedByteBuffer.position() + (Buffers.SIZEOF_INT * fboColorAttachmentBufferMaxSize)); + slicedByteBuffer.position(slicedByteBuffer.limit()) + .limit(slicedByteBuffer.position() + (Buffers.SIZEOF_INT * fboColorAttachmentBufferMaxSize)); fboColorAttachmentBuffer = slicedByteBuffer.slice().order(ByteOrder.nativeOrder()).asIntBuffer(); - slicedByteBuffer.position(slicedByteBuffer.limit()).limit( - slicedByteBuffer.position() + (Buffers.SIZEOF_BYTE * infoLogBufferMaxSize)); + slicedByteBuffer.position(slicedByteBuffer.limit()) + .limit(slicedByteBuffer.position() + (Buffers.SIZEOF_BYTE * infoLogBufferMaxSize)); infoLogBuffer = slicedByteBuffer.slice().order(ByteOrder.nativeOrder()); - slicedByteBuffer.position(slicedByteBuffer.limit()).limit( - slicedByteBuffer.position() + (Buffers.SIZEOF_INT * textureIdsBufferMaxSize)); + slicedByteBuffer.position(slicedByteBuffer.limit()) + .limit(slicedByteBuffer.position() + (Buffers.SIZEOF_INT * textureIdsBufferMaxSize)); textureIdsBuffer = slicedByteBuffer.slice().order(ByteOrder.nativeOrder()).asIntBuffer(); - slicedByteBuffer.position(slicedByteBuffer.limit()).limit( - slicedByteBuffer.position() + (Buffers.SIZEOF_INT * vboIdsBufferMaxSize)); + slicedByteBuffer.position(slicedByteBuffer.limit()) + .limit(slicedByteBuffer.position() + (Buffers.SIZEOF_INT * vboIdsBufferMaxSize)); vboIdsBuffer = slicedByteBuffer.slice().order(ByteOrder.nativeOrder()).asIntBuffer(); slicedByteBuffer.clear(); } @@ -83,6 +87,10 @@ public final class DirectNioBuffersSet { return singleIntBuffer; } + public IntBuffer getDualIntBuffer() { + return dualIntBuffer; + } + public FloatBuffer getSingleFloatBuffer() { return singleFloatBuffer; } |