From b420ca74047e26d03bb107b66c50108b153b4ce1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 26 Jun 2020 18:35:48 +0200 Subject: [PATCH] Add GLFW_CONTEXT_DEBUG window hint alias This adds GLFW_CONTEXT_DEBUG as a preferred alias for the GLFW_OPENGL_DEBUG_CONTEXT window hint, as debug contexts are defined for both OpenGL and OpenGL ES. Related to #1720. --- docs/compat.dox | 18 ++++++++---------- docs/news.dox | 1 + docs/window.dox | 12 +++++++----- include/GLFW/glfw3.h | 11 ++++++++--- src/window.c | 4 ++-- tests/glfwinfo.c | 4 ++-- 6 files changed, 28 insertions(+), 22 deletions(-) diff --git a/docs/compat.dox b/docs/compat.dox index 8aba6698..5b264b3f 100644 --- a/docs/compat.dox +++ b/docs/compat.dox @@ -163,10 +163,9 @@ multisampling anti-aliasing. Where this extension is unavailable, the GLFW uses the `GLX_ARB_create_context` extension when available, even when creating OpenGL contexts of version 2.1 and below. Where this extension is unavailable, the `GLFW_CONTEXT_VERSION_MAJOR` and `GLFW_CONTEXT_VERSION_MINOR` -hints will only be partially supported, the `GLFW_OPENGL_DEBUG_CONTEXT` hint -will have no effect, and setting the `GLFW_OPENGL_PROFILE` or -`GLFW_OPENGL_FORWARD_COMPAT` hints to `GLFW_TRUE` will cause @ref -glfwCreateWindow to fail. +hints will only be partially supported, the `GLFW_CONTEXT_DEBUG` hint will have +no effect, and setting the `GLFW_OPENGL_PROFILE` or `GLFW_OPENGL_FORWARD_COMPAT` +hints to `GLFW_TRUE` will cause @ref glfwCreateWindow to fail. GLFW uses the `GLX_ARB_create_context_profile` extension to provide support for context profiles. Where this extension is unavailable, setting the @@ -206,10 +205,9 @@ unavailable, the `GLFW_SAMPLES` hint will have no effect. GLFW uses the `WGL_ARB_create_context` extension when available, even when creating OpenGL contexts of version 2.1 and below. Where this extension is unavailable, the `GLFW_CONTEXT_VERSION_MAJOR` and `GLFW_CONTEXT_VERSION_MINOR` -hints will only be partially supported, the `GLFW_OPENGL_DEBUG_CONTEXT` hint -will have no effect, and setting the `GLFW_OPENGL_PROFILE` or -`GLFW_OPENGL_FORWARD_COMPAT` hints to `GLFW_TRUE` will cause @ref -glfwCreateWindow to fail. +hints will only be partially supported, the `GLFW_CONTEXT_DEBUG` hint will have +no effect, and setting the `GLFW_OPENGL_PROFILE` or `GLFW_OPENGL_FORWARD_COMPAT` +hints to `GLFW_TRUE` will cause @ref glfwCreateWindow to fail. GLFW uses the `WGL_ARB_create_context_profile` extension to provide support for context profiles. Where this extension is unavailable, setting the @@ -239,13 +237,13 @@ Because of this, on OS X 10.7 and later, the `GLFW_CONTEXT_VERSION_MAJOR` and `GLFW_CONTEXT_VERSION_MINOR` hints will cause @ref glfwCreateWindow to fail if given version 3.0 or 3.1. The `GLFW_OPENGL_PROFILE` hint must be set to `GLFW_OPENGL_CORE_PROFILE` when creating OpenGL 3.2 and later contexts. The -`GLFW_OPENGL_DEBUG_CONTEXT` and `GLFW_CONTEXT_NO_ERROR` hints are ignored. +`GLFW_CONTEXT_DEBUG` and `GLFW_CONTEXT_NO_ERROR` hints are ignored. Also, on Mac OS X 10.6 and below, the `GLFW_CONTEXT_VERSION_MAJOR` and `GLFW_CONTEXT_VERSION_MINOR` hints will fail if given a version above 2.1, setting the `GLFW_OPENGL_PROFILE` or `GLFW_OPENGL_FORWARD_COMPAT` hints to a non-default value will cause @ref glfwCreateWindow to fail and the -`GLFW_OPENGL_DEBUG_CONTEXT` hint is ignored. +`GLFW_CONTEXT_DEBUG` hint is ignored. @section compat_vulkan Vulkan loader and API diff --git a/docs/news.dox b/docs/news.dox index 0b948356..64421025 100644 --- a/docs/news.dox +++ b/docs/news.dox @@ -91,6 +91,7 @@ then GLFW will fail to initialize. - @ref GLFW_NOT_ALLOWED_CURSOR - @ref GLFW_CURSOR_UNAVAILABLE - @ref GLFW_WIN32_KEYBOARD_MENU + - @ref GLFW_CONTEXT_DEBUG @section news_archive Release notes for earlier versions diff --git a/docs/window.dox b/docs/window.dox index 4c762408..ddd75147 100644 --- a/docs/window.dox +++ b/docs/window.dox @@ -405,10 +405,11 @@ version is 3.0 or above. If OpenGL ES is requested, this hint is ignored. Forward-compatibility is described in detail in the [OpenGL Reference Manual](https://www.opengl.org/registry/). +@anchor GLFW_CONTEXT_DEBUG_hint @anchor GLFW_OPENGL_DEBUG_CONTEXT_hint -__GLFW_OPENGL_DEBUG_CONTEXT__ specifies whether the context should be created -in debug mode, which may provide additional error and diagnostic reporting -functionality. Possible values are `GLFW_TRUE` and `GLFW_FALSE`. +__GLFW_CONTEXT_DEBUG__ specifies whether the context should be created in debug +mode, which may provide additional error and diagnostic reporting functionality. +Possible values are `GLFW_TRUE` and `GLFW_FALSE`. @par Debug contexts for OpenGL and OpenGL ES are described in detail by the @@ -545,7 +546,7 @@ GLFW_CONTEXT_VERSION_MINOR | 0 | Any valid minor ve GLFW_CONTEXT_ROBUSTNESS | `GLFW_NO_ROBUSTNESS` | `GLFW_NO_ROBUSTNESS`, `GLFW_NO_RESET_NOTIFICATION` or `GLFW_LOSE_CONTEXT_ON_RESET` GLFW_CONTEXT_RELEASE_BEHAVIOR | `GLFW_ANY_RELEASE_BEHAVIOR` | `GLFW_ANY_RELEASE_BEHAVIOR`, `GLFW_RELEASE_BEHAVIOR_FLUSH` or `GLFW_RELEASE_BEHAVIOR_NONE` GLFW_OPENGL_FORWARD_COMPAT | `GLFW_FALSE` | `GLFW_TRUE` or `GLFW_FALSE` -GLFW_OPENGL_DEBUG_CONTEXT | `GLFW_FALSE` | `GLFW_TRUE` or `GLFW_FALSE` +GLFW_CONTEXT_DEBUG | `GLFW_FALSE` | `GLFW_TRUE` or `GLFW_FALSE` GLFW_OPENGL_PROFILE | `GLFW_OPENGL_ANY_PROFILE` | `GLFW_OPENGL_ANY_PROFILE`, `GLFW_OPENGL_COMPAT_PROFILE` or `GLFW_OPENGL_CORE_PROFILE` GLFW_WIN32_KEYBOARD_MENU | `GLFW_FALSE` | `GLFW_TRUE` or `GLFW_FALSE` GLFW_COCOA_RETINA_FRAMEBUFFER | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE` @@ -1338,8 +1339,9 @@ of the GLFW header. __GLFW_OPENGL_FORWARD_COMPAT__ is `GLFW_TRUE` if the window's context is an OpenGL forward-compatible one, or `GLFW_FALSE` otherwise. +@anchor GLFW_CONTEXT_DEBUG_attrib @anchor GLFW_OPENGL_DEBUG_CONTEXT_attrib -__GLFW_OPENGL_DEBUG_CONTEXT__ is `GLFW_TRUE` if the window's context is in debug +__GLFW_CONTEXT_DEBUG__ is `GLFW_TRUE` if the window's context is in debug mode, or `GLFW_FALSE` otherwise. @anchor GLFW_OPENGL_PROFILE_attrib diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index 31f5cc93..c5785bfe 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -1014,10 +1014,15 @@ extern "C" { #define GLFW_OPENGL_FORWARD_COMPAT 0x00022006 /*! @brief Debug mode context hint and attribute. * - * Debug mode context [hint](@ref GLFW_OPENGL_DEBUG_CONTEXT_hint) and - * [attribute](@ref GLFW_OPENGL_DEBUG_CONTEXT_attrib). + * Debug mode context [hint](@ref GLFW_CONTEXT_DEBUG_hint) and + * [attribute](@ref GLFW_CONTEXT_DEBUG_attrib). */ -#define GLFW_OPENGL_DEBUG_CONTEXT 0x00022007 +#define GLFW_CONTEXT_DEBUG 0x00022007 +/*! @brief Legacy name for compatibility. + * + * This is an alias for compatibility with earlier versions. + */ +#define GLFW_OPENGL_DEBUG_CONTEXT GLFW_CONTEXT_DEBUG /*! @brief OpenGL profile hint and attribute. * * OpenGL profile [hint](@ref GLFW_OPENGL_PROFILE_hint) and diff --git a/src/window.c b/src/window.c index bb5ba956..4716cd09 100644 --- a/src/window.c +++ b/src/window.c @@ -396,7 +396,7 @@ GLFWAPI void glfwWindowHint(int hint, int value) case GLFW_OPENGL_FORWARD_COMPAT: _glfw.hints.context.forward = value ? GLFW_TRUE : GLFW_FALSE; return; - case GLFW_OPENGL_DEBUG_CONTEXT: + case GLFW_CONTEXT_DEBUG: _glfw.hints.context.debug = value ? GLFW_TRUE : GLFW_FALSE; return; case GLFW_CONTEXT_NO_ERROR: @@ -846,7 +846,7 @@ GLFWAPI int glfwGetWindowAttrib(GLFWwindow* handle, int attrib) return window->context.robustness; case GLFW_OPENGL_FORWARD_COMPAT: return window->context.forward; - case GLFW_OPENGL_DEBUG_CONTEXT: + case GLFW_CONTEXT_DEBUG: return window->context.debug; case GLFW_OPENGL_PROFILE: return window->context.profile; diff --git a/tests/glfwinfo.c b/tests/glfwinfo.c index 0ea23fd6..e4b02dcd 100644 --- a/tests/glfwinfo.c +++ b/tests/glfwinfo.c @@ -422,7 +422,7 @@ int main(int argc, char** argv) break; case 'd': case DEBUG_CONTEXT: - glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GLFW_TRUE); + glfwWindowHint(GLFW_CONTEXT_DEBUG, GLFW_TRUE); break; case 'f': case FORWARD: @@ -639,7 +639,7 @@ int main(int argc, char** argv) if (glfwGetWindowAttrib(window, GLFW_OPENGL_FORWARD_COMPAT)) printf(" forward-compatible"); - if (glfwGetWindowAttrib(window, GLFW_OPENGL_DEBUG_CONTEXT)) + if (glfwGetWindowAttrib(window, GLFW_CONTEXT_DEBUG)) printf(" debug"); if (glfwGetWindowAttrib(window, GLFW_CONTEXT_ROBUSTNESS) == GLFW_LOSE_CONTEXT_ON_RESET) printf(" robustness");