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