From 4263d65090721aaf93718349a1165d8bb320f771 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB=20=D0=9A=D0=B0=D0=BF?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BA=D0=BE?= Date: Mon, 26 Oct 2026 06:27:28 +0300 Subject: [PATCH 01/55] =?UTF-8?q?=D0=BF=D1=83=D1=81=D1=82=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -- 2.53.0 From 5a875b44a8f234d9a29d691928fc9063288f554d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB=20=D0=9A=D0=B0=D0=BF?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BA=D0=BE?= Date: Mon, 26 Oct 2026 06:51:45 +0300 Subject: [PATCH 02/55] ref --- README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 6db0e2d..e71c0bb 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,10 @@ ## Prerequisites -* macOS +### macOS - `brew install raylib` +* `brew install raylib` -* iOS +### iOS - `brew install xcodegen` +* `brew install xcodegen` +* [ghera/raylib-iOS](https://github.com/ghera/raylib-iOS) -- 2.53.0 From 6e5a355fc856463d9bdef22a4cd339b97f129ea8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB=20=D0=9A=D0=B0=D0=BF?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BA=D0=BE?= Date: Mon, 26 Oct 2026 07:11:33 +0300 Subject: [PATCH 03/55] check for raylib ios --- util/paths | 2 ++ util/prepare-ogs-blue-ios | 1 + util/step/checkRaylibIOS | 15 +++++++++++++++ 3 files changed, 18 insertions(+) create mode 100755 util/step/checkRaylibIOS diff --git a/util/paths b/util/paths index e69de29..3c59328 100644 --- a/util/paths +++ b/util/paths @@ -0,0 +1,2 @@ +RAYLIB_IOS_EGL="raylib-iOS/deps/ANGLE/libEGL.xcframework" +RAYLIB_IOS_GLES="raylib-iOS/deps/ANGLE/libGLESv2.xcframework" diff --git a/util/prepare-ogs-blue-ios b/util/prepare-ogs-blue-ios index e523f01..d243173 100755 --- a/util/prepare-ogs-blue-ios +++ b/util/prepare-ogs-blue-ios @@ -7,5 +7,6 @@ source $SDIR/paths TARGET=ogs-blue STEP=0 +source $T/checkRaylibIOS $TARGET source $T/generateDialect $TARGET source $T/prepareIOS $TARGET diff --git a/util/step/checkRaylibIOS b/util/step/checkRaylibIOS new file mode 100755 index 0000000..d127a9b --- /dev/null +++ b/util/step/checkRaylibIOS @@ -0,0 +1,15 @@ +#!/bin/bash -e + +DEP="raylib-iOS" + +STEP=$((STEP+1)) +echo -e "\n> > > > Step №$STEP. Check $DEP presence" + +MISSING=0 +[[ -e $SDIR/../../$RAYLIB_IOS_EGL ]] || MISSING=1 +[[ -e $SDIR/../../$RAYLIB_IOS_GLES ]] || MISSING=1 + +if [[ $MISSING -eq 1 ]]; then + echo "$DEP not found alongside this project" + exit 1 +fi -- 2.53.0 From 7e511afb73b7b254d3c2ad251a18990d0cffe0b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB=20=D0=9A=D0=B0=D0=BF?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BA=D0=BE?= Date: Mon, 26 Oct 2026 16:02:28 +0300 Subject: [PATCH 04/55] along --- README.md | 5 ++++- util/paths | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e71c0bb..ab78226 100644 --- a/README.md +++ b/README.md @@ -7,4 +7,7 @@ ### iOS * `brew install xcodegen` -* [ghera/raylib-iOS](https://github.com/ghera/raylib-iOS) +* ghera's [raylib-ios-xcframeworks-6.2.0-iOS][ghera-raylib-zip] release unpacked and placed alongside the project + + +[ghera-raylib-zip]: diff --git a/util/paths b/util/paths index 3c59328..a6c1c8a 100644 --- a/util/paths +++ b/util/paths @@ -1,2 +1,3 @@ RAYLIB_IOS_EGL="raylib-iOS/deps/ANGLE/libEGL.xcframework" RAYLIB_IOS_GLES="raylib-iOS/deps/ANGLE/libGLESv2.xcframework" +RAYLIB_IOS="raylib-iOS-xcframeworks/raylib.xcframework" "$FRAMEWORKS/" -- 2.53.0 From 3ee51fd3551a53f1de72ca1ae67dde76eb117ca5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB=20=D0=9A=D0=B0=D0=BF?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BA=D0=BE?= Date: Mon, 26 Oct 2026 16:03:24 +0300 Subject: [PATCH 05/55] url --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ab78226..22ee284 100644 --- a/README.md +++ b/README.md @@ -10,4 +10,4 @@ * ghera's [raylib-ios-xcframeworks-6.2.0-iOS][ghera-raylib-zip] release unpacked and placed alongside the project -[ghera-raylib-zip]: +[ghera-raylib-zip]: https://github.com/ghera/raylib-iOS/releases/download/6.2.0-iOS/raylib-ios-xcframeworks-6.2.0-iOS.zip -- 2.53.0 From 9101b9f5d46de621603b2bb24a48738c0a4b2b75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB=20=D0=9A=D0=B0=D0=BF?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BA=D0=BE?= Date: Mon, 26 Oct 2026 16:04:55 +0300 Subject: [PATCH 06/55] some --- README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 22ee284..103bb52 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,6 @@ ### iOS * `brew install xcodegen` -* ghera's [raylib-ios-xcframeworks-6.2.0-iOS][ghera-raylib-zip] release unpacked and placed alongside the project +* ghera's [raylib-ios-xcframeworks][rzip] release unpacked and placed alongside the project - -[ghera-raylib-zip]: https://github.com/ghera/raylib-iOS/releases/download/6.2.0-iOS/raylib-ios-xcframeworks-6.2.0-iOS.zip +[rzip]: https://github.com/ghera/raylib-iOS/releases/download/6.2.0-iOS/raylib-ios-xcframeworks-6.2.0-iOS.zip -- 2.53.0 From cfd9f9c0af20da112bbfb07e0558efaa606cc9df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB=20=D0=9A=D0=B0=D0=BF?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BA=D0=BE?= Date: Mon, 26 Oct 2026 16:12:01 +0300 Subject: [PATCH 07/55] ref bin zip --- util/paths | 6 +++--- util/step/checkRaylibIOS | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/util/paths b/util/paths index a6c1c8a..eb1f91f 100644 --- a/util/paths +++ b/util/paths @@ -1,3 +1,3 @@ -RAYLIB_IOS_EGL="raylib-iOS/deps/ANGLE/libEGL.xcframework" -RAYLIB_IOS_GLES="raylib-iOS/deps/ANGLE/libGLESv2.xcframework" -RAYLIB_IOS="raylib-iOS-xcframeworks/raylib.xcframework" "$FRAMEWORKS/" +RAYLIB_IOS="raylib-ios-xcframeworks/raylib.xcframework" +RAYLIB_IOS_EGL="raylib-ios-xcframeworks/libEGL.xcframework" +RAYLIB_IOS_GLES="raylib-ios-xcframeworks/libGLESv2.xcframework" diff --git a/util/step/checkRaylibIOS b/util/step/checkRaylibIOS index d127a9b..001f4f7 100755 --- a/util/step/checkRaylibIOS +++ b/util/step/checkRaylibIOS @@ -1,15 +1,16 @@ #!/bin/bash -e -DEP="raylib-iOS" +DEP="raylib-ios-xcframeworks" STEP=$((STEP+1)) echo -e "\n> > > > Step №$STEP. Check $DEP presence" MISSING=0 +[[ -e $SDIR/../../$RAYLIB_IOS ]] || MISSING=1 [[ -e $SDIR/../../$RAYLIB_IOS_EGL ]] || MISSING=1 [[ -e $SDIR/../../$RAYLIB_IOS_GLES ]] || MISSING=1 if [[ $MISSING -eq 1 ]]; then - echo "$DEP not found alongside this project" + echo "ERROR $DEP not found alongside this project" exit 1 fi -- 2.53.0 From d0b45b6b99caff041307e963e2024c5784518fc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB=20=D0=9A=D0=B0=D0=BF?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BA=D0=BE?= Date: Mon, 26 Oct 2026 16:41:18 +0300 Subject: [PATCH 08/55] proj a bitr --- util/prepare-ogs-blue-ios | 3 ++- util/step/{prepareIOS => generateIOS} | 0 util/step/prepareANGLE | 22 ++++++++++++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) rename util/step/{prepareIOS => generateIOS} (100%) create mode 100755 util/step/prepareANGLE diff --git a/util/prepare-ogs-blue-ios b/util/prepare-ogs-blue-ios index d243173..6135231 100755 --- a/util/prepare-ogs-blue-ios +++ b/util/prepare-ogs-blue-ios @@ -9,4 +9,5 @@ TARGET=ogs-blue STEP=0 source $T/checkRaylibIOS $TARGET source $T/generateDialect $TARGET -source $T/prepareIOS $TARGET +source $T/prepareANGLE $TARGET +source $T/generateIOS $TARGET diff --git a/util/step/prepareIOS b/util/step/generateIOS similarity index 100% rename from util/step/prepareIOS rename to util/step/generateIOS diff --git a/util/step/prepareANGLE b/util/step/prepareANGLE new file mode 100755 index 0000000..868a4b6 --- /dev/null +++ b/util/step/prepareANGLE @@ -0,0 +1,22 @@ +#!/bin/bash -e + +TARGET=$1 + +STEP=$((STEP+1)) +echo -e "\n> > > > Step №$STEP. Prepare ANGLE includes for '$TARGET'" + +BUILD=$SDIR/../$TARGET/ver-ios/.build +INC=$BUILD/include +LIB=$BUILD/lib +mkdir -p $INC $LIB + +# Create EGL and GLES symlinks because their internal includes refer to each other +# without knowing of XCFramework bounderies +ln -sfn "$SDIR/../../$RAYLIB_IOS_EGL/ios-arm64_x86_64-simulator/libEGL.framework/Headers" "$INC/libEGL" +ln -sfn "$SDIR/../../$RAYLIB_IOS_GLES/ios-arm64_x86_64-simulator/libGLESv2.framework/Headers" "$INC/libGLESv2" + +# Symlink libraries for convenience, too + +ln -sfn "$SDIR/../../$RAYLIB_IOS" "$LIB" +ln -sfn "$SDIR/../../$RAYLIB_IOS_EGL" "$LIB" +ln -sfn "$SDIR/../../$RAYLIB_IOS_GLES" "$LIB" -- 2.53.0 From 1c841a18bbeef0e4401aeae14c53bb65338f1985 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB=20=D0=9A=D0=B0=D0=BF?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BA=D0=BE?= Date: Mon, 26 Oct 2026 16:42:24 +0300 Subject: [PATCH 09/55] embed angle into ios --- ogs-blue/ver-ios/project.yml | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/ogs-blue/ver-ios/project.yml b/ogs-blue/ver-ios/project.yml index da9deba..ef45776 100644 --- a/ogs-blue/ver-ios/project.yml +++ b/ogs-blue/ver-ios/project.yml @@ -3,13 +3,28 @@ options: bundleIdPrefix: org.opengamestudio targets: ogs-blue: - type: application - platform: iOS + dependencies: + - framework: .build/lib/libEGL.xcframework + embed: true + - framework: .build/lib/libGLESv2.xcframework + embed: true deploymentTarget: "15.0" + platform: iOS sources: - path: Assets.xcassets - path: src settings: base: - PRODUCT_BUNDLE_IDENTIFIER: org.opengamestudio.blue + GCC_PREPROCESSOR_DEFINITIONS: + - PLATFORM_IOS=1 + - GRAPHICS_API_OPENGL_ES3=1 + - GL_GLEXT_PROTOTYPES=1 + HEADER_SEARCH_PATHS: + - "$(SRCROOT)/.build/include" + - "$(SRCROOT)/.build/lib/raylib.xcframework/ios-arm64_x86_64-simulator/raylib.framework/Headers" + - "$(SRCROOT)/.build/lib/raylib.xcframework/ios-arm64/raylib.framework/Headers" INFOPLIST_FILE: Info.plist + LD_RUNPATH_SEARCH_PATHS: + - "$(inherited) @executable_path/Frameworks" + PRODUCT_BUNDLE_IDENTIFIER: org.opengamestudio.blue + type: application -- 2.53.0 From 21605f98b4c8558593c7cf785116bfca347463ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB=20=D0=9A=D0=B0=D0=BF?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BA=D0=BE?= Date: Tue, 27 Oct 2026 06:39:07 +0300 Subject: [PATCH 10/55] raybri mac --- components/raybri/{ => mac}/raybri.c | 0 components/raybri/{ => mac}/raybriAux.c | 0 components/raybri/{ => mac}/raybriAux.h | 0 components/raybri/{ => mac}/raybriConst.c | 0 components/raybri/{ => mac}/raybriConst.h | 0 5 files changed, 0 insertions(+), 0 deletions(-) rename components/raybri/{ => mac}/raybri.c (100%) rename components/raybri/{ => mac}/raybriAux.c (100%) rename components/raybri/{ => mac}/raybriAux.h (100%) rename components/raybri/{ => mac}/raybriConst.c (100%) rename components/raybri/{ => mac}/raybriConst.h (100%) diff --git a/components/raybri/raybri.c b/components/raybri/mac/raybri.c similarity index 100% rename from components/raybri/raybri.c rename to components/raybri/mac/raybri.c diff --git a/components/raybri/raybriAux.c b/components/raybri/mac/raybriAux.c similarity index 100% rename from components/raybri/raybriAux.c rename to components/raybri/mac/raybriAux.c diff --git a/components/raybri/raybriAux.h b/components/raybri/mac/raybriAux.h similarity index 100% rename from components/raybri/raybriAux.h rename to components/raybri/mac/raybriAux.h diff --git a/components/raybri/raybriConst.c b/components/raybri/mac/raybriConst.c similarity index 100% rename from components/raybri/raybriConst.c rename to components/raybri/mac/raybriConst.c diff --git a/components/raybri/raybriConst.h b/components/raybri/mac/raybriConst.h similarity index 100% rename from components/raybri/raybriConst.h rename to components/raybri/mac/raybriConst.h -- 2.53.0 From e3844dfb188cf69a563ddf663e51c75f701ffa3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB=20=D0=9A=D0=B0=D0=BF?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BA=D0=BE?= Date: Tue, 27 Oct 2026 06:42:09 +0300 Subject: [PATCH 11/55] ysm --- ogs-blue/ver-mac/src/raybri/raybri.c | 2 +- ogs-blue/ver-mac/src/raybri/raybriAux.c | 2 +- ogs-blue/ver-mac/src/raybri/raybriAux.h | 2 +- ogs-blue/ver-mac/src/raybri/raybriConst.c | 2 +- ogs-blue/ver-mac/src/raybri/raybriConst.h | 2 +- ogs-chkgfx/ver-mac/src/raybri/raybri.c | 2 +- ogs-chkgfx/ver-mac/src/raybri/raybriAux.c | 1 + ogs-chkgfx/ver-mac/src/raybri/raybriAux.h | 1 + ogs-chkgfx/ver-mac/src/raybri/raybriConst.c | 2 +- ogs-chkgfx/ver-mac/src/raybri/raybriConst.h | 2 +- 10 files changed, 10 insertions(+), 8 deletions(-) create mode 120000 ogs-chkgfx/ver-mac/src/raybri/raybriAux.c create mode 120000 ogs-chkgfx/ver-mac/src/raybri/raybriAux.h diff --git a/ogs-blue/ver-mac/src/raybri/raybri.c b/ogs-blue/ver-mac/src/raybri/raybri.c index 52b1940..80f2251 120000 --- a/ogs-blue/ver-mac/src/raybri/raybri.c +++ b/ogs-blue/ver-mac/src/raybri/raybri.c @@ -1 +1 @@ -../../../../components/raybri/raybri.c \ No newline at end of file +../../../../components/raybri/mac/raybri.c \ No newline at end of file diff --git a/ogs-blue/ver-mac/src/raybri/raybriAux.c b/ogs-blue/ver-mac/src/raybri/raybriAux.c index 377245e..36bd50c 120000 --- a/ogs-blue/ver-mac/src/raybri/raybriAux.c +++ b/ogs-blue/ver-mac/src/raybri/raybriAux.c @@ -1 +1 @@ -../../../../components/raybri/raybriAux.c \ No newline at end of file +../../../../components/raybri/mac/raybriAux.c \ No newline at end of file diff --git a/ogs-blue/ver-mac/src/raybri/raybriAux.h b/ogs-blue/ver-mac/src/raybri/raybriAux.h index 1033d69..ebb7346 120000 --- a/ogs-blue/ver-mac/src/raybri/raybriAux.h +++ b/ogs-blue/ver-mac/src/raybri/raybriAux.h @@ -1 +1 @@ -../../../../components/raybri/raybriAux.h \ No newline at end of file +../../../../components/raybri/mac/raybriAux.h \ No newline at end of file diff --git a/ogs-blue/ver-mac/src/raybri/raybriConst.c b/ogs-blue/ver-mac/src/raybri/raybriConst.c index fe840ed..2656529 120000 --- a/ogs-blue/ver-mac/src/raybri/raybriConst.c +++ b/ogs-blue/ver-mac/src/raybri/raybriConst.c @@ -1 +1 @@ -../../../../components/raybri/raybriConst.c \ No newline at end of file +../../../../components/raybri/mac/raybriConst.c \ No newline at end of file diff --git a/ogs-blue/ver-mac/src/raybri/raybriConst.h b/ogs-blue/ver-mac/src/raybri/raybriConst.h index 7e1b994..f834a27 120000 --- a/ogs-blue/ver-mac/src/raybri/raybriConst.h +++ b/ogs-blue/ver-mac/src/raybri/raybriConst.h @@ -1 +1 @@ -../../../../components/raybri/raybriConst.h \ No newline at end of file +../../../../components/raybri/mac/raybriConst.h \ No newline at end of file diff --git a/ogs-chkgfx/ver-mac/src/raybri/raybri.c b/ogs-chkgfx/ver-mac/src/raybri/raybri.c index 52b1940..80f2251 120000 --- a/ogs-chkgfx/ver-mac/src/raybri/raybri.c +++ b/ogs-chkgfx/ver-mac/src/raybri/raybri.c @@ -1 +1 @@ -../../../../components/raybri/raybri.c \ No newline at end of file +../../../../components/raybri/mac/raybri.c \ No newline at end of file diff --git a/ogs-chkgfx/ver-mac/src/raybri/raybriAux.c b/ogs-chkgfx/ver-mac/src/raybri/raybriAux.c new file mode 120000 index 0000000..36bd50c --- /dev/null +++ b/ogs-chkgfx/ver-mac/src/raybri/raybriAux.c @@ -0,0 +1 @@ +../../../../components/raybri/mac/raybriAux.c \ No newline at end of file diff --git a/ogs-chkgfx/ver-mac/src/raybri/raybriAux.h b/ogs-chkgfx/ver-mac/src/raybri/raybriAux.h new file mode 120000 index 0000000..ebb7346 --- /dev/null +++ b/ogs-chkgfx/ver-mac/src/raybri/raybriAux.h @@ -0,0 +1 @@ +../../../../components/raybri/mac/raybriAux.h \ No newline at end of file diff --git a/ogs-chkgfx/ver-mac/src/raybri/raybriConst.c b/ogs-chkgfx/ver-mac/src/raybri/raybriConst.c index fe840ed..2656529 120000 --- a/ogs-chkgfx/ver-mac/src/raybri/raybriConst.c +++ b/ogs-chkgfx/ver-mac/src/raybri/raybriConst.c @@ -1 +1 @@ -../../../../components/raybri/raybriConst.c \ No newline at end of file +../../../../components/raybri/mac/raybriConst.c \ No newline at end of file diff --git a/ogs-chkgfx/ver-mac/src/raybri/raybriConst.h b/ogs-chkgfx/ver-mac/src/raybri/raybriConst.h index 7e1b994..f834a27 120000 --- a/ogs-chkgfx/ver-mac/src/raybri/raybriConst.h +++ b/ogs-chkgfx/ver-mac/src/raybri/raybriConst.h @@ -1 +1 @@ -../../../../components/raybri/raybriConst.h \ No newline at end of file +../../../../components/raybri/mac/raybriConst.h \ No newline at end of file -- 2.53.0 From 5a3f45dfa4cce89244d52f589792289d4b658e7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB=20=D0=9A=D0=B0=D0=BF?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BA=D0=BE?= Date: Tue, 27 Oct 2026 06:45:04 +0300 Subject: [PATCH 12/55] layer --- components/raybri/mac/raybri.c | 2 +- components/raybri/raybri.h | 2 +- components/render/renderEffect.swift | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/components/raybri/mac/raybri.c b/components/raybri/mac/raybri.c index 6593117..3115688 100644 --- a/components/raybri/mac/raybri.c +++ b/components/raybri/mac/raybri.c @@ -2,7 +2,7 @@ #include "raybriAux.h" #include "rlgl.h" -void raybriInit(void) { +void raybriInit(void *layer) { //SetTraceLogLevel(LOG_WARNING); // Load OpenGL extensions diff --git a/components/raybri/raybri.h b/components/raybri/raybri.h index 902f706..ef63e31 100644 --- a/components/raybri/raybri.h +++ b/components/raybri/raybri.h @@ -1,7 +1,7 @@ #ifndef RAYBRI_H #define RAYBRI_H -void raybriInit(void); +void raybriInit(void *layer); void raybriRender(int width, int height); void raybriShutdown(void); diff --git a/components/render/renderEffect.swift b/components/render/renderEffect.swift index ad3d568..31165ad 100644 --- a/components/render/renderEffect.swift +++ b/components/render/renderEffect.swift @@ -16,7 +16,7 @@ func renderInit(_ vm: RenderVM) { var swapInterval: Int32 = 1 vm.glView.openGLContext?.setValues(&swapInterval, for: .swapInterval) - raybriInit() + raybriInit(nil) } func renderStartTimer(_ vm: RenderVM) { -- 2.53.0 From dfe16133df8b625de4cba724f5745415027dc8fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB=20=D0=9A=D0=B0=D0=BF?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BA=D0=BE?= Date: Tue, 27 Oct 2026 07:06:17 +0300 Subject: [PATCH 13/55] a few ios --- components/raybri/ios/raybri.c | 36 +++++++++++++++++++++++++++++++ components/raybri/ios/raybriEGL.c | 20 +++++++++++++++++ components/raybri/ios/raybriEGL.h | 6 ++++++ components/raybri/mac/raybri.c | 6 ++++++ components/raybri/raybri.h | 1 + 5 files changed, 69 insertions(+) create mode 100644 components/raybri/ios/raybri.c create mode 100644 components/raybri/ios/raybriEGL.c create mode 100644 components/raybri/ios/raybriEGL.h diff --git a/components/raybri/ios/raybri.c b/components/raybri/ios/raybri.c new file mode 100644 index 0000000..9d22d62 --- /dev/null +++ b/components/raybri/ios/raybri.c @@ -0,0 +1,36 @@ +#include "raybri.h" +#include "rlgl.h" +#include + +void raybriInit(void *layer) { + //SetTraceLogLevel(LOG_WARNING); + + if (!raybriInitEGL()) { + raybriLog(stderr, "ERROR Could not initialize EGL") + } + + // Initialize raylib graphics layer with a placeholder 1x1 framebuffer size + // Graphics layer includes default texture, shader, render batch and OpenGL state + rlglInit(1, 1); + // Background is painted in blue + rlClearColor(0, 0, 255, 255); +} + +void raybriLog(const char *txt) { + fprintf(stderr, "Raybri: %s\n", txt); + fflush(stderr); +} + +void raybriRender(int width, int height) { + // Set the drawing area to the current pixel size + rlViewport(0, 0, width, height); + // Clear color and depth buffers for the next frame + rlClearScreenBuffers(); + // Draw any queued geometry + rlDrawRenderBatchActive(); +} + +void raybriShutdown(void) { + // Release rlgl buffers, shaders and textures + rlglClose(); +} diff --git a/components/raybri/ios/raybriEGL.c b/components/raybri/ios/raybriEGL.c new file mode 100644 index 0000000..8a15b58 --- /dev/null +++ b/components/raybri/ios/raybriEGL.c @@ -0,0 +1,20 @@ +#include +#include +#include "raybriEGL.h" + +bool raybriInitEGL(void) { + EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY); + if (display == EGL_NO_DISPLAY) { + return false; + } + + if (eglInitialize(display, NULL, NULL) == EGL_FALSE) { + return false; + } + + if (eglBindAPI(EGL_OPENGL_ES_API) == EGL_FALSE) { + return false; + } + + return true; +} diff --git a/components/raybri/ios/raybriEGL.h b/components/raybri/ios/raybriEGL.h new file mode 100644 index 0000000..4365fed --- /dev/null +++ b/components/raybri/ios/raybriEGL.h @@ -0,0 +1,6 @@ +#ifndef RAYBRI_EGL_H +#define RAYBRI_EGL_H + +bool raybriInitEGL(void); + +#endif // RAYBRI_EGL_H diff --git a/components/raybri/mac/raybri.c b/components/raybri/mac/raybri.c index 3115688..505c772 100644 --- a/components/raybri/mac/raybri.c +++ b/components/raybri/mac/raybri.c @@ -1,6 +1,7 @@ #include "raybri.h" #include "raybriAux.h" #include "rlgl.h" +#include void raybriInit(void *layer) { //SetTraceLogLevel(LOG_WARNING); @@ -14,6 +15,11 @@ void raybriInit(void *layer) { rlClearColor(0, 0, 255, 255); } +void raybriLog(const char *txt) { + fprintf(stderr, "Raybri: %s\n", txt); + fflush(stderr); +} + void raybriRender(int width, int height) { // Set the drawing area to the current pixel size rlViewport(0, 0, width, height); diff --git a/components/raybri/raybri.h b/components/raybri/raybri.h index ef63e31..3692975 100644 --- a/components/raybri/raybri.h +++ b/components/raybri/raybri.h @@ -2,6 +2,7 @@ #define RAYBRI_H void raybriInit(void *layer); +void raybriLog(const char *txt); void raybriRender(int width, int height); void raybriShutdown(void); -- 2.53.0 From 64bb22560c575223ea09cd84e8ab50b869ec74f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB=20=D0=9A=D0=B0=D0=BF?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BA=D0=BE?= Date: Wed, 28 Oct 2026 15:57:03 +0300 Subject: [PATCH 14/55] preapre more ios --- ogs-blue/ver-ios/project.yml | 5 +++-- ogs-blue/ver-ios/src/raybri/raybri.c | 1 + ogs-blue/ver-ios/src/raybri/raybri.h | 1 + ogs-blue/ver-ios/src/raybri/raybriEGL.c | 1 + ogs-blue/ver-ios/src/raybri/raybriEGL.h | 1 + 5 files changed, 7 insertions(+), 2 deletions(-) create mode 120000 ogs-blue/ver-ios/src/raybri/raybri.c create mode 120000 ogs-blue/ver-ios/src/raybri/raybri.h create mode 120000 ogs-blue/ver-ios/src/raybri/raybriEGL.c create mode 120000 ogs-blue/ver-ios/src/raybri/raybriEGL.h diff --git a/ogs-blue/ver-ios/project.yml b/ogs-blue/ver-ios/project.yml index ef45776..12310e8 100644 --- a/ogs-blue/ver-ios/project.yml +++ b/ogs-blue/ver-ios/project.yml @@ -16,9 +16,9 @@ targets: settings: base: GCC_PREPROCESSOR_DEFINITIONS: - - PLATFORM_IOS=1 - - GRAPHICS_API_OPENGL_ES3=1 - GL_GLEXT_PROTOTYPES=1 + - GRAPHICS_API_OPENGL_ES3=1 + - PLATFORM_IOS=1 HEADER_SEARCH_PATHS: - "$(SRCROOT)/.build/include" - "$(SRCROOT)/.build/lib/raylib.xcframework/ios-arm64_x86_64-simulator/raylib.framework/Headers" @@ -27,4 +27,5 @@ targets: LD_RUNPATH_SEARCH_PATHS: - "$(inherited) @executable_path/Frameworks" PRODUCT_BUNDLE_IDENTIFIER: org.opengamestudio.blue + SWIFT_OBJC_BRIDGING_HEADER: src/raybri/raybri.h type: application diff --git a/ogs-blue/ver-ios/src/raybri/raybri.c b/ogs-blue/ver-ios/src/raybri/raybri.c new file mode 120000 index 0000000..d36f47a --- /dev/null +++ b/ogs-blue/ver-ios/src/raybri/raybri.c @@ -0,0 +1 @@ +../../../../components/raybri/ios/raybri.c \ No newline at end of file diff --git a/ogs-blue/ver-ios/src/raybri/raybri.h b/ogs-blue/ver-ios/src/raybri/raybri.h new file mode 120000 index 0000000..daec20f --- /dev/null +++ b/ogs-blue/ver-ios/src/raybri/raybri.h @@ -0,0 +1 @@ +../../../../components/raybri/raybri.h \ No newline at end of file diff --git a/ogs-blue/ver-ios/src/raybri/raybriEGL.c b/ogs-blue/ver-ios/src/raybri/raybriEGL.c new file mode 120000 index 0000000..52503c2 --- /dev/null +++ b/ogs-blue/ver-ios/src/raybri/raybriEGL.c @@ -0,0 +1 @@ +../../../../components/raybri/ios/raybriEGL.c \ No newline at end of file diff --git a/ogs-blue/ver-ios/src/raybri/raybriEGL.h b/ogs-blue/ver-ios/src/raybri/raybriEGL.h new file mode 120000 index 0000000..7566dfa --- /dev/null +++ b/ogs-blue/ver-ios/src/raybri/raybriEGL.h @@ -0,0 +1 @@ +../../../../components/raybri/ios/raybriEGL.h \ No newline at end of file -- 2.53.0 From 9c5b2981317bb6f9f335b96975bfa9ea83316c93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB=20=D0=9A=D0=B0=D0=BF?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BA=D0=BE?= Date: Wed, 28 Oct 2026 16:00:39 +0300 Subject: [PATCH 15/55] ios --- components/raybri/ios/raybri.c | 3 ++- components/raybri/ios/raybriEGL.c | 2 +- components/raybri/ios/raybriEGL.h | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/components/raybri/ios/raybri.c b/components/raybri/ios/raybri.c index 9d22d62..f2b544a 100644 --- a/components/raybri/ios/raybri.c +++ b/components/raybri/ios/raybri.c @@ -1,11 +1,12 @@ #include "raybri.h" +#include "raybriEGL.h" #include "rlgl.h" #include void raybriInit(void *layer) { //SetTraceLogLevel(LOG_WARNING); - if (!raybriInitEGL()) { + if (!raybriEGLInit()) { raybriLog(stderr, "ERROR Could not initialize EGL") } diff --git a/components/raybri/ios/raybriEGL.c b/components/raybri/ios/raybriEGL.c index 8a15b58..d218fc1 100644 --- a/components/raybri/ios/raybriEGL.c +++ b/components/raybri/ios/raybriEGL.c @@ -2,7 +2,7 @@ #include #include "raybriEGL.h" -bool raybriInitEGL(void) { +bool raybriEGLInit(void) { EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY); if (display == EGL_NO_DISPLAY) { return false; diff --git a/components/raybri/ios/raybriEGL.h b/components/raybri/ios/raybriEGL.h index 4365fed..fba6768 100644 --- a/components/raybri/ios/raybriEGL.h +++ b/components/raybri/ios/raybriEGL.h @@ -1,6 +1,6 @@ #ifndef RAYBRI_EGL_H #define RAYBRI_EGL_H -bool raybriInitEGL(void); +bool raybriEGLInit(void); #endif // RAYBRI_EGL_H -- 2.53.0 From e6056ae8b2339d8a13fb19f5369bf14d0a4e567e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB=20=D0=9A=D0=B0=D0=BF?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BA=D0=BE?= Date: Wed, 28 Oct 2026 16:05:22 +0300 Subject: [PATCH 16/55] stdbool --- components/raybri/ios/raybri.c | 2 +- components/raybri/ios/raybriEGL.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/components/raybri/ios/raybri.c b/components/raybri/ios/raybri.c index f2b544a..a66b7bb 100644 --- a/components/raybri/ios/raybri.c +++ b/components/raybri/ios/raybri.c @@ -7,7 +7,7 @@ void raybriInit(void *layer) { //SetTraceLogLevel(LOG_WARNING); if (!raybriEGLInit()) { - raybriLog(stderr, "ERROR Could not initialize EGL") + raybriLog("ERROR Could not initialize EGL") } // Initialize raylib graphics layer with a placeholder 1x1 framebuffer size diff --git a/components/raybri/ios/raybriEGL.h b/components/raybri/ios/raybriEGL.h index fba6768..f2ff44d 100644 --- a/components/raybri/ios/raybriEGL.h +++ b/components/raybri/ios/raybriEGL.h @@ -1,6 +1,8 @@ #ifndef RAYBRI_EGL_H #define RAYBRI_EGL_H +#include + bool raybriEGLInit(void); #endif // RAYBRI_EGL_H -- 2.53.0 From 7361f5c212551bd75165f994f98a7fe319c2812c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB=20=D0=9A=D0=B0=D0=BF?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BA=D0=BE?= Date: Wed, 28 Oct 2026 16:06:04 +0300 Subject: [PATCH 17/55] sm --- components/raybri/ios/raybri.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/raybri/ios/raybri.c b/components/raybri/ios/raybri.c index a66b7bb..e0a9289 100644 --- a/components/raybri/ios/raybri.c +++ b/components/raybri/ios/raybri.c @@ -7,7 +7,7 @@ void raybriInit(void *layer) { //SetTraceLogLevel(LOG_WARNING); if (!raybriEGLInit()) { - raybriLog("ERROR Could not initialize EGL") + raybriLog("ERROR Could not initialize EGL"); } // Initialize raylib graphics layer with a placeholder 1x1 framebuffer size -- 2.53.0 From 433afa5f9edf8712a0d683135c80df11426914f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB=20=D0=9A=D0=B0=D0=BF?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BA=D0=BE?= Date: Wed, 28 Oct 2026 16:09:30 +0300 Subject: [PATCH 18/55] impl --- components/raybri/ios/raybri.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/components/raybri/ios/raybri.c b/components/raybri/ios/raybri.c index e0a9289..ce484d9 100644 --- a/components/raybri/ios/raybri.c +++ b/components/raybri/ios/raybri.c @@ -1,6 +1,9 @@ #include "raybri.h" #include "raybriEGL.h" + +#define RLGL_IMPLEMENTATION #include "rlgl.h" + #include void raybriInit(void *layer) { -- 2.53.0 From bfc4b22b48032ccdfd4b5f26c8b0d3b2efdb19c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB=20=D0=9A=D0=B0=D0=BF?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BA=D0=BE?= Date: Wed, 28 Oct 2026 16:10:37 +0300 Subject: [PATCH 19/55] build ios --- components/raybri/ios/raybriEGL.c | 2 -- components/raybri/ios/raybriEGL.h | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/components/raybri/ios/raybriEGL.c b/components/raybri/ios/raybriEGL.c index d218fc1..ab41570 100644 --- a/components/raybri/ios/raybriEGL.c +++ b/components/raybri/ios/raybriEGL.c @@ -1,5 +1,3 @@ -#include -#include #include "raybriEGL.h" bool raybriEGLInit(void) { diff --git a/components/raybri/ios/raybriEGL.h b/components/raybri/ios/raybriEGL.h index f2ff44d..7742002 100644 --- a/components/raybri/ios/raybriEGL.h +++ b/components/raybri/ios/raybriEGL.h @@ -1,6 +1,8 @@ #ifndef RAYBRI_EGL_H #define RAYBRI_EGL_H +#include +#include #include bool raybriEGLInit(void); -- 2.53.0 From 730da461c3bbc80fb995b50dd554e8da2579ad71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB=20=D0=9A=D0=B0=D0=BF?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BA=D0=BE?= Date: Wed, 28 Oct 2026 16:15:56 +0300 Subject: [PATCH 20/55] some --- components/render/ios/view/RenderView.swift | 10 ++++++++++ ogs-blue/ver-ios/src/BlueApp.swift | 6 +++++- ogs-blue/ver-ios/src/render/view/RenderView.swift | 1 + 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 components/render/ios/view/RenderView.swift create mode 120000 ogs-blue/ver-ios/src/render/view/RenderView.swift diff --git a/components/render/ios/view/RenderView.swift b/components/render/ios/view/RenderView.swift new file mode 100644 index 0000000..47a985c --- /dev/null +++ b/components/render/ios/view/RenderView.swift @@ -0,0 +1,10 @@ +import SwiftUI +import UIKit + +struct RenderView: UIViewRepresentable { + func makeUIView(context: Context) -> RenderGLView { + RenderVM.shared!.glView + } + + func updateUIView(_ uiView: RenderGLView, context: Context) {} +} diff --git a/ogs-blue/ver-ios/src/BlueApp.swift b/ogs-blue/ver-ios/src/BlueApp.swift index 85682a4..3133386 100644 --- a/ogs-blue/ver-ios/src/BlueApp.swift +++ b/ogs-blue/ver-ios/src/BlueApp.swift @@ -6,7 +6,11 @@ struct BlueApp: App { var body: some Scene { WindowGroup { - BlueView(appDelegate.blueVM) + ZStack { + RenderView() + .ignoreSafeArea() + BlueView(appDelegate.blueVM) + } } } } diff --git a/ogs-blue/ver-ios/src/render/view/RenderView.swift b/ogs-blue/ver-ios/src/render/view/RenderView.swift new file mode 120000 index 0000000..0f880a1 --- /dev/null +++ b/ogs-blue/ver-ios/src/render/view/RenderView.swift @@ -0,0 +1 @@ +../../../../../components/render/ios/view/RenderView.swift \ No newline at end of file -- 2.53.0 From 4d639fc6b5bee61ea4ab6a08b32e9242d6911e63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB=20=D0=9A=D0=B0=D0=BF?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BA=D0=BE?= Date: Wed, 28 Oct 2026 16:17:47 +0300 Subject: [PATCH 21/55] vm --- ogs-blue/ver-ios/src/AppDelegate.swift | 2 ++ ogs-blue/ver-ios/src/BlueApp.swift | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/ogs-blue/ver-ios/src/AppDelegate.swift b/ogs-blue/ver-ios/src/AppDelegate.swift index 28fa61b..335dee9 100644 --- a/ogs-blue/ver-ios/src/AppDelegate.swift +++ b/ogs-blue/ver-ios/src/AppDelegate.swift @@ -6,6 +6,8 @@ final class AppDelegate: { let blue = BlueComponent() let blueVM = BlueVM() + let render = RenderComponent() + let renderVM = RenderVM() func application( _ application: UIApplication, diff --git a/ogs-blue/ver-ios/src/BlueApp.swift b/ogs-blue/ver-ios/src/BlueApp.swift index 3133386..d63f771 100644 --- a/ogs-blue/ver-ios/src/BlueApp.swift +++ b/ogs-blue/ver-ios/src/BlueApp.swift @@ -8,7 +8,7 @@ struct BlueApp: App { WindowGroup { ZStack { RenderView() - .ignoreSafeArea() + .ignoresSafeArea() BlueView(appDelegate.blueVM) } } -- 2.53.0 From 36392764f7071b9b21931221b887bf918ee0eb91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB=20=D0=9A=D0=B0=D0=BF?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BA=D0=BE?= Date: Wed, 28 Oct 2026 16:28:44 +0300 Subject: [PATCH 22/55] sym --- components/render/ios/view/RenderGLView.swift | 3 +++ components/render/{ => mac}/renderAux.swift | 0 components/render/{ => mac}/renderEffect.swift | 0 ogs-blue/ver-mac/src/render/renderAux.swift | 2 +- ogs-blue/ver-mac/src/render/renderEffect.swift | 2 +- 5 files changed, 5 insertions(+), 2 deletions(-) rename components/render/{ => mac}/renderAux.swift (100%) rename components/render/{ => mac}/renderEffect.swift (100%) diff --git a/components/render/ios/view/RenderGLView.swift b/components/render/ios/view/RenderGLView.swift index 9580023..81bb49f 100644 --- a/components/render/ios/view/RenderGLView.swift +++ b/components/render/ios/view/RenderGLView.swift @@ -3,6 +3,9 @@ import UIKit final class RenderGLView: UIView { override init(frame: CGRect) { super.init(frame: frame) + + contentScaleFactor = UIScreen.main.scale + layer.contentsScale = contentScaleFactor } required init?(coder: NSCoder) { diff --git a/components/render/renderAux.swift b/components/render/mac/renderAux.swift similarity index 100% rename from components/render/renderAux.swift rename to components/render/mac/renderAux.swift diff --git a/components/render/renderEffect.swift b/components/render/mac/renderEffect.swift similarity index 100% rename from components/render/renderEffect.swift rename to components/render/mac/renderEffect.swift diff --git a/ogs-blue/ver-mac/src/render/renderAux.swift b/ogs-blue/ver-mac/src/render/renderAux.swift index 1975b82..a7dec7f 120000 --- a/ogs-blue/ver-mac/src/render/renderAux.swift +++ b/ogs-blue/ver-mac/src/render/renderAux.swift @@ -1 +1 @@ -../../../../components/render/renderAux.swift \ No newline at end of file +../../../../components/render/mac/renderAux.swift \ No newline at end of file diff --git a/ogs-blue/ver-mac/src/render/renderEffect.swift b/ogs-blue/ver-mac/src/render/renderEffect.swift index d269bb5..098053c 120000 --- a/ogs-blue/ver-mac/src/render/renderEffect.swift +++ b/ogs-blue/ver-mac/src/render/renderEffect.swift @@ -1 +1 @@ -../../../../components/render/renderEffect.swift \ No newline at end of file +../../../../components/render/mac/renderEffect.swift \ No newline at end of file -- 2.53.0 From 9d6c2aeb27c9f005880030c6f1c5de12d6449e79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB=20=D0=9A=D0=B0=D0=BF?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BA=D0=BE?= Date: Wed, 28 Oct 2026 16:46:36 +0300 Subject: [PATCH 23/55] prep --- components/render/ios/renderEffect.swift | 11 +++++ components/render/ios/view/RenderGLView.swift | 15 ++++++- components/render/mac/view/RenderGLView.swift | 2 +- ogs-blue/dialect.yml | 26 ++++++++--- ogs-blue/ver-mac/src/dialect.swift | 44 +++++++++++++++++++ 5 files changed, 89 insertions(+), 9 deletions(-) create mode 100644 components/render/ios/renderEffect.swift diff --git a/components/render/ios/renderEffect.swift b/components/render/ios/renderEffect.swift new file mode 100644 index 0000000..03b386b --- /dev/null +++ b/components/render/ios/renderEffect.swift @@ -0,0 +1,11 @@ +import Foundation + +func renderInit(_ vm: RenderVM) { + vm.glView.openGLContext?.makeCurrentContext() + + // Enable VSync + var swapInterval: Int32 = 1 + vm.glView.openGLContext?.setValues(&swapInterval, for: .swapInterval) + + raybriInit(nil) +} diff --git a/components/render/ios/view/RenderGLView.swift b/components/render/ios/view/RenderGLView.swift index 81bb49f..a9455ab 100644 --- a/components/render/ios/view/RenderGLView.swift +++ b/components/render/ios/view/RenderGLView.swift @@ -4,11 +4,22 @@ final class RenderGLView: UIView { override init(frame: CGRect) { super.init(frame: frame) - contentScaleFactor = UIScreen.main.scale - layer.contentsScale = contentScaleFactor + isOpaque = true + isUserInteractionEnabled = false } required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } + + override func didMoveToWindow() { + super.didMoveToWindow() + guard let window else { return } + renderSet(F.didPrepareIOSGL, true); + } + + override func layoutSubviews() { + super.layoutSubviews() + } + } diff --git a/components/render/mac/view/RenderGLView.swift b/components/render/mac/view/RenderGLView.swift index 4a56cd9..04acce2 100644 --- a/components/render/mac/view/RenderGLView.swift +++ b/components/render/mac/view/RenderGLView.swift @@ -17,7 +17,7 @@ final class RenderGLView: NSOpenGLView { override func prepareOpenGL() { super.prepareOpenGL() - renderSet(F.didPrepareGL, true) + renderSet(F.didPrepareMacGL, true) } override func reshape() { diff --git a/ogs-blue/dialect.yml b/ogs-blue/dialect.yml index 8784c03..ece6548 100644 --- a/ogs-blue/dialect.yml +++ b/ogs-blue/dialect.yml @@ -4,6 +4,12 @@ output: ver-mac/src/dialect.swift: type: swift +BlueContext: + type: context + fields: + didLaunch: Bool + didSetup: Bool + BlueComponent: type: component shoulds: @@ -15,18 +21,14 @@ BlueComponent: then: c.didLaunch = true -BlueContext: - type: context - fields: - didLaunch: Bool - didSetup: Bool - RenderContext: type: context fields: backingPixelSize: [Int32] didLaunch: Bool didPrepareGL: Bool + didPrepareIOSGL: Bool + didPrepareMacGL: Bool didSetup: Bool pixelSize: [Int32] reshapePixelSize: [Int32] @@ -48,6 +50,18 @@ RenderComponent: c.didLaunch == false then: c.didLaunch = true + didPrepareGL: + 1. For macOS: + if: + c.recentField == F.didPrepareMacGL + then: + c.didPrepareGL = true + 2. For iOS: + if: + c.recentField == F.didPrepareIOSGL && + !c.didPrepareGL + then: + c.didPrepareGL = true pixelSize: 1. Upon launch: if: diff --git a/ogs-blue/ver-mac/src/dialect.swift b/ogs-blue/ver-mac/src/dialect.swift index 19cbef9..411020e 100644 --- a/ogs-blue/ver-mac/src/dialect.swift +++ b/ogs-blue/ver-mac/src/dialect.swift @@ -122,6 +122,8 @@ public struct F { public static let backingPixelSize = "backingPixelSize" public static let didLaunch = "didLaunch" public static let didPrepareGL = "didPrepareGL" + public static let didPrepareIOSGL = "didPrepareIOSGL" + public static let didPrepareMacGL = "didPrepareMacGL" public static let didSetup = "didSetup" public static let pixelSize = "pixelSize" public static let reshapePixelSize = "reshapePixelSize" @@ -163,6 +165,8 @@ public struct RenderContext: DialectContext { public var backingPixelSize = [Int32]() public var didLaunch = Bool() public var didPrepareGL = Bool() + public var didPrepareIOSGL = Bool() + public var didPrepareMacGL = Bool() public var didSetup = Bool() public var pixelSize = [Int32]() public var reshapePixelSize = [Int32]() @@ -180,6 +184,12 @@ public struct RenderContext: DialectContext { else if (name == "didPrepareGL") { return didPrepareGL as! T } + else if (name == "didPrepareIOSGL") { + return didPrepareIOSGL as! T + } + else if (name == "didPrepareMacGL") { + return didPrepareMacGL as! T + } else if (name == "didSetup") { return didSetup as! T } @@ -209,6 +219,12 @@ public struct RenderContext: DialectContext { else if (name == "didPrepareGL") { didPrepareGL = value as! Bool } + else if (name == "didPrepareIOSGL") { + didPrepareIOSGL = value as! Bool + } + else if (name == "didPrepareMacGL") { + didPrepareMacGL = value as! Bool + } else if (name == "didSetup") { didSetup = value as! Bool } @@ -275,6 +291,33 @@ func renderShouldResetDidLaunch(_ c: RenderContext) -> RenderContext { return c } +func renderShouldResetDidPrepareGL(_ c: RenderContext) -> RenderContext { + var c = c + + /* 1. For macOS */ + if + c.recentField == F.didPrepareMacGL + { + c.didPrepareGL = true + c.recentField = F.didPrepareGL + return c + } + + /* 2. For iOS */ + if + c.recentField == F.didPrepareIOSGL && + !c.didPrepareGL + { + c.didPrepareGL = true + c.recentField = F.didPrepareGL + return c + } + + + c.recentField = DIALECT_CONTEXT_RECENT_FIELD_NONE + return c +} + func renderShouldResetPixelSize(_ c: RenderContext) -> RenderContext { var c = c @@ -322,6 +365,7 @@ func blueRegisterShoulds(_ ctrl: DialectController) { func renderRegisterShoulds(_ ctrl: DialectController) { [ renderShouldResetDidLaunch, + renderShouldResetDidPrepareGL, renderShouldResetPixelSize, ].forEach { f in -- 2.53.0 From 2ecd15e79ffcab98448a0380c2b5ff9824acc25c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB=20=D0=9A=D0=B0=D0=BF?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BA=D0=BE?= Date: Wed, 28 Oct 2026 16:47:39 +0300 Subject: [PATCH 24/55] oios --- components/render/ios/view/RenderGLView.swift | 3 +++ 1 file changed, 3 insertions(+) diff --git a/components/render/ios/view/RenderGLView.swift b/components/render/ios/view/RenderGLView.swift index a9455ab..ef189fc 100644 --- a/components/render/ios/view/RenderGLView.swift +++ b/components/render/ios/view/RenderGLView.swift @@ -15,6 +15,9 @@ final class RenderGLView: UIView { override func didMoveToWindow() { super.didMoveToWindow() guard let window else { return } + contentScaleFactor = window.screen.nativeScale + layer.contentsScale = contentScaleFactor + renderSet(F.didPrepareIOSGL, true); } -- 2.53.0 From 3f94adf13ab4d20c8fb6790dd36fed8c87cb51b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB=20=D0=9A=D0=B0=D0=BF?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BA=D0=BE?= Date: Wed, 28 Oct 2026 16:56:50 +0300 Subject: [PATCH 25/55] prep --- components/render/ios/renderAux.swift | 8 ++++++++ components/render/ios/view/RenderGLView.swift | 2 ++ 2 files changed, 10 insertions(+) create mode 100644 components/render/ios/renderAux.swift diff --git a/components/render/ios/renderAux.swift b/components/render/ios/renderAux.swift new file mode 100644 index 0000000..24316a9 --- /dev/null +++ b/components/render/ios/renderAux.swift @@ -0,0 +1,8 @@ +import UIKit + +func renderPixelSize(_ view: UIView) -> [Int32] { + let scale = view.contentScaleFactor + let w = Int32(max(1, (view.bounds.width * scale).rounded())) + let h = Int32(max(1, (view.bounds.height * scale).rounded())) + return [w, h] +} diff --git a/components/render/ios/view/RenderGLView.swift b/components/render/ios/view/RenderGLView.swift index ef189fc..606e111 100644 --- a/components/render/ios/view/RenderGLView.swift +++ b/components/render/ios/view/RenderGLView.swift @@ -23,6 +23,8 @@ final class RenderGLView: UIView { override func layoutSubviews() { super.layoutSubviews() + let ps = renderPixelSize(self) + renderSet(F.reshapePixelSize, ps) } } -- 2.53.0 From aa541a8e23758d273a9e0c84f6659ae5bef2f5b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB=20=D0=9A=D0=B0=D0=BF?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BA=D0=BE?= Date: Wed, 28 Oct 2026 16:57:22 +0300 Subject: [PATCH 26/55] some --- ogs-blue/ver-ios/src/render/renderAux.swift | 1 + ogs-blue/ver-ios/src/render/renderEffect.swift | 1 + ogs-blue/ver-ios/src/render/renderTMPIOS.swift | 2 -- 3 files changed, 2 insertions(+), 2 deletions(-) create mode 120000 ogs-blue/ver-ios/src/render/renderAux.swift create mode 120000 ogs-blue/ver-ios/src/render/renderEffect.swift diff --git a/ogs-blue/ver-ios/src/render/renderAux.swift b/ogs-blue/ver-ios/src/render/renderAux.swift new file mode 120000 index 0000000..c244730 --- /dev/null +++ b/ogs-blue/ver-ios/src/render/renderAux.swift @@ -0,0 +1 @@ +../../../../components/render/ios/renderAux.swift \ No newline at end of file diff --git a/ogs-blue/ver-ios/src/render/renderEffect.swift b/ogs-blue/ver-ios/src/render/renderEffect.swift new file mode 120000 index 0000000..725b279 --- /dev/null +++ b/ogs-blue/ver-ios/src/render/renderEffect.swift @@ -0,0 +1 @@ +../../../../components/render/ios/renderEffect.swift \ No newline at end of file diff --git a/ogs-blue/ver-ios/src/render/renderTMPIOS.swift b/ogs-blue/ver-ios/src/render/renderTMPIOS.swift index da0a587..3fba957 100644 --- a/ogs-blue/ver-ios/src/render/renderTMPIOS.swift +++ b/ogs-blue/ver-ios/src/render/renderTMPIOS.swift @@ -1,4 +1,2 @@ func renderDeinit(_ vm: RenderVM) { } -func renderInit(_ vm: RenderVM) { } -func renderLoadCubeModel(_ vm: RenderVM) { } func renderStartTimer(_ vm: RenderVM) { } -- 2.53.0 From 1dc202b1aff1d28c5f3856135a8f13ecca580f64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB=20=D0=9A=D0=B0=D0=BF?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BA=D0=BE?= Date: Wed, 28 Oct 2026 17:10:05 +0300 Subject: [PATCH 27/55] some --- components/render/ios/renderAux.swift | 4 +++ components/render/ios/renderConst.swift | 3 ++ components/render/ios/renderEffect.swift | 34 +++++++++++++++---- ogs-blue/ver-ios/src/render/renderConst.swift | 1 + .../ver-ios/src/render/renderTMPIOS.swift | 2 -- 5 files changed, 35 insertions(+), 9 deletions(-) create mode 100644 components/render/ios/renderConst.swift create mode 120000 ogs-blue/ver-ios/src/render/renderConst.swift delete mode 100644 ogs-blue/ver-ios/src/render/renderTMPIOS.swift diff --git a/components/render/ios/renderAux.swift b/components/render/ios/renderAux.swift index 24316a9..46205ef 100644 --- a/components/render/ios/renderAux.swift +++ b/components/render/ios/renderAux.swift @@ -1,5 +1,9 @@ import UIKit +func renderDraw(_ vm: RenderVM) { + raybriRender(vm.pixelSize[0], vm.pixelSize[1]) +} + func renderPixelSize(_ view: UIView) -> [Int32] { let scale = view.contentScaleFactor let w = Int32(max(1, (view.bounds.width * scale).rounded())) diff --git a/components/render/ios/renderConst.swift b/components/render/ios/renderConst.swift new file mode 100644 index 0000000..7b0a7c8 --- /dev/null +++ b/components/render/ios/renderConst.swift @@ -0,0 +1,3 @@ +// iOS render constants. The macOS renderConst.swift depends on AppKit, so the +// two platforms keep separate files. +let RENDER_FPS = 60.0 diff --git a/components/render/ios/renderEffect.swift b/components/render/ios/renderEffect.swift index 03b386b..4395f38 100644 --- a/components/render/ios/renderEffect.swift +++ b/components/render/ios/renderEffect.swift @@ -1,11 +1,31 @@ import Foundation +import QuartzCore +import UIKit + +func renderDeinit(_ vm: RenderVM) { + vm.timer?.invalidate() + vm.timer = nil + raybriShutdown() +} func renderInit(_ vm: RenderVM) { - vm.glView.openGLContext?.makeCurrentContext() - - // Enable VSync - var swapInterval: Int32 = 1 - vm.glView.openGLContext?.setValues(&swapInterval, for: .swapInterval) - - raybriInit(nil) + // UIKit has no NSOpenGLContext: EGL/ANGLE renders into the view's layer, + // so the layer is what the bridge needs to create its surface from. + let layer = Unmanaged.passUnretained(vm.glView.layer).toOpaque() + raybriInit(layer) +} + +func renderStartTimer(_ vm: RenderVM) { + // Make a time mark for calculating time delta + vm.startTime = CACurrentMediaTime() + + // Unlike macOS, UIKit never calls draw(_:) on the view, so the timer + // renders each frame itself. + let timer = Timer(timeInterval: 1.0 / RENDER_FPS, repeats: true) { [weak vm] _ in + guard let vm else { return } + renderDraw(vm) + } + vm.timer = timer + // .common means holding buttons in UI does not pause this rendering timer + RunLoop.main.add(timer, forMode: .common) } diff --git a/ogs-blue/ver-ios/src/render/renderConst.swift b/ogs-blue/ver-ios/src/render/renderConst.swift new file mode 120000 index 0000000..ff2ffaf --- /dev/null +++ b/ogs-blue/ver-ios/src/render/renderConst.swift @@ -0,0 +1 @@ +../../../../components/render/ios/renderConst.swift \ No newline at end of file diff --git a/ogs-blue/ver-ios/src/render/renderTMPIOS.swift b/ogs-blue/ver-ios/src/render/renderTMPIOS.swift deleted file mode 100644 index 3fba957..0000000 --- a/ogs-blue/ver-ios/src/render/renderTMPIOS.swift +++ /dev/null @@ -1,2 +0,0 @@ -func renderDeinit(_ vm: RenderVM) { } -func renderStartTimer(_ vm: RenderVM) { } -- 2.53.0 From 701e3a983a5466d19f70e6b14b239f5293df7898 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB=20=D0=9A=D0=B0=D0=BF?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BA=D0=BE?= Date: Wed, 28 Oct 2026 17:12:58 +0300 Subject: [PATCH 28/55] setup --- ogs-blue/ver-ios/src/AppDelegate.swift | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ogs-blue/ver-ios/src/AppDelegate.swift b/ogs-blue/ver-ios/src/AppDelegate.swift index 335dee9..b98c522 100644 --- a/ogs-blue/ver-ios/src/AppDelegate.swift +++ b/ogs-blue/ver-ios/src/AppDelegate.swift @@ -15,6 +15,8 @@ final class AppDelegate: ) -> Bool { otherSetupConsoleLogging(blue.ctrl, "Blue") blue.setup() + otherSetupConsoleLogging(render.ctrl, "Render") + render.setup() return true } -- 2.53.0 From d613f3ace1a4e49b62b63528b88ed6ab76da9ff0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB=20=D0=9A=D0=B0=D0=BF?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BA=D0=BE?= Date: Wed, 28 Oct 2026 17:16:18 +0300 Subject: [PATCH 29/55] some --- components/render/ios/renderConst.swift | 3 --- components/render/mac/renderConstMac.swift | 11 +++++++++++ components/render/renderConst.swift | 13 ------------- ogs-blue/ver-ios/src/render/renderConst.swift | 2 +- ogs-blue/ver-mac/src/render/renderConstMac.swift | 1 + 5 files changed, 13 insertions(+), 17 deletions(-) delete mode 100644 components/render/ios/renderConst.swift create mode 100644 components/render/mac/renderConstMac.swift create mode 120000 ogs-blue/ver-mac/src/render/renderConstMac.swift diff --git a/components/render/ios/renderConst.swift b/components/render/ios/renderConst.swift deleted file mode 100644 index 7b0a7c8..0000000 --- a/components/render/ios/renderConst.swift +++ /dev/null @@ -1,3 +0,0 @@ -// iOS render constants. The macOS renderConst.swift depends on AppKit, so the -// two platforms keep separate files. -let RENDER_FPS = 60.0 diff --git a/components/render/mac/renderConstMac.swift b/components/render/mac/renderConstMac.swift new file mode 100644 index 0000000..d71ec37 --- /dev/null +++ b/components/render/mac/renderConstMac.swift @@ -0,0 +1,11 @@ +import AppKit + +let RENDER_OPENGL_ATTRS: [NSOpenGLPixelFormatAttribute] = [ + UInt32(NSOpenGLPFAOpenGLProfile), UInt32(NSOpenGLProfileVersion3_2Core), + UInt32(NSOpenGLPFAColorSize), 24, + UInt32(NSOpenGLPFAAlphaSize), 8, + UInt32(NSOpenGLPFADepthSize), 24, + UInt32(NSOpenGLPFADoubleBuffer), + UInt32(NSOpenGLPFAAccelerated), + 0 +] diff --git a/components/render/renderConst.swift b/components/render/renderConst.swift index 1abea29..dea395c 100644 --- a/components/render/renderConst.swift +++ b/components/render/renderConst.swift @@ -1,15 +1,2 @@ -import AppKit - let RENDER_FPS = 60.0 - let RENDER_MODEL_CUBE = "/cube/cube.gltf" - -let RENDER_OPENGL_ATTRS: [NSOpenGLPixelFormatAttribute] = [ - UInt32(NSOpenGLPFAOpenGLProfile), UInt32(NSOpenGLProfileVersion3_2Core), - UInt32(NSOpenGLPFAColorSize), 24, - UInt32(NSOpenGLPFAAlphaSize), 8, - UInt32(NSOpenGLPFADepthSize), 24, - UInt32(NSOpenGLPFADoubleBuffer), - UInt32(NSOpenGLPFAAccelerated), - 0 -] diff --git a/ogs-blue/ver-ios/src/render/renderConst.swift b/ogs-blue/ver-ios/src/render/renderConst.swift index ff2ffaf..d953714 120000 --- a/ogs-blue/ver-ios/src/render/renderConst.swift +++ b/ogs-blue/ver-ios/src/render/renderConst.swift @@ -1 +1 @@ -../../../../components/render/ios/renderConst.swift \ No newline at end of file +../../../../components/render/renderConst.swift \ No newline at end of file diff --git a/ogs-blue/ver-mac/src/render/renderConstMac.swift b/ogs-blue/ver-mac/src/render/renderConstMac.swift new file mode 120000 index 0000000..b5756b0 --- /dev/null +++ b/ogs-blue/ver-mac/src/render/renderConstMac.swift @@ -0,0 +1 @@ +../../../../components/render/mac/renderConstMac.swift \ No newline at end of file -- 2.53.0 From ac649266ac35f8d463eaa5bb272609f06d82438f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB=20=D0=9A=D0=B0=D0=BF?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BA=D0=BE?= Date: Wed, 28 Oct 2026 17:29:20 +0300 Subject: [PATCH 30/55] clarify --- components/render/ios/renderEffect.swift | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/components/render/ios/renderEffect.swift b/components/render/ios/renderEffect.swift index 4395f38..7b34b44 100644 --- a/components/render/ios/renderEffect.swift +++ b/components/render/ios/renderEffect.swift @@ -19,8 +19,9 @@ func renderStartTimer(_ vm: RenderVM) { // Make a time mark for calculating time delta vm.startTime = CACurrentMediaTime() - // Unlike macOS, UIKit never calls draw(_:) on the view, so the timer - // renders each frame itself. + // The frame is presented by eglSwapBuffers into the view's layer, not by + // CoreGraphics, so the timer drives the rendering itself instead of + // invalidating the view for a draw(_:) pass the way macOS does. let timer = Timer(timeInterval: 1.0 / RENDER_FPS, repeats: true) { [weak vm] _ in guard let vm else { return } renderDraw(vm) -- 2.53.0 From 48f7d37c78ddbd2e3b5094c8c64c836cc455fded Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB=20=D0=9A=D0=B0=D0=BF?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BA=D0=BE?= Date: Thu, 29 Oct 2026 15:46:37 +0300 Subject: [PATCH 31/55] single raybriEGL --- components/raybri/ios/raybri.c | 1 + components/raybri/ios/raybriEGL.c | 18 ------------------ components/raybri/ios/raybriEGL.h | 24 ++++++++++++++++++++++++ ogs-blue/ver-ios/src/raybri/raybriEGL.c | 1 - 4 files changed, 25 insertions(+), 19 deletions(-) delete mode 100644 components/raybri/ios/raybriEGL.c delete mode 120000 ogs-blue/ver-ios/src/raybri/raybriEGL.c diff --git a/components/raybri/ios/raybri.c b/components/raybri/ios/raybri.c index ce484d9..0e47f79 100644 --- a/components/raybri/ios/raybri.c +++ b/components/raybri/ios/raybri.c @@ -1,4 +1,5 @@ #include "raybri.h" +#define RAYBRI_EGL_IMPLEMENTATION #include "raybriEGL.h" #define RLGL_IMPLEMENTATION diff --git a/components/raybri/ios/raybriEGL.c b/components/raybri/ios/raybriEGL.c deleted file mode 100644 index ab41570..0000000 --- a/components/raybri/ios/raybriEGL.c +++ /dev/null @@ -1,18 +0,0 @@ -#include "raybriEGL.h" - -bool raybriEGLInit(void) { - EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY); - if (display == EGL_NO_DISPLAY) { - return false; - } - - if (eglInitialize(display, NULL, NULL) == EGL_FALSE) { - return false; - } - - if (eglBindAPI(EGL_OPENGL_ES_API) == EGL_FALSE) { - return false; - } - - return true; -} diff --git a/components/raybri/ios/raybriEGL.h b/components/raybri/ios/raybriEGL.h index 7742002..32c4700 100644 --- a/components/raybri/ios/raybriEGL.h +++ b/components/raybri/ios/raybriEGL.h @@ -5,6 +5,30 @@ #include #include +// Header + bool raybriEGLInit(void); +// Source + +#if defined(RAYBRI_EGL_IMPLEMENTATION) + +bool raybriEGLInit(void) { + EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY); + if (display == EGL_NO_DISPLAY) { + return false; + } + + if (eglInitialize(display, NULL, NULL) == EGL_FALSE) { + return false; + } + + if (eglBindAPI(EGL_OPENGL_ES_API) == EGL_FALSE) { + return false; + } + + return true; +} +#endif // RAYBRI_EGL_IMPLEMENTATION + #endif // RAYBRI_EGL_H diff --git a/ogs-blue/ver-ios/src/raybri/raybriEGL.c b/ogs-blue/ver-ios/src/raybri/raybriEGL.c deleted file mode 120000 index 52503c2..0000000 --- a/ogs-blue/ver-ios/src/raybri/raybriEGL.c +++ /dev/null @@ -1 +0,0 @@ -../../../../components/raybri/ios/raybriEGL.c \ No newline at end of file -- 2.53.0 From 9757a40b36d5683953b69b2378910094422c825c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB=20=D0=9A=D0=B0=D0=BF?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BA=D0=BE?= Date: Thu, 29 Oct 2026 15:54:55 +0300 Subject: [PATCH 32/55] compact mac files --- components/raybri/mac/raybri.c | 4 +++ components/raybri/mac/raybriAux.c | 21 -------------- components/raybri/mac/raybriAux.h | 29 ++++++++++++++++++++ components/raybri/mac/raybriConst.c | 3 -- components/raybri/mac/raybriConst.h | 10 +++++++ ogs-blue/ver-mac/src/raybri/raybriAux.c | 1 - ogs-blue/ver-mac/src/raybri/raybriConst.c | 1 - ogs-mahjong/ver-mac/src/raybri/raybriConst.c | 1 - 8 files changed, 43 insertions(+), 27 deletions(-) delete mode 100644 components/raybri/mac/raybriAux.c delete mode 100644 components/raybri/mac/raybriConst.c delete mode 120000 ogs-blue/ver-mac/src/raybri/raybriAux.c delete mode 120000 ogs-blue/ver-mac/src/raybri/raybriConst.c delete mode 120000 ogs-mahjong/ver-mac/src/raybri/raybriConst.c diff --git a/components/raybri/mac/raybri.c b/components/raybri/mac/raybri.c index 505c772..f0c6857 100644 --- a/components/raybri/mac/raybri.c +++ b/components/raybri/mac/raybri.c @@ -1,4 +1,8 @@ #include "raybri.h" +// Const must be before Aux due to Aux referencing constants of Const +#define RAYBRI_CONST_IMPLEMENTATION +#include "raybriConst.h" +#define RAYBRI_AUX_IMPLEMENTATION #include "raybriAux.h" #include "rlgl.h" #include diff --git a/components/raybri/mac/raybriAux.c b/components/raybri/mac/raybriAux.c deleted file mode 100644 index e78ec49..0000000 --- a/components/raybri/mac/raybriAux.c +++ /dev/null @@ -1,21 +0,0 @@ -#include -#include "raybriAux.h" -#include "raybriConst.h" -#include - -// raylib is built as a static/dynamic library with GLFW baked in, but we never -// call InitWindow(). Instead we render into an OpenGL context owned by the -// macOS app, so we must supply the OpenGL entry point loader ourselves. -void *raybriGLLoader(const char *name) { - static void *handle = NULL; - - if (handle == NULL) { - handle = dlopen(RAYBRI_MAC_GL, RTLD_LAZY | RTLD_LOCAL); - } - - if (handle == NULL) { - return NULL; - } - - return dlsym(handle, name); -} diff --git a/components/raybri/mac/raybriAux.h b/components/raybri/mac/raybriAux.h index 3e12210..40c44ca 100644 --- a/components/raybri/mac/raybriAux.h +++ b/components/raybri/mac/raybriAux.h @@ -1,6 +1,35 @@ #ifndef RAYBRI_AUX_H #define RAYBRI_AUX_H +// Header + void *raybriGLLoader(const char *name); +// Source + +#if defined(RAYBRI_AUX_IMPLEMENTATION) + +#include +#include +#include "raybriConst.h" + +// raylib is built as a static/dynamic library with GLFW baked in, but we never +// call InitWindow(). Instead we render into an OpenGL context owned by the +// macOS app, so we must supply the OpenGL entry point loader ourselves. +void *raybriGLLoader(const char *name) { + static void *handle = NULL; + + if (handle == NULL) { + handle = dlopen(RAYBRI_MAC_GL, RTLD_LAZY | RTLD_LOCAL); + } + + if (handle == NULL) { + return NULL; + } + + return dlsym(handle, name); +} + +#endif // RAYBRI_AUX_IMPLEMENTATION + #endif // RAYBRI_AUX_H diff --git a/components/raybri/mac/raybriConst.c b/components/raybri/mac/raybriConst.c deleted file mode 100644 index bc427dc..0000000 --- a/components/raybri/mac/raybriConst.c +++ /dev/null @@ -1,3 +0,0 @@ -#include "raybriConst.h" - -const char RAYBRI_MAC_GL[] = "/System/Library/Frameworks/OpenGL.framework/OpenGL"; diff --git a/components/raybri/mac/raybriConst.h b/components/raybri/mac/raybriConst.h index cde42ee..f2ed1b1 100644 --- a/components/raybri/mac/raybriConst.h +++ b/components/raybri/mac/raybriConst.h @@ -1,6 +1,16 @@ #ifndef RAYBRI_CONST_H #define RAYBRI_CONST_H +// Header + extern const char RAYBRI_MAC_GL[]; +// Source + +#if defined(RAYBRI_CONST_IMPLEMENTATION) + +const char RAYBRI_MAC_GL[] = "/System/Library/Frameworks/OpenGL.framework/OpenGL"; + +#endif // RAYBRI_CONST_IMPLEMENTATION + #endif // RAYBRI_CONST_H diff --git a/ogs-blue/ver-mac/src/raybri/raybriAux.c b/ogs-blue/ver-mac/src/raybri/raybriAux.c deleted file mode 120000 index 36bd50c..0000000 --- a/ogs-blue/ver-mac/src/raybri/raybriAux.c +++ /dev/null @@ -1 +0,0 @@ -../../../../components/raybri/mac/raybriAux.c \ No newline at end of file diff --git a/ogs-blue/ver-mac/src/raybri/raybriConst.c b/ogs-blue/ver-mac/src/raybri/raybriConst.c deleted file mode 120000 index 2656529..0000000 --- a/ogs-blue/ver-mac/src/raybri/raybriConst.c +++ /dev/null @@ -1 +0,0 @@ -../../../../components/raybri/mac/raybriConst.c \ No newline at end of file diff --git a/ogs-mahjong/ver-mac/src/raybri/raybriConst.c b/ogs-mahjong/ver-mac/src/raybri/raybriConst.c deleted file mode 120000 index fe840ed..0000000 --- a/ogs-mahjong/ver-mac/src/raybri/raybriConst.c +++ /dev/null @@ -1 +0,0 @@ -../../../../components/raybri/raybriConst.c \ No newline at end of file -- 2.53.0 From cc2748efb768f5cef2ee98d9b680fb6e2f8fd248 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB=20=D0=9A=D0=B0=D0=BF?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BA=D0=BE?= Date: Thu, 29 Oct 2026 16:00:23 +0300 Subject: [PATCH 33/55] const --- components/raybri/ios/raybriEGL.h | 1 + components/raybri/ios/raybriEGLConst.h | 33 ++++++++++++++++++++ ogs-blue/ver-ios/src/raybri/raybriEGLConst.h | 1 + 3 files changed, 35 insertions(+) create mode 100644 components/raybri/ios/raybriEGLConst.h create mode 120000 ogs-blue/ver-ios/src/raybri/raybriEGLConst.h diff --git a/components/raybri/ios/raybriEGL.h b/components/raybri/ios/raybriEGL.h index 32c4700..1f172fa 100644 --- a/components/raybri/ios/raybriEGL.h +++ b/components/raybri/ios/raybriEGL.h @@ -29,6 +29,7 @@ bool raybriEGLInit(void) { return true; } + #endif // RAYBRI_EGL_IMPLEMENTATION #endif // RAYBRI_EGL_H diff --git a/components/raybri/ios/raybriEGLConst.h b/components/raybri/ios/raybriEGLConst.h new file mode 100644 index 0000000..91953d1 --- /dev/null +++ b/components/raybri/ios/raybriEGLConst.h @@ -0,0 +1,33 @@ +#ifndef RAYBRI_EGL_CONST_H +#define RAYBRI_EGL_CONST_H + +#include + +// Header + +extern const EGLint RAYBRI_EGL_CFG[]; +extern const EGLint RAYBRI_EGL_CTX[]; + +// Source + +const EGLint RAYBRI_EGL_CFG[] = { + EGL_RENDERABLE_TYPE, EGL_OPENGL_ES3_BIT, + EGL_SURFACE_TYPE, EGL_WINDOW_BIT, + EGL_RED_SIZE, 8, + EGL_GREEN_SIZE, 8, + EGL_BLUE_SIZE, 8, + EGL_ALPHA_SIZE, 8, + EGL_DEPTH_SIZE, 16, + EGL_NONE +}; + +const EGLint RAYBRI_EGL_CTX[] = { + EGL_CONTEXT_CLIENT_VERSION, 3, + EGL_NONE +}; + +#if defined(RAYBRI_EGL_CONST_IMPLEMENTATION) + +#endif // RAYBRI_EGL_CONST_IMPLEMENTATION + +#endif // RAYBRI_EGL_CONST_H diff --git a/ogs-blue/ver-ios/src/raybri/raybriEGLConst.h b/ogs-blue/ver-ios/src/raybri/raybriEGLConst.h new file mode 120000 index 0000000..2674f03 --- /dev/null +++ b/ogs-blue/ver-ios/src/raybri/raybriEGLConst.h @@ -0,0 +1 @@ +../../../../components/raybri/ios/raybriEGLConst.h \ No newline at end of file -- 2.53.0 From 2fbaba4a5149fe4aea9afea34506accbd954b023 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB=20=D0=9A=D0=B0=D0=BF?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BA=D0=BE?= Date: Thu, 29 Oct 2026 16:09:18 +0300 Subject: [PATCH 34/55] some --- components/raybri/ios/raybri.c | 4 ++++ components/raybri/ios/raybriEGL.h | 20 +++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/components/raybri/ios/raybri.c b/components/raybri/ios/raybri.c index 0e47f79..bad3d04 100644 --- a/components/raybri/ios/raybri.c +++ b/components/raybri/ios/raybri.c @@ -1,4 +1,8 @@ #include "raybri.h" + +#define RAYBRI_EGL_CONST_IMPLEMENTATION +#include "raybriEGLConst.h" + #define RAYBRI_EGL_IMPLEMENTATION #include "raybriEGL.h" diff --git a/components/raybri/ios/raybriEGL.h b/components/raybri/ios/raybriEGL.h index 1f172fa..3949779 100644 --- a/components/raybri/ios/raybriEGL.h +++ b/components/raybri/ios/raybriEGL.h @@ -3,6 +3,7 @@ #include #include +#include "raybriEGLConst.h" #include // Header @@ -14,7 +15,11 @@ bool raybriEGLInit(void); #if defined(RAYBRI_EGL_IMPLEMENTATION) bool raybriEGLInit(void) { - EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY); + EGLConfig cfg = NULL; + EGLContext ctx = EGL_NO_CONTEXT; + EGLDisplay display = EGL_NO_DISPLAY; + + display = eglGetDisplay(EGL_DEFAULT_DISPLAY); if (display == EGL_NO_DISPLAY) { return false; } @@ -27,6 +32,19 @@ bool raybriEGLInit(void) { return false; } + EGLint cfgCount = 0; + if ( + eglChooseConfig(display, RAYBRI_EGL_CFG, &cfg, 1, &cfgCount) == EGL_FALSE || + cfgCount < 1 + ) { + return false; + } + + ctx = eglCreateContext(display, cfg, EGL_NO_CONTEXT, RAYBRI_EGL_CTX); + if (ctx == EGL_NO_CONTEXT) { + return false; + } + return true; } -- 2.53.0 From b1dd0a5107a21b0ac2f3e9d2f30f39fc729c7d27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB=20=D0=9A=D0=B0=D0=BF?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BA=D0=BE?= Date: Thu, 29 Oct 2026 16:18:40 +0300 Subject: [PATCH 35/55] reset sur --- components/raybri/ios/raybriEGL.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/components/raybri/ios/raybriEGL.h b/components/raybri/ios/raybriEGL.h index 3949779..5beada6 100644 --- a/components/raybri/ios/raybriEGL.h +++ b/components/raybri/ios/raybriEGL.h @@ -9,6 +9,12 @@ // Header bool raybriEGLInit(void); +bool raybriEGLResetSurface( + void *caLayer, + EGLConfig *cfg, + EGLDisplay *display, + EGLSurface *surface +); // Source @@ -48,6 +54,28 @@ bool raybriEGLInit(void) { return true; } +bool raybriEGLResetSurface( + void *caLayer, + EGLConfig *cfg, + EGLDisplay *display, + EGLSurface *surface +) { + // Destroy previous surface + if (surface != EGL_NO_SURFACE) { + eglDestroySurface(display, surface); + surface = EGL_NO_SURFACE; + } + + // Create new surface + // ANGLE on iOS takes a CALayer as the native window + surface = eglCreateWindowSurface(display, cfg, (EGLNativeWindowType)caLayer, NULL); + if (surface == EGL_NO_SURFACE) { + return false; + } + + return true; +} + #endif // RAYBRI_EGL_IMPLEMENTATION #endif // RAYBRI_EGL_H -- 2.53.0 From 7b8c3181d535296b762889e7785ddf93f585506f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB=20=D0=9A=D0=B0=D0=BF?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BA=D0=BE?= Date: Thu, 29 Oct 2026 16:25:05 +0300 Subject: [PATCH 36/55] pass --- components/raybri/ios/raybri.c | 6 +++++- components/raybri/ios/raybriEGL.h | 16 ++++++++++------ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/components/raybri/ios/raybri.c b/components/raybri/ios/raybri.c index bad3d04..9186228 100644 --- a/components/raybri/ios/raybri.c +++ b/components/raybri/ios/raybri.c @@ -14,7 +14,11 @@ void raybriInit(void *layer) { //SetTraceLogLevel(LOG_WARNING); - if (!raybriEGLInit()) { + EGLConfig cfg = NULL; + EGLContext ctx = EGL_NO_CONTEXT; + EGLDisplay display = EGL_NO_DISPLAY; + + if (!raybriEGLInit(&cfg, &ctx, &display)) { raybriLog("ERROR Could not initialize EGL"); } diff --git a/components/raybri/ios/raybriEGL.h b/components/raybri/ios/raybriEGL.h index 5beada6..259e4ec 100644 --- a/components/raybri/ios/raybriEGL.h +++ b/components/raybri/ios/raybriEGL.h @@ -8,7 +8,11 @@ // Header -bool raybriEGLInit(void); +bool raybriEGLInit( + EGLConfig *cfg, + EGLContext *ctx, + EGLDisplay *display +); bool raybriEGLResetSurface( void *caLayer, EGLConfig *cfg, @@ -20,11 +24,11 @@ bool raybriEGLResetSurface( #if defined(RAYBRI_EGL_IMPLEMENTATION) -bool raybriEGLInit(void) { - EGLConfig cfg = NULL; - EGLContext ctx = EGL_NO_CONTEXT; - EGLDisplay display = EGL_NO_DISPLAY; - +bool raybriEGLInit( + EGLConfig *cfg, + EGLContext *ctx, + EGLDisplay *display +){ display = eglGetDisplay(EGL_DEFAULT_DISPLAY); if (display == EGL_NO_DISPLAY) { return false; -- 2.53.0 From 1f92c8e41c409155e94cedf35c48c907543f413e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB=20=D0=9A=D0=B0=D0=BF?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BA=D0=BE?= Date: Thu, 29 Oct 2026 16:28:39 +0300 Subject: [PATCH 37/55] sur --- components/raybri/ios/raybri.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/components/raybri/ios/raybri.c b/components/raybri/ios/raybri.c index 9186228..3cf5eba 100644 --- a/components/raybri/ios/raybri.c +++ b/components/raybri/ios/raybri.c @@ -17,10 +17,14 @@ void raybriInit(void *layer) { EGLConfig cfg = NULL; EGLContext ctx = EGL_NO_CONTEXT; EGLDisplay display = EGL_NO_DISPLAY; + EGLSurface surface = EGL_NO_SURFACE; if (!raybriEGLInit(&cfg, &ctx, &display)) { raybriLog("ERROR Could not initialize EGL"); } + if (!raybriEGLResetSurface(&cfg, &ctx, &display, &surface)) { + raybriLog("ERROR Could not reset EGL surface"); + } // Initialize raylib graphics layer with a placeholder 1x1 framebuffer size // Graphics layer includes default texture, shader, render batch and OpenGL state -- 2.53.0 From f76932fd9103fe8ed206bcc7ffc3a4483175f68c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB=20=D0=9A=D0=B0=D0=BF?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BA=D0=BE?= Date: Thu, 29 Oct 2026 16:34:56 +0300 Subject: [PATCH 38/55] ptr --- components/raybri/ios/raybriEGL.h | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/components/raybri/ios/raybriEGL.h b/components/raybri/ios/raybriEGL.h index 259e4ec..d2ae6d3 100644 --- a/components/raybri/ios/raybriEGL.h +++ b/components/raybri/ios/raybriEGL.h @@ -29,12 +29,12 @@ bool raybriEGLInit( EGLContext *ctx, EGLDisplay *display ){ - display = eglGetDisplay(EGL_DEFAULT_DISPLAY); - if (display == EGL_NO_DISPLAY) { + *display = eglGetDisplay(EGL_DEFAULT_DISPLAY); + if (*display == EGL_NO_DISPLAY) { return false; } - if (eglInitialize(display, NULL, NULL) == EGL_FALSE) { + if (eglInitialize(*display, NULL, NULL) == EGL_FALSE) { return false; } @@ -44,14 +44,14 @@ bool raybriEGLInit( EGLint cfgCount = 0; if ( - eglChooseConfig(display, RAYBRI_EGL_CFG, &cfg, 1, &cfgCount) == EGL_FALSE || + eglChooseConfig(*display, RAYBRI_EGL_CFG, cfg, 1, &cfgCount) == EGL_FALSE || cfgCount < 1 ) { return false; } - ctx = eglCreateContext(display, cfg, EGL_NO_CONTEXT, RAYBRI_EGL_CTX); - if (ctx == EGL_NO_CONTEXT) { + *ctx = eglCreateContext(*display, *cfg, EGL_NO_CONTEXT, RAYBRI_EGL_CTX); + if (*ctx == EGL_NO_CONTEXT) { return false; } @@ -65,15 +65,15 @@ bool raybriEGLResetSurface( EGLSurface *surface ) { // Destroy previous surface - if (surface != EGL_NO_SURFACE) { - eglDestroySurface(display, surface); - surface = EGL_NO_SURFACE; + if (*surface != EGL_NO_SURFACE) { + eglDestroySurface(*display, *surface); + *surface = EGL_NO_SURFACE; } // Create new surface // ANGLE on iOS takes a CALayer as the native window - surface = eglCreateWindowSurface(display, cfg, (EGLNativeWindowType)caLayer, NULL); - if (surface == EGL_NO_SURFACE) { + *surface = eglCreateWindowSurface(*display, *cfg, (EGLNativeWindowType)caLayer, NULL); + if (*surface == EGL_NO_SURFACE) { return false; } -- 2.53.0 From 6c142f794c5737181296bf30e7d1a3b62edad429 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB=20=D0=9A=D0=B0=D0=BF?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BA=D0=BE?= Date: Thu, 29 Oct 2026 16:50:02 +0300 Subject: [PATCH 39/55] fix layer pass --- components/raybri/ios/raybri.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/raybri/ios/raybri.c b/components/raybri/ios/raybri.c index 3cf5eba..485a2a7 100644 --- a/components/raybri/ios/raybri.c +++ b/components/raybri/ios/raybri.c @@ -22,7 +22,7 @@ void raybriInit(void *layer) { if (!raybriEGLInit(&cfg, &ctx, &display)) { raybriLog("ERROR Could not initialize EGL"); } - if (!raybriEGLResetSurface(&cfg, &ctx, &display, &surface)) { + if (!raybriEGLResetSurface(layer, &cfg, &display, &surface)) { raybriLog("ERROR Could not reset EGL surface"); } -- 2.53.0 From b9b7e91bcd8f7183e5ffe7ebe197d18200218fbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB=20=D0=9A=D0=B0=D0=BF?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BA=D0=BE?= Date: Thu, 29 Oct 2026 17:02:28 +0300 Subject: [PATCH 40/55] introduce struct --- components/raybri/ios/raybri.c | 17 ++++++--- components/raybri/ios/raybriEGL.h | 61 ++++++++++++++----------------- 2 files changed, 38 insertions(+), 40 deletions(-) diff --git a/components/raybri/ios/raybri.c b/components/raybri/ios/raybri.c index 485a2a7..d1fec88 100644 --- a/components/raybri/ios/raybri.c +++ b/components/raybri/ios/raybri.c @@ -11,18 +11,23 @@ #include +static RaybriEGLState globalES = { + .caLayer = NULL, + .cfg = NULL, + .ctx = EGL_NO_CONTEXT, + .display = EGL_NO_DISPLAY, + .surface = EGL_NO_SURFACE +}; + void raybriInit(void *layer) { //SetTraceLogLevel(LOG_WARNING); - EGLConfig cfg = NULL; - EGLContext ctx = EGL_NO_CONTEXT; - EGLDisplay display = EGL_NO_DISPLAY; - EGLSurface surface = EGL_NO_SURFACE; + globalES.caLayer = layer; - if (!raybriEGLInit(&cfg, &ctx, &display)) { + if (!raybriEGLInit(&globalES)) { raybriLog("ERROR Could not initialize EGL"); } - if (!raybriEGLResetSurface(layer, &cfg, &display, &surface)) { + if (!raybriEGLResetSurface(&globalES)) { raybriLog("ERROR Could not reset EGL surface"); } diff --git a/components/raybri/ios/raybriEGL.h b/components/raybri/ios/raybriEGL.h index d2ae6d3..4a4297b 100644 --- a/components/raybri/ios/raybriEGL.h +++ b/components/raybri/ios/raybriEGL.h @@ -6,35 +6,28 @@ #include "raybriEGLConst.h" #include -// Header +typedef struct RaybriEGLState { + void *caLayer; + EGLConfig cfg; + EGLContext ctx; + EGLDisplay display; + EGLSurface surface; +} RaybriEGLState; -bool raybriEGLInit( - EGLConfig *cfg, - EGLContext *ctx, - EGLDisplay *display -); -bool raybriEGLResetSurface( - void *caLayer, - EGLConfig *cfg, - EGLDisplay *display, - EGLSurface *surface -); +bool raybriEGLInit(RaybriEGLState *st); +bool raybriEGLResetSurface(RaybriEGLState *st); // Source #if defined(RAYBRI_EGL_IMPLEMENTATION) -bool raybriEGLInit( - EGLConfig *cfg, - EGLContext *ctx, - EGLDisplay *display -){ - *display = eglGetDisplay(EGL_DEFAULT_DISPLAY); - if (*display == EGL_NO_DISPLAY) { +bool raybriEGLInit(RaybriEGLState *st) { + st->display = eglGetDisplay(EGL_DEFAULT_DISPLAY); + if (st->display == EGL_NO_DISPLAY) { return false; } - if (eglInitialize(*display, NULL, NULL) == EGL_FALSE) { + if (eglInitialize(st->display, NULL, NULL) == EGL_FALSE) { return false; } @@ -44,36 +37,36 @@ bool raybriEGLInit( EGLint cfgCount = 0; if ( - eglChooseConfig(*display, RAYBRI_EGL_CFG, cfg, 1, &cfgCount) == EGL_FALSE || + eglChooseConfig(st->display, RAYBRI_EGL_CFG, &st->cfg, 1, &cfgCount) == EGL_FALSE || cfgCount < 1 ) { return false; } - *ctx = eglCreateContext(*display, *cfg, EGL_NO_CONTEXT, RAYBRI_EGL_CTX); - if (*ctx == EGL_NO_CONTEXT) { + st->ctx = eglCreateContext(st->display, st->cfg, EGL_NO_CONTEXT, RAYBRI_EGL_CTX); + if (st->ctx == EGL_NO_CONTEXT) { return false; } return true; } -bool raybriEGLResetSurface( - void *caLayer, - EGLConfig *cfg, - EGLDisplay *display, - EGLSurface *surface -) { +bool raybriEGLResetSurface(RaybriEGLState *st) { // Destroy previous surface - if (*surface != EGL_NO_SURFACE) { - eglDestroySurface(*display, *surface); - *surface = EGL_NO_SURFACE; + if (st->surface != EGL_NO_SURFACE) { + eglDestroySurface(st->display, st->surface); + st->surface = EGL_NO_SURFACE; } // Create new surface // ANGLE on iOS takes a CALayer as the native window - *surface = eglCreateWindowSurface(*display, *cfg, (EGLNativeWindowType)caLayer, NULL); - if (*surface == EGL_NO_SURFACE) { + st->surface = eglCreateWindowSurface( + st->display, + st->cfg, + (EGLNativeWindowType)st->caLayer, + NULL + ); + if (st->surface == EGL_NO_SURFACE) { return false; } -- 2.53.0 From 360be210c24d7ca75c3e41b3b31b78e88aed0ffb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB=20=D0=9A=D0=B0=D0=BF?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BA=D0=BE?= Date: Thu, 29 Oct 2026 23:01:59 +0300 Subject: [PATCH 41/55] egl cmp --- .../{raybri/ios/raybriEGL.h => egl/egl.h} | 28 +++++++++---------- .../ios/raybriEGLConst.h => egl/eglConst.h} | 20 ++++++------- components/raybri/ios/raybri.c | 14 +++++----- ogs-blue/ver-ios/src/egl/egl.h | 1 + ogs-blue/ver-ios/src/egl/eglConst.h | 1 + ogs-blue/ver-ios/src/raybri/raybriEGL.h | 1 - ogs-blue/ver-ios/src/raybri/raybriEGLConst.h | 1 - 7 files changed, 33 insertions(+), 33 deletions(-) rename components/{raybri/ios/raybriEGL.h => egl/egl.h} (70%) rename components/{raybri/ios/raybriEGLConst.h => egl/eglConst.h} (50%) create mode 120000 ogs-blue/ver-ios/src/egl/egl.h create mode 120000 ogs-blue/ver-ios/src/egl/eglConst.h delete mode 120000 ogs-blue/ver-ios/src/raybri/raybriEGL.h delete mode 120000 ogs-blue/ver-ios/src/raybri/raybriEGLConst.h diff --git a/components/raybri/ios/raybriEGL.h b/components/egl/egl.h similarity index 70% rename from components/raybri/ios/raybriEGL.h rename to components/egl/egl.h index 4a4297b..6b151b6 100644 --- a/components/raybri/ios/raybriEGL.h +++ b/components/egl/egl.h @@ -1,27 +1,27 @@ -#ifndef RAYBRI_EGL_H -#define RAYBRI_EGL_H +#ifndef EGL_H +#define EGL_H +#include "eglConst.h" #include #include -#include "raybriEGLConst.h" #include -typedef struct RaybriEGLState { +typedef struct EGLState { void *caLayer; EGLConfig cfg; EGLContext ctx; EGLDisplay display; EGLSurface surface; -} RaybriEGLState; +} EGLState; -bool raybriEGLInit(RaybriEGLState *st); -bool raybriEGLResetSurface(RaybriEGLState *st); +bool eglInit(EGLState *st); +bool eglResetSurface(EGLState *st); // Source -#if defined(RAYBRI_EGL_IMPLEMENTATION) +#if defined(EGL_IMPLEMENTATION) -bool raybriEGLInit(RaybriEGLState *st) { +bool eglInit(EGLState *st) { st->display = eglGetDisplay(EGL_DEFAULT_DISPLAY); if (st->display == EGL_NO_DISPLAY) { return false; @@ -37,13 +37,13 @@ bool raybriEGLInit(RaybriEGLState *st) { EGLint cfgCount = 0; if ( - eglChooseConfig(st->display, RAYBRI_EGL_CFG, &st->cfg, 1, &cfgCount) == EGL_FALSE || + eglChooseConfig(st->display, EGL_CFG, &st->cfg, 1, &cfgCount) == EGL_FALSE || cfgCount < 1 ) { return false; } - st->ctx = eglCreateContext(st->display, st->cfg, EGL_NO_CONTEXT, RAYBRI_EGL_CTX); + st->ctx = eglCreateContext(st->display, st->cfg, EGL_NO_CONTEXT, EGL_CTX); if (st->ctx == EGL_NO_CONTEXT) { return false; } @@ -51,7 +51,7 @@ bool raybriEGLInit(RaybriEGLState *st) { return true; } -bool raybriEGLResetSurface(RaybriEGLState *st) { +bool eglResetSurface(EGLState *st) { // Destroy previous surface if (st->surface != EGL_NO_SURFACE) { eglDestroySurface(st->display, st->surface); @@ -73,6 +73,6 @@ bool raybriEGLResetSurface(RaybriEGLState *st) { return true; } -#endif // RAYBRI_EGL_IMPLEMENTATION +#endif // EGL_IMPLEMENTATION -#endif // RAYBRI_EGL_H +#endif // EGL_H diff --git a/components/raybri/ios/raybriEGLConst.h b/components/egl/eglConst.h similarity index 50% rename from components/raybri/ios/raybriEGLConst.h rename to components/egl/eglConst.h index 91953d1..b164ce6 100644 --- a/components/raybri/ios/raybriEGLConst.h +++ b/components/egl/eglConst.h @@ -1,16 +1,18 @@ -#ifndef RAYBRI_EGL_CONST_H -#define RAYBRI_EGL_CONST_H +#ifndef EGL_CONST_H +#define EGL_CONST_H #include // Header -extern const EGLint RAYBRI_EGL_CFG[]; -extern const EGLint RAYBRI_EGL_CTX[]; +extern const EGLint EGL_CFG[]; +extern const EGLint EGL_CTX[]; // Source -const EGLint RAYBRI_EGL_CFG[] = { +#if defined(EGL_CONST_IMPLEMENTATION) + +const EGLint EGL_CFG[] = { EGL_RENDERABLE_TYPE, EGL_OPENGL_ES3_BIT, EGL_SURFACE_TYPE, EGL_WINDOW_BIT, EGL_RED_SIZE, 8, @@ -21,13 +23,11 @@ const EGLint RAYBRI_EGL_CFG[] = { EGL_NONE }; -const EGLint RAYBRI_EGL_CTX[] = { +const EGLint EGL_CTX[] = { EGL_CONTEXT_CLIENT_VERSION, 3, EGL_NONE }; -#if defined(RAYBRI_EGL_CONST_IMPLEMENTATION) +#endif // EGL_CONST_IMPLEMENTATION -#endif // RAYBRI_EGL_CONST_IMPLEMENTATION - -#endif // RAYBRI_EGL_CONST_H +#endif // EGL_CONST_H diff --git a/components/raybri/ios/raybri.c b/components/raybri/ios/raybri.c index d1fec88..2834d5a 100644 --- a/components/raybri/ios/raybri.c +++ b/components/raybri/ios/raybri.c @@ -1,17 +1,17 @@ #include "raybri.h" -#define RAYBRI_EGL_CONST_IMPLEMENTATION -#include "raybriEGLConst.h" +#define EGL_CONST_IMPLEMENTATION +#include "eglConst.h" -#define RAYBRI_EGL_IMPLEMENTATION -#include "raybriEGL.h" +#define EGL_IMPLEMENTATION +#include "egl.h" #define RLGL_IMPLEMENTATION #include "rlgl.h" #include -static RaybriEGLState globalES = { +static EGLState globalES = { .caLayer = NULL, .cfg = NULL, .ctx = EGL_NO_CONTEXT, @@ -24,10 +24,10 @@ void raybriInit(void *layer) { globalES.caLayer = layer; - if (!raybriEGLInit(&globalES)) { + if (!eglInit(&globalES)) { raybriLog("ERROR Could not initialize EGL"); } - if (!raybriEGLResetSurface(&globalES)) { + if (!eglResetSurface(&globalES)) { raybriLog("ERROR Could not reset EGL surface"); } diff --git a/ogs-blue/ver-ios/src/egl/egl.h b/ogs-blue/ver-ios/src/egl/egl.h new file mode 120000 index 0000000..9cfd5c7 --- /dev/null +++ b/ogs-blue/ver-ios/src/egl/egl.h @@ -0,0 +1 @@ +../../../../components/egl/egl.h \ No newline at end of file diff --git a/ogs-blue/ver-ios/src/egl/eglConst.h b/ogs-blue/ver-ios/src/egl/eglConst.h new file mode 120000 index 0000000..73ad711 --- /dev/null +++ b/ogs-blue/ver-ios/src/egl/eglConst.h @@ -0,0 +1 @@ +../../../../components/egl/eglConst.h \ No newline at end of file diff --git a/ogs-blue/ver-ios/src/raybri/raybriEGL.h b/ogs-blue/ver-ios/src/raybri/raybriEGL.h deleted file mode 120000 index 7566dfa..0000000 --- a/ogs-blue/ver-ios/src/raybri/raybriEGL.h +++ /dev/null @@ -1 +0,0 @@ -../../../../components/raybri/ios/raybriEGL.h \ No newline at end of file diff --git a/ogs-blue/ver-ios/src/raybri/raybriEGLConst.h b/ogs-blue/ver-ios/src/raybri/raybriEGLConst.h deleted file mode 120000 index 2674f03..0000000 --- a/ogs-blue/ver-ios/src/raybri/raybriEGLConst.h +++ /dev/null @@ -1 +0,0 @@ -../../../../components/raybri/ios/raybriEGLConst.h \ No newline at end of file -- 2.53.0 From 26528819a717a254d0b54c5f44dee21f3dd142b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB=20=D0=9A=D0=B0=D0=BF?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BA=D0=BE?= Date: Thu, 29 Oct 2026 23:05:04 +0300 Subject: [PATCH 42/55] some --- components/egl/egl.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/components/egl/egl.h b/components/egl/egl.h index 6b151b6..d9817fe 100644 --- a/components/egl/egl.h +++ b/components/egl/egl.h @@ -15,6 +15,7 @@ typedef struct EGLState { } EGLState; bool eglInit(EGLState *st); +bool eglMakeCurrentContext(EGLState *st); bool eglResetSurface(EGLState *st); // Source @@ -51,6 +52,14 @@ bool eglInit(EGLState *st) { return true; } +bool eglMakeCurrentContext(EGLState *st) { + if (eglMakeCurrent(st->display, st->surface, st->surface, st->ctx) == EGL_FALSE) { + return false; + } + + return true; +} + bool eglResetSurface(EGLState *st) { // Destroy previous surface if (st->surface != EGL_NO_SURFACE) { -- 2.53.0 From 7bd72fc60a0a5e23bbaea8932b3661575b76c509 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB=20=D0=9A=D0=B0=D0=BF?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BA=D0=BE?= Date: Thu, 29 Oct 2026 23:12:16 +0300 Subject: [PATCH 43/55] attempt-1 --- components/raybri/ios/raybri.c | 17 ----------------- components/render/ios/renderEffect.swift | 11 +++++++++++ components/render/ios/view/RenderGLView.swift | 8 ++++++++ 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/components/raybri/ios/raybri.c b/components/raybri/ios/raybri.c index 2834d5a..638bc96 100644 --- a/components/raybri/ios/raybri.c +++ b/components/raybri/ios/raybri.c @@ -11,26 +11,9 @@ #include -static EGLState globalES = { - .caLayer = NULL, - .cfg = NULL, - .ctx = EGL_NO_CONTEXT, - .display = EGL_NO_DISPLAY, - .surface = EGL_NO_SURFACE -}; - void raybriInit(void *layer) { //SetTraceLogLevel(LOG_WARNING); - globalES.caLayer = layer; - - if (!eglInit(&globalES)) { - raybriLog("ERROR Could not initialize EGL"); - } - if (!eglResetSurface(&globalES)) { - raybriLog("ERROR Could not reset EGL surface"); - } - // Initialize raylib graphics layer with a placeholder 1x1 framebuffer size // Graphics layer includes default texture, shader, render batch and OpenGL state rlglInit(1, 1); diff --git a/components/render/ios/renderEffect.swift b/components/render/ios/renderEffect.swift index 7b34b44..db63878 100644 --- a/components/render/ios/renderEffect.swift +++ b/components/render/ios/renderEffect.swift @@ -12,6 +12,17 @@ func renderInit(_ vm: RenderVM) { // UIKit has no NSOpenGLContext: EGL/ANGLE renders into the view's layer, // so the layer is what the bridge needs to create its surface from. let layer = Unmanaged.passUnretained(vm.glView.layer).toOpaque() + vm.glView.st.caLayer = layer; + + if (!eglInit(&vm.glView.st)) { + raybriLog("ERROR Could not initialize EGL"); + } + if (!eglResetSurface(&vm.glView.st)) { + raybriLog("ERROR Could not reset EGL surface"); + } + + eglMakeCurrentContext(&vm.glView.st) + raybriInit(layer) } diff --git a/components/render/ios/view/RenderGLView.swift b/components/render/ios/view/RenderGLView.swift index 606e111..cd02d02 100644 --- a/components/render/ios/view/RenderGLView.swift +++ b/components/render/ios/view/RenderGLView.swift @@ -1,6 +1,14 @@ import UIKit final class RenderGLView: UIView { + var st: EGLState = { + .caLayer = NULL, + .cfg = NULL, + .ctx = EGL_NO_CONTEXT, + .display = EGL_NO_DISPLAY, + .surface = EGL_NO_SURFACE + }; + override init(frame: CGRect) { super.init(frame: frame) -- 2.53.0 From de36ad782c8b602e753c069051c101b4828ad23a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB=20=D0=9A=D0=B0=D0=BF?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BA=D0=BE?= Date: Thu, 29 Oct 2026 23:32:04 +0300 Subject: [PATCH 44/55] blue --- components/raybri/ios/raybri.c | 4 ++-- components/raybri/raybri.h | 4 ++++ components/render/ios/renderAux.swift | 2 ++ components/render/ios/renderEffect.swift | 18 +++++++++--------- components/render/ios/view/RenderGLView.swift | 11 ++++------- ogs-blue/ver-ios/Info.plist | 2 ++ 6 files changed, 23 insertions(+), 18 deletions(-) diff --git a/components/raybri/ios/raybri.c b/components/raybri/ios/raybri.c index 638bc96..947c2bc 100644 --- a/components/raybri/ios/raybri.c +++ b/components/raybri/ios/raybri.c @@ -1,11 +1,11 @@ -#include "raybri.h" - #define EGL_CONST_IMPLEMENTATION #include "eglConst.h" #define EGL_IMPLEMENTATION #include "egl.h" +#include "raybri.h" + #define RLGL_IMPLEMENTATION #include "rlgl.h" diff --git a/components/raybri/raybri.h b/components/raybri/raybri.h index 3692975..0b0af2c 100644 --- a/components/raybri/raybri.h +++ b/components/raybri/raybri.h @@ -1,6 +1,10 @@ #ifndef RAYBRI_H #define RAYBRI_H +#if defined(PLATFORM_IOS) +#include "../egl/egl.h" +#endif + void raybriInit(void *layer); void raybriLog(const char *txt); void raybriRender(int width, int height); diff --git a/components/render/ios/renderAux.swift b/components/render/ios/renderAux.swift index 46205ef..431704c 100644 --- a/components/render/ios/renderAux.swift +++ b/components/render/ios/renderAux.swift @@ -1,7 +1,9 @@ import UIKit func renderDraw(_ vm: RenderVM) { + guard eglMakeCurrentContext(&vm.glView.st) else { return } raybriRender(vm.pixelSize[0], vm.pixelSize[1]) + eglSwapBuffers(vm.glView.st.display, vm.glView.st.surface) } func renderPixelSize(_ view: UIView) -> [Int32] { diff --git a/components/render/ios/renderEffect.swift b/components/render/ios/renderEffect.swift index db63878..4a7dd13 100644 --- a/components/render/ios/renderEffect.swift +++ b/components/render/ios/renderEffect.swift @@ -5,23 +5,23 @@ import UIKit func renderDeinit(_ vm: RenderVM) { vm.timer?.invalidate() vm.timer = nil + guard eglMakeCurrentContext(&vm.glView.st) else { return } raybriShutdown() + eglMakeCurrent(vm.glView.st.display, nil, nil, nil) + eglDestroySurface(vm.glView.st.display, vm.glView.st.surface) + eglDestroyContext(vm.glView.st.display, vm.glView.st.ctx) + eglTerminate(vm.glView.st.display) } func renderInit(_ vm: RenderVM) { // UIKit has no NSOpenGLContext: EGL/ANGLE renders into the view's layer, // so the layer is what the bridge needs to create its surface from. let layer = Unmanaged.passUnretained(vm.glView.layer).toOpaque() - vm.glView.st.caLayer = layer; + vm.glView.st.caLayer = layer - if (!eglInit(&vm.glView.st)) { - raybriLog("ERROR Could not initialize EGL"); - } - if (!eglResetSurface(&vm.glView.st)) { - raybriLog("ERROR Could not reset EGL surface"); - } - - eglMakeCurrentContext(&vm.glView.st) + guard eglInit(&vm.glView.st) else { fatalError("ERROR Could not initialize EGL") } + guard eglResetSurface(&vm.glView.st) else { fatalError("ERROR Could not reset EGL surface") } + guard eglMakeCurrentContext(&vm.glView.st) else { fatalError("ERROR Could not make EGL context current") } raybriInit(layer) } diff --git a/components/render/ios/view/RenderGLView.swift b/components/render/ios/view/RenderGLView.swift index cd02d02..a7ad397 100644 --- a/components/render/ios/view/RenderGLView.swift +++ b/components/render/ios/view/RenderGLView.swift @@ -1,13 +1,7 @@ import UIKit final class RenderGLView: UIView { - var st: EGLState = { - .caLayer = NULL, - .cfg = NULL, - .ctx = EGL_NO_CONTEXT, - .display = EGL_NO_DISPLAY, - .surface = EGL_NO_SURFACE - }; + var st = EGLState() override init(frame: CGRect) { super.init(frame: frame) @@ -31,6 +25,9 @@ final class RenderGLView: UIView { override func layoutSubviews() { super.layoutSubviews() + if st.surface != nil { + guard eglResetSurface(&st), eglMakeCurrentContext(&st) else { fatalError("ERROR Could not reset EGL surface") } + } let ps = renderPixelSize(self) renderSet(F.reshapePixelSize, ps) } diff --git a/ogs-blue/ver-ios/Info.plist b/ogs-blue/ver-ios/Info.plist index 7f91849..27c69f8 100644 --- a/ogs-blue/ver-ios/Info.plist +++ b/ogs-blue/ver-ios/Info.plist @@ -20,6 +20,8 @@ UISupportedInterfaceOrientations + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight UIInterfaceOrientationPortrait -- 2.53.0 From ea68f486089f037686775ecff03445044f035008 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB=20=D0=9A=D0=B0=D0=BF?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BA=D0=BE?= Date: Thu, 29 Oct 2026 23:38:53 +0300 Subject: [PATCH 45/55] willRecreateSurface --- components/render/ios/renderAux.swift | 5 ++++ components/render/ios/view/RenderGLView.swift | 3 --- components/render/mac/renderAux.swift | 4 +++ ogs-blue/dialect.yml | 8 ++++++ ogs-blue/ver-mac/src/dialect.swift | 27 +++++++++++++++++++ 5 files changed, 44 insertions(+), 3 deletions(-) diff --git a/components/render/ios/renderAux.swift b/components/render/ios/renderAux.swift index 431704c..c0bbc31 100644 --- a/components/render/ios/renderAux.swift +++ b/components/render/ios/renderAux.swift @@ -12,3 +12,8 @@ func renderPixelSize(_ view: UIView) -> [Int32] { let h = Int32(max(1, (view.bounds.height * scale).rounded())) return [w, h] } + +func renderRecreateSurface(_ vm: RenderVM) { + eglResetSurface(&vm.glView.st) + eglMakeCurrentContext(&vm.glView.st) +} diff --git a/components/render/ios/view/RenderGLView.swift b/components/render/ios/view/RenderGLView.swift index a7ad397..d054063 100644 --- a/components/render/ios/view/RenderGLView.swift +++ b/components/render/ios/view/RenderGLView.swift @@ -25,9 +25,6 @@ final class RenderGLView: UIView { override func layoutSubviews() { super.layoutSubviews() - if st.surface != nil { - guard eglResetSurface(&st), eglMakeCurrentContext(&st) else { fatalError("ERROR Could not reset EGL surface") } - } let ps = renderPixelSize(self) renderSet(F.reshapePixelSize, ps) } diff --git a/components/render/mac/renderAux.swift b/components/render/mac/renderAux.swift index cd5d82a..abd3e21 100644 --- a/components/render/mac/renderAux.swift +++ b/components/render/mac/renderAux.swift @@ -13,3 +13,7 @@ func renderPixelSize(_ view: NSView) -> [Int32] { let h = Int32(max(1, backing.height)) return [w, h] } + +func renderRecreateSurface(_ vm: RenderVM) { + // No-op on macOS +} diff --git a/ogs-blue/dialect.yml b/ogs-blue/dialect.yml index ece6548..7c28b32 100644 --- a/ogs-blue/dialect.yml +++ b/ogs-blue/dialect.yml @@ -33,6 +33,7 @@ RenderContext: pixelSize: [Int32] reshapePixelSize: [Int32] willDeinit: Bool + willRecreateSurface: Bool RenderComponent: type: component @@ -42,6 +43,7 @@ RenderComponent: - didPrepareGL: renderStartTimer(RenderVM.shared!) - pixelSize: RenderVM.shared!.pixelSize = c.pixelSize - willDeinit: renderDeinit(RenderVM.shared!) + - willRecreateSurface: renderRecreateSurface(RenderVM.shared!) shoulds: didLaunch: 1. Only once during the first setup: @@ -78,3 +80,9 @@ RenderComponent: c.recentField == F.backingPixelSize then: c.pixelSize = c.backingPixelSize + willRecreateSurface: + 1. Upon resize: + if: + c.recentField == F.reshapePixelSize + then: + c.willRecreateSurface = true diff --git a/ogs-blue/ver-mac/src/dialect.swift b/ogs-blue/ver-mac/src/dialect.swift index 411020e..e860d79 100644 --- a/ogs-blue/ver-mac/src/dialect.swift +++ b/ogs-blue/ver-mac/src/dialect.swift @@ -128,6 +128,7 @@ public struct F { public static let pixelSize = "pixelSize" public static let reshapePixelSize = "reshapePixelSize" public static let willDeinit = "willDeinit" + public static let willRecreateSurface = "willRecreateSurface" } public struct BlueContext: DialectContext { @@ -171,6 +172,7 @@ public struct RenderContext: DialectContext { public var pixelSize = [Int32]() public var reshapePixelSize = [Int32]() public var willDeinit = Bool() + public var willRecreateSurface = Bool() public var recentField = "" @@ -202,6 +204,9 @@ public struct RenderContext: DialectContext { else if (name == "willDeinit") { return willDeinit as! T } + else if (name == "willRecreateSurface") { + return willRecreateSurface as! T + } return "unknown-field-name" as! T } @@ -237,6 +242,9 @@ public struct RenderContext: DialectContext { else if (name == "willDeinit") { willDeinit = value as! Bool } + else if (name == "willRecreateSurface") { + willRecreateSurface = value as! Bool + } } } @@ -353,6 +361,23 @@ func renderShouldResetPixelSize(_ c: RenderContext) -> RenderContext { return c } +func renderShouldResetWillRecreateSurface(_ c: RenderContext) -> RenderContext { + var c = c + + /* 1. Upon resize */ + if + c.recentField == F.reshapePixelSize + { + c.willRecreateSurface = true + c.recentField = F.willRecreateSurface + return c + } + + + c.recentField = DIALECT_CONTEXT_RECENT_FIELD_NONE + return c +} + func blueRegisterShoulds(_ ctrl: DialectController) { [ blueShouldResetDidLaunch, @@ -367,6 +392,7 @@ func renderRegisterShoulds(_ ctrl: DialectController) { renderShouldResetDidLaunch, renderShouldResetDidPrepareGL, renderShouldResetPixelSize, + renderShouldResetWillRecreateSurface, ].forEach { f in ctrl.registerFunction { c in f(c as! RenderContext) } @@ -380,6 +406,7 @@ func renderRegisterEffects(_ ctrl: DialectController) { F.didPrepareGL, { (c: RenderContext) in renderStartTimer(RenderVM.shared!) }, F.pixelSize, { (c: RenderContext) in RenderVM.shared!.pixelSize = c.pixelSize }, F.willDeinit, { (c: RenderContext) in renderDeinit(RenderVM.shared!) }, + F.willRecreateSurface, { (c: RenderContext) in renderRecreateSurface(RenderVM.shared!) }, ]) } -- 2.53.0 From b750dace761d1bb58cc937e20b8aea835177ea7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB=20=D0=9A=D0=B0=D0=BF?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BA=D0=BE?= Date: Thu, 29 Oct 2026 23:42:24 +0300 Subject: [PATCH 46/55] some --- components/raybri/ios/raybri.c | 7 +------ components/raybri/mac/raybri.c | 7 +------ components/raybri/raybri.h | 3 +-- components/render/ios/renderEffect.swift | 2 +- components/render/mac/renderEffect.swift | 2 +- 5 files changed, 5 insertions(+), 16 deletions(-) diff --git a/components/raybri/ios/raybri.c b/components/raybri/ios/raybri.c index 947c2bc..0b2f6ce 100644 --- a/components/raybri/ios/raybri.c +++ b/components/raybri/ios/raybri.c @@ -11,7 +11,7 @@ #include -void raybriInit(void *layer) { +void raybriInit() { //SetTraceLogLevel(LOG_WARNING); // Initialize raylib graphics layer with a placeholder 1x1 framebuffer size @@ -21,11 +21,6 @@ void raybriInit(void *layer) { rlClearColor(0, 0, 255, 255); } -void raybriLog(const char *txt) { - fprintf(stderr, "Raybri: %s\n", txt); - fflush(stderr); -} - void raybriRender(int width, int height) { // Set the drawing area to the current pixel size rlViewport(0, 0, width, height); diff --git a/components/raybri/mac/raybri.c b/components/raybri/mac/raybri.c index f0c6857..9cd5da9 100644 --- a/components/raybri/mac/raybri.c +++ b/components/raybri/mac/raybri.c @@ -7,7 +7,7 @@ #include "rlgl.h" #include -void raybriInit(void *layer) { +void raybriInit() { //SetTraceLogLevel(LOG_WARNING); // Load OpenGL extensions @@ -19,11 +19,6 @@ void raybriInit(void *layer) { rlClearColor(0, 0, 255, 255); } -void raybriLog(const char *txt) { - fprintf(stderr, "Raybri: %s\n", txt); - fflush(stderr); -} - void raybriRender(int width, int height) { // Set the drawing area to the current pixel size rlViewport(0, 0, width, height); diff --git a/components/raybri/raybri.h b/components/raybri/raybri.h index 0b0af2c..ea3d372 100644 --- a/components/raybri/raybri.h +++ b/components/raybri/raybri.h @@ -5,8 +5,7 @@ #include "../egl/egl.h" #endif -void raybriInit(void *layer); -void raybriLog(const char *txt); +void raybriInit(); void raybriRender(int width, int height); void raybriShutdown(void); diff --git a/components/render/ios/renderEffect.swift b/components/render/ios/renderEffect.swift index 4a7dd13..247f967 100644 --- a/components/render/ios/renderEffect.swift +++ b/components/render/ios/renderEffect.swift @@ -23,7 +23,7 @@ func renderInit(_ vm: RenderVM) { guard eglResetSurface(&vm.glView.st) else { fatalError("ERROR Could not reset EGL surface") } guard eglMakeCurrentContext(&vm.glView.st) else { fatalError("ERROR Could not make EGL context current") } - raybriInit(layer) + raybriInit() } func renderStartTimer(_ vm: RenderVM) { diff --git a/components/render/mac/renderEffect.swift b/components/render/mac/renderEffect.swift index 31165ad..ad3d568 100644 --- a/components/render/mac/renderEffect.swift +++ b/components/render/mac/renderEffect.swift @@ -16,7 +16,7 @@ func renderInit(_ vm: RenderVM) { var swapInterval: Int32 = 1 vm.glView.openGLContext?.setValues(&swapInterval, for: .swapInterval) - raybriInit(nil) + raybriInit() } func renderStartTimer(_ vm: RenderVM) { -- 2.53.0 From 32dd0ab1138cd718ee1f9d5ea4dfcac38798df49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB=20=D0=9A=D0=B0=D0=BF?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BA=D0=BE?= Date: Thu, 29 Oct 2026 23:44:18 +0300 Subject: [PATCH 47/55] fix warning --- components/raybri/ios/raybri.c | 2 +- components/raybri/mac/raybri.c | 2 +- components/raybri/raybri.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/components/raybri/ios/raybri.c b/components/raybri/ios/raybri.c index 0b2f6ce..3d44af9 100644 --- a/components/raybri/ios/raybri.c +++ b/components/raybri/ios/raybri.c @@ -11,7 +11,7 @@ #include -void raybriInit() { +void raybriInit(void) { //SetTraceLogLevel(LOG_WARNING); // Initialize raylib graphics layer with a placeholder 1x1 framebuffer size diff --git a/components/raybri/mac/raybri.c b/components/raybri/mac/raybri.c index 9cd5da9..c9dccd5 100644 --- a/components/raybri/mac/raybri.c +++ b/components/raybri/mac/raybri.c @@ -7,7 +7,7 @@ #include "rlgl.h" #include -void raybriInit() { +void raybriInit(void) { //SetTraceLogLevel(LOG_WARNING); // Load OpenGL extensions diff --git a/components/raybri/raybri.h b/components/raybri/raybri.h index ea3d372..1d857ca 100644 --- a/components/raybri/raybri.h +++ b/components/raybri/raybri.h @@ -5,7 +5,7 @@ #include "../egl/egl.h" #endif -void raybriInit(); +void raybriInit(void); void raybriRender(int width, int height); void raybriShutdown(void); -- 2.53.0 From 3ab45ab003b6d2d40731873f876169a039f083d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB=20=D0=9A=D0=B0=D0=BF?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BA=D0=BE?= Date: Thu, 29 Oct 2026 23:46:52 +0300 Subject: [PATCH 48/55] brid h --- components/raybri/raybri.h | 4 ---- ogs-blue/ver-ios/project.yml | 2 +- ogs-blue/ver-ios/src/BlueBridgingHeader.h | 7 +++++++ 3 files changed, 8 insertions(+), 5 deletions(-) create mode 100644 ogs-blue/ver-ios/src/BlueBridgingHeader.h diff --git a/components/raybri/raybri.h b/components/raybri/raybri.h index 1d857ca..902f706 100644 --- a/components/raybri/raybri.h +++ b/components/raybri/raybri.h @@ -1,10 +1,6 @@ #ifndef RAYBRI_H #define RAYBRI_H -#if defined(PLATFORM_IOS) -#include "../egl/egl.h" -#endif - void raybriInit(void); void raybriRender(int width, int height); void raybriShutdown(void); diff --git a/ogs-blue/ver-ios/project.yml b/ogs-blue/ver-ios/project.yml index 12310e8..d5e0acf 100644 --- a/ogs-blue/ver-ios/project.yml +++ b/ogs-blue/ver-ios/project.yml @@ -27,5 +27,5 @@ targets: LD_RUNPATH_SEARCH_PATHS: - "$(inherited) @executable_path/Frameworks" PRODUCT_BUNDLE_IDENTIFIER: org.opengamestudio.blue - SWIFT_OBJC_BRIDGING_HEADER: src/raybri/raybri.h + SWIFT_OBJC_BRIDGING_HEADER: src/BlueBridgingHeader.h type: application diff --git a/ogs-blue/ver-ios/src/BlueBridgingHeader.h b/ogs-blue/ver-ios/src/BlueBridgingHeader.h new file mode 100644 index 0000000..2d1fc0f --- /dev/null +++ b/ogs-blue/ver-ios/src/BlueBridgingHeader.h @@ -0,0 +1,7 @@ +#ifndef OGS_BLUE_BRIDGING_HEADER_H +#define OGS_BLUE_BRIDGING_HEADER_H + +#include "egl/egl.h" +#include "raybri/raybri.h" + +#endif // OGS_BLUE_BRIDGING_HEADER_H -- 2.53.0 From d4da4325f9f69de88c54d87f0a500ff1cef2ac65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB=20=D0=9A=D0=B0=D0=BF?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BA=D0=BE?= Date: Thu, 29 Oct 2026 23:51:06 +0300 Subject: [PATCH 49/55] blue c --- components/raybri/ios/raybri.c | 36 ---------------------------- components/raybri/raybri.h | 34 ++++++++++++++++++++++++++ ogs-blue/ver-ios/src/Blue.c | 12 ++++++++++ ogs-blue/ver-ios/src/raybri/raybri.c | 1 - 4 files changed, 46 insertions(+), 37 deletions(-) delete mode 100644 components/raybri/ios/raybri.c create mode 100644 ogs-blue/ver-ios/src/Blue.c delete mode 120000 ogs-blue/ver-ios/src/raybri/raybri.c diff --git a/components/raybri/ios/raybri.c b/components/raybri/ios/raybri.c deleted file mode 100644 index 3d44af9..0000000 --- a/components/raybri/ios/raybri.c +++ /dev/null @@ -1,36 +0,0 @@ -#define EGL_CONST_IMPLEMENTATION -#include "eglConst.h" - -#define EGL_IMPLEMENTATION -#include "egl.h" - -#include "raybri.h" - -#define RLGL_IMPLEMENTATION -#include "rlgl.h" - -#include - -void raybriInit(void) { - //SetTraceLogLevel(LOG_WARNING); - - // Initialize raylib graphics layer with a placeholder 1x1 framebuffer size - // Graphics layer includes default texture, shader, render batch and OpenGL state - rlglInit(1, 1); - // Background is painted in blue - rlClearColor(0, 0, 255, 255); -} - -void raybriRender(int width, int height) { - // Set the drawing area to the current pixel size - rlViewport(0, 0, width, height); - // Clear color and depth buffers for the next frame - rlClearScreenBuffers(); - // Draw any queued geometry - rlDrawRenderBatchActive(); -} - -void raybriShutdown(void) { - // Release rlgl buffers, shaders and textures - rlglClose(); -} diff --git a/components/raybri/raybri.h b/components/raybri/raybri.h index 902f706..4960c11 100644 --- a/components/raybri/raybri.h +++ b/components/raybri/raybri.h @@ -1,8 +1,42 @@ #ifndef RAYBRI_H #define RAYBRI_H +// Header + void raybriInit(void); void raybriRender(int width, int height); void raybriShutdown(void); +// Source + +#if defined(RAYBRI_IMPLEMENTATION) + +#include "rlgl.h" + +void raybriInit(void) { + //SetTraceLogLevel(LOG_WARNING); + + // Initialize raylib graphics layer with a placeholder 1x1 framebuffer size + // Graphics layer includes default texture, shader, render batch and OpenGL state + rlglInit(1, 1); + // Background is painted in blue + rlClearColor(0, 0, 255, 255); +} + +void raybriRender(int width, int height) { + // Set the drawing area to the current pixel size + rlViewport(0, 0, width, height); + // Clear color and depth buffers for the next frame + rlClearScreenBuffers(); + // Draw any queued geometry + rlDrawRenderBatchActive(); +} + +void raybriShutdown(void) { + // Release rlgl buffers, shaders and textures + rlglClose(); +} + +#endif // RAYBRI_IMPLEMENTATION + #endif // RAYBRI_H diff --git a/ogs-blue/ver-ios/src/Blue.c b/ogs-blue/ver-ios/src/Blue.c new file mode 100644 index 0000000..919d07b --- /dev/null +++ b/ogs-blue/ver-ios/src/Blue.c @@ -0,0 +1,12 @@ +#define EGL_CONST_IMPLEMENTATION +#include "eglConst.h" + +#define EGL_IMPLEMENTATION +#include "egl.h" + +#define RAYBRI_IMPLEMENTATION +#include "raybri.h" + +#define RLGL_IMPLEMENTATION +#include "rlgl.h" + diff --git a/ogs-blue/ver-ios/src/raybri/raybri.c b/ogs-blue/ver-ios/src/raybri/raybri.c deleted file mode 120000 index d36f47a..0000000 --- a/ogs-blue/ver-ios/src/raybri/raybri.c +++ /dev/null @@ -1 +0,0 @@ -../../../../components/raybri/ios/raybri.c \ No newline at end of file -- 2.53.0 From f4fd8cb5232a4753da9768e2db28f61c594def72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB=20=D0=9A=D0=B0=D0=BF?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BA=D0=BE?= Date: Thu, 29 Oct 2026 23:59:05 +0300 Subject: [PATCH 50/55] clarify --- components/raybri/mac/raybri.c | 34 ----------------------- components/raybri/mac/raybriAux.h | 2 +- components/raybri/{mac => }/raybriConst.h | 0 components/render/mac/renderEffect.swift | 3 ++ ogs-blue/ver-ios/src/Blue.c | 3 ++ ogs-blue/ver-ios/src/raybri/raybriConst.h | 1 + ogs-blue/ver-mac/src/Blue.c | 11 ++++++++ ogs-blue/ver-mac/src/raybri/raybri.c | 1 - ogs-blue/ver-mac/src/raybri/raybriConst.h | 2 +- 9 files changed, 20 insertions(+), 37 deletions(-) delete mode 100644 components/raybri/mac/raybri.c rename components/raybri/{mac => }/raybriConst.h (100%) create mode 120000 ogs-blue/ver-ios/src/raybri/raybriConst.h create mode 100644 ogs-blue/ver-mac/src/Blue.c delete mode 120000 ogs-blue/ver-mac/src/raybri/raybri.c diff --git a/components/raybri/mac/raybri.c b/components/raybri/mac/raybri.c deleted file mode 100644 index c9dccd5..0000000 --- a/components/raybri/mac/raybri.c +++ /dev/null @@ -1,34 +0,0 @@ -#include "raybri.h" -// Const must be before Aux due to Aux referencing constants of Const -#define RAYBRI_CONST_IMPLEMENTATION -#include "raybriConst.h" -#define RAYBRI_AUX_IMPLEMENTATION -#include "raybriAux.h" -#include "rlgl.h" -#include - -void raybriInit(void) { - //SetTraceLogLevel(LOG_WARNING); - - // Load OpenGL extensions - rlLoadExtensions((void *)raybriGLLoader); - // Initialize raylib graphics layer with a placeholder 1x1 framebuffer size - // Graphics layer includes default texture, shader, render batch and OpenGL state - rlglInit(1, 1); - // Background is painted in blue - rlClearColor(0, 0, 255, 255); -} - -void raybriRender(int width, int height) { - // Set the drawing area to the current pixel size - rlViewport(0, 0, width, height); - // Clear color and depth buffers for the next frame - rlClearScreenBuffers(); - // Draw any queued geometry - rlDrawRenderBatchActive(); -} - -void raybriShutdown(void) { - // Release rlgl buffers, shaders and textures - rlglClose(); -} diff --git a/components/raybri/mac/raybriAux.h b/components/raybri/mac/raybriAux.h index 40c44ca..fd9630c 100644 --- a/components/raybri/mac/raybriAux.h +++ b/components/raybri/mac/raybriAux.h @@ -10,8 +10,8 @@ void *raybriGLLoader(const char *name); #if defined(RAYBRI_AUX_IMPLEMENTATION) #include -#include #include "raybriConst.h" +#include // raylib is built as a static/dynamic library with GLFW baked in, but we never // call InitWindow(). Instead we render into an OpenGL context owned by the diff --git a/components/raybri/mac/raybriConst.h b/components/raybri/raybriConst.h similarity index 100% rename from components/raybri/mac/raybriConst.h rename to components/raybri/raybriConst.h diff --git a/components/render/mac/renderEffect.swift b/components/render/mac/renderEffect.swift index ad3d568..4f7b306 100644 --- a/components/render/mac/renderEffect.swift +++ b/components/render/mac/renderEffect.swift @@ -16,6 +16,9 @@ func renderInit(_ vm: RenderVM) { var swapInterval: Int32 = 1 vm.glView.openGLContext?.setValues(&swapInterval, for: .swapInterval) + // Load OpenGL extensions + rlLoadExtensions((void *)raybriGLLoader); + raybriInit() } diff --git a/ogs-blue/ver-ios/src/Blue.c b/ogs-blue/ver-ios/src/Blue.c index 919d07b..52c46a0 100644 --- a/ogs-blue/ver-ios/src/Blue.c +++ b/ogs-blue/ver-ios/src/Blue.c @@ -4,6 +4,9 @@ #define EGL_IMPLEMENTATION #include "egl.h" +#define RAYBRI_CONST_IMPLEMENTATION +#include "raybriConst.h" + #define RAYBRI_IMPLEMENTATION #include "raybri.h" diff --git a/ogs-blue/ver-ios/src/raybri/raybriConst.h b/ogs-blue/ver-ios/src/raybri/raybriConst.h new file mode 120000 index 0000000..7e1b994 --- /dev/null +++ b/ogs-blue/ver-ios/src/raybri/raybriConst.h @@ -0,0 +1 @@ +../../../../components/raybri/raybriConst.h \ No newline at end of file diff --git a/ogs-blue/ver-mac/src/Blue.c b/ogs-blue/ver-mac/src/Blue.c new file mode 100644 index 0000000..d0e9f07 --- /dev/null +++ b/ogs-blue/ver-mac/src/Blue.c @@ -0,0 +1,11 @@ +#define RAYBRI_CONST_IMPLEMENTATION +#include "raybriConst.h" + +#define RAYBRI_AUX_IMPLEMENTATION +#include "raybriAux.h" + +#define RAYBRI_IMPLEMENTATION +#include "raybri.h" + +#define RLGL_IMPLEMENTATION +#include "rlgl.h" diff --git a/ogs-blue/ver-mac/src/raybri/raybri.c b/ogs-blue/ver-mac/src/raybri/raybri.c deleted file mode 120000 index 80f2251..0000000 --- a/ogs-blue/ver-mac/src/raybri/raybri.c +++ /dev/null @@ -1 +0,0 @@ -../../../../components/raybri/mac/raybri.c \ No newline at end of file diff --git a/ogs-blue/ver-mac/src/raybri/raybriConst.h b/ogs-blue/ver-mac/src/raybri/raybriConst.h index f834a27..7e1b994 120000 --- a/ogs-blue/ver-mac/src/raybri/raybriConst.h +++ b/ogs-blue/ver-mac/src/raybri/raybriConst.h @@ -1 +1 @@ -../../../../components/raybri/mac/raybriConst.h \ No newline at end of file +../../../../components/raybri/raybriConst.h \ No newline at end of file -- 2.53.0 From f0972f0d5ba796e3fa417081f43c00a9654b2aa6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB=20=D0=9A=D0=B0=D0=BF?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BA=D0=BE?= Date: Fri, 30 Oct 2026 00:02:25 +0300 Subject: [PATCH 51/55] blue mac --- components/render/mac/renderEffect.swift | 2 +- ogs-blue/ver-mac/Package.swift | 10 ++++++---- ogs-blue/ver-mac/src/Blue.c | 3 --- ogs-blue/ver-mac/src/raybri/Blue.h | 8 ++++++++ 4 files changed, 15 insertions(+), 8 deletions(-) create mode 100644 ogs-blue/ver-mac/src/raybri/Blue.h diff --git a/components/render/mac/renderEffect.swift b/components/render/mac/renderEffect.swift index 4f7b306..b246dcf 100644 --- a/components/render/mac/renderEffect.swift +++ b/components/render/mac/renderEffect.swift @@ -17,7 +17,7 @@ func renderInit(_ vm: RenderVM) { vm.glView.openGLContext?.setValues(&swapInterval, for: .swapInterval) // Load OpenGL extensions - rlLoadExtensions((void *)raybriGLLoader); + rlLoadExtensions(unsafeBitCast(raybriGLLoader as @convention(c) (UnsafePointer?) -> UnsafeMutableRawPointer?, to: UnsafeMutableRawPointer.self)) raybriInit() } diff --git a/ogs-blue/ver-mac/Package.swift b/ogs-blue/ver-mac/Package.swift index 8ea77e5..8c03e0b 100644 --- a/ogs-blue/ver-mac/Package.swift +++ b/ogs-blue/ver-mac/Package.swift @@ -12,9 +12,11 @@ let package = Package( targets: [ .target( name: "RaylibBridge", - path: "src/raybri", - publicHeadersPath: ".", + path: "src", + sources: ["Blue.c"], + publicHeadersPath: "raybri", cSettings: [ + .headerSearchPath("raybri"), .unsafeFlags(["-I", "\(raylibPrefix)/include"]) ] ), @@ -22,9 +24,9 @@ let package = Package( name: "ogs-blue", dependencies: ["RaylibBridge"], path: "src", - exclude: ["raybri"], + exclude: ["raybri", "Blue.c"], swiftSettings: [ - .unsafeFlags(["-Xcc", "-DGL_SILENCE_DEPRECATION"]) + .unsafeFlags(["-Xcc", "-DGL_SILENCE_DEPRECATION", "-Xcc", "-I\(raylibPrefix)/include"]) ], linkerSettings: [ .unsafeFlags([ diff --git a/ogs-blue/ver-mac/src/Blue.c b/ogs-blue/ver-mac/src/Blue.c index d0e9f07..2797ded 100644 --- a/ogs-blue/ver-mac/src/Blue.c +++ b/ogs-blue/ver-mac/src/Blue.c @@ -6,6 +6,3 @@ #define RAYBRI_IMPLEMENTATION #include "raybri.h" - -#define RLGL_IMPLEMENTATION -#include "rlgl.h" diff --git a/ogs-blue/ver-mac/src/raybri/Blue.h b/ogs-blue/ver-mac/src/raybri/Blue.h new file mode 100644 index 0000000..8508c9c --- /dev/null +++ b/ogs-blue/ver-mac/src/raybri/Blue.h @@ -0,0 +1,8 @@ +#ifndef BLUE_H +#define BLUE_H + +#include "raybri.h" +#include "raybriAux.h" +#include "rlgl.h" + +#endif // BLUE_H -- 2.53.0 From cd82f445d3eaebc2388112970f868038d019fdfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB=20=D0=9A=D0=B0=D0=BF?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BA=D0=BE?= Date: Fri, 30 Oct 2026 16:35:30 +0300 Subject: [PATCH 52/55] mirr --- AGENTS.md | 300 ++++++++++++++--------------------------- docs/mirror-summary.md | 68 ++++++++++ 2 files changed, 167 insertions(+), 201 deletions(-) create mode 100644 docs/mirror-summary.md diff --git a/AGENTS.md b/AGENTS.md index 9026946..514202f 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -1,218 +1,120 @@ -# OGS Mahjong (`mj`) +# OGS applications (`mj`) -A macOS SwiftUI app for **OGS Mahjong**, built on the **Dialect v4** declarative -reactive engine (see the sibling `../dialect` repo — this project is a -downstream consumer of its code generator). +Native SwiftUI applications using the Dialect v4 declarative reactive engine. +Version: `2.0.0`. Remote: `https://git.opengamestudio.org/mahjong/mahjong`. -Business logic lives in `dialect.yml` (YAML). A generator turns it into -`game/ver-mac/src/dialect.swift` (the runtime engine + `struct F` field -constants + component/should/effect registration). The Swift app shell -(`GameApp`/`AppDelegate`) and the SwiftUI views live outside the generated file -and talk to the engine through generated functions like `rootSet(...)`. +## Current status -Remote: `https://git.opengamestudio.org/mahjong/mahjong` · Version: `2.0.0` +- `ogs-blue/` is the active minimal graphics example for macOS and iOS: a solid + blue raylib background with a SwiftUI overlay. It has no model/texture/shadow + scene; rlgl still creates its default internal GPU resources. +- `ogs-mahjong/` contains the macOS Mahjong scaffold and counter-template logic; + Mahjong gameplay has not been implemented. +- `ogs-chkgfx/` is a companion graphics scaffold with macOS/iOS project files. + Older targets can lag behind shared-component changes; verify each target + separately before claiming it builds. +- The previous `game/ver-mac` and root `dialect.yml` layout is obsolete. -> `dialect.yml` is still the "Root / counter" template with a `Render` context -> bolted on: the Mahjong game logic has not been written yet. The app shell, -> packaging, symlink wiring and the raylib renderer are in place. +## Source layout -## Structure +- `/dialect.yml`: per-application logic; generates + `/ver-mac/src/dialect.swift`. Blue iOS links to its macOS generated file. +- `components/`: shared source of truth. App `src/` files use relative symlinks; + edit real component files and preserve symlink parity. +- `components/render/`: shared component/model/constants, plus mirrored `ios/` + and `mac/` effects, helpers and native/SwiftUI views. macOS additionally has + `renderConstMac.swift` for native pixel-format attributes. +- `components/raybri/raybri.h`: declarations plus implementation gated by + `RAYBRI_IMPLEMENTATION`; clears blue, renders and shuts down rlgl. +- `components/raybri/raybriConst.h`: shared constants with an implementation macro. + `components/raybri/mac/raybriAux.h`: macOS OpenGL symbol loader. +- `components/egl/egl.h` and `eglConst.h`: EGL state/helpers and configuration, + using single-header implementation macros. +- `ogs-blue/ver-{mac,ios}/src/Blue.c`: platform C implementation translation units. +- `history/gitjs/`: historical JavaScript Mahjong reference, outside the build. + `ref/swiftraylib` links to the sibling renderer sample. -``` -dialect.yml Single source of truth for the reactive logic. - Generates game/ver-mac/src/dialect.swift +## Graphics ownership and platform differences -components/ SHARED source-of-truth for all components. - other/other.swift Shared helpers (otherPrintStderr, otherWriteFile, - otherSetupConsoleLogging, ...) - raybri/raybri.h C API of the raylib bridge (raybri_config, raybri_init, - raybri_load_model, raybri_resize, raybri_set_rotation, - raybri_render, raybri_shutdown); extern "C" guards. - raybri/raybri.c Bridge implementation: rlgl scene, shadow pass, shaders. - root/root.swift RootComponent (owns DialectController, registers - effects + shoulds, sets didSetup on setup()) - root/rootVM.swift RootVM (ObservableObject / @Published countText) - root/mac/view/RootView.swift SwiftUI view: RenderView in a ZStack + UI - render/render.swift RenderComponent (controller, effects + shoulds) - render/renderVM.swift RenderVM (weak shared; glView, didPrepareGL, - pixelSize, startTime, timer) - render/renderConst.swift RENDER_CONFIG (raybri_config), RENDER_FPS, - RENDER_MODEL_CUBE, RENDER_OPENGL_ATTRS - render/renderConstShader.swift RENDER_SHADER_* GLSL sources (GLSL 150) - render/renderAux.swift renderDraw(vm), renderPixelSize(view) - render/renderEffect.swift renderInit, renderLoadCubeModel, - renderStartTimer, renderDeinit - render/mac/view/RenderGLView.swift Thin NSOpenGLView: pixel format, callbacks - -> renderSet(...), draw -> renderDraw - render/mac/view/RenderView.swift NSViewRepresentable wrapper +Every GPU operation requires its context current on the calling thread. +`rlLoadExtensions` also requires an existing current context; it precedes +`rlglInit`, not native context creation. -game/ver-mac/ macOS app (SPM executable target "ogs-mahjong") - Package.swift SPM manifest (macOS 13+, swift-tools 5.9); C target - "RaylibBridge" (path src/raybri, publicHeadersPath ".") + - links Homebrew raylib; the Swift target excludes raybri - and gets -Xcc -DGL_SILENCE_DEPRECATION - Info.plist Bundle id org.opengamestudio.Mahjong, exec ogs-mahjong - Resources/AppIcon.icns App icon - Resources/assets/ Bundled glTF assets: cube.gltf (static), - cube_texture.png, cube_normal.png - src/ - GameApp.swift @main SwiftUI App entry - AppDelegate.swift Creates Render/Root components + VMs, calls setup() - dialect.swift GENERATED — do not hand-edit (see chicken-egg below) - other/other.swift -> symlink components/other/other.swift - raybri/raybri.c -> symlink components/raybri/raybri.c - raybri/raybri.h -> symlink components/raybri/raybri.h - render/render.swift -> symlink components/render/render.swift - render/renderAux.swift -> symlink components/render/renderAux.swift - render/renderConst.swift -> symlink components/render/renderConst.swift - render/renderConstShader.swift -> symlink .../renderConstShader.swift - render/renderEffect.swift -> symlink components/render/renderEffect.swift - render/renderVM.swift -> symlink components/render/renderVM.swift - render/view/RenderGLView.swift -> symlink components/render/mac/view/... - render/view/RenderView.swift -> symlink components/render/mac/view/... - root/root.swift -> symlink components/root/root.swift - root/rootVM.swift -> symlink components/root/rootVM.swift - root/view/RootView.swift -> symlink components/root/mac/view/... +macOS uses `NSOpenGLView` (OpenGL 3.2 Core). `renderInit` makes its context +current, enables VSync, loads extensions with the C loader callback and starts +raylib. The timer requests `needsDisplay`; `draw(_:)` forwards to `renderDraw`, +which activates the context, renders and presents via `flushBuffer`. -ref/swiftraylib Symlink to ../../swiftraylib — the raylib/SwiftUI - renderer sample the game will use for 3D rendering. +Blue's SPM `RaylibBridge` target compiles `src/Blue.c`, exposes headers in +`src/raybri`, and links Homebrew raylib. It does NOT define +`RLGL_IMPLEMENTATION`: Homebrew headers omit the `external/glad.h` needed to +compile desktop rlgl locally. Swift imports `RaylibBridge`. `RAYLIB_PREFIX` +defaults to `/opt/homebrew`; build scripts detect `brew --prefix raylib`. +The installed raylib may produce a deployment-target linker warning. -util/ Build/run scripts (see Build & Run) - paths APP_MAC = .build/OGS Mahjong.app - build-mac generateDialect -> buildMac -> packageMac - run-mac runMac - rm-mac-geom Resets saved window geometry - step/ Sourced steps: generateDialect, buildMac, - packageMac, runMac +On iOS, UIKit owns the view/layer and `RenderGLView.st` owns an `EGLState`. +Swift effects create EGL/ANGLE state and surface, make the context current, +and initialize raylib. Timer ticks call rendering directly; presentation uses +`eglSwapBuffers`. Pixel sizes come from view bounds and content scale. +Dialect's resize event triggers `renderRecreateSurface`; the macOS helper is +intentionally a no-op. Teardown must stop the timer, activate the context, +release rlgl resources, then destroy EGL surface/context/display resources. -history/gitjs/ GitJS "Glavred" history + the original JS source of the - web Mahjong, kept for reference — not part of the build. +Blue iOS uses `src/BlueBridgingHeader.h` to expose C APIs to Swift. `Blue.c` +compiles EGL helpers and rlgl using their implementation macros exactly once. +It uses the raylib-iOS XCFramework headers but does not link its full raylib +library. The app links/embeds `libEGL` and `libGLESv2` (ANGLE's Metal backend). +The XcodeGen settings define `PLATFORM_IOS`, `GRAPHICS_API_OPENGL_ES3`, and +`GL_GLEXT_PROTOTYPES`. Minimum iOS is 15.0; portrait and both landscape +orientations are enabled in Blue's Info.plist. + +## Build and prerequisites + +- macOS: `brew install raylib`. +- iOS project generation: `brew install xcodegen`; supply sibling + `../raylib-ios-xcframeworks` containing raylib/libEGL/libGLESv2 XCFrameworks. + `checkRaylibIOS` checks presence; it does not download them. +- Dialect: sibling `../dialect`, built with `(cd ../dialect && util/build-generator)`. + +```sh +util/build-ogs-blue-mac +util/run-ogs-blue-mac +util/prepare-ogs-blue-ios ``` -## Symlink parity rule +The corresponding macOS build/run scripts also exist for `ogs-chkgfx` and +`ogs-mahjong`; `prepare-ogs-chkgfx-ios` exists as well. Inspect their individual +configuration before assuming parity with Blue. -`components/` is the source of truth; `game/ver-mac/src/` contains real -directories whose files are **relative symlinks** back into `components/`: +macOS build scripts generate Dialect, run `swift build`, and package resources +from `ver-mac/res/` into `ver-mac/.build/.app`. iOS preparation checks +XCFrameworks, generates Dialect, stages ANGLE include/library symlinks in +`ver-ios/.build/`, then runs XcodeGen. Build Blue for Simulator with: -``` -src/other/other.swift -> ../../../../components/other/other.swift (4 up) -src/raybri/raybri.c -> ../../../../components/raybri/raybri.c (4 up) -src/raybri/raybri.h -> ../../../../components/raybri/raybri.h (4 up) -src/render/render.swift -> ../../../../components/render/render.swift (4 up) -src/render/renderAux.swift -> ../../../../components/render/renderAux.swift (4 up) -src/render/renderConst.swift-> ../../../../components/render/renderConst.swift (4 up) -src/render/renderConstShader.swift -> ../../../../components/render/renderConstShader.swift (4 up) -src/render/renderEffect.swift -> ../../../../components/render/renderEffect.swift (4 up) -src/render/renderVM.swift -> ../../../../components/render/renderVM.swift (4 up) -src/root/root.swift -> ../../../../components/root/root.swift (4 up) -src/root/rootVM.swift -> ../../../../components/root/rootVM.swift (4 up) -src/root/view/RootView.swift-> ../../../../../components/root/mac/view/RootView.swift (5 up) -src/render/view/RenderGLView.swift -> ../../../../../components/render/mac/view/RenderGLView.swift (5 up) -src/render/view/RenderView.swift -> ../../../../../components/render/mac/view/RenderView.swift (5 up) +```sh +xcodebuild -project 'ogs-blue/ver-ios/OGS blue.xcodeproj' -scheme ogs-blue \ + -sdk iphonesimulator -destination 'generic/platform=iOS Simulator' \ + CODE_SIGNING_ALLOWED=NO build ``` -SPM silently **skips** a dangling symlink (no error), so after moving -`components/` or a subdir, audit for broken links: +Audit dangling source symlinks after moves (SPM can silently skip them): -```bash -find . -type l ! -exec test -e {} \; -not -path './.build/*' +```sh +find components ogs-blue ogs-chkgfx ogs-mahjong -type l ! -exec test -e {} \; -not -path '*/.build/*' ``` -## Prerequisite: the generator - -`util/step/generateDialect` calls the **sibling** dialect repo: - -```bash -$SDIR/../../dialect/util/run-generator --file=$SDIR/../dialect.yml -``` - -So `/Volumes/MOE/p/dialect` must exist and its generator must be built before -`util/build-mac` can regenerate: - -```bash -(cd ../dialect && util/build-generator) # once, or after dialect core changes -``` - -The generator resolves the `output:` path **relative to `dialect.yml`'s -directory**, which is why `dialect.yml` says `game/ver-mac/src/dialect.swift`. - -## Prerequisite: raylib - -The 3D scene links against Homebrew **raylib** (`brew install raylib`). The -`RaylibBridge` C target and the link step read `RAYLIB_PREFIX` (default -`/opt/homebrew`); `util/step/buildMac` auto-detects it via `brew --prefix raylib`. -The bridge renders with raylib's rlgl layer into an `NSOpenGLView` — raylib never -creates its own window. `RootView` puts `RenderView` (backed by `RenderGLView`) -behind the SwiftUI UI in a `ZStack`. A textured cube is drawn from `Resources/assets` (`cube.gltf` + -`cube_texture.png` + `cube_normal.png`); the app rotates it each frame via `raybri_set_rotation`. -(raylib's `LoadModelAnimations` only handles *skinned* meshes, so a plain -node-rotation glTF animation cannot be played by the renderer — hence the cube is -app-driven.) `packageMac` bundles `Resources/assets/` into the app. - -Shaders and render constants live in **Swift**, not in C: GLSL sources are -`RENDER_SHADER_*` in `components/render/renderConstShader.swift`, and -`RENDER_CONFIG` / `raybri_config` tunables are in `renderConst.swift`. `raybri_init` -compiles the shaders in place (no storage/`strdup`). `cube_normal.png` drives -tangentless normal mapping via the derivative-based `cotangentFrame`. The -context is OpenGL 3.2 Core (`RENDER_OPENGL_ATTRS`); on Apple Silicon the driver -still reports 4.1/GLSL 4.10. - -## Render architecture - -The `Render` dialect context owns the GL scene. `RenderGLView` is a thin -`NSOpenGLView`; it only translates AppKit callbacks into dialect fields, and the -`render*` files do the actual work. - -1. `AppDelegate` creates `RenderComponent` + `RenderVM` and calls - `render.setup()` -> `didSetup` -> `didLaunch` (should) -> `pixelSize = [1, 1]`. -2. SwiftUI builds `RenderView` -> `RenderGLView`; `prepareOpenGL()` sets - `F.didPrepareGL`. Its oneliners run `renderInit` (`raybri_init`), set - `RenderVM.didPrepareGL = true`, and `renderStartTimer`. -3. `reshape()` / `viewDidChangeBackingProperties()` compute the backing pixel - size via `renderPixelSize` and set `F.reshapePixelSize` / - `F.backingPixelSize`. The `pixelSize` shoulds fold these into `F.pixelSize`, - whose oneliner stores `RenderVM.pixelSize`. -4. The timer only sets `needsDisplay` every `1 / RENDER_FPS`. `draw(_:)` forwards - to `renderDraw` (make context current, `raybri_resize`, `raybri_set_rotation`, - `raybri_render`, `flushBuffer`). -5. A button click runs `rootSet(F.didClickIncrement)` -> RootComponent oneliner - `renderSet(F.didClickIncrement)` -> `renderLoadCubeModel` (the cube is loaded - on demand, not at startup). -6. `RenderGLView.deinit` sets `F.willDeinit` -> `renderDeinit` (stop timer, - `raybri_shutdown`). - -**GL context rule**: every raylib call must run with the view's context current. -`renderInit`, `renderLoadCubeModel`, `renderDeinit` and `renderDraw` all call -`openGLContext?.makeCurrentContext()` first. Loading a model/texture without it -fails silently with `WARNING: TEXTURE: Failed to load texture`. - -## Build & Run - -```bash -util/build-mac # generateDialect + swift build + package OGS Mahjong.app -util/run-mac # runs .build/OGS Mahjong.app/Contents/MacOS/ogs-mahjong -util/rm-mac-geom # reset the app's saved window geometry -``` - -`build-mac` sources `util/paths` then the `util/step/*` scripts in order: - -1. `generateDialect` — runs the sibling generator, writes `src/dialect.swift` -2. `buildMac` — `brew --prefix raylib` -> `RAYLIB_PREFIX`, `swift build` -3. `packageMac` — assembles `.build/OGS Mahjong.app` (binary `ogs-mahjong`, - `Info.plist`, `Resources/AppIcon.icns`, `Resources/assets/`) - ## Editing the dialect -- Add/modify contexts and components in `dialect.yml`, then run - `util/build-mac` to regenerate `dialect.swift`. +- Add/modify contexts and components in `/dialect.yml`, then run + `util/build--mac` to regenerate `dialect.swift`. - **Chicken-egg**: `struct F` (field-name constants) lives only in the - generated `dialect.swift`. Adding a new field to a context in `dialect.yml` + generated `dialect.swift`. Adding a new field to a context in `/dialect.yml` requires hand-patching its `static let = ""` into `struct F` in `dialect.swift` (ASCII-alphabetical order) if you cannot regenerate first, otherwise the build fails on `F.` being unresolved. - `dialect.swift` is generated — edits there are overwritten on the next - `util/build-mac`. Change the source (`dialect.yml` / `components/`) instead. -- **Validate `dialect.yml` after edits** (e.g. `ruby -ryaml -e 'YAML.load_file("dialect.yml")'`). + `util/build--mac`. Change the source (`/dialect.yml` / `components/`) instead. +- **Validate `/dialect.yml` after edits** (e.g. `ruby -ryaml -e 'YAML.load_file("ogs-blue/dialect.yml")'`). Every should-branch label (`1. Upon each ...`) MUST end with a colon — the parser (`components/yml/ymlFun.swift`) blindly `dropLast()`s it, so a missing colon silently eats the label's last character in the generated `about` @@ -246,17 +148,13 @@ Do not flip it on without addressing those. - Never call raylib / `raybri_*` without making the view's GL context current first (see the GL context rule above). -## Skill: source-file study documents - -When the task is to produce a source-code study document — a self-contained, -downloadable HTML file with a line-by-line table of the file and its -explanations (and, on request, a second version highlighting changes after a -fix) — follow the skill in `docs/file-summary.md`. - -- Write the result to `docs/.html` (e.g. `docs/RaylibGLView.html`) and - name the file's Git revision in the header. The file is the source of truth — - document the exact revision requested, not the working tree. -- Existing example: `docs/RaylibGLView.html` — documents the historical - single-cube `RaylibGLView.swift`, since split into `RenderGLView.swift` plus - the `render*` files. +## Source study documents +- Single-file source studies: follow [docs/file-summary.md](docs/file-summary.md). +- Mirrored platform studies: follow [docs/mirror-summary.md](docs/mirror-summary.md). + Produce one self-contained downloadable HTML with aligned function starts, + original line numbers, green/orange number fills, counts/percentages and a + non-repetitive explanation column. +- Existing mirrored example: `docs/render-platform-comparison.html`, documenting + the revision named in its header. Never silently substitute working-tree code + for a requested historical revision. diff --git a/docs/mirror-summary.md b/docs/mirror-summary.md new file mode 100644 index 0000000..d3edfa2 --- /dev/null +++ b/docs/mirror-summary.md @@ -0,0 +1,68 @@ +# Mirrored source-file study documents + +Use this workflow when comparing corresponding source files across platforms. +The established example is `docs/render-platform-comparison.html`. +For a single-file study, follow `docs/file-summary.md` instead. + +## Source and scope + +- Read sources from the exact requested Git revision with `git show REV:path`. + If no revision is specified, use HEAD and record its full commit hash. +- Discover matching relative filenames beneath the two platform directories. + State which platform-only files are excluded; never invent a counterpart. +- Produce one downloadable, self-contained HTML document in `docs/`, with + navigation links and one section per file pair. Preserve earlier documents + unless removal is requested. +- Record both source paths and the source revision. Preserve every source line, + original line number, indentation and blank line. Escape HTML characters. + +## Comparison layout + +- Use one table per pair with three columns: first platform's numbered source, + second platform's numbered source, and explanation. Do not create separate + line-by-line explanation tables or a Status column. +- Align corresponding function starts where possible. Insert missing-line + placeholders to keep later functions aligned; preserve source order and + original numbers. For example, macOS renderEffect line 12 aligns with iOS + line 16 at revision f0972f0d5ba796e3fa417081f43c00a9654b2aa6. +- Within each function or intervening block, align lines sequentially unless + better semantic alignment is needed. Equal line numbers need not share a row + when function alignment requires padding. +- Compare the exact source text in each aligned row, including whitespace. + Fill BOTH line-number backgrounds green when they match. Fill numbers orange + when they differ. A missing line is an orange-filled dash, not a plain dash. + Keep code backgrounds neutral and retain syntax highlighting. +- Include two filled statistics boxes beneath each section heading: green for + matching line count and percentage, orange for mismatched count and percentage. + Show the total line count as plain text alongside them. +- Count actual lines across BOTH files, including blank lines. A matching pair + contributes two matching lines; a differing pair contributes two mismatches; + a platform-only line contributes one mismatch. Missing placeholders do not + count. Percentages use the combined actual-line total. Recalculate after any + alignment change, and explain this counting convention in the document. + +## Explanations + +- Explain each distinct point once across the document, at its first relevant + occurrence. Leave later cells empty unless they add information. +- Eliminate semantic repetition, not just identical sentences. Do not repeat + platform/import boilerplate such as “UIKit serves iOS” for every import. +- Explain shared behavior once. Label iOS/macOS details only when needed to + distinguish behavior. Explain the reason or consequence of platform differences. +- Avoid redundant function summaries when the individual operations already + explain the same behavior. Leave blank lines and closing braces unexplained. +- When realigning rows, anchor each platform-specific explanation to its own + source line rather than to the old visual row. + +## Presentation and verification + +- Inline all CSS and syntax highlighting; no external fonts, scripts or requests. +- Use `
`, `white-space: pre-wrap`, and `overflow-wrap: anywhere`.
+  Give the code columns equal width; ensure long lines remain readable without
+  horizontal scrolling. Do not use striped row shading.
+- Verify every source line and number against the named Git revision, in order,
+  with no omissions or duplicates. Check function anchors, placeholder fills,
+  both matching-number fills, statistics, and explanation attachment.
+- Review explanations for repeated clauses as well as repeated sentences.
+- Inspect the rendered HTML for layout problems. Return a clickable file link;
+  tell the user to refresh an already open document after updates.
-- 
2.53.0


From 5e5537aee6c4732921626eac984351c94d3c983f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB=20=D0=9A=D0=B0=D0=BF?=
 =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BA=D0=BE?= 
Date: Fri, 30 Oct 2026 16:56:50 +0300
Subject: [PATCH 53/55] unify

---
 components/render/ios/renderEffect.swift      |  8 +++----
 components/render/ios/view/RenderGLView.swift |  5 ++++-
 components/render/mac/renderEffect.swift      |  2 +-
 components/render/mac/view/RenderGLView.swift | 22 +++++++++----------
 components/render/mac/view/RenderView.swift   |  1 -
 5 files changed, 20 insertions(+), 18 deletions(-)

diff --git a/components/render/ios/renderEffect.swift b/components/render/ios/renderEffect.swift
index 247f967..71c31df 100644
--- a/components/render/ios/renderEffect.swift
+++ b/components/render/ios/renderEffect.swift
@@ -5,8 +5,9 @@ import UIKit
 func renderDeinit(_ vm: RenderVM) {
     vm.timer?.invalidate()
     vm.timer = nil
-    guard eglMakeCurrentContext(&vm.glView.st) else { return }
+    eglMakeCurrentContext(&vm.glView.st)
     raybriShutdown()
+
     eglMakeCurrent(vm.glView.st.display, nil, nil, nil)
     eglDestroySurface(vm.glView.st.display, vm.glView.st.surface)
     eglDestroyContext(vm.glView.st.display, vm.glView.st.ctx)
@@ -14,8 +15,7 @@ func renderDeinit(_ vm: RenderVM) {
 }
 
 func renderInit(_ vm: RenderVM) {
-    // UIKit has no NSOpenGLContext: EGL/ANGLE renders into the view's layer,
-    // so the layer is what the bridge needs to create its surface from.
+    // On iOS EGL/ANGLE renders into the UIView's layer
     let layer = Unmanaged.passUnretained(vm.glView.layer).toOpaque()
     vm.glView.st.caLayer = layer
 
@@ -32,7 +32,7 @@ func renderStartTimer(_ vm: RenderVM) {
 
     // The frame is presented by eglSwapBuffers into the view's layer, not by
     // CoreGraphics, so the timer drives the rendering itself instead of
-    // invalidating the view for a draw(_:) pass the way macOS does.
+    // invalidating the view for a draw(_:) pass the way macOS does
     let timer = Timer(timeInterval: 1.0 / RENDER_FPS, repeats: true) { [weak vm] _ in
         guard let vm else { return }
         renderDraw(vm)
diff --git a/components/render/ios/view/RenderGLView.swift b/components/render/ios/view/RenderGLView.swift
index d054063..3c99009 100644
--- a/components/render/ios/view/RenderGLView.swift
+++ b/components/render/ios/view/RenderGLView.swift
@@ -5,7 +5,6 @@ final class RenderGLView: UIView {
 
     override init(frame: CGRect) {
         super.init(frame: frame)
-
         isOpaque = true
         isUserInteractionEnabled = false
     }
@@ -14,6 +13,10 @@ final class RenderGLView: UIView {
         fatalError("init(coder:) has not been implemented")
     }
 
+    deinit {
+        renderSet(F.willDeinit, true)
+    }
+
     override func didMoveToWindow() {
         super.didMoveToWindow()
         guard let window else { return }
diff --git a/components/render/mac/renderEffect.swift b/components/render/mac/renderEffect.swift
index b246dcf..3b270f7 100644
--- a/components/render/mac/renderEffect.swift
+++ b/components/render/mac/renderEffect.swift
@@ -3,8 +3,8 @@ import RaylibBridge
 import QuartzCore
 
 func renderDeinit(_ vm: RenderVM) {
-    print("ИГР renderD")
     vm.timer?.invalidate()
+    vm.timer = nil
     vm.glView.openGLContext?.makeCurrentContext()
     raybriShutdown()
 }
diff --git a/components/render/mac/view/RenderGLView.swift b/components/render/mac/view/RenderGLView.swift
index 04acce2..ef1c690 100644
--- a/components/render/mac/view/RenderGLView.swift
+++ b/components/render/mac/view/RenderGLView.swift
@@ -15,6 +15,17 @@ final class RenderGLView: NSOpenGLView {
         fatalError("init(coder:) has not been implemented")
     }
 
+    deinit {
+        renderSet(F.willDeinit, true)
+    }
+
+    override func draw(_ dirtyRect: NSRect) {
+        let vm = RenderVM.shared!
+        if vm.didPrepareGL {
+            renderDraw(vm)
+        }
+    }
+
     override func prepareOpenGL() {
         super.prepareOpenGL()
         renderSet(F.didPrepareMacGL, true)
@@ -33,15 +44,4 @@ final class RenderGLView: NSOpenGLView {
         let ps = renderPixelSize(self)
         renderSet(F.backingPixelSize, ps)
     }
-
-    override func draw(_ dirtyRect: NSRect) {
-        let vm = RenderVM.shared!
-        if vm.didPrepareGL {
-            renderDraw(vm)
-        }
-    }
-
-    deinit {
-        renderSet(F.willDeinit, true)
-    }
 }
diff --git a/components/render/mac/view/RenderView.swift b/components/render/mac/view/RenderView.swift
index 42a503f..bd154e9 100644
--- a/components/render/mac/view/RenderView.swift
+++ b/components/render/mac/view/RenderView.swift
@@ -1,7 +1,6 @@
 import AppKit
 import SwiftUI
 
-/// Render view for SwiftUI
 struct RenderView: NSViewRepresentable {
     func makeNSView(context: Context) -> RenderGLView {
         RenderVM.shared!.glView
-- 
2.53.0


From 3bcfc32ef17d36f16381be4c407a609df8063eb8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB=20=D0=9A=D0=B0=D0=BF?=
 =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BA=D0=BE?= 
Date: Fri, 30 Oct 2026 17:05:46 +0300
Subject: [PATCH 54/55] move extensions loading to Aux

---
 components/raybri/mac/raybriAux.h        | 6 ++++++
 components/render/mac/renderEffect.swift | 4 +---
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/components/raybri/mac/raybriAux.h b/components/raybri/mac/raybriAux.h
index fd9630c..be688ce 100644
--- a/components/raybri/mac/raybriAux.h
+++ b/components/raybri/mac/raybriAux.h
@@ -4,6 +4,7 @@
 // Header
 
 void *raybriGLLoader(const char *name);
+void raybriLoadExtensions(void);
 
 // Source
 
@@ -11,6 +12,7 @@ void *raybriGLLoader(const char *name);
 
 #include 
 #include "raybriConst.h"
+#include "rlgl.h"
 #include 
 
 // raylib is built as a static/dynamic library with GLFW baked in, but we never
@@ -30,6 +32,10 @@ void *raybriGLLoader(const char *name) {
     return dlsym(handle, name);
 }
 
+void raybriLoadExtensions(void) {
+    rlLoadExtensions(raybriGLLoader);
+}
+
 #endif // RAYBRI_AUX_IMPLEMENTATION
 
 #endif // RAYBRI_AUX_H
diff --git a/components/render/mac/renderEffect.swift b/components/render/mac/renderEffect.swift
index 3b270f7..899b378 100644
--- a/components/render/mac/renderEffect.swift
+++ b/components/render/mac/renderEffect.swift
@@ -16,9 +16,7 @@ func renderInit(_ vm: RenderVM) {
     var swapInterval: Int32 = 1
     vm.glView.openGLContext?.setValues(&swapInterval, for: .swapInterval)
 
-    // Load OpenGL extensions
-    rlLoadExtensions(unsafeBitCast(raybriGLLoader as @convention(c) (UnsafePointer?) -> UnsafeMutableRawPointer?, to: UnsafeMutableRawPointer.self))
-
+    raybriLoadExtensions()
     raybriInit()
 }
 
-- 
2.53.0


From 325499d40442863625b623a0d5d1848ce28d79d4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB=20=D0=9A=D0=B0=D0=BF?=
 =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BA=D0=BE?= 
Date: Fri, 30 Oct 2026 17:15:51 +0300
Subject: [PATCH 55/55] rm blue h

---
 ogs-blue/ver-mac/src/raybri/Blue.h | 8 --------
 1 file changed, 8 deletions(-)
 delete mode 100644 ogs-blue/ver-mac/src/raybri/Blue.h

diff --git a/ogs-blue/ver-mac/src/raybri/Blue.h b/ogs-blue/ver-mac/src/raybri/Blue.h
deleted file mode 100644
index 8508c9c..0000000
--- a/ogs-blue/ver-mac/src/raybri/Blue.h
+++ /dev/null
@@ -1,8 +0,0 @@
-#ifndef BLUE_H
-#define BLUE_H
-
-#include "raybri.h"
-#include "raybriAux.h"
-#include "rlgl.h"
-
-#endif // BLUE_H
-- 
2.53.0