Update a few build scripts for android compat
diff --git a/build.sh b/build.sh
index 8b29a8c..0571fe3 100755
--- a/build.sh
+++ b/build.sh
@@ -17,6 +17,9 @@
elif [ "$OPTION" = "release" ]
then
premake5 gmake2 && make config=release -j7
+elif [ "$OPTION" = "android" ]
+then
+ premake5 --with-low-level-rendering gmake2 && make config=release -j7
else
premake5 gmake2 && make -j7
fi
diff --git a/renderer/library/build.sh b/renderer/library/build.sh
index cc912b1..b7c47f3 100755
--- a/renderer/library/build.sh
+++ b/renderer/library/build.sh
@@ -16,11 +16,14 @@
echo build.sh release - build release library
elif [ "$OPTION" = "clean" ]
then
- echo Cleaning project ...
+ echo Cleaning renderer_library project ...
premake5 clean
elif [ "$OPTION" = "release" ]
then
- premake5 gmake && make config=release -j7
+ premake5 --for-macos gmake && make config=release -j7
+elif [ "$OPTION" = "android" ]
+then
+ premake5 --for-android gmake && make config=release -j7
else
- premake5 gmake && make -j7
+ premake5 --for-macos gmake && make -j7
fi
\ No newline at end of file
diff --git a/renderer/library/build/premake5.lua b/renderer/library/build/premake5.lua
index a28d333..f2391b2 100644
--- a/renderer/library/build/premake5.lua
+++ b/renderer/library/build/premake5.lua
@@ -9,17 +9,10 @@
objdir "obj/%{cfg.buildcfg}"
includedirs {"../include", "../../../include"}
-if os.host() == "macosx" then
- links {"Cocoa.framework", "rive"}
- defines {"RIVE_HAS_METAL", "RIVE_HAS_OPENGL"}
- defines {"GL_SILENCE_DEPRECATION"}
- includedirs {"../../dependencies/DiligentEngine_build/build/include"}
- files {"../src/**.mm"}
-else
- links {"rive"}
-end
-
-libdirs {"../../../build/bin/%{cfg.buildcfg}", "../../dependencies/skia/out/Static"}
+newoption {
+ trigger = "for-android",
+ description = "Builds in utility classes and methods used for low level renderering implementations that work with Android systems"
+}
files {"../src/**.cpp"}
@@ -33,6 +26,19 @@
defines {"RELEASE"}
optimize "On"
+configuration "for-android"
+ links {"rive"}
+ defines {"RIVE_HAS_OPENGL", "ANDROID", "GL_SILENCE_DEPRECATION"}
+ libdirs {"../../../build/bin/%{cfg.buildcfg}"}
+
+configuration "for-macos"
+ links {"Cocoa.framework", "rive"}
+ defines {"RIVE_HAS_METAL", "RIVE_HAS_OPENGL"}
+ defines {"GL_SILENCE_DEPRECATION"}
+ includedirs {"../../dependencies/DiligentEngine_build/build/include"}
+ files {"../src/**.mm"}
+ libdirs {"../../../build/bin/%{cfg.buildcfg}", "../../dependencies/skia/out/Static"}
+
-- Clean Function --
newaction {
trigger = "clean",
diff --git a/renderer/library/include/opengl/opengl.h b/renderer/library/include/opengl/opengl.h
index 1f1cd48..6102ff9 100644
--- a/renderer/library/include/opengl/opengl.h
+++ b/renderer/library/include/opengl/opengl.h
@@ -11,8 +11,8 @@
#include <OpenGL/gl3.h>
#endif
#elif defined(__ANDROID__) || defined(ANDROID)
-#include <GLES2/gl2.h>
-#include <GLES2/gl2ext.h>
+#include <GLES3/gl3.h>
+#include <GLES3/gl3ext.h>
#elif defined(__linux__) || defined(__unix__) || defined(__posix__)
#include <GL/gl.h>
#include <GL/glu.h>
diff --git a/renderer/library/src/opengl/opengl_shaders.cpp b/renderer/library/src/opengl/opengl_shaders.cpp
index 9da09c9..9e8560d 100644
--- a/renderer/library/src/opengl/opengl_shaders.cpp
+++ b/renderer/library/src/opengl/opengl_shaders.cpp
@@ -1,8 +1,8 @@
-const char* vertexShaderSource = R"""(
-#version 330 core
-layout (location = 0) in vec2 position;
+const char* vertexShaderSource = R"""(#version 300 es
+
+ layout(location = 0) in vec2 position;
out vec2 pos;
@@ -10,15 +10,14 @@
uniform mat4 transform;
uniform mat4 localTransform;
-void main()
+void main()
{
- gl_Position = projection*transform*vec4(position, 0.0, 1.0);
- pos = (localTransform*vec4(position, 0.0, 1.0)).xy;
+ gl_Position = projection * transform * vec4(position, 0.0, 1.0);
+ pos = (localTransform * vec4(position, 0.0, 1.0)).xy;
}
)""";
-const char* fragmentShaderSource = R"""(
-#version 330 core
+const char* fragmentShaderSource = R"""(#version 300 es
#ifdef GL_ES
precision highp float;
@@ -35,59 +34,58 @@
void main()
{
- if (fillType == 0)
- {
- // solid
- fragColor = color;//vec4(color.rgb * color.a, color.a);
- }
- else if (fillType == 1)
- {
- // linear
+ if (fillType == 0)
+ {
+ // solid
+ fragColor = color; // vec4(color.rgb * color.a, color.a);
+ }
+ else if (fillType == 1)
+ {
+ // linear
- vec2 start = position.xy;
- vec2 end = position.zw;
+ vec2 start = position.xy;
+ vec2 end = position.zw;
-
- vec2 toEnd = end - start;
- float lengthSquared = toEnd.x * toEnd.x + toEnd.y * toEnd.y;
- float f = dot(pos - start, toEnd) / lengthSquared;
- fragColor =
- mix(colors[0], colors[1], smoothstep(stops[0], stops[1], f));
- for (int i = 1; i < 15; ++i)
- {
- if (i >= count - 1)
- {
- break;
- }
- fragColor = mix(fragColor,
- colors[i + 1],
- smoothstep(stops[i], stops[i + 1], f));
- }
- // float alpha = fragColor.w;
- // fragColor = vec4(fragColor.xyz * alpha, alpha);
- }
- else if (fillType == 2)
- {
- // radial
+ vec2 toEnd = end - start;
+ float lengthSquared = toEnd.x * toEnd.x + toEnd.y * toEnd.y;
+ float f = dot(pos - start, toEnd) / lengthSquared;
+ fragColor =
+ mix(colors[0], colors[1], smoothstep(stops[0], stops[1], f));
+ for (int i = 1; i < 15; ++i)
+ {
+ if (i >= count - 1)
+ {
+ break;
+ }
+ fragColor = mix(fragColor,
+ colors[i + 1],
+ smoothstep(stops[i], stops[i + 1], f));
+ }
+ // float alpha = fragColor.w;
+ // fragColor = vec4(fragColor.xyz * alpha, alpha);
+ }
+ else if (fillType == 2)
+ {
+ // radial
- vec2 start = position.xy;
- vec2 end = position.zw;
-
- float f = distance(start, pos) / distance(start, end);
- fragColor =
- mix(colors[0], colors[1], smoothstep(stops[0], stops[1], f));
- for (int i = 1; i < 15; ++i)
- {
- if (i >= count - 1)
- {
- break;
- }
- fragColor = mix(fragColor,
- colors[i + 1],
- smoothstep(stops[i], stops[i + 1], f));
- }
- // float alpha = fragColor.w;
- // fragColor = vec4(fragColor.xyz * alpha, alpha);
- }
+ vec2 start = position.xy;
+ vec2 end = position.zw;
+
+ float f = distance(start, pos) / distance(start, end);
+ fragColor =
+ mix(colors[0], colors[1], smoothstep(stops[0], stops[1], f));
+ for (int i = 1; i < 15; ++i)
+ {
+ if (i >= count - 1)
+ {
+ break;
+ }
+ fragColor = mix(fragColor,
+ colors[i + 1],
+ smoothstep(stops[i], stops[i + 1], f));
+ }
+ // float alpha = fragColor.w;
+ // fragColor = vec4(fragColor.xyz * alpha, alpha);
+ }
}
)""";
\ No newline at end of file