diff --git a/components/raybri/mac/raybri.c b/components/raybri/mac/raybri.c index 505c772..f0c6857 100644 --- a/components/raybri/mac/raybri.c +++ b/components/raybri/mac/raybri.c @@ -1,4 +1,8 @@ #include "raybri.h" +// Const must be before Aux due to Aux referencing constants of Const +#define RAYBRI_CONST_IMPLEMENTATION +#include "raybriConst.h" +#define RAYBRI_AUX_IMPLEMENTATION #include "raybriAux.h" #include "rlgl.h" #include diff --git a/components/raybri/mac/raybriAux.c b/components/raybri/mac/raybriAux.c deleted file mode 100644 index e78ec49..0000000 --- a/components/raybri/mac/raybriAux.c +++ /dev/null @@ -1,21 +0,0 @@ -#include -#include "raybriAux.h" -#include "raybriConst.h" -#include - -// raylib is built as a static/dynamic library with GLFW baked in, but we never -// call InitWindow(). Instead we render into an OpenGL context owned by the -// macOS app, so we must supply the OpenGL entry point loader ourselves. -void *raybriGLLoader(const char *name) { - static void *handle = NULL; - - if (handle == NULL) { - handle = dlopen(RAYBRI_MAC_GL, RTLD_LAZY | RTLD_LOCAL); - } - - if (handle == NULL) { - return NULL; - } - - return dlsym(handle, name); -} diff --git a/components/raybri/mac/raybriAux.h b/components/raybri/mac/raybriAux.h index 3e12210..40c44ca 100644 --- a/components/raybri/mac/raybriAux.h +++ b/components/raybri/mac/raybriAux.h @@ -1,6 +1,35 @@ #ifndef RAYBRI_AUX_H #define RAYBRI_AUX_H +// Header + void *raybriGLLoader(const char *name); +// Source + +#if defined(RAYBRI_AUX_IMPLEMENTATION) + +#include +#include +#include "raybriConst.h" + +// raylib is built as a static/dynamic library with GLFW baked in, but we never +// call InitWindow(). Instead we render into an OpenGL context owned by the +// macOS app, so we must supply the OpenGL entry point loader ourselves. +void *raybriGLLoader(const char *name) { + static void *handle = NULL; + + if (handle == NULL) { + handle = dlopen(RAYBRI_MAC_GL, RTLD_LAZY | RTLD_LOCAL); + } + + if (handle == NULL) { + return NULL; + } + + return dlsym(handle, name); +} + +#endif // RAYBRI_AUX_IMPLEMENTATION + #endif // RAYBRI_AUX_H diff --git a/components/raybri/mac/raybriConst.c b/components/raybri/mac/raybriConst.c deleted file mode 100644 index bc427dc..0000000 --- a/components/raybri/mac/raybriConst.c +++ /dev/null @@ -1,3 +0,0 @@ -#include "raybriConst.h" - -const char RAYBRI_MAC_GL[] = "/System/Library/Frameworks/OpenGL.framework/OpenGL"; diff --git a/components/raybri/mac/raybriConst.h b/components/raybri/mac/raybriConst.h index cde42ee..f2ed1b1 100644 --- a/components/raybri/mac/raybriConst.h +++ b/components/raybri/mac/raybriConst.h @@ -1,6 +1,16 @@ #ifndef RAYBRI_CONST_H #define RAYBRI_CONST_H +// Header + extern const char RAYBRI_MAC_GL[]; +// Source + +#if defined(RAYBRI_CONST_IMPLEMENTATION) + +const char RAYBRI_MAC_GL[] = "/System/Library/Frameworks/OpenGL.framework/OpenGL"; + +#endif // RAYBRI_CONST_IMPLEMENTATION + #endif // RAYBRI_CONST_H diff --git a/ogs-blue/ver-mac/src/raybri/raybriAux.c b/ogs-blue/ver-mac/src/raybri/raybriAux.c deleted file mode 120000 index 36bd50c..0000000 --- a/ogs-blue/ver-mac/src/raybri/raybriAux.c +++ /dev/null @@ -1 +0,0 @@ -../../../../components/raybri/mac/raybriAux.c \ No newline at end of file diff --git a/ogs-blue/ver-mac/src/raybri/raybriConst.c b/ogs-blue/ver-mac/src/raybri/raybriConst.c deleted file mode 120000 index 2656529..0000000 --- a/ogs-blue/ver-mac/src/raybri/raybriConst.c +++ /dev/null @@ -1 +0,0 @@ -../../../../components/raybri/mac/raybriConst.c \ No newline at end of file diff --git a/ogs-mahjong/ver-mac/src/raybri/raybriConst.c b/ogs-mahjong/ver-mac/src/raybri/raybriConst.c deleted file mode 120000 index fe840ed..0000000 --- a/ogs-mahjong/ver-mac/src/raybri/raybriConst.c +++ /dev/null @@ -1 +0,0 @@ -../../../../components/raybri/raybriConst.c \ No newline at end of file