Android support, attempt-1 #8
No files matched your search
@@ -11,26 +11,9 @@
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
static EGLState globalES = {
|
||||
.caLayer = NULL,
|
||||
.cfg = NULL,
|
||||
.ctx = EGL_NO_CONTEXT,
|
||||
.display = EGL_NO_DISPLAY,
|
||||
.surface = EGL_NO_SURFACE
|
||||
};
|
||||
|
||||
void raybriInit(void *layer) {
|
||||
//SetTraceLogLevel(LOG_WARNING);
|
||||
|
||||
globalES.caLayer = layer;
|
||||
|
||||
if (!eglInit(&globalES)) {
|
||||
raybriLog("ERROR Could not initialize EGL");
|
||||
}
|
||||
if (!eglResetSurface(&globalES)) {
|
||||
raybriLog("ERROR Could not reset EGL surface");
|
||||
}
|
||||
|
||||
// Initialize raylib graphics layer with a placeholder 1x1 framebuffer size
|
||||
// Graphics layer includes default texture, shader, render batch and OpenGL state
|
||||
rlglInit(1, 1);
|
||||
|
||||
@@ -12,6 +12,17 @@ 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;
|
||||
|
||||
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)
|
||||
|
||||
raybriInit(layer)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
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
|
||||
};
|
||||
|
||||
override init(frame: CGRect) {
|
||||
super.init(frame: frame)
|
||||
|
||||
|
||||
Reference in new issue
Block a user