12 Commits
Author SHA1 Message Date
Михаил Капелько 56d4b2dd88 single bg color 2026-10-23 15:27:28 +03:00
Михаил Капелько e0f54dde75 some 2026-10-23 06:57:04 +03:00
Михаил Капелько 4b70bd9906 c mm 2026-10-23 06:51:25 +03:00
Михаил Капелько 33fae994fc mov 2026-10-23 06:45:53 +03:00
Михаил Капелько 197d93ee7b reuse renderVM 2026-10-23 06:29:11 +03:00
Михаил Капелько 81bfac20f9 clarify 2026-10-23 06:26:40 +03:00
Михаил Капелько 27b7679bf8 mv 2026-10-23 06:25:13 +03:00
Михаил Капелько fa1cd053c8 try my way 2026-10-22 18:33:09 +03:00
Михаил Капелько 6fecc1e95e пусто 2026-10-22 17:32:19 +03:00
Михаил Капелько 7a0a09c2a1 prep 2026-10-22 06:43:31 +03:00
Михаил Капелько 3ae9275dd4 make chkgfx ios stub 2026-10-22 06:39:47 +03:00
Михаил Капелько b00aac5042 пусто 2026-10-22 06:24:11 +03:00
36 changed files with 586 additions and 214 deletions

No files matched your search

+1
View File
@@ -9,3 +9,4 @@ gradle-daemon-jvm.properties
local.properties local.properties
Package.resolved Package.resolved
*.xcodeproj *.xcodeproj
Frameworks
+2 -2
View File
@@ -63,7 +63,7 @@ game/ver-mac/ macOS app (SPM executable target "ogs-mahjong")
raybri/raybri.c -> symlink components/raybri/raybri.c raybri/raybri.c -> symlink components/raybri/raybri.c
raybri/raybri.h -> symlink components/raybri/raybri.h raybri/raybri.h -> symlink components/raybri/raybri.h
render/render.swift -> symlink components/render/render.swift render/render.swift -> symlink components/render/render.swift
render/renderAux.swift -> symlink components/render/renderAux.swift render/renderAux.swift -> symlink components/render/mac/renderAux.swift
render/renderConst.swift -> symlink components/render/renderConst.swift render/renderConst.swift -> symlink components/render/renderConst.swift
render/renderConstShader.swift -> symlink .../renderConstShader.swift render/renderConstShader.swift -> symlink .../renderConstShader.swift
render/renderEffect.swift -> symlink components/render/renderEffect.swift render/renderEffect.swift -> symlink components/render/renderEffect.swift
@@ -99,7 +99,7 @@ src/other/other.swift -> ../../../../components/other/other.swift (
src/raybri/raybri.c -> ../../../../components/raybri/raybri.c (4 up) src/raybri/raybri.c -> ../../../../components/raybri/raybri.c (4 up)
src/raybri/raybri.h -> ../../../../components/raybri/raybri.h (4 up) src/raybri/raybri.h -> ../../../../components/raybri/raybri.h (4 up)
src/render/render.swift -> ../../../../components/render/render.swift (4 up) src/render/render.swift -> ../../../../components/render/render.swift (4 up)
src/render/renderAux.swift -> ../../../../components/render/renderAux.swift (4 up) src/render/renderAux.swift -> ../../../../components/render/mac/renderAux.swift (4 up)
src/render/renderConst.swift-> ../../../../components/render/renderConst.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/renderConstShader.swift -> ../../../../components/render/renderConstShader.swift (4 up)
src/render/renderEffect.swift -> ../../../../components/render/renderEffect.swift (4 up) src/render/renderEffect.swift -> ../../../../components/render/renderEffect.swift (4 up)
+4
View File
@@ -3,3 +3,7 @@
* macOS * macOS
`brew install raylib` `brew install raylib`
* iOS
`brew install xcodegen`
+1
View File
@@ -0,0 +1 @@
../../mac/view/ChkgfxView.swift
@@ -0,0 +1,6 @@
#ifndef OGS_MAHJONG_RAYLIB_IOS_BRIDGING_HEADER_H
#define OGS_MAHJONG_RAYLIB_IOS_BRIDGING_HEADER_H
#include "../raybri.h"
#endif
+207
View File
@@ -0,0 +1,207 @@
// iOS counterpart of raybri.c.
//
// The prebuilt ghera/raylib-iOS xcframework is callback-driven: its rcore_ios.c
// defines main(), AppDelegate, SceneDelegate and GameViewController, so linking
// it would hand the whole app to raylib (and clash with SwiftUI's own main()).
// Instead this bridge compiles raylib's renderer (rlgl) directly and owns only
// the GL side. The view and the frame timer stay in ver-ios, exactly like the
// macOS build where RenderVM drives the NSOpenGLView.
//
// GL runs on ANGLE (libEGL + libGLESv2, Metal backend), taken from the same
// ghera release as raylib's headers.
#include "../raybri.h"
#include <stdio.h>
#include <libEGL/libEGL.h>
// rlgl's iOS branch includes <libGLESv2/GLES/glext.h> before gl2/gl3, so the
// GL_API/GL_APIENTRY macros have to come from glplatform.h first. ghera's
// build script does this with -include; we do it explicitly.
#include <libGLESv2/GLES/gl.h>
#define RLGL_IMPLEMENTATION
#include <rlgl.h>
static EGLDisplay sr_display = EGL_NO_DISPLAY;
static EGLSurface sr_surface = EGL_NO_SURFACE;
static EGLContext sr_context = EGL_NO_CONTEXT;
static EGLConfig sr_config = NULL;
static void *sr_layer = NULL;
static int sr_ready = 0;
static int sr_width = 1;
static int sr_height = 1;
static void sr_log(const char *text)
{
fprintf(stderr, "RBIOS: %s\n", text);
fflush(stderr);
}
// (Re)create the EGL window surface on the layer handed to us by UIKit.
static int sr_create_surface(void)
{
if (sr_surface != EGL_NO_SURFACE)
{
eglDestroySurface(sr_display, sr_surface);
sr_surface = EGL_NO_SURFACE;
}
// ANGLE on iOS takes a CALayer as the native window.
sr_surface = eglCreateWindowSurface(sr_display, sr_config, (EGLNativeWindowType)sr_layer, NULL);
if (sr_surface == EGL_NO_SURFACE)
{
sr_log("failed to create EGL window surface");
return 0;
}
if (eglMakeCurrent(sr_display, sr_surface, sr_surface, sr_context) == EGL_FALSE)
{
sr_log("failed to make the EGL context current");
return 0;
}
rlViewport(0, 0, sr_width, sr_height);
rlSetFramebufferWidth(sr_width);
rlSetFramebufferHeight(sr_height);
return 1;
}
int raybri_init(void *layer, int width, int height)
{
if (sr_ready) return 1;
if (layer == NULL)
{
sr_log("no drawable layer");
return 0;
}
sr_layer = layer;
sr_width = (width > 0) ? width : 1;
sr_height = (height > 0) ? height : 1;
sr_display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
if (sr_display == EGL_NO_DISPLAY)
{
sr_log("failed to get the EGL display");
return 0;
}
if (eglInitialize(sr_display, NULL, NULL) == EGL_FALSE)
{
sr_log("failed to initialize EGL");
return 0;
}
if (eglBindAPI(EGL_OPENGL_ES_API) == EGL_FALSE)
{
sr_log("failed to bind the OpenGL ES API");
return 0;
}
const EGLint config_attribs[] = {
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
};
EGLint config_count = 0;
if (eglChooseConfig(sr_display, config_attribs, &sr_config, 1, &config_count) == EGL_FALSE || config_count < 1)
{
sr_log("failed to choose an EGL config");
return 0;
}
const EGLint context_attribs[] = {
EGL_CONTEXT_CLIENT_VERSION, 3,
EGL_NONE
};
sr_context = eglCreateContext(sr_display, sr_config, EGL_NO_CONTEXT, context_attribs);
if (sr_context == EGL_NO_CONTEXT)
{
sr_log("failed to create an EGL context");
return 0;
}
if (!sr_create_surface()) return 0;
// With GL_GLEXT_PROTOTYPES rlgl calls the ANGLE entry points directly, but
// the call keeps parity with the platform backends and is harmless.
rlLoadExtensions((void *)eglGetProcAddress);
rlglInit(sr_width, sr_height);
sr_log("EGL/ANGLE + rlgl initialized");
sr_ready = 1;
return 1;
}
void raybri_resize(int width, int height)
{
if (!sr_ready) return;
if (width <= 0 || height <= 0) return;
if (width == sr_width && height == sr_height) return;
sr_width = width;
sr_height = height;
if (!sr_create_surface()) return;
sr_log("surface recreated");
}
void raybri_render(void)
{
if (!sr_ready) return;
if (eglMakeCurrent(sr_display, sr_surface, sr_surface, sr_context) == EGL_FALSE) return;
rlClearColor(0, 0, 255, 255);
rlClearScreenBuffers();
eglSwapBuffers(sr_display, sr_surface);
}
void raybri_shutdown(void)
{
if (!sr_ready) return;
eglMakeCurrent(sr_display, sr_surface, sr_surface, sr_context);
rlglClose();
eglMakeCurrent(sr_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
if (sr_surface != EGL_NO_SURFACE)
{
eglDestroySurface(sr_display, sr_surface);
sr_surface = EGL_NO_SURFACE;
}
if (sr_context != EGL_NO_CONTEXT)
{
eglDestroyContext(sr_display, sr_context);
sr_context = EGL_NO_CONTEXT;
}
if (sr_display != EGL_NO_DISPLAY)
{
eglTerminate(sr_display);
sr_display = EGL_NO_DISPLAY;
}
sr_layer = NULL;
sr_ready = 0;
sr_log("shutdown");
}
+27 -8
View File
@@ -1,6 +1,8 @@
#ifndef OGS_MAHJONG_RAYLIB_BRIDGE_H #ifndef OGS_MAHJONG_RAYLIB_BRIDGE_H
#define OGS_MAHJONG_RAYLIB_BRIDGE_H #define OGS_MAHJONG_RAYLIB_BRIDGE_H
#include <TargetConditionals.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
@@ -14,6 +16,30 @@ typedef struct raybri_config {
float ground_size; // ground plane extent float ground_size; // ground plane extent
} raybri_config; } raybri_config;
// The bridge always renders into a GL context owned by the app (no raylib
// window), but the platform setup and the current feature set differ:
// macOS renders the textured cube through raybri.c, iOS currently only clears
// its EGL/ANGLE drawable through raybriIOS.c. The common names keep the Swift
// call sites and lifecycle symmetrical.
// Resize the drawable (backing pixels). On macOS this only records the size;
// on iOS it recreates the EGL window surface when it changes.
void raybri_resize(int width, int height);
// Render one frame.
void raybri_render(void);
// Release the GL/EGL resources owned by the bridge.
void raybri_shutdown(void);
#if TARGET_OS_IPHONE
// Initialise EGL (ANGLE) on the given CALayer and bring up rlgl.
// Returns 1 on success, 0 on failure.
int raybri_init(void *layer, int width, int height);
#else
// Initialise the OpenGL-backed raylib scene (no raylib window is created). // Initialise the OpenGL-backed raylib scene (no raylib window is created).
// The four shader sources come from renderConstShader.swift. // The four shader sources come from renderConstShader.swift.
void raybri_init( void raybri_init(
@@ -27,17 +53,10 @@ void raybri_init(
// Load the textured cube glTF model. // Load the textured cube glTF model.
void raybri_load_model(const char *gltf_path); void raybri_load_model(const char *gltf_path);
// Resize the viewport.
void raybri_resize(int width, int height);
// Cube rotation, driven by the application (Euler angles, degrees). // Cube rotation, driven by the application (Euler angles, degrees).
void raybri_set_rotation(float x_deg, float y_deg, float z_deg); void raybri_set_rotation(float x_deg, float y_deg, float z_deg);
// Render one frame. #endif
void raybri_render(void);
// Release all GPU resources.
void raybri_shutdown(void);
#ifdef __cplusplus #ifdef __cplusplus
} }
+1
View File
@@ -0,0 +1 @@
../renderVM.swift
+16
View File
@@ -0,0 +1,16 @@
import UIKit
// Render a single frame. The timer calls this directly: an EGL/ANGLE surface
// presents into the view's layer, so there is no draw(_:) / needsDisplay pass
// like in the NSOpenGLView on macOS.
func renderDraw(_ vm: RenderVM) {
raybri_render()
}
// Backing-pixel size of the view, which is what EGL/ANGLE renders into.
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]
}
+3
View File
@@ -0,0 +1,3 @@
// iOS render constants. The macOS renderConst.swift depends on AppKit and the
// RaylibBridge SPM module, so the two platforms keep separate files.
let RENDER_FPS = 60.0
+32
View File
@@ -0,0 +1,32 @@
import Foundation
import UIKit
// Bring up EGL/ANGLE on the view's layer. Returns false when the surface could
// not be created (the caller then leaves the timer stopped).
func renderInit(_ vm: RenderVM) -> Bool {
let size = renderPixelSize(vm.glView)
let layer = Unmanaged.passUnretained(vm.glView.layer).toOpaque()
let ok = raybri_init(layer, size[0], size[1]) != 0
if !ok {
otherPrintStderr("ИГР renderInit: EGL/ANGLE initialization failed")
}
return ok
}
// Same shape as the macOS timer: a repeating timer on the main run loop, but
// here it calls the renderer directly instead of flagging the view for redraw.
func renderStartTimer(_ vm: RenderVM) {
let timer = Timer(timeInterval: 1.0 / RENDER_FPS, repeats: true) { [weak vm] _ in
guard let vm else { return }
renderDraw(vm)
}
vm.timer = timer
// .common keeps rendering alive while the user holds a control.
RunLoop.main.add(timer, forMode: .common)
}
func renderDeinit(_ vm: RenderVM) {
vm.timer?.invalidate()
vm.timer = nil
raybri_shutdown()
}
@@ -0,0 +1,58 @@
import UIKit
// UIView counterpart of the macOS RenderGLView. UIKit never draws into it: the
// EGL/ANGLE surface renders directly into this view's layer, and the timer in
// RenderVM presents a new frame. The view only reports when it gains a window
// and when its backing size changes.
final class RenderGLView: UIView {
private weak var renderVM: RenderVM?
override init(frame: CGRect) {
super.init(frame: frame)
isOpaque = true
// Touch handling is not wired to raylib yet, so keep the GL view
// transparent to the SwiftUI hierarchy above it.
isUserInteractionEnabled = false
contentScaleFactor = UIScreen.main.scale
layer.contentsScale = contentScaleFactor
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func didMoveToWindow() {
super.didMoveToWindow()
guard let window else { return }
contentScaleFactor = window.screen.nativeScale
layer.contentsScale = contentScaleFactor
guard let vm = RenderVM.shared, !vm.didPrepareGL else { return }
guard renderInit(vm) else { return }
renderVM = vm
vm.didPrepareGL = true
vm.pixelSize = renderPixelSize(self)
renderStartTimer(vm)
}
override func layoutSubviews() {
super.layoutSubviews()
guard let vm = renderVM, vm.didPrepareGL else { return }
let size = renderPixelSize(self)
guard size != vm.pixelSize else { return }
vm.pixelSize = size
raybri_resize(size[0], size[1])
}
deinit {
guard let vm = renderVM, vm.didPrepareGL else { return }
renderDeinit(vm)
}
}
@@ -0,0 +1,9 @@
import SwiftUI
struct RenderView: UIViewRepresentable {
func makeUIView(context: Context) -> RenderGLView {
RenderVM.shared!.glView
}
func updateUIView(_ uiView: RenderGLView, context: Context) {}
}
File renamed without changes.
@@ -1,7 +1,6 @@
import AppKit import AppKit
import SwiftUI import SwiftUI
/// Render view for SwiftUI
struct RenderView: NSViewRepresentable { struct RenderView: NSViewRepresentable {
func makeNSView(context: Context) -> RenderGLView { func makeNSView(context: Context) -> RenderGLView {
RenderVM.shared!.glView RenderVM.shared!.glView
-45
View File
@@ -20,48 +20,3 @@ ChkgfxContext:
fields: fields:
didLaunch: Bool didLaunch: Bool
didSetup: Bool didSetup: Bool
RenderContext:
type: context
fields:
backingPixelSize: [Int32]
didLaunch: Bool
didPrepareGL: Bool
didSetup: Bool
pixelSize: [Int32]
reshapePixelSize: [Int32]
willDeinit: Bool
RenderComponent:
type: component
oneliners:
- didPrepareGL: renderInit(RenderVM.shared!)
- didPrepareGL: RenderVM.shared!.didPrepareGL = true
- didPrepareGL: renderStartTimer(RenderVM.shared!)
- didPrepareGL: renderLoadCubeModel(RenderVM.shared!)
- pixelSize: RenderVM.shared!.pixelSize = c.pixelSize
- willDeinit: renderDeinit(RenderVM.shared!)
shoulds:
didLaunch:
1. Only once during the first setup:
if:
c.recentField == F.didSetup &&
c.didLaunch == false
then:
c.didLaunch = true
pixelSize:
1. Upon launch:
if:
c.recentField == F.didLaunch
then:
c.pixelSize = [1, 1]
2. Upon resize:
if:
c.recentField == F.reshapePixelSize
then:
c.pixelSize = c.reshapePixelSize
3. Upon DPI change:
if:
c.recentField == F.backingPixelSize
then:
c.pixelSize = c.backingPixelSize
Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB

@@ -0,0 +1,14 @@
{
"images" : [
{
"filename" : "AppIcon.png",
"idiom" : "universal",
"platform" : "ios",
"size" : "1024x1024"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
+26
View File
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleName</key>
<string>OGS chkgfx</string>
<key>CFBundleDisplayName</key>
<string>OGS chkgfx</string>
<key>CFBundleIdentifier</key>
<string>org.opengamestudio.chkgfx</string>
<key>CFBundleExecutable</key>
<string>ogs-chkgfx</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>UILaunchScreen</key>
<dict/>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
</array>
</dict>
</plist>
+35
View File
@@ -0,0 +1,35 @@
name: OGS chkgfx
options:
bundleIdPrefix: org.opengamestudio
targets:
ogs-chkgfx:
type: application
platform: iOS
deploymentTarget: "15.6"
sources:
- path: Assets.xcassets
- path: src
- path: ../../components/render/ios
- path: ../../components/raybri/ios
dependencies:
- framework: Frameworks/libEGL.xcframework
embed: true
- framework: Frameworks/libGLESv2.xcframework
embed: true
settings:
base:
INFOPLIST_FILE: Info.plist
PRODUCT_BUNDLE_IDENTIFIER: org.opengamestudio.chkgfx
SWIFT_OBJC_BRIDGING_HEADER: ../../components/raybri/ios/RaybriIOS-Bridging-Header.h
HEADER_SEARCH_PATHS:
- "$(SRCROOT)/../../components/raybri/ios"
- "$(SRCROOT)/../../components/render/ios"
- "$(SRCROOT)/Frameworks/include"
- "$(SRCROOT)/Frameworks/raylib.xcframework/ios-arm64_x86_64-simulator/raylib.framework/Headers"
- "$(SRCROOT)/Frameworks/raylib.xcframework/ios-arm64/raylib.framework/Headers"
GCC_PREPROCESSOR_DEFINITIONS:
- PLATFORM_IOS=1
- GRAPHICS_API_OPENGL_ES3=1
- GL_GLEXT_PROTOTYPES=1
LD_RUNPATH_SEARCH_PATHS:
- "$(inherited) @executable_path/Frameworks"
+20
View File
@@ -0,0 +1,20 @@
import UIKit
final class AppDelegate:
NSObject,
UIApplicationDelegate
{
let chkgfx = ChkgfxComponent()
let chkgfxVM = ChkgfxVM()
let renderVM = RenderVM()
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
) -> Bool {
otherSetupConsoleLogging(chkgfx.ctrl, "Chkgfx")
chkgfx.setup()
return true
}
}
+16
View File
@@ -0,0 +1,16 @@
import SwiftUI
@main
struct ChkgfxApp: App {
@UIApplicationDelegateAdaptor(AppDelegate.self) private var appDelegate
var body: some Scene {
WindowGroup {
ZStack {
RenderView()
.ignoresSafeArea()
ChkgfxView(appDelegate.chkgfxVM)
}
}
}
}
+1
View File
@@ -0,0 +1 @@
../../../../components/chkgfx/chkgfx.swift
+1
View File
@@ -0,0 +1 @@
../../../../components/chkgfx/chkgfxVM.swift
+1
View File
@@ -0,0 +1 @@
../../../../../components/chkgfx/ios/view/ChkgfxView.swift
+1
View File
@@ -0,0 +1 @@
../../ver-mac/src/dialect.swift
+1
View File
@@ -0,0 +1 @@
../../../../components/other/other.swift
-1
View File
@@ -1,4 +1,3 @@
import AppKit
import SwiftUI import SwiftUI
@main @main
-153
View File
@@ -119,13 +119,8 @@ func registerOneliners<T>(
// Context field names for static type check // Context field names for static type check
public struct F { public struct F {
public static let backingPixelSize = "backingPixelSize"
public static let didLaunch = "didLaunch" public static let didLaunch = "didLaunch"
public static let didPrepareGL = "didPrepareGL"
public static let didSetup = "didSetup" public static let didSetup = "didSetup"
public static let pixelSize = "pixelSize"
public static let reshapePixelSize = "reshapePixelSize"
public static let willDeinit = "willDeinit"
} }
public struct ChkgfxContext: DialectContext { public struct ChkgfxContext: DialectContext {
@@ -159,72 +154,6 @@ public struct ChkgfxContext: DialectContext {
} }
} }
public struct RenderContext: DialectContext {
public var backingPixelSize = [Int32]()
public var didLaunch = Bool()
public var didPrepareGL = Bool()
public var didSetup = Bool()
public var pixelSize = [Int32]()
public var reshapePixelSize = [Int32]()
public var willDeinit = Bool()
public var recentField = ""
public func field<T>(_ name: String) -> T {
if (name == "backingPixelSize") {
return backingPixelSize as! T
}
else if (name == "didLaunch") {
return didLaunch as! T
}
else if (name == "didPrepareGL") {
return didPrepareGL as! T
}
else if (name == "didSetup") {
return didSetup as! T
}
else if (name == "pixelSize") {
return pixelSize as! T
}
else if (name == "reshapePixelSize") {
return reshapePixelSize as! T
}
else if (name == "willDeinit") {
return willDeinit as! T
}
return "unknown-field-name" as! T
}
public mutating func setField(
_ name: String,
_ value: Any
) {
if (name == "backingPixelSize") {
backingPixelSize = value as! [Int32]
}
else if (name == "didLaunch") {
didLaunch = value as! Bool
}
else if (name == "didPrepareGL") {
didPrepareGL = value as! Bool
}
else if (name == "didSetup") {
didSetup = value as! Bool
}
else if (name == "pixelSize") {
pixelSize = value as! [Int32]
}
else if (name == "reshapePixelSize") {
reshapePixelSize = value as! [Int32]
}
else if (name == "willDeinit") {
willDeinit = value as! Bool
}
}
}
public func chkgfxSet( public func chkgfxSet(
_ key: String, _ key: String,
_ value: Any _ value: Any
@@ -232,13 +161,6 @@ public func chkgfxSet(
ChkgfxComponent.singleton!.ctrl.set(key, value) ChkgfxComponent.singleton!.ctrl.set(key, value)
} }
public func renderSet(
_ key: String,
_ value: Any
) {
RenderComponent.singleton!.ctrl.set(key, value)
}
func chkgfxShouldResetDidLaunch(_ c: ChkgfxContext) -> ChkgfxContext { func chkgfxShouldResetDidLaunch(_ c: ChkgfxContext) -> ChkgfxContext {
var c = c var c = c
@@ -257,59 +179,6 @@ func chkgfxShouldResetDidLaunch(_ c: ChkgfxContext) -> ChkgfxContext {
return c return c
} }
func renderShouldResetDidLaunch(_ c: RenderContext) -> RenderContext {
var c = c
/* 1. Only once during the first setup */
if
c.recentField == F.didSetup &&
c.didLaunch == false
{
c.didLaunch = true
c.recentField = F.didLaunch
return c
}
c.recentField = DIALECT_CONTEXT_RECENT_FIELD_NONE
return c
}
func renderShouldResetPixelSize(_ c: RenderContext) -> RenderContext {
var c = c
/* 1. Upon launch */
if
c.recentField == F.didLaunch
{
c.pixelSize = [1, 1]
c.recentField = F.pixelSize
return c
}
/* 2. Upon resize */
if
c.recentField == F.reshapePixelSize
{
c.pixelSize = c.reshapePixelSize
c.recentField = F.pixelSize
return c
}
/* 3. Upon DPI change */
if
c.recentField == F.backingPixelSize
{
c.pixelSize = c.backingPixelSize
c.recentField = F.pixelSize
return c
}
c.recentField = DIALECT_CONTEXT_RECENT_FIELD_NONE
return c
}
func chkgfxRegisterShoulds(_ ctrl: DialectController) { func chkgfxRegisterShoulds(_ ctrl: DialectController) {
[ [
chkgfxShouldResetDidLaunch, chkgfxShouldResetDidLaunch,
@@ -318,25 +187,3 @@ func chkgfxRegisterShoulds(_ ctrl: DialectController) {
ctrl.registerFunction { c in f(c as! ChkgfxContext) } ctrl.registerFunction { c in f(c as! ChkgfxContext) }
} }
} }
func renderRegisterShoulds(_ ctrl: DialectController) {
[
renderShouldResetDidLaunch,
renderShouldResetPixelSize,
].forEach { f in
ctrl.registerFunction { c in f(c as! RenderContext) }
}
}
func renderRegisterEffects(_ ctrl: DialectController) {
let _: RenderContext? = registerOneliners(ctrl, [
F.didPrepareGL, { (c: RenderContext) in renderInit(RenderVM.shared!) },
F.didPrepareGL, { (c: RenderContext) in RenderVM.shared!.didPrepareGL = true },
F.didPrepareGL, { (c: RenderContext) in renderStartTimer(RenderVM.shared!) },
F.didPrepareGL, { (c: RenderContext) in renderLoadCubeModel(RenderVM.shared!) },
F.pixelSize, { (c: RenderContext) in RenderVM.shared!.pixelSize = c.pixelSize },
F.willDeinit, { (c: RenderContext) in renderDeinit(RenderVM.shared!) },
])
}
@@ -1 +1 @@
../../../../components/render/renderAux.swift ../../../../components/render/mac/renderAux.swift
@@ -1,8 +1,7 @@
import AppKit
import SwiftUI import SwiftUI
@main @main
struct GameApp: App { struct MahjongApp: App {
@NSApplicationDelegateAdaptor(AppDelegate.self) private var appDelegate @NSApplicationDelegateAdaptor(AppDelegate.self) private var appDelegate
var body: some Scene { var body: some Scene {
@@ -1 +1 @@
../../../../components/render/renderAux.swift ../../../../components/render/mac/renderAux.swift
+14
View File
@@ -0,0 +1,14 @@
#!/bin/bash -e
SDIR=$(cd "$(dirname "$0")" ; pwd -P)
T=$SDIR/step
source $SDIR/paths
TARGET=ogs-chkgfx
STEP=0
source $T/generateDialect $TARGET
source $T/prepareIOS $TARGET
cd $SDIR/../$TARGET/ver-ios
xcodebuild -scheme "ogs-chkgfx" -sdk iphonesimulator -destination 'generic/platform=iOS Simulator' -derivedDataPath .build build
+11
View File
@@ -0,0 +1,11 @@
#!/bin/bash -e
SDIR=$(cd "$(dirname "$0")" ; pwd -P)
T=$SDIR/step
source $SDIR/paths
TARGET=ogs-chkgfx
STEP=0
source $T/generateDialect $TARGET
source $T/prepareIOS $TARGET
+26
View File
@@ -0,0 +1,26 @@
#!/bin/bash -e
SDIR=$(cd "$(dirname "$0")" ; pwd -P)
T=$SDIR/step
source $SDIR/paths
TARGET=ogs-chkgfx
BUNDLE_ID=org.opengamestudio.chkgfx
APP="$SDIR/../$TARGET/ver-ios/.build/Build/Products/Debug-iphonesimulator/ogs-chkgfx.app"
if [[ ! -d "$APP" ]]; then
echo "iOS app not built yet, run util/build-ogs-chkgfx-ios"
exit 1
fi
DEVICE=${DEVICE:-"iPhone 15 Pro"}
UDID=$(xcrun simctl list devices available | grep -m1 "$DEVICE (" | sed -E 's/.*\(([0-9A-F-]{36})\).*/\1/')
if [[ -z "$UDID" ]]; then
echo "Simulator '$DEVICE' not found"
exit 1
fi
xcrun simctl boot "$UDID" 2>/dev/null || true
sleep 2
xcrun simctl install "$UDID" "$APP"
xcrun simctl launch "$UDID" "$BUNDLE_ID"
+49
View File
@@ -0,0 +1,49 @@
#!/bin/bash -e
TARGET=$1
STEP=$((STEP+1))
echo -e "\n> > > > Step №$STEP. Generate iOS project for '$TARGET'"
# iOS rendering goes through ghera/raylib-iOS: a raylib fork that renders
# OpenGL ES via ANGLE (Metal backend). Its stable releases ship prebuilt
# xcframeworks (raylib + libEGL + libGLESv2, ~46 MB), so they are downloaded
# on demand and never committed.
#
# Unlike the fork's own app, ver-ios does not link raylib.xcframework (its
# rcore.o defines main() and a private view controller). We only use its
# headers: raylib's renderer (rlgl) is compiled into components/raybri/ios,
# and EGL/ANGLE provides the GL context.
RAYLIB_IOS_TAG=6.0.7-iOS
FRAMEWORKS=$SDIR/../$TARGET/ver-ios/Frameworks
MISSING=0
for FRAMEWORK in raylib libEGL libGLESv2; do
[[ -d "$FRAMEWORKS/$FRAMEWORK.xcframework" ]] || MISSING=1
done
if [[ $MISSING -eq 1 ]]; then
echo "Raylib iOS xcframeworks missing, downloading $RAYLIB_IOS_TAG..."
mkdir -p "$FRAMEWORKS"
TMP=$(mktemp -d)
curl -sL --retry 3 -o "$TMP/raylib-ios.zip" \
"https://github.com/ghera/raylib-iOS/releases/download/$RAYLIB_IOS_TAG/raylib-ios-xcframeworks-$RAYLIB_IOS_TAG.zip"
unzip -q "$TMP/raylib-ios.zip" -d "$TMP"
cp -R "$TMP/raylib-ios-xcframeworks/raylib.xcframework" "$FRAMEWORKS/"
cp -R "$TMP/raylib-ios-xcframeworks/libEGL.xcframework" "$FRAMEWORKS/"
cp -R "$TMP/raylib-ios-xcframeworks/libGLESv2.xcframework" "$FRAMEWORKS/"
rm -rf "$TMP"
fi
# The ANGLE headers are shipped as framework Headers directories but their
# internal includes expect the `libEGL/...` and `libGLESv2/...` layout, so
# stage symlinks for the header search path. The headers are identical for
# device and simulator, so one slice is enough.
mkdir -p "$FRAMEWORKS/include"
ln -sfn "../libEGL.xcframework/ios-arm64_x86_64-simulator/libEGL.framework/Headers" \
"$FRAMEWORKS/include/libEGL"
ln -sfn "../libGLESv2.xcframework/ios-arm64_x86_64-simulator/libGLESv2.framework/Headers" \
"$FRAMEWORKS/include/libGLESv2"
cd $SDIR/../$TARGET/ver-ios
xcodegen