egl cmp
This commit is contained in:
1 parent
b9b7e91bcd
commit
360be210c2
7 files changed
+33
-33
No files matched your search
@@ -1,17 +1,17 @@
|
||||
#include "raybri.h"
|
||||
|
||||
#define RAYBRI_EGL_CONST_IMPLEMENTATION
|
||||
#include "raybriEGLConst.h"
|
||||
#define EGL_CONST_IMPLEMENTATION
|
||||
#include "eglConst.h"
|
||||
|
||||
#define RAYBRI_EGL_IMPLEMENTATION
|
||||
#include "raybriEGL.h"
|
||||
#define EGL_IMPLEMENTATION
|
||||
#include "egl.h"
|
||||
|
||||
#define RLGL_IMPLEMENTATION
|
||||
#include "rlgl.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
static RaybriEGLState globalES = {
|
||||
static EGLState globalES = {
|
||||
.caLayer = NULL,
|
||||
.cfg = NULL,
|
||||
.ctx = EGL_NO_CONTEXT,
|
||||
@@ -24,10 +24,10 @@ void raybriInit(void *layer) {
|
||||
|
||||
globalES.caLayer = layer;
|
||||
|
||||
if (!raybriEGLInit(&globalES)) {
|
||||
if (!eglInit(&globalES)) {
|
||||
raybriLog("ERROR Could not initialize EGL");
|
||||
}
|
||||
if (!raybriEGLResetSurface(&globalES)) {
|
||||
if (!eglResetSurface(&globalES)) {
|
||||
raybriLog("ERROR Could not reset EGL surface");
|
||||
}
|
||||
|
||||
|
||||
@@ -1,78 +0,0 @@
|
||||
#ifndef RAYBRI_EGL_H
|
||||
#define RAYBRI_EGL_H
|
||||
|
||||
#include <libEGL/libEGL.h>
|
||||
#include <libGLESv2/GLES/gl.h>
|
||||
#include "raybriEGLConst.h"
|
||||
#include <stdbool.h>
|
||||
|
||||
typedef struct RaybriEGLState {
|
||||
void *caLayer;
|
||||
EGLConfig cfg;
|
||||
EGLContext ctx;
|
||||
EGLDisplay display;
|
||||
EGLSurface surface;
|
||||
} RaybriEGLState;
|
||||
|
||||
bool raybriEGLInit(RaybriEGLState *st);
|
||||
bool raybriEGLResetSurface(RaybriEGLState *st);
|
||||
|
||||
// Source
|
||||
|
||||
#if defined(RAYBRI_EGL_IMPLEMENTATION)
|
||||
|
||||
bool raybriEGLInit(RaybriEGLState *st) {
|
||||
st->display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
||||
if (st->display == EGL_NO_DISPLAY) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (eglInitialize(st->display, NULL, NULL) == EGL_FALSE) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (eglBindAPI(EGL_OPENGL_ES_API) == EGL_FALSE) {
|
||||
return false;
|
||||
}
|
||||
|
||||
EGLint cfgCount = 0;
|
||||
if (
|
||||
eglChooseConfig(st->display, RAYBRI_EGL_CFG, &st->cfg, 1, &cfgCount) == EGL_FALSE ||
|
||||
cfgCount < 1
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
st->ctx = eglCreateContext(st->display, st->cfg, EGL_NO_CONTEXT, RAYBRI_EGL_CTX);
|
||||
if (st->ctx == EGL_NO_CONTEXT) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool raybriEGLResetSurface(RaybriEGLState *st) {
|
||||
// Destroy previous surface
|
||||
if (st->surface != EGL_NO_SURFACE) {
|
||||
eglDestroySurface(st->display, st->surface);
|
||||
st->surface = EGL_NO_SURFACE;
|
||||
}
|
||||
|
||||
// Create new surface
|
||||
// ANGLE on iOS takes a CALayer as the native window
|
||||
st->surface = eglCreateWindowSurface(
|
||||
st->display,
|
||||
st->cfg,
|
||||
(EGLNativeWindowType)st->caLayer,
|
||||
NULL
|
||||
);
|
||||
if (st->surface == EGL_NO_SURFACE) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif // RAYBRI_EGL_IMPLEMENTATION
|
||||
|
||||
#endif // RAYBRI_EGL_H
|
||||
@@ -1,33 +0,0 @@
|
||||
#ifndef RAYBRI_EGL_CONST_H
|
||||
#define RAYBRI_EGL_CONST_H
|
||||
|
||||
#include <libEGL/libEGL.h>
|
||||
|
||||
// Header
|
||||
|
||||
extern const EGLint RAYBRI_EGL_CFG[];
|
||||
extern const EGLint RAYBRI_EGL_CTX[];
|
||||
|
||||
// Source
|
||||
|
||||
const EGLint RAYBRI_EGL_CFG[] = {
|
||||
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES3_BIT,
|
||||
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
|
||||
EGL_RED_SIZE, 8,
|
||||
EGL_GREEN_SIZE, 8,
|
||||
EGL_BLUE_SIZE, 8,
|
||||
EGL_ALPHA_SIZE, 8,
|
||||
EGL_DEPTH_SIZE, 16,
|
||||
EGL_NONE
|
||||
};
|
||||
|
||||
const EGLint RAYBRI_EGL_CTX[] = {
|
||||
EGL_CONTEXT_CLIENT_VERSION, 3,
|
||||
EGL_NONE
|
||||
};
|
||||
|
||||
#if defined(RAYBRI_EGL_CONST_IMPLEMENTATION)
|
||||
|
||||
#endif // RAYBRI_EGL_CONST_IMPLEMENTATION
|
||||
|
||||
#endif // RAYBRI_EGL_CONST_H
|
||||
Reference in new issue
Block a user