Make GLFW_DOUBLEBUFFER a window attribute

This commit is contained in:
Camilla Löwy 2021-05-13 21:38:46 +02:00
parent da236ba807
commit 04f21abb52
5 changed files with 20 additions and 5 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -387,6 +387,7 @@ struct _GLFWwindow
GLFWbool mousePassthrough;
GLFWbool shouldClose;
void* userPointer;
GLFWbool doublebuffer;
GLFWvidmode videoMode;
_GLFWmonitor* monitor;
_GLFWcursor* cursor;

View File

@ -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: