From ce85c7dcaf48be96870f2d8fec1d78b0b7d744c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 3 May 2022 19:54:08 +0200 Subject: [PATCH] Fix GLAPIENTRY not being defined for native access This is a follow-up to 535c3ce63240ee91f998219b35dc82abef545c3d. That commit made glfw3native.h undefine GLAPIENTRY whenever GLFW_EXPOSE_NATIVE_GLX or GLFW_EXPOSE_NATIVE_OSMESA was defined, on the assumption that it was glfw3.h that had defined GLAPIENTRY. If gl.h or an extension loader header has been included before glfw3.h, then it has defined inclusion guards preventing GLAPIENTRY from being defined later when the GLX or OSMesa header includes gl.h. This commit ensures GLAPIENTRY is only undefined if glfw3.h defined it. Related to #2010 --- include/GLFW/glfw3.h | 1 + include/GLFW/glfw3native.h | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index 6f189274..52225c74 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -6383,6 +6383,7 @@ GLFWAPI VkResult glfwCreateWindowSurface(VkInstance instance, GLFWwindow* window */ #ifndef GLAPIENTRY #define GLAPIENTRY APIENTRY + #define GLFW_GLAPIENTRY_DEFINED #endif /* -------------------- END SYSTEM/COMPILER SPECIFIC --------------------- */ diff --git a/include/GLFW/glfw3native.h b/include/GLFW/glfw3native.h index 7f5bf9e4..6d090778 100644 --- a/include/GLFW/glfw3native.h +++ b/include/GLFW/glfw3native.h @@ -116,7 +116,10 @@ extern "C" { * default it also acts as an OpenGL header * However, glx.h will include gl.h, which will define it unconditionally */ - #undef GLAPIENTRY + #if defined(GLFW_GLAPIENTRY_DEFINED) + #undef GLAPIENTRY + #undef GLFW_GLAPIENTRY_DEFINED + #endif #include #endif #if defined(GLFW_EXPOSE_NATIVE_EGL) @@ -127,7 +130,10 @@ extern "C" { * default it also acts as an OpenGL header * However, osmesa.h will include gl.h, which will define it unconditionally */ - #undef GLAPIENTRY + #if defined(GLFW_GLAPIENTRY_DEFINED) + #undef GLAPIENTRY + #undef GLFW_GLAPIENTRY_DEFINED + #endif #include #endif