Skip to content

Commit 21dc9df

Browse files
authored
Use angle as GL provider on Kivy 3.0.0.dev0 (and above) (#928)
* WIP TESTS ANGLE * WIP * WIP * Revert some defaults, disable opengl only on sdl3 * Revert OpenGLES removal * Patch setup only in case of sdl2 usage (sdl3 uses angle) * Revery kivy version to default * Update angle to latest release
1 parent 70c89c2 commit 21dc9df

File tree

6 files changed

+91
-5
lines changed

6 files changed

+91
-5
lines changed

kivy_ios/recipes/angle/__init__.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import os
2+
import shutil
3+
4+
from kivy_ios.toolchain import GenericPlatform, Recipe, cache_execution
5+
6+
7+
class IphoneAllUniversalPlatform(GenericPlatform):
8+
9+
@property
10+
def name(self):
11+
return "iphoneall-universal"
12+
13+
14+
class ANGLERecipe(Recipe):
15+
version = "chromium-7151_rev1"
16+
url = "https://github.com/kivy/angle-builder/releases/download/{version}/angle-iphoneall-universal.tar.gz"
17+
include_dir = ["include"]
18+
libraries = ["libEGL.a", "libGLESv2.a"]
19+
20+
@property
21+
def platforms_to_build(self):
22+
yield IphoneAllUniversalPlatform(self.ctx)
23+
24+
@cache_execution
25+
def build_all(self):
26+
self.install_include()
27+
self.install()
28+
29+
@cache_execution
30+
def install(self):
31+
xcframework_folder = os.path.join(self.ctx.dist_dir, "xcframework")
32+
33+
build_dir = self.get_build_dir(
34+
plat=IphoneAllUniversalPlatform(self.ctx)
35+
)
36+
37+
for fn in os.listdir(build_dir):
38+
if fn.endswith(".xcframework"):
39+
shutil.copytree(
40+
os.path.join(build_dir, fn),
41+
os.path.join(xcframework_folder, fn),
42+
dirs_exist_ok=True,
43+
)
44+
45+
46+
recipe = ANGLERecipe()

kivy_ios/recipes/kivy/__init__.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ class KivyRecipe(CythonRecipe):
2727
"urllib3",
2828
"filetype",
2929
]
30-
pbx_frameworks = [
31-
"OpenGLES",
30+
_base_pbx_frameworks = [
3231
"Accelerate",
3332
"CoreMedia",
3433
"CoreVideo",
@@ -85,6 +84,21 @@ def get_required_sdl_version(self):
8584

8685
return self._required_sdl_version
8786

87+
@property
88+
def pbx_frameworks(self):
89+
if self.get_required_sdl_version() == "sdl2":
90+
return self._base_pbx_frameworks + [
91+
"OpenGLES",
92+
]
93+
elif self.get_required_sdl_version() == "sdl3":
94+
return self._base_pbx_frameworks + [
95+
"Metal",
96+
]
97+
else:
98+
raise ValueError(
99+
f"Unsupported SDL version: {self.get_required_sdl_version()}"
100+
)
101+
88102
@property
89103
def depends(self):
90104
if self.get_required_sdl_version() == "sdl2":
@@ -100,6 +114,7 @@ def depends(self):
100114
"sdl3_image",
101115
"sdl3_ttf",
102116
"sdl3_mixer",
117+
"angle",
103118
]
104119
else:
105120
raise ValueError(
@@ -118,7 +133,8 @@ def get_recipe_env(self, plat):
118133
]
119134
)
120135
elif self.get_required_sdl_version() == "sdl3":
121-
env["USE_ANGLE_GL_BACKEND"] = "0"
136+
env["KIVY_ANGLE_INCLUDE_DIR"] = join(self.ctx.dist_dir, "include", "common", "angle")
137+
env["KIVY_ANGLE_LIB_DIR"] = join(self.ctx.dist_dir, "frameworks", plat.sdk)
122138
env["KIVY_SDL3_PATH"] = ":".join(
123139
[
124140
join(self.ctx.dist_dir, "include", "common", "sdl3"),
@@ -154,7 +170,8 @@ def get_recipe_env(self, plat):
154170
return env
155171

156172
def build_platform(self, plat):
157-
self._patch_setup()
173+
if self.get_required_sdl_version() == "sdl2":
174+
self._patch_setup()
158175
super().build_platform(plat)
159176

160177
def _patch_setup(self):

kivy_ios/recipes/sdl3/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def prebuild_platform(self, plat):
2727
if self.has_marker("patched"):
2828
return
2929
self.apply_patch("uikit-transparent.patch")
30-
# self.apply_patch("disable-hidapi.patch")
30+
self.apply_patch("disable-opengl.patch")
3131
self.set_marker("patched")
3232

3333
def build_platform(self, plat):
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--- SDL3-3.2.8/include/build_config/SDL_build_config_ios.h.orig 2025-06-26 21:36:13
2+
+++ SDL3-3.2.8/include/build_config/SDL_build_config_ios.h 2025-06-26 21:37:02
3+
@@ -177,9 +177,9 @@
4+
5+
/* Enable OpenGL ES */
6+
#if !TARGET_OS_MACCATALYST && !TARGET_OS_VISION
7+
-#define SDL_VIDEO_OPENGL_ES2 1
8+
-#define SDL_VIDEO_OPENGL_ES 1
9+
-#define SDL_VIDEO_RENDER_OGL_ES2 1
10+
+#define SDL_VIDEO_OPENGL_ES2 0
11+
+#define SDL_VIDEO_OPENGL_ES 0
12+
+#define SDL_VIDEO_RENDER_OGL_ES2 0
13+
#endif
14+
15+
/* Metal supported on 64-bit devices running iOS 8.0 and tvOS 9.0 and newer

kivy_ios/tools/liblink

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ while i < len(sys.argv):
2323
libs.append(opt)
2424
continue
2525

26+
if opt.startswith("-F"):
27+
libs.append(opt)
28+
continue
29+
2630
if opt in ("-r", "-pipe", "-no-cpp-precomp"):
2731
continue
2832

kivy_ios/tools/templates/{{ cookiecutter.project_name }}-ios/main.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ int main(int argc, char *argv[]) {
3838
putenv("KIVY_AUDIO=sdl2");
3939
putenv("KIVY_GL_BACKEND=sdl2");
4040

41+
// WIP_ Will move to angle and sdl3 as default in the future
42+
// Set KIVY_GL_BACKEND=angle if building for kivy==master branch
43+
// putenv("KIVY_GL_BACKEND=angle");
44+
4145
// IOS_IS_WINDOWED=True disables fullscreen and then statusbar is shown
4246
putenv("IOS_IS_WINDOWED=False");
4347

0 commit comments

Comments
 (0)