some
This commit is contained in:
1 parent
aca30bfe6a
commit
01594353d8
11 files changed
+265
-330
No files matched your search
@@ -1,15 +1,17 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "raylib.h"
|
||||
#include "raybri.h"
|
||||
#include "renderConstShaderIOS.h"
|
||||
#include "renderShaders.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 as a transparent overlay window stacked above raylib's window.
|
||||
// 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.
|
||||
@@ -20,6 +22,16 @@ extern "C" void rcios_present_overlay(void); // implemented in Swift (RenderIOS.
|
||||
void rcios_present_overlay(void);
|
||||
#endif
|
||||
|
||||
// The shader templates in renderShaders.c start with %VERSION%; substitute the
|
||||
// GLSL ES version directive (which must be the first token of the shader).
|
||||
static std::string sr_shader(const char *template_source)
|
||||
{
|
||||
NSString *replaced = [[NSString stringWithUTF8String:template_source]
|
||||
stringByReplacingOccurrencesOfString:[NSString stringWithUTF8String:RENDER_SHADER_VERSION_TOKEN]
|
||||
withString:[NSString stringWithUTF8String:RENDER_SHADER_VERSION_ES]];
|
||||
return std::string([replaced UTF8String]);
|
||||
}
|
||||
|
||||
static double sr_start_time = 0.0;
|
||||
static int sr_window_ready = 0;
|
||||
|
||||
@@ -37,11 +49,15 @@ extern "C" void ios_ready(void)
|
||||
|
||||
// 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(RENDER_SHADER_MAIN_VS_T);
|
||||
std::string main_fs = sr_shader(RENDER_SHADER_MAIN_FS_T);
|
||||
std::string shadow_vs = sr_shader(RENDER_SHADER_SHADOW_VS_T);
|
||||
std::string shadow_fs = sr_shader(RENDER_SHADER_SHADOW_FS_T);
|
||||
raybri_init(
|
||||
RENDER_SHADER_MAIN_VS,
|
||||
RENDER_SHADER_MAIN_FS,
|
||||
RENDER_SHADER_SHADOW_VS,
|
||||
RENDER_SHADER_SHADOW_FS,
|
||||
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 }
|
||||
);
|
||||
|
||||
|
||||
Reference in new issue
Block a user