some
This commit is contained in:
1 parent
4b70bd9906
commit
e0f54dde75
7 files changed
+38
-43
No files matched your search
@@ -1,6 +1,6 @@
|
||||
#ifndef OGS_MAHJONG_RAYLIB_IOS_BRIDGING_HEADER_H
|
||||
#define OGS_MAHJONG_RAYLIB_IOS_BRIDGING_HEADER_H
|
||||
|
||||
#import "raybriIOS.h"
|
||||
#include "../raybri.h"
|
||||
|
||||
#endif
|
||||
@@ -10,7 +10,7 @@
|
||||
// GL runs on ANGLE (libEGL + libGLESv2, Metal backend), taken from the same
|
||||
// ghera release as raylib's headers.
|
||||
|
||||
#include "raybriIOS.h"
|
||||
#include "../raybri.h"
|
||||
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
@@ -90,7 +90,7 @@ static int sr_create_surface(void)
|
||||
return 1;
|
||||
}
|
||||
|
||||
int raybri_ios_init(void *layer, int width, int height)
|
||||
int raybri_init(void *layer, int width, int height)
|
||||
{
|
||||
if (sr_ready) return 1;
|
||||
|
||||
@@ -166,7 +166,7 @@ int raybri_ios_init(void *layer, int width, int height)
|
||||
return 1;
|
||||
}
|
||||
|
||||
void raybri_ios_resize(int width, int height)
|
||||
void raybri_resize(int width, int height)
|
||||
{
|
||||
if (!sr_ready) return;
|
||||
|
||||
@@ -181,7 +181,7 @@ void raybri_ios_resize(int width, int height)
|
||||
sr_log("surface recreated");
|
||||
}
|
||||
|
||||
void raybri_ios_render(double time)
|
||||
void raybri_render(double time)
|
||||
{
|
||||
if (!sr_ready) return;
|
||||
|
||||
@@ -200,7 +200,7 @@ void raybri_ios_render(double time)
|
||||
eglSwapBuffers(sr_display, sr_surface);
|
||||
}
|
||||
|
||||
void raybri_ios_shutdown(void)
|
||||
void raybri_shutdown(void)
|
||||
{
|
||||
if (!sr_ready) return;
|
||||
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
#ifndef OGS_MAHJONG_RAYLIB_IOS_BRIDGE_H
|
||||
#define OGS_MAHJONG_RAYLIB_IOS_BRIDGE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Initialise EGL (ANGLE) on the given CALayer and bring up raylib's rlgl.
|
||||
// Unlike the ghera/raylib-iOS backend, no raylib window, view controller or
|
||||
// app delegate is involved: the caller owns the layer and the frame timer.
|
||||
// Returns 1 on success, 0 on failure.
|
||||
int raybri_ios_init(void *layer, int width, int height);
|
||||
|
||||
// Recreate the EGL window surface for a new drawable size (backing pixels).
|
||||
void raybri_ios_resize(int width, int height);
|
||||
|
||||
// Render one frame: clear the drawable to a time-based background colour and
|
||||
// present it. `time` is monotonically increasing seconds.
|
||||
void raybri_ios_render(double time);
|
||||
|
||||
// Release rlgl state and the EGL surface/context/display.
|
||||
void raybri_ios_shutdown(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,6 +1,8 @@
|
||||
#ifndef OGS_MAHJONG_RAYLIB_BRIDGE_H
|
||||
#define OGS_MAHJONG_RAYLIB_BRIDGE_H
|
||||
|
||||
#include <TargetConditionals.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@@ -14,6 +16,31 @@ typedef struct raybri_config {
|
||||
float ground_size; // ground plane extent
|
||||
} 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);
|
||||
|
||||
// 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);
|
||||
|
||||
// Render one frame: clear the drawable to a time-based background colour and
|
||||
// present it. `time` is monotonically increasing seconds.
|
||||
void raybri_render(double time);
|
||||
|
||||
#else
|
||||
|
||||
// Initialise the OpenGL-backed raylib scene (no raylib window is created).
|
||||
// The four shader sources come from renderConstShader.swift.
|
||||
void raybri_init(
|
||||
@@ -27,17 +54,13 @@ void raybri_init(
|
||||
// Load the textured cube glTF model.
|
||||
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).
|
||||
void raybri_set_rotation(float x_deg, float y_deg, float z_deg);
|
||||
|
||||
// Render one frame.
|
||||
void raybri_render(void);
|
||||
|
||||
// Release all GPU resources.
|
||||
void raybri_shutdown(void);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import UIKit
|
||||
// like in the NSOpenGLView on macOS.
|
||||
func renderDraw(_ vm: RenderVM) {
|
||||
let t = CACurrentMediaTime() - vm.startTime
|
||||
raybri_ios_render(t)
|
||||
raybri_render(t)
|
||||
}
|
||||
|
||||
// Backing-pixel size of the view, which is what EGL/ANGLE renders into.
|
||||
|
||||
@@ -7,7 +7,7 @@ import UIKit
|
||||
func renderInit(_ vm: RenderVM) -> Bool {
|
||||
let size = renderPixelSize(vm.glView)
|
||||
let layer = Unmanaged.passUnretained(vm.glView.layer).toOpaque()
|
||||
let ok = raybri_ios_init(layer, size[0], size[1]) != 0
|
||||
let ok = raybri_init(layer, size[0], size[1]) != 0
|
||||
if !ok {
|
||||
otherPrintStderr("ИГР renderInit: EGL/ANGLE initialization failed")
|
||||
}
|
||||
@@ -31,5 +31,5 @@ func renderStartTimer(_ vm: RenderVM) {
|
||||
func renderDeinit(_ vm: RenderVM) {
|
||||
vm.timer?.invalidate()
|
||||
vm.timer = nil
|
||||
raybri_ios_shutdown()
|
||||
raybri_shutdown()
|
||||
}
|
||||
@@ -48,7 +48,7 @@ final class RenderGLView: UIView {
|
||||
guard size != vm.pixelSize else { return }
|
||||
|
||||
vm.pixelSize = size
|
||||
raybri_ios_resize(size[0], size[1])
|
||||
raybri_resize(size[0], size[1])
|
||||
}
|
||||
|
||||
deinit {
|
||||
|
||||
Reference in new issue
Block a user