Compare commits
7
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
96a5684709 | ||
|
|
01594353d8 | ||
|
|
aca30bfe6a | ||
|
|
0af2d75754 | ||
|
|
7a0a09c2a1 | ||
|
|
3ae9275dd4 | ||
|
|
b00aac5042 |
No files matched your search
@@ -9,3 +9,5 @@ gradle-daemon-jvm.properties
|
||||
local.properties
|
||||
Package.resolved
|
||||
*.xcodeproj
|
||||
Frameworks
|
||||
raylib-src
|
||||
@@ -38,7 +38,7 @@ components/ SHARED source-of-truth for all components.
|
||||
pixelSize, startTime, timer)
|
||||
render/renderConst.swift RENDER_CONFIG (raybri_config), RENDER_FPS,
|
||||
RENDER_MODEL_CUBE, RENDER_OPENGL_ATTRS
|
||||
render/renderConstShader.swift RENDER_SHADER_* GLSL sources (GLSL 150)
|
||||
render/renderConstShader.swift Substitutes %VERSION% in the shared templates
|
||||
render/renderAux.swift renderDraw(vm), renderPixelSize(view)
|
||||
render/renderEffect.swift renderInit, renderLoadCubeModel,
|
||||
renderStartTimer, renderDeinit
|
||||
@@ -149,13 +149,20 @@ behind the SwiftUI UI in a `ZStack`. A textured cube is drawn from `Resources/as
|
||||
node-rotation glTF animation cannot be played by the renderer — hence the cube is
|
||||
app-driven.) `packageMac` bundles `Resources/assets/` into the app.
|
||||
|
||||
Shaders and render constants live in **Swift**, not in C: GLSL sources are
|
||||
`RENDER_SHADER_*` in `components/render/renderConstShader.swift`, and
|
||||
`RENDER_CONFIG` / `raybri_config` tunables are in `renderConst.swift`. `raybri_init`
|
||||
compiles the shaders in place (no storage/`strdup`). `cube_normal.png` drives
|
||||
tangentless normal mapping via the derivative-based `cotangentFrame`. The
|
||||
context is OpenGL 3.2 Core (`RENDER_OPENGL_ATTRS`); on Apple Silicon the driver
|
||||
still reports 4.1/GLSL 4.10.
|
||||
Shaders live in **Swift** and are shared by both builds: the GLSL bodies are
|
||||
the `RENDER_SHADER_*_T` templates in
|
||||
`components/render/renderConstShader.swift`, each starting with the `%VERSION%`
|
||||
placeholder. The `RENDER_SHADER_*` sources passed to `raybri_init` are produced
|
||||
by `replacingOccurrences`, choosing `RENDER_SHADER_VERSION_GL` (`#version 150`)
|
||||
or `RENDER_SHADER_VERSION_ES` (`#version 300 es`) via `#if os(iOS)`. The
|
||||
directive must be the first shader token, so it cannot be picked by an `#ifdef`
|
||||
inside the GLSL. Fragment templates also carry `precision highp float;` —
|
||||
required by GLSL ES, accepted and ignored by desktop GLSL. The iOS ObjC++ bridge
|
||||
reaches the strings through `@_cdecl` accessors in `RenderIOS.swift`. `RENDER_CONFIG` / `raybri_config` tunables stay in `renderConst.swift`.
|
||||
`raybri_init` compiles the shaders in place (no storage/`strdup`).
|
||||
`cube_normal.png` drives tangentless normal mapping via the derivative-based
|
||||
`cotangentFrame`. The context is OpenGL 3.2 Core (`RENDER_OPENGL_ATTRS`); on
|
||||
Apple Silicon the driver still reports 4.1/GLSL 4.10.
|
||||
|
||||
## Render architecture
|
||||
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
../../mac/view/ChkgfxView.swift
|
||||
@@ -0,0 +1,8 @@
|
||||
#ifndef OTHER_BRIDGING_HEADER_H
|
||||
#define OTHER_BRIDGING_HEADER_H
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
#import <QuartzCore/QuartzCore.h>
|
||||
|
||||
#endif
|
||||
@@ -4,12 +4,15 @@
|
||||
#include "rlgl.h"
|
||||
#include "raymath.h"
|
||||
|
||||
#include <dlfcn.h>
|
||||
#include <math.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#if !defined(PLATFORM_IOS)
|
||||
#include <dlfcn.h>
|
||||
#endif
|
||||
|
||||
static int sr_width = 1;
|
||||
static int sr_height = 1;
|
||||
|
||||
@@ -65,6 +68,7 @@ static int loc_fog_color = -1;
|
||||
static int loc_fog_start = -1;
|
||||
static int loc_fog_end = -1;
|
||||
|
||||
#if !defined(PLATFORM_IOS)
|
||||
// raylib is built as a static/dynamic library with GLFW baked in, but we never
|
||||
// call InitWindow(). Instead we render into an OpenGL context owned by the
|
||||
// macOS app, so we must supply the OpenGL entry point loader ourselves.
|
||||
@@ -78,6 +82,7 @@ static void *sr_gl_loader(const char *name)
|
||||
if (handle == NULL) return NULL;
|
||||
return dlsym(handle, name);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Compose a model transform exactly like raylib's DrawModel() does, so the
|
||||
// matrices we feed to DrawMesh() match what rlgl computes internally.
|
||||
@@ -190,9 +195,14 @@ void raybri_init(
|
||||
// raylib's default INFO logging is noisy; keep warnings and errors only.
|
||||
SetTraceLogLevel(LOG_WARNING);
|
||||
|
||||
#if !defined(PLATFORM_IOS)
|
||||
rlLoadExtensions((void *)sr_gl_loader);
|
||||
// Init with default 1x1 size
|
||||
rlglInit(1, 1);
|
||||
#else
|
||||
// On iOS the prebuilt raylib (ghera/raylib-iOS) already calls
|
||||
// rlLoadExtensions() and rlglInit() inside InitWindow(); skip here.
|
||||
#endif
|
||||
|
||||
sr_load_shaders(main_vs, main_fs, shadow_vs, shadow_fs);
|
||||
sr_config_shaders();
|
||||
@@ -216,6 +226,9 @@ void raybri_load_model(const char *gltf_path)
|
||||
|
||||
if (sr_has_model)
|
||||
{
|
||||
fprintf(stderr, "SR: model loaded: %s (%d meshes, %d materials)\n",
|
||||
gltf_path, sr_model.meshCount, sr_model.materialCount);
|
||||
|
||||
int cube_mat_index = (sr_model.materialCount > 0) ? sr_model.meshMaterial[0] : 0;
|
||||
sr_cube_material = sr_model.materials[cube_mat_index];
|
||||
sr_cube_material.shader = sr_main_shader;
|
||||
@@ -435,6 +448,8 @@ void raybri_shutdown(void)
|
||||
if (sr_main_shader.id > 0) UnloadShader(sr_main_shader);
|
||||
if (sr_shadow_shader.id > 0) UnloadShader(sr_shadow_shader);
|
||||
|
||||
#if !defined(PLATFORM_IOS)
|
||||
rlglClose();
|
||||
#endif
|
||||
sr_ready = 0;
|
||||
}
|
||||
@@ -15,7 +15,8 @@ typedef struct raybri_config {
|
||||
} raybri_config;
|
||||
|
||||
// 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 (with the
|
||||
// platform #version already substituted).
|
||||
void raybri_init(
|
||||
const char *main_vs,
|
||||
const char *main_fs,
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
import SwiftUI
|
||||
import UIKit
|
||||
|
||||
// The prebuilt raylib iOS framework owns the app entry point (main()/
|
||||
// AppDelegate/SceneDelegate in rcore_ios.c). Its SceneDelegate creates the
|
||||
// window, installs GameViewController as the root and only then calls
|
||||
// ios_ready(), so by the time rcios_present_overlay() runs there is already a
|
||||
// key window with a GL-backed root view.
|
||||
//
|
||||
// We deliberately do NOT create a second UIWindow: that would sit at a fixed
|
||||
// windowLevel and break alerts/buttons later. Instead we add the SwiftUI
|
||||
// content as a child UIViewController of raylib's root view controller, so:
|
||||
// - buttons receive touches through the normal responder chain;
|
||||
// - .alert / sheets present correctly in the same window;
|
||||
// - rotation and geometry changes apply to both layers at once.
|
||||
//
|
||||
// ChkgfxComponent/ChkgfxVM live here because the component lifecycle is
|
||||
// otherwise driven by the (iOS-unavailable) SwiftUI app shell.
|
||||
|
||||
enum RenderIOS {
|
||||
static let chkgfx = ChkgfxComponent()
|
||||
static let chkgfxVM = ChkgfxVM()
|
||||
// Inert on iOS (the raylib framework drives the scene), but the generated
|
||||
// dialect refers to them, so keep them alive.
|
||||
static let render = RenderComponent()
|
||||
static let renderVM = RenderVM()
|
||||
}
|
||||
|
||||
// The GLSL sources live in renderConstShader.swift (shared with the macOS
|
||||
// build, with the platform #version already substituted). Expose them to the
|
||||
// ObjC++ bridge as C strings; each call returns a malloc'd copy the caller
|
||||
// must free().
|
||||
@_cdecl("rcios_shader_main_vs")
|
||||
public func rciosShaderMainVS() -> UnsafeMutablePointer<CChar>? {
|
||||
strdup(RENDER_SHADER_MAIN_VS)
|
||||
}
|
||||
|
||||
@_cdecl("rcios_shader_main_fs")
|
||||
public func rciosShaderMainFS() -> UnsafeMutablePointer<CChar>? {
|
||||
strdup(RENDER_SHADER_MAIN_FS)
|
||||
}
|
||||
|
||||
@_cdecl("rcios_shader_shadow_vs")
|
||||
public func rciosShaderShadowVS() -> UnsafeMutablePointer<CChar>? {
|
||||
strdup(RENDER_SHADER_SHADOW_VS)
|
||||
}
|
||||
|
||||
@_cdecl("rcios_shader_shadow_fs")
|
||||
public func rciosShaderShadowFS() -> UnsafeMutablePointer<CChar>? {
|
||||
strdup(RENDER_SHADER_SHADOW_FS)
|
||||
}
|
||||
|
||||
@_cdecl("rcios_present_overlay")
|
||||
public func rciosPresentOverlay() {
|
||||
otherSetupConsoleLogging(RenderIOS.chkgfx.ctrl, "Chkgfx")
|
||||
RenderIOS.chkgfx.setup()
|
||||
|
||||
DispatchQueue.main.async {
|
||||
guard let scene = UIApplication.shared.connectedScenes
|
||||
.compactMap({ $0 as? UIWindowScene })
|
||||
.first(where: { $0.activationState == .foregroundActive })
|
||||
?? UIApplication.shared.connectedScenes
|
||||
.compactMap({ $0 as? UIWindowScene }).first
|
||||
else { return }
|
||||
|
||||
// raylib's SceneDelegate made its window key before calling ios_ready().
|
||||
guard let window = scene.windows.first(where: { $0.isKeyWindow })
|
||||
?? scene.windows.first,
|
||||
let host = window.rootViewController
|
||||
else { return }
|
||||
|
||||
let root = ChkgfxView(RenderIOS.chkgfxVM)
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .top)
|
||||
|
||||
let hosting = UIHostingController(rootView: root)
|
||||
hosting.view.backgroundColor = .clear
|
||||
// The UI is a passive title for now. Once it gains buttons, drop this
|
||||
// line; touches will then stay in the SwiftUI layer over the whole
|
||||
// screen instead of reaching raylib's GameViewController.
|
||||
hosting.view.isUserInteractionEnabled = false
|
||||
|
||||
host.addChild(hosting)
|
||||
hosting.view.frame = host.view.bounds
|
||||
hosting.view.autoresizingMask = [.flexibleWidth, .flexibleHeight]
|
||||
host.view.addSubview(hosting.view)
|
||||
hosting.didMove(toParent: host)
|
||||
|
||||
// addChild retains the hosting controller for as long as it stays
|
||||
// attached, so no extra strong reference is needed here.
|
||||
OverlayHost.retained = hosting
|
||||
}
|
||||
}
|
||||
|
||||
// Optional handle for later use (e.g. presenting an alert from the hosting
|
||||
// controller). The parent view controller keeps it alive while attached.
|
||||
private enum OverlayHost {
|
||||
static weak var retained: UIViewController?
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string>
|
||||
|
||||
#include "raylib.h"
|
||||
#include "raybri.h"
|
||||
|
||||
// iOS entry points. The prebuilt raylib.framework (ghera/raylib-iOS) owns
|
||||
// main()/AppDelegate/SceneDelegate and a full-screen EGL/ANGLE window; it
|
||||
// calls these three callbacks (see src/platforms/rcore_ios.c). We therefore
|
||||
// drive the same raybri_* scene as the macOS build from here, and present the
|
||||
// SwiftUI UI inside raylib's own window (see RenderIOS.swift).
|
||||
//
|
||||
// The prebuilt framework already ran rlLoadExtensions()/rlglInit() inside
|
||||
// InitWindow(), so raybri_init() only compiles the shaders and builds meshes.
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" void rcios_present_overlay(void); // implemented in Swift (RenderIOS.swift)
|
||||
#else
|
||||
void rcios_present_overlay(void);
|
||||
#endif
|
||||
|
||||
// The GLSL sources live in renderConstShader.swift (shared with the macOS
|
||||
// build, with the platform #version already substituted there). These Swift
|
||||
// accessors return malloc'd copies that sr_shader() releases.
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
char *rcios_shader_main_vs(void);
|
||||
char *rcios_shader_main_fs(void);
|
||||
char *rcios_shader_shadow_vs(void);
|
||||
char *rcios_shader_shadow_fs(void);
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
static std::string sr_shader(char *(*accessor)(void))
|
||||
{
|
||||
char *source = accessor();
|
||||
std::string shader = source ? source : "";
|
||||
free(source);
|
||||
return shader;
|
||||
}
|
||||
|
||||
static double sr_start_time = 0.0;
|
||||
static int sr_window_ready = 0;
|
||||
|
||||
double rcios_time_now(void)
|
||||
{
|
||||
return CACurrentMediaTime();
|
||||
}
|
||||
|
||||
extern "C" void ios_ready(void)
|
||||
{
|
||||
SetTraceLogLevel(LOG_WARNING);
|
||||
|
||||
// Size is ignored on PLATFORM_IOS; the fork sizes the window itself.
|
||||
InitWindow(0, 0, "OGS chkgfx");
|
||||
|
||||
// On iOS raylib's InitWindow loaded the GL functions and called rlglInit,
|
||||
// so raybri_init() must not repeat it (see raybri.c, RAYBRI_PLATFORM_IOS).
|
||||
std::string main_vs = sr_shader(rcios_shader_main_vs);
|
||||
std::string main_fs = sr_shader(rcios_shader_main_fs);
|
||||
std::string shadow_vs = sr_shader(rcios_shader_shadow_vs);
|
||||
std::string shadow_fs = sr_shader(rcios_shader_shadow_fs);
|
||||
raybri_init(
|
||||
main_vs.c_str(),
|
||||
main_fs.c_str(),
|
||||
shadow_vs.c_str(),
|
||||
shadow_fs.c_str(),
|
||||
(raybri_config){ 45.0f, 0.1f, 1000.0f, 256, 40.0f }
|
||||
);
|
||||
|
||||
// Same layout as the macOS app bundle: <bundle>/cube/cube.gltf
|
||||
NSString *gltf = [[[NSBundle mainBundle] resourcePath]
|
||||
stringByAppendingPathComponent:@"cube/cube.gltf"];
|
||||
raybri_load_model([gltf UTF8String]);
|
||||
|
||||
sr_start_time = rcios_time_now();
|
||||
sr_window_ready = 1;
|
||||
|
||||
// Show ChkgfxView (the SwiftUI title) above the raylib scene.
|
||||
rcios_present_overlay();
|
||||
}
|
||||
|
||||
extern "C" void ios_update(bool viewSizeChanged)
|
||||
{
|
||||
if (!sr_window_ready) return;
|
||||
|
||||
int w = GetRenderWidth();
|
||||
int h = GetRenderHeight();
|
||||
raybri_resize(w, h);
|
||||
|
||||
float t = (float)(rcios_time_now() - sr_start_time);
|
||||
raybri_set_rotation(t * 6.0f, t * 18.0f, 0.0f);
|
||||
|
||||
BeginDrawing();
|
||||
raybri_render();
|
||||
EndDrawing();
|
||||
}
|
||||
|
||||
extern "C" void ios_destroy(void)
|
||||
{
|
||||
if (!sr_window_ready) return;
|
||||
raybri_shutdown();
|
||||
CloseWindow();
|
||||
sr_window_ready = 0;
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
import Combine
|
||||
import Foundation
|
||||
|
||||
// On iOS the renderer is the prebuilt raylib framework's own full-screen
|
||||
// window (see components/render/ios/renderIOS.mm: ios_ready/ios_update/
|
||||
// ios_destroy). The macOS render component is not used there, but the
|
||||
// generated dialect.swift still refers to RenderComponent/RenderVM and to the
|
||||
// renderInit/renderStartTimer/renderLoadCubeModel/renderDeinit oneliners, so
|
||||
// we provide inert counterparts to keep the dialect compiling.
|
||||
//
|
||||
// The real work happens in renderIOS.mm, which talks to the very same
|
||||
// raybri_* bridge functions these stubs would call on macOS.
|
||||
|
||||
final class RenderVM: ObservableObject {
|
||||
var didPrepareGL = false
|
||||
var pixelSize = [Int32]()
|
||||
var startTime: CFTimeInterval = 0
|
||||
|
||||
static private(set) weak var shared: RenderVM?
|
||||
|
||||
init() {
|
||||
Self.shared = self
|
||||
}
|
||||
}
|
||||
|
||||
class RenderComponent {
|
||||
let ctrl = DialectController(RenderContext())
|
||||
static private(set) weak var singleton: RenderComponent?
|
||||
|
||||
init() {
|
||||
Self.singleton = self
|
||||
renderRegisterShoulds(ctrl)
|
||||
}
|
||||
|
||||
func setup() {
|
||||
renderSet(F.didSetup, true)
|
||||
}
|
||||
}
|
||||
|
||||
func renderInit(_ vm: RenderVM) {}
|
||||
|
||||
func renderStartTimer(_ vm: RenderVM) {}
|
||||
|
||||
func renderLoadCubeModel(_ vm: RenderVM) {}
|
||||
|
||||
func renderDeinit(_ vm: RenderVM) {}
|
||||
@@ -1,5 +1,27 @@
|
||||
let RENDER_SHADER_MAIN_FS = """
|
||||
#version 150
|
||||
// GLSL sources shared by the macOS (GLSL 150) and iOS (GLSL ES 300)
|
||||
// builds. A shader's #version directive must precede everything else (even
|
||||
// "precision"), so it cannot be chosen with an #ifdef inside the GLSL; the
|
||||
// templates below start with RENDER_SHADER_VERSION_TOKEN and the platform
|
||||
// version is substituted with replacingOccurrences.
|
||||
//
|
||||
// The fragment templates carry "precision highp float;" because GLSL ES has
|
||||
// no default float precision in the fragment stage; desktop GLSL 1.30+
|
||||
// accepts and ignores it. GLSL ES vertex shaders default to highp, so the
|
||||
// vertex templates need no precision statement.
|
||||
|
||||
let RENDER_SHADER_VERSION_TOKEN = "%VERSION%"
|
||||
let RENDER_SHADER_VERSION_GL = "#version 150"
|
||||
let RENDER_SHADER_VERSION_ES = "#version 300 es"
|
||||
|
||||
#if os(iOS)
|
||||
let RENDER_SHADER_VERSION = RENDER_SHADER_VERSION_ES
|
||||
#else
|
||||
let RENDER_SHADER_VERSION = RENDER_SHADER_VERSION_GL
|
||||
#endif
|
||||
|
||||
let RENDER_SHADER_MAIN_FS_T = """
|
||||
%VERSION%
|
||||
precision highp float;
|
||||
|
||||
in vec3 vWorldPos;
|
||||
in vec3 vNormal;
|
||||
@@ -116,8 +138,13 @@ void main()
|
||||
}
|
||||
"""
|
||||
|
||||
let RENDER_SHADER_MAIN_VS = """
|
||||
#version 150
|
||||
let RENDER_SHADER_MAIN_FS = RENDER_SHADER_MAIN_FS_T.replacingOccurrences(
|
||||
of: RENDER_SHADER_VERSION_TOKEN,
|
||||
with: RENDER_SHADER_VERSION
|
||||
)
|
||||
|
||||
let RENDER_SHADER_MAIN_VS_T = """
|
||||
%VERSION%
|
||||
in vec3 vertexPosition;
|
||||
in vec2 vertexTexCoord;
|
||||
in vec3 vertexNormal;
|
||||
@@ -142,8 +169,14 @@ void main()
|
||||
}
|
||||
"""
|
||||
|
||||
let RENDER_SHADER_SHADOW_FS = """
|
||||
#version 150
|
||||
let RENDER_SHADER_MAIN_VS = RENDER_SHADER_MAIN_VS_T.replacingOccurrences(
|
||||
of: RENDER_SHADER_VERSION_TOKEN,
|
||||
with: RENDER_SHADER_VERSION
|
||||
)
|
||||
|
||||
let RENDER_SHADER_SHADOW_FS_T = """
|
||||
%VERSION%
|
||||
precision highp float;
|
||||
out vec4 finalColor;
|
||||
void main()
|
||||
{
|
||||
@@ -151,8 +184,13 @@ void main()
|
||||
}
|
||||
"""
|
||||
|
||||
let RENDER_SHADER_SHADOW_VS = """
|
||||
#version 150
|
||||
let RENDER_SHADER_SHADOW_FS = RENDER_SHADER_SHADOW_FS_T.replacingOccurrences(
|
||||
of: RENDER_SHADER_VERSION_TOKEN,
|
||||
with: RENDER_SHADER_VERSION
|
||||
)
|
||||
|
||||
let RENDER_SHADER_SHADOW_VS_T = """
|
||||
%VERSION%
|
||||
in vec3 vertexPosition;
|
||||
uniform mat4 mvp;
|
||||
void main()
|
||||
@@ -160,3 +198,8 @@ void main()
|
||||
gl_Position = mvp * vec4(vertexPosition, 1.0);
|
||||
}
|
||||
"""
|
||||
|
||||
let RENDER_SHADER_SHADOW_VS = RENDER_SHADER_SHADOW_VS_T.replacingOccurrences(
|
||||
of: RENDER_SHADER_VERSION_TOKEN,
|
||||
with: RENDER_SHADER_VERSION
|
||||
)
|
||||
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
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?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>UIApplicationSceneManifest</key>
|
||||
<dict>
|
||||
<key>UIApplicationSupportsMultipleScenes</key>
|
||||
<false/>
|
||||
<key>UISceneConfigurations</key>
|
||||
<dict>
|
||||
<key>UIWindowSceneSessionRoleApplication</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>UISceneConfigurationName</key>
|
||||
<string>Default Configuration</string>
|
||||
<key>UISceneDelegateClassName</key>
|
||||
<string>SceneDelegate</string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>UISupportedInterfaceOrientations</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,81 @@
|
||||
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/render/renderConstShader.swift
|
||||
- path: ../../components/raybri
|
||||
- path: ../../components/other
|
||||
- path: ../../components/chkgfx/chkgfx.swift
|
||||
- path: ../../components/chkgfx/chkgfxVM.swift
|
||||
- path: ../../components/chkgfx/ios/view/ChkgfxView.swift
|
||||
dependencies:
|
||||
- framework: Frameworks/raylib.xcframework
|
||||
embed: true
|
||||
- framework: Frameworks/libEGL.xcframework
|
||||
embed: true
|
||||
- framework: Frameworks/libGLESv2.xcframework
|
||||
embed: true
|
||||
- sdk: UIKit.framework
|
||||
- sdk: SwiftUI.framework
|
||||
- sdk: QuartzCore.framework
|
||||
- sdk: CoreGraphics.framework
|
||||
- sdk: Foundation.framework
|
||||
settings:
|
||||
base:
|
||||
INFOPLIST_FILE: Info.plist
|
||||
PRODUCT_BUNDLE_IDENTIFIER: org.opengamestudio.chkgfx
|
||||
SWIFT_OBJC_BRIDGING_HEADER: ../../components/other/other-Bridging-Header.h
|
||||
HEADER_SEARCH_PATHS:
|
||||
- "$(SRCROOT)/../../components"
|
||||
- "$(SRCROOT)/../../components/raybri"
|
||||
- "$(SRCROOT)/../../components/render"
|
||||
- "$(SRCROOT)/../../components/render/ios"
|
||||
- "$(SRCROOT)/../../components/other"
|
||||
- "$(SRCROOT)/Frameworks/raylib.xcframework/ios-arm64_x86_64-simulator/raylib.framework/Headers"
|
||||
- "$(SRCROOT)/Frameworks/raylib.xcframework/ios-arm64/raylib.framework/Headers"
|
||||
- "$(SRCROOT)/Frameworks/libEGL.xcframework/ios-arm64_x86_64-simulator/Headers"
|
||||
- "$(SRCROOT)/Frameworks/libEGL.xcframework/ios-arm64/Headers"
|
||||
- "$(SRCROOT)/Frameworks/libGLESv2.xcframework/ios-arm64_x86_64-simulator/Headers"
|
||||
- "$(SRCROOT)/Frameworks/libGLESv2.xcframework/ios-arm64/Headers"
|
||||
USER_HEADER_SEARCH_PATHS:
|
||||
- "$(SRCROOT)/../../components/raybri"
|
||||
- "$(SRCROOT)/../../components/render/ios"
|
||||
- "$(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
|
||||
OTHER_LDFLAGS:
|
||||
- "-ObjC"
|
||||
FRAMEWORK_SEARCH_PATHS:
|
||||
- "$(SRCROOT)/Frameworks"
|
||||
- "$(SRCROOT)/Frameworks/raylib.xcframework/ios-arm64_x86_64-simulator"
|
||||
- "$(SRCROOT)/Frameworks/raylib.xcframework/ios-arm64"
|
||||
- "$(SRCROOT)/Frameworks/libEGL.xcframework/ios-arm64_x86_64-simulator"
|
||||
- "$(SRCROOT)/Frameworks/libEGL.xcframework/ios-arm64"
|
||||
- "$(SRCROOT)/Frameworks/libGLESv2.xcframework/ios-arm64_x86_64-simulator"
|
||||
- "$(SRCROOT)/Frameworks/libGLESv2.xcframework/ios-arm64"
|
||||
LD_RUNPATH_SEARCH_PATHS:
|
||||
- "$(inherited) @executable_path/Frameworks"
|
||||
postBuildScripts:
|
||||
- name: Copy res
|
||||
script: |
|
||||
# Mirror the macOS packaging: the shared res/ tree (symlinks
|
||||
# dereferenced) lands in the app bundle root, so the model is
|
||||
# at <bundle>/cube/cube.gltf
|
||||
RES="${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
|
||||
mkdir -p "$RES"
|
||||
cp -R -L "${SRCROOT}/../../res/." "$RES/"
|
||||
inputFiles:
|
||||
- "$(SRCROOT)/../../res"
|
||||
outputFiles:
|
||||
- "$(TARGET_BUILD_DIR)/$(UNLOCALIZED_RESOURCES_FOLDER_PATH)/cube/cube.gltf"
|
||||
+1
@@ -0,0 +1 @@
|
||||
../../ver-mac/src/dialect.swift
|
||||
@@ -1,4 +1,3 @@
|
||||
import AppKit
|
||||
import SwiftUI
|
||||
|
||||
@main
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import AppKit
|
||||
import SwiftUI
|
||||
|
||||
@main
|
||||
struct GameApp: App {
|
||||
struct MahjongApp: App {
|
||||
@NSApplicationDelegateAdaptor(AppDelegate.self) private var appDelegate
|
||||
|
||||
var body: some Scene {
|
||||
Executable
+14
@@ -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
|
||||
Executable
+11
@@ -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
|
||||
Executable
+26
@@ -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"
|
||||
Executable
+28
@@ -0,0 +1,28 @@
|
||||
#!/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 adds an
|
||||
# iOS platform (rcore_ios.c) rendering OpenGL ES via ANGLE. Its stable
|
||||
# releases ship prebuilt xcframeworks (raylib + libEGL + libGLESv2). They are
|
||||
# ~46 MB, so they are downloaded on demand and never committed.
|
||||
RAYLIB_IOS_TAG=6.0.7-iOS
|
||||
FRAMEWORKS=$SDIR/../$TARGET/ver-ios/Frameworks
|
||||
if [[ ! -d "$FRAMEWORKS/raylib.xcframework" ]]; then
|
||||
echo "Raylib iOS xcframeworks missing, downloading $RAYLIB_IOS_TAG..."
|
||||
mkdir -p "$FRAMEWORKS"
|
||||
TMP=$(mktemp -d)
|
||||
curl -sL -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
|
||||
|
||||
cd $SDIR/../$TARGET/ver-ios
|
||||
xcodegen
|
||||
Reference in new issue
Block a user