Files
__mahjong/components/raybri/ios/raybri.c
T

59 lines
1.4 KiB
C

#include "raybri.h"
#define RAYBRI_EGL_CONST_IMPLEMENTATION
#include "raybriEGLConst.h"
#define RAYBRI_EGL_IMPLEMENTATION
#include "raybriEGL.h"
#define RLGL_IMPLEMENTATION
#include "rlgl.h"
#include <stdio.h>
static RaybriEGLState 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 (!raybriEGLInit(&globalES)) {
raybriLog("ERROR Could not initialize EGL");
}
if (!raybriEGLResetSurface(&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);
// 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();
}