From 04f21abb52e557addb932af1634b29658fd3a6ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 13 May 2021 21:38:46 +0200 Subject: [PATCH] Make GLFW_DOUBLEBUFFER a window attribute --- README.md | 1 + docs/window.dox | 14 +++++++++++--- include/GLFW/glfw3.h | 5 +++-- src/internal.h | 1 + src/window.c | 4 ++++ 5 files changed, 20 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 54dcec80..8f81dc67 100644 --- a/README.md +++ b/README.md @@ -130,6 +130,7 @@ information on what to include when reporting a bug. - Added `GLFW_X11_XCB_VULKAN_SURFACE` init hint for selecting X11 Vulkan surface extension (#1793) - Made joystick subsystem initialize at first use (#1284,#1646) + - Made `GLFW_DOUBLEBUFFER` a read-only window attribute - Updated the minimum required CMake version to 3.1 - Disabled tests and examples by default when built as a CMake subdirectory - Bugfix: The CMake config-file package used an absolute path and was not diff --git a/docs/window.dox b/docs/window.dox index f72edaed..5e482431 100644 --- a/docs/window.dox +++ b/docs/window.dox @@ -310,6 +310,7 @@ rendering will be disabled. always have sRGB rendering enabled. @anchor GLFW_DOUBLEBUFFER +@anchor GLFW_DOUBLEBUFFER_hint __GLFW_DOUBLEBUFFER__ specifies whether the framebuffer should be double buffered. You nearly always want to use double buffering. This is a hard constraint. Possible values are `GLFW_TRUE` and `GLFW_FALSE`. @@ -1377,9 +1378,11 @@ if the window's context supports robustness, or `GLFW_NO_ROBUSTNESS` otherwise. @subsubsection window_attribs_fb Framebuffer related attributes -GLFW does not expose attributes of the default framebuffer (i.e. the framebuffer -attached to the window) as these can be queried directly with either OpenGL, -OpenGL ES or Vulkan. +GLFW does not expose most attributes of the default framebuffer (i.e. the +framebuffer attached to the window) as these can be queried directly with either +OpenGL, OpenGL ES or Vulkan. The one exception is +[GLFW_DOUBLEBUFFER](@ref GLFW_DOUBLEBUFFER_attrib), as this is not provided by +OpenGL ES. If you are using version 3.0 or later of OpenGL or OpenGL ES, the `glGetFramebufferAttachmentParameteriv` function can be used to retrieve the @@ -1405,6 +1408,11 @@ alpha sizes are queried from the `GL_BACK_LEFT`, while the depth and stencil sizes are queried from the `GL_DEPTH` and `GL_STENCIL` attachments, respectively. +@anchor GLFW_DOUBLEBUFFER_attrib +__GLFW_DOUBLEBUFFER__ indicates whether the specified window is double-buffered +when rendering with OpenGL or OpenGL ES. This can be set before creation with +the [GLFW_DOUBLEBUFFER](@ref GLFW_DOUBLEBUFFER_hint) window hint. + @section buffer_swap Buffer swapping diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index e3cda682..7728dad1 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -978,9 +978,10 @@ extern "C" { * Monitor refresh rate [hint](@ref GLFW_REFRESH_RATE). */ #define GLFW_REFRESH_RATE 0x0002100F -/*! @brief Framebuffer double buffering hint. +/*! @brief Framebuffer double buffering hint and attribute. * - * Framebuffer double buffering [hint](@ref GLFW_DOUBLEBUFFER). + * Framebuffer double buffering [hint](@ref GLFW_DOUBLEBUFFER_hint) and + * [attribute](@ref GLFW_DOUBLEBUFFER_attrib). */ #define GLFW_DOUBLEBUFFER 0x00021010 diff --git a/src/internal.h b/src/internal.h index dc1771a7..ce9783f9 100644 --- a/src/internal.h +++ b/src/internal.h @@ -387,6 +387,7 @@ struct _GLFWwindow GLFWbool mousePassthrough; GLFWbool shouldClose; void* userPointer; + GLFWbool doublebuffer; GLFWvidmode videoMode; _GLFWmonitor* monitor; _GLFWcursor* cursor; diff --git a/src/window.c b/src/window.c index d2196e2f..518b27fd 100644 --- a/src/window.c +++ b/src/window.c @@ -206,6 +206,8 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height, window->mousePassthrough = wndconfig.mousePassthrough; window->cursorMode = GLFW_CURSOR_NORMAL; + window->doublebuffer = fbconfig.doublebuffer; + window->minwidth = GLFW_DONT_CARE; window->minheight = GLFW_DONT_CARE; window->maxwidth = GLFW_DONT_CARE; @@ -841,6 +843,8 @@ GLFWAPI int glfwGetWindowAttrib(GLFWwindow* handle, int attrib) return window->floating; case GLFW_AUTO_ICONIFY: return window->autoIconify; + case GLFW_DOUBLEBUFFER: + return window->doublebuffer; case GLFW_CLIENT_API: return window->context.client; case GLFW_CONTEXT_CREATION_API: