From 821f5f5f29fc3140784eae34dd3adb36183472ac Mon Sep 17 00:00:00 2001 From: Jesse Talavera Date: Sun, 21 Jul 2024 11:02:31 -0400 Subject: [PATCH] Allow frontends to use different headers for OpenGL declarations (#2102) --- src/PlatformOGL.h | 13 ++++++++++--- src/frontend/qt_sdl/CMakeLists.txt | 8 ++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/PlatformOGL.h b/src/PlatformOGL.h index bc047807..120e8690 100644 --- a/src/PlatformOGL.h +++ b/src/PlatformOGL.h @@ -1,9 +1,16 @@ #ifndef PLATFORMOGL_H #define PLATFORMOGL_H -// if you don't wanna use glad for your platform -// add your header here! +// If you don't wanna use glad for your platform, +// define MELONDS_GL_HEADER to the path of some other header +// that pulls in the necessary OpenGL declarations. +// Make sure to include quotes or angle brackets as needed, +// and that all targets get the same MELONDS_GL_HEADER definition. -#include "frontend/glad/glad.h" +#ifndef MELONDS_GL_HEADER +#define MELONDS_GL_HEADER "\"frontend/glad/glad.h\"" +#endif + +#include MELONDS_GL_HEADER #endif diff --git a/src/frontend/qt_sdl/CMakeLists.txt b/src/frontend/qt_sdl/CMakeLists.txt index 7409d056..9cf78542 100644 --- a/src/frontend/qt_sdl/CMakeLists.txt +++ b/src/frontend/qt_sdl/CMakeLists.txt @@ -237,3 +237,11 @@ if (UNIX AND NOT APPLE) INTERPROCEDURAL_OPTIMIZATION_RELEASE OFF) endif() endif() + +if (ENABLE_OGLRENDERER) + set(MELONDS_GL_HEADER \"frontend/glad/glad.h\" CACHE STRING "Path to a header that contains OpenGL function and type declarations.") + + target_compile_definitions(melonDS PUBLIC OGLRENDERER_ENABLED) + target_compile_definitions(melonDS PUBLIC MELONDS_GL_HEADER=${MELONDS_GL_HEADER}) + target_compile_definitions(core PUBLIC MELONDS_GL_HEADER=${MELONDS_GL_HEADER}) +endif() \ No newline at end of file