From fbea0673c146c5c2ad4ced25127944ea2ae24649 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, 19 Oct 2026 06:35:18 +0300 Subject: [PATCH] rename --- AGENTS.md | 12 ++++++++---- .../mac/view/RenderGLView.swift} | 18 ++---------------- components/render/mac/view/RenderView.swift | 13 +++++++++++++ components/root/mac/view/RootView.swift | 2 +- .../ver-mac/src/render/view/RenderGLView.swift | 1 + game/ver-mac/src/render/view/RenderView.swift | 1 + game/ver-mac/src/root/view/RaylibGLView.swift | 1 - 7 files changed, 26 insertions(+), 22 deletions(-) rename components/{root/mac/view/RaylibGLView.swift => render/mac/view/RenderGLView.swift} (85%) create mode 100644 components/render/mac/view/RenderView.swift create mode 120000 game/ver-mac/src/render/view/RenderGLView.swift create mode 120000 game/ver-mac/src/render/view/RenderView.swift delete mode 120000 game/ver-mac/src/root/view/RaylibGLView.swift diff --git a/AGENTS.md b/AGENTS.md index c387552..2923098 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -44,10 +44,12 @@ game/ver-mac/ macOS app (SPM executable target "ogs-mahjong") AppDelegate.swift Creates RootComponent + RootVM, calls root.setup() dialect.swift GENERATED — do not hand-edit (see chicken-egg below) other/other.swift -> symlink components/other/other.swift + render/renderConstShader.swift -> symlink components/render/renderConstShader.swift + render/view/RenderGLView.swift -> symlink components/render/mac/view/RenderGLView.swift + render/view/RenderView.swift -> symlink components/render/mac/view/RenderView.swift 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/RootView.swift - root/view/RaylibGLView.swift -> symlink components/root/mac/view/RaylibGLView.swift ref/swiftraylib Symlink to ../../swiftraylib — the raylib/SwiftUI renderer sample the game will use for 3D rendering. @@ -71,10 +73,12 @@ directories whose files are **relative symlinks** back into `components/`: ``` src/other/other.swift -> ../../../../components/other/other.swift (4 up) +src/render/renderConstShader.swift -> ../../../../components/render/renderConstShader.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/root/view/RaylibGLView.swift -> ../../../../../components/root/mac/view/RaylibGLView.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) ``` SPM silently **skips** a dangling symlink (no error), so after moving @@ -108,8 +112,8 @@ 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 `RaylibGLView` behind the SwiftUI UI in a -`ZStack`. A textured cube is drawn from `Resources/assets` (`cube.gltf` + +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`); the app rotates it each frame via `sr_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 diff --git a/components/root/mac/view/RaylibGLView.swift b/components/render/mac/view/RenderGLView.swift similarity index 85% rename from components/root/mac/view/RaylibGLView.swift rename to components/render/mac/view/RenderGLView.swift index 7715a6f..3100500 100644 --- a/components/root/mac/view/RaylibGLView.swift +++ b/components/render/mac/view/RenderGLView.swift @@ -1,23 +1,9 @@ -import SwiftUI import AppKit import QuartzCore import RaylibBridge +import SwiftUI -/// A raylib-driven 3D scene (rendered through rlgl into an NSOpenGLView) that -/// sits behind the SwiftUI interface. -struct RaylibGLView: NSViewRepresentable { - func makeNSView(context: Context) -> RaylibGLNSView { - RaylibGLNSView(frame: .zero) - } - - func updateNSView(_ nsView: RaylibGLNSView, context: Context) {} -} - -/// An OpenGL view whose context is rendered directly by raylib's rlgl layer, -/// without letting raylib create its own window. Mirrors the reference sample -/// (`swiftraylib`), but drives a single cube that is rotated by the application -/// every frame. -final class RaylibGLNSView: NSOpenGLView { +final class RenderGLView: NSOpenGLView { private var renderTimer: Timer? private var ready = false private var pixelWidth: Int32 = 1 diff --git a/components/render/mac/view/RenderView.swift b/components/render/mac/view/RenderView.swift new file mode 100644 index 0000000..be60e19 --- /dev/null +++ b/components/render/mac/view/RenderView.swift @@ -0,0 +1,13 @@ +import AppKit +import QuartzCore +import RaylibBridge +import SwiftUI + +/// Render view for SwiftUI +struct RenderView: NSViewRepresentable { + func makeNSView(context: Context) -> RenderGLView { + RenderGLView(frame: .zero) + } + + func updateNSView(_ nsView: RenderGLView, context: Context) {} +} diff --git a/components/root/mac/view/RootView.swift b/components/root/mac/view/RootView.swift index 5234ae8..034e891 100644 --- a/components/root/mac/view/RootView.swift +++ b/components/root/mac/view/RootView.swift @@ -9,7 +9,7 @@ struct RootView: View { var body: some View { ZStack { - RaylibGLView() + RenderView() .ignoresSafeArea() VStack(spacing: 16) { diff --git a/game/ver-mac/src/render/view/RenderGLView.swift b/game/ver-mac/src/render/view/RenderGLView.swift new file mode 120000 index 0000000..7223ae3 --- /dev/null +++ b/game/ver-mac/src/render/view/RenderGLView.swift @@ -0,0 +1 @@ +../../../../../components/render/mac/view/RenderGLView.swift \ No newline at end of file diff --git a/game/ver-mac/src/render/view/RenderView.swift b/game/ver-mac/src/render/view/RenderView.swift new file mode 120000 index 0000000..754ef01 --- /dev/null +++ b/game/ver-mac/src/render/view/RenderView.swift @@ -0,0 +1 @@ +../../../../../components/render/mac/view/RenderView.swift \ No newline at end of file diff --git a/game/ver-mac/src/root/view/RaylibGLView.swift b/game/ver-mac/src/root/view/RaylibGLView.swift deleted file mode 120000 index c750636..0000000 --- a/game/ver-mac/src/root/view/RaylibGLView.swift +++ /dev/null @@ -1 +0,0 @@ -../../../../../components/root/mac/view/RaylibGLView.swift \ No newline at end of file