blue
This commit is contained in:
1 parent
7bd72fc60a
commit
de36ad782c
6 files changed
+23
-18
No files matched your search
@@ -1,11 +1,11 @@
|
||||
#include "raybri.h"
|
||||
|
||||
#define EGL_CONST_IMPLEMENTATION
|
||||
#include "eglConst.h"
|
||||
|
||||
#define EGL_IMPLEMENTATION
|
||||
#include "egl.h"
|
||||
|
||||
#include "raybri.h"
|
||||
|
||||
#define RLGL_IMPLEMENTATION
|
||||
#include "rlgl.h"
|
||||
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
#ifndef RAYBRI_H
|
||||
#define RAYBRI_H
|
||||
|
||||
#if defined(PLATFORM_IOS)
|
||||
#include "../egl/egl.h"
|
||||
#endif
|
||||
|
||||
void raybriInit(void *layer);
|
||||
void raybriLog(const char *txt);
|
||||
void raybriRender(int width, int height);
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import UIKit
|
||||
|
||||
func renderDraw(_ vm: RenderVM) {
|
||||
guard eglMakeCurrentContext(&vm.glView.st) else { return }
|
||||
raybriRender(vm.pixelSize[0], vm.pixelSize[1])
|
||||
eglSwapBuffers(vm.glView.st.display, vm.glView.st.surface)
|
||||
}
|
||||
|
||||
func renderPixelSize(_ view: UIView) -> [Int32] {
|
||||
|
||||
@@ -5,23 +5,23 @@ import UIKit
|
||||
func renderDeinit(_ vm: RenderVM) {
|
||||
vm.timer?.invalidate()
|
||||
vm.timer = nil
|
||||
guard eglMakeCurrentContext(&vm.glView.st) else { return }
|
||||
raybriShutdown()
|
||||
eglMakeCurrent(vm.glView.st.display, nil, nil, nil)
|
||||
eglDestroySurface(vm.glView.st.display, vm.glView.st.surface)
|
||||
eglDestroyContext(vm.glView.st.display, vm.glView.st.ctx)
|
||||
eglTerminate(vm.glView.st.display)
|
||||
}
|
||||
|
||||
func renderInit(_ vm: RenderVM) {
|
||||
// UIKit has no NSOpenGLContext: EGL/ANGLE renders into the view's layer,
|
||||
// so the layer is what the bridge needs to create its surface from.
|
||||
let layer = Unmanaged.passUnretained(vm.glView.layer).toOpaque()
|
||||
vm.glView.st.caLayer = layer;
|
||||
vm.glView.st.caLayer = layer
|
||||
|
||||
if (!eglInit(&vm.glView.st)) {
|
||||
raybriLog("ERROR Could not initialize EGL");
|
||||
}
|
||||
if (!eglResetSurface(&vm.glView.st)) {
|
||||
raybriLog("ERROR Could not reset EGL surface");
|
||||
}
|
||||
|
||||
eglMakeCurrentContext(&vm.glView.st)
|
||||
guard eglInit(&vm.glView.st) else { fatalError("ERROR Could not initialize EGL") }
|
||||
guard eglResetSurface(&vm.glView.st) else { fatalError("ERROR Could not reset EGL surface") }
|
||||
guard eglMakeCurrentContext(&vm.glView.st) else { fatalError("ERROR Could not make EGL context current") }
|
||||
|
||||
raybriInit(layer)
|
||||
}
|
||||
|
||||
@@ -1,13 +1,7 @@
|
||||
import UIKit
|
||||
|
||||
final class RenderGLView: UIView {
|
||||
var st: EGLState = {
|
||||
.caLayer = NULL,
|
||||
.cfg = NULL,
|
||||
.ctx = EGL_NO_CONTEXT,
|
||||
.display = EGL_NO_DISPLAY,
|
||||
.surface = EGL_NO_SURFACE
|
||||
};
|
||||
var st = EGLState()
|
||||
|
||||
override init(frame: CGRect) {
|
||||
super.init(frame: frame)
|
||||
@@ -31,6 +25,9 @@ final class RenderGLView: UIView {
|
||||
|
||||
override func layoutSubviews() {
|
||||
super.layoutSubviews()
|
||||
if st.surface != nil {
|
||||
guard eglResetSurface(&st), eglMakeCurrentContext(&st) else { fatalError("ERROR Could not reset EGL surface") }
|
||||
}
|
||||
let ps = renderPixelSize(self)
|
||||
renderSet(F.reshapePixelSize, ps)
|
||||
}
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
<dict/>
|
||||
<key>UISupportedInterfaceOrientations</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
</array>
|
||||
</dict>
|
||||
|
||||
Reference in new issue
Block a user