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] 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)