Support iOS for ogs-blue (#7)
This commit was merged in pull request #7.
This commit is contained in:
1 parent
37c4e6f442
commit
2b556a4a58
58 files changed
+710
-300
No files matched your search
@@ -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([
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
#define RAYBRI_CONST_IMPLEMENTATION
|
||||
#include "raybriConst.h"
|
||||
|
||||
#define RAYBRI_AUX_IMPLEMENTATION
|
||||
#include "raybriAux.h"
|
||||
|
||||
#define RAYBRI_IMPLEMENTATION
|
||||
#include "raybri.h"
|
||||
@@ -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 +0,0 @@
|
||||
../../../../components/raybri/raybri.c
|
||||
@@ -1 +0,0 @@
|
||||
../../../../components/raybri/raybriAux.c
|
||||
@@ -1 +1 @@
|
||||
../../../../components/raybri/raybriAux.h
|
||||
../../../../components/raybri/mac/raybriAux.h
|
||||
@@ -1 +0,0 @@
|
||||
../../../../components/raybri/raybriConst.c
|
||||
@@ -1 +1 @@
|
||||
../../../../components/render/renderAux.swift
|
||||
../../../../components/render/mac/renderAux.swift
|
||||
@@ -0,0 +1 @@
|
||||
../../../../components/render/mac/renderConstMac.swift
|
||||
@@ -1 +1 @@
|
||||
../../../../components/render/renderEffect.swift
|
||||
../../../../components/render/mac/renderEffect.swift
|
||||
Reference in new issue
Block a user