Android support, attempt-1 #8

Open
kornerr wants to merge 62 commits from and1 into master
pull from: and1
7 changed files with 33 additions and 33 deletions
Showing only changes of commit 360be210c2 - Show all commits

No files matched your search

@@ -1,27 +1,27 @@
#ifndef RAYBRI_EGL_H #ifndef EGL_H
#define RAYBRI_EGL_H #define EGL_H
#include "eglConst.h"
#include <libEGL/libEGL.h> #include <libEGL/libEGL.h>
#include <libGLESv2/GLES/gl.h> #include <libGLESv2/GLES/gl.h>
#include "raybriEGLConst.h"
#include <stdbool.h> #include <stdbool.h>
typedef struct RaybriEGLState { typedef struct EGLState {
void *caLayer; void *caLayer;
EGLConfig cfg; EGLConfig cfg;
EGLContext ctx; EGLContext ctx;
EGLDisplay display; EGLDisplay display;
EGLSurface surface; EGLSurface surface;
} RaybriEGLState; } EGLState;
bool raybriEGLInit(RaybriEGLState *st); bool eglInit(EGLState *st);
bool raybriEGLResetSurface(RaybriEGLState *st); bool eglResetSurface(EGLState *st);
// Source // Source
#if defined(RAYBRI_EGL_IMPLEMENTATION) #if defined(EGL_IMPLEMENTATION)
bool raybriEGLInit(RaybriEGLState *st) { bool eglInit(EGLState *st) {
st->display = eglGetDisplay(EGL_DEFAULT_DISPLAY); st->display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
if (st->display == EGL_NO_DISPLAY) { if (st->display == EGL_NO_DISPLAY) {
return false; return false;
@@ -37,13 +37,13 @@ bool raybriEGLInit(RaybriEGLState *st) {
EGLint cfgCount = 0; EGLint cfgCount = 0;
if ( if (
eglChooseConfig(st->display, RAYBRI_EGL_CFG, &st->cfg, 1, &cfgCount) == EGL_FALSE || eglChooseConfig(st->display, EGL_CFG, &st->cfg, 1, &cfgCount) == EGL_FALSE ||
cfgCount < 1 cfgCount < 1
) { ) {
return false; return false;
} }
st->ctx = eglCreateContext(st->display, st->cfg, EGL_NO_CONTEXT, RAYBRI_EGL_CTX); st->ctx = eglCreateContext(st->display, st->cfg, EGL_NO_CONTEXT, EGL_CTX);
if (st->ctx == EGL_NO_CONTEXT) { if (st->ctx == EGL_NO_CONTEXT) {
return false; return false;
} }
@@ -51,7 +51,7 @@ bool raybriEGLInit(RaybriEGLState *st) {
return true; return true;
} }
bool raybriEGLResetSurface(RaybriEGLState *st) { bool eglResetSurface(EGLState *st) {
// Destroy previous surface // Destroy previous surface
if (st->surface != EGL_NO_SURFACE) { if (st->surface != EGL_NO_SURFACE) {
eglDestroySurface(st->display, st->surface); eglDestroySurface(st->display, st->surface);
@@ -73,6 +73,6 @@ bool raybriEGLResetSurface(RaybriEGLState *st) {
return true; return true;
} }
#endif // RAYBRI_EGL_IMPLEMENTATION #endif // EGL_IMPLEMENTATION
#endif // RAYBRI_EGL_H #endif // EGL_H
@@ -1,16 +1,18 @@
#ifndef RAYBRI_EGL_CONST_H #ifndef EGL_CONST_H
#define RAYBRI_EGL_CONST_H #define EGL_CONST_H
#include <libEGL/libEGL.h> #include <libEGL/libEGL.h>
// Header // Header
extern const EGLint RAYBRI_EGL_CFG[]; extern const EGLint EGL_CFG[];
extern const EGLint RAYBRI_EGL_CTX[]; extern const EGLint EGL_CTX[];
// Source // Source
const EGLint RAYBRI_EGL_CFG[] = { #if defined(EGL_CONST_IMPLEMENTATION)
const EGLint EGL_CFG[] = {
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES3_BIT, EGL_RENDERABLE_TYPE, EGL_OPENGL_ES3_BIT,
EGL_SURFACE_TYPE, EGL_WINDOW_BIT, EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
EGL_RED_SIZE, 8, EGL_RED_SIZE, 8,
@@ -21,13 +23,11 @@ const EGLint RAYBRI_EGL_CFG[] = {
EGL_NONE EGL_NONE
}; };
const EGLint RAYBRI_EGL_CTX[] = { const EGLint EGL_CTX[] = {
EGL_CONTEXT_CLIENT_VERSION, 3, EGL_CONTEXT_CLIENT_VERSION, 3,
EGL_NONE EGL_NONE
}; };
#if defined(RAYBRI_EGL_CONST_IMPLEMENTATION) #endif // EGL_CONST_IMPLEMENTATION
#endif // RAYBRI_EGL_CONST_IMPLEMENTATION #endif // EGL_CONST_H
#endif // RAYBRI_EGL_CONST_H
+7 -7
View File
@@ -1,17 +1,17 @@
#include "raybri.h" #include "raybri.h"
#define RAYBRI_EGL_CONST_IMPLEMENTATION #define EGL_CONST_IMPLEMENTATION
#include "raybriEGLConst.h" #include "eglConst.h"
#define RAYBRI_EGL_IMPLEMENTATION #define EGL_IMPLEMENTATION
#include "raybriEGL.h" #include "egl.h"
#define RLGL_IMPLEMENTATION #define RLGL_IMPLEMENTATION
#include "rlgl.h" #include "rlgl.h"
#include <stdio.h> #include <stdio.h>
static RaybriEGLState globalES = { static EGLState globalES = {
.caLayer = NULL, .caLayer = NULL,
.cfg = NULL, .cfg = NULL,
.ctx = EGL_NO_CONTEXT, .ctx = EGL_NO_CONTEXT,
@@ -24,10 +24,10 @@ void raybriInit(void *layer) {
globalES.caLayer = layer; globalES.caLayer = layer;
if (!raybriEGLInit(&globalES)) { if (!eglInit(&globalES)) {
raybriLog("ERROR Could not initialize EGL"); raybriLog("ERROR Could not initialize EGL");
} }
if (!raybriEGLResetSurface(&globalES)) { if (!eglResetSurface(&globalES)) {
raybriLog("ERROR Could not reset EGL surface"); raybriLog("ERROR Could not reset EGL surface");
} }
+1
View File
@@ -0,0 +1 @@
../../../../components/egl/egl.h
+1
View File
@@ -0,0 +1 @@
../../../../components/egl/eglConst.h
-1
View File
@@ -1 +0,0 @@
../../../../components/raybri/ios/raybriEGL.h
@@ -1 +0,0 @@
../../../../components/raybri/ios/raybriEGLConst.h