some
This commit is contained in:
1 parent
01594353d8
commit
96a5684709
12 files changed
+262
-250
No files matched your search
@@ -26,6 +26,30 @@ enum RenderIOS {
|
||||
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")
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string>
|
||||
|
||||
#include "raylib.h"
|
||||
#include "raybri.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
|
||||
@@ -22,14 +22,26 @@ 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)
|
||||
// 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))
|
||||
{
|
||||
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]);
|
||||
char *source = accessor();
|
||||
std::string shader = source ? source : "";
|
||||
free(source);
|
||||
return shader;
|
||||
}
|
||||
|
||||
static double sr_start_time = 0.0;
|
||||
@@ -49,10 +61,10 @@ 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);
|
||||
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(),
|
||||
|
||||
Reference in new issue
Block a user