diff --git a/components/raybri/ios/raybri.c b/components/raybri/ios/raybri.c new file mode 100644 index 0000000..9d22d62 --- /dev/null +++ b/components/raybri/ios/raybri.c @@ -0,0 +1,36 @@ +#include "raybri.h" +#include "rlgl.h" +#include + +void raybriInit(void *layer) { + //SetTraceLogLevel(LOG_WARNING); + + if (!raybriInitEGL()) { + raybriLog(stderr, "ERROR Could not initialize EGL") + } + + // Initialize raylib graphics layer with a placeholder 1x1 framebuffer size + // Graphics layer includes default texture, shader, render batch and OpenGL state + rlglInit(1, 1); + // Background is painted in blue + rlClearColor(0, 0, 255, 255); +} + +void raybriLog(const char *txt) { + fprintf(stderr, "Raybri: %s\n", txt); + fflush(stderr); +} + +void raybriRender(int width, int height) { + // Set the drawing area to the current pixel size + rlViewport(0, 0, width, height); + // Clear color and depth buffers for the next frame + rlClearScreenBuffers(); + // Draw any queued geometry + rlDrawRenderBatchActive(); +} + +void raybriShutdown(void) { + // Release rlgl buffers, shaders and textures + rlglClose(); +} diff --git a/components/raybri/ios/raybriEGL.c b/components/raybri/ios/raybriEGL.c new file mode 100644 index 0000000..8a15b58 --- /dev/null +++ b/components/raybri/ios/raybriEGL.c @@ -0,0 +1,20 @@ +#include +#include +#include "raybriEGL.h" + +bool raybriInitEGL(void) { + EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY); + if (display == EGL_NO_DISPLAY) { + return false; + } + + if (eglInitialize(display, NULL, NULL) == EGL_FALSE) { + return false; + } + + if (eglBindAPI(EGL_OPENGL_ES_API) == EGL_FALSE) { + return false; + } + + return true; +} diff --git a/components/raybri/ios/raybriEGL.h b/components/raybri/ios/raybriEGL.h new file mode 100644 index 0000000..4365fed --- /dev/null +++ b/components/raybri/ios/raybriEGL.h @@ -0,0 +1,6 @@ +#ifndef RAYBRI_EGL_H +#define RAYBRI_EGL_H + +bool raybriInitEGL(void); + +#endif // RAYBRI_EGL_H diff --git a/components/raybri/mac/raybri.c b/components/raybri/mac/raybri.c index 3115688..505c772 100644 --- a/components/raybri/mac/raybri.c +++ b/components/raybri/mac/raybri.c @@ -1,6 +1,7 @@ #include "raybri.h" #include "raybriAux.h" #include "rlgl.h" +#include void raybriInit(void *layer) { //SetTraceLogLevel(LOG_WARNING); @@ -14,6 +15,11 @@ void raybriInit(void *layer) { rlClearColor(0, 0, 255, 255); } +void raybriLog(const char *txt) { + fprintf(stderr, "Raybri: %s\n", txt); + fflush(stderr); +} + void raybriRender(int width, int height) { // Set the drawing area to the current pixel size rlViewport(0, 0, width, height); diff --git a/components/raybri/raybri.h b/components/raybri/raybri.h index ef63e31..3692975 100644 --- a/components/raybri/raybri.h +++ b/components/raybri/raybri.h @@ -2,6 +2,7 @@ #define RAYBRI_H void raybriInit(void *layer); +void raybriLog(const char *txt); void raybriRender(int width, int height); void raybriShutdown(void);