From 8e15ce579210e381d404be4b437786317d5e7e48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=A9meth=20=C3=81d=C3=A1m?= Date: Mon, 9 Nov 2015 13:39:49 +0100 Subject: [PATCH 01/43] test commit --- iOS/G3MiOSSDK/Commons/Basic/G3MWidget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iOS/G3MiOSSDK/Commons/Basic/G3MWidget.cpp b/iOS/G3MiOSSDK/Commons/Basic/G3MWidget.cpp index aa895c4a8b..f520c5d4c2 100644 --- a/iOS/G3MiOSSDK/Commons/Basic/G3MWidget.cpp +++ b/iOS/G3MiOSSDK/Commons/Basic/G3MWidget.cpp @@ -620,7 +620,7 @@ void G3MWidget::render(int width, int height) { _totalRenderTime += elapsedTimeMS; if ((_renderStatisticsTimer == NULL) || - (_renderStatisticsTimer->elapsedTimeInMilliseconds() > 2000)) { + (_renderStatisticsTimer->elapsedTimeInMilliseconds() > 3000)) { const double averageTimePerRender = (double) _totalRenderTime / _renderCounter; const double fps = 1000.0 / averageTimePerRender; ILogger::instance()->logInfo("FPS=%f" , fps); From e94c735876c70f15243d1c11f6eb42aeff9d507f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=A9meth=20=C3=81d=C3=A1m?= Date: Mon, 9 Nov 2015 14:05:07 +0100 Subject: [PATCH 02/43] test commit 2 --- iOS/G3MiOSSDK/Commons/Rendererers/BusyMeshRenderer.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/iOS/G3MiOSSDK/Commons/Rendererers/BusyMeshRenderer.cpp b/iOS/G3MiOSSDK/Commons/Rendererers/BusyMeshRenderer.cpp index d3b4f86eef..c201480db0 100644 --- a/iOS/G3MiOSSDK/Commons/Rendererers/BusyMeshRenderer.cpp +++ b/iOS/G3MiOSSDK/Commons/Rendererers/BusyMeshRenderer.cpp @@ -71,9 +71,9 @@ Mesh* BusyMeshRenderer::createMesh(const G3MRenderContext* rc) { const int viewPortWidth = camera->getViewPortWidth(); const int viewPortHeight = camera->getViewPortHeight(); const int minSize = (viewPortWidth < viewPortHeight) ? viewPortWidth : viewPortHeight; - const float outerRadius = minSize / 15.0f; - - const IMathUtils* mu = IMathUtils::instance(); + const float outerRadius = minSize / 18.0f; + ILogger::instance()->logError("This a test log line"); + const IMathUtils* mu = IMathUtils::instance(); for (int step = 0; step <= numStrides; step++) { const double angle = (double) step * 2 * PI / numStrides; From d06a6f0ade736ec7b50ab417bfc8195f353cefc0 Mon Sep 17 00:00:00 2001 From: aldeanueva Date: Mon, 9 Nov 2015 18:15:44 +0100 Subject: [PATCH 03/43] Generated --- .../src/org/glob3/mobile/generated/BusyMeshRenderer.java | 6 +++--- .../src/org/glob3/mobile/generated/G3MWidget.java | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/BusyMeshRenderer.java b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/BusyMeshRenderer.java index 44b2f37e6f..bd54a53bd4 100644 --- a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/BusyMeshRenderer.java +++ b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/BusyMeshRenderer.java @@ -76,9 +76,9 @@ private Mesh createMesh(G3MRenderContext rc) final int viewPortWidth = camera.getViewPortWidth(); final int viewPortHeight = camera.getViewPortHeight(); final int minSize = (viewPortWidth < viewPortHeight) ? viewPortWidth : viewPortHeight; - final float outerRadius = minSize / 15.0f; - - final IMathUtils mu = IMathUtils.instance(); + final float outerRadius = minSize / 18.0f; + ILogger.instance().logError("This a test log line"); + final IMathUtils mu = IMathUtils.instance(); for (int step = 0; step <= numStrides; step++) { diff --git a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/G3MWidget.java b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/G3MWidget.java index 6453314a19..3bce39b5ae 100644 --- a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/G3MWidget.java +++ b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/G3MWidget.java @@ -266,7 +266,7 @@ public final void render(int width, int height) { _totalRenderTime += elapsedTimeMS; - if ((_renderStatisticsTimer == null) || (_renderStatisticsTimer.elapsedTimeInMilliseconds() > 2000)) + if ((_renderStatisticsTimer == null) || (_renderStatisticsTimer.elapsedTimeInMilliseconds() > 3000)) { final double averageTimePerRender = (double) _totalRenderTime / _renderCounter; final double fps = 1000.0 / averageTimePerRender; From cf32dd7df3783318f08e8cf0d2d7605af46cba46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=A9meth=20=C3=81d=C3=A1m?= Date: Tue, 10 Nov 2015 13:59:34 +0100 Subject: [PATCH 04/43] changes for aeroglass project --- .gitignore | 8 ++++ Android/G3MAndroidSDK/AndroidManifest.xml | 14 ------- .../glob3/mobile/specific/ES2Renderer.java | 41 +++++++++---------- .../mobile/specific/G3MBuilder_Android.java | 7 +--- .../mobile/specific/G3MWidget_Android.java | 19 +++++++-- 5 files changed, 46 insertions(+), 43 deletions(-) diff --git a/.gitignore b/.gitignore index 8e58cce79f..0b2545d291 100644 --- a/.gitignore +++ b/.gitignore @@ -82,3 +82,11 @@ tools/point-cloud-octree/bin/ .settings tools/externals/poly2tri-java/bin/ + +# Android-Studio +*.iml +*.idea + +# Gradle +build +*/build diff --git a/Android/G3MAndroidSDK/AndroidManifest.xml b/Android/G3MAndroidSDK/AndroidManifest.xml index d3f5476488..a630b7eb77 100644 --- a/Android/G3MAndroidSDK/AndroidManifest.xml +++ b/Android/G3MAndroidSDK/AndroidManifest.xml @@ -6,18 +6,4 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/Android/G3MAndroidSDK/src/org/glob3/mobile/specific/ES2Renderer.java b/Android/G3MAndroidSDK/src/org/glob3/mobile/specific/ES2Renderer.java index 01aa480640..04d779a47f 100644 --- a/Android/G3MAndroidSDK/src/org/glob3/mobile/specific/ES2Renderer.java +++ b/Android/G3MAndroidSDK/src/org/glob3/mobile/specific/ES2Renderer.java @@ -62,29 +62,28 @@ public void onDrawFrame(final GL10 glUnused) { final G3MWidget widget = _widgetAndroid.getG3MWidget(); widget.render(_width, _height); - // experimental FPS reduction - DGD - final long now = System.currentTimeMillis(); - final long timeElapsedInRender = now - _startTime; - final long timeLeftInMS = GOAL_MS_PER_FRAME - timeElapsedInRender; - if (timeLeftInMS > 0) { - // System.gc(); - // - // timeElapsedInRender = System.currentTimeMillis() - _startTime; - // timeLeftInMS = GOAL_MS_PER_FRAME - timeElapsedInRender; - // if (timeLeftInMS > 0) { - try { - //ILogger.instance().logInfo("**** sleeping OpenGL thread for " + timeLeftInMS + "ms"); - Thread.sleep(timeLeftInMS); + if (!_widgetAndroid.getNoFPSReduction()) { + // experimental FPS reduction - DGD + final long now = System.currentTimeMillis(); + final long timeElapsedInRender = now - _startTime; + final long timeLeftInMS = GOAL_MS_PER_FRAME - timeElapsedInRender; + if (timeLeftInMS > 0) { + // System.gc(); + // + // timeElapsedInRender = System.currentTimeMillis() - _startTime; + // timeLeftInMS = GOAL_MS_PER_FRAME - timeElapsedInRender; + // if (timeLeftInMS > 0) { + try { + //ILogger.instance().logInfo("**** sleeping OpenGL thread for " + timeLeftInMS + "ms"); + Thread.sleep(timeLeftInMS); + } catch (final InterruptedException e) { + } + // } + _startTime = System.currentTimeMillis(); + } else { + _startTime = now; } - catch (final InterruptedException e) { - } - // } - _startTime = System.currentTimeMillis(); - } - else { - _startTime = now; } - } diff --git a/Android/G3MAndroidSDK/src/org/glob3/mobile/specific/G3MBuilder_Android.java b/Android/G3MAndroidSDK/src/org/glob3/mobile/specific/G3MBuilder_Android.java index 0b37e865a0..d2e3d8a883 100644 --- a/Android/G3MAndroidSDK/src/org/glob3/mobile/specific/G3MBuilder_Android.java +++ b/Android/G3MAndroidSDK/src/org/glob3/mobile/specific/G3MBuilder_Android.java @@ -19,11 +19,10 @@ public class G3MBuilder_Android private final G3MWidget_Android _nativeWidget; - - public G3MBuilder_Android(final Context context) { + public G3MBuilder_Android(final Context context, final boolean noFPSReduction) { super(); - _nativeWidget = new G3MWidget_Android(context); + _nativeWidget = new G3MWidget_Android(context, noFPSReduction); } @@ -91,6 +90,4 @@ protected IDownloader createDefaultDownloader() { getStorage(), // saveInBackground); } - - } diff --git a/Android/G3MAndroidSDK/src/org/glob3/mobile/specific/G3MWidget_Android.java b/Android/G3MAndroidSDK/src/org/glob3/mobile/specific/G3MWidget_Android.java index 2adfed7374..2f20b36831 100644 --- a/Android/G3MAndroidSDK/src/org/glob3/mobile/specific/G3MWidget_Android.java +++ b/Android/G3MAndroidSDK/src/org/glob3/mobile/specific/G3MWidget_Android.java @@ -61,7 +61,7 @@ public final class G3MWidget_Android private final OnDoubleTapListener _doubleTapListener; private final GestureDetector _gestureDetector; private Thread _openGLThread = null; - + private final boolean _noFPSReduction; public G3MWidget_Android(final android.content.Context context) { this(context, null); @@ -83,11 +83,22 @@ public final void checkOpenGLThread() { } } + public G3MWidget_Android(final android.content.Context context, + final boolean noFPSReduction) { + this(context, null, noFPSReduction); + } // Needed to create widget from XML layout public G3MWidget_Android(final android.content.Context context, - final AttributeSet attrs) { + final AttributeSet attrs) { + this(context, attrs, false); + } + + public G3MWidget_Android(final android.content.Context context, + final AttributeSet attrs, + final boolean noFPSReduction) { super(context, attrs); + _noFPSReduction = noFPSReduction; initSingletons(); @@ -453,5 +464,7 @@ public G3MContext getG3MContext() { return getG3MWidget().getG3MContext(); } - + public boolean getNoFPSReduction() { + return _noFPSReduction; + } } From 41f9c2cf19988c7004e1c0294a0bfe187ab0ba1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=A9meth=20=C3=81d=C3=A1m?= Date: Tue, 10 Nov 2015 14:25:45 +0100 Subject: [PATCH 05/43] fixed character which causes issue in generated source on android studio on windows --- iOS/G3MiOSSDK/Commons/Geometry/Vector2D.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iOS/G3MiOSSDK/Commons/Geometry/Vector2D.cpp b/iOS/G3MiOSSDK/Commons/Geometry/Vector2D.cpp index a41d1ce047..878409ac7f 100644 --- a/iOS/G3MiOSSDK/Commons/Geometry/Vector2D.cpp +++ b/iOS/G3MiOSSDK/Commons/Geometry/Vector2D.cpp @@ -32,7 +32,7 @@ const std::string Vector2D::description() const { Vector2D Vector2D::intersectionOfTwoLines(const Vector2D& p1, const Vector2D& r1, const Vector2D& p2, const Vector2D& r2) { - //u = (p2 − p1) × r1 / (r1 × r2) + //u = (p2 - p1) × r1 / (r1 × r2) //out = p2 + u x r2 double u = ((p2.sub(p1)).dot(r1)) / r1.dot(r2); From 1710d355797ca4294bd550e515f0d39bdce827b9 Mon Sep 17 00:00:00 2001 From: aldeanueva Date: Tue, 10 Nov 2015 14:30:12 +0100 Subject: [PATCH 06/43] Generated --- .../G3MSharedSDK/src/org/glob3/mobile/generated/Vector2D.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/Vector2D.java b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/Vector2D.java index daf879eaf7..757e0cfd2c 100644 --- a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/Vector2D.java +++ b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/Vector2D.java @@ -156,7 +156,7 @@ public String toString() { public static Vector2D intersectionOfTwoLines(Vector2D p1, Vector2D r1, Vector2D p2, Vector2D r2) { - //u = (p2 − p1) × r1 / (r1 × r2) + //u = (p2 - p1) × r1 / (r1 × r2) //out = p2 + u x r2 double u = ((p2.sub(p1)).dot(r1)) / r1.dot(r2); From c83e3f6e0c5baa985a52300ed03237299f20f289 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=A9meth=20=C3=81d=C3=A1m?= Date: Thu, 12 Nov 2015 15:22:11 +0100 Subject: [PATCH 07/43] added custom GL shader feature --- iOS/G3MiOSSDK/Commons/GL/GLFeature.hpp | 23 ++++++++++++++++++- iOS/G3MiOSSDK/Commons/GL/GLState.cpp | 11 +++++---- .../Commons/GL/GPUProgramManager.cpp | 20 ++++++++++++++++ .../Commons/GL/GPUProgramManager.hpp | 2 ++ .../Commons/GL/GPUVariableValueSet.hpp | 12 ++++++++++ 5 files changed, 63 insertions(+), 5 deletions(-) diff --git a/iOS/G3MiOSSDK/Commons/GL/GLFeature.hpp b/iOS/G3MiOSSDK/Commons/GL/GLFeature.hpp index 3779a1e433..324f400bf8 100644 --- a/iOS/G3MiOSSDK/Commons/GL/GLFeature.hpp +++ b/iOS/G3MiOSSDK/Commons/GL/GLFeature.hpp @@ -33,7 +33,8 @@ enum GLFeatureID{ GLF_DIRECTION_LIGTH, GLF_VERTEX_NORMAL, GLF_MODEL_VIEW, - GLF_BLENDING_MODE + GLF_BLENDING_MODE, + GLF_CUSTOM_SHADER }; class GLFeature: public RCObject { @@ -578,5 +579,25 @@ class VertexNormalGLFeature: public GLFeature { void applyOnGlobalGLState(GLGlobalState* state) const {} }; +class CustomShaderGLFeature: public GLFeature { +private: + const std::string _shaderName; + + ~CustomShaderGLFeature() { +#ifdef JAVA_CODE + super.dispose(); +#endif + } + +public: + CustomShaderGLFeature(const std::string shaderName) : + GLFeature(NO_GROUP, GLF_CUSTOM_SHADER), + _shaderName(shaderName) + { + _values->setCustomShaderName(shaderName); + } + + void applyOnGlobalGLState(GLGlobalState* state) const {} +}; #endif diff --git a/iOS/G3MiOSSDK/Commons/GL/GLState.cpp b/iOS/G3MiOSSDK/Commons/GL/GLState.cpp index 6cc346172c..4f4eefbf2b 100644 --- a/iOS/G3MiOSSDK/Commons/GL/GLState.cpp +++ b/iOS/G3MiOSSDK/Commons/GL/GLState.cpp @@ -111,10 +111,13 @@ void GLState::applyOnGPU(GL* gl, GPUProgramManager& progManager) const { GLFeatureGroup::applyToAllGroups(*accumulatedFeatures, *_valuesSet, *_globalState); - const int uniformsCode = _valuesSet->getUniformsCode(); - const int attributesCode = _valuesSet->getAttributesCode(); - - _linkedProgram = progManager.getProgram(gl, uniformsCode, attributesCode); //GET RETAINED REFERENCE + if (_valuesSet->hasCustomShader()) { + _linkedProgram = progManager.getProgram(gl, _valuesSet->getCustomShaderName()); + } else { + const int uniformsCode = _valuesSet->getUniformsCode(); + const int attributesCode = _valuesSet->getAttributesCode(); + _linkedProgram = progManager.getProgram(gl, uniformsCode, attributesCode); //GET RETAINED REFERENCE + } } if (_valuesSet == NULL || _globalState == NULL) { diff --git a/iOS/G3MiOSSDK/Commons/GL/GPUProgramManager.cpp b/iOS/G3MiOSSDK/Commons/GL/GPUProgramManager.cpp index 8be5030184..1ac0f27af1 100644 --- a/iOS/G3MiOSSDK/Commons/GL/GPUProgramManager.cpp +++ b/iOS/G3MiOSSDK/Commons/GL/GPUProgramManager.cpp @@ -41,6 +41,26 @@ GPUProgram* GPUProgramManager::getProgram(GL* gl, int uniformsCode, int attribut return p; } +GPUProgram* GPUProgramManager::getProgram(GL* gl, const std::string& name) { + GPUProgram* p = getCompiledProgram(name); + if (p == NULL) { + p = compileProgramWithName(gl, name); + if (p == NULL) { + ILogger::instance()->logError("Problem at compiling program."); + return NULL; + } + + if (p->getName() != name) { + //#warning GIVE MORE DETAIL + ILogger::instance()->logError("New compiled program does not match GL state."); + } + } + + p->addReference(); + + return p; +} + GPUProgram* GPUProgramManager::getNewProgram(GL* gl, int uniformsCode, int attributesCode) { const bool texture = GPUVariable::hasAttribute(attributesCode, TEXTURE_COORDS); diff --git a/iOS/G3MiOSSDK/Commons/GL/GPUProgramManager.hpp b/iOS/G3MiOSSDK/Commons/GL/GPUProgramManager.hpp index 970350046c..990104c37d 100644 --- a/iOS/G3MiOSSDK/Commons/GL/GPUProgramManager.hpp +++ b/iOS/G3MiOSSDK/Commons/GL/GPUProgramManager.hpp @@ -37,6 +37,8 @@ class GPUProgramManager { GPUProgram* getProgram(GL* gl, int uniformsCode, int attributesCode); + GPUProgram* getProgram(GL* gl, const std::string& name); + void removeUnused(); }; diff --git a/iOS/G3MiOSSDK/Commons/GL/GPUVariableValueSet.hpp b/iOS/G3MiOSSDK/Commons/GL/GPUVariableValueSet.hpp index 5f52ff80de..0706cffc53 100644 --- a/iOS/G3MiOSSDK/Commons/GL/GPUVariableValueSet.hpp +++ b/iOS/G3MiOSSDK/Commons/GL/GPUVariableValueSet.hpp @@ -21,6 +21,7 @@ class GPUVariableValueSet { mutable int _uniformsCode; mutable int _attributeCode; + mutable std::string _customShaderName; GPUVariableValueSet(const GPUVariableValueSet& that); GPUVariableValueSet& operator=(const GPUVariableValueSet& that); @@ -133,6 +134,17 @@ class GPUVariableValueSet { int getAttributesCode() const; + bool hasCustomShader() const { + return !_customShaderName.empty(); + } + + void setCustomShaderName(const std::string& name) { + _customShaderName = name; + } + + const std::string& getCustomShaderName() const { + return _customShaderName; + } }; #endif From 6e3aef03b247330e4bbbeebc0b9ed070f64ad538 Mon Sep 17 00:00:00 2001 From: aldeanueva Date: Thu, 12 Nov 2015 15:30:25 +0100 Subject: [PATCH 08/43] Generated --- .../generated/CustomShaderGLFeature.java | 21 ++++++++++++++++ .../glob3/mobile/generated/GLFeatureID.java | 3 ++- .../org/glob3/mobile/generated/GLState.java | 14 +++++++---- .../mobile/generated/GPUProgramManager.java | 24 +++++++++++++++++++ .../mobile/generated/GPUVariableValueSet.java | 15 ++++++++++++ 5 files changed, 72 insertions(+), 5 deletions(-) create mode 100644 Commons/G3MSharedSDK/src/org/glob3/mobile/generated/CustomShaderGLFeature.java diff --git a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/CustomShaderGLFeature.java b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/CustomShaderGLFeature.java new file mode 100644 index 0000000000..5faab1fc72 --- /dev/null +++ b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/CustomShaderGLFeature.java @@ -0,0 +1,21 @@ +package org.glob3.mobile.generated; +public class CustomShaderGLFeature extends GLFeature +{ + private final String _shaderName; + + public void dispose() + { + super.dispose(); + } + + public CustomShaderGLFeature(String shaderName) + { + super(GLFeatureGroupName.NO_GROUP, GLFeatureID.GLF_CUSTOM_SHADER); + _shaderName = shaderName; + _values.setCustomShaderName(shaderName); + } + + public final void applyOnGlobalGLState(GLGlobalState state) + { + } +} \ No newline at end of file diff --git a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GLFeatureID.java b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GLFeatureID.java index 8db3b31fcf..f0c9654471 100644 --- a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GLFeatureID.java +++ b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GLFeatureID.java @@ -36,7 +36,8 @@ public enum GLFeatureID GLF_DIRECTION_LIGTH, GLF_VERTEX_NORMAL, GLF_MODEL_VIEW, - GLF_BLENDING_MODE; + GLF_BLENDING_MODE, + GLF_CUSTOM_SHADER; public int getValue() { diff --git a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GLState.java b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GLState.java index 5fbac1d5cb..5c3dc6005b 100644 --- a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GLState.java +++ b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GLState.java @@ -172,10 +172,16 @@ public final void applyOnGPU(GL gl, GPUProgramManager progManager) GLFeatureGroup.applyToAllGroups(accumulatedFeatures, _valuesSet, _globalState); - final int uniformsCode = _valuesSet.getUniformsCode(); - final int attributesCode = _valuesSet.getAttributesCode(); - - _linkedProgram = progManager.getProgram(gl, uniformsCode, attributesCode); //GET RETAINED REFERENCE + if (_valuesSet.hasCustomShader()) + { + _linkedProgram = progManager.getProgram(gl, _valuesSet.getCustomShaderName()); + } + else + { + final int uniformsCode = _valuesSet.getUniformsCode(); + final int attributesCode = _valuesSet.getAttributesCode(); + _linkedProgram = progManager.getProgram(gl, uniformsCode, attributesCode); //GET RETAINED REFERENCE + } } if (_valuesSet == null || _globalState == null) diff --git a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUProgramManager.java b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUProgramManager.java index 6f83c6ac67..16cd676825 100644 --- a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUProgramManager.java +++ b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUProgramManager.java @@ -207,6 +207,30 @@ public final GPUProgram getProgram(GL gl, int uniformsCode, int attributesCode) return p; } + public final GPUProgram getProgram(GL gl, String name) + { + GPUProgram p = getCompiledProgram(name); + if (p == null) + { + p = compileProgramWithName(gl, name); + if (p == null) + { + ILogger.instance().logError("Problem at compiling program."); + return null; + } + + if (!name.equals(p.getName())) + { + ///#warning GIVE MORE DETAIL + ILogger.instance().logError("New compiled program does not match GL state."); + } + } + + p.addReference(); + + return p; + } + public final void removeUnused() { final java.util.Iterator> iterator = _programs.entrySet().iterator(); diff --git a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUVariableValueSet.java b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUVariableValueSet.java index 8a6ac7f355..aa43b64726 100644 --- a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUVariableValueSet.java +++ b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUVariableValueSet.java @@ -26,6 +26,7 @@ public class GPUVariableValueSet private int _uniformsCode; private int _attributeCode; + private String _customShaderName; //C++ TO JAVA CONVERTER TODO TASK: The implementation of the following method could not be found: // GPUVariableValueSet(GPUVariableValueSet that); @@ -219,4 +220,18 @@ public final int getAttributesCode() return _attributeCode; } + public final boolean hasCustomShader() + { + return !_customShaderName.length() == 0; + } + + public final void setCustomShaderName(String name) + { + _customShaderName = name; + } + + public final String getCustomShaderName() + { + return _customShaderName; + } } \ No newline at end of file From 417156c772c79a4c5ab6ea4841639a9a3c872801 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=A9meth=20=C3=81d=C3=A1m?= Date: Thu, 12 Nov 2015 15:55:18 +0100 Subject: [PATCH 09/43] fix string empty check --- iOS/G3MiOSSDK/Commons/GL/GPUVariableValueSet.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iOS/G3MiOSSDK/Commons/GL/GPUVariableValueSet.hpp b/iOS/G3MiOSSDK/Commons/GL/GPUVariableValueSet.hpp index 0706cffc53..857dc61974 100644 --- a/iOS/G3MiOSSDK/Commons/GL/GPUVariableValueSet.hpp +++ b/iOS/G3MiOSSDK/Commons/GL/GPUVariableValueSet.hpp @@ -135,7 +135,7 @@ class GPUVariableValueSet { int getAttributesCode() const; bool hasCustomShader() const { - return !_customShaderName.empty(); + return (_customShaderName.length() != 0); } void setCustomShaderName(const std::string& name) { From dd287c40cfa1469f953f893ccb5378f2317173d6 Mon Sep 17 00:00:00 2001 From: aldeanueva Date: Thu, 12 Nov 2015 16:02:50 +0100 Subject: [PATCH 10/43] Generated --- .../src/org/glob3/mobile/generated/GPUVariableValueSet.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUVariableValueSet.java b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUVariableValueSet.java index aa43b64726..dfbe71f236 100644 --- a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUVariableValueSet.java +++ b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUVariableValueSet.java @@ -222,7 +222,7 @@ public final int getAttributesCode() public final boolean hasCustomShader() { - return !_customShaderName.length() == 0; + return (_customShaderName.length() != 0); } public final void setCustomShaderName(String name) From a636407a009bb57c0d665c67bb62c4d5ba23fccd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=A9meth=20=C3=81d=C3=A1m?= Date: Fri, 13 Nov 2015 10:10:06 +0100 Subject: [PATCH 11/43] fixed string default value --- iOS/G3MiOSSDK/Commons/GL/GPUVariableValueSet.hpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/iOS/G3MiOSSDK/Commons/GL/GPUVariableValueSet.hpp b/iOS/G3MiOSSDK/Commons/GL/GPUVariableValueSet.hpp index 857dc61974..c4e3f70a17 100644 --- a/iOS/G3MiOSSDK/Commons/GL/GPUVariableValueSet.hpp +++ b/iOS/G3MiOSSDK/Commons/GL/GPUVariableValueSet.hpp @@ -32,7 +32,8 @@ class GPUVariableValueSet { _highestAttributeKey(0), _highestUniformKey(0), _uniformsCode(0), - _attributeCode(0) { + _attributeCode(0), + _customShaderName("") { for (int i = 0; i < 32; i++) { _uniformValues[i] = NULL; _attributeValues[i] = NULL; @@ -142,7 +143,7 @@ class GPUVariableValueSet { _customShaderName = name; } - const std::string& getCustomShaderName() const { + const std::string getCustomShaderName() const { return _customShaderName; } }; From 8f5e3d47b717c3bf804fcaac6a5801beeb0b7d29 Mon Sep 17 00:00:00 2001 From: aldeanueva Date: Fri, 13 Nov 2015 10:14:22 +0100 Subject: [PATCH 12/43] Generated --- .../src/org/glob3/mobile/generated/GPUVariableValueSet.java | 1 + 1 file changed, 1 insertion(+) diff --git a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUVariableValueSet.java b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUVariableValueSet.java index dfbe71f236..a2ea02de1b 100644 --- a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUVariableValueSet.java +++ b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUVariableValueSet.java @@ -40,6 +40,7 @@ public GPUVariableValueSet() _highestUniformKey = 0; _uniformsCode = 0; _attributeCode = 0; + _customShaderName = ""; for (int i = 0; i < 32; i++) { _uniformValues[i] = null; From 5f2a79908aa0ac0dffd147916f83f94977d88302 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=A9meth=20=C3=81d=C3=A1m?= Date: Tue, 17 Nov 2015 13:55:20 +0100 Subject: [PATCH 13/43] more changes for custom shader support --- iOS/G3MiOSSDK/Commons/GL/GLFeature.hpp | 4 +--- iOS/G3MiOSSDK/Commons/GL/GPUProgram.cpp | 4 ++-- iOS/G3MiOSSDK/Commons/GL/GPUVariableValueSet.cpp | 4 ++++ 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/iOS/G3MiOSSDK/Commons/GL/GLFeature.hpp b/iOS/G3MiOSSDK/Commons/GL/GLFeature.hpp index 324f400bf8..1406323ecf 100644 --- a/iOS/G3MiOSSDK/Commons/GL/GLFeature.hpp +++ b/iOS/G3MiOSSDK/Commons/GL/GLFeature.hpp @@ -581,7 +581,6 @@ class VertexNormalGLFeature: public GLFeature { class CustomShaderGLFeature: public GLFeature { private: - const std::string _shaderName; ~CustomShaderGLFeature() { #ifdef JAVA_CODE @@ -591,8 +590,7 @@ class CustomShaderGLFeature: public GLFeature { public: CustomShaderGLFeature(const std::string shaderName) : - GLFeature(NO_GROUP, GLF_CUSTOM_SHADER), - _shaderName(shaderName) + GLFeature(NO_GROUP, GLF_CUSTOM_SHADER) { _values->setCustomShaderName(shaderName); } diff --git a/iOS/G3MiOSSDK/Commons/GL/GPUProgram.cpp b/iOS/G3MiOSSDK/Commons/GL/GPUProgram.cpp index adda1a0326..ec474c9719 100644 --- a/iOS/G3MiOSSDK/Commons/GL/GPUProgram.cpp +++ b/iOS/G3MiOSSDK/Commons/GL/GPUProgram.cpp @@ -54,7 +54,7 @@ GPUProgram* GPUProgram::createProgram(GL* gl, // link program if (!p->linkProgram(gl)) { - ILogger::instance()->logError("GPUProgram: ERROR linking graphic program\n"); + ILogger::instance()->logError("GPUProgram: ERROR linking graphic program: %s\n", name.c_str()); p->deleteShader(gl, vertexShader); p->deleteShader(gl, fragmentShader); p->deleteProgram(gl, p); @@ -69,7 +69,7 @@ GPUProgram* GPUProgram::createProgram(GL* gl, p->getVariables(gl); if (gl->getError() != GLError::noError()) { - ILogger::instance()->logError("Error while compiling program"); + ILogger::instance()->logError("Error while compiling program: %s\n", name.c_str()); } return p; diff --git a/iOS/G3MiOSSDK/Commons/GL/GPUVariableValueSet.cpp b/iOS/G3MiOSSDK/Commons/GL/GPUVariableValueSet.cpp index 07f8bd0913..300ade1319 100644 --- a/iOS/G3MiOSSDK/Commons/GL/GPUVariableValueSet.cpp +++ b/iOS/G3MiOSSDK/Commons/GL/GPUVariableValueSet.cpp @@ -28,6 +28,10 @@ void GPUVariableValueSet::combineWith(const GPUVariableValueSet* vs) { } } } + + if (vs->hasCustomShader()) { + _customShaderName = vs->getCustomShaderName(); + } } void GPUVariableValueSet::applyValuesToProgram(GPUProgram* prog) const { From 1e54d801b91aca2acde9af34ce426c70a88c82f4 Mon Sep 17 00:00:00 2001 From: aldeanueva Date: Tue, 17 Nov 2015 13:58:54 +0100 Subject: [PATCH 14/43] Generated --- .../org/glob3/mobile/generated/CustomShaderGLFeature.java | 2 -- .../src/org/glob3/mobile/generated/GPUProgram.java | 4 ++-- .../src/org/glob3/mobile/generated/GPUVariableValueSet.java | 5 +++++ 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/CustomShaderGLFeature.java b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/CustomShaderGLFeature.java index 5faab1fc72..aea77757ab 100644 --- a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/CustomShaderGLFeature.java +++ b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/CustomShaderGLFeature.java @@ -1,7 +1,6 @@ package org.glob3.mobile.generated; public class CustomShaderGLFeature extends GLFeature { - private final String _shaderName; public void dispose() { @@ -11,7 +10,6 @@ public void dispose() public CustomShaderGLFeature(String shaderName) { super(GLFeatureGroupName.NO_GROUP, GLFeatureID.GLF_CUSTOM_SHADER); - _shaderName = shaderName; _values.setCustomShaderName(shaderName); } diff --git a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUProgram.java b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUProgram.java index 4ed37c94cf..e90f49cb56 100644 --- a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUProgram.java +++ b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUProgram.java @@ -205,7 +205,7 @@ public static GPUProgram createProgram(GL gl, String name, String vertexSource, // link program if (!p.linkProgram(gl)) { - ILogger.instance().logError("GPUProgram: ERROR linking graphic program\n"); + ILogger.instance().logError("GPUProgram: ERROR linking graphic program: %s\n", name); p.deleteShader(gl, vertexShader); p.deleteShader(gl, fragmentShader); p.deleteProgram(gl, p); @@ -221,7 +221,7 @@ public static GPUProgram createProgram(GL gl, String name, String vertexSource, if (gl.getError() != GLError.noError()) { - ILogger.instance().logError("Error while compiling program"); + ILogger.instance().logError("Error while compiling program: %s\n", name); } return p; diff --git a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUVariableValueSet.java b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUVariableValueSet.java index a2ea02de1b..6c36d512bb 100644 --- a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUVariableValueSet.java +++ b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUVariableValueSet.java @@ -168,6 +168,11 @@ public final void combineWith(GPUVariableValueSet vs) } } } + + if (vs.hasCustomShader()) + { + _customShaderName = vs.getCustomShaderName(); + } } public final void applyValuesToProgram(GPUProgram prog) From 96dfc72bb1f303d8064466ec66c330d0ffdca10a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=A9meth=20=C3=81d=C3=A1m?= Date: Mon, 30 Nov 2015 16:11:58 +0100 Subject: [PATCH 15/43] added ability to the android sql cache store to be able to contain bigger data files by saving them separately and saving a pointer into the database --- .../specific/SQLiteStorage_Android.java | 154 +++++++++++++++--- 1 file changed, 133 insertions(+), 21 deletions(-) diff --git a/Android/G3MAndroidSDK/src/org/glob3/mobile/specific/SQLiteStorage_Android.java b/Android/G3MAndroidSDK/src/org/glob3/mobile/specific/SQLiteStorage_Android.java index 68d57b336c..08405c3dfe 100644 --- a/Android/G3MAndroidSDK/src/org/glob3/mobile/specific/SQLiteStorage_Android.java +++ b/Android/G3MAndroidSDK/src/org/glob3/mobile/specific/SQLiteStorage_Android.java @@ -2,8 +2,13 @@ package org.glob3.mobile.specific; -import java.io.ByteArrayOutputStream; -import java.io.File; +import android.content.ContentValues; +import android.database.Cursor; +import android.database.sqlite.SQLiteDatabase; +import android.database.sqlite.SQLiteOpenHelper; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.util.Log; import org.glob3.mobile.generated.G3MContext; import org.glob3.mobile.generated.GTask; @@ -16,19 +21,23 @@ import org.glob3.mobile.generated.TimeInterval; import org.glob3.mobile.generated.URL; -import android.content.ContentValues; -import android.database.Cursor; -import android.database.sqlite.SQLiteDatabase; -import android.database.sqlite.SQLiteOpenHelper; -import android.graphics.Bitmap; -import android.graphics.BitmapFactory; -import android.util.Log; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.nio.charset.Charset; public final class SQLiteStorage_Android extends IStorage { + private static final long DB_RAW_DATA_EXTERNAL_THRESHOLD = 1024 * 1024; // 1 MiB + private static final String DB_EXTERNAL_TAG = "EXT:"; + private static final Charset UTF8 = Charset.forName("UTF-8"); + private static final String[] COLUMNS = new String[] { "contents", "expiration" }; private static final String SELECTION = "name = ?"; @@ -41,6 +50,7 @@ public final class SQLiteStorage_Android private final BitmapFactory.Options _options; private final byte[] _temp_storage = new byte[128 * 1024]; + private final String _documentsDirectory; private class MySQLiteOpenHelper @@ -81,13 +91,7 @@ public void onUpgrade(final SQLiteDatabase db, private String getPath() { - File f = _androidContext.getExternalCacheDir(); - if ((f == null) || !f.exists()) { - f = _androidContext.getCacheDir(); - } - final String documentsDirectory = f.getAbsolutePath(); - - final File f2 = new File(new File(documentsDirectory), _databaseName); + final File f2 = new File(new File(_documentsDirectory), _databaseName); final String path = f2.getAbsolutePath(); Log.d("SQLiteStorage_Android", "Creating DB in " + path); @@ -98,8 +102,14 @@ private String getPath() { public SQLiteStorage_Android(final String path, final android.content.Context context) { + _androidContext = context; + File f = _androidContext.getExternalCacheDir(); + if ((f == null) || !f.exists()) { + f = _androidContext.getCacheDir(); + } + _documentsDirectory = f.getAbsolutePath(); + _databaseName = path; - _androidContext = context; _dbHelper = new MySQLiteOpenHelper(context, getPath()); _writeDB = _dbHelper.getWritableDatabase(); @@ -135,14 +145,74 @@ public void run(final G3MContext context) { } } + private boolean writeFileToCacheFolder(final String fileName, final byte[] content) { + final File f2 = new File(new File(_documentsDirectory), fileName); + FileOutputStream fout = null; + try { + fout = new FileOutputStream(f2); + fout.write(content); + fout.flush(); + return true; + } catch (FileNotFoundException e) { + e.printStackTrace(); + return false; + } catch (IOException e) { + e.printStackTrace(); + return false; + } finally { + if (fout != null) { + try { + fout.close(); + } catch (IOException e1) { + e1.printStackTrace(); + } + } + } + } + + private byte[] readFileFromCacheFolder(final String fileName) { + final File f2 = new File(new File(_documentsDirectory), fileName); + FileInputStream fin = null; + try { + fin = new FileInputStream(f2); + final int avail = fin.available(); + if (avail == 0) { + return null; + } + final byte[] r = new byte[avail]; + if (fin.read(r) != avail) { + return null; + } + return r; + } catch (FileNotFoundException e) { + e.printStackTrace(); + return null; + } catch (IOException e) { + e.printStackTrace(); + return null; + } finally { + if (fin != null) { + try { + fin.close(); + } catch (IOException e1) { + e1.printStackTrace(); + } + } + } + } private synchronized void rawSave(final String table, final String name, final byte[] contents, final TimeInterval timeToExpires) { + + final boolean external = contents.length >= DB_RAW_DATA_EXTERNAL_THRESHOLD; + final String externalFileName = external ? (table + name).hashCode() + ".raw_cache" : null; + final ContentValues values = new ContentValues(3); values.put("name", name); - values.put("contents", contents); + values.put("contents", + external ? (DB_EXTERNAL_TAG + externalFileName).getBytes(UTF8) : contents); final long expiration = System.currentTimeMillis() + timeToExpires.milliseconds(); values.put("expiration", Long.toString(expiration)); @@ -150,6 +220,13 @@ private synchronized void rawSave(final String table, ILogger.instance().logError("SQL: Can't write " + table + " in database \"%s\". _writeDB not available\n", _databaseName); } else { + if (external) { + if (!writeFileToCacheFolder(externalFileName, contents)) { + ILogger.instance().logError("SQL: Can't write external file for cache \"%s\"\n", name); + return; + } + } + final long rowID = _writeDB.insertWithOnConflict(table, null, values, SQLiteDatabase.CONFLICT_REPLACE); if (rowID == -1) { ILogger.instance().logError("SQL: Can't write " + table + " in database \"%s\"\n", _databaseName); @@ -165,7 +242,7 @@ public IByteBufferResult readBuffer(final URL url, boolean expired = false; final String name = url._path; - final Cursor cursor = _readDB.query( // + final Cursor cursor = _readDB.query( // "buffer2", // COLUMNS, // SELECTION, // @@ -180,7 +257,23 @@ public IByteBufferResult readBuffer(final URL url, expired = (expirationInterval <= System.currentTimeMillis()); if (!expired || readExpired) { - buffer = new ByteBuffer_Android(data); + if (data.length > DB_EXTERNAL_TAG.length()) { + final String extTag = new String(data, 0, DB_EXTERNAL_TAG.length(), UTF8); + if (!extTag.isEmpty() && DB_EXTERNAL_TAG.equalsIgnoreCase(extTag)) { + final byte[] cacheData = readFileFromCacheFolder( + new String(data, DB_EXTERNAL_TAG.length(), data.length - DB_EXTERNAL_TAG.length(), UTF8)); + if (cacheData == null || cacheData.length == 0) { + ILogger.instance() + .logError("SQL: Can't read external file for cache \"%s\"\n", name); + cursor.close(); + return new IByteBufferResult(null, expired); + } + buffer = new ByteBuffer_Android(cacheData); + } + } + if (buffer == null) { + buffer = new ByteBuffer_Android(data); + } } } cursor.close(); @@ -251,8 +344,27 @@ public IImageResult readImage(final URL url, expired = (expirationInterval <= System.currentTimeMillis()); if (!expired || readExpired) { + Bitmap bitmap = null; + + if (data.length > DB_EXTERNAL_TAG.length()) { + final String extTag = new String(data, 0, DB_EXTERNAL_TAG.length(), UTF8); + if (!extTag.isEmpty() && DB_EXTERNAL_TAG.equalsIgnoreCase(extTag)) { + final byte[] cacheData = readFileFromCacheFolder( + new String(data, DB_EXTERNAL_TAG.length(), data.length - DB_EXTERNAL_TAG.length(), UTF8)); + if (cacheData == null || cacheData.length == 0) { + ILogger.instance() + .logError("SQL: Can't read external file for cache \"%s\"\n", name); + cursor.close(); + return new IImageResult(null, expired); + } + bitmap = BitmapFactory.decodeByteArray(cacheData, 0, cacheData.length, _options); + } + } + // final long start = System.currentTimeMillis(); - final Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, data.length, _options); + if (bitmap == null) { + bitmap = BitmapFactory.decodeByteArray(data, 0, data.length, _options); + } // ILogger.instance().logInfo("CACHE: Bitmap parsed in " + (System.currentTimeMillis() - start) + "ms"); if (bitmap == null) { From 1562a2c74743763439bf3fa7bd32aa6eca06a572 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=A9meth=20=C3=81d=C3=A1m?= Date: Wed, 2 Dec 2015 10:28:39 +0100 Subject: [PATCH 16/43] added hooks to be able to handle custom shader's attributes and uniforms from a gl feature --- iOS/G3MiOSSDK/Commons/GL/GLFeature.hpp | 15 +++++++++++++-- iOS/G3MiOSSDK/Commons/GL/GLState.cpp | 5 +++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/iOS/G3MiOSSDK/Commons/GL/GLFeature.hpp b/iOS/G3MiOSSDK/Commons/GL/GLFeature.hpp index 1406323ecf..56e75847af 100644 --- a/iOS/G3MiOSSDK/Commons/GL/GLFeature.hpp +++ b/iOS/G3MiOSSDK/Commons/GL/GLFeature.hpp @@ -581,6 +581,7 @@ class VertexNormalGLFeature: public GLFeature { class CustomShaderGLFeature: public GLFeature { private: + bool _initializedShader; ~CustomShaderGLFeature() { #ifdef JAVA_CODE @@ -590,12 +591,22 @@ class CustomShaderGLFeature: public GLFeature { public: CustomShaderGLFeature(const std::string shaderName) : - GLFeature(NO_GROUP, GLF_CUSTOM_SHADER) + GLFeature(NO_GROUP, GLF_CUSTOM_SHADER), _initializedShader(false) { _values->setCustomShaderName(shaderName); } - void applyOnGlobalGLState(GLGlobalState* state) const {} + virtual bool onInitializeShader(const GL* gl, const GLState* state, const GPUProgram* linkedProgram)=0; + virtual void onAfterApplyShaderOnGPU(const GL* gl, const GLState* state, const GPUProgram* linkedProgram)=0; + + void afterApplyOnGPU(const GL* gl, const GLState* state, const GPUProgram* linkedProgram) { + if (!_initializedShader) { + _initializedShader = onInitializeShader(gl, state, linkedProgram); + } + if (_initializedShader) { + onAfterApplyShaderOnGPU(gl, state, linkedProgram); + } + } }; #endif diff --git a/iOS/G3MiOSSDK/Commons/GL/GLState.cpp b/iOS/G3MiOSSDK/Commons/GL/GLState.cpp index 4f4eefbf2b..417c420448 100644 --- a/iOS/G3MiOSSDK/Commons/GL/GLState.cpp +++ b/iOS/G3MiOSSDK/Commons/GL/GLState.cpp @@ -133,6 +133,11 @@ void GLState::applyOnGPU(GL* gl, GPUProgramManager& progManager) const { _linkedProgram->applyChanges(gl); + CustomShaderGLFeature* feature = (CustomShaderGLFeature*) getGLFeature(GLF_CUSTOM_SHADER); + if (feature) { + feature->afterApplyOnGPU(gl, this, _linkedProgram); + } + //prog->onUnused(); //Uncomment to check that all GPUProgramStates are complete } else { From e15c543d89fdf12062e9bf71d29427ab424dd593 Mon Sep 17 00:00:00 2001 From: aldeanueva Date: Wed, 2 Dec 2015 10:38:57 +0100 Subject: [PATCH 17/43] Generated --- .../mobile/generated/CustomShaderGLFeature.java | 17 +++++++++++++++-- .../src/org/glob3/mobile/generated/GLState.java | 6 ++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/CustomShaderGLFeature.java b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/CustomShaderGLFeature.java index aea77757ab..7b6f7e0dc8 100644 --- a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/CustomShaderGLFeature.java +++ b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/CustomShaderGLFeature.java @@ -1,6 +1,7 @@ package org.glob3.mobile.generated; -public class CustomShaderGLFeature extends GLFeature +public abstract class CustomShaderGLFeature extends GLFeature { + private boolean _initializedShader; public void dispose() { @@ -10,10 +11,22 @@ public void dispose() public CustomShaderGLFeature(String shaderName) { super(GLFeatureGroupName.NO_GROUP, GLFeatureID.GLF_CUSTOM_SHADER); + _initializedShader = false; _values.setCustomShaderName(shaderName); } - public final void applyOnGlobalGLState(GLGlobalState state) + public abstract boolean onInitializeShader(GL gl, GLState state, GPUProgram linkedProgram); + public abstract void onAfterApplyShaderOnGPU(GL gl, GLState state, GPUProgram linkedProgram); + + public final void afterApplyOnGPU(GL gl, GLState state, GPUProgram linkedProgram) { + if (!_initializedShader) + { + _initializedShader = onInitializeShader(gl, state, linkedProgram); + } + if (_initializedShader) + { + onAfterApplyShaderOnGPU(gl, state, linkedProgram); + } } } \ No newline at end of file diff --git a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GLState.java b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GLState.java index 5c3dc6005b..198c1765a6 100644 --- a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GLState.java +++ b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GLState.java @@ -199,6 +199,12 @@ public final void applyOnGPU(GL gl, GPUProgramManager progManager) _linkedProgram.applyChanges(gl); + CustomShaderGLFeature feature = (CustomShaderGLFeature) getGLFeature(GLFeatureID.GLF_CUSTOM_SHADER); + if (feature != null) + { + feature.afterApplyOnGPU(gl, this, _linkedProgram); + } + //prog->onUnused(); //Uncomment to check that all GPUProgramStates are complete } else From 0226b89574c1f28bcfacc049a8dcedd40b99ffab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=A9meth=20=C3=81d=C3=A1m?= Date: Wed, 2 Dec 2015 11:22:42 +0100 Subject: [PATCH 18/43] changed custom shader feature internal functions into protected --- iOS/G3MiOSSDK/Commons/GL/GLFeature.hpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/iOS/G3MiOSSDK/Commons/GL/GLFeature.hpp b/iOS/G3MiOSSDK/Commons/GL/GLFeature.hpp index 56e75847af..d69375fd21 100644 --- a/iOS/G3MiOSSDK/Commons/GL/GLFeature.hpp +++ b/iOS/G3MiOSSDK/Commons/GL/GLFeature.hpp @@ -588,6 +588,10 @@ class CustomShaderGLFeature: public GLFeature { super.dispose(); #endif } + +protected: + virtual bool onInitializeShader(const GL* gl, const GLState* state, const GPUProgram* linkedProgram)=0; + virtual void onAfterApplyShaderOnGPU(const GL* gl, const GLState* state, const GPUProgram* linkedProgram)=0; public: CustomShaderGLFeature(const std::string shaderName) : @@ -595,9 +599,6 @@ class CustomShaderGLFeature: public GLFeature { { _values->setCustomShaderName(shaderName); } - - virtual bool onInitializeShader(const GL* gl, const GLState* state, const GPUProgram* linkedProgram)=0; - virtual void onAfterApplyShaderOnGPU(const GL* gl, const GLState* state, const GPUProgram* linkedProgram)=0; void afterApplyOnGPU(const GL* gl, const GLState* state, const GPUProgram* linkedProgram) { if (!_initializedShader) { From a736448cea9b18e93997660b56a6d6c4867ec733 Mon Sep 17 00:00:00 2001 From: aldeanueva Date: Wed, 2 Dec 2015 11:28:18 +0100 Subject: [PATCH 19/43] Generated --- .../org/glob3/mobile/generated/CustomShaderGLFeature.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/CustomShaderGLFeature.java b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/CustomShaderGLFeature.java index 7b6f7e0dc8..ab9b6596e9 100644 --- a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/CustomShaderGLFeature.java +++ b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/CustomShaderGLFeature.java @@ -8,6 +8,9 @@ public void dispose() super.dispose(); } + protected abstract boolean onInitializeShader(GL gl, GLState state, GPUProgram linkedProgram); + protected abstract void onAfterApplyShaderOnGPU(GL gl, GLState state, GPUProgram linkedProgram); + public CustomShaderGLFeature(String shaderName) { super(GLFeatureGroupName.NO_GROUP, GLFeatureID.GLF_CUSTOM_SHADER); @@ -15,9 +18,6 @@ public CustomShaderGLFeature(String shaderName) _values.setCustomShaderName(shaderName); } - public abstract boolean onInitializeShader(GL gl, GLState state, GPUProgram linkedProgram); - public abstract void onAfterApplyShaderOnGPU(GL gl, GLState state, GPUProgram linkedProgram); - public final void afterApplyOnGPU(GL gl, GLState state, GPUProgram linkedProgram) { if (!_initializedShader) From ce868a10b8d31c1ca96b6edb9ee716fcbef38b89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=A9meth=20=C3=81d=C3=A1m?= Date: Wed, 2 Dec 2015 13:11:00 +0100 Subject: [PATCH 20/43] ignore invalid uniform and attribute indices --- iOS/G3MiOSSDK/Commons/GL/GPUProgram.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/iOS/G3MiOSSDK/Commons/GL/GPUProgram.cpp b/iOS/G3MiOSSDK/Commons/GL/GPUProgram.cpp index ec474c9719..7a7fa822f8 100644 --- a/iOS/G3MiOSSDK/Commons/GL/GPUProgram.cpp +++ b/iOS/G3MiOSSDK/Commons/GL/GPUProgram.cpp @@ -153,7 +153,7 @@ void GPUProgram::getVariables(GL* gl) { for (int i = 0; i < _nUniforms; i++) { GPUUniform* u = gl->getActiveUniform(this, i); - if (u != NULL) { + if (u != NULL && u->getIndex() >= 0) { _uniforms[u->getIndex()] = u; const int code = GPUVariable::getUniformCode(u->_key); @@ -172,7 +172,7 @@ void GPUProgram::getVariables(GL* gl) { for (int i = 0; i < _nAttributes; i++) { GPUAttribute* a = gl->getActiveAttribute(this, i); - if (a != NULL) { + if (a != NULL && a->getIndex() >= 0) { _attributes[a->getIndex()] = a; const int code = GPUVariable::getAttributeCode(a->_key); From 11d6a849bb33c6e8c79a259845a083648e585cb9 Mon Sep 17 00:00:00 2001 From: aldeanueva Date: Wed, 2 Dec 2015 13:16:31 +0100 Subject: [PATCH 21/43] Generated --- .../src/org/glob3/mobile/generated/GPUProgram.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUProgram.java b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUProgram.java index e90f49cb56..1c6d972fb7 100644 --- a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUProgram.java +++ b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUProgram.java @@ -81,7 +81,7 @@ private void getVariables(GL gl) for (int i = 0; i < _nUniforms; i++) { GPUUniform u = gl.getActiveUniform(this, i); - if (u != null) + if (u != null && u->getIndex() >= 0) { _uniforms[u.getIndex()] = u; @@ -102,7 +102,7 @@ private void getVariables(GL gl) for (int i = 0; i < _nAttributes; i++) { GPUAttribute a = gl.getActiveAttribute(this, i); - if (a != null) + if (a != null && a.getIndex() >= 0) { _attributes[a.getIndex()] = a; From c19ee8b2a2157f4a2e1884022919a0b1937384c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=A9meth=20=C3=81d=C3=A1m?= Date: Wed, 2 Dec 2015 14:04:37 +0100 Subject: [PATCH 22/43] gpu program ignores unrecongized attributes and uniforms and character coding fix --- iOS/G3MiOSSDK/Commons/GL/GPUAttribute.hpp | 3 +++ iOS/G3MiOSSDK/Commons/GL/GPUProgram.cpp | 2 +- iOS/G3MiOSSDK/Commons/GL/GPUUniform.cpp | 3 +++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/iOS/G3MiOSSDK/Commons/GL/GPUAttribute.hpp b/iOS/G3MiOSSDK/Commons/GL/GPUAttribute.hpp index 641fae3ffe..93aee930ff 100644 --- a/iOS/G3MiOSSDK/Commons/GL/GPUAttribute.hpp +++ b/iOS/G3MiOSSDK/Commons/GL/GPUAttribute.hpp @@ -171,6 +171,9 @@ class GPUAttribute: public GPUVariable { virtual void applyChanges(GL* gl) { + if (_type == UNRECOGNIZED_ATTRIBUTE) { + return; + } if (_value == NULL) { if (_enabled) { ILogger::instance()->logError("Attribute " + _name + " was not set but it is enabled."); diff --git a/iOS/G3MiOSSDK/Commons/GL/GPUProgram.cpp b/iOS/G3MiOSSDK/Commons/GL/GPUProgram.cpp index 7a7fa822f8..b3b342c785 100644 --- a/iOS/G3MiOSSDK/Commons/GL/GPUProgram.cpp +++ b/iOS/G3MiOSSDK/Commons/GL/GPUProgram.cpp @@ -153,7 +153,7 @@ void GPUProgram::getVariables(GL* gl) { for (int i = 0; i < _nUniforms; i++) { GPUUniform* u = gl->getActiveUniform(this, i); - if (u != NULL && u->getIndex() >= 0) { + if (u != NULL && u->getIndex() >= 0) { _uniforms[u->getIndex()] = u; const int code = GPUVariable::getUniformCode(u->_key); diff --git a/iOS/G3MiOSSDK/Commons/GL/GPUUniform.cpp b/iOS/G3MiOSSDK/Commons/GL/GPUUniform.cpp index 775cafab28..93d2727afc 100644 --- a/iOS/G3MiOSSDK/Commons/GL/GPUUniform.cpp +++ b/iOS/G3MiOSSDK/Commons/GL/GPUUniform.cpp @@ -17,6 +17,9 @@ void GPUUniform::unset() { } void GPUUniform::applyChanges(GL* gl) { + if (_type == UNRECOGNIZED_UNIFORM) { + return; + } if (_dirty) { _value->setUniform(gl, _id); _dirty = false; From cebce4e6e74ff7994494abb47038c0a009f2cdf4 Mon Sep 17 00:00:00 2001 From: aldeanueva Date: Wed, 2 Dec 2015 14:10:06 +0100 Subject: [PATCH 23/43] Generated --- .../src/org/glob3/mobile/generated/GPUAttribute.java | 4 ++++ .../src/org/glob3/mobile/generated/GPUProgram.java | 2 +- .../src/org/glob3/mobile/generated/GPUUniform.java | 4 ++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUAttribute.java b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUAttribute.java index b56f623ded..acbd704763 100644 --- a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUAttribute.java +++ b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUAttribute.java @@ -96,6 +96,10 @@ public final void set(GPUAttributeValue v) public void applyChanges(GL gl) { + if (_type == GPUAttributeKey.UNRECOGNIZED_ATTRIBUTE.getValue()) + { + return; + } if (_value == null) { if (_enabled) diff --git a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUProgram.java b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUProgram.java index 1c6d972fb7..081f38c208 100644 --- a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUProgram.java +++ b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUProgram.java @@ -81,7 +81,7 @@ private void getVariables(GL gl) for (int i = 0; i < _nUniforms; i++) { GPUUniform u = gl.getActiveUniform(this, i); - if (u != null && u->getIndex() >= 0) + if (u != null && u.getIndex() >= 0) { _uniforms[u.getIndex()] = u; diff --git a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUUniform.java b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUUniform.java index c038974471..7aeeeb35d3 100644 --- a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUUniform.java +++ b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUUniform.java @@ -82,6 +82,10 @@ public final void set(GPUUniformValue v) public final void applyChanges(GL gl) { + if (_type == GPUUniformKey.UNRECOGNIZED_UNIFORM.getValue()) + { + return; + } if (_dirty) { _value.setUniform(gl, _id); From 79c746f74f45c46366c3671aeb096bca9902c7f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=A9meth=20=C3=81d=C3=A1m?= Date: Wed, 2 Dec 2015 15:06:18 +0100 Subject: [PATCH 24/43] added feature to make sure unrecognized attributes and uniforms are ignored --- iOS/G3MiOSSDK/Commons/GL/GPUAttribute.hpp | 42 +++++++++++++++++++++++ iOS/G3MiOSSDK/Commons/GL/GPUProgram.cpp | 28 +++++++++------ iOS/G3MiOSSDK/Commons/GL/GPUUniform.hpp | 23 +++++++++++++ 3 files changed, 83 insertions(+), 10 deletions(-) diff --git a/iOS/G3MiOSSDK/Commons/GL/GPUAttribute.hpp b/iOS/G3MiOSSDK/Commons/GL/GPUAttribute.hpp index 93aee930ff..c2e69db49d 100644 --- a/iOS/G3MiOSSDK/Commons/GL/GPUAttribute.hpp +++ b/iOS/G3MiOSSDK/Commons/GL/GPUAttribute.hpp @@ -415,4 +415,46 @@ class GPUAttributeVec4Float: public GPUAttribute{ }; //////// +/////////// +class GPUAttributeValueUnrecognized : public GPUAttributeValue { +private: + ~GPUAttributeValueUnrecognized() { +#ifdef JAVA_CODE + super.dispose(); +#endif + } + +public: + GPUAttributeValueUnrecognized(const int type) : + GPUAttributeValue(type, 0, 0, 0, 0, false) {} + + void setAttribute(GL* gl, const int id) const { + } + + bool isEquals(const GPUAttributeValue* v) const { + return (v->_type == _type); + } + + GPUAttributeValue* shallowCopy() const { + return new GPUAttributeValueUnrecognized(_type); + } + + std::string description() const { + return "Attribute Unrecognized."; + } + + GPUAttributeValue* copyOrCreate(GPUAttributeValue* oldAtt) const { + if (oldAtt == NULL) { + return new GPUAttributeValueUnrecognized(_type); + } + if (oldAtt->_enabled) { + oldAtt->_release(); + return new GPUAttributeValueUnrecognized(_type); + } + return oldAtt; + } + +}; +//////// + #endif diff --git a/iOS/G3MiOSSDK/Commons/GL/GPUProgram.cpp b/iOS/G3MiOSSDK/Commons/GL/GPUProgram.cpp index b3b342c785..0351fb124f 100644 --- a/iOS/G3MiOSSDK/Commons/GL/GPUProgram.cpp +++ b/iOS/G3MiOSSDK/Commons/GL/GPUProgram.cpp @@ -153,11 +153,15 @@ void GPUProgram::getVariables(GL* gl) { for (int i = 0; i < _nUniforms; i++) { GPUUniform* u = gl->getActiveUniform(this, i); - if (u != NULL && u->getIndex() >= 0) { - _uniforms[u->getIndex()] = u; - - const int code = GPUVariable::getUniformCode(u->_key); - _uniformsCode = _uniformsCode | code; + if (u != NULL) { + if (u->getIndex() == UNRECOGNIZED_UNIFORM) { + u->set(new GPUUniformValueUnrecognized(u->_type)); + } else { + _uniforms[u->getIndex()] = u; + + const int code = GPUVariable::getUniformCode(u->_key); + _uniformsCode = _uniformsCode | code; + } } _createdUniforms[counter++] = u; //Adding to created uniforms array @@ -172,11 +176,15 @@ void GPUProgram::getVariables(GL* gl) { for (int i = 0; i < _nAttributes; i++) { GPUAttribute* a = gl->getActiveAttribute(this, i); - if (a != NULL && a->getIndex() >= 0) { - _attributes[a->getIndex()] = a; - - const int code = GPUVariable::getAttributeCode(a->_key); - _attributesCode = _attributesCode | code; + if (a != NULL) { + if (a->getIndex() == UNRECOGNIZED_ATTRIBUTE) { + a->set(new GPUAttributeValueUnrecognized(a->_type)); + } else { + _attributes[a->getIndex()] = a; + + const int code = GPUVariable::getAttributeCode(a->_key); + _attributesCode = _attributesCode | code; + } } _createdAttributes[counter++] = a; diff --git a/iOS/G3MiOSSDK/Commons/GL/GPUUniform.hpp b/iOS/G3MiOSSDK/Commons/GL/GPUUniform.hpp index 56013dd169..970d1659e3 100644 --- a/iOS/G3MiOSSDK/Commons/GL/GPUUniform.hpp +++ b/iOS/G3MiOSSDK/Commons/GL/GPUUniform.hpp @@ -578,4 +578,27 @@ class GPUUniformValueInt : public GPUUniformValue { } }; +class GPUUniformValueUnrecognized : public GPUUniformValue { +private: + ~GPUUniformValueUnrecognized() { +#ifdef JAVA_CODE + super.dispose(); +#endif + } + +public: + GPUUniformValueUnrecognized(const int type):GPUUniformValue(type) {} + + void setUniform(GL* gl, const IGLUniformID* id) const { + } + + bool isEquals(const GPUUniformValue* v) const { + return getType() == v->getType(); + } + + std::string description() const { + return "Uniform Unrecognized"; + } +}; + #endif From da431d660a0b52eb542a6d262f0b4c4158255de9 Mon Sep 17 00:00:00 2001 From: aldeanueva Date: Wed, 2 Dec 2015 15:11:54 +0100 Subject: [PATCH 25/43] Generated --- .../GPUAttributeValueUnrecognized.java | 53 +++++++++++++++++++ .../generated/GPUAttributeVec4Float.java | 5 +- .../glob3/mobile/generated/GPUProgram.java | 34 ++++++++---- .../GPUUniformValueUnrecognized.java | 27 ++++++++++ 4 files changed, 105 insertions(+), 14 deletions(-) create mode 100644 Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUAttributeValueUnrecognized.java create mode 100644 Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUUniformValueUnrecognized.java diff --git a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUAttributeValueUnrecognized.java b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUAttributeValueUnrecognized.java new file mode 100644 index 0000000000..d20f415b1e --- /dev/null +++ b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUAttributeValueUnrecognized.java @@ -0,0 +1,53 @@ +package org.glob3.mobile.generated; +//////// + +/////////// +public class GPUAttributeValueUnrecognized extends GPUAttributeValue +{ + public void dispose() + { + super.dispose(); + } + + public GPUAttributeValueUnrecognized(int type) + { + super(type, 0, 0, 0, 0, false); + } + + public final void setAttribute(GL gl, int id) + { + } + + public final boolean isEquals(GPUAttributeValue v) + { + return (v._type == _type); + } + + public final GPUAttributeValue shallowCopy() + { + return new GPUAttributeValueUnrecognized(_type); + } + + public final String description() + { + return "Attribute Unrecognized."; + } + + public final GPUAttributeValue copyOrCreate(GPUAttributeValue oldAtt) + { + if (oldAtt == null) + { + return new GPUAttributeValueUnrecognized(_type); + } + if (oldAtt._enabled) + { + oldAtt._release(); + return new GPUAttributeValueUnrecognized(_type); + } + return oldAtt; + } + +} +//////// + + diff --git a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUAttributeVec4Float.java b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUAttributeVec4Float.java index 68cba07db6..56493ec855 100644 --- a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUAttributeVec4Float.java +++ b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUAttributeVec4Float.java @@ -10,7 +10,4 @@ public GPUAttributeVec4Float(String name, int id) { super(name, id, GLType.glFloat(), 4); } -} -//////// - - +} \ No newline at end of file diff --git a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUProgram.java b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUProgram.java index 081f38c208..83319d49d3 100644 --- a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUProgram.java +++ b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUProgram.java @@ -81,12 +81,19 @@ private void getVariables(GL gl) for (int i = 0; i < _nUniforms; i++) { GPUUniform u = gl.getActiveUniform(this, i); - if (u != null && u.getIndex() >= 0) + if (u != null) { - _uniforms[u.getIndex()] = u; - - final int code = GPUVariable.getUniformCode(u._key); - _uniformsCode = _uniformsCode | code; + if (u.getIndex() == GPUUniformKey.UNRECOGNIZED_UNIFORM) + { + u.set(new GPUUniformValueUnrecognized(u._type)); + } + else + { + _uniforms[u.getIndex()] = u; + + final int code = GPUVariable.getUniformCode(u._key); + _uniformsCode = _uniformsCode | code; + } } _createdUniforms[counter++] = u; //Adding to created uniforms array @@ -102,12 +109,19 @@ private void getVariables(GL gl) for (int i = 0; i < _nAttributes; i++) { GPUAttribute a = gl.getActiveAttribute(this, i); - if (a != null && a.getIndex() >= 0) + if (a != null) { - _attributes[a.getIndex()] = a; - - final int code = GPUVariable.getAttributeCode(a._key); - _attributesCode = _attributesCode | code; + if (a.getIndex() == GPUAttributeKey.UNRECOGNIZED_ATTRIBUTE) + { + a.set(new GPUAttributeValueUnrecognized(a._type)); + } + else + { + _attributes[a.getIndex()] = a; + + final int code = GPUVariable.getAttributeCode(a._key); + _attributesCode = _attributesCode | code; + } } _createdAttributes[counter++] = a; diff --git a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUUniformValueUnrecognized.java b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUUniformValueUnrecognized.java new file mode 100644 index 0000000000..0df4a73bc6 --- /dev/null +++ b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUUniformValueUnrecognized.java @@ -0,0 +1,27 @@ +package org.glob3.mobile.generated; +public class GPUUniformValueUnrecognized extends GPUUniformValue +{ + public void dispose() + { + super.dispose(); + } + + public GPUUniformValueUnrecognized(int type) + { + super(type); + } + + public final void setUniform(GL gl, IGLUniformID id) + { + } + + public final boolean isEquals(GPUUniformValue v) + { + return getType() == v.getType(); + } + + public final String description() + { + return "Uniform Unrecognized"; + } +} \ No newline at end of file From 48b127930159480dc0dd59d84dc709daacfd02f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=A9meth=20=C3=81d=C3=A1m?= Date: Wed, 2 Dec 2015 15:22:02 +0100 Subject: [PATCH 26/43] get the attribute and uniform keys properly --- iOS/G3MiOSSDK/Commons/GL/GPUProgram.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/iOS/G3MiOSSDK/Commons/GL/GPUProgram.cpp b/iOS/G3MiOSSDK/Commons/GL/GPUProgram.cpp index 0351fb124f..1bb9c1ec88 100644 --- a/iOS/G3MiOSSDK/Commons/GL/GPUProgram.cpp +++ b/iOS/G3MiOSSDK/Commons/GL/GPUProgram.cpp @@ -154,7 +154,7 @@ void GPUProgram::getVariables(GL* gl) { for (int i = 0; i < _nUniforms; i++) { GPUUniform* u = gl->getActiveUniform(this, i); if (u != NULL) { - if (u->getIndex() == UNRECOGNIZED_UNIFORM) { + if (u->getIndex() == GPUVariable::getUniformCode(UNRECOGNIZED_UNIFORM)) { u->set(new GPUUniformValueUnrecognized(u->_type)); } else { _uniforms[u->getIndex()] = u; @@ -177,7 +177,7 @@ void GPUProgram::getVariables(GL* gl) { for (int i = 0; i < _nAttributes; i++) { GPUAttribute* a = gl->getActiveAttribute(this, i); if (a != NULL) { - if (a->getIndex() == UNRECOGNIZED_ATTRIBUTE) { + if (a->getIndex() == GPUVariable::getAttributeCode(UNRECOGNIZED_ATTRIBUTE)) { a->set(new GPUAttributeValueUnrecognized(a->_type)); } else { _attributes[a->getIndex()] = a; From 55f5d2da3347054c83cb107457c4974d5270f275 Mon Sep 17 00:00:00 2001 From: aldeanueva Date: Wed, 2 Dec 2015 15:27:29 +0100 Subject: [PATCH 27/43] Generated --- .../src/org/glob3/mobile/generated/GPUProgram.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUProgram.java b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUProgram.java index 83319d49d3..c8b71472ed 100644 --- a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUProgram.java +++ b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUProgram.java @@ -83,7 +83,7 @@ private void getVariables(GL gl) GPUUniform u = gl.getActiveUniform(this, i); if (u != null) { - if (u.getIndex() == GPUUniformKey.UNRECOGNIZED_UNIFORM) + if (u.getIndex() == GPUVariable.getUniformCode(GPUUniformKey.UNRECOGNIZED_UNIFORM)) { u.set(new GPUUniformValueUnrecognized(u._type)); } @@ -111,7 +111,7 @@ private void getVariables(GL gl) GPUAttribute a = gl.getActiveAttribute(this, i); if (a != null) { - if (a.getIndex() == GPUAttributeKey.UNRECOGNIZED_ATTRIBUTE) + if (a.getIndex() == GPUVariable.getAttributeCode(GPUAttributeKey.UNRECOGNIZED_ATTRIBUTE)) { a.set(new GPUAttributeValueUnrecognized(a._type)); } From 5703cbc07622005663df46e76483b3b1ac38a0f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=A9meth=20=C3=81d=C3=A1m?= Date: Wed, 2 Dec 2015 15:32:15 +0100 Subject: [PATCH 28/43] key check changes again --- iOS/G3MiOSSDK/Commons/GL/GPUProgram.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/iOS/G3MiOSSDK/Commons/GL/GPUProgram.cpp b/iOS/G3MiOSSDK/Commons/GL/GPUProgram.cpp index 1bb9c1ec88..25c8ddca5b 100644 --- a/iOS/G3MiOSSDK/Commons/GL/GPUProgram.cpp +++ b/iOS/G3MiOSSDK/Commons/GL/GPUProgram.cpp @@ -154,7 +154,7 @@ void GPUProgram::getVariables(GL* gl) { for (int i = 0; i < _nUniforms; i++) { GPUUniform* u = gl->getActiveUniform(this, i); if (u != NULL) { - if (u->getIndex() == GPUVariable::getUniformCode(UNRECOGNIZED_UNIFORM)) { + if (u->_key == UNRECOGNIZED_UNIFORM) { u->set(new GPUUniformValueUnrecognized(u->_type)); } else { _uniforms[u->getIndex()] = u; @@ -177,7 +177,7 @@ void GPUProgram::getVariables(GL* gl) { for (int i = 0; i < _nAttributes; i++) { GPUAttribute* a = gl->getActiveAttribute(this, i); if (a != NULL) { - if (a->getIndex() == GPUVariable::getAttributeCode(UNRECOGNIZED_ATTRIBUTE)) { + if (a->_key == UNRECOGNIZED_ATTRIBUTE) { a->set(new GPUAttributeValueUnrecognized(a->_type)); } else { _attributes[a->getIndex()] = a; From ac79bd1ca9f5b29127f14c685ee60b40cb2704b8 Mon Sep 17 00:00:00 2001 From: aldeanueva Date: Wed, 2 Dec 2015 15:38:10 +0100 Subject: [PATCH 29/43] Generated --- .../src/org/glob3/mobile/generated/GPUProgram.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUProgram.java b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUProgram.java index c8b71472ed..1adc798d4e 100644 --- a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUProgram.java +++ b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUProgram.java @@ -83,7 +83,7 @@ private void getVariables(GL gl) GPUUniform u = gl.getActiveUniform(this, i); if (u != null) { - if (u.getIndex() == GPUVariable.getUniformCode(GPUUniformKey.UNRECOGNIZED_UNIFORM)) + if (u._key == GPUUniformKey.UNRECOGNIZED_UNIFORM) { u.set(new GPUUniformValueUnrecognized(u._type)); } @@ -111,7 +111,7 @@ private void getVariables(GL gl) GPUAttribute a = gl.getActiveAttribute(this, i); if (a != null) { - if (a.getIndex() == GPUVariable.getAttributeCode(GPUAttributeKey.UNRECOGNIZED_ATTRIBUTE)) + if (a._key == GPUAttributeKey.UNRECOGNIZED_ATTRIBUTE) { a.set(new GPUAttributeValueUnrecognized(a._type)); } From fa6303c4c0d38c74459bc1eaf61b9896754c9f7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=A9meth=20=C3=81d=C3=A1m?= Date: Thu, 3 Dec 2015 10:32:20 +0100 Subject: [PATCH 30/43] these are not needed because values that set nothing are already added way before this --- iOS/G3MiOSSDK/Commons/GL/GPUAttribute.hpp | 3 --- iOS/G3MiOSSDK/Commons/GL/GPUUniform.cpp | 3 --- 2 files changed, 6 deletions(-) diff --git a/iOS/G3MiOSSDK/Commons/GL/GPUAttribute.hpp b/iOS/G3MiOSSDK/Commons/GL/GPUAttribute.hpp index c2e69db49d..0e0449a410 100644 --- a/iOS/G3MiOSSDK/Commons/GL/GPUAttribute.hpp +++ b/iOS/G3MiOSSDK/Commons/GL/GPUAttribute.hpp @@ -171,9 +171,6 @@ class GPUAttribute: public GPUVariable { virtual void applyChanges(GL* gl) { - if (_type == UNRECOGNIZED_ATTRIBUTE) { - return; - } if (_value == NULL) { if (_enabled) { ILogger::instance()->logError("Attribute " + _name + " was not set but it is enabled."); diff --git a/iOS/G3MiOSSDK/Commons/GL/GPUUniform.cpp b/iOS/G3MiOSSDK/Commons/GL/GPUUniform.cpp index 93d2727afc..775cafab28 100644 --- a/iOS/G3MiOSSDK/Commons/GL/GPUUniform.cpp +++ b/iOS/G3MiOSSDK/Commons/GL/GPUUniform.cpp @@ -17,9 +17,6 @@ void GPUUniform::unset() { } void GPUUniform::applyChanges(GL* gl) { - if (_type == UNRECOGNIZED_UNIFORM) { - return; - } if (_dirty) { _value->setUniform(gl, _id); _dirty = false; From 58db0b46db5de32d9737c3cf8b56ad06200f310b Mon Sep 17 00:00:00 2001 From: aldeanueva Date: Thu, 3 Dec 2015 10:38:25 +0100 Subject: [PATCH 31/43] Generated --- .../src/org/glob3/mobile/generated/GPUAttribute.java | 4 ---- .../src/org/glob3/mobile/generated/GPUUniform.java | 4 ---- 2 files changed, 8 deletions(-) diff --git a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUAttribute.java b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUAttribute.java index acbd704763..b56f623ded 100644 --- a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUAttribute.java +++ b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUAttribute.java @@ -96,10 +96,6 @@ public final void set(GPUAttributeValue v) public void applyChanges(GL gl) { - if (_type == GPUAttributeKey.UNRECOGNIZED_ATTRIBUTE.getValue()) - { - return; - } if (_value == null) { if (_enabled) diff --git a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUUniform.java b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUUniform.java index 7aeeeb35d3..c038974471 100644 --- a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUUniform.java +++ b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUUniform.java @@ -82,10 +82,6 @@ public final void set(GPUUniformValue v) public final void applyChanges(GL gl) { - if (_type == GPUUniformKey.UNRECOGNIZED_UNIFORM.getValue()) - { - return; - } if (_dirty) { _value.setUniform(gl, _id); From 38d1fca023f67851a1da11d7fa7e7d77c950df03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=A9meth=20=C3=81d=C3=A1m?= Date: Thu, 3 Dec 2015 11:54:27 +0100 Subject: [PATCH 32/43] added to ignore unrecognized attributes and uniforms --- iOS/G3MiOSSDK/Commons/GL/GPUAttribute.hpp | 3 +++ iOS/G3MiOSSDK/Commons/GL/GPUUniform.cpp | 3 +++ 2 files changed, 6 insertions(+) diff --git a/iOS/G3MiOSSDK/Commons/GL/GPUAttribute.hpp b/iOS/G3MiOSSDK/Commons/GL/GPUAttribute.hpp index 0e0449a410..aba0b05b36 100644 --- a/iOS/G3MiOSSDK/Commons/GL/GPUAttribute.hpp +++ b/iOS/G3MiOSSDK/Commons/GL/GPUAttribute.hpp @@ -171,6 +171,9 @@ class GPUAttribute: public GPUVariable { virtual void applyChanges(GL* gl) { + if (_key == UNRECOGNIZED_ATTRIBUTE) { + return; + } if (_value == NULL) { if (_enabled) { ILogger::instance()->logError("Attribute " + _name + " was not set but it is enabled."); diff --git a/iOS/G3MiOSSDK/Commons/GL/GPUUniform.cpp b/iOS/G3MiOSSDK/Commons/GL/GPUUniform.cpp index 775cafab28..fc8a584e09 100644 --- a/iOS/G3MiOSSDK/Commons/GL/GPUUniform.cpp +++ b/iOS/G3MiOSSDK/Commons/GL/GPUUniform.cpp @@ -17,6 +17,9 @@ void GPUUniform::unset() { } void GPUUniform::applyChanges(GL* gl) { + if (_key == UNRECOGNIZED_UNIFORM) { + return; + } if (_dirty) { _value->setUniform(gl, _id); _dirty = false; From a1758db7b92799e9a5e8264472afffefb5452433 Mon Sep 17 00:00:00 2001 From: aldeanueva Date: Thu, 3 Dec 2015 12:00:04 +0100 Subject: [PATCH 33/43] Generated --- .../src/org/glob3/mobile/generated/GPUAttribute.java | 4 ++++ .../src/org/glob3/mobile/generated/GPUUniform.java | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUAttribute.java b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUAttribute.java index b56f623ded..db46348c1c 100644 --- a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUAttribute.java +++ b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUAttribute.java @@ -96,6 +96,10 @@ public final void set(GPUAttributeValue v) public void applyChanges(GL gl) { + if (_key == GPUAttributeKey.UNRECOGNIZED_ATTRIBUTE) + { + return; + } if (_value == null) { if (_enabled) diff --git a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUUniform.java b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUUniform.java index c038974471..04d8b9618c 100644 --- a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUUniform.java +++ b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUUniform.java @@ -82,6 +82,10 @@ public final void set(GPUUniformValue v) public final void applyChanges(GL gl) { + if (_key == GPUUniformKey.UNRECOGNIZED_UNIFORM) + { + return; + } if (_dirty) { _value.setUniform(gl, _id); From e935481e7e9550ea07f88a65398e7ba960cfb7c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=A9meth=20=C3=81d=C3=A1m?= Date: Thu, 3 Dec 2015 13:43:27 +0100 Subject: [PATCH 34/43] added ability to get gl feature in a gl state which includes anchestors --- iOS/G3MiOSSDK/Commons/GL/GLState.cpp | 17 ++++++++++++++++- iOS/G3MiOSSDK/Commons/GL/GLState.hpp | 3 ++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/iOS/G3MiOSSDK/Commons/GL/GLState.cpp b/iOS/G3MiOSSDK/Commons/GL/GLState.cpp index 417c420448..76c3a11124 100644 --- a/iOS/G3MiOSSDK/Commons/GL/GLState.cpp +++ b/iOS/G3MiOSSDK/Commons/GL/GLState.cpp @@ -133,7 +133,7 @@ void GLState::applyOnGPU(GL* gl, GPUProgramManager& progManager) const { _linkedProgram->applyChanges(gl); - CustomShaderGLFeature* feature = (CustomShaderGLFeature*) getGLFeature(GLF_CUSTOM_SHADER); + CustomShaderGLFeature* feature = (CustomShaderGLFeature*) getGLFeatureIncludingAncestors(GLF_CUSTOM_SHADER); if (feature) { feature->afterApplyOnGPU(gl, this, _linkedProgram); } @@ -172,6 +172,21 @@ GLFeature* GLState::getGLFeature(GLFeatureID id) const { return NULL; } +GLFeature* GLState::getGLFeatureIncludingAncestors(GLFeatureID id) const { + const int size = _features->size(); + for (int i = 0; i < size; i++) { + GLFeature* f = _features->get(i); + if (f->_id == id) { + return f; + } + } + if (_parentGLState != NULL) { + return _parentGLState->getGLFeatureIncludingAncestors(id); + } + + return NULL; +} + GLFeatureSet* GLState::getGLFeatures(GLFeatureID id) const { GLFeatureSet* features = new GLFeatureSet(); const int size = _features->size(); diff --git a/iOS/G3MiOSSDK/Commons/GL/GLState.hpp b/iOS/G3MiOSSDK/Commons/GL/GLState.hpp index 7bed995fe9..4c113b300a 100644 --- a/iOS/G3MiOSSDK/Commons/GL/GLState.hpp +++ b/iOS/G3MiOSSDK/Commons/GL/GLState.hpp @@ -81,7 +81,8 @@ class GLState: public RCObject { int getNumberOfGLFeatures() const; GLFeature* getGLFeature(GLFeatureID id) const; - + GLFeature* getGLFeatureIncludingAncestors(GLFeatureID id) const; + GLFeatureSet* getGLFeatures(GLFeatureID id) const; }; From 6cd9db0524fd677c0710b999cf34e0af64609781 Mon Sep 17 00:00:00 2001 From: aldeanueva Date: Thu, 3 Dec 2015 13:53:51 +0100 Subject: [PATCH 35/43] Generated --- .../org/glob3/mobile/generated/GLState.java | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GLState.java b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GLState.java index 198c1765a6..fff0d86fae 100644 --- a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GLState.java +++ b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GLState.java @@ -199,7 +199,7 @@ public final void applyOnGPU(GL gl, GPUProgramManager progManager) _linkedProgram.applyChanges(gl); - CustomShaderGLFeature feature = (CustomShaderGLFeature) getGLFeature(GLFeatureID.GLF_CUSTOM_SHADER); + CustomShaderGLFeature feature = (CustomShaderGLFeature) getGLFeatureIncludingAncestors(GLFeatureID.GLF_CUSTOM_SHADER); if (feature != null) { feature.afterApplyOnGPU(gl, this, _linkedProgram); @@ -257,6 +257,24 @@ public final GLFeature getGLFeature(GLFeatureID id) return null; } + public final GLFeature getGLFeatureIncludingAncestors(GLFeatureID id) + { + final int size = _features.size(); + for (int i = 0; i < size; i++) + { + GLFeature f = _features.get(i); + if (f._id == id) + { + return f; + } + } + if (_parentGLState != null) + { + return _parentGLState.getGLFeatureIncludingAncestors(id); + } + + return null; + } public final GLFeatureSet getGLFeatures(GLFeatureID id) { From 61fa1fcdb9dfe112350ad43213eb7984d5d388f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=A9meth=20=C3=81d=C3=A1m?= Date: Tue, 8 Dec 2015 13:07:34 +0100 Subject: [PATCH 36/43] reverted tests made for java converter testing --- iOS/G3MiOSSDK/Commons/Basic/G3MWidget.cpp | 2 +- iOS/G3MiOSSDK/Commons/Rendererers/BusyMeshRenderer.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/iOS/G3MiOSSDK/Commons/Basic/G3MWidget.cpp b/iOS/G3MiOSSDK/Commons/Basic/G3MWidget.cpp index f520c5d4c2..aa895c4a8b 100644 --- a/iOS/G3MiOSSDK/Commons/Basic/G3MWidget.cpp +++ b/iOS/G3MiOSSDK/Commons/Basic/G3MWidget.cpp @@ -620,7 +620,7 @@ void G3MWidget::render(int width, int height) { _totalRenderTime += elapsedTimeMS; if ((_renderStatisticsTimer == NULL) || - (_renderStatisticsTimer->elapsedTimeInMilliseconds() > 3000)) { + (_renderStatisticsTimer->elapsedTimeInMilliseconds() > 2000)) { const double averageTimePerRender = (double) _totalRenderTime / _renderCounter; const double fps = 1000.0 / averageTimePerRender; ILogger::instance()->logInfo("FPS=%f" , fps); diff --git a/iOS/G3MiOSSDK/Commons/Rendererers/BusyMeshRenderer.cpp b/iOS/G3MiOSSDK/Commons/Rendererers/BusyMeshRenderer.cpp index c201480db0..d3b4f86eef 100644 --- a/iOS/G3MiOSSDK/Commons/Rendererers/BusyMeshRenderer.cpp +++ b/iOS/G3MiOSSDK/Commons/Rendererers/BusyMeshRenderer.cpp @@ -71,9 +71,9 @@ Mesh* BusyMeshRenderer::createMesh(const G3MRenderContext* rc) { const int viewPortWidth = camera->getViewPortWidth(); const int viewPortHeight = camera->getViewPortHeight(); const int minSize = (viewPortWidth < viewPortHeight) ? viewPortWidth : viewPortHeight; - const float outerRadius = minSize / 18.0f; - ILogger::instance()->logError("This a test log line"); - const IMathUtils* mu = IMathUtils::instance(); + const float outerRadius = minSize / 15.0f; + + const IMathUtils* mu = IMathUtils::instance(); for (int step = 0; step <= numStrides; step++) { const double angle = (double) step * 2 * PI / numStrides; From 7e6104aaf5094a195d8047a3affc08fe06215923 Mon Sep 17 00:00:00 2001 From: aldeanueva Date: Tue, 8 Dec 2015 13:16:19 +0100 Subject: [PATCH 37/43] Generated --- .../src/org/glob3/mobile/generated/BusyMeshRenderer.java | 6 +++--- .../src/org/glob3/mobile/generated/G3MWidget.java | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/BusyMeshRenderer.java b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/BusyMeshRenderer.java index bd54a53bd4..44b2f37e6f 100644 --- a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/BusyMeshRenderer.java +++ b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/BusyMeshRenderer.java @@ -76,9 +76,9 @@ private Mesh createMesh(G3MRenderContext rc) final int viewPortWidth = camera.getViewPortWidth(); final int viewPortHeight = camera.getViewPortHeight(); final int minSize = (viewPortWidth < viewPortHeight) ? viewPortWidth : viewPortHeight; - final float outerRadius = minSize / 18.0f; - ILogger.instance().logError("This a test log line"); - final IMathUtils mu = IMathUtils.instance(); + final float outerRadius = minSize / 15.0f; + + final IMathUtils mu = IMathUtils.instance(); for (int step = 0; step <= numStrides; step++) { diff --git a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/G3MWidget.java b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/G3MWidget.java index 3bce39b5ae..6453314a19 100644 --- a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/G3MWidget.java +++ b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/G3MWidget.java @@ -266,7 +266,7 @@ public final void render(int width, int height) { _totalRenderTime += elapsedTimeMS; - if ((_renderStatisticsTimer == null) || (_renderStatisticsTimer.elapsedTimeInMilliseconds() > 3000)) + if ((_renderStatisticsTimer == null) || (_renderStatisticsTimer.elapsedTimeInMilliseconds() > 2000)) { final double averageTimePerRender = (double) _totalRenderTime / _renderCounter; final double fps = 1000.0 / averageTimePerRender; From f31c8a242a37cec538a9f189f5681d39ef5ec093 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=A9meth=20=C3=81d=C3=A1m?= Date: Sat, 12 Dec 2015 10:02:15 +0100 Subject: [PATCH 38/43] fix for issue with case when the internal shshaders are mistaken for custom shaders and used instead --- iOS/G3MiOSSDK/Commons/GL/GPUProgram.cpp | 4 +++- iOS/G3MiOSSDK/Commons/GL/GPUProgram.hpp | 7 ++++++- iOS/G3MiOSSDK/Commons/GL/GPUProgramManager.cpp | 13 ++++++++++--- iOS/G3MiOSSDK/Commons/GL/GPUProgramManager.hpp | 2 ++ 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/iOS/G3MiOSSDK/Commons/GL/GPUProgram.cpp b/iOS/G3MiOSSDK/Commons/GL/GPUProgram.cpp index 25c8ddca5b..b7852ff57d 100644 --- a/iOS/G3MiOSSDK/Commons/GL/GPUProgram.cpp +++ b/iOS/G3MiOSSDK/Commons/GL/GPUProgram.cpp @@ -16,13 +16,15 @@ GPUProgram* GPUProgram::createProgram(GL* gl, const std::string& name, const std::string& vertexSource, - const std::string& fragmentSource) { + const std::string& fragmentSource, + const bool referencedByName) { GPUProgram* p = new GPUProgram(); p->_name = name; p->_programID = gl->createProgram(); p->_gl = gl; + p->_referencedByName = referencedByName; // compile vertex shader int vertexShader= gl->createShader(VERTEX_SHADER); diff --git a/iOS/G3MiOSSDK/Commons/GL/GPUProgram.hpp b/iOS/G3MiOSSDK/Commons/GL/GPUProgram.hpp index 0f47c0fe41..1349edc80e 100644 --- a/iOS/G3MiOSSDK/Commons/GL/GPUProgram.hpp +++ b/iOS/G3MiOSSDK/Commons/GL/GPUProgram.hpp @@ -56,6 +56,8 @@ class GPUProgram{ int _nReferences; //Number of items that reference this Program + bool _referencedByName; + bool compileShader(GL* gl, int shader, const std::string& source) const; bool linkProgram(GL* gl) const; void deleteShader(GL* gl, int shader) const; @@ -85,7 +87,8 @@ class GPUProgram{ static GPUProgram* createProgram(GL* gl, const std::string& name, const std::string& vertexSource, - const std::string& fragmentSource); + const std::string& fragmentSource, + const bool referencedByName); std::string getName() const { return _name;} @@ -94,6 +97,8 @@ class GPUProgram{ int getGPUAttributesNumber() const { return _nAttributes;} int getGPUUniformsNumber() const { return _nUniforms;} + bool isReferencedByName() const { return _referencedByName; } + GPUUniform* getGPUUniform(const std::string& name) const; GPUAttribute* getGPUAttribute(const std::string& name) const; diff --git a/iOS/G3MiOSSDK/Commons/GL/GPUProgramManager.cpp b/iOS/G3MiOSSDK/Commons/GL/GPUProgramManager.cpp index 1ac0f27af1..ee9aa5f8d6 100644 --- a/iOS/G3MiOSSDK/Commons/GL/GPUProgramManager.cpp +++ b/iOS/G3MiOSSDK/Commons/GL/GPUProgramManager.cpp @@ -44,7 +44,7 @@ GPUProgram* GPUProgramManager::getProgram(GL* gl, int uniformsCode, int attribut GPUProgram* GPUProgramManager::getProgram(GL* gl, const std::string& name) { GPUProgram* p = getCompiledProgram(name); if (p == NULL) { - p = compileProgramWithName(gl, name); + p = compileProgramWithName(gl, name, true); if (p == NULL) { ILogger::instance()->logError("Problem at compiling program."); return NULL; @@ -153,7 +153,7 @@ GPUProgram* GPUProgramManager::getCompiledProgram(int uniformsCode, int attribut for (std::map::iterator it = _programs.begin(); it != _programs.end(); ++it) { //#warning GPUProgram getUniformsCode avoid call GPUProgram* p = it->second; - if (p->getUniformsCode() == uniformsCode && p->getAttributesCode() == attributesCode) { + if (p->getUniformsCode() == uniformsCode && p->getAttributesCode() == attributesCode && !p->isReferencedByName()) { return p; } } @@ -170,6 +170,12 @@ GPUProgram* GPUProgramManager::getCompiledProgram(int uniformsCode, int attribut GPUProgram* GPUProgramManager::compileProgramWithName(GL* gl, const std::string& name) { + return compileProgramWithName(gl, name, false); +} + +GPUProgram* GPUProgramManager::compileProgramWithName(GL* gl, + const std::string& name, + bool referencedByName) { GPUProgram* prog = getCompiledProgram(name); if (prog == NULL) { @@ -180,7 +186,8 @@ GPUProgram* GPUProgramManager::compileProgramWithName(GL* gl, prog = GPUProgram::createProgram(gl, ps->_name, ps->_vertexSource, - ps->_fragmentSource); + ps->_fragmentSource, + referencedByName); //#warning DETECT COLISSION WITH COLLECTION OF GPUPROGRAM if (prog == NULL) { ILogger::instance()->logError("Problem at creating program named %s.", name.c_str()); diff --git a/iOS/G3MiOSSDK/Commons/GL/GPUProgramManager.hpp b/iOS/G3MiOSSDK/Commons/GL/GPUProgramManager.hpp index 990104c37d..01f06b92f7 100644 --- a/iOS/G3MiOSSDK/Commons/GL/GPUProgramManager.hpp +++ b/iOS/G3MiOSSDK/Commons/GL/GPUProgramManager.hpp @@ -26,6 +26,8 @@ class GPUProgramManager { GPUProgram* compileProgramWithName(GL* gl, const std::string& name); + GPUProgram* compileProgramWithName(GL* gl, const std::string& name, bool referencedByName); + GPUProgram* getNewProgram(GL* gl, int uniformsCode, int attributesCode); GPUProgram* getCompiledProgram(int uniformsCode, int attributesCode); From 9cddb56d92208fdaf42b61f79c243794e9e98308 Mon Sep 17 00:00:00 2001 From: aldeanueva Date: Sat, 12 Dec 2015 10:08:58 +0100 Subject: [PATCH 39/43] Generated --- .../src/org/glob3/mobile/generated/GPUProgram.java | 10 +++++++++- .../org/glob3/mobile/generated/GPUProgramManager.java | 9 +++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUProgram.java b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUProgram.java index 1adc798d4e..662aee84ef 100644 --- a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUProgram.java +++ b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUProgram.java @@ -20,6 +20,8 @@ public class GPUProgram private int _nReferences; //Number of items that reference this Program + private boolean _referencedByName; + private boolean compileShader(GL gl, int shader, String source) { boolean result = gl.compileShader(shader, source); @@ -177,7 +179,7 @@ public void dispose() } } - public static GPUProgram createProgram(GL gl, String name, String vertexSource, String fragmentSource) + public static GPUProgram createProgram(GL gl, String name, String vertexSource, String fragmentSource, boolean referencedByName) { GPUProgram p = new GPUProgram(); @@ -185,6 +187,7 @@ public static GPUProgram createProgram(GL gl, String name, String vertexSource, p._name = name; p._programID = gl.createProgram(); p._gl = gl; + p._referencedByName = referencedByName; // compile vertex shader int vertexShader = gl.createShader(ShaderType.VERTEX_SHADER); @@ -260,6 +263,11 @@ public final int getGPUUniformsNumber() return _nUniforms; } + public final boolean isReferencedByName() + { + return _referencedByName; + } + public final GPUUniform getGPUUniform(String name) { final int key = GPUVariable.getUniformKey(name).getValue(); diff --git a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUProgramManager.java b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUProgramManager.java index 16cd676825..46934a46c0 100644 --- a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUProgramManager.java +++ b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUProgramManager.java @@ -31,6 +31,11 @@ private GPUProgram getCompiledProgram(String name) } private GPUProgram compileProgramWithName(GL gl, String name) + { + return compileProgramWithName(gl, name, false); + } + + private GPUProgram compileProgramWithName(GL gl, String name, boolean referencedByName) { GPUProgram prog = getCompiledProgram(name); @@ -41,7 +46,7 @@ private GPUProgram compileProgramWithName(GL gl, String name) //Compile new Program if (ps != null) { - prog = GPUProgram.createProgram(gl, ps._name, ps._vertexSource, ps._fragmentSource); + prog = GPUProgram.createProgram(gl, ps._name, ps._vertexSource, ps._fragmentSource, referencedByName); ///#warning DETECT COLISSION WITH COLLECTION OF GPUPROGRAM if (prog == null) { @@ -212,7 +217,7 @@ public final GPUProgram getProgram(GL gl, String name) GPUProgram p = getCompiledProgram(name); if (p == null) { - p = compileProgramWithName(gl, name); + p = compileProgramWithName(gl, name, true); if (p == null) { ILogger.instance().logError("Problem at compiling program."); From a451d995bd740fb8a1f70997d43f74842056b327 Mon Sep 17 00:00:00 2001 From: Zoltan Pillio Date: Sat, 12 Dec 2015 19:46:58 +0100 Subject: [PATCH 40/43] fix JAVA code --- iOS/G3MiOSSDK/Commons/GL/GPUProgramManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iOS/G3MiOSSDK/Commons/GL/GPUProgramManager.cpp b/iOS/G3MiOSSDK/Commons/GL/GPUProgramManager.cpp index ee9aa5f8d6..2aa7908586 100644 --- a/iOS/G3MiOSSDK/Commons/GL/GPUProgramManager.cpp +++ b/iOS/G3MiOSSDK/Commons/GL/GPUProgramManager.cpp @@ -160,7 +160,7 @@ GPUProgram* GPUProgramManager::getCompiledProgram(int uniformsCode, int attribut #endif #ifdef JAVA_CODE for (final GPUProgram p : _programs.values()) { - if ((p.getUniformsCode() == uniformsCode) && (p.getAttributesCode() == attributesCode)) { + if ((p.getUniformsCode() == uniformsCode) && (p.getAttributesCode() == attributesCode) && p.isReferencedByName()) { return p; } } From 7219d9da8ebbe42c6000c1f9142c1e18bfa22dba Mon Sep 17 00:00:00 2001 From: aldeanueva Date: Sat, 12 Dec 2015 19:54:40 +0100 Subject: [PATCH 41/43] Generated --- .../src/org/glob3/mobile/generated/GPUProgramManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUProgramManager.java b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUProgramManager.java index 46934a46c0..d068883f82 100644 --- a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUProgramManager.java +++ b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUProgramManager.java @@ -171,7 +171,7 @@ private GPUProgram getNewProgram(GL gl, int uniformsCode, int attributesCode) private GPUProgram getCompiledProgram(int uniformsCode, int attributesCode) { for (final GPUProgram p : _programs.values()) { - if ((p.getUniformsCode() == uniformsCode) && (p.getAttributesCode() == attributesCode)) { + if ((p.getUniformsCode() == uniformsCode) && (p.getAttributesCode() == attributesCode) && p.isReferencedByName()) { return p; } } From 40efcb9b4344f6c403b1ba017e4f8eb2602390d7 Mon Sep 17 00:00:00 2001 From: Zoltan Pillio Date: Sat, 12 Dec 2015 20:11:05 +0100 Subject: [PATCH 42/43] fix fix JAVA code --- iOS/G3MiOSSDK/Commons/GL/GPUProgramManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iOS/G3MiOSSDK/Commons/GL/GPUProgramManager.cpp b/iOS/G3MiOSSDK/Commons/GL/GPUProgramManager.cpp index 2aa7908586..72076c6872 100644 --- a/iOS/G3MiOSSDK/Commons/GL/GPUProgramManager.cpp +++ b/iOS/G3MiOSSDK/Commons/GL/GPUProgramManager.cpp @@ -160,7 +160,7 @@ GPUProgram* GPUProgramManager::getCompiledProgram(int uniformsCode, int attribut #endif #ifdef JAVA_CODE for (final GPUProgram p : _programs.values()) { - if ((p.getUniformsCode() == uniformsCode) && (p.getAttributesCode() == attributesCode) && p.isReferencedByName()) { + if ((p.getUniformsCode() == uniformsCode) && (p.getAttributesCode() == attributesCode) && !p.isReferencedByName()) { return p; } } From daf2ae42beb5238098a3b1513a0706d34c15ea4f Mon Sep 17 00:00:00 2001 From: aldeanueva Date: Sat, 12 Dec 2015 20:17:51 +0100 Subject: [PATCH 43/43] Generated --- .../src/org/glob3/mobile/generated/GPUProgramManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUProgramManager.java b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUProgramManager.java index d068883f82..f5b495d703 100644 --- a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUProgramManager.java +++ b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/GPUProgramManager.java @@ -171,7 +171,7 @@ private GPUProgram getNewProgram(GL gl, int uniformsCode, int attributesCode) private GPUProgram getCompiledProgram(int uniformsCode, int attributesCode) { for (final GPUProgram p : _programs.values()) { - if ((p.getUniformsCode() == uniformsCode) && (p.getAttributesCode() == attributesCode) && p.isReferencedByName()) { + if ((p.getUniformsCode() == uniformsCode) && (p.getAttributesCode() == attributesCode) && !p.isReferencedByName()) { return p; } }