From be692a2ceb183734653d6d5167f43562efbe871a Mon Sep 17 00:00:00 2001 From: Daniel Johansson Date: Wed, 15 Jul 2015 10:25:27 +0100 Subject: [PATCH 01/20] Reverted changes to build script regarding bullet libs. --- jme3-bullet-native-android/build.gradle | 2 +- jme3-jbullet/build.gradle | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/jme3-bullet-native-android/build.gradle b/jme3-bullet-native-android/build.gradle index a640fcf93..30fdd44b5 100644 --- a/jme3-bullet-native-android/build.gradle +++ b/jme3-bullet-native-android/build.gradle @@ -21,7 +21,6 @@ if (!hasProperty('mainClass')) { } dependencies { - compile project(':jme3-bullet-native') compile project(':jme3-bullet') } @@ -29,6 +28,7 @@ dependencies { sourceSets { main { java { + srcDir jmeCppPath srcDir jmeAndroidPath } } diff --git a/jme3-jbullet/build.gradle b/jme3-jbullet/build.gradle index 763a9e57b..0e3967ab2 100644 --- a/jme3-jbullet/build.gradle +++ b/jme3-jbullet/build.gradle @@ -6,6 +6,7 @@ sourceSets { main { java { srcDir 'src/main/java' + srcDir '../jme3-bullet/src/common/java' } } } @@ -15,5 +16,5 @@ dependencies { compile files('../lib/jbullet.jar', '../lib/stack-alloc.jar') compile project(':jme3-core') compile project(':jme3-terrain') - compile project(':jme3-bullet') +// compile project(':jme3-bullet') } From d319a7c5d31ffebcefc4aac7a52ac73665906049 Mon Sep 17 00:00:00 2001 From: Daniel Johansson Date: Mon, 20 Jul 2015 11:22:16 +0100 Subject: [PATCH 02/20] Added unit test for J3MLoader to cover the new texture parameters available in #295. Also fixed a couple of issues in the code to reduce logging that was not needed and removed redundant code. This update also updates junit to 4.12 and adds Mockito and Fest Assertions as test dependencies. --- common.gradle | 4 +- jme3-core/build.gradle | 5 + .../com/jme3/material/plugins/J3MLoader.java | 17 +-- .../jme3/material/plugins/J3MLoaderTest.java | 117 ++++++++++++++++++ .../resources/texture-parameters-newstyle.j3m | 11 ++ .../resources/texture-parameters-oldstyle.j3m | 6 + 6 files changed, 147 insertions(+), 13 deletions(-) create mode 100644 jme3-core/src/test/java/com/jme3/material/plugins/J3MLoaderTest.java create mode 100644 jme3-core/src/test/resources/texture-parameters-newstyle.j3m create mode 100644 jme3-core/src/test/resources/texture-parameters-oldstyle.j3m diff --git a/common.gradle b/common.gradle index 6af4c664f..43fcf481d 100644 --- a/common.gradle +++ b/common.gradle @@ -21,7 +21,9 @@ repositories { dependencies { // Adding dependencies here will add the dependencies to each subproject. - testCompile group: 'junit', name: 'junit', version: '4.10' + testCompile group: 'junit', name: 'junit', version: '4.12' + testCompile group: 'org.mockito', name: 'mockito-core', version: '2.0.28-beta' + testCompile group: 'org.easytesting', name: 'fest-assert-core', version: '2.0M10' } javadoc { diff --git a/jme3-core/build.gradle b/jme3-core/build.gradle index bd699f52a..87b52fb94 100644 --- a/jme3-core/build.gradle +++ b/jme3-core/build.gradle @@ -10,6 +10,11 @@ sourceSets { srcDir 'src/tools/java' } } + test { + java { + srcDir 'src/test/java' + } + } } buildscript { diff --git a/jme3-core/src/plugins/java/com/jme3/material/plugins/J3MLoader.java b/jme3-core/src/plugins/java/com/jme3/material/plugins/J3MLoader.java index 29829b099..13a8e0232 100644 --- a/jme3-core/src/plugins/java/com/jme3/material/plugins/J3MLoader.java +++ b/jme3-core/src/plugins/java/com/jme3/material/plugins/J3MLoader.java @@ -158,7 +158,7 @@ public class J3MLoader implements AssetLoader { final String value = values.get(i); final TextureOption textureOption = TextureOption.getTextureOption(value); - if (textureOption == null && !value.contains("\\") && !value.contains("/")) { + if (textureOption == null && !value.contains("\\") && !value.contains("/") && !values.get(0).equals("Flip") && !values.get(0).equals("Repeat")) { logger.log(Level.WARNING, "Unknown texture option \"{0}\" encountered for \"{1}\" in material \"{2}\"", new Object[]{value, key, material.getKey().getName()}); } else if (textureOption != null){ final String option = textureOption.getOptionValue(value); @@ -179,27 +179,25 @@ public class J3MLoader implements AssetLoader { final List textureOptionValues = parseTextureOptions(textureValues); TextureKey textureKey = null; - boolean repeat = false; // If there is only one token on the value, it must be the path to the texture. if (textureValues.size() == 1) { - textureKey = new TextureKey(textureValues.get(0)); + textureKey = new TextureKey(textureValues.get(0), false); } else { String texturePath = value.trim(); - boolean flipY = false; // If there are no valid "new" texture options specified but the path is split into several parts, lets parse the old way. if (isTexturePathDeclaredTheTraditionalWay(textureValues.size(), textureOptionValues.size(), texturePath)) { + boolean flipY = false; + if (texturePath.startsWith("Flip Repeat ") || texturePath.startsWith("Repeat Flip ")) { texturePath = texturePath.substring(12).trim(); flipY = true; - repeat = true; } else if (texturePath.startsWith("Flip ")) { texturePath = texturePath.substring(5).trim(); flipY = true; } else if (texturePath.startsWith("Repeat ")) { texturePath = texturePath.substring(7).trim(); - repeat = true; } // Support path starting with quotes (double and single) @@ -216,7 +214,7 @@ public class J3MLoader implements AssetLoader { } if (textureKey == null) { - textureKey = new TextureKey(textureValues.get(textureValues.size() - 1)); + textureKey = new TextureKey(textureValues.get(textureValues.size() - 1), false); } // Apply texture options to the texture key @@ -256,11 +254,6 @@ public class J3MLoader implements AssetLoader { texture.setName(textureKey.getName()); } - // This is here for backwards compatibility, we need to do this after the texture has been instantiated. - if (repeat) { - texture.setWrap(Texture.WrapMode.Repeat); - } - // Apply texture options to the texture if (!textureOptionValues.isEmpty()) { for (final TextureOptionValue textureOptionValue : textureOptionValues) { diff --git a/jme3-core/src/test/java/com/jme3/material/plugins/J3MLoaderTest.java b/jme3-core/src/test/java/com/jme3/material/plugins/J3MLoaderTest.java new file mode 100644 index 000000000..6438baaac --- /dev/null +++ b/jme3-core/src/test/java/com/jme3/material/plugins/J3MLoaderTest.java @@ -0,0 +1,117 @@ +package com.jme3.material.plugins; + +import com.jme3.asset.AssetInfo; +import com.jme3.asset.AssetKey; +import com.jme3.asset.AssetManager; +import com.jme3.asset.TextureKey; +import com.jme3.material.MatParamTexture; +import com.jme3.material.Material; +import com.jme3.material.MaterialDef; +import com.jme3.shader.VarType; +import com.jme3.texture.Texture; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.runners.MockitoJUnitRunner; + +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +/** + * @author Daniel Johansson + * @since 2015-07-20 + */ +@RunWith(MockitoJUnitRunner.class) +public class J3MLoaderTest { + + private J3MLoader j3MLoader; + + @Mock + private AssetInfo assetInfo; + + @Mock + private AssetManager assetManager; + + @Mock + private AssetKey assetKey; + + @Mock + private MaterialDef materialDef; + + @Before + public void setUp() throws Exception { + when(assetKey.getExtension()).thenReturn(".j3m"); + when(assetInfo.getManager()).thenReturn(assetManager); + when(assetInfo.getKey()).thenReturn(assetKey); + when(assetManager.loadAsset(any(AssetKey.class))).thenReturn(materialDef); + + j3MLoader = new J3MLoader(); + } + + @Test + public void oldStyleTextureParameters_shouldBeSupported() throws Exception { + when(assetInfo.openStream()).thenReturn(J3MLoader.class.getResourceAsStream("/texture-parameters-oldstyle.j3m")); + + final Texture textureOldStyle = Mockito.mock(Texture.class); + final Texture textureOldStyleUsingQuotes = Mockito.mock(Texture.class); + + final TextureKey textureKeyUsingQuotes = setupMockForTexture("OldStyleUsingQuotes", "old style using quotes/texture.png", true, textureOldStyleUsingQuotes); + final TextureKey textureKeyOldStyle = setupMockForTexture("OldStyle", "old style/texture.png", true, textureOldStyle); + + j3MLoader.load(assetInfo); + + verify(assetManager).loadTexture(textureKeyUsingQuotes); + verify(assetManager).loadTexture(textureKeyOldStyle); + verify(textureOldStyle).setWrap(Texture.WrapMode.Repeat); + verify(textureOldStyleUsingQuotes).setWrap(Texture.WrapMode.Repeat); + } + + @Test + public void newStyleTextureParameters_shouldBeSupported() throws Exception { + when(assetInfo.openStream()).thenReturn(J3MLoader.class.getResourceAsStream("/texture-parameters-newstyle.j3m")); + + final Texture textureNoParameters = Mockito.mock(Texture.class); + final Texture textureFlip = Mockito.mock(Texture.class); + final Texture textureRepeat = Mockito.mock(Texture.class); + final Texture textureRepeatAxis = Mockito.mock(Texture.class); + final Texture textureMin = Mockito.mock(Texture.class); + final Texture textureMag = Mockito.mock(Texture.class); + final Texture textureCombined = Mockito.mock(Texture.class); + + final TextureKey textureKeyNoParameters = setupMockForTexture("Empty", "empty.png", false, textureNoParameters); + final TextureKey textureKeyFlip = setupMockForTexture("Flip", "flip.png", true, textureFlip); + setupMockForTexture("Repeat", "repeat.png", false, textureRepeat); + setupMockForTexture("RepeatAxis", "repeat-axis.png", false, textureRepeatAxis); + setupMockForTexture("Min", "min.png", false, textureMin); + setupMockForTexture("Mag", "mag.png", false, textureMag); + setupMockForTexture("Combined", "combined.png", true, textureCombined); + + j3MLoader.load(assetInfo); + + verify(assetManager).loadTexture(textureKeyNoParameters); + verify(assetManager).loadTexture(textureKeyFlip); + + verify(textureRepeat).setWrap(Texture.WrapMode.Repeat); + verify(textureRepeatAxis).setWrap(Texture.WrapAxis.T, Texture.WrapMode.Repeat); + verify(textureMin).setMinFilter(Texture.MinFilter.Trilinear); + verify(textureMag).setMagFilter(Texture.MagFilter.Bilinear); + + verify(textureCombined).setMagFilter(Texture.MagFilter.Nearest); + verify(textureCombined).setMinFilter(Texture.MinFilter.BilinearNoMipMaps); + verify(textureCombined).setWrap(Texture.WrapMode.Repeat); + } + + private TextureKey setupMockForTexture(final String paramName, final String path, final boolean flipY, final Texture texture) { + when(materialDef.getMaterialParam(paramName)).thenReturn(new MatParamTexture(VarType.Texture2D, paramName, texture, 0, null)); + + final TextureKey textureKey = new TextureKey(path, flipY); + textureKey.setGenerateMips(true); + + when(assetManager.loadTexture(textureKey)).thenReturn(texture); + + return textureKey; + } +} diff --git a/jme3-core/src/test/resources/texture-parameters-newstyle.j3m b/jme3-core/src/test/resources/texture-parameters-newstyle.j3m new file mode 100644 index 000000000..a7619d948 --- /dev/null +++ b/jme3-core/src/test/resources/texture-parameters-newstyle.j3m @@ -0,0 +1,11 @@ +Material Test : matdef.j3md { + MaterialParameters { + Empty: "empty.png" + Flip: Flip "flip.png" + Repeat: WrapRepeat "repeat.png" + Min: MinTrilinear "min.png" + Mag: MagBilinear "mag.png" + RepeatAxis: WrapRepeat_T "repeat-axis.png" + Combined: MagNearest MinBilinearNoMipMaps Flip WrapRepeat "combined.png" + } +} \ No newline at end of file diff --git a/jme3-core/src/test/resources/texture-parameters-oldstyle.j3m b/jme3-core/src/test/resources/texture-parameters-oldstyle.j3m new file mode 100644 index 000000000..7f34af464 --- /dev/null +++ b/jme3-core/src/test/resources/texture-parameters-oldstyle.j3m @@ -0,0 +1,6 @@ +Material Test : matdef.j3md { + MaterialParameters { + OldStyle: Flip Repeat old style/texture.png + OldStyleUsingQuotes: Repeat Flip "old style using quotes/texture.png" + } +} \ No newline at end of file From df19c742486711cd34b849d0e29d3cbd913d5b99 Mon Sep 17 00:00:00 2001 From: Dokthar Date: Wed, 22 Jul 2015 22:36:05 +0200 Subject: [PATCH 03/20] SDK scenecomposer : changed the lineWidth of the axisMarker - lineWidth of the arrows is now set at 3f - the arrows of the axisMarker are now easier to select. --- .../src/com/jme3/gde/scenecomposer/SceneEditTool.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sdk/jme3-scenecomposer/src/com/jme3/gde/scenecomposer/SceneEditTool.java b/sdk/jme3-scenecomposer/src/com/jme3/gde/scenecomposer/SceneEditTool.java index 372984f8e..9c7ad75cb 100644 --- a/sdk/jme3-scenecomposer/src/com/jme3/gde/scenecomposer/SceneEditTool.java +++ b/sdk/jme3-scenecomposer/src/com/jme3/gde/scenecomposer/SceneEditTool.java @@ -453,6 +453,9 @@ public abstract class SceneEditTool { Geometry arrowX = new Geometry("arrowX", new Arrow(new Vector3f(arrowSize, 0, 0))); Geometry arrowY = new Geometry("arrowY", new Arrow(new Vector3f(0, arrowSize, 0))); Geometry arrowZ = new Geometry("arrowZ", new Arrow(new Vector3f(0, 0, arrowSize))); + arrowX.getMesh().setLineWidth(3f); + arrowY.getMesh().setLineWidth(3f); + arrowZ.getMesh().setLineWidth(3f); axis.attachChild(arrowX); axis.attachChild(arrowY); axis.attachChild(arrowZ); From 616dadc4981d739c121285df8426fc3863f622cc Mon Sep 17 00:00:00 2001 From: Kirill Vainer Date: Thu, 3 Sep 2015 09:46:34 -0400 Subject: [PATCH 04/20] Deprecate ColoredTextured.j3md --- .../main/resources/Common/MatDefs/Misc/ColoredTextured.j3md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/jme3-core/src/main/resources/Common/MatDefs/Misc/ColoredTextured.j3md b/jme3-core/src/main/resources/Common/MatDefs/Misc/ColoredTextured.j3md index 6b74c3074..497b7d0a7 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Misc/ColoredTextured.j3md +++ b/jme3-core/src/main/resources/Common/MatDefs/Misc/ColoredTextured.j3md @@ -1,3 +1,4 @@ +Exception This material definition is deprecated. Please use Unshaded.j3md instead. MaterialDef Colored Textured { MaterialParameters { @@ -17,4 +18,4 @@ MaterialDef Colored Textured { Technique { } -} \ No newline at end of file +} From 139ba573bc3bd8e1bd428e8c1baf3067850bab8c Mon Sep 17 00:00:00 2001 From: Kirill Vainer Date: Fri, 4 Sep 2015 10:35:14 -0400 Subject: [PATCH 05/20] travis-ci: try to fix incorrect .travis.yml file --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index fb7588262..eb7e58253 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,7 +25,7 @@ install: script: - ./gradlew check - ./gradlew createZipDistribution - - [ $TRAVIS_BRANCH == 'master' ] && [ $TRAVIS_PULL_REQUEST == 'false' ] && ./gradlew uploadArchives || : + - "[ $TRAVIS_BRANCH == 'master' ] && [ $TRAVIS_PULL_REQUEST == 'false' ] && ./gradlew uploadArchives || :" before_deploy: - export RELEASE_DIST=$(ls build/distributions/*.zip) From cb7d13948812d51ac0fdab95cebb086ca01e87bc Mon Sep 17 00:00:00 2001 From: Kirill Vainer Date: Sat, 5 Sep 2015 13:55:59 -0400 Subject: [PATCH 06/20] GLSLCompat: support GLES compatibility --- .../Common/MatDefs/Misc/Unshaded.frag | 2 +- .../Common/MatDefs/Misc/Unshaded.vert | 2 +- .../Common/ShaderLib/GLSL150Compat.glsllib | 14 -------- .../Common/ShaderLib/GLSLCompat.glsllib | 34 +++++++++++++++++++ 4 files changed, 36 insertions(+), 16 deletions(-) delete mode 100644 jme3-core/src/main/resources/Common/ShaderLib/GLSL150Compat.glsllib create mode 100644 jme3-core/src/main/resources/Common/ShaderLib/GLSLCompat.glsllib diff --git a/jme3-core/src/main/resources/Common/MatDefs/Misc/Unshaded.frag b/jme3-core/src/main/resources/Common/MatDefs/Misc/Unshaded.frag index 73df8d740..e615d8f1e 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Misc/Unshaded.frag +++ b/jme3-core/src/main/resources/Common/MatDefs/Misc/Unshaded.frag @@ -1,4 +1,4 @@ -#import "Common/ShaderLib/GLSL150Compat.glsllib" +#import "Common/ShaderLib/GLSLCompat.glsllib" #if defined(HAS_GLOWMAP) || defined(HAS_COLORMAP) || (defined(HAS_LIGHTMAP) && !defined(SEPARATE_TEXCOORD)) #define NEED_TEXCOORD1 diff --git a/jme3-core/src/main/resources/Common/MatDefs/Misc/Unshaded.vert b/jme3-core/src/main/resources/Common/MatDefs/Misc/Unshaded.vert index 454708d92..ba7899ca5 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Misc/Unshaded.vert +++ b/jme3-core/src/main/resources/Common/MatDefs/Misc/Unshaded.vert @@ -1,4 +1,4 @@ -#import "Common/ShaderLib/GLSL150Compat.glsllib" +#import "Common/ShaderLib/GLSLCompat.glsllib" #import "Common/ShaderLib/Skinning.glsllib" #import "Common/ShaderLib/Instancing.glsllib" diff --git a/jme3-core/src/main/resources/Common/ShaderLib/GLSL150Compat.glsllib b/jme3-core/src/main/resources/Common/ShaderLib/GLSL150Compat.glsllib deleted file mode 100644 index 87f07a3f5..000000000 --- a/jme3-core/src/main/resources/Common/ShaderLib/GLSL150Compat.glsllib +++ /dev/null @@ -1,14 +0,0 @@ -#if __VERSION__ >= 130 -out vec4 outFragColor; -# define texture1D texture -# define texture2D texture -# define texture3D texture -# define texture2DLod texture -# if defined VERTEX_SHADER -# define varying out -# define attribute in -# elif defined FRAGMENT_SHADER -# define varying in -# define gl_FragColor outFragColor -# endif -#endif \ No newline at end of file diff --git a/jme3-core/src/main/resources/Common/ShaderLib/GLSLCompat.glsllib b/jme3-core/src/main/resources/Common/ShaderLib/GLSLCompat.glsllib new file mode 100644 index 000000000..3a3173997 --- /dev/null +++ b/jme3-core/src/main/resources/Common/ShaderLib/GLSLCompat.glsllib @@ -0,0 +1,34 @@ +#if defined _GL_ES_ +# define hfloat highp float +# define hvec2 highp vec2 +# define hvec3 highp vec3 +# define hvec4 highp vec4 +# define lfloat lowp float +# define lvec2 lowp vec2 +# define lvec3 lowp vec3 +# define lvec4 lowp vec4 +#else +# define hfloat float +# define hvec2 vec2 +# define hvec3 vec3 +# define hvec4 vec4 +# define lfloat float +# define lvec2 vec2 +# define lvec3 vec3 +# define lvec4 vec4 +#endif + +#if __VERSION__ >= 130 +out vec4 outFragColor; +# define texture1D texture +# define texture2D texture +# define texture3D texture +# define texture2DLod texture +# if defined VERTEX_SHADER +# define varying out +# define attribute in +# elif defined FRAGMENT_SHADER +# define varying in +# define gl_FragColor outFragColor +# endif +#endif \ No newline at end of file From 148c78a9433aead07303d0aefe09155db907dd5d Mon Sep 17 00:00:00 2001 From: Kirill Vainer Date: Sat, 5 Sep 2015 14:03:32 -0400 Subject: [PATCH 07/20] GL: make lwjgl implementation classes final --- jme3-core/src/main/java/com/jme3/renderer/opengl/GL.java | 1 + jme3-lwjgl/src/main/java/com/jme3/renderer/lwjgl/LwjglGL.java | 2 +- .../src/main/java/com/jme3/renderer/lwjgl/LwjglGLExt.java | 2 +- .../src/main/java/com/jme3/renderer/lwjgl/LwjglGLFboEXT.java | 2 +- .../src/main/java/com/jme3/renderer/lwjgl/LwjglGLFboGL3.java | 2 +- settings.gradle | 2 +- 6 files changed, 6 insertions(+), 5 deletions(-) diff --git a/jme3-core/src/main/java/com/jme3/renderer/opengl/GL.java b/jme3-core/src/main/java/com/jme3/renderer/opengl/GL.java index 4a9380cf4..1b9c3f94d 100644 --- a/jme3-core/src/main/java/com/jme3/renderer/opengl/GL.java +++ b/jme3-core/src/main/java/com/jme3/renderer/opengl/GL.java @@ -161,6 +161,7 @@ public interface GL { public static final int GL_TEXTURE_CUBE_MAP_NEGATIVE_Y = 0x8518; public static final int GL_TEXTURE_CUBE_MAP_POSITIVE_Z = 0x8519; public static final int GL_TEXTURE_CUBE_MAP_NEGATIVE_Z = 0x851A; + public static final int GL_TEXTURE_BASE_LEVEL = 0x813C; public static final int GL_TEXTURE_MAG_FILTER = 0x2800; public static final int GL_TEXTURE_MAX_LEVEL = 0x813D; public static final int GL_TEXTURE_MIN_FILTER = 0x2801; diff --git a/jme3-lwjgl/src/main/java/com/jme3/renderer/lwjgl/LwjglGL.java b/jme3-lwjgl/src/main/java/com/jme3/renderer/lwjgl/LwjglGL.java index bf99c84eb..2b7df131a 100644 --- a/jme3-lwjgl/src/main/java/com/jme3/renderer/lwjgl/LwjglGL.java +++ b/jme3-lwjgl/src/main/java/com/jme3/renderer/lwjgl/LwjglGL.java @@ -13,7 +13,7 @@ import java.nio.ShortBuffer; import com.jme3.renderer.opengl.GL4; import org.lwjgl.opengl.*; -public class LwjglGL implements GL, GL2, GL3, GL4 { +public final class LwjglGL implements GL, GL2, GL3, GL4 { private static void checkLimit(Buffer buffer) { if (buffer == null) { diff --git a/jme3-lwjgl/src/main/java/com/jme3/renderer/lwjgl/LwjglGLExt.java b/jme3-lwjgl/src/main/java/com/jme3/renderer/lwjgl/LwjglGLExt.java index 2c6a63fd7..e3b9e6c77 100644 --- a/jme3-lwjgl/src/main/java/com/jme3/renderer/lwjgl/LwjglGLExt.java +++ b/jme3-lwjgl/src/main/java/com/jme3/renderer/lwjgl/LwjglGLExt.java @@ -13,7 +13,7 @@ import org.lwjgl.opengl.GL15; import org.lwjgl.opengl.GL20; import org.lwjgl.opengl.GLSync; -public class LwjglGLExt implements GLExt { +public final class LwjglGLExt implements GLExt { private static void checkLimit(Buffer buffer) { if (buffer == null) { diff --git a/jme3-lwjgl/src/main/java/com/jme3/renderer/lwjgl/LwjglGLFboEXT.java b/jme3-lwjgl/src/main/java/com/jme3/renderer/lwjgl/LwjglGLFboEXT.java index 159000a6c..40571f5ed 100644 --- a/jme3-lwjgl/src/main/java/com/jme3/renderer/lwjgl/LwjglGLFboEXT.java +++ b/jme3-lwjgl/src/main/java/com/jme3/renderer/lwjgl/LwjglGLFboEXT.java @@ -13,7 +13,7 @@ import org.lwjgl.opengl.EXTFramebufferObject; * * @author Kirill Vainer */ -public class LwjglGLFboEXT implements GLFbo { +public final class LwjglGLFboEXT implements GLFbo { private static void checkLimit(Buffer buffer) { if (buffer == null) { diff --git a/jme3-lwjgl/src/main/java/com/jme3/renderer/lwjgl/LwjglGLFboGL3.java b/jme3-lwjgl/src/main/java/com/jme3/renderer/lwjgl/LwjglGLFboGL3.java index acc540273..14e0cc9e6 100644 --- a/jme3-lwjgl/src/main/java/com/jme3/renderer/lwjgl/LwjglGLFboGL3.java +++ b/jme3-lwjgl/src/main/java/com/jme3/renderer/lwjgl/LwjglGLFboGL3.java @@ -11,7 +11,7 @@ import org.lwjgl.opengl.GL30; * * @author Kirill Vainer */ -public class LwjglGLFboGL3 implements GLFbo { +public final class LwjglGLFboGL3 implements GLFbo { private static void checkLimit(Buffer buffer) { if (buffer == null) { diff --git a/settings.gradle b/settings.gradle index 89b8fc075..6aad1b374 100644 --- a/settings.gradle +++ b/settings.gradle @@ -36,7 +36,7 @@ include 'jme3-testdata' include 'jme3-examples' if(buildAndroidExamples == "true"){ - include 'jme3-android-examples' + include 'jme3-android-examples' } if(buildSdkProject == "true"){ From e93fb65bca47a10c2e5b702465feb1c8b4ccbea3 Mon Sep 17 00:00:00 2001 From: Kirill Vainer Date: Sat, 5 Sep 2015 14:04:01 -0400 Subject: [PATCH 08/20] sdk build: enable nbm signing (if key exists) --- sdk/nbproject/platform.properties | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sdk/nbproject/platform.properties b/sdk/nbproject/platform.properties index 73f8590d7..65b38a709 100644 --- a/sdk/nbproject/platform.properties +++ b/sdk/nbproject/platform.properties @@ -1,4 +1,6 @@ branding.token=jmonkeyplatform +keystore=../nbproject/private/keystore.jks +nbm_alias=jmeupdates cluster.path=\ ${nbplatform.active.dir}/extide:\ ${nbplatform.active.dir}/harness:\ From 4f1477735db1c274bb0a1a87ebcba14f8f43851f Mon Sep 17 00:00:00 2001 From: Dokthar Date: Sun, 6 Sep 2015 12:57:35 +0200 Subject: [PATCH 09/20] SDK scenecomposer :reduce the arrows line width from 3 to 2. --- .../src/com/jme3/gde/scenecomposer/SceneEditTool.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sdk/jme3-scenecomposer/src/com/jme3/gde/scenecomposer/SceneEditTool.java b/sdk/jme3-scenecomposer/src/com/jme3/gde/scenecomposer/SceneEditTool.java index 9c7ad75cb..c2a4753c4 100644 --- a/sdk/jme3-scenecomposer/src/com/jme3/gde/scenecomposer/SceneEditTool.java +++ b/sdk/jme3-scenecomposer/src/com/jme3/gde/scenecomposer/SceneEditTool.java @@ -453,9 +453,9 @@ public abstract class SceneEditTool { Geometry arrowX = new Geometry("arrowX", new Arrow(new Vector3f(arrowSize, 0, 0))); Geometry arrowY = new Geometry("arrowY", new Arrow(new Vector3f(0, arrowSize, 0))); Geometry arrowZ = new Geometry("arrowZ", new Arrow(new Vector3f(0, 0, arrowSize))); - arrowX.getMesh().setLineWidth(3f); - arrowY.getMesh().setLineWidth(3f); - arrowZ.getMesh().setLineWidth(3f); + arrowX.getMesh().setLineWidth(2f); + arrowY.getMesh().setLineWidth(2f); + arrowZ.getMesh().setLineWidth(2f); axis.attachChild(arrowX); axis.attachChild(arrowY); axis.attachChild(arrowZ); From 7e0bd4a385f9c9c975096167271c7b6d10daf3a4 Mon Sep 17 00:00:00 2001 From: Dokthar Date: Sun, 6 Sep 2015 13:07:55 +0200 Subject: [PATCH 10/20] SDK scenecomposer : fix issue #332 cursor doesn't move the position of the cursor wasn't updated, now it's work fine --- .../gde/scenecomposer/tools/SelectTool.java | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/sdk/jme3-scenecomposer/src/com/jme3/gde/scenecomposer/tools/SelectTool.java b/sdk/jme3-scenecomposer/src/com/jme3/gde/scenecomposer/tools/SelectTool.java index 87f3c283f..013cfb492 100644 --- a/sdk/jme3-scenecomposer/src/com/jme3/gde/scenecomposer/tools/SelectTool.java +++ b/sdk/jme3-scenecomposer/src/com/jme3/gde/scenecomposer/tools/SelectTool.java @@ -10,6 +10,7 @@ import com.jme3.gde.core.sceneexplorer.nodes.JmeSpatial; import com.jme3.gde.core.sceneviewer.SceneViewerTopComponent; import com.jme3.gde.scenecomposer.SceneEditTool; import com.jme3.math.Vector2f; +import com.jme3.math.Vector3f; import com.jme3.scene.Node; import com.jme3.scene.Spatial; import com.jme3.terrain.Terrain; @@ -33,7 +34,7 @@ import org.openide.loaders.DataObject; */ public class SelectTool extends SceneEditTool { - private boolean wasDraggingR = false; + private boolean wasDraggingR, wasDraggingL = false; private boolean wasDownR = false; /** @@ -52,13 +53,24 @@ public class SelectTool extends SceneEditTool { */ @Override public void actionPrimary(Vector2f screenCoord, boolean pressed, final JmeNode rootNode, DataObject dataObject) { - + if (!pressed){ + if (!wasDraggingL) { + Vector3f result = pickWorldLocation(getCamera(), screenCoord, rootNode); + if (result != null) { + if (toolController.isSnapToGrid()) { + result.set(Math.round(result.x), result.y, Math.round(result.z)); + } + toolController.doSetCursorLocation(result); + } + } + wasDraggingL = false; + } } @Override public void actionSecondary(final Vector2f screenCoord, boolean pressed, final JmeNode rootNode, DataObject dataObject) { if (pressed) { - Spatial selected = toolController.getSelectedSpatial(); + Spatial selected;// = toolController.getSelectedSpatial(); // mouse down if (!wasDraggingR && !wasDownR) { // wasn't dragging and was not down already @@ -137,6 +149,7 @@ public class SelectTool extends SceneEditTool { @Override public void draggedPrimary(Vector2f screenCoord, boolean pressed, JmeNode rootNode, DataObject currentDataObject) { + wasDraggingL = pressed; } @Override From e552fb11012946963d77f44b4326dcdb1c41ee8e Mon Sep 17 00:00:00 2001 From: Kirill Vainer Date: Sun, 6 Sep 2015 17:07:16 -0400 Subject: [PATCH 11/20] travis-ci: don't try to decrypt updates key for PRs --- .travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index eb7e58253..48e75d0b4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -43,8 +43,7 @@ deploy: before_install: - git fetch --unshallow - - openssl aes-256-cbc -K $encrypted_a1949b55824a_key -iv $encrypted_a1949b55824a_iv - -in private/www-updater.key.enc -out private/www-updater.key -d + - "[ $TRAVIS_PULL_REQUEST == 'false' ] && openssl aes-256-cbc -K $encrypted_a1949b55824a_key -iv $encrypted_a1949b55824a_iv -in private/www-updater.key.enc -out private/www-updater.key -d || :" # before_install: # required libs for android build tools From 71e2a7efef679ef6cb01baca45422b24f405dcad Mon Sep 17 00:00:00 2001 From: Dokthar Date: Wed, 9 Sep 2015 20:27:57 +0200 Subject: [PATCH 12/20] SDK Terrain Editor : changed the paintTool tooltip text to match the tool actions --- .../src/com/jme3/gde/terraineditor/Bundle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/Bundle.properties b/sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/Bundle.properties index 1f7cfa66f..69d691908 100644 --- a/sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/Bundle.properties +++ b/sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/Bundle.properties @@ -124,7 +124,7 @@ TerrainEditorTopComponent.AbsoluteCheckbox.tooltip=Define the height to adjust t TerrainEditorTopComponent.slopeLockCheckbox.tooltip=Contains the slope between the two slope nodes TerrainEditorTopComponent.borderDistanceLabel.tooltip=Distance means how far from the terrain's edge the border will be raised (thickness of the border). TerrainEditorTopComponent.borderHeightLAbel.tooltip=Height means how high the border will go (also accept negative values). -TerrainEditorTopComponent.paintButton.toolTipText=Erase a texture from the terrain +TerrainEditorTopComponent.paintButton.toolTipText=Paint a texture on the terrain. RMB to Erase. TerrainEditorTopComponent.paintButton.text= RenameTerrainVisualPanel1.ranemeLabel.text=Rename Terrain Alphamaps RenameTerrainVisualPanel1.renameField.text= From edd183a2be86af90f5bea680fc2b953d8bf0177f Mon Sep 17 00:00:00 2001 From: Kirill Vainer Date: Wed, 9 Sep 2015 22:43:37 -0400 Subject: [PATCH 13/20] GLRenderer: fix texture update regression introduced in 9f3a145dd7bd083c21b302e0faaf46eddfd82237 --- .../com/jme3/renderer/opengl/GLRenderer.java | 54 +++++++++---------- 1 file changed, 26 insertions(+), 28 deletions(-) diff --git a/jme3-core/src/main/java/com/jme3/renderer/opengl/GLRenderer.java b/jme3-core/src/main/java/com/jme3/renderer/opengl/GLRenderer.java index dd30da089..15307a9b2 100644 --- a/jme3-core/src/main/java/com/jme3/renderer/opengl/GLRenderer.java +++ b/jme3-core/src/main/java/com/jme3/renderer/opengl/GLRenderer.java @@ -1950,6 +1950,28 @@ public class GLRenderer implements Renderer { } } + /** + * Ensures that the texture is bound to the given unit + * and that the unit is currently active (for modification). + * + * @param target The texture target, one of GL_TEXTURE_*** + * @param img The image texture to bind + * @param unit At what unit to bind the texture. + */ + private void bindTextureAndUnit(int target, Image img, int unit) { + if (context.boundTextureUnit != unit) { + gl.glActiveTexture(GL.GL_TEXTURE0 + unit); + context.boundTextureUnit = unit; + } + if (context.boundTextures[unit] != img) { + gl.glBindTexture(target, img.getId()); + context.boundTextures[unit] = img; + statistics.onTextureUse(img, true); + } else { + statistics.onTextureUse(img, false); + } + } + /** * Uploads the given image to the GL driver. * @@ -1973,17 +1995,7 @@ public class GLRenderer implements Renderer { // bind texture int target = convertTextureType(type, img.getMultiSamples(), -1); - if (context.boundTextures[unit] != img) { - if (context.boundTextureUnit != unit) { - gl.glActiveTexture(GL.GL_TEXTURE0 + unit); - context.boundTextureUnit = unit; - } - - gl.glBindTexture(target, texId); - context.boundTextures[unit] = img; - - statistics.onTextureUse(img, true); - } + bindTextureAndUnit(target, img, unit); if (!img.hasMipmaps() && img.isGeneratedMipmapsRequired()) { // Image does not have mipmaps, but they are required. @@ -2092,6 +2104,7 @@ public class GLRenderer implements Renderer { img.clearUpdateNeeded(); } + @Override public void setTexture(int unit, Texture tex) { Image image = tex.getImage(); if (image.isUpdateNeeded() || (image.isGeneratedMipmapsRequired() && !image.isMipmapsGenerated())) { @@ -2118,23 +2131,8 @@ public class GLRenderer implements Renderer { int texId = image.getId(); assert texId != -1; - Image[] textures = context.boundTextures; - - int type = convertTextureType(tex.getType(), image.getMultiSamples(), -1); - if (textures[unit] != image) { - if (context.boundTextureUnit != unit) { - gl.glActiveTexture(GL.GL_TEXTURE0 + unit); - context.boundTextureUnit = unit; - } - - gl.glBindTexture(type, texId); - textures[unit] = image; - - statistics.onTextureUse(image, true); - } else { - statistics.onTextureUse(image, false); - } - + int target = convertTextureType(tex.getType(), image.getMultiSamples(), -1); + bindTextureAndUnit(target, image, unit); setupTextureParams(tex); } From 584567140982b8b70a09ed1d35dfc439b84fb9c2 Mon Sep 17 00:00:00 2001 From: Kirill Vainer Date: Thu, 10 Sep 2015 22:33:08 -0400 Subject: [PATCH 14/20] GLRenderer: enable seamless cubemap globally --- .../java/com/jme3/renderer/RenderContext.java | 3 --- .../com/jme3/renderer/opengl/GLRenderer.java | 17 +++++------------ 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/jme3-core/src/main/java/com/jme3/renderer/RenderContext.java b/jme3-core/src/main/java/com/jme3/renderer/RenderContext.java index 16c07dc71..4b51e0727 100644 --- a/jme3-core/src/main/java/com/jme3/renderer/RenderContext.java +++ b/jme3-core/src/main/java/com/jme3/renderer/RenderContext.java @@ -255,8 +255,6 @@ public class RenderContext { public ColorRGBA clearColor = new ColorRGBA(0,0,0,0); - public boolean seamlessCubemap = false; - /** * Reset the RenderContext to default GL state */ @@ -308,6 +306,5 @@ public class RenderContext { depthFunc = RenderState.TestFunction.LessOrEqual; alphaFunc = RenderState.TestFunction.Greater; clearColor.set(0,0,0,0); - seamlessCubemap = false; } } diff --git a/jme3-core/src/main/java/com/jme3/renderer/opengl/GLRenderer.java b/jme3-core/src/main/java/com/jme3/renderer/opengl/GLRenderer.java index 15307a9b2..de11d7898 100644 --- a/jme3-core/src/main/java/com/jme3/renderer/opengl/GLRenderer.java +++ b/jme3-core/src/main/java/com/jme3/renderer/opengl/GLRenderer.java @@ -503,6 +503,11 @@ public class GLRenderer implements Renderer { // Initialize default state.. gl.glPixelStorei(GL.GL_UNPACK_ALIGNMENT, 1); + + if (caps.contains(Caps.SeamlessCubemap)) { + // Enable this globally. Should be OK. + gl.glEnable(GLExt.GL_TEXTURE_CUBE_MAP_SEAMLESS); + } if (caps.contains(Caps.CoreProfile)) { // Core Profile requires VAO to be bound. @@ -1833,18 +1838,6 @@ public class GLRenderer implements Renderer { gl.glTexParameteri(target, GL.GL_TEXTURE_MIN_FILTER, minFilter); image.getLastTextureState().minFilter = tex.getMinFilter(); } - if (caps.contains(Caps.SeamlessCubemap) && tex.getType() == Texture.Type.CubeMap) { - if (haveMips && !context.seamlessCubemap) { - // We can enable seamless cubemap filtering. - gl.glEnable(GLExt.GL_TEXTURE_CUBE_MAP_SEAMLESS); - context.seamlessCubemap = true; - } else if (!haveMips && context.seamlessCubemap) { - // For skyboxes (no mipmaps), disable seamless cubemap filtering. - gl.glDisable(GLExt.GL_TEXTURE_CUBE_MAP_SEAMLESS); - context.seamlessCubemap = false; - } - } - if (tex.getAnisotropicFilter() > 1) { if (caps.contains(Caps.TextureFilterAnisotropic)) { gl.glTexParameterf(target, From f80364a8c2979f810e9d03e65ba0ae942a69e52e Mon Sep 17 00:00:00 2001 From: Kirill Vainer Date: Thu, 10 Sep 2015 22:34:12 -0400 Subject: [PATCH 15/20] GLRenderer: don't set depth function twice --- .../src/main/java/com/jme3/renderer/RenderContext.java | 6 +++--- .../src/main/java/com/jme3/renderer/opengl/GLRenderer.java | 5 ++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/jme3-core/src/main/java/com/jme3/renderer/RenderContext.java b/jme3-core/src/main/java/com/jme3/renderer/RenderContext.java index 4b51e0727..8287a270e 100644 --- a/jme3-core/src/main/java/com/jme3/renderer/RenderContext.java +++ b/jme3-core/src/main/java/com/jme3/renderer/RenderContext.java @@ -241,12 +241,12 @@ public class RenderContext { public IDList attribIndexList = new IDList(); /** - * depth tets function + * depth test function */ - public RenderState.TestFunction depthFunc = RenderState.TestFunction.LessOrEqual; + public RenderState.TestFunction depthFunc = RenderState.TestFunction.Less; /** - * alpha tets function + * alpha test function */ public RenderState.TestFunction alphaFunc = RenderState.TestFunction.Greater; diff --git a/jme3-core/src/main/java/com/jme3/renderer/opengl/GLRenderer.java b/jme3-core/src/main/java/com/jme3/renderer/opengl/GLRenderer.java index de11d7898..2d8287817 100644 --- a/jme3-core/src/main/java/com/jme3/renderer/opengl/GLRenderer.java +++ b/jme3-core/src/main/java/com/jme3/renderer/opengl/GLRenderer.java @@ -614,17 +614,16 @@ public class GLRenderer implements Renderer { if (state.isDepthTest() && !context.depthTestEnabled) { gl.glEnable(GL.GL_DEPTH_TEST); - gl.glDepthFunc(convertTestFunction(context.depthFunc)); context.depthTestEnabled = true; } else if (!state.isDepthTest() && context.depthTestEnabled) { gl.glDisable(GL.GL_DEPTH_TEST); context.depthTestEnabled = false; } - if (state.getDepthFunc() != context.depthFunc) { + if (state.isDepthTest() && state.getDepthFunc() != context.depthFunc) { gl.glDepthFunc(convertTestFunction(state.getDepthFunc())); context.depthFunc = state.getDepthFunc(); } - + if (state.isDepthWrite() && !context.depthWriteEnabled) { gl.glDepthMask(true); context.depthWriteEnabled = true; From 8fdc0f9c904c28717a7bfe4529f82bc40df79489 Mon Sep 17 00:00:00 2001 From: Kirill Vainer Date: Thu, 10 Sep 2015 23:08:50 -0400 Subject: [PATCH 16/20] GLRenderer: avoid useless glActiveTexture calls --- .../com/jme3/renderer/opengl/GLRenderer.java | 59 ++++++++++++++----- .../jme3/texture/image/LastTextureState.java | 2 + 2 files changed, 47 insertions(+), 14 deletions(-) diff --git a/jme3-core/src/main/java/com/jme3/renderer/opengl/GLRenderer.java b/jme3-core/src/main/java/com/jme3/renderer/opengl/GLRenderer.java index 2d8287817..17e9c1055 100644 --- a/jme3-core/src/main/java/com/jme3/renderer/opengl/GLRenderer.java +++ b/jme3-core/src/main/java/com/jme3/renderer/opengl/GLRenderer.java @@ -1432,7 +1432,7 @@ public class GLRenderer implements Renderer { // NOTE: For depth textures, sets nearest/no-mips mode // Required to fix "framebuffer unsupported" // for old NVIDIA drivers! - setupTextureParams(tex); + setupTextureParams(0, tex); } glfbo.glFramebufferTexture2DEXT(GLFbo.GL_FRAMEBUFFER_EXT, @@ -1816,7 +1816,7 @@ public class GLRenderer implements Renderer { } @SuppressWarnings("fallthrough") - private void setupTextureParams(Texture tex) { + private void setupTextureParams(int unit, Texture tex) { Image image = tex.getImage(); int target = convertTextureType(tex.getType(), image != null ? image.getMultiSamples() : 1, -1); @@ -1829,20 +1829,23 @@ public class GLRenderer implements Renderer { // filter things if (image.getLastTextureState().magFilter != tex.getMagFilter()) { int magFilter = convertMagFilter(tex.getMagFilter()); + bindTextureAndUnit(target, image, unit); gl.glTexParameteri(target, GL.GL_TEXTURE_MAG_FILTER, magFilter); image.getLastTextureState().magFilter = tex.getMagFilter(); } if (image.getLastTextureState().minFilter != tex.getMinFilter()) { int minFilter = convertMinFilter(tex.getMinFilter(), haveMips); + bindTextureAndUnit(target, image, unit); gl.glTexParameteri(target, GL.GL_TEXTURE_MIN_FILTER, minFilter); image.getLastTextureState().minFilter = tex.getMinFilter(); } - if (tex.getAnisotropicFilter() > 1) { - if (caps.contains(Caps.TextureFilterAnisotropic)) { - gl.glTexParameterf(target, - GLExt.GL_TEXTURE_MAX_ANISOTROPY_EXT, - tex.getAnisotropicFilter()); - } + if (caps.contains(Caps.TextureFilterAnisotropic) + && image.getLastTextureState().anisoFilter != tex.getAnisotropicFilter()) { + bindTextureAndUnit(target, image, unit); + gl.glTexParameterf(target, + GLExt.GL_TEXTURE_MAX_ANISOTROPY_EXT, + tex.getAnisotropicFilter()); + image.getLastTextureState().anisoFilter = tex.getAnisotropicFilter(); } // repeat modes @@ -1850,6 +1853,7 @@ public class GLRenderer implements Renderer { case ThreeDimensional: case CubeMap: // cubemaps use 3D coords if (gl2 != null && image.getLastTextureState().rWrap != tex.getWrap(WrapAxis.R)) { + bindTextureAndUnit(target, image, unit); gl2.glTexParameteri(target, GL2.GL_TEXTURE_WRAP_R, convertWrapMode(tex.getWrap(WrapAxis.R))); image.getLastTextureState().rWrap = tex.getWrap(WrapAxis.R); } @@ -1857,10 +1861,12 @@ public class GLRenderer implements Renderer { case TwoDimensional: case TwoDimensionalArray: if (image.getLastTextureState().tWrap != tex.getWrap(WrapAxis.T)) { + bindTextureAndUnit(target, image, unit); gl.glTexParameteri(target, GL.GL_TEXTURE_WRAP_T, convertWrapMode(tex.getWrap(WrapAxis.T))); image.getLastTextureState().tWrap = tex.getWrap(WrapAxis.T); } if (image.getLastTextureState().sWrap != tex.getWrap(WrapAxis.S)) { + bindTextureAndUnit(target, image, unit); gl.glTexParameteri(target, GL.GL_TEXTURE_WRAP_S, convertWrapMode(tex.getWrap(WrapAxis.S))); image.getLastTextureState().sWrap = tex.getWrap(WrapAxis.S); } @@ -1869,9 +1875,10 @@ public class GLRenderer implements Renderer { throw new UnsupportedOperationException("Unknown texture type: " + tex.getType()); } - if(tex.isNeedCompareModeUpdate() && gl2 != null){ + if (tex.isNeedCompareModeUpdate() && gl2 != null) { // R to Texture compare mode if (tex.getShadowCompareMode() != Texture.ShadowCompareMode.Off) { + bindTextureAndUnit(target, image, unit); gl2.glTexParameteri(target, GL2.GL_TEXTURE_COMPARE_MODE, GL2.GL_COMPARE_R_TO_TEXTURE); gl2.glTexParameteri(target, GL2.GL_DEPTH_TEXTURE_MODE, GL2.GL_INTENSITY); if (tex.getShadowCompareMode() == Texture.ShadowCompareMode.GreaterOrEqual) { @@ -1879,12 +1886,16 @@ public class GLRenderer implements Renderer { } else { gl2.glTexParameteri(target, GL2.GL_TEXTURE_COMPARE_FUNC, GL.GL_LEQUAL); } - }else{ + } else { + bindTextureAndUnit(target, image, unit); //restoring default value gl2.glTexParameteri(target, GL2.GL_TEXTURE_COMPARE_MODE, GL.GL_NONE); } tex.compareModeUpdated(); } + + // If at this point we didn't bind the texture, bind it now + bindTextureOnly(target, image, unit); } /** @@ -1964,6 +1975,28 @@ public class GLRenderer implements Renderer { } } + /** + * Ensures that the texture is bound to the given unit, + * but does not care if the unit is active (for rendering). + * + * @param target The texture target, one of GL_TEXTURE_*** + * @param img The image texture to bind + * @param unit At what unit to bind the texture. + */ + private void bindTextureOnly(int target, Image img, int unit) { + if (context.boundTextures[unit] != img) { + if (context.boundTextureUnit != unit) { + gl.glActiveTexture(GL.GL_TEXTURE0 + unit); + context.boundTextureUnit = unit; + } + gl.glBindTexture(target, img.getId()); + context.boundTextures[unit] = img; + statistics.onTextureUse(img, true); + } else { + statistics.onTextureUse(img, false); + } + } + /** * Uploads the given image to the GL driver. * @@ -1985,7 +2018,7 @@ public class GLRenderer implements Renderer { statistics.onNewTexture(); } - // bind texture + // bind texture int target = convertTextureType(type, img.getMultiSamples(), -1); bindTextureAndUnit(target, img, unit); @@ -2123,9 +2156,7 @@ public class GLRenderer implements Renderer { int texId = image.getId(); assert texId != -1; - int target = convertTextureType(tex.getType(), image.getMultiSamples(), -1); - bindTextureAndUnit(target, image, unit); - setupTextureParams(tex); + setupTextureParams(unit, tex); } public void modifyTexture(Texture tex, Image pixels, int x, int y) { diff --git a/jme3-core/src/main/java/com/jme3/texture/image/LastTextureState.java b/jme3-core/src/main/java/com/jme3/texture/image/LastTextureState.java index e7f2a2a14..3b85563ef 100644 --- a/jme3-core/src/main/java/com/jme3/texture/image/LastTextureState.java +++ b/jme3-core/src/main/java/com/jme3/texture/image/LastTextureState.java @@ -45,6 +45,7 @@ public final class LastTextureState { public Texture.WrapMode sWrap, tWrap, rWrap; public Texture.MagFilter magFilter; public Texture.MinFilter minFilter; + public int anisoFilter = 0; public LastTextureState() { // All parameters initialized to null (meaning unset). @@ -56,5 +57,6 @@ public final class LastTextureState { rWrap = null; magFilter = null; minFilter = null; + anisoFilter = 0; } } From 9da4b78830f168c93862e65c117667b96b5e43b9 Mon Sep 17 00:00:00 2001 From: Kirill Vainer Date: Thu, 10 Sep 2015 23:09:15 -0400 Subject: [PATCH 17/20] GLRenderer: disable unused vertex attributes before rendering instead of after --- .../src/main/java/com/jme3/renderer/opengl/GLRenderer.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/jme3-core/src/main/java/com/jme3/renderer/opengl/GLRenderer.java b/jme3-core/src/main/java/com/jme3/renderer/opengl/GLRenderer.java index 17e9c1055..0aa0d693f 100644 --- a/jme3-core/src/main/java/com/jme3/renderer/opengl/GLRenderer.java +++ b/jme3-core/src/main/java/com/jme3/renderer/opengl/GLRenderer.java @@ -2650,12 +2650,13 @@ public class GLRenderer implements Renderer { } } + clearVertexAttribs(); + if (indices != null) { drawTriangleList(indices, mesh, count); } else { drawTriangleArray(mesh.getMode(), count, mesh.getVertexCount()); } - clearVertexAttribs(); } public void renderMesh(Mesh mesh, int lod, int count, VertexBuffer[] instanceData) { From e9245a753b8336f6ff3a9deac76b048e2362ed7f Mon Sep 17 00:00:00 2001 From: Kirill Vainer Date: Thu, 10 Sep 2015 23:10:13 -0400 Subject: [PATCH 18/20] GLTracer: generate syntax highlighting and easier to read output --- .../com/jme3/renderer/opengl/GLTracer.java | 358 ++++++++++++++---- 1 file changed, 281 insertions(+), 77 deletions(-) diff --git a/jme3-core/src/main/java/com/jme3/renderer/opengl/GLTracer.java b/jme3-core/src/main/java/com/jme3/renderer/opengl/GLTracer.java index 1b0d70749..a2775ba0a 100644 --- a/jme3-core/src/main/java/com/jme3/renderer/opengl/GLTracer.java +++ b/jme3-core/src/main/java/com/jme3/renderer/opengl/GLTracer.java @@ -36,8 +36,14 @@ import java.lang.reflect.Field; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; import java.lang.reflect.Proxy; +import java.nio.Buffer; import java.nio.ByteBuffer; +import java.nio.CharBuffer; +import java.nio.DoubleBuffer; +import java.nio.FloatBuffer; import java.nio.IntBuffer; +import java.nio.LongBuffer; +import java.nio.ShortBuffer; import java.util.HashMap; /** @@ -51,6 +57,17 @@ public final class GLTracer implements InvocationHandler { private final IntMap constMap; private static final HashMap> nonEnumArgMap = new HashMap>(); + private static final String ANSI_RESET = "\u001B[0m"; + private static final String ANSI_BRIGHT = "\u001B[1m"; + private static final String ANSI_BLACK = "\u001B[30m"; + private static final String ANSI_RED = "\u001B[31m"; + private static final String ANSI_GREEN = "\u001B[32m"; + private static final String ANSI_YELLOW = "\u001B[33m"; + private static final String ANSI_BLUE = "\u001B[34m"; + private static final String ANSI_MAGENTA = "\u001B[35m"; + private static final String ANSI_CYAN = "\u001B[36m"; + private static final String ANSI_WHITE = "\u001B[37m"; + private static void noEnumArgs(String method, int... argSlots) { IntMap argSlotsMap = new IntMap(); for (int argSlot : argSlots) { @@ -174,100 +191,287 @@ public final class GLTracer implements InvocationHandler { new GLTracer(glInterface, constMap)); } - private String translateInteger(String method, int value, int argIndex) { - IntMap argSlotMap = nonEnumArgMap.get(method); - if (argSlotMap != null && argSlotMap.containsKey(argIndex)) { - return Integer.toString(value); - } + private void printStyle(String style, String string) { + System.out.print(style + string + ANSI_RESET); + } + + private void print(String string) { + System.out.print(string); + } + + private void printInt(int value) { + print(Integer.toString(value)); + } + + private void printEnum(int value) { String enumName = constMap.get(value); if (enumName != null) { - return enumName; + if (enumName.startsWith("GL_")) { + enumName = enumName.substring(3); + } + if (enumName.endsWith("_EXT") || enumName.endsWith("_ARB")) { + enumName = enumName.substring(0, enumName.length() - 4); + } + printStyle(ANSI_GREEN, enumName); + } else { + printStyle(ANSI_GREEN, "ENUM_" + Integer.toHexString(value)); + } + } + + private void printIntOrEnum(String method, int value, int argIndex) { + IntMap argSlotMap = nonEnumArgMap.get(method); + if (argSlotMap != null && argSlotMap.containsKey(argIndex)) { + printInt(value); } else { - return "GL_ENUM_" + Integer.toHexString(value); - //throw new IllegalStateException("Untranslatable enum encountered on " + method + - // " at argument " + argIndex + " with value " + value); + printEnum(value); } } - private String translateString(String value) { - return "\"" + value.replaceAll("\0", "\\\\0") + "\""; + private void printNewLine() { + System.out.println(); } - public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { - Object result = method.invoke(obj, args); - String methodName = method.getName(); + private void printString(String value) { + if (value.length() > 150) { + value = value.substring(0, 150) + "..."; + } + StringBuilder sb = new StringBuilder(); + sb.append(ANSI_YELLOW); + sb.append("\""); + sb.append(ANSI_RESET); + for (String line : value.split("\n")) { + sb.append(ANSI_YELLOW); + sb.append(line.replaceAll("\0", "\\\\0")); + sb.append(ANSI_RESET); + sb.append("\n"); + } + if (sb.length() > 1 && sb.charAt(sb.length() - 1) == '\n') { + sb.setLength(sb.length() - 1); + } + sb.append(ANSI_YELLOW); + sb.append("\""); + sb.append(ANSI_RESET); + print(sb.toString()); + } + + private void printBoolean(boolean bool) { + printStyle(ANSI_BLUE, bool ? "true" : "false"); + } + + private void printBuffer(Buffer buffer) { + StringBuilder sb = new StringBuilder(); + sb.append(ANSI_MAGENTA); + if (buffer instanceof ByteBuffer) { + sb.append("byte"); + } else if (buffer instanceof ShortBuffer) { + sb.append("short"); + } else if (buffer instanceof CharBuffer) { + sb.append("char"); + } else if (buffer instanceof FloatBuffer) { + sb.append("float"); + } else if (buffer instanceof IntBuffer) { + sb.append("int"); + } else if (buffer instanceof LongBuffer) { + sb.append("long"); + } else if (buffer instanceof DoubleBuffer) { + sb.append("double"); + } else { + throw new UnsupportedOperationException(); + } + sb.append(ANSI_RESET); + sb.append("["); + + if (buffer.position() == 0 + && buffer.limit() == buffer.capacity()) { + // Common case. Just print buffer size. + sb.append(buffer.capacity()); + } else { + sb.append("pos=").append(buffer.position()); + sb.append(" lim=").append(buffer.limit()); + sb.append(" cap=").append(buffer.capacity()); + } + + sb.append("]"); + print(sb.toString()); + } + + private void printMethodName(String methodName) { if (methodName.startsWith("gl")) { - System.out.print(methodName); - System.out.print("("); - if (args != null) { - Class[] paramTypes = method.getParameterTypes(); - for (int i = 0; i < args.length; i++) { - if (paramTypes[i] == int.class) { - int val = (Integer)args[i]; - System.out.print(translateInteger(methodName, val, i)); - } else if (paramTypes[i] == String.class) { - System.out.print(translateString((String)args[i])); - } else if (paramTypes[i] == String[].class) { - String[] arr = (String[]) args[i]; - if (arr.length == 1) { - if (arr[0].length() > 150) { - System.out.print("\"" + arr[0].substring(0, 150) + "...\""); - } else { - System.out.print("\"" + arr[0] + "\""); - } - } else { - System.out.print("String[" + arr.length + "]"); - } - } else if (args[i] instanceof IntBuffer) { - IntBuffer buf = (IntBuffer) args[i]; - if (buf.capacity() == 16) { - int val = buf.get(0); - System.out.print("out=" + translateInteger(methodName, val, i)); - } else if (buf.capacity() == 1) { - System.out.print("out=" + buf.get(0)); - } else { - System.out.print(args[i]); - } - } else if (args[i] instanceof ByteBuffer) { - ByteBuffer bb = (ByteBuffer)args[i]; - if (bb.capacity() == 250) { - if (bb.get(0) != 0) { - System.out.print("out=GL_TRUE"); - } else { - System.out.print("out=GL_FALSE"); - } - } else { - System.out.print(args[i]); - } - } else { - System.out.print(args[i]); - } - - if (i != args.length - 1) { - System.out.print(", "); - } + // GL calls which actually draw (as opposed to change state) + // will be printed in darker color + methodName = methodName.substring(2); + if (methodName.equals("Clear") + || methodName.equals("DrawRangeElements")) { + print(methodName); + } else { + if (methodName.endsWith("EXT")) { + methodName = methodName.substring(0, methodName.length() - 3); } + printStyle(ANSI_BRIGHT, methodName); } + } else if (methodName.equals("resetStats")) { + printStyle(ANSI_RED, "-- frame boundary --"); + } + } + + private void printArgsClear(int mask) { + boolean needAPipe = false; + print("("); + if ((mask & GL.GL_COLOR_BUFFER_BIT) != 0) { + printStyle(ANSI_GREEN, "COLOR_BUFFER_BIT"); + needAPipe = true; + } + if ((mask & GL.GL_DEPTH_BUFFER_BIT) != 0) { + if (needAPipe) { + print(" | "); + } + printStyle(ANSI_GREEN, "DEPTH_BUFFER_BIT"); + } + if ((mask & GL.GL_STENCIL_BUFFER_BIT) != 0) { + if (needAPipe) { + print(" | "); + } + printStyle(ANSI_GREEN, "STENCIL_BUFFER_BIT"); + } + print(")"); + } + + private void printArgsTexParameter(Object[] args) { + print("("); - System.out.print(")"); + int target = (Integer) args[0]; + int param = (Integer) args[1]; + int value = (Integer) args[2]; - if (method.getReturnType() != void.class) { - if (result instanceof String) { - System.out.println(" = " + translateString((String)result)); - } else if (method.getReturnType() == int.class) { - int val = (Integer)result; - System.out.println(" = " + translateInteger(methodName, val, -1)); - } else if (method.getReturnType() == boolean.class) { - boolean val = (Boolean)result; - if (val) System.out.println(" = GL_TRUE"); - else System.out.println(" = GL_FALSE"); + printEnum(target); + print(", "); + printEnum(param); + print(", "); + + if (param == GL.GL_TEXTURE_BASE_LEVEL + || param == GL.GL_TEXTURE_MAX_LEVEL) { + printInt(value); + } else { + printEnum(value); + } + + print(")"); + } + + private void printOut() { + printStyle(ANSI_CYAN, "out="); + } + + private void printResult(String methodName, Object result, Class returnType) { + if (returnType != void.class) { + print(" = "); + if (result instanceof String) { + printString((String) result); + } else if (returnType == int.class) { + int val = (Integer) result; + printIntOrEnum(methodName, val, -1); + } else if (returnType == boolean.class) { + printBoolean((Boolean)result); + } else { + print(" = ???"); + } + } + } + + private void printNull() { + printStyle(ANSI_BLUE, "null"); + } + + private void printArgs(String methodName, Object[] args, Class[] paramTypes) { + if (methodName.equals("glClear")) { + printArgsClear((Integer)args[0]); + return; + } else if (methodName.equals("glTexParameteri")) { + printArgsTexParameter(args); + return; + } + + if (args == null) { + print("()"); + return; + } + + print("("); + for (int i = 0; i < args.length; i++) { + if (paramTypes[i] == int.class) { + int val = (Integer)args[i]; + printIntOrEnum(methodName, val, i); + } else if (paramTypes[i] == boolean.class) { + printBoolean((Boolean)args[i]); + } else if (paramTypes[i] == String.class) { + printString((String)args[i]); + } else if (paramTypes[i] == String[].class) { + String[] arr = (String[]) args[i]; + if (arr.length == 1) { + printString(arr[0]); } else { - System.out.println(" = ???"); + print("string[" + arr.length + "]"); } + } else if (args[i] instanceof IntBuffer) { + IntBuffer buf = (IntBuffer) args[i]; + if (buf.capacity() == 16) { + int val = buf.get(0); + printOut(); + printIntOrEnum(methodName, val, i); + } else if (buf.capacity() == 1) { + printOut(); + print(Integer.toString(buf.get(0))); + } else { + printBuffer(buf); + } + } else if (args[i] instanceof ByteBuffer) { + ByteBuffer bb = (ByteBuffer)args[i]; + if (bb.capacity() == 250) { + printOut(); + printBoolean(bb.get(0) != 0); + } else { + printBuffer(bb); + } + } else if (args[i] instanceof Buffer) { + printBuffer((Buffer)args[i]); + } else if (args[i] != null) { + print(args[i].toString()); } else { - System.out.println(); + printNull(); + } + + if (i != args.length - 1) { + System.out.print(", "); + } + } + print(")"); + } + + @Override + public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { + String methodName = method.getName(); + printMethodName(methodName); + + if (methodName.startsWith("gl")) { + try { + // Try to evaluate result first, so we can see output values. + Object result = method.invoke(obj, args); + printArgs(methodName, args, method.getParameterTypes()); + printResult(methodName, result, method.getReturnType()); + printNewLine(); + return result; + } catch (Throwable ex) { + // Execution failed, print args anyway + // but output values will be incorrect. + printArgs(methodName, args, method.getParameterTypes()); + printNewLine(); + System.out.println("\tException occurred!"); + System.out.println(ex.toString()); + throw ex; } + } else { + printNewLine(); + return method.invoke(obj, args); } - return result; } } From 86439c2c2b307c2ae54c0ebe1898f3b096989ec2 Mon Sep 17 00:00:00 2001 From: Kirill Vainer Date: Fri, 11 Sep 2015 13:51:48 -0400 Subject: [PATCH 19/20] native bullet: fix JNI crash in ray / sweep test Method return type does not match call function return type --- jme3-bullet-native/src/native/cpp/jmeBulletUtil.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jme3-bullet-native/src/native/cpp/jmeBulletUtil.cpp b/jme3-bullet-native/src/native/cpp/jmeBulletUtil.cpp index 04b56a545..a51bcf833 100644 --- a/jme3-bullet-native/src/native/cpp/jmeBulletUtil.cpp +++ b/jme3-bullet-native/src/native/cpp/jmeBulletUtil.cpp @@ -351,7 +351,7 @@ void jmeBulletUtil::addResult(JNIEnv* env, jobject resultlist, btVector3* hitnor env->SetFloatField(singleresult, jmeClasses::PhysicsRay_hitfraction, m_hitFraction); env->SetObjectField(singleresult, jmeClasses::PhysicsRay_collisionObject, up1->javaCollisionObject); - env->CallVoidMethod(resultlist, jmeClasses::PhysicsRay_addmethod, singleresult); + env->CallBooleanMethod(resultlist, jmeClasses::PhysicsRay_addmethod, singleresult); if (env->ExceptionCheck()) { env->Throw(env->ExceptionOccurred()); return; @@ -371,7 +371,7 @@ void jmeBulletUtil::addSweepResult(JNIEnv* env, jobject resultlist, btVector3* h env->SetFloatField(singleresult, jmeClasses::PhysicsSweep_hitfraction, m_hitFraction); env->SetObjectField(singleresult, jmeClasses::PhysicsSweep_collisionObject, up1->javaCollisionObject); - env->CallVoidMethod(resultlist, jmeClasses::PhysicsSweep_addmethod, singleresult); + env->CallBooleanMethod(resultlist, jmeClasses::PhysicsSweep_addmethod, singleresult); if (env->ExceptionCheck()) { env->Throw(env->ExceptionOccurred()); return; From 62eede87b3e69e90851ab8c28a1ae6d6177514e6 Mon Sep 17 00:00:00 2001 From: Kirill Vainer Date: Sat, 12 Sep 2015 17:54:43 -0400 Subject: [PATCH 20/20] niftygui build: add niftygui repository reference to pom --- jme3-niftygui/build.gradle | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/jme3-niftygui/build.gradle b/jme3-niftygui/build.gradle index abe25f6e4..fe4f46462 100644 --- a/jme3-niftygui/build.gradle +++ b/jme3-niftygui/build.gradle @@ -14,3 +14,16 @@ dependencies { compile 'lessvoid:nifty-default-controls:1.4.1' compile 'lessvoid:nifty-style-black:1.4.1' } + +uploadArchives { + repositories.mavenDeployer { + pom.project { + repositories { + repository { + id "nifty-maven-repo.sourceforge.net" + url "http://nifty-gui.sourceforge.net/nifty-maven-repo" + } + } + } + } +} \ No newline at end of file