Support iOS for ogs-blue (#7)

This commit was merged in pull request #7.
This commit is contained in:
kornerr committed 2026-10-30 15:17:24 +01:00
1 parent 37c4e6f442
commit 2b556a4a58
58 files changed
+710 -300

No files matched your search

+28 -6
View File
@@ -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,22 +21,19 @@ 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]
willDeinit: Bool
willRecreateSurface: Bool
RenderComponent:
type: component
@@ -40,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:
@@ -48,6 +52,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:
@@ -64,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
+2
View File
@@ -20,6 +20,8 @@
<dict/>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
<string>UIInterfaceOrientationPortrait</string>
</array>
</dict>
+19 -3
View File
@@ -3,13 +3,29 @@ 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:
- 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"
- "$(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
SWIFT_OBJC_BRIDGING_HEADER: src/BlueBridgingHeader.h
type: application
+4
View File
@@ -6,6 +6,8 @@ final class AppDelegate:
{
let blue = BlueComponent()
let blueVM = BlueVM()
let render = RenderComponent()
let renderVM = RenderVM()
func application(
_ application: UIApplication,
@@ -13,6 +15,8 @@ final class AppDelegate:
) -> Bool {
otherSetupConsoleLogging(blue.ctrl, "Blue")
blue.setup()
otherSetupConsoleLogging(render.ctrl, "Render")
render.setup()
return true
}
+15
View File
@@ -0,0 +1,15 @@
#define EGL_CONST_IMPLEMENTATION
#include "eglConst.h"
#define EGL_IMPLEMENTATION
#include "egl.h"
#define RAYBRI_CONST_IMPLEMENTATION
#include "raybriConst.h"
#define RAYBRI_IMPLEMENTATION
#include "raybri.h"
#define RLGL_IMPLEMENTATION
#include "rlgl.h"
+5 -1
View File
@@ -6,7 +6,11 @@ struct BlueApp: App {
var body: some Scene {
WindowGroup {
BlueView(appDelegate.blueVM)
ZStack {
RenderView()
.ignoresSafeArea()
BlueView(appDelegate.blueVM)
}
}
}
}
@@ -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
+1
View File
@@ -0,0 +1 @@
../../../../components/egl/egl.h
+1
View File
@@ -0,0 +1 @@
../../../../components/egl/eglConst.h
+1
View File
@@ -0,0 +1 @@
../../../../components/raybri/raybri.h
+1
View File
@@ -0,0 +1 @@
../../../../components/raybri/raybriConst.h
+1
View File
@@ -0,0 +1 @@
../../../../components/render/ios/renderAux.swift
+1
View File
@@ -0,0 +1 @@
../../../../components/render/renderConst.swift
+1
View File
@@ -0,0 +1 @@
../../../../components/render/ios/renderEffect.swift
@@ -1,4 +0,0 @@
func renderDeinit(_ vm: RenderVM) { }
func renderInit(_ vm: RenderVM) { }
func renderLoadCubeModel(_ vm: RenderVM) { }
func renderStartTimer(_ vm: RenderVM) { }
+1
View File
@@ -0,0 +1 @@
../../../../../components/render/ios/view/RenderView.swift
+6 -4
View File
@@ -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([
+8
View File
@@ -0,0 +1,8 @@
#define RAYBRI_CONST_IMPLEMENTATION
#include "raybriConst.h"
#define RAYBRI_AUX_IMPLEMENTATION
#include "raybriAux.h"
#define RAYBRI_IMPLEMENTATION
#include "raybri.h"
+71
View File
@@ -122,10 +122,13 @@ 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"
public static let willDeinit = "willDeinit"
public static let willRecreateSurface = "willRecreateSurface"
}
public struct BlueContext: DialectContext {
@@ -163,10 +166,13 @@ 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]()
public var willDeinit = Bool()
public var willRecreateSurface = Bool()
public var recentField = ""
@@ -180,6 +186,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
}
@@ -192,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
}
@@ -209,6 +224,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
}
@@ -221,6 +242,9 @@ public struct RenderContext: DialectContext {
else if (name == "willDeinit") {
willDeinit = value as! Bool
}
else if (name == "willRecreateSurface") {
willRecreateSurface = value as! Bool
}
}
}
@@ -275,6 +299,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
@@ -310,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,
@@ -322,7 +390,9 @@ func blueRegisterShoulds(_ ctrl: DialectController) {
func renderRegisterShoulds(_ ctrl: DialectController) {
[
renderShouldResetDidLaunch,
renderShouldResetDidPrepareGL,
renderShouldResetPixelSize,
renderShouldResetWillRecreateSurface,
].forEach { f in
ctrl.registerFunction { c in f(c as! RenderContext) }
@@ -336,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!) },
])
}
-1
View File
@@ -1 +0,0 @@
../../../../components/raybri/raybri.c
-1
View File
@@ -1 +0,0 @@
../../../../components/raybri/raybriAux.c
+1 -1
View File
@@ -1 +1 @@
../../../../components/raybri/raybriAux.h
../../../../components/raybri/mac/raybriAux.h
@@ -1 +0,0 @@
../../../../components/raybri/raybriConst.c
+1 -1
View File
@@ -1 +1 @@
../../../../components/render/renderAux.swift
../../../../components/render/mac/renderAux.swift
+1
View File
@@ -0,0 +1 @@
../../../../components/render/mac/renderConstMac.swift
@@ -1 +1 @@
../../../../components/render/renderEffect.swift
../../../../components/render/mac/renderEffect.swift