Compare commits

...

11 Commits

Author SHA1 Message Date
Tianlan Zhou
0750adb89d
Merge 1bd20df533 into 63a7e8b7f8 2025-08-21 01:43:16 +02:00
Camilla Löwy
63a7e8b7f8 Add and update Wayland-specific notes in docs
Fixes #2746
2025-08-20 20:13:07 +02:00
Doug Binks
acb92944d4 Revert readme for "Wayland: Keyboard leave event handler now processes key repeats" 2025-08-19 11:30:52 +02:00
SuperSodaSea
1bd20df533
Merge branch 'master' into feature/acceleration 2024-05-24 20:49:57 +08:00
Tianlan Zhou
475ba17351
Merge branch 'master' into feature/acceleration 2024-02-21 22:10:58 +08:00
SuperSodaSea
cac3fd18a0
Update context.c 2024-02-20 23:14:21 +08:00
SuperSodaSea
2c28530875
Update context.c & glfwinfo.c 2024-02-20 22:59:54 +08:00
SuperSodaSea
dc7c52ed31
Update CONTRIBUTORS.md 2024-02-20 22:25:45 +08:00
SuperSodaSea
456bb88748
Update win32_platform.h 2024-02-20 22:14:20 +08:00
SuperSodaSea
f447b250bf
Update README.md 2024-02-20 22:11:23 +08:00
SuperSodaSea
49d8b1ff11
Added GLFW_ACCELERATION window hint for hardware acceleration 2024-02-20 22:04:14 +08:00
12 changed files with 129 additions and 44 deletions

View File

@ -55,6 +55,7 @@ video tutorials.
- Jason Daly - Jason Daly
- danhambleton - danhambleton
- Jarrod Davis - Jarrod Davis
- decce
- Olivier Delannoy - Olivier Delannoy
- Paul R. Deppe - Paul R. Deppe
- Michael Dickens - Michael Dickens
@ -291,6 +292,7 @@ video tutorials.
- Ryogo Yoshimura - Ryogo Yoshimura
- Lukas Zanner - Lukas Zanner
- Andrey Zholos - Andrey Zholos
- Tianlan Zhou
- Aihui Zhu - Aihui Zhu
- Santi Zupancic - Santi Zupancic
- Jonas Ådahl - Jonas Ådahl

View File

@ -134,7 +134,6 @@ information on what to include when reporting a bug.
- [Wayland] Bugfix: Ignore key repeat events when no window has keyboard focus (#2727) - [Wayland] Bugfix: Ignore key repeat events when no window has keyboard focus (#2727)
- [Wayland] Bugfix: Reset key repeat timer when window destroyed (#2741,#2727) - [Wayland] Bugfix: Reset key repeat timer when window destroyed (#2741,#2727)
- [Wayland] Bugfix: Memory would leak if reading a data offer failed midway - [Wayland] Bugfix: Memory would leak if reading a data offer failed midway
- [Wayland] Bugfix: Keyboard leave event handler now processes key repeats (#2736)
- [Wayland] Bugfix: Retrieved cursor position would be incorrect when hovering over - [Wayland] Bugfix: Retrieved cursor position would be incorrect when hovering over
fallback decorations fallback decorations
- [Wayland] Bugfix: Fallback decorations would report scroll events - [Wayland] Bugfix: Fallback decorations would report scroll events
@ -149,6 +148,7 @@ information on what to include when reporting a bug.
- [Null] Added EGL context creation on Mesa via `EGL_MESA_platform_surfaceless` - [Null] Added EGL context creation on Mesa via `EGL_MESA_platform_surfaceless`
- [EGL] Allowed native access on Wayland with `GLFW_CONTEXT_CREATION_API` set to - [EGL] Allowed native access on Wayland with `GLFW_CONTEXT_CREATION_API` set to
`GLFW_NATIVE_CONTEXT_API` (#2518) `GLFW_NATIVE_CONTEXT_API` (#2518)
- Added `GLFW_ACCELERATION` window hint for hardware acceleration (#2491)
## Contact ## Contact

View File

@ -255,3 +255,7 @@ hardware gamma correction, which today is typically an approximation of sRGB
gamma. This means that setting a perfectly linear ramp, or gamma 1.0, will gamma. This means that setting a perfectly linear ramp, or gamma 1.0, will
produce the default (usually sRGB-like) behavior. produce the default (usually sRGB-like) behavior.
@note @wayland An application cannot read or modify the monitor gamma ramp. The
@ref glfwGetGammaRamp, @ref glfwSetGammaRamp and @ref glfwSetGamma functions
emit @ref GLFW_FEATURE_UNAVAILABLE.

View File

@ -14,8 +14,25 @@ values over 8. For compatibility with older versions, the
@ref GLFW_UNLIMITED_MOUSE_BUTTONS input mode needs to be set to make use of @ref GLFW_UNLIMITED_MOUSE_BUTTONS input mode needs to be set to make use of
this. this.
### Window hint for hardware acceleration {#acceleration}
You can use window hint [GLFW_ACCELERATION](@ref GLFW_ACCELERATION_hint) to
specify whether hardware acceleration is preferred or not. The default value
is to prefer hardware acceleration. You can get whether hardware acceleration
is enabled with the window attribute
[GLFW_ACCELERATION](@ref GLFW_ACCELERATION_attrib). This feature is only
available on WGL currently.
## Caveats {#caveats} ## Caveats {#caveats}
### Microsoft GDI software OpenGL ICD support {#gdi_opengl_icd}
GLFW now supports creating window when the Microsoft GDI software OpenGL ICD is
the only available implementation.
See [GLFW_ACCELERATION](@ref GLFW_ACCELERATION_hint) for more details.
## Deprecations {#deprecations} ## Deprecations {#deprecations}
## Removals {#removals} ## Removals {#removals}
@ -52,4 +69,3 @@ actively maintained and available on many platforms.
- [Release notes for 3.2](https://www.glfw.org/docs/3.2/news.html) - [Release notes for 3.2](https://www.glfw.org/docs/3.2/news.html)
- [Release notes for 3.1](https://www.glfw.org/docs/3.1/news.html) - [Release notes for 3.1](https://www.glfw.org/docs/3.1/news.html)
- [Release notes for 3.0](https://www.glfw.org/docs/3.0/news.html) - [Release notes for 3.0](https://www.glfw.org/docs/3.0/news.html)

View File

@ -336,6 +336,15 @@ __GLFW_DOUBLEBUFFER__ specifies whether the framebuffer should be double
buffered. You nearly always want to use double buffering. This is a hard buffered. You nearly always want to use double buffering. This is a hard
constraint. Possible values are `GLFW_TRUE` and `GLFW_FALSE`. constraint. Possible values are `GLFW_TRUE` and `GLFW_FALSE`.
@anchor GLFW_ACCELERATION
@anchor GLFW_ACCELERATION_hint
__GLFW_ACCELERATION__ specifies whether the hardware acceleration should be
preferred. By default, hardware acceleration is preferred, and will fallback
to no acceleration if hardware acceleration is unavailable. Possible values
are `GLFW_TRUE` and `GLFW_FALSE`.
This hint only has an effect on WGL.
#### Monitor related hints {#window_hints_mtr} #### Monitor related hints {#window_hints_mtr}
@ -893,6 +902,12 @@ int xpos, ypos;
glfwGetWindowPos(window, &xpos, &ypos); glfwGetWindowPos(window, &xpos, &ypos);
``` ```
@note @wayland An applications cannot know the positions of its windows or
whether one has been moved. The @ref GLFW_POSITION_X and @ref GLFW_POSITION_Y
window hints are ignored. The @ref glfwGetWindowPos and @ref glfwSetWindowPos
functions emit @ref GLFW_FEATURE_UNAVAILABLE. The window position callback will
not be called.
### Window title {#window_title} ### Window title {#window_title}
@ -1038,6 +1053,12 @@ You can also get the current iconification state with @ref glfwGetWindowAttrib.
int iconified = glfwGetWindowAttrib(window, GLFW_ICONIFIED); int iconified = glfwGetWindowAttrib(window, GLFW_ICONIFIED);
``` ```
@note @wayland An application cannot know if any of its windows have been
iconified or restore one from iconification. The @ref glfwRestoreWindow
function can only restore windows from maximization and the iconify callback
will not be called. The [GLFW_ICONIFIED](@ref GLFW_ICONIFIED_attrib) attribute
will be false. The @ref glfwIconifyWindow function works normally.
### Window maximization {#window_maximize} ### Window maximization {#window_maximize}
@ -1487,6 +1508,11 @@ __GLFW_DOUBLEBUFFER__ indicates whether the specified window is double-buffered
when rendering with OpenGL or OpenGL ES. This can be set before creation with when rendering with OpenGL or OpenGL ES. This can be set before creation with
the [GLFW_DOUBLEBUFFER](@ref GLFW_DOUBLEBUFFER_hint) window hint. the [GLFW_DOUBLEBUFFER](@ref GLFW_DOUBLEBUFFER_hint) window hint.
@anchor GLFW_ACCELERATION_attrib
__GLFW_ACCELERATION__ indicates whether the specified window is hardware
accelerated when rendering with OpenGL or OpenGL ES. This can be set before
creation with the [GLFW_ACCELERATION](@ref GLFW_ACCELERATION_hint) window hint.
## Buffer swapping {#buffer_swap} ## Buffer swapping {#buffer_swap}

View File

@ -1022,6 +1022,14 @@ extern "C" {
* [attribute](@ref GLFW_DOUBLEBUFFER_attrib). * [attribute](@ref GLFW_DOUBLEBUFFER_attrib).
*/ */
#define GLFW_DOUBLEBUFFER 0x00021010 #define GLFW_DOUBLEBUFFER 0x00021010
/*! @brief Hardware acceleration hint.
*
* Hardware acceleration [hint](@ref GLFW_ACCELERATION_hint) and
* [attribute](@ref GLFW_ACCELERATION_attrib).
*
* @since Added in version 3.4.
*/
#define GLFW_ACCELERATION 0x00021011
/*! @brief Context client API hint and attribute. /*! @brief Context client API hint and attribute.
* *
@ -2915,8 +2923,8 @@ GLFWAPI const GLFWvidmode* glfwGetVideoMode(GLFWmonitor* monitor);
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref GLFW_INVALID_VALUE, * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref GLFW_INVALID_VALUE,
* @ref GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks). * @ref GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks).
* *
* @remark @wayland Gamma handling is a privileged protocol, this function * @remark @wayland Monitor gamma is a privileged protocol, so this function
* will thus never be implemented and emits @ref GLFW_FEATURE_UNAVAILABLE. * cannot be implemented and emits @ref GLFW_FEATURE_UNAVAILABLE.
* *
* @thread_safety This function must only be called from the main thread. * @thread_safety This function must only be called from the main thread.
* *
@ -2939,8 +2947,8 @@ GLFWAPI void glfwSetGamma(GLFWmonitor* monitor, float gamma);
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref GLFW_PLATFORM_ERROR * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref GLFW_PLATFORM_ERROR
* and @ref GLFW_FEATURE_UNAVAILABLE (see remarks). * and @ref GLFW_FEATURE_UNAVAILABLE (see remarks).
* *
* @remark @wayland Gamma handling is a privileged protocol, this function * @remark @wayland Monitor gamma is a privileged protocol, so this function
* will thus never be implemented and emits @ref GLFW_FEATURE_UNAVAILABLE while * cannot be implemented and emits @ref GLFW_FEATURE_UNAVAILABLE while
* returning `NULL`. * returning `NULL`.
* *
* @pointer_lifetime The returned structure and its arrays are allocated and * @pointer_lifetime The returned structure and its arrays are allocated and
@ -2983,8 +2991,8 @@ GLFWAPI const GLFWgammaramp* glfwGetGammaRamp(GLFWmonitor* monitor);
* *
* @remark @win32 The gamma ramp size must be 256. * @remark @win32 The gamma ramp size must be 256.
* *
* @remark @wayland Gamma handling is a privileged protocol, this function * @remark @wayland Monitor gamma is a privileged protocol, so this function
* will thus never be implemented and emits @ref GLFW_FEATURE_UNAVAILABLE. * cannot be implemented and emits @ref GLFW_FEATURE_UNAVAILABLE.
* *
* @pointer_lifetime The specified gamma ramp is copied before this function * @pointer_lifetime The specified gamma ramp is copied before this function
* returns. * returns.
@ -3159,9 +3167,6 @@ GLFWAPI void glfwWindowHintString(int hint, const char* value);
* GLFW_VERSION_UNAVAILABLE, @ref GLFW_FORMAT_UNAVAILABLE, @ref * GLFW_VERSION_UNAVAILABLE, @ref GLFW_FORMAT_UNAVAILABLE, @ref
* GLFW_NO_WINDOW_CONTEXT and @ref GLFW_PLATFORM_ERROR. * GLFW_NO_WINDOW_CONTEXT and @ref GLFW_PLATFORM_ERROR.
* *
* @remark @win32 Window creation will fail if the Microsoft GDI software
* OpenGL implementation is the only one available.
*
* @remark @win32 If the executable has an icon resource named `GLFW_ICON,` it * @remark @win32 If the executable has an icon resource named `GLFW_ICON,` it
* will be set as the initial icon for the window. If no such icon is present, * will be set as the initial icon for the window. If no such icon is present,
* the `IDI_APPLICATION` icon will be used instead. To set a different icon, * the `IDI_APPLICATION` icon will be used instead. To set a different icon,
@ -3430,8 +3435,8 @@ GLFWAPI void glfwSetWindowIcon(GLFWwindow* window, int count, const GLFWimage* i
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
* GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks). * GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks).
* *
* @remark @wayland There is no way for an application to retrieve the global * @remark @wayland Window positions are not currently part of any common
* position of its windows. This function will emit @ref * Wayland protocol, so this function cannot be implemented and will emit @ref
* GLFW_FEATURE_UNAVAILABLE. * GLFW_FEATURE_UNAVAILABLE.
* *
* @thread_safety This function must only be called from the main thread. * @thread_safety This function must only be called from the main thread.
@ -3464,8 +3469,8 @@ GLFWAPI void glfwGetWindowPos(GLFWwindow* window, int* xpos, int* ypos);
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
* GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks). * GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks).
* *
* @remark @wayland There is no way for an application to set the global * @remark @wayland Window positions are not currently part of any common
* position of its windows. This function will emit @ref * Wayland protocol, so this function cannot be implemented and will emit @ref
* GLFW_FEATURE_UNAVAILABLE. * GLFW_FEATURE_UNAVAILABLE.
* *
* @thread_safety This function must only be called from the main thread. * @thread_safety This function must only be called from the main thread.
@ -3807,10 +3812,6 @@ GLFWAPI void glfwSetWindowOpacity(GLFWwindow* window, float opacity);
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
* GLFW_PLATFORM_ERROR. * GLFW_PLATFORM_ERROR.
* *
* @remark @wayland Once a window is iconified, @ref glfwRestoreWindow wont
* be able to restore it. This is a design decision of the xdg-shell
* protocol.
*
* @thread_safety This function must only be called from the main thread. * @thread_safety This function must only be called from the main thread.
* *
* @sa @ref window_iconify * @sa @ref window_iconify
@ -3838,6 +3839,10 @@ GLFWAPI void glfwIconifyWindow(GLFWwindow* window);
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
* GLFW_PLATFORM_ERROR. * GLFW_PLATFORM_ERROR.
* *
* @remark @wayland Restoring a window from maximization is not currently part
* of any common Wayland protocol, so this function can only restore windows
* from maximization.
*
* @thread_safety This function must only be called from the main thread. * @thread_safety This function must only be called from the main thread.
* *
* @sa @ref window_iconify * @sa @ref window_iconify
@ -4058,8 +4063,8 @@ GLFWAPI GLFWmonitor* glfwGetWindowMonitor(GLFWwindow* window);
* affected by any resizing or mode switching, although you may need to update * affected by any resizing or mode switching, although you may need to update
* your viewport if the framebuffer size has changed. * your viewport if the framebuffer size has changed.
* *
* @remark @wayland The desired window position is ignored, as there is no way * @remark @wayland Window positions are not currently part of any common
* for an application to set this property. * Wayland protocol. The window position arguments are ignored.
* *
* @thread_safety This function must only be called from the main thread. * @thread_safety This function must only be called from the main thread.
* *
@ -4096,8 +4101,9 @@ GLFWAPI void glfwSetWindowMonitor(GLFWwindow* window, GLFWmonitor* monitor, int
* errors. However, this function should not fail as long as it is passed * errors. However, this function should not fail as long as it is passed
* valid arguments and the library has been [initialized](@ref intro_init). * valid arguments and the library has been [initialized](@ref intro_init).
* *
* @remark @wayland The Wayland protocol provides no way to check whether a * @remark @wayland Checking whether a window is iconified is not currently
* window is iconfied, so @ref GLFW_ICONIFIED always returns `GLFW_FALSE`. * part of any common Wayland protocol, so the @ref GLFW_ICONIFIED attribute
* cannot be implemented and is always `GLFW_FALSE`.
* *
* @thread_safety This function must only be called from the main thread. * @thread_safety This function must only be called from the main thread.
* *
@ -4219,8 +4225,8 @@ GLFWAPI void* glfwGetWindowUserPointer(GLFWwindow* window);
* *
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
* *
* @remark @wayland This callback will never be called, as there is no way for * @remark @wayland This callback will not be called. The Wayland protocol
* an application to know its global position. * provides no way to be notified of when a window is moved.
* *
* @thread_safety This function must only be called from the main thread. * @thread_safety This function must only be called from the main thread.
* *
@ -4395,6 +4401,10 @@ GLFWAPI GLFWwindowfocusfun glfwSetWindowFocusCallback(GLFWwindow* window, GLFWwi
* *
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
* *
* @remark @wayland This callback will not be called. The Wayland protocol
* provides no way to be notified of when a window is iconified, and no way to
* check whether a window is currently iconified.
*
* @thread_safety This function must only be called from the main thread. * @thread_safety This function must only be called from the main thread.
* *
* @sa @ref window_iconify * @sa @ref window_iconify

View File

@ -28,10 +28,10 @@
#include "internal.h" #include "internal.h"
#include <assert.h> #include <assert.h>
#include <limits.h>
#include <stdbool.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <limits.h>
#include <stdio.h>
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
@ -185,6 +185,7 @@ const _GLFWfbconfig* _glfwChooseFBConfig(const _GLFWfbconfig* desired,
unsigned int count) unsigned int count)
{ {
unsigned int i; unsigned int i;
bool accelerationMatch, closestAccelerationMatch = false;
unsigned int missing, leastMissing = UINT_MAX; unsigned int missing, leastMissing = UINT_MAX;
unsigned int colorDiff, leastColorDiff = UINT_MAX; unsigned int colorDiff, leastColorDiff = UINT_MAX;
unsigned int extraDiff, leastExtraDiff = UINT_MAX; unsigned int extraDiff, leastExtraDiff = UINT_MAX;
@ -201,6 +202,8 @@ const _GLFWfbconfig* _glfwChooseFBConfig(const _GLFWfbconfig* desired,
continue; continue;
} }
accelerationMatch = desired->acceleration == current->acceleration;
// Count number of missing buffers // Count number of missing buffers
{ {
missing = 0; missing = 0;
@ -318,6 +321,10 @@ const _GLFWfbconfig* _glfwChooseFBConfig(const _GLFWfbconfig* desired,
// Least number of missing buffers is the most important heuristic, // Least number of missing buffers is the most important heuristic,
// then color buffer size match and lastly size match for other buffers // then color buffer size match and lastly size match for other buffers
if (accelerationMatch && !closestAccelerationMatch)
closest = current;
else if (accelerationMatch == closestAccelerationMatch)
{
if (missing < leastMissing) if (missing < leastMissing)
closest = current; closest = current;
else if (missing == leastMissing) else if (missing == leastMissing)
@ -328,9 +335,11 @@ const _GLFWfbconfig* _glfwChooseFBConfig(const _GLFWfbconfig* desired,
closest = current; closest = current;
} }
} }
}
if (current == closest) if (current == closest)
{ {
closestAccelerationMatch = accelerationMatch;
leastMissing = missing; leastMissing = missing;
leastColorDiff = colorDiff; leastColorDiff = colorDiff;
leastExtraDiff = extraDiff; leastExtraDiff = extraDiff;

View File

@ -481,6 +481,7 @@ struct _GLFWfbconfig
GLFWbool sRGB; GLFWbool sRGB;
GLFWbool doublebuffer; GLFWbool doublebuffer;
GLFWbool transparent; GLFWbool transparent;
GLFWbool acceleration;
uintptr_t handle; uintptr_t handle;
}; };
@ -541,6 +542,7 @@ struct _GLFWwindow
GLFWbool shouldClose; GLFWbool shouldClose;
void* userPointer; void* userPointer;
GLFWbool doublebuffer; GLFWbool doublebuffer;
GLFWbool acceleration;
GLFWvidmode videoMode; GLFWvidmode videoMode;
_GLFWmonitor* monitor; _GLFWmonitor* monitor;
_GLFWcursor* cursor; _GLFWcursor* cursor;

View File

@ -145,6 +145,8 @@ static int choosePixelFormatWGL(_GLFWwindow* window,
{ {
// Get pixel format attributes through "modern" extension // Get pixel format attributes through "modern" extension
int acceleration;
if (!wglGetPixelFormatAttribivARB(window->context.wgl.dc, if (!wglGetPixelFormatAttribivARB(window->context.wgl.dc,
pixelFormat, 0, pixelFormat, 0,
attribCount, attribCount,
@ -166,12 +168,11 @@ static int choosePixelFormatWGL(_GLFWwindow* window,
if (FIND_ATTRIB_VALUE(WGL_PIXEL_TYPE_ARB) != WGL_TYPE_RGBA_ARB) if (FIND_ATTRIB_VALUE(WGL_PIXEL_TYPE_ARB) != WGL_TYPE_RGBA_ARB)
continue; continue;
if (FIND_ATTRIB_VALUE(WGL_ACCELERATION_ARB) == WGL_NO_ACCELERATION_ARB)
continue;
if (FIND_ATTRIB_VALUE(WGL_DOUBLE_BUFFER_ARB) != fbconfig->doublebuffer) if (FIND_ATTRIB_VALUE(WGL_DOUBLE_BUFFER_ARB) != fbconfig->doublebuffer)
continue; continue;
acceleration = FIND_ATTRIB_VALUE(WGL_ACCELERATION_ARB);
u->redBits = FIND_ATTRIB_VALUE(WGL_RED_BITS_ARB); u->redBits = FIND_ATTRIB_VALUE(WGL_RED_BITS_ARB);
u->greenBits = FIND_ATTRIB_VALUE(WGL_GREEN_BITS_ARB); u->greenBits = FIND_ATTRIB_VALUE(WGL_GREEN_BITS_ARB);
u->blueBits = FIND_ATTRIB_VALUE(WGL_BLUE_BITS_ARB); u->blueBits = FIND_ATTRIB_VALUE(WGL_BLUE_BITS_ARB);
@ -210,6 +211,10 @@ static int choosePixelFormatWGL(_GLFWwindow* window,
u->sRGB = GLFW_TRUE; u->sRGB = GLFW_TRUE;
} }
} }
u->acceleration =
acceleration == WGL_GENERIC_ACCELERATION_ARB ||
acceleration == WGL_FULL_ACCELERATION_ARB;
} }
else else
{ {
@ -235,12 +240,6 @@ static int choosePixelFormatWGL(_GLFWwindow* window,
continue; continue;
} }
if (!(pfd.dwFlags & PFD_GENERIC_ACCELERATED) &&
(pfd.dwFlags & PFD_GENERIC_FORMAT))
{
continue;
}
if (pfd.iPixelType != PFD_TYPE_RGBA) if (pfd.iPixelType != PFD_TYPE_RGBA)
continue; continue;
@ -264,6 +263,10 @@ static int choosePixelFormatWGL(_GLFWwindow* window,
if (pfd.dwFlags & PFD_STEREO) if (pfd.dwFlags & PFD_STEREO)
u->stereo = GLFW_TRUE; u->stereo = GLFW_TRUE;
u->acceleration =
(pfd.dwFlags & PFD_GENERIC_ACCELERATED) ||
!(pfd.dwFlags & PFD_GENERIC_FORMAT);
} }
u->handle = pixelFormat; u->handle = pixelFormat;
@ -437,8 +440,6 @@ GLFWbool _glfwInitWGL(void)
// NOTE: A dummy context has to be created for opengl32.dll to load the // NOTE: A dummy context has to be created for opengl32.dll to load the
// OpenGL ICD, from which we can then query WGL extensions // OpenGL ICD, from which we can then query WGL extensions
// NOTE: This code will accept the Microsoft GDI ICD; accelerated context
// creation failure occurs during manual pixel format enumeration
dc = GetDC(_glfw.win32.helperWindowHandle); dc = GetDC(_glfw.win32.helperWindowHandle);

View File

@ -172,6 +172,8 @@ typedef enum
#define WGL_TYPE_RGBA_ARB 0x202b #define WGL_TYPE_RGBA_ARB 0x202b
#define WGL_ACCELERATION_ARB 0x2003 #define WGL_ACCELERATION_ARB 0x2003
#define WGL_NO_ACCELERATION_ARB 0x2025 #define WGL_NO_ACCELERATION_ARB 0x2025
#define WGL_GENERIC_ACCELERATION_ARB 0x2026
#define WGL_FULL_ACCELERATION_ARB 0x2027
#define WGL_RED_BITS_ARB 0x2015 #define WGL_RED_BITS_ARB 0x2015
#define WGL_RED_SHIFT_ARB 0x2016 #define WGL_RED_SHIFT_ARB 0x2016
#define WGL_GREEN_BITS_ARB 0x2017 #define WGL_GREEN_BITS_ARB 0x2017

View File

@ -235,6 +235,7 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height,
window->cursorMode = GLFW_CURSOR_NORMAL; window->cursorMode = GLFW_CURSOR_NORMAL;
window->doublebuffer = fbconfig.doublebuffer; window->doublebuffer = fbconfig.doublebuffer;
window->acceleration = fbconfig.acceleration;
window->minwidth = GLFW_DONT_CARE; window->minwidth = GLFW_DONT_CARE;
window->minheight = GLFW_DONT_CARE; window->minheight = GLFW_DONT_CARE;
@ -287,6 +288,7 @@ void glfwDefaultWindowHints(void)
_glfw.hints.framebuffer.depthBits = 24; _glfw.hints.framebuffer.depthBits = 24;
_glfw.hints.framebuffer.stencilBits = 8; _glfw.hints.framebuffer.stencilBits = 8;
_glfw.hints.framebuffer.doublebuffer = GLFW_TRUE; _glfw.hints.framebuffer.doublebuffer = GLFW_TRUE;
_glfw.hints.framebuffer.acceleration = GLFW_TRUE;
// The default is to select the highest available refresh rate // The default is to select the highest available refresh rate
_glfw.hints.refreshRate = GLFW_DONT_CARE; _glfw.hints.refreshRate = GLFW_DONT_CARE;
@ -346,6 +348,9 @@ GLFWAPI void glfwWindowHint(int hint, int value)
case GLFW_SRGB_CAPABLE: case GLFW_SRGB_CAPABLE:
_glfw.hints.framebuffer.sRGB = value ? GLFW_TRUE : GLFW_FALSE; _glfw.hints.framebuffer.sRGB = value ? GLFW_TRUE : GLFW_FALSE;
return; return;
case GLFW_ACCELERATION:
_glfw.hints.framebuffer.acceleration = value ? GLFW_TRUE : GLFW_FALSE;
return;
case GLFW_RESIZABLE: case GLFW_RESIZABLE:
_glfw.hints.window.resizable = value ? GLFW_TRUE : GLFW_FALSE; _glfw.hints.window.resizable = value ? GLFW_TRUE : GLFW_FALSE;
return; return;
@ -912,6 +917,8 @@ GLFWAPI int glfwGetWindowAttrib(GLFWwindow* handle, int attrib)
return window->autoIconify; return window->autoIconify;
case GLFW_DOUBLEBUFFER: case GLFW_DOUBLEBUFFER:
return window->doublebuffer; return window->doublebuffer;
case GLFW_ACCELERATION:
return window->acceleration;
case GLFW_CLIENT_API: case GLFW_CLIENT_API:
return window->context.client; return window->context.client;
case GLFW_CONTEXT_CREATION_API: case GLFW_CONTEXT_CREATION_API:

View File

@ -383,6 +383,7 @@ int main(int argc, char** argv)
int angle_type = GLFW_ANGLE_PLATFORM_TYPE_NONE; int angle_type = GLFW_ANGLE_PLATFORM_TYPE_NONE;
bool cocoa_graphics_switching = false; bool cocoa_graphics_switching = false;
bool disable_xcb_surface = false; bool disable_xcb_surface = false;
bool acceleration = true;
enum { PLATFORM, CLIENT, CONTEXT, BEHAVIOR, DEBUG_CONTEXT, FORWARD, HELP, enum { PLATFORM, CLIENT, CONTEXT, BEHAVIOR, DEBUG_CONTEXT, FORWARD, HELP,
EXTENSIONS, LAYERS, EXTENSIONS, LAYERS,
@ -390,7 +391,7 @@ int main(int argc, char** argv)
REDBITS, GREENBITS, BLUEBITS, ALPHABITS, DEPTHBITS, STENCILBITS, REDBITS, GREENBITS, BLUEBITS, ALPHABITS, DEPTHBITS, STENCILBITS,
ACCUMREDBITS, ACCUMGREENBITS, ACCUMBLUEBITS, ACCUMALPHABITS, ACCUMREDBITS, ACCUMGREENBITS, ACCUMBLUEBITS, ACCUMALPHABITS,
AUXBUFFERS, SAMPLES, STEREO, SRGB, SINGLEBUFFER, NOERROR_SRSLY, AUXBUFFERS, SAMPLES, STEREO, SRGB, SINGLEBUFFER, NOERROR_SRSLY,
ANGLE_TYPE, GRAPHICS_SWITCHING, XCB_SURFACE }; ANGLE_TYPE, GRAPHICS_SWITCHING, XCB_SURFACE, NO_ACCELERATION };
const struct option options[] = const struct option options[] =
{ {
{ "platform", 1, NULL, PLATFORM }, { "platform", 1, NULL, PLATFORM },
@ -426,6 +427,7 @@ int main(int argc, char** argv)
{ "angle-type", 1, NULL, ANGLE_TYPE }, { "angle-type", 1, NULL, ANGLE_TYPE },
{ "graphics-switching", 0, NULL, GRAPHICS_SWITCHING }, { "graphics-switching", 0, NULL, GRAPHICS_SWITCHING },
{ "vk-xcb-surface", 0, NULL, XCB_SURFACE }, { "vk-xcb-surface", 0, NULL, XCB_SURFACE },
{ "no-acceleration", 0, NULL, NO_ACCELERATION },
{ NULL, 0, NULL, 0 } { NULL, 0, NULL, 0 }
}; };
@ -654,6 +656,9 @@ int main(int argc, char** argv)
case XCB_SURFACE: case XCB_SURFACE:
disable_xcb_surface = true; disable_xcb_surface = true;
break; break;
case NO_ACCELERATION:
acceleration = false;
break;
default: default:
usage(); usage();
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
@ -708,6 +713,7 @@ int main(int argc, char** argv)
glfwWindowHint(GLFW_STEREO, fb_stereo); glfwWindowHint(GLFW_STEREO, fb_stereo);
glfwWindowHint(GLFW_SRGB_CAPABLE, fb_srgb); glfwWindowHint(GLFW_SRGB_CAPABLE, fb_srgb);
glfwWindowHint(GLFW_DOUBLEBUFFER, fb_doublebuffer); glfwWindowHint(GLFW_DOUBLEBUFFER, fb_doublebuffer);
glfwWindowHint(GLFW_ACCELERATION, acceleration);
glfwWindowHint(GLFW_COCOA_GRAPHICS_SWITCHING, cocoa_graphics_switching); glfwWindowHint(GLFW_COCOA_GRAPHICS_SWITCHING, cocoa_graphics_switching);