mirror of
https://github.com/glfw/glfw.git
synced 2024-11-14 18:34:34 +00:00
Replace GLFWvidMode with GLFWvideoMode
Deprecates GLFWvidmode, glfwGetVideoMode, glfwGetVideoModes and glfwSetWindowMonitor. Adds GLFWvideoMode, glfwWindowHintDouble, glfwGetVideoMode2, glfwGetVideoModes2, glfwSetWindowMonitor2, glfwVideoModeGetSize, glfwVideoModeGetColorDepth, and glfwVideoModeGetRefreshRate. Fixes #230 Closes #2281
This commit is contained in:
parent
9b1f63bad9
commit
8ce52bc708
@ -98,6 +98,7 @@ video tutorials.
|
|||||||
- IntellectualKitty
|
- IntellectualKitty
|
||||||
- Aaron Jacobs
|
- Aaron Jacobs
|
||||||
- JannikGM
|
- JannikGM
|
||||||
|
- Andreas O. Jansen
|
||||||
- Erik S. V. Jansson
|
- Erik S. V. Jansson
|
||||||
- jjYBdx4IL
|
- jjYBdx4IL
|
||||||
- Toni Jovanoski
|
- Toni Jovanoski
|
||||||
|
@ -121,6 +121,12 @@ information on what to include when reporting a bug.
|
|||||||
|
|
||||||
## Changelog
|
## Changelog
|
||||||
|
|
||||||
|
- Added `glfwWindowHintDouble`, `GLFWvideoMode`, `glfwGetVideoMode2`,
|
||||||
|
`glfwGetVideoModes2`, `glfwSetWindowMonitor2`, `glfwVideoModesEqual`,
|
||||||
|
`glfwVideoModeGetSize`, `glfwVideoModeGetColorDepth` and
|
||||||
|
`glfwVideoModeGetRefreshRate` (#230)
|
||||||
|
- Deprecated `GLFWvidmode`, `glfwGetVideoMode`, `glfwGetVideoModes` and
|
||||||
|
`glfwSetWindowMonitor` (#230)
|
||||||
- Added `GLFW_PLATFORM` init hint for runtime platform selection (#1958)
|
- Added `GLFW_PLATFORM` init hint for runtime platform selection (#1958)
|
||||||
- Added `GLFW_ANY_PLATFORM`, `GLFW_PLATFORM_WIN32`, `GLFW_PLATFORM_COCOA`,
|
- Added `GLFW_ANY_PLATFORM`, `GLFW_PLATFORM_WIN32`, `GLFW_PLATFORM_COCOA`,
|
||||||
`GLFW_PLATFORM_WAYLAND`, `GLFW_PLATFORM_X11` and `GLFW_PLATFORM_NULL` symbols to
|
`GLFW_PLATFORM_WAYLAND`, `GLFW_PLATFORM_X11` and `GLFW_PLATFORM_NULL` symbols to
|
||||||
|
@ -105,20 +105,20 @@ a full screen window, change its video mode or make a windowed one full
|
|||||||
screen, but it is sometimes useful to know exactly which video modes are
|
screen, but it is sometimes useful to know exactly which video modes are
|
||||||
supported.
|
supported.
|
||||||
|
|
||||||
Video modes are represented as @ref GLFWvidmode structures. You can get an
|
Video modes are represented as @ref GLFWvideoMode objects. You can get an
|
||||||
array of the video modes supported by a monitor with @ref glfwGetVideoModes.
|
array of the video modes supported by a monitor with @ref glfwGetVideoModes2.
|
||||||
See the reference documentation for the lifetime of the returned array.
|
See the reference documentation for the lifetime of the returned array.
|
||||||
|
|
||||||
@code
|
@code
|
||||||
int count;
|
int count;
|
||||||
GLFWvidmode* modes = glfwGetVideoModes(monitor, &count);
|
const GLFWvideoMode* const * modes = glfwGetVideoModes2(monitor, &count);
|
||||||
@endcode
|
@endcode
|
||||||
|
|
||||||
To get the current video mode of a monitor call @ref glfwGetVideoMode. See the
|
To get the current video mode of a monitor call @ref glfwGetVideoMode2. See the
|
||||||
reference documentation for the lifetime of the returned pointer.
|
reference documentation for the lifetime of the returned pointer.
|
||||||
|
|
||||||
@code
|
@code
|
||||||
const GLFWvidmode* mode = glfwGetVideoMode(monitor);
|
const GLFWvideoMode* mode = glfwGetVideoMode2(monitor);
|
||||||
@endcode
|
@endcode
|
||||||
|
|
||||||
The resolution of a video mode is specified in
|
The resolution of a video mode is specified in
|
||||||
|
@ -58,7 +58,7 @@ Full screen windows cover the entire display area of a monitor, have no border
|
|||||||
or decorations.
|
or decorations.
|
||||||
|
|
||||||
Windowed mode windows can be made full screen by setting a monitor with @ref
|
Windowed mode windows can be made full screen by setting a monitor with @ref
|
||||||
glfwSetWindowMonitor, and full screen ones can be made windowed by unsetting it
|
glfwSetWindowMonitor2, and full screen ones can be made windowed by unsetting it
|
||||||
with the same function.
|
with the same function.
|
||||||
|
|
||||||
Each field of the @ref GLFWvidmode structure corresponds to a function parameter
|
Each field of the @ref GLFWvidmode structure corresponds to a function parameter
|
||||||
@ -67,18 +67,18 @@ The supported video mode most closely matching the desired video mode will be
|
|||||||
set for the chosen monitor as long as the window has input focus. For more
|
set for the chosen monitor as long as the window has input focus. For more
|
||||||
information about retrieving video modes, see @ref monitor_modes.
|
information about retrieving video modes, see @ref monitor_modes.
|
||||||
|
|
||||||
Video mode field | Corresponds to
|
Video mode field | Corresponds to | GLFWvideoMode equivalence
|
||||||
---------------- | --------------
|
---------------- | -------------- | --------------
|
||||||
GLFWvidmode.width | `width` parameter of @ref glfwCreateWindow
|
GLFWvidmode.width | `width` parameter of @ref glfwCreateWindow | @ref glfwVideoModeGetSize
|
||||||
GLFWvidmode.height | `height` parameter of @ref glfwCreateWindow
|
GLFWvidmode.height | `height` parameter of @ref glfwCreateWindow | @ref glfwVideoModeGetSize
|
||||||
GLFWvidmode.redBits | @ref GLFW_RED_BITS hint
|
GLFWvidmode.redBits | @ref GLFW_RED_BITS hint | @ref glfwVideoModeGetColorDepth
|
||||||
GLFWvidmode.greenBits | @ref GLFW_GREEN_BITS hint
|
GLFWvidmode.greenBits | @ref GLFW_GREEN_BITS hint | @ref glfwVideoModeGetColorDepth
|
||||||
GLFWvidmode.blueBits | @ref GLFW_BLUE_BITS hint
|
GLFWvidmode.blueBits | @ref GLFW_BLUE_BITS hint | @ref glfwVideoModeGetColorDepth
|
||||||
GLFWvidmode.refreshRate | @ref GLFW_REFRESH_RATE hint
|
GLFWvidmode.refreshRate | @ref GLFW_REFRESH_RATE hint | @ref glfwVideoModeGetRefreshRate
|
||||||
|
|
||||||
Once you have a full screen window, you can change its resolution, refresh rate
|
Once you have a full screen window, you can change its resolution, refresh rate
|
||||||
and monitor with @ref glfwSetWindowMonitor. If you only need change its
|
and monitor with @ref glfwSetWindowMonitor2. If you only need to change its
|
||||||
resolution you can also call @ref glfwSetWindowSize. In all cases, the new
|
resolution, you can also call @ref glfwSetWindowSize. In all cases, the new
|
||||||
video mode will be selected the same way as the video mode chosen by @ref
|
video mode will be selected the same way as the video mode chosen by @ref
|
||||||
glfwCreateWindow. If the window has an OpenGL or OpenGL ES context, it will be
|
glfwCreateWindow. If the window has an OpenGL or OpenGL ES context, it will be
|
||||||
unaffected.
|
unaffected.
|
||||||
@ -102,22 +102,33 @@ _borderless full screen_ window and counts as a full screen window. To create
|
|||||||
such a window, request the current video mode.
|
such a window, request the current video mode.
|
||||||
|
|
||||||
@code
|
@code
|
||||||
const GLFWvidmode* mode = glfwGetVideoMode(monitor);
|
const GLFWvideoMode* mode = glfwGetVideoMode2(monitor);
|
||||||
|
|
||||||
glfwWindowHint(GLFW_RED_BITS, mode->redBits);
|
int width, height;
|
||||||
glfwWindowHint(GLFW_GREEN_BITS, mode->greenBits);
|
int red, green, blue;
|
||||||
glfwWindowHint(GLFW_BLUE_BITS, mode->blueBits);
|
double refreshRate;
|
||||||
glfwWindowHint(GLFW_REFRESH_RATE, mode->refreshRate);
|
|
||||||
|
|
||||||
GLFWwindow* window = glfwCreateWindow(mode->width, mode->height, "My Title", monitor, NULL);
|
glfwVideoModeGetSize(&width, &height);
|
||||||
|
glfwVideoModeGetColorDepth(&red, &green, &blue);
|
||||||
|
refreshRate = glfwVideoModeGetRefreshRate();
|
||||||
|
|
||||||
|
glfwWindowHint(GLFW_RED_BITS, red);
|
||||||
|
glfwWindowHint(GLFW_GREEN_BITS, green);
|
||||||
|
glfwWindowHint(GLFW_BLUE_BITS, blue);
|
||||||
|
glfwWindowHintDouble(GLFW_REFRESH_RATE, refreshRate);
|
||||||
|
|
||||||
|
GLFWwindow* window = glfwCreateWindow(width, height, "My Title", monitor, NULL);
|
||||||
@endcode
|
@endcode
|
||||||
|
|
||||||
This also works for windowed mode windows that are made full screen.
|
This also works for windowed mode windows that are made full screen.
|
||||||
|
|
||||||
@code
|
@code
|
||||||
const GLFWvidmode* mode = glfwGetVideoMode(monitor);
|
const GLFWvideoMode* mode = glfwGetVideoMode2(monitor);
|
||||||
|
int width, height;
|
||||||
|
glfwVideoModeGetSize(&width, &height);
|
||||||
|
double refreshRate = glfwVideoModeGetRefreshRate();
|
||||||
|
|
||||||
glfwSetWindowMonitor(window, monitor, 0, 0, mode->width, mode->height, mode->refreshRate);
|
glfwSetWindowMonitor2(window, monitor, 0, 0, width, height, refreshRate);
|
||||||
@endcode
|
@endcode
|
||||||
|
|
||||||
Note that @ref glfwGetVideoMode returns the _current_ video mode of a monitor,
|
Note that @ref glfwGetVideoMode returns the _current_ video mode of a monitor,
|
||||||
@ -147,7 +158,9 @@ There are a number of hints that can be set before the creation of a window and
|
|||||||
context. Some affect the window itself, others affect the framebuffer or
|
context. Some affect the window itself, others affect the framebuffer or
|
||||||
context. These hints are set to their default values each time the library is
|
context. These hints are set to their default values each time the library is
|
||||||
initialized with @ref glfwInit. Integer value hints can be set individually
|
initialized with @ref glfwInit. Integer value hints can be set individually
|
||||||
with @ref glfwWindowHint and string value hints with @ref glfwWindowHintString.
|
with @ref glfwWindowHint, floating point value hints
|
||||||
|
with @ref glfwWindowHintDouble, and string value hints
|
||||||
|
with @ref glfwWindowHintString.
|
||||||
You can reset all at once to their defaults with @ref glfwDefaultWindowHints.
|
You can reset all at once to their defaults with @ref glfwDefaultWindowHints.
|
||||||
|
|
||||||
Some hints are platform specific. These are always valid to set on any
|
Some hints are platform specific. These are always valid to set on any
|
||||||
@ -539,7 +552,7 @@ GLFW_ACCUM_BLUE_BITS | 0 | 0 to `INT_MAX` or
|
|||||||
GLFW_ACCUM_ALPHA_BITS | 0 | 0 to `INT_MAX` or `GLFW_DONT_CARE`
|
GLFW_ACCUM_ALPHA_BITS | 0 | 0 to `INT_MAX` or `GLFW_DONT_CARE`
|
||||||
GLFW_AUX_BUFFERS | 0 | 0 to `INT_MAX` or `GLFW_DONT_CARE`
|
GLFW_AUX_BUFFERS | 0 | 0 to `INT_MAX` or `GLFW_DONT_CARE`
|
||||||
GLFW_SAMPLES | 0 | 0 to `INT_MAX` or `GLFW_DONT_CARE`
|
GLFW_SAMPLES | 0 | 0 to `INT_MAX` or `GLFW_DONT_CARE`
|
||||||
GLFW_REFRESH_RATE | `GLFW_DONT_CARE` | 0 to `INT_MAX` or `GLFW_DONT_CARE`
|
GLFW_REFRESH_RATE | `GLFW_DONT_CARE` | 0.0 to `DBL_MAX` or `GLFW_DONT_CARE`
|
||||||
GLFW_STEREO | `GLFW_FALSE` | `GLFW_TRUE` or `GLFW_FALSE`
|
GLFW_STEREO | `GLFW_FALSE` | `GLFW_TRUE` or `GLFW_FALSE`
|
||||||
GLFW_SRGB_CAPABLE | `GLFW_FALSE` | `GLFW_TRUE` or `GLFW_FALSE`
|
GLFW_SRGB_CAPABLE | `GLFW_FALSE` | `GLFW_TRUE` or `GLFW_FALSE`
|
||||||
GLFW_DOUBLEBUFFER | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE`
|
GLFW_DOUBLEBUFFER | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE`
|
||||||
@ -927,16 +940,19 @@ on a different monitor, specify the desired monitor, resolution and refresh
|
|||||||
rate. The position arguments are ignored.
|
rate. The position arguments are ignored.
|
||||||
|
|
||||||
@code
|
@code
|
||||||
const GLFWvidmode* mode = glfwGetVideoMode(monitor);
|
const GLFWvideoMode* mode = glfwGetVideoMode2(monitor);
|
||||||
|
int width, height;
|
||||||
|
glfwVideoModeGetSize(&width, &height);
|
||||||
|
double refreshRate = glfwVideoModeGetRefreshRate();
|
||||||
|
|
||||||
glfwSetWindowMonitor(window, monitor, 0, 0, mode->width, mode->height, mode->refreshRate);
|
glfwSetWindowMonitor2(window, monitor, 0, 0, width, height, refreshRate);
|
||||||
@endcode
|
@endcode
|
||||||
|
|
||||||
When making the window windowed, specify the desired position and size. The
|
When making the window windowed, specify the desired position and size. The
|
||||||
refresh rate argument is ignored.
|
refresh rate argument is ignored.
|
||||||
|
|
||||||
@code
|
@code
|
||||||
glfwSetWindowMonitor(window, NULL, xpos, ypos, width, height, 0);
|
glfwSetWindowMonitor2(window, NULL, xpos, ypos, width, height, 0);
|
||||||
@endcode
|
@endcode
|
||||||
|
|
||||||
This restores any previous window settings such as whether it is decorated,
|
This restores any previous window settings such as whether it is decorated,
|
||||||
|
@ -1370,6 +1370,22 @@ typedef void (*GLFWvkproc)(void);
|
|||||||
*/
|
*/
|
||||||
typedef struct GLFWmonitor GLFWmonitor;
|
typedef struct GLFWmonitor GLFWmonitor;
|
||||||
|
|
||||||
|
/*! @brief Opaque video mode object.
|
||||||
|
*
|
||||||
|
* Opaque video mode object.
|
||||||
|
*
|
||||||
|
* @see @ref video_mode_object
|
||||||
|
*
|
||||||
|
* @sa @ref monitor_modes
|
||||||
|
* @sa @ref glfwGetVideoMode2
|
||||||
|
* @sa @ref glfwGetVideoModes2
|
||||||
|
*
|
||||||
|
* @since Added in version 3.4.
|
||||||
|
*
|
||||||
|
* @ingroup monitor
|
||||||
|
*/
|
||||||
|
typedef struct GLFWvideoMode GLFWvideoMode;
|
||||||
|
|
||||||
/*! @brief Opaque window object.
|
/*! @brief Opaque window object.
|
||||||
*
|
*
|
||||||
* Opaque window object.
|
* Opaque window object.
|
||||||
@ -1975,6 +1991,8 @@ typedef void (* GLFWjoystickfun)(int jid, int event);
|
|||||||
* @since Added in version 1.0.
|
* @since Added in version 1.0.
|
||||||
* @glfw3 Added refresh rate member.
|
* @glfw3 Added refresh rate member.
|
||||||
*
|
*
|
||||||
|
* @deprecated Scheduled for removal in version 4.0.
|
||||||
|
*
|
||||||
* @ingroup monitor
|
* @ingroup monitor
|
||||||
*/
|
*/
|
||||||
typedef struct GLFWvidmode
|
typedef struct GLFWvidmode
|
||||||
@ -2076,7 +2094,7 @@ typedef struct GLFWgamepadstate
|
|||||||
float axes[6];
|
float axes[6];
|
||||||
} GLFWgamepadstate;
|
} GLFWgamepadstate;
|
||||||
|
|
||||||
/*! @brief
|
/*! @brief Allocation function pointers
|
||||||
*
|
*
|
||||||
* @sa @ref init_allocator
|
* @sa @ref init_allocator
|
||||||
* @sa @ref glfwInitAllocator
|
* @sa @ref glfwInitAllocator
|
||||||
@ -2786,6 +2804,9 @@ GLFWAPI GLFWmonitorfun glfwSetMonitorCallback(GLFWmonitorfun callback);
|
|||||||
* @since Added in version 1.0.
|
* @since Added in version 1.0.
|
||||||
* @glfw3 Changed to return an array of modes for a specific monitor.
|
* @glfw3 Changed to return an array of modes for a specific monitor.
|
||||||
*
|
*
|
||||||
|
* @deprecated Deprecated in version 3.4. Scheduled for removal in version 4.0.
|
||||||
|
* Replaced with @ref glfwGetVideoModes2.
|
||||||
|
*
|
||||||
* @ingroup monitor
|
* @ingroup monitor
|
||||||
*/
|
*/
|
||||||
GLFWAPI const GLFWvidmode* glfwGetVideoModes(GLFWmonitor* monitor, int* count);
|
GLFWAPI const GLFWvidmode* glfwGetVideoModes(GLFWmonitor* monitor, int* count);
|
||||||
@ -2814,10 +2835,74 @@ GLFWAPI const GLFWvidmode* glfwGetVideoModes(GLFWmonitor* monitor, int* count);
|
|||||||
*
|
*
|
||||||
* @since Added in version 3.0. Replaces `glfwGetDesktopMode`.
|
* @since Added in version 3.0. Replaces `glfwGetDesktopMode`.
|
||||||
*
|
*
|
||||||
|
* @deprecated Deprecated in version 3.4. Scheduled for removal in version 4.0.
|
||||||
|
* Replaced with @ref glfwGetVideoMode2.
|
||||||
|
*
|
||||||
* @ingroup monitor
|
* @ingroup monitor
|
||||||
*/
|
*/
|
||||||
GLFWAPI const GLFWvidmode* glfwGetVideoMode(GLFWmonitor* monitor);
|
GLFWAPI const GLFWvidmode* glfwGetVideoMode(GLFWmonitor* monitor);
|
||||||
|
|
||||||
|
/*! @brief Returns the available video modes for the specified monitor.
|
||||||
|
*
|
||||||
|
* This function returns an array of all video modes supported by the specified
|
||||||
|
* monitor. The returned array is sorted in ascending order, first by color
|
||||||
|
* bit depth (the sum of all channel depths), then by resolution area (the
|
||||||
|
* product of width and height), then resolution width and finally by refresh
|
||||||
|
* rate.
|
||||||
|
*
|
||||||
|
* @param[in] monitor The monitor to query.
|
||||||
|
* @param[out] count Where to store the number of video modes in the returned
|
||||||
|
* array. This is set to zero if an error occurred.
|
||||||
|
* @return An array of video modes, or `NULL` if an
|
||||||
|
* [error](@ref error_handling) occurred.
|
||||||
|
*
|
||||||
|
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
|
||||||
|
* GLFW_PLATFORM_ERROR.
|
||||||
|
*
|
||||||
|
* @pointer_lifetime The returned array is allocated and freed by GLFW. You
|
||||||
|
* should not free it yourself. It is valid until the specified monitor is
|
||||||
|
* disconnected, this function is called again for that monitor or the library
|
||||||
|
* is terminated.
|
||||||
|
*
|
||||||
|
* @thread_safety This function must only be called from the main thread.
|
||||||
|
*
|
||||||
|
* @sa @ref monitor_modes
|
||||||
|
* @sa @ref glfwGetVideoMode2
|
||||||
|
*
|
||||||
|
* @since Added in version 3.4. Replaces `glfwGetVideoModes`.
|
||||||
|
*
|
||||||
|
* @ingroup monitor
|
||||||
|
*/
|
||||||
|
GLFWAPI const GLFWvideoMode* const* glfwGetVideoModes2(GLFWmonitor* monitor, int* count);
|
||||||
|
|
||||||
|
/*! @brief Returns the current mode of the specified monitor.
|
||||||
|
*
|
||||||
|
* This function returns the current video mode of the specified monitor. If
|
||||||
|
* you have created a full screen window for that monitor, the return value
|
||||||
|
* will depend on whether that window is iconified.
|
||||||
|
*
|
||||||
|
* @param[in] monitor The monitor to query.
|
||||||
|
* @return The current mode of the monitor, or `NULL` if an
|
||||||
|
* [error](@ref error_handling) occurred.
|
||||||
|
*
|
||||||
|
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
|
||||||
|
* GLFW_PLATFORM_ERROR.
|
||||||
|
*
|
||||||
|
* @pointer_lifetime The returned array is allocated and freed by GLFW. You
|
||||||
|
* should not free it yourself. It is valid until the specified monitor is
|
||||||
|
* disconnected or the library is terminated.
|
||||||
|
*
|
||||||
|
* @thread_safety This function must only be called from the main thread.
|
||||||
|
*
|
||||||
|
* @sa @ref monitor_modes
|
||||||
|
* @sa @ref glfwGetVideoModes2
|
||||||
|
*
|
||||||
|
* @since Added in version 3.4. Replaces `glfwGetVideoMode`.
|
||||||
|
*
|
||||||
|
* @ingroup monitor
|
||||||
|
*/
|
||||||
|
GLFWAPI const GLFWvideoMode* glfwGetVideoMode2(GLFWmonitor* monitor);
|
||||||
|
|
||||||
/*! @brief Generates a gamma ramp and sets it for the specified monitor.
|
/*! @brief Generates a gamma ramp and sets it for the specified monitor.
|
||||||
*
|
*
|
||||||
* This function generates an appropriately sized gamma ramp from the specified
|
* This function generates an appropriately sized gamma ramp from the specified
|
||||||
@ -2922,6 +3007,79 @@ GLFWAPI const GLFWgammaramp* glfwGetGammaRamp(GLFWmonitor* monitor);
|
|||||||
*/
|
*/
|
||||||
GLFWAPI void glfwSetGammaRamp(GLFWmonitor* monitor, const GLFWgammaramp* ramp);
|
GLFWAPI void glfwSetGammaRamp(GLFWmonitor* monitor, const GLFWgammaramp* ramp);
|
||||||
|
|
||||||
|
/*! @brief Tests the equality of two [video modes](@ref GLFWvideoMode).
|
||||||
|
*
|
||||||
|
* This function tests the equality of two [video modes](@ref GLFWvideoMode).
|
||||||
|
*
|
||||||
|
* @param[in] first The video mode to test against the second argument.
|
||||||
|
* @param[in] second The video mode to test against the first argument.
|
||||||
|
*
|
||||||
|
* @return @ref GLFW_TRUE if the modes are equal, else @ref GLFW_FALSE.
|
||||||
|
*
|
||||||
|
* @sa @ref monitor_modes
|
||||||
|
*
|
||||||
|
* @since Added in version 3.4.
|
||||||
|
*
|
||||||
|
* @ingroup monitor
|
||||||
|
*/
|
||||||
|
GLFWAPI int glfwVideoModesEqual(const GLFWvideoMode* first, const GLFWvideoMode* second);
|
||||||
|
|
||||||
|
/*! @brief Gets the size of a [video mode](@ref GLFWvideoMode).
|
||||||
|
*
|
||||||
|
* This function returns the size of a [video mode](@ref GLFWvideoMode), in screen coordinates.
|
||||||
|
*
|
||||||
|
* @param[in] videoMode The video mode to get the size of.
|
||||||
|
* @param[out] width Where to store the width of the
|
||||||
|
* video mode, or `NULL`.
|
||||||
|
* @param[out] height Where to store the height of the
|
||||||
|
* video mode, or `NULL`.
|
||||||
|
*
|
||||||
|
* @sa @ref monitor_modes
|
||||||
|
*
|
||||||
|
* @since Added in version 3.4.
|
||||||
|
*
|
||||||
|
* @ingroup monitor
|
||||||
|
*/
|
||||||
|
GLFWAPI void glfwVideoModeGetSize(const GLFWvideoMode* videoMode, int* width, int* height);
|
||||||
|
|
||||||
|
/*! @brief Gets the color depth of a [video mode](@ref GLFWvideoMode).
|
||||||
|
*
|
||||||
|
* This function returns the color depth of a [video mode](@ref GLFWvideoMode).
|
||||||
|
*
|
||||||
|
* @param[in] videoMode The video mode to get the color depth of.
|
||||||
|
* @param[out] red Where to store the red bits of the
|
||||||
|
* video mode, or `NULL`.
|
||||||
|
* @param[out] green Where to store the green bits of the
|
||||||
|
* video mode, or `NULL`.
|
||||||
|
* @param[out] blue Where to store the blue bits of the
|
||||||
|
* video mode, or `NULL`.
|
||||||
|
*
|
||||||
|
* @sa @ref monitor_modes
|
||||||
|
*
|
||||||
|
* @since Added in version 3.4.
|
||||||
|
*
|
||||||
|
* @ingroup monitor
|
||||||
|
*/
|
||||||
|
GLFWAPI void glfwVideoModeGetColorDepth(const GLFWvideoMode* videoMode, int* red, int* green, int* blue);
|
||||||
|
|
||||||
|
/*! @brief Gets the refresh rate of a [video mode](@ref GLFWvideoMode).
|
||||||
|
*
|
||||||
|
* This function returns the refresh rate, in Hz, of the [video mode](@ref GLFWvideoMode).
|
||||||
|
*
|
||||||
|
* @param[in] videoMode The video mode to get the refresh rate of.
|
||||||
|
*
|
||||||
|
* @return @ref The refresh rate, in Hz, of the video mode.
|
||||||
|
*
|
||||||
|
* @remark @win32 Precise refresh rates are not currently available in GLFW.
|
||||||
|
*
|
||||||
|
* @sa @ref monitor_modes
|
||||||
|
*
|
||||||
|
* @since Added in version 3.4.
|
||||||
|
*
|
||||||
|
* @ingroup monitor
|
||||||
|
*/
|
||||||
|
GLFWAPI double glfwVideoModeGetRefreshRate(const GLFWvideoMode* videoMode);
|
||||||
|
|
||||||
/*! @brief Resets all window hints to their default values.
|
/*! @brief Resets all window hints to their default values.
|
||||||
*
|
*
|
||||||
* This function resets all window hints to their
|
* This function resets all window hints to their
|
||||||
@ -2947,7 +3105,8 @@ GLFWAPI void glfwDefaultWindowHints(void);
|
|||||||
* hints, once set, retain their values until changed by a call to this
|
* hints, once set, retain their values until changed by a call to this
|
||||||
* function or @ref glfwDefaultWindowHints, or until the library is terminated.
|
* function or @ref glfwDefaultWindowHints, or until the library is terminated.
|
||||||
*
|
*
|
||||||
* Only integer value hints can be set with this function. String value hints
|
* Only integer value hints can be set with this function. Floating point
|
||||||
|
* value hints are set with @ref glfwWindowHintDouble. String value hints
|
||||||
* are set with @ref glfwWindowHintString.
|
* are set with @ref glfwWindowHintString.
|
||||||
*
|
*
|
||||||
* This function does not check whether the specified hint values are valid.
|
* This function does not check whether the specified hint values are valid.
|
||||||
@ -2967,6 +3126,7 @@ GLFWAPI void glfwDefaultWindowHints(void);
|
|||||||
* @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_hints
|
* @sa @ref window_hints
|
||||||
|
* @sa @ref glfwWindowHintDouble
|
||||||
* @sa @ref glfwWindowHintString
|
* @sa @ref glfwWindowHintString
|
||||||
* @sa @ref glfwDefaultWindowHints
|
* @sa @ref glfwDefaultWindowHints
|
||||||
*
|
*
|
||||||
@ -2976,6 +3136,43 @@ GLFWAPI void glfwDefaultWindowHints(void);
|
|||||||
*/
|
*/
|
||||||
GLFWAPI void glfwWindowHint(int hint, int value);
|
GLFWAPI void glfwWindowHint(int hint, int value);
|
||||||
|
|
||||||
|
/*! @brief Sets the specified window hint to the desired value.
|
||||||
|
*
|
||||||
|
* This function sets hints for the next call to @ref glfwCreateWindow. The
|
||||||
|
* hints, once set, retain their values until changed by a call to this
|
||||||
|
* function or @ref glfwDefaultWindowHints, or until the library is terminated.
|
||||||
|
*
|
||||||
|
* Only floating point hints can be set with this function. Integer value hints
|
||||||
|
* are set with @ref glfwWindowHint. String value hints are set
|
||||||
|
* with @ref glfwWindowHintString.
|
||||||
|
*
|
||||||
|
* This function does not check whether the specified hint values are valid.
|
||||||
|
* If you set hints to invalid values this will instead be reported by the next
|
||||||
|
* call to @ref glfwCreateWindow.
|
||||||
|
*
|
||||||
|
* Some hints are platform specific. These may be set on any platform but they
|
||||||
|
* will only affect their specific platform. Other platforms will ignore them.
|
||||||
|
* Setting these hints requires no platform specific headers or functions.
|
||||||
|
*
|
||||||
|
* @param[in] hint The [window hint](@ref window_hints) to set.
|
||||||
|
* @param[in] value The new value of the window hint.
|
||||||
|
*
|
||||||
|
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
|
||||||
|
* GLFW_INVALID_ENUM.
|
||||||
|
*
|
||||||
|
* @thread_safety This function must only be called from the main thread.
|
||||||
|
*
|
||||||
|
* @sa @ref window_hints
|
||||||
|
* @sa @ref glfwWindowHint
|
||||||
|
* @sa @ref glfwWindowHintString
|
||||||
|
* @sa @ref glfwDefaultWindowHints
|
||||||
|
*
|
||||||
|
* @since Added in version 3.4.
|
||||||
|
*
|
||||||
|
* @ingroup window
|
||||||
|
*/
|
||||||
|
GLFWAPI void glfwWindowHintDouble(int hint, double value);
|
||||||
|
|
||||||
/*! @brief Sets the specified window hint to the desired value.
|
/*! @brief Sets the specified window hint to the desired value.
|
||||||
*
|
*
|
||||||
* This function sets hints for the next call to @ref glfwCreateWindow. The
|
* This function sets hints for the next call to @ref glfwCreateWindow. The
|
||||||
@ -2983,7 +3180,8 @@ GLFWAPI void glfwWindowHint(int hint, int value);
|
|||||||
* function or @ref glfwDefaultWindowHints, or until the library is terminated.
|
* function or @ref glfwDefaultWindowHints, or until the library is terminated.
|
||||||
*
|
*
|
||||||
* Only string type hints can be set with this function. Integer value hints
|
* Only string type hints can be set with this function. Integer value hints
|
||||||
* are set with @ref glfwWindowHint.
|
* are set with @ref glfwWindowHint. Floating point value hints are set
|
||||||
|
* with @ref glfwWindowHintDouble.
|
||||||
*
|
*
|
||||||
* This function does not check whether the specified hint values are valid.
|
* This function does not check whether the specified hint values are valid.
|
||||||
* If you set hints to invalid values this will instead be reported by the next
|
* If you set hints to invalid values this will instead be reported by the next
|
||||||
@ -3006,6 +3204,7 @@ GLFWAPI void glfwWindowHint(int hint, int value);
|
|||||||
*
|
*
|
||||||
* @sa @ref window_hints
|
* @sa @ref window_hints
|
||||||
* @sa @ref glfwWindowHint
|
* @sa @ref glfwWindowHint
|
||||||
|
* @sa @ref glfwWindowHintDouble
|
||||||
* @sa @ref glfwDefaultWindowHints
|
* @sa @ref glfwDefaultWindowHints
|
||||||
*
|
*
|
||||||
* @since Added in version 3.3.
|
* @since Added in version 3.3.
|
||||||
@ -3046,7 +3245,7 @@ GLFWAPI void glfwWindowHintString(int hint, const char* value);
|
|||||||
* or _borderless full screen_ windows, see @ref window_windowed_full_screen.
|
* or _borderless full screen_ windows, see @ref window_windowed_full_screen.
|
||||||
*
|
*
|
||||||
* Once you have created the window, you can switch it between windowed and
|
* Once you have created the window, you can switch it between windowed and
|
||||||
* full screen mode with @ref glfwSetWindowMonitor. This will not affect its
|
* full screen mode with @ref glfwSetWindowMonitor2. This will not affect its
|
||||||
* OpenGL or OpenGL ES context.
|
* OpenGL or OpenGL ES context.
|
||||||
*
|
*
|
||||||
* By default, newly created windows use the placement recommended by the
|
* By default, newly created windows use the placement recommended by the
|
||||||
@ -3498,7 +3697,7 @@ GLFWAPI void glfwSetWindowAspectRatio(GLFWwindow* window, int numer, int denom);
|
|||||||
* framebuffer remain unchanged.
|
* framebuffer remain unchanged.
|
||||||
*
|
*
|
||||||
* If you wish to update the refresh rate of the desired video mode in addition
|
* If you wish to update the refresh rate of the desired video mode in addition
|
||||||
* to its resolution, see @ref glfwSetWindowMonitor.
|
* to its resolution, see @ref glfwSetWindowMonitor2.
|
||||||
*
|
*
|
||||||
* The window manager may put limits on what sizes are allowed. GLFW cannot
|
* The window manager may put limits on what sizes are allowed. GLFW cannot
|
||||||
* and should not override these limits.
|
* and should not override these limits.
|
||||||
@ -3519,7 +3718,7 @@ GLFWAPI void glfwSetWindowAspectRatio(GLFWwindow* window, int numer, int denom);
|
|||||||
*
|
*
|
||||||
* @sa @ref window_size
|
* @sa @ref window_size
|
||||||
* @sa @ref glfwGetWindowSize
|
* @sa @ref glfwGetWindowSize
|
||||||
* @sa @ref glfwSetWindowMonitor
|
* @sa @ref glfwSetWindowMonitor2
|
||||||
*
|
*
|
||||||
* @since Added in version 1.0.
|
* @since Added in version 1.0.
|
||||||
* @glfw3 Added window handle parameter.
|
* @glfw3 Added window handle parameter.
|
||||||
@ -3904,7 +4103,7 @@ GLFWAPI void glfwRequestWindowAttention(GLFWwindow* window);
|
|||||||
* @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_monitor
|
* @sa @ref window_monitor
|
||||||
* @sa @ref glfwSetWindowMonitor
|
* @sa @ref glfwSetWindowMonitor2
|
||||||
*
|
*
|
||||||
* @since Added in version 3.0.
|
* @since Added in version 3.0.
|
||||||
*
|
*
|
||||||
@ -3912,6 +4111,21 @@ GLFWAPI void glfwRequestWindowAttention(GLFWwindow* window);
|
|||||||
*/
|
*/
|
||||||
GLFWAPI GLFWmonitor* glfwGetWindowMonitor(GLFWwindow* window);
|
GLFWAPI GLFWmonitor* glfwGetWindowMonitor(GLFWwindow* window);
|
||||||
|
|
||||||
|
/*! @brief Sets the mode, monitor, video mode and placement of a window.
|
||||||
|
*
|
||||||
|
* @see @ref glfwSetWindowMonitor2 for a detailed description of this function.
|
||||||
|
*
|
||||||
|
* @sa @ref window_monitor
|
||||||
|
* @sa @ref window_full_screen
|
||||||
|
*
|
||||||
|
* @since Added in version 3.2.
|
||||||
|
*
|
||||||
|
* @deprecated Deprecated in version 3.4. Replaced with @ref glfwSetWindowMonitor2
|
||||||
|
*
|
||||||
|
* @ingroup window
|
||||||
|
*/
|
||||||
|
GLFWAPI void glfwSetWindowMonitor(GLFWwindow* window, GLFWmonitor* monitor, int xpos, int ypos, int width, int height, int refreshRate);
|
||||||
|
|
||||||
/*! @brief Sets the mode, monitor, video mode and placement of a window.
|
/*! @brief Sets the mode, monitor, video mode and placement of a window.
|
||||||
*
|
*
|
||||||
* This function sets the monitor that the window uses for full screen mode or,
|
* This function sets the monitor that the window uses for full screen mode or,
|
||||||
@ -3956,7 +4170,7 @@ GLFWAPI GLFWmonitor* glfwGetWindowMonitor(GLFWwindow* window);
|
|||||||
* for an application to set this property.
|
* for an application to set this property.
|
||||||
*
|
*
|
||||||
* @remark @wayland Setting the window to full screen will not attempt to
|
* @remark @wayland Setting the window to full screen will not attempt to
|
||||||
* change the mode, no matter what the requested size or refresh rate.
|
* change the mode, no matter what the requested size or refresh rate are.
|
||||||
*
|
*
|
||||||
* @thread_safety This function must only be called from the main thread.
|
* @thread_safety This function must only be called from the main thread.
|
||||||
*
|
*
|
||||||
@ -3965,11 +4179,11 @@ GLFWAPI GLFWmonitor* glfwGetWindowMonitor(GLFWwindow* window);
|
|||||||
* @sa @ref glfwGetWindowMonitor
|
* @sa @ref glfwGetWindowMonitor
|
||||||
* @sa @ref glfwSetWindowSize
|
* @sa @ref glfwSetWindowSize
|
||||||
*
|
*
|
||||||
* @since Added in version 3.2.
|
* @since Added in version 3.4.
|
||||||
*
|
*
|
||||||
* @ingroup window
|
* @ingroup window
|
||||||
*/
|
*/
|
||||||
GLFWAPI void glfwSetWindowMonitor(GLFWwindow* window, GLFWmonitor* monitor, int xpos, int ypos, int width, int height, int refreshRate);
|
GLFWAPI void glfwSetWindowMonitor2(GLFWwindow* window, GLFWmonitor* monitor, int xpos, int ypos, int width, int height, double refreshRate);
|
||||||
|
|
||||||
/*! @brief Returns an attribute of the specified window.
|
/*! @brief Returns an attribute of the specified window.
|
||||||
*
|
*
|
||||||
|
@ -154,16 +154,16 @@ static GLFWbool modeIsGood(CGDisplayModeRef mode)
|
|||||||
|
|
||||||
// Convert Core Graphics display mode to GLFW video mode
|
// Convert Core Graphics display mode to GLFW video mode
|
||||||
//
|
//
|
||||||
static GLFWvidmode vidmodeFromCGDisplayMode(CGDisplayModeRef mode,
|
static _GLFWvideoMode videoModeFromCGDisplayMode(CGDisplayModeRef mode,
|
||||||
double fallbackRefreshRate)
|
double fallbackRefreshRate)
|
||||||
{
|
{
|
||||||
GLFWvidmode result;
|
_GLFWvideoMode result;
|
||||||
result.width = (int) CGDisplayModeGetWidth(mode);
|
result.width = (int) CGDisplayModeGetWidth(mode);
|
||||||
result.height = (int) CGDisplayModeGetHeight(mode);
|
result.height = (int) CGDisplayModeGetHeight(mode);
|
||||||
result.refreshRate = (int) round(CGDisplayModeGetRefreshRate(mode));
|
result.refreshRate = CGDisplayModeGetRefreshRate(mode);
|
||||||
|
|
||||||
if (result.refreshRate == 0)
|
if (result.refreshRate == 0)
|
||||||
result.refreshRate = (int) round(fallbackRefreshRate);
|
result.refreshRate = fallbackRefreshRate;
|
||||||
|
|
||||||
#if MAC_OS_X_VERSION_MAX_ALLOWED <= 101100
|
#if MAC_OS_X_VERSION_MAX_ALLOWED <= 101100
|
||||||
CFStringRef format = CGDisplayModeCopyPixelEncoding(mode);
|
CFStringRef format = CGDisplayModeCopyPixelEncoding(mode);
|
||||||
@ -383,12 +383,12 @@ void _glfwPollMonitorsCocoa(void)
|
|||||||
|
|
||||||
// Change the current video mode
|
// Change the current video mode
|
||||||
//
|
//
|
||||||
void _glfwSetVideoModeCocoa(_GLFWmonitor* monitor, const GLFWvidmode* desired)
|
void _glfwSetVideoModeCocoa(_GLFWmonitor* monitor, const _GLFWvideoMode* desired)
|
||||||
{
|
{
|
||||||
GLFWvidmode current;
|
_GLFWvideoMode current;
|
||||||
_glfwGetVideoModeCocoa(monitor, ¤t);
|
_glfwGetVideoModeCocoa(monitor, ¤t);
|
||||||
|
|
||||||
const GLFWvidmode* best = _glfwChooseVideoMode(monitor, desired);
|
const _GLFWvideoMode* best = _glfwChooseVideoMode(monitor, desired);
|
||||||
if (_glfwCompareVideoModes(¤t, best) == 0)
|
if (_glfwCompareVideoModes(¤t, best) == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -402,8 +402,8 @@ void _glfwSetVideoModeCocoa(_GLFWmonitor* monitor, const GLFWvidmode* desired)
|
|||||||
if (!modeIsGood(dm))
|
if (!modeIsGood(dm))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const GLFWvidmode mode =
|
const _GLFWvideoMode mode =
|
||||||
vidmodeFromCGDisplayMode(dm, monitor->ns.fallbackRefreshRate);
|
videoModeFromCGDisplayMode(dm, monitor->ns.fallbackRefreshRate);
|
||||||
if (_glfwCompareVideoModes(best, &mode) == 0)
|
if (_glfwCompareVideoModes(best, &mode) == 0)
|
||||||
{
|
{
|
||||||
native = dm;
|
native = dm;
|
||||||
@ -511,7 +511,7 @@ void _glfwGetMonitorWorkareaCocoa(_GLFWmonitor* monitor,
|
|||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWvidmode* _glfwGetVideoModesCocoa(_GLFWmonitor* monitor, int* count)
|
_GLFWvideoMode* _glfwGetVideoModesCocoa(_GLFWmonitor* monitor, int* count)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
|
|
||||||
@ -519,7 +519,7 @@ GLFWvidmode* _glfwGetVideoModesCocoa(_GLFWmonitor* monitor, int* count)
|
|||||||
|
|
||||||
CFArrayRef modes = CGDisplayCopyAllDisplayModes(monitor->ns.displayID, NULL);
|
CFArrayRef modes = CGDisplayCopyAllDisplayModes(monitor->ns.displayID, NULL);
|
||||||
const CFIndex found = CFArrayGetCount(modes);
|
const CFIndex found = CFArrayGetCount(modes);
|
||||||
GLFWvidmode* result = _glfw_calloc(found, sizeof(GLFWvidmode));
|
_GLFWvideoMode* result = _glfw_calloc(found, sizeof(_GLFWvideoMode));
|
||||||
|
|
||||||
for (CFIndex i = 0; i < found; i++)
|
for (CFIndex i = 0; i < found; i++)
|
||||||
{
|
{
|
||||||
@ -527,8 +527,8 @@ GLFWvidmode* _glfwGetVideoModesCocoa(_GLFWmonitor* monitor, int* count)
|
|||||||
if (!modeIsGood(dm))
|
if (!modeIsGood(dm))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const GLFWvidmode mode =
|
const _GLFWvideoMode mode =
|
||||||
vidmodeFromCGDisplayMode(dm, monitor->ns.fallbackRefreshRate);
|
videoModeFromCGDisplayMode(dm, monitor->ns.fallbackRefreshRate);
|
||||||
CFIndex j;
|
CFIndex j;
|
||||||
|
|
||||||
for (j = 0; j < *count; j++)
|
for (j = 0; j < *count; j++)
|
||||||
@ -551,12 +551,12 @@ GLFWvidmode* _glfwGetVideoModesCocoa(_GLFWmonitor* monitor, int* count)
|
|||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwGetVideoModeCocoa(_GLFWmonitor* monitor, GLFWvidmode *mode)
|
void _glfwGetVideoModeCocoa(_GLFWmonitor* monitor, _GLFWvideoMode* mode)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
|
|
||||||
CGDisplayModeRef native = CGDisplayCopyDisplayMode(monitor->ns.displayID);
|
CGDisplayModeRef native = CGDisplayCopyDisplayMode(monitor->ns.displayID);
|
||||||
*mode = vidmodeFromCGDisplayMode(native, monitor->ns.fallbackRefreshRate);
|
*mode = videoModeFromCGDisplayMode(native, monitor->ns.fallbackRefreshRate);
|
||||||
CGDisplayModeRelease(native);
|
CGDisplayModeRelease(native);
|
||||||
|
|
||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
|
@ -234,7 +234,7 @@ void _glfwShowWindowCocoa(_GLFWwindow* window);
|
|||||||
void _glfwHideWindowCocoa(_GLFWwindow* window);
|
void _glfwHideWindowCocoa(_GLFWwindow* window);
|
||||||
void _glfwRequestWindowAttentionCocoa(_GLFWwindow* window);
|
void _glfwRequestWindowAttentionCocoa(_GLFWwindow* window);
|
||||||
void _glfwFocusWindowCocoa(_GLFWwindow* window);
|
void _glfwFocusWindowCocoa(_GLFWwindow* window);
|
||||||
void _glfwSetWindowMonitorCocoa(_GLFWwindow* window, _GLFWmonitor* monitor, int xpos, int ypos, int width, int height, int refreshRate);
|
void _glfwSetWindowMonitorCocoa(_GLFWwindow* window, _GLFWmonitor* monitor, int xpos, int ypos, int width, int height, double refreshRate);
|
||||||
GLFWbool _glfwWindowFocusedCocoa(_GLFWwindow* window);
|
GLFWbool _glfwWindowFocusedCocoa(_GLFWwindow* window);
|
||||||
GLFWbool _glfwWindowIconifiedCocoa(_GLFWwindow* window);
|
GLFWbool _glfwWindowIconifiedCocoa(_GLFWwindow* window);
|
||||||
GLFWbool _glfwWindowVisibleCocoa(_GLFWwindow* window);
|
GLFWbool _glfwWindowVisibleCocoa(_GLFWwindow* window);
|
||||||
@ -280,13 +280,13 @@ void _glfwFreeMonitorCocoa(_GLFWmonitor* monitor);
|
|||||||
void _glfwGetMonitorPosCocoa(_GLFWmonitor* monitor, int* xpos, int* ypos);
|
void _glfwGetMonitorPosCocoa(_GLFWmonitor* monitor, int* xpos, int* ypos);
|
||||||
void _glfwGetMonitorContentScaleCocoa(_GLFWmonitor* monitor, float* xscale, float* yscale);
|
void _glfwGetMonitorContentScaleCocoa(_GLFWmonitor* monitor, float* xscale, float* yscale);
|
||||||
void _glfwGetMonitorWorkareaCocoa(_GLFWmonitor* monitor, int* xpos, int* ypos, int* width, int* height);
|
void _glfwGetMonitorWorkareaCocoa(_GLFWmonitor* monitor, int* xpos, int* ypos, int* width, int* height);
|
||||||
GLFWvidmode* _glfwGetVideoModesCocoa(_GLFWmonitor* monitor, int* count);
|
_GLFWvideoMode* _glfwGetVideoModesCocoa(_GLFWmonitor* monitor, int* count);
|
||||||
void _glfwGetVideoModeCocoa(_GLFWmonitor* monitor, GLFWvidmode* mode);
|
void _glfwGetVideoModeCocoa(_GLFWmonitor* monitor, _GLFWvideoMode* mode);
|
||||||
GLFWbool _glfwGetGammaRampCocoa(_GLFWmonitor* monitor, GLFWgammaramp* ramp);
|
GLFWbool _glfwGetGammaRampCocoa(_GLFWmonitor* monitor, GLFWgammaramp* ramp);
|
||||||
void _glfwSetGammaRampCocoa(_GLFWmonitor* monitor, const GLFWgammaramp* ramp);
|
void _glfwSetGammaRampCocoa(_GLFWmonitor* monitor, const GLFWgammaramp* ramp);
|
||||||
|
|
||||||
void _glfwPollMonitorsCocoa(void);
|
void _glfwPollMonitorsCocoa(void);
|
||||||
void _glfwSetVideoModeCocoa(_GLFWmonitor* monitor, const GLFWvidmode* desired);
|
void _glfwSetVideoModeCocoa(_GLFWmonitor* monitor, const _GLFWvideoMode* desired);
|
||||||
void _glfwRestoreVideoModeCocoa(_GLFWmonitor* monitor);
|
void _glfwRestoreVideoModeCocoa(_GLFWmonitor* monitor);
|
||||||
|
|
||||||
float _glfwTransformYCocoa(float y);
|
float _glfwTransformYCocoa(float y);
|
||||||
|
@ -784,7 +784,7 @@ static GLFWbool createNativeWindow(_GLFWwindow* window,
|
|||||||
|
|
||||||
if (window->monitor)
|
if (window->monitor)
|
||||||
{
|
{
|
||||||
GLFWvidmode mode;
|
_GLFWvideoMode mode;
|
||||||
int xpos, ypos;
|
int xpos, ypos;
|
||||||
|
|
||||||
_glfwGetVideoModeCocoa(window->monitor, &mode);
|
_glfwGetVideoModeCocoa(window->monitor, &mode);
|
||||||
@ -1240,7 +1240,7 @@ void _glfwSetWindowMonitorCocoa(_GLFWwindow* window,
|
|||||||
_GLFWmonitor* monitor,
|
_GLFWmonitor* monitor,
|
||||||
int xpos, int ypos,
|
int xpos, int ypos,
|
||||||
int width, int height,
|
int width, int height,
|
||||||
int refreshRate)
|
double refreshRate)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
|
|
||||||
|
@ -70,6 +70,7 @@ typedef struct _GLFWcontext _GLFWcontext;
|
|||||||
typedef struct _GLFWwindow _GLFWwindow;
|
typedef struct _GLFWwindow _GLFWwindow;
|
||||||
typedef struct _GLFWplatform _GLFWplatform;
|
typedef struct _GLFWplatform _GLFWplatform;
|
||||||
typedef struct _GLFWlibrary _GLFWlibrary;
|
typedef struct _GLFWlibrary _GLFWlibrary;
|
||||||
|
typedef struct _GLFWvideoMode _GLFWvideoMode;
|
||||||
typedef struct _GLFWmonitor _GLFWmonitor;
|
typedef struct _GLFWmonitor _GLFWmonitor;
|
||||||
typedef struct _GLFWcursor _GLFWcursor;
|
typedef struct _GLFWcursor _GLFWcursor;
|
||||||
typedef struct _GLFWmapelement _GLFWmapelement;
|
typedef struct _GLFWmapelement _GLFWmapelement;
|
||||||
@ -515,6 +516,26 @@ struct _GLFWcontext
|
|||||||
GLFW_PLATFORM_CONTEXT_STATE
|
GLFW_PLATFORM_CONTEXT_STATE
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct _GLFWvideoMode
|
||||||
|
{
|
||||||
|
// The width, in screen coordinates, of the video mode.
|
||||||
|
int width;
|
||||||
|
// The height, in screen coordinates, of the video mode.
|
||||||
|
int height;
|
||||||
|
|
||||||
|
// The bit depth of the red channel of the video mode.
|
||||||
|
int redBits;
|
||||||
|
// The bit depth of the green channel of the video mode.
|
||||||
|
int greenBits;
|
||||||
|
// The bit depth of the blue channel of the video mode.
|
||||||
|
int blueBits;
|
||||||
|
// The refresh rate, in Hz, of the video mode.
|
||||||
|
double refreshRate;
|
||||||
|
|
||||||
|
// Update the comparison in glfwGetVideoModes if adding
|
||||||
|
// more independent fields here.
|
||||||
|
};
|
||||||
|
|
||||||
// Window and context structure
|
// Window and context structure
|
||||||
//
|
//
|
||||||
struct _GLFWwindow
|
struct _GLFWwindow
|
||||||
@ -531,7 +552,7 @@ struct _GLFWwindow
|
|||||||
GLFWbool shouldClose;
|
GLFWbool shouldClose;
|
||||||
void* userPointer;
|
void* userPointer;
|
||||||
GLFWbool doublebuffer;
|
GLFWbool doublebuffer;
|
||||||
GLFWvidmode videoMode;
|
_GLFWvideoMode videoMode;
|
||||||
_GLFWmonitor* monitor;
|
_GLFWmonitor* monitor;
|
||||||
_GLFWcursor* cursor;
|
_GLFWcursor* cursor;
|
||||||
|
|
||||||
@ -588,9 +609,17 @@ struct _GLFWmonitor
|
|||||||
// The window whose video mode is current on this monitor
|
// The window whose video mode is current on this monitor
|
||||||
_GLFWwindow* window;
|
_GLFWwindow* window;
|
||||||
|
|
||||||
GLFWvidmode* modes;
|
// Deprecated; Use modes, modesCount and currentMode instead. External use only.
|
||||||
|
GLFWvidmode* modesOld;
|
||||||
|
int modeCountOld;
|
||||||
|
GLFWvidmode currentModeOld;
|
||||||
|
|
||||||
|
_GLFWvideoMode* modes;
|
||||||
int modeCount;
|
int modeCount;
|
||||||
GLFWvidmode currentMode;
|
|
||||||
|
// An array of pointers to each element in modes. External use only.
|
||||||
|
GLFWvideoMode** modesPointers;
|
||||||
|
_GLFWvideoMode currentMode;
|
||||||
|
|
||||||
GLFWgammaramp originalRamp;
|
GLFWgammaramp originalRamp;
|
||||||
GLFWgammaramp currentRamp;
|
GLFWgammaramp currentRamp;
|
||||||
@ -697,8 +726,8 @@ struct _GLFWplatform
|
|||||||
void (*getMonitorPos)(_GLFWmonitor*,int*,int*);
|
void (*getMonitorPos)(_GLFWmonitor*,int*,int*);
|
||||||
void (*getMonitorContentScale)(_GLFWmonitor*,float*,float*);
|
void (*getMonitorContentScale)(_GLFWmonitor*,float*,float*);
|
||||||
void (*getMonitorWorkarea)(_GLFWmonitor*,int*,int*,int*,int*);
|
void (*getMonitorWorkarea)(_GLFWmonitor*,int*,int*,int*,int*);
|
||||||
GLFWvidmode* (*getVideoModes)(_GLFWmonitor*,int*);
|
_GLFWvideoMode* (*getVideoModes)(_GLFWmonitor*,int*); // TODO: reimplement for Wayland, X11, Win32
|
||||||
void (*getVideoMode)(_GLFWmonitor*,GLFWvidmode*);
|
void (*getVideoMode)(_GLFWmonitor*,_GLFWvideoMode*); // TODO: reimplement for Wayland, X11, Win32
|
||||||
GLFWbool (*getGammaRamp)(_GLFWmonitor*,GLFWgammaramp*);
|
GLFWbool (*getGammaRamp)(_GLFWmonitor*,GLFWgammaramp*);
|
||||||
void (*setGammaRamp)(_GLFWmonitor*,const GLFWgammaramp*);
|
void (*setGammaRamp)(_GLFWmonitor*,const GLFWgammaramp*);
|
||||||
// window
|
// window
|
||||||
@ -722,7 +751,7 @@ struct _GLFWplatform
|
|||||||
void (*hideWindow)(_GLFWwindow*);
|
void (*hideWindow)(_GLFWwindow*);
|
||||||
void (*requestWindowAttention)(_GLFWwindow*);
|
void (*requestWindowAttention)(_GLFWwindow*);
|
||||||
void (*focusWindow)(_GLFWwindow*);
|
void (*focusWindow)(_GLFWwindow*);
|
||||||
void (*setWindowMonitor)(_GLFWwindow*,_GLFWmonitor*,int,int,int,int,int);
|
void (*setWindowMonitor)(_GLFWwindow*,_GLFWmonitor*,int,int,int,int,double); // TODO: reimplement for Wayland, X11, Win32
|
||||||
GLFWbool (*windowFocused)(_GLFWwindow*);
|
GLFWbool (*windowFocused)(_GLFWwindow*);
|
||||||
GLFWbool (*windowIconified)(_GLFWwindow*);
|
GLFWbool (*windowIconified)(_GLFWwindow*);
|
||||||
GLFWbool (*windowVisible)(_GLFWwindow*);
|
GLFWbool (*windowVisible)(_GLFWwindow*);
|
||||||
@ -763,7 +792,7 @@ struct _GLFWlibrary
|
|||||||
_GLFWfbconfig framebuffer;
|
_GLFWfbconfig framebuffer;
|
||||||
_GLFWwndconfig window;
|
_GLFWwndconfig window;
|
||||||
_GLFWctxconfig context;
|
_GLFWctxconfig context;
|
||||||
int refreshRate;
|
double refreshRate;
|
||||||
} hints;
|
} hints;
|
||||||
|
|
||||||
_GLFWerror* errorListHead;
|
_GLFWerror* errorListHead;
|
||||||
@ -954,9 +983,9 @@ GLFWbool _glfwRefreshContextAttribs(_GLFWwindow* window,
|
|||||||
const _GLFWctxconfig* ctxconfig);
|
const _GLFWctxconfig* ctxconfig);
|
||||||
GLFWbool _glfwIsValidContextConfig(const _GLFWctxconfig* ctxconfig);
|
GLFWbool _glfwIsValidContextConfig(const _GLFWctxconfig* ctxconfig);
|
||||||
|
|
||||||
const GLFWvidmode* _glfwChooseVideoMode(_GLFWmonitor* monitor,
|
const _GLFWvideoMode* _glfwChooseVideoMode(_GLFWmonitor* monitor,
|
||||||
const GLFWvidmode* desired);
|
const _GLFWvideoMode* desired);
|
||||||
int _glfwCompareVideoModes(const GLFWvidmode* first, const GLFWvidmode* second);
|
int _glfwCompareVideoModes(const _GLFWvideoMode* first, const _GLFWvideoMode* second);
|
||||||
_GLFWmonitor* _glfwAllocMonitor(const char* name, int widthMM, int heightMM);
|
_GLFWmonitor* _glfwAllocMonitor(const char* name, int widthMM, int heightMM);
|
||||||
void _glfwFreeMonitor(_GLFWmonitor* monitor);
|
void _glfwFreeMonitor(_GLFWmonitor* monitor);
|
||||||
void _glfwAllocGammaArrays(GLFWgammaramp* ramp, unsigned int size);
|
void _glfwAllocGammaArrays(GLFWgammaramp* ramp, unsigned int size);
|
||||||
|
167
src/monitor.c
167
src/monitor.c
@ -36,13 +36,32 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
||||||
|
// Copies the contents of a @ref _GLFWvideoMode into a @ref GLFWvidmode.
|
||||||
|
//
|
||||||
|
static void copyVideoMode(GLFWvidmode* target, const _GLFWvideoMode* source)
|
||||||
|
{
|
||||||
|
target->width = source->width;
|
||||||
|
target->height = source->height;
|
||||||
|
target->redBits = source->redBits;
|
||||||
|
target->greenBits = source->greenBits;
|
||||||
|
target->blueBits = source->blueBits;
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
// Win32 only provides integers. No need to round.
|
||||||
|
target->refreshRate = (int) source->refreshRate;
|
||||||
|
#else
|
||||||
|
target->refreshRate = (int) round(source->refreshRate);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
// Lexically compare video modes, used by qsort
|
// Lexically compare video modes, used by qsort
|
||||||
//
|
//
|
||||||
static int compareVideoModes(const void* fp, const void* sp)
|
static int compareVideoModes(const void* fp, const void* sp)
|
||||||
{
|
{
|
||||||
const GLFWvidmode* fm = fp;
|
double refRateDiff;
|
||||||
const GLFWvidmode* sm = sp;
|
const _GLFWvideoMode* fm = fp;
|
||||||
|
const _GLFWvideoMode* sm = sp;
|
||||||
const int fbpp = fm->redBits + fm->greenBits + fm->blueBits;
|
const int fbpp = fm->redBits + fm->greenBits + fm->blueBits;
|
||||||
const int sbpp = sm->redBits + sm->greenBits + sm->blueBits;
|
const int sbpp = sm->redBits + sm->greenBits + sm->blueBits;
|
||||||
const int farea = fm->width * fm->height;
|
const int farea = fm->width * fm->height;
|
||||||
@ -61,27 +80,46 @@ static int compareVideoModes(const void* fp, const void* sp)
|
|||||||
return fm->width - sm->width;
|
return fm->width - sm->width;
|
||||||
|
|
||||||
// Lastly sort on refresh rate
|
// Lastly sort on refresh rate
|
||||||
return fm->refreshRate - sm->refreshRate;
|
refRateDiff = fm->refreshRate - sm->refreshRate;
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
// All Win32 refresh rates are converted from integers
|
||||||
|
return (int) refRateDiff;
|
||||||
|
#else
|
||||||
|
// Limits the minimum absolute value to 1.0, to prevent different modes from
|
||||||
|
// evaluating to equal, which happens when the difference between the
|
||||||
|
// refresh rates is less than 1.0, and this number is truncated to an integer.
|
||||||
|
return (int) copysign(fmax(fabs(refRateDiff), 1.0), refRateDiff);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// Retrieves the available modes for the specified monitor
|
// Retrieves the available modes for the specified monitor
|
||||||
//
|
//
|
||||||
static GLFWbool refreshVideoModes(_GLFWmonitor* monitor)
|
static GLFWbool refreshVideoModes(_GLFWmonitor* monitor)
|
||||||
{
|
{
|
||||||
int modeCount;
|
int i, modeCount;
|
||||||
GLFWvidmode* modes;
|
_GLFWvideoMode* modes;
|
||||||
|
|
||||||
if (monitor->modes)
|
if (monitor->modes)
|
||||||
return GLFW_TRUE;
|
return GLFW_TRUE;
|
||||||
|
|
||||||
modes = _glfw.platform.getVideoModes(monitor, &modeCount);
|
modes = _glfw.platform.getVideoModes(monitor, &modeCount);
|
||||||
|
|
||||||
if (!modes)
|
if (!modes)
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
|
|
||||||
qsort(modes, modeCount, sizeof(GLFWvidmode), compareVideoModes);
|
qsort(modes, modeCount, sizeof(_GLFWvideoMode), compareVideoModes);
|
||||||
|
|
||||||
|
_glfw_free(monitor->modesOld);
|
||||||
|
monitor->modesOld = NULL;
|
||||||
|
|
||||||
_glfw_free(monitor->modes);
|
|
||||||
monitor->modes = modes;
|
monitor->modes = modes;
|
||||||
|
monitor->modesPointers = _glfw_realloc(monitor->modesPointers,
|
||||||
|
modeCount * sizeof(GLFWvideoMode*));
|
||||||
|
|
||||||
|
for (i = 0; i < modeCount; ++i)
|
||||||
|
monitor->modesPointers[i] = (GLFWvideoMode*) &modes[i];
|
||||||
|
|
||||||
monitor->modeCount = modeCount;
|
monitor->modeCount = modeCount;
|
||||||
|
|
||||||
return GLFW_TRUE;
|
return GLFW_TRUE;
|
||||||
@ -194,6 +232,8 @@ void _glfwFreeMonitor(_GLFWmonitor* monitor)
|
|||||||
_glfwFreeGammaArrays(&monitor->currentRamp);
|
_glfwFreeGammaArrays(&monitor->currentRamp);
|
||||||
|
|
||||||
_glfw_free(monitor->modes);
|
_glfw_free(monitor->modes);
|
||||||
|
_glfw_free(monitor->modesPointers);
|
||||||
|
_glfw_free(monitor->modesOld);
|
||||||
_glfw_free(monitor);
|
_glfw_free(monitor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -220,15 +260,15 @@ void _glfwFreeGammaArrays(GLFWgammaramp* ramp)
|
|||||||
|
|
||||||
// Chooses the video mode most closely matching the desired one
|
// Chooses the video mode most closely matching the desired one
|
||||||
//
|
//
|
||||||
const GLFWvidmode* _glfwChooseVideoMode(_GLFWmonitor* monitor,
|
const _GLFWvideoMode* _glfwChooseVideoMode(_GLFWmonitor* monitor,
|
||||||
const GLFWvidmode* desired)
|
const _GLFWvideoMode* desired)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
unsigned int sizeDiff, leastSizeDiff = UINT_MAX;
|
unsigned int sizeDiff, leastSizeDiff = UINT_MAX;
|
||||||
unsigned int rateDiff, leastRateDiff = UINT_MAX;
|
double rateDiff, leastRateDiff = DBL_MAX;
|
||||||
unsigned int colorDiff, leastColorDiff = UINT_MAX;
|
unsigned int colorDiff, leastColorDiff = UINT_MAX;
|
||||||
const GLFWvidmode* current;
|
const _GLFWvideoMode* current;
|
||||||
const GLFWvidmode* closest = NULL;
|
const _GLFWvideoMode* closest = NULL;
|
||||||
|
|
||||||
if (!refreshVideoModes(monitor))
|
if (!refreshVideoModes(monitor))
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -252,7 +292,7 @@ const GLFWvidmode* _glfwChooseVideoMode(_GLFWmonitor* monitor,
|
|||||||
(current->height - desired->height));
|
(current->height - desired->height));
|
||||||
|
|
||||||
if (desired->refreshRate != GLFW_DONT_CARE)
|
if (desired->refreshRate != GLFW_DONT_CARE)
|
||||||
rateDiff = abs(current->refreshRate - desired->refreshRate);
|
rateDiff = fabs(current->refreshRate - desired->refreshRate);
|
||||||
else
|
else
|
||||||
rateDiff = UINT_MAX - current->refreshRate;
|
rateDiff = UINT_MAX - current->refreshRate;
|
||||||
|
|
||||||
@ -270,9 +310,9 @@ const GLFWvidmode* _glfwChooseVideoMode(_GLFWmonitor* monitor,
|
|||||||
return closest;
|
return closest;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Performs lexical comparison between two @ref GLFWvidmode structures
|
// Performs lexical comparison between two @ref _GLFWvideoMode structures
|
||||||
//
|
//
|
||||||
int _glfwCompareVideoModes(const GLFWvidmode* fm, const GLFWvidmode* sm)
|
int _glfwCompareVideoModes(const _GLFWvideoMode* fm, const _GLFWvideoMode* sm)
|
||||||
{
|
{
|
||||||
return compareVideoModes(fm, sm);
|
return compareVideoModes(fm, sm);
|
||||||
}
|
}
|
||||||
@ -429,6 +469,45 @@ GLFWAPI GLFWmonitorfun glfwSetMonitorCallback(GLFWmonitorfun cbfun)
|
|||||||
}
|
}
|
||||||
|
|
||||||
GLFWAPI const GLFWvidmode* glfwGetVideoModes(GLFWmonitor* handle, int* count)
|
GLFWAPI const GLFWvidmode* glfwGetVideoModes(GLFWmonitor* handle, int* count)
|
||||||
|
{
|
||||||
|
int i, j;
|
||||||
|
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
|
||||||
|
if (!glfwGetVideoModes2(handle, count))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if (!monitor->modesOld)
|
||||||
|
{
|
||||||
|
monitor->modesOld = _glfw_calloc(monitor->modeCount, sizeof(GLFWvidmode));
|
||||||
|
|
||||||
|
monitor->modeCountOld = 0;
|
||||||
|
for (i = 0, j = 0; i < monitor->modeCount; ++i)
|
||||||
|
{
|
||||||
|
copyVideoMode(&monitor->modesOld[j], &monitor->modes[i]);
|
||||||
|
|
||||||
|
// Because the old video mode structure contains less precision
|
||||||
|
// than the new one, different new modes will lead to similar
|
||||||
|
// old ones, which must be ignored.
|
||||||
|
|
||||||
|
// The modes array is already sorted, so identical video modes
|
||||||
|
// will always be adjacent. Therefore, it's only necessary to
|
||||||
|
// test for equality with the previous mode in the array.
|
||||||
|
|
||||||
|
// The only difference between the old and new GLFW video modes,
|
||||||
|
// is that the new one allows higher precision refresh rates, so
|
||||||
|
// this is the only field that requires a comparison.
|
||||||
|
if (j > 0 && monitor->modesOld[j - 1].refreshRate == monitor->modesOld[j].refreshRate)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
++monitor->modeCountOld;
|
||||||
|
++j;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
*count = monitor->modeCountOld;
|
||||||
|
return monitor->modesOld;
|
||||||
|
}
|
||||||
|
|
||||||
|
GLFWAPI const GLFWvideoMode* const* glfwGetVideoModes2(GLFWmonitor* handle, int* count)
|
||||||
{
|
{
|
||||||
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
|
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
|
||||||
assert(monitor != NULL);
|
assert(monitor != NULL);
|
||||||
@ -442,7 +521,7 @@ GLFWAPI const GLFWvidmode* glfwGetVideoModes(GLFWmonitor* handle, int* count)
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
*count = monitor->modeCount;
|
*count = monitor->modeCount;
|
||||||
return monitor->modes;
|
return (const GLFWvideoMode* const *) monitor->modesPointers;
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWAPI const GLFWvidmode* glfwGetVideoMode(GLFWmonitor* handle)
|
GLFWAPI const GLFWvidmode* glfwGetVideoMode(GLFWmonitor* handle)
|
||||||
@ -453,7 +532,21 @@ GLFWAPI const GLFWvidmode* glfwGetVideoMode(GLFWmonitor* handle)
|
|||||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||||
|
|
||||||
_glfw.platform.getVideoMode(monitor, &monitor->currentMode);
|
_glfw.platform.getVideoMode(monitor, &monitor->currentMode);
|
||||||
return &monitor->currentMode;
|
|
||||||
|
copyVideoMode(&monitor->currentModeOld, &monitor->currentMode);
|
||||||
|
|
||||||
|
return &monitor->currentModeOld;
|
||||||
|
}
|
||||||
|
|
||||||
|
GLFWAPI const GLFWvideoMode* glfwGetVideoMode2(GLFWmonitor* handle)
|
||||||
|
{
|
||||||
|
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
|
||||||
|
assert(monitor != NULL);
|
||||||
|
|
||||||
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||||
|
|
||||||
|
_glfw.platform.getVideoMode(monitor, &monitor->currentMode);
|
||||||
|
return (GLFWvideoMode*) &monitor->currentMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWAPI void glfwSetGamma(GLFWmonitor* handle, float gamma)
|
GLFWAPI void glfwSetGamma(GLFWmonitor* handle, float gamma)
|
||||||
@ -546,3 +639,43 @@ GLFWAPI void glfwSetGammaRamp(GLFWmonitor* handle, const GLFWgammaramp* ramp)
|
|||||||
_glfw.platform.setGammaRamp(monitor, ramp);
|
_glfw.platform.setGammaRamp(monitor, ramp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
GLFWAPI int glfwVideoModesEqual(const GLFWvideoMode* first, const GLFWvideoMode* second)
|
||||||
|
{
|
||||||
|
if (memcmp(first, second, sizeof(_GLFWvideoMode)) == 0)
|
||||||
|
return GLFW_TRUE;
|
||||||
|
|
||||||
|
return GLFW_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
GLFWAPI void glfwVideoModeGetSize(const GLFWvideoMode* videoMode, int* width, int* height)
|
||||||
|
{
|
||||||
|
const _GLFWvideoMode* mode = (_GLFWvideoMode*) videoMode;
|
||||||
|
assert(videoMode != NULL);
|
||||||
|
|
||||||
|
if (width)
|
||||||
|
*width = mode->width;
|
||||||
|
if (height)
|
||||||
|
*height = mode->height;
|
||||||
|
}
|
||||||
|
|
||||||
|
GLFWAPI void glfwVideoModeGetColorDepth(const GLFWvideoMode* videoMode, int* red, int* green, int* blue)
|
||||||
|
{
|
||||||
|
const _GLFWvideoMode* mode = (_GLFWvideoMode*) videoMode;
|
||||||
|
assert(videoMode != NULL);
|
||||||
|
|
||||||
|
if (red)
|
||||||
|
*red = mode->redBits;
|
||||||
|
if (green)
|
||||||
|
*green = mode->greenBits;
|
||||||
|
if (blue)
|
||||||
|
*blue = mode->blueBits;
|
||||||
|
}
|
||||||
|
|
||||||
|
GLFWAPI double glfwVideoModeGetRefreshRate(const GLFWvideoMode* videoMode)
|
||||||
|
{
|
||||||
|
assert(videoMode != NULL);
|
||||||
|
|
||||||
|
return ((_GLFWvideoMode*) videoMode)->refreshRate;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -35,15 +35,15 @@
|
|||||||
|
|
||||||
// The the sole (fake) video mode of our (sole) fake monitor
|
// The the sole (fake) video mode of our (sole) fake monitor
|
||||||
//
|
//
|
||||||
static GLFWvidmode getVideoMode(void)
|
static _GLFWvideoMode getVideoMode(void)
|
||||||
{
|
{
|
||||||
GLFWvidmode mode;
|
_GLFWvideoMode mode;
|
||||||
mode.width = 1920;
|
mode.width = 1920;
|
||||||
mode.height = 1080;
|
mode.height = 1080;
|
||||||
mode.redBits = 8;
|
mode.redBits = 8;
|
||||||
mode.greenBits = 8;
|
mode.greenBits = 8;
|
||||||
mode.blueBits = 8;
|
mode.blueBits = 8;
|
||||||
mode.refreshRate = 60;
|
mode.refreshRate = 60.0;
|
||||||
return mode;
|
return mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ static GLFWvidmode getVideoMode(void)
|
|||||||
void _glfwPollMonitorsNull(void)
|
void _glfwPollMonitorsNull(void)
|
||||||
{
|
{
|
||||||
const float dpi = 141.f;
|
const float dpi = 141.f;
|
||||||
const GLFWvidmode mode = getVideoMode();
|
const _GLFWvideoMode mode = getVideoMode();
|
||||||
_GLFWmonitor* monitor = _glfwAllocMonitor("Null SuperNoop 0",
|
_GLFWmonitor* monitor = _glfwAllocMonitor("Null SuperNoop 0",
|
||||||
(int) (mode.width * 25.4f / dpi),
|
(int) (mode.width * 25.4f / dpi),
|
||||||
(int) (mode.height * 25.4f / dpi));
|
(int) (mode.height * 25.4f / dpi));
|
||||||
@ -91,7 +91,7 @@ void _glfwGetMonitorWorkareaNull(_GLFWmonitor* monitor,
|
|||||||
int* xpos, int* ypos,
|
int* xpos, int* ypos,
|
||||||
int* width, int* height)
|
int* width, int* height)
|
||||||
{
|
{
|
||||||
const GLFWvidmode mode = getVideoMode();
|
const _GLFWvideoMode mode = getVideoMode();
|
||||||
|
|
||||||
if (xpos)
|
if (xpos)
|
||||||
*xpos = 0;
|
*xpos = 0;
|
||||||
@ -103,15 +103,15 @@ void _glfwGetMonitorWorkareaNull(_GLFWmonitor* monitor,
|
|||||||
*height = mode.height - 10;
|
*height = mode.height - 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWvidmode* _glfwGetVideoModesNull(_GLFWmonitor* monitor, int* found)
|
_GLFWvideoMode* _glfwGetVideoModesNull(_GLFWmonitor* monitor, int* found)
|
||||||
{
|
{
|
||||||
GLFWvidmode* mode = _glfw_calloc(1, sizeof(GLFWvidmode));
|
_GLFWvideoMode* mode = _glfw_calloc(1, sizeof(_GLFWvideoMode));
|
||||||
*mode = getVideoMode();
|
*mode = getVideoMode();
|
||||||
*found = 1;
|
*found = 1;
|
||||||
return mode;
|
return mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwGetVideoModeNull(_GLFWmonitor* monitor, GLFWvidmode* mode)
|
void _glfwGetVideoModeNull(_GLFWmonitor* monitor, _GLFWvideoMode* mode)
|
||||||
{
|
{
|
||||||
*mode = getVideoMode();
|
*mode = getVideoMode();
|
||||||
}
|
}
|
||||||
|
@ -80,8 +80,8 @@ void _glfwFreeMonitorNull(_GLFWmonitor* monitor);
|
|||||||
void _glfwGetMonitorPosNull(_GLFWmonitor* monitor, int* xpos, int* ypos);
|
void _glfwGetMonitorPosNull(_GLFWmonitor* monitor, int* xpos, int* ypos);
|
||||||
void _glfwGetMonitorContentScaleNull(_GLFWmonitor* monitor, float* xscale, float* yscale);
|
void _glfwGetMonitorContentScaleNull(_GLFWmonitor* monitor, float* xscale, float* yscale);
|
||||||
void _glfwGetMonitorWorkareaNull(_GLFWmonitor* monitor, int* xpos, int* ypos, int* width, int* height);
|
void _glfwGetMonitorWorkareaNull(_GLFWmonitor* monitor, int* xpos, int* ypos, int* width, int* height);
|
||||||
GLFWvidmode* _glfwGetVideoModesNull(_GLFWmonitor* monitor, int* found);
|
_GLFWvideoMode* _glfwGetVideoModesNull(_GLFWmonitor* monitor, int* found);
|
||||||
void _glfwGetVideoModeNull(_GLFWmonitor* monitor, GLFWvidmode* mode);
|
void _glfwGetVideoModeNull(_GLFWmonitor* monitor, _GLFWvideoMode* mode);
|
||||||
GLFWbool _glfwGetGammaRampNull(_GLFWmonitor* monitor, GLFWgammaramp* ramp);
|
GLFWbool _glfwGetGammaRampNull(_GLFWmonitor* monitor, GLFWgammaramp* ramp);
|
||||||
void _glfwSetGammaRampNull(_GLFWmonitor* monitor, const GLFWgammaramp* ramp);
|
void _glfwSetGammaRampNull(_GLFWmonitor* monitor, const GLFWgammaramp* ramp);
|
||||||
|
|
||||||
@ -89,7 +89,7 @@ GLFWbool _glfwCreateWindowNull(_GLFWwindow* window, const _GLFWwndconfig* wndcon
|
|||||||
void _glfwDestroyWindowNull(_GLFWwindow* window);
|
void _glfwDestroyWindowNull(_GLFWwindow* window);
|
||||||
void _glfwSetWindowTitleNull(_GLFWwindow* window, const char* title);
|
void _glfwSetWindowTitleNull(_GLFWwindow* window, const char* title);
|
||||||
void _glfwSetWindowIconNull(_GLFWwindow* window, int count, const GLFWimage* images);
|
void _glfwSetWindowIconNull(_GLFWwindow* window, int count, const GLFWimage* images);
|
||||||
void _glfwSetWindowMonitorNull(_GLFWwindow* window, _GLFWmonitor* monitor, int xpos, int ypos, int width, int height, int refreshRate);
|
void _glfwSetWindowMonitorNull(_GLFWwindow* window, _GLFWmonitor* monitor, int xpos, int ypos, int width, int height, double refreshRate);
|
||||||
void _glfwGetWindowPosNull(_GLFWwindow* window, int* xpos, int* ypos);
|
void _glfwGetWindowPosNull(_GLFWwindow* window, int* xpos, int* ypos);
|
||||||
void _glfwSetWindowPosNull(_GLFWwindow* window, int xpos, int ypos);
|
void _glfwSetWindowPosNull(_GLFWwindow* window, int xpos, int ypos);
|
||||||
void _glfwGetWindowSizeNull(_GLFWwindow* window, int* width, int* height);
|
void _glfwGetWindowSizeNull(_GLFWwindow* window, int* width, int* height);
|
||||||
|
@ -52,7 +52,7 @@ static void applySizeLimits(_GLFWwindow* window, int* width, int* height)
|
|||||||
|
|
||||||
static void fitToMonitor(_GLFWwindow* window)
|
static void fitToMonitor(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
GLFWvidmode mode;
|
_GLFWvideoMode mode;
|
||||||
_glfwGetVideoModeNull(window->monitor, &mode);
|
_glfwGetVideoModeNull(window->monitor, &mode);
|
||||||
_glfwGetMonitorPosNull(window->monitor,
|
_glfwGetMonitorPosNull(window->monitor,
|
||||||
&window->null.xpos,
|
&window->null.xpos,
|
||||||
@ -191,7 +191,7 @@ void _glfwSetWindowMonitorNull(_GLFWwindow* window,
|
|||||||
_GLFWmonitor* monitor,
|
_GLFWmonitor* monitor,
|
||||||
int xpos, int ypos,
|
int xpos, int ypos,
|
||||||
int width, int height,
|
int width, int height,
|
||||||
int refreshRate)
|
double refreshRate)
|
||||||
{
|
{
|
||||||
if (window->monitor == monitor)
|
if (window->monitor == monitor)
|
||||||
{
|
{
|
||||||
|
@ -247,10 +247,10 @@ void _glfwPollMonitorsWin32(void)
|
|||||||
|
|
||||||
// Change the current video mode
|
// Change the current video mode
|
||||||
//
|
//
|
||||||
void _glfwSetVideoModeWin32(_GLFWmonitor* monitor, const GLFWvidmode* desired)
|
void _glfwSetVideoModeWin32(_GLFWmonitor* monitor, const _GLFWvideoMode* desired)
|
||||||
{
|
{
|
||||||
GLFWvidmode current;
|
_GLFWvideoMode current;
|
||||||
const GLFWvidmode* best;
|
const _GLFWvideoMode* best;
|
||||||
DEVMODEW dm;
|
DEVMODEW dm;
|
||||||
LONG result;
|
LONG result;
|
||||||
|
|
||||||
@ -266,7 +266,7 @@ void _glfwSetVideoModeWin32(_GLFWmonitor* monitor, const GLFWvidmode* desired)
|
|||||||
dm.dmPelsWidth = best->width;
|
dm.dmPelsWidth = best->width;
|
||||||
dm.dmPelsHeight = best->height;
|
dm.dmPelsHeight = best->height;
|
||||||
dm.dmBitsPerPel = best->redBits + best->greenBits + best->blueBits;
|
dm.dmBitsPerPel = best->redBits + best->greenBits + best->blueBits;
|
||||||
dm.dmDisplayFrequency = best->refreshRate;
|
dm.dmDisplayFrequency = (int) best->refreshRate;
|
||||||
|
|
||||||
if (dm.dmBitsPerPel < 15 || dm.dmBitsPerPel >= 24)
|
if (dm.dmBitsPerPel < 15 || dm.dmBitsPerPel >= 24)
|
||||||
dm.dmBitsPerPel = 32;
|
dm.dmBitsPerPel = 32;
|
||||||
@ -395,17 +395,17 @@ void _glfwGetMonitorWorkareaWin32(_GLFWmonitor* monitor,
|
|||||||
*height = mi.rcWork.bottom - mi.rcWork.top;
|
*height = mi.rcWork.bottom - mi.rcWork.top;
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWvidmode* _glfwGetVideoModesWin32(_GLFWmonitor* monitor, int* count)
|
_GLFWvideoMode* _glfwGetVideoModesWin32(_GLFWmonitor* monitor, int* count)
|
||||||
{
|
{
|
||||||
int modeIndex = 0, size = 0;
|
int modeIndex = 0, size = 0;
|
||||||
GLFWvidmode* result = NULL;
|
_GLFWvideoMode* result = NULL;
|
||||||
|
|
||||||
*count = 0;
|
*count = 0;
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
GLFWvidmode mode;
|
_GLFWvideoMode mode;
|
||||||
DEVMODEW dm;
|
DEVMODEW dm;
|
||||||
|
|
||||||
ZeroMemory(&dm, sizeof(dm));
|
ZeroMemory(&dm, sizeof(dm));
|
||||||
@ -454,7 +454,7 @@ GLFWvidmode* _glfwGetVideoModesWin32(_GLFWmonitor* monitor, int* count)
|
|||||||
if (*count == size)
|
if (*count == size)
|
||||||
{
|
{
|
||||||
size += 128;
|
size += 128;
|
||||||
result = (GLFWvidmode*) _glfw_realloc(result, size * sizeof(GLFWvidmode));
|
result = (_GLFWvideoMode*) _glfw_realloc(result, size * sizeof(_GLFWvideoMode));
|
||||||
}
|
}
|
||||||
|
|
||||||
(*count)++;
|
(*count)++;
|
||||||
@ -464,7 +464,7 @@ GLFWvidmode* _glfwGetVideoModesWin32(_GLFWmonitor* monitor, int* count)
|
|||||||
if (!*count)
|
if (!*count)
|
||||||
{
|
{
|
||||||
// HACK: Report the current mode if no valid modes were found
|
// HACK: Report the current mode if no valid modes were found
|
||||||
result = _glfw_calloc(1, sizeof(GLFWvidmode));
|
result = _glfw_calloc(1, sizeof(_GLFWvideoMode));
|
||||||
_glfwGetVideoModeWin32(monitor, result);
|
_glfwGetVideoModeWin32(monitor, result);
|
||||||
*count = 1;
|
*count = 1;
|
||||||
}
|
}
|
||||||
@ -472,7 +472,7 @@ GLFWvidmode* _glfwGetVideoModesWin32(_GLFWmonitor* monitor, int* count)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwGetVideoModeWin32(_GLFWmonitor* monitor, GLFWvidmode* mode)
|
void _glfwGetVideoModeWin32(_GLFWmonitor* monitor, _GLFWvideoMode* mode)
|
||||||
{
|
{
|
||||||
DEVMODEW dm;
|
DEVMODEW dm;
|
||||||
ZeroMemory(&dm, sizeof(dm));
|
ZeroMemory(&dm, sizeof(dm));
|
||||||
@ -482,7 +482,7 @@ void _glfwGetVideoModeWin32(_GLFWmonitor* monitor, GLFWvidmode* mode)
|
|||||||
|
|
||||||
mode->width = dm.dmPelsWidth;
|
mode->width = dm.dmPelsWidth;
|
||||||
mode->height = dm.dmPelsHeight;
|
mode->height = dm.dmPelsHeight;
|
||||||
mode->refreshRate = dm.dmDisplayFrequency;
|
mode->refreshRate = (double) dm.dmDisplayFrequency;
|
||||||
_glfwSplitBPP(dm.dmBitsPerPel,
|
_glfwSplitBPP(dm.dmBitsPerPel,
|
||||||
&mode->redBits,
|
&mode->redBits,
|
||||||
&mode->greenBits,
|
&mode->greenBits,
|
||||||
|
@ -535,7 +535,7 @@ void _glfwInputErrorWin32(int error, const char* description);
|
|||||||
void _glfwUpdateKeyNamesWin32(void);
|
void _glfwUpdateKeyNamesWin32(void);
|
||||||
|
|
||||||
void _glfwPollMonitorsWin32(void);
|
void _glfwPollMonitorsWin32(void);
|
||||||
void _glfwSetVideoModeWin32(_GLFWmonitor* monitor, const GLFWvidmode* desired);
|
void _glfwSetVideoModeWin32(_GLFWmonitor* monitor, const _GLFWvideoMode* desired);
|
||||||
void _glfwRestoreVideoModeWin32(_GLFWmonitor* monitor);
|
void _glfwRestoreVideoModeWin32(_GLFWmonitor* monitor);
|
||||||
void _glfwGetHMONITORContentScaleWin32(HMONITOR handle, float* xscale, float* yscale);
|
void _glfwGetHMONITORContentScaleWin32(HMONITOR handle, float* xscale, float* yscale);
|
||||||
|
|
||||||
@ -559,7 +559,7 @@ void _glfwShowWindowWin32(_GLFWwindow* window);
|
|||||||
void _glfwHideWindowWin32(_GLFWwindow* window);
|
void _glfwHideWindowWin32(_GLFWwindow* window);
|
||||||
void _glfwRequestWindowAttentionWin32(_GLFWwindow* window);
|
void _glfwRequestWindowAttentionWin32(_GLFWwindow* window);
|
||||||
void _glfwFocusWindowWin32(_GLFWwindow* window);
|
void _glfwFocusWindowWin32(_GLFWwindow* window);
|
||||||
void _glfwSetWindowMonitorWin32(_GLFWwindow* window, _GLFWmonitor* monitor, int xpos, int ypos, int width, int height, int refreshRate);
|
void _glfwSetWindowMonitorWin32(_GLFWwindow* window, _GLFWmonitor* monitor, int xpos, int ypos, int width, int height, double refreshRate);
|
||||||
GLFWbool _glfwWindowFocusedWin32(_GLFWwindow* window);
|
GLFWbool _glfwWindowFocusedWin32(_GLFWwindow* window);
|
||||||
GLFWbool _glfwWindowIconifiedWin32(_GLFWwindow* window);
|
GLFWbool _glfwWindowIconifiedWin32(_GLFWwindow* window);
|
||||||
GLFWbool _glfwWindowVisibleWin32(_GLFWwindow* window);
|
GLFWbool _glfwWindowVisibleWin32(_GLFWwindow* window);
|
||||||
@ -605,8 +605,8 @@ void _glfwFreeMonitorWin32(_GLFWmonitor* monitor);
|
|||||||
void _glfwGetMonitorPosWin32(_GLFWmonitor* monitor, int* xpos, int* ypos);
|
void _glfwGetMonitorPosWin32(_GLFWmonitor* monitor, int* xpos, int* ypos);
|
||||||
void _glfwGetMonitorContentScaleWin32(_GLFWmonitor* monitor, float* xscale, float* yscale);
|
void _glfwGetMonitorContentScaleWin32(_GLFWmonitor* monitor, float* xscale, float* yscale);
|
||||||
void _glfwGetMonitorWorkareaWin32(_GLFWmonitor* monitor, int* xpos, int* ypos, int* width, int* height);
|
void _glfwGetMonitorWorkareaWin32(_GLFWmonitor* monitor, int* xpos, int* ypos, int* width, int* height);
|
||||||
GLFWvidmode* _glfwGetVideoModesWin32(_GLFWmonitor* monitor, int* count);
|
_GLFWvideoMode* _glfwGetVideoModesWin32(_GLFWmonitor* monitor, int* count);
|
||||||
void _glfwGetVideoModeWin32(_GLFWmonitor* monitor, GLFWvidmode* mode);
|
void _glfwGetVideoModeWin32(_GLFWmonitor* monitor, _GLFWvideoMode* mode);
|
||||||
GLFWbool _glfwGetGammaRampWin32(_GLFWmonitor* monitor, GLFWgammaramp* ramp);
|
GLFWbool _glfwGetGammaRampWin32(_GLFWmonitor* monitor, GLFWgammaramp* ramp);
|
||||||
void _glfwSetGammaRampWin32(_GLFWmonitor* monitor, const GLFWgammaramp* ramp);
|
void _glfwSetGammaRampWin32(_GLFWmonitor* monitor, const GLFWgammaramp* ramp);
|
||||||
|
|
||||||
|
@ -1773,7 +1773,7 @@ void _glfwSetWindowMonitorWin32(_GLFWwindow* window,
|
|||||||
_GLFWmonitor* monitor,
|
_GLFWmonitor* monitor,
|
||||||
int xpos, int ypos,
|
int xpos, int ypos,
|
||||||
int width, int height,
|
int width, int height,
|
||||||
int refreshRate)
|
double refreshRate)
|
||||||
{
|
{
|
||||||
if (window->monitor == monitor)
|
if (window->monitor == monitor)
|
||||||
{
|
{
|
||||||
|
30
src/window.c
30
src/window.c
@ -427,12 +427,27 @@ GLFWAPI void glfwWindowHint(int hint, int value)
|
|||||||
case GLFW_CONTEXT_RELEASE_BEHAVIOR:
|
case GLFW_CONTEXT_RELEASE_BEHAVIOR:
|
||||||
_glfw.hints.context.release = value;
|
_glfw.hints.context.release = value;
|
||||||
return;
|
return;
|
||||||
|
// Supported as an integer hint for backwards-compatability
|
||||||
|
case GLFW_REFRESH_RATE:
|
||||||
|
_glfw.hints.refreshRate = (double) value;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_glfwInputError(GLFW_INVALID_ENUM, "Invalid window hint 0x%08X", hint);
|
||||||
|
}
|
||||||
|
|
||||||
|
GLFWAPI void glfwWindowHintDouble(int hint, double value)
|
||||||
|
{
|
||||||
|
_GLFW_REQUIRE_INIT();
|
||||||
|
|
||||||
|
switch (hint)
|
||||||
|
{
|
||||||
case GLFW_REFRESH_RATE:
|
case GLFW_REFRESH_RATE:
|
||||||
_glfw.hints.refreshRate = value;
|
_glfw.hints.refreshRate = value;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_glfwInputError(GLFW_INVALID_ENUM, "Invalid window hint 0x%08X", hint);
|
_glfwInputError(GLFW_INVALID_ENUM, "Invalid window hint double 0x%08X", hint);
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWAPI void glfwWindowHintString(int hint, const char* value)
|
GLFWAPI void glfwWindowHintString(int hint, const char* value)
|
||||||
@ -968,12 +983,19 @@ GLFWAPI void glfwSetWindowMonitor(GLFWwindow* wh,
|
|||||||
int xpos, int ypos,
|
int xpos, int ypos,
|
||||||
int width, int height,
|
int width, int height,
|
||||||
int refreshRate)
|
int refreshRate)
|
||||||
|
{
|
||||||
|
glfwSetWindowMonitor2(wh, mh, xpos, ypos, width, height, refreshRate);
|
||||||
|
}
|
||||||
|
|
||||||
|
GLFWAPI void glfwSetWindowMonitor2(GLFWwindow* wh,
|
||||||
|
GLFWmonitor* mh,
|
||||||
|
int xpos, int ypos,
|
||||||
|
int width, int height,
|
||||||
|
double refreshRate)
|
||||||
{
|
{
|
||||||
_GLFWwindow* window = (_GLFWwindow*) wh;
|
_GLFWwindow* window = (_GLFWwindow*) wh;
|
||||||
_GLFWmonitor* monitor = (_GLFWmonitor*) mh;
|
_GLFWmonitor* monitor = (_GLFWmonitor*) mh;
|
||||||
assert(window != NULL);
|
assert(window != NULL);
|
||||||
assert(width >= 0);
|
|
||||||
assert(height >= 0);
|
|
||||||
|
|
||||||
_GLFW_REQUIRE_INIT();
|
_GLFW_REQUIRE_INIT();
|
||||||
|
|
||||||
@ -988,7 +1010,7 @@ GLFWAPI void glfwSetWindowMonitor(GLFWwindow* wh,
|
|||||||
if (refreshRate < 0 && refreshRate != GLFW_DONT_CARE)
|
if (refreshRate < 0 && refreshRate != GLFW_DONT_CARE)
|
||||||
{
|
{
|
||||||
_glfwInputError(GLFW_INVALID_VALUE,
|
_glfwInputError(GLFW_INVALID_VALUE,
|
||||||
"Invalid refresh rate %i",
|
"Invalid refresh rate %f",
|
||||||
refreshRate);
|
refreshRate);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -69,18 +69,18 @@ static void outputHandleMode(void* userData,
|
|||||||
int32_t refresh)
|
int32_t refresh)
|
||||||
{
|
{
|
||||||
struct _GLFWmonitor* monitor = userData;
|
struct _GLFWmonitor* monitor = userData;
|
||||||
GLFWvidmode mode;
|
_GLFWvideoMode mode;
|
||||||
|
|
||||||
mode.width = width;
|
mode.width = width;
|
||||||
mode.height = height;
|
mode.height = height;
|
||||||
mode.redBits = 8;
|
mode.redBits = 8;
|
||||||
mode.greenBits = 8;
|
mode.greenBits = 8;
|
||||||
mode.blueBits = 8;
|
mode.blueBits = 8;
|
||||||
mode.refreshRate = (int) round(refresh / 1000.0);
|
mode.refreshRate = refresh / 1000.0;
|
||||||
|
|
||||||
monitor->modeCount++;
|
monitor->modeCount++;
|
||||||
monitor->modes =
|
monitor->modes =
|
||||||
_glfw_realloc(monitor->modes, monitor->modeCount * sizeof(GLFWvidmode));
|
_glfw_realloc(monitor->modes, monitor->modeCount * sizeof(_GLFWvideoMode));
|
||||||
monitor->modes[monitor->modeCount - 1] = mode;
|
monitor->modes[monitor->modeCount - 1] = mode;
|
||||||
|
|
||||||
if (flags & WL_OUTPUT_MODE_CURRENT)
|
if (flags & WL_OUTPUT_MODE_CURRENT)
|
||||||
@ -94,7 +94,7 @@ static void outputHandleDone(void* userData, struct wl_output* output)
|
|||||||
if (monitor->widthMM <= 0 || monitor->heightMM <= 0)
|
if (monitor->widthMM <= 0 || monitor->heightMM <= 0)
|
||||||
{
|
{
|
||||||
// If Wayland does not provide a physical size, assume the default 96 DPI
|
// If Wayland does not provide a physical size, assume the default 96 DPI
|
||||||
const GLFWvidmode* mode = &monitor->modes[monitor->wl.currentMode];
|
const _GLFWvideoMode* mode = &monitor->modes[monitor->wl.currentMode];
|
||||||
monitor->widthMM = (int) (mode->width * 25.4f / 96.f);
|
monitor->widthMM = (int) (mode->width * 25.4f / 96.f);
|
||||||
monitor->heightMM = (int) (mode->height * 25.4f / 96.f);
|
monitor->heightMM = (int) (mode->height * 25.4f / 96.f);
|
||||||
}
|
}
|
||||||
@ -236,13 +236,13 @@ void _glfwGetMonitorWorkareaWayland(_GLFWmonitor* monitor,
|
|||||||
*height = monitor->modes[monitor->wl.currentMode].height;
|
*height = monitor->modes[monitor->wl.currentMode].height;
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWvidmode* _glfwGetVideoModesWayland(_GLFWmonitor* monitor, int* found)
|
_GLFWvideoMode* _glfwGetVideoModesWayland(_GLFWmonitor* monitor, int* found)
|
||||||
{
|
{
|
||||||
*found = monitor->modeCount;
|
*found = monitor->modeCount;
|
||||||
return monitor->modes;
|
return monitor->modes;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwGetVideoModeWayland(_GLFWmonitor* monitor, GLFWvidmode* mode)
|
void _glfwGetVideoModeWayland(_GLFWmonitor* monitor, _GLFWvideoMode* mode)
|
||||||
{
|
{
|
||||||
*mode = monitor->modes[monitor->wl.currentMode];
|
*mode = monitor->modes[monitor->wl.currentMode];
|
||||||
}
|
}
|
||||||
|
@ -462,7 +462,7 @@ void _glfwShowWindowWayland(_GLFWwindow* window);
|
|||||||
void _glfwHideWindowWayland(_GLFWwindow* window);
|
void _glfwHideWindowWayland(_GLFWwindow* window);
|
||||||
void _glfwRequestWindowAttentionWayland(_GLFWwindow* window);
|
void _glfwRequestWindowAttentionWayland(_GLFWwindow* window);
|
||||||
void _glfwFocusWindowWayland(_GLFWwindow* window);
|
void _glfwFocusWindowWayland(_GLFWwindow* window);
|
||||||
void _glfwSetWindowMonitorWayland(_GLFWwindow* window, _GLFWmonitor* monitor, int xpos, int ypos, int width, int height, int refreshRate);
|
void _glfwSetWindowMonitorWayland(_GLFWwindow* window, _GLFWmonitor* monitor, int xpos, int ypos, int width, int height, double refreshRate);
|
||||||
GLFWbool _glfwWindowFocusedWayland(_GLFWwindow* window);
|
GLFWbool _glfwWindowFocusedWayland(_GLFWwindow* window);
|
||||||
GLFWbool _glfwWindowIconifiedWayland(_GLFWwindow* window);
|
GLFWbool _glfwWindowIconifiedWayland(_GLFWwindow* window);
|
||||||
GLFWbool _glfwWindowVisibleWayland(_GLFWwindow* window);
|
GLFWbool _glfwWindowVisibleWayland(_GLFWwindow* window);
|
||||||
@ -508,8 +508,8 @@ void _glfwFreeMonitorWayland(_GLFWmonitor* monitor);
|
|||||||
void _glfwGetMonitorPosWayland(_GLFWmonitor* monitor, int* xpos, int* ypos);
|
void _glfwGetMonitorPosWayland(_GLFWmonitor* monitor, int* xpos, int* ypos);
|
||||||
void _glfwGetMonitorContentScaleWayland(_GLFWmonitor* monitor, float* xscale, float* yscale);
|
void _glfwGetMonitorContentScaleWayland(_GLFWmonitor* monitor, float* xscale, float* yscale);
|
||||||
void _glfwGetMonitorWorkareaWayland(_GLFWmonitor* monitor, int* xpos, int* ypos, int* width, int* height);
|
void _glfwGetMonitorWorkareaWayland(_GLFWmonitor* monitor, int* xpos, int* ypos, int* width, int* height);
|
||||||
GLFWvidmode* _glfwGetVideoModesWayland(_GLFWmonitor* monitor, int* count);
|
_GLFWvideoMode* _glfwGetVideoModesWayland(_GLFWmonitor* monitor, int* count);
|
||||||
void _glfwGetVideoModeWayland(_GLFWmonitor* monitor, GLFWvidmode* mode);
|
void _glfwGetVideoModeWayland(_GLFWmonitor* monitor, _GLFWvideoMode* mode);
|
||||||
GLFWbool _glfwGetGammaRampWayland(_GLFWmonitor* monitor, GLFWgammaramp* ramp);
|
GLFWbool _glfwGetGammaRampWayland(_GLFWmonitor* monitor, GLFWgammaramp* ramp);
|
||||||
void _glfwSetGammaRampWayland(_GLFWmonitor* monitor, const GLFWgammaramp* ramp);
|
void _glfwSetGammaRampWayland(_GLFWmonitor* monitor, const GLFWgammaramp* ramp);
|
||||||
|
|
||||||
|
@ -2102,7 +2102,7 @@ void _glfwSetWindowMonitorWayland(_GLFWwindow* window,
|
|||||||
_GLFWmonitor* monitor,
|
_GLFWmonitor* monitor,
|
||||||
int xpos, int ypos,
|
int xpos, int ypos,
|
||||||
int width, int height,
|
int width, int height,
|
||||||
int refreshRate)
|
double refreshRate)
|
||||||
{
|
{
|
||||||
if (window->monitor == monitor)
|
if (window->monitor == monitor)
|
||||||
{
|
{
|
||||||
|
@ -49,7 +49,7 @@ static GLFWbool modeIsGood(const XRRModeInfo* mi)
|
|||||||
static int calculateRefreshRate(const XRRModeInfo* mi)
|
static int calculateRefreshRate(const XRRModeInfo* mi)
|
||||||
{
|
{
|
||||||
if (mi->hTotal && mi->vTotal)
|
if (mi->hTotal && mi->vTotal)
|
||||||
return (int) round((double) mi->dotClock / ((double) mi->hTotal * (double) mi->vTotal));
|
return (double) mi->dotClock / ((double) mi->hTotal * (double) mi->vTotal);
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -69,10 +69,10 @@ static const XRRModeInfo* getModeInfo(const XRRScreenResources* sr, RRMode id)
|
|||||||
|
|
||||||
// Convert RandR mode info to GLFW video mode
|
// Convert RandR mode info to GLFW video mode
|
||||||
//
|
//
|
||||||
static GLFWvidmode vidmodeFromModeInfo(const XRRModeInfo* mi,
|
static _GLFWvideoMode vidmodeFromModeInfo(const XRRModeInfo* mi,
|
||||||
const XRRCrtcInfo* ci)
|
const XRRCrtcInfo* ci)
|
||||||
{
|
{
|
||||||
GLFWvidmode mode;
|
_GLFWvideoMode mode;
|
||||||
|
|
||||||
if (ci->rotation == RR_Rotate_90 || ci->rotation == RR_Rotate_270)
|
if (ci->rotation == RR_Rotate_90 || ci->rotation == RR_Rotate_270)
|
||||||
{
|
{
|
||||||
@ -226,14 +226,14 @@ void _glfwPollMonitorsX11(void)
|
|||||||
|
|
||||||
// Set the current video mode for the specified monitor
|
// Set the current video mode for the specified monitor
|
||||||
//
|
//
|
||||||
void _glfwSetVideoModeX11(_GLFWmonitor* monitor, const GLFWvidmode* desired)
|
void _glfwSetVideoModeX11(_GLFWmonitor* monitor, const _GLFWvideoMode* desired)
|
||||||
{
|
{
|
||||||
if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken)
|
if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken)
|
||||||
{
|
{
|
||||||
GLFWvidmode current;
|
_GLFWvideoMode current;
|
||||||
RRMode native = None;
|
RRMode native = None;
|
||||||
|
|
||||||
const GLFWvidmode* best = _glfwChooseVideoMode(monitor, desired);
|
const _GLFWvideoMode* best = _glfwChooseVideoMode(monitor, desired);
|
||||||
_glfwGetVideoModeX11(monitor, ¤t);
|
_glfwGetVideoModeX11(monitor, ¤t);
|
||||||
if (_glfwCompareVideoModes(¤t, best) == 0)
|
if (_glfwCompareVideoModes(¤t, best) == 0)
|
||||||
return;
|
return;
|
||||||
@ -249,7 +249,7 @@ void _glfwSetVideoModeX11(_GLFWmonitor* monitor, const GLFWvidmode* desired)
|
|||||||
if (!modeIsGood(mi))
|
if (!modeIsGood(mi))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const GLFWvidmode mode = vidmodeFromModeInfo(mi, ci);
|
const _GLFWvideoMode mode = vidmodeFromModeInfo(mi, ci);
|
||||||
if (_glfwCompareVideoModes(best, &mode) == 0)
|
if (_glfwCompareVideoModes(best, &mode) == 0)
|
||||||
{
|
{
|
||||||
native = mi->id;
|
native = mi->id;
|
||||||
@ -441,9 +441,9 @@ void _glfwGetMonitorWorkareaX11(_GLFWmonitor* monitor,
|
|||||||
*height = areaHeight;
|
*height = areaHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWvidmode* _glfwGetVideoModesX11(_GLFWmonitor* monitor, int* count)
|
_GLFWvideoMode* _glfwGetVideoModesX11(_GLFWmonitor* monitor, int* count)
|
||||||
{
|
{
|
||||||
GLFWvidmode* result;
|
_GLFWvideoMode* result;
|
||||||
|
|
||||||
*count = 0;
|
*count = 0;
|
||||||
|
|
||||||
@ -454,7 +454,7 @@ GLFWvidmode* _glfwGetVideoModesX11(_GLFWmonitor* monitor, int* count)
|
|||||||
XRRCrtcInfo* ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);
|
XRRCrtcInfo* ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);
|
||||||
XRROutputInfo* oi = XRRGetOutputInfo(_glfw.x11.display, sr, monitor->x11.output);
|
XRROutputInfo* oi = XRRGetOutputInfo(_glfw.x11.display, sr, monitor->x11.output);
|
||||||
|
|
||||||
result = _glfw_calloc(oi->nmode, sizeof(GLFWvidmode));
|
result = _glfw_calloc(oi->nmode, sizeof(_GLFWvideoMode));
|
||||||
|
|
||||||
for (int i = 0; i < oi->nmode; i++)
|
for (int i = 0; i < oi->nmode; i++)
|
||||||
{
|
{
|
||||||
@ -462,7 +462,7 @@ GLFWvidmode* _glfwGetVideoModesX11(_GLFWmonitor* monitor, int* count)
|
|||||||
if (!modeIsGood(mi))
|
if (!modeIsGood(mi))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const GLFWvidmode mode = vidmodeFromModeInfo(mi, ci);
|
const _GLFWvideoMode mode = vidmodeFromModeInfo(mi, ci);
|
||||||
int j;
|
int j;
|
||||||
|
|
||||||
for (j = 0; j < *count; j++)
|
for (j = 0; j < *count; j++)
|
||||||
@ -486,14 +486,14 @@ GLFWvidmode* _glfwGetVideoModesX11(_GLFWmonitor* monitor, int* count)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
*count = 1;
|
*count = 1;
|
||||||
result = _glfw_calloc(1, sizeof(GLFWvidmode));
|
result = _glfw_calloc(1, sizeof(_GLFWvideoMode));
|
||||||
_glfwGetVideoModeX11(monitor, result);
|
_glfwGetVideoModeX11(monitor, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwGetVideoModeX11(_GLFWmonitor* monitor, GLFWvidmode* mode)
|
void _glfwGetVideoModeX11(_GLFWmonitor* monitor, _GLFWvideoMode* mode)
|
||||||
{
|
{
|
||||||
if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken)
|
if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken)
|
||||||
{
|
{
|
||||||
|
@ -921,7 +921,7 @@ void _glfwShowWindowX11(_GLFWwindow* window);
|
|||||||
void _glfwHideWindowX11(_GLFWwindow* window);
|
void _glfwHideWindowX11(_GLFWwindow* window);
|
||||||
void _glfwRequestWindowAttentionX11(_GLFWwindow* window);
|
void _glfwRequestWindowAttentionX11(_GLFWwindow* window);
|
||||||
void _glfwFocusWindowX11(_GLFWwindow* window);
|
void _glfwFocusWindowX11(_GLFWwindow* window);
|
||||||
void _glfwSetWindowMonitorX11(_GLFWwindow* window, _GLFWmonitor* monitor, int xpos, int ypos, int width, int height, int refreshRate);
|
void _glfwSetWindowMonitorX11(_GLFWwindow* window, _GLFWmonitor* monitor, int xpos, int ypos, int width, int height, double refreshRate);
|
||||||
GLFWbool _glfwWindowFocusedX11(_GLFWwindow* window);
|
GLFWbool _glfwWindowFocusedX11(_GLFWwindow* window);
|
||||||
GLFWbool _glfwWindowIconifiedX11(_GLFWwindow* window);
|
GLFWbool _glfwWindowIconifiedX11(_GLFWwindow* window);
|
||||||
GLFWbool _glfwWindowVisibleX11(_GLFWwindow* window);
|
GLFWbool _glfwWindowVisibleX11(_GLFWwindow* window);
|
||||||
@ -967,13 +967,13 @@ void _glfwFreeMonitorX11(_GLFWmonitor* monitor);
|
|||||||
void _glfwGetMonitorPosX11(_GLFWmonitor* monitor, int* xpos, int* ypos);
|
void _glfwGetMonitorPosX11(_GLFWmonitor* monitor, int* xpos, int* ypos);
|
||||||
void _glfwGetMonitorContentScaleX11(_GLFWmonitor* monitor, float* xscale, float* yscale);
|
void _glfwGetMonitorContentScaleX11(_GLFWmonitor* monitor, float* xscale, float* yscale);
|
||||||
void _glfwGetMonitorWorkareaX11(_GLFWmonitor* monitor, int* xpos, int* ypos, int* width, int* height);
|
void _glfwGetMonitorWorkareaX11(_GLFWmonitor* monitor, int* xpos, int* ypos, int* width, int* height);
|
||||||
GLFWvidmode* _glfwGetVideoModesX11(_GLFWmonitor* monitor, int* count);
|
_GLFWvideoMode* _glfwGetVideoModesX11(_GLFWmonitor* monitor, int* count);
|
||||||
void _glfwGetVideoModeX11(_GLFWmonitor* monitor, GLFWvidmode* mode);
|
void _glfwGetVideoModeX11(_GLFWmonitor* monitor, _GLFWvideoMode* mode);
|
||||||
GLFWbool _glfwGetGammaRampX11(_GLFWmonitor* monitor, GLFWgammaramp* ramp);
|
GLFWbool _glfwGetGammaRampX11(_GLFWmonitor* monitor, GLFWgammaramp* ramp);
|
||||||
void _glfwSetGammaRampX11(_GLFWmonitor* monitor, const GLFWgammaramp* ramp);
|
void _glfwSetGammaRampX11(_GLFWmonitor* monitor, const GLFWgammaramp* ramp);
|
||||||
|
|
||||||
void _glfwPollMonitorsX11(void);
|
void _glfwPollMonitorsX11(void);
|
||||||
void _glfwSetVideoModeX11(_GLFWmonitor* monitor, const GLFWvidmode* desired);
|
void _glfwSetVideoModeX11(_GLFWmonitor* monitor, const _GLFWvideoMode* desired);
|
||||||
void _glfwRestoreVideoModeX11(_GLFWmonitor* monitor);
|
void _glfwRestoreVideoModeX11(_GLFWmonitor* monitor);
|
||||||
|
|
||||||
Cursor _glfwCreateNativeCursorX11(const GLFWimage* image, int xhot, int yhot);
|
Cursor _glfwCreateNativeCursorX11(const GLFWimage* image, int xhot, int yhot);
|
||||||
|
@ -1106,7 +1106,7 @@ static void acquireMonitor(_GLFWwindow* window)
|
|||||||
if (window->x11.overrideRedirect)
|
if (window->x11.overrideRedirect)
|
||||||
{
|
{
|
||||||
int xpos, ypos;
|
int xpos, ypos;
|
||||||
GLFWvidmode mode;
|
_GLFWvideoMode mode;
|
||||||
|
|
||||||
// Manually position the window over its monitor
|
// Manually position the window over its monitor
|
||||||
_glfwGetMonitorPosX11(window->monitor, &xpos, &ypos);
|
_glfwGetMonitorPosX11(window->monitor, &xpos, &ypos);
|
||||||
@ -2470,7 +2470,7 @@ void _glfwSetWindowMonitorX11(_GLFWwindow* window,
|
|||||||
_GLFWmonitor* monitor,
|
_GLFWmonitor* monitor,
|
||||||
int xpos, int ypos,
|
int xpos, int ypos,
|
||||||
int width, int height,
|
int width, int height,
|
||||||
int refreshRate)
|
double refreshRate)
|
||||||
{
|
{
|
||||||
if (window->monitor == monitor)
|
if (window->monitor == monitor)
|
||||||
{
|
{
|
||||||
|
127
tests/monitors.c
127
tests/monitors.c
@ -41,6 +41,7 @@
|
|||||||
|
|
||||||
enum Mode
|
enum Mode
|
||||||
{
|
{
|
||||||
|
LIST_MODE_OLD,
|
||||||
LIST_MODE,
|
LIST_MODE,
|
||||||
TEST_MODE
|
TEST_MODE
|
||||||
};
|
};
|
||||||
@ -74,6 +75,32 @@ static const char* format_mode(const GLFWvidmode* mode)
|
|||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char* format_mode2(const GLFWvideoMode* mode)
|
||||||
|
{
|
||||||
|
int width, height;
|
||||||
|
int r, g, b;
|
||||||
|
float rate;
|
||||||
|
|
||||||
|
glfwVideoModeGetSize(mode, &width, &height);
|
||||||
|
glfwVideoModeGetColorDepth(mode, &r, &g, &b);
|
||||||
|
rate = glfwVideoModeGetRefreshRate(mode);
|
||||||
|
|
||||||
|
static char buffer[512];
|
||||||
|
const int gcd = euclid(width, height);
|
||||||
|
|
||||||
|
snprintf(buffer,
|
||||||
|
sizeof(buffer),
|
||||||
|
"%i x %i x %i (%i:%i) (%i %i %i) %f Hz",
|
||||||
|
width, height,
|
||||||
|
r + g + b,
|
||||||
|
width / gcd, height / gcd,
|
||||||
|
r, g, b,
|
||||||
|
rate);
|
||||||
|
|
||||||
|
buffer[sizeof(buffer) - 1] = '\0';
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
||||||
static void error_callback(int error, const char* description)
|
static void error_callback(int error, const char* description)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Error: %s\n", description);
|
fprintf(stderr, "Error: %s\n", description);
|
||||||
@ -131,36 +158,83 @@ static void list_modes(GLFWmonitor* monitor)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void list_modes2(GLFWmonitor* monitor)
|
||||||
|
{
|
||||||
|
int width, height;
|
||||||
|
int count, x, y, width_mm, height_mm, i;
|
||||||
|
int workarea_x, workarea_y, workarea_width, workarea_height;
|
||||||
|
float xscale, yscale;
|
||||||
|
|
||||||
|
const GLFWvideoMode* mode = glfwGetVideoMode2(monitor);
|
||||||
|
const GLFWvideoMode* const* modes = glfwGetVideoModes2(monitor, &count);
|
||||||
|
|
||||||
|
glfwGetMonitorPos(monitor, &x, &y);
|
||||||
|
glfwGetMonitorPhysicalSize(monitor, &width_mm, &height_mm);
|
||||||
|
glfwGetMonitorContentScale(monitor, &xscale, &yscale);
|
||||||
|
glfwGetMonitorWorkarea(monitor, &workarea_x, &workarea_y, &workarea_width, &workarea_height);
|
||||||
|
glfwVideoModeGetSize(mode, &width, &height);
|
||||||
|
|
||||||
|
printf("Name: %s (%s)\n",
|
||||||
|
glfwGetMonitorName(monitor),
|
||||||
|
glfwGetPrimaryMonitor() == monitor ? "primary" : "secondary");
|
||||||
|
printf("Current mode: %s\n", format_mode2(mode));
|
||||||
|
printf("Virtual position: %i, %i\n", x, y);
|
||||||
|
printf("Content scale: %f x %f\n", xscale, yscale);
|
||||||
|
|
||||||
|
printf("Physical size: %i x %i mm (%0.2f dpi at %i x %i)\n",
|
||||||
|
width_mm, height_mm, width * 25.4f / width_mm, width, height);
|
||||||
|
printf("Monitor work area: %i x %i starting at %i, %i\n",
|
||||||
|
workarea_width, workarea_height, workarea_x, workarea_y);
|
||||||
|
|
||||||
|
printf("Modes:\n");
|
||||||
|
|
||||||
|
for (i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
printf("%3u: %s", (unsigned int) i, format_mode2(modes[i]));
|
||||||
|
|
||||||
|
if (glfwVideoModesEqual(mode, modes[i]))
|
||||||
|
printf(" (current mode)");
|
||||||
|
|
||||||
|
putchar('\n');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void test_modes(GLFWmonitor* monitor)
|
static void test_modes(GLFWmonitor* monitor)
|
||||||
{
|
{
|
||||||
int i, count;
|
int i, count;
|
||||||
GLFWwindow* window;
|
GLFWwindow* window;
|
||||||
const GLFWvidmode* modes = glfwGetVideoModes(monitor, &count);
|
const GLFWvideoMode* const* modes = glfwGetVideoModes2(monitor, &count);
|
||||||
|
|
||||||
for (i = 0; i < count; i++)
|
for (i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
const GLFWvidmode* mode = modes + i;
|
const GLFWvideoMode* mode = modes[i];
|
||||||
GLFWvidmode current;
|
int width, height, currentWidth, currentHeight;
|
||||||
|
int red, green, blue, currentRed, currentGreen, currentBlue;
|
||||||
|
double refreshRate, currentRefreshRate;
|
||||||
|
|
||||||
glfwWindowHint(GLFW_RED_BITS, mode->redBits);
|
glfwVideoModeGetSize(mode, &width, &height);
|
||||||
glfwWindowHint(GLFW_GREEN_BITS, mode->greenBits);
|
glfwVideoModeGetColorDepth(mode, &red, &green, &blue);
|
||||||
glfwWindowHint(GLFW_BLUE_BITS, mode->blueBits);
|
refreshRate = glfwVideoModeGetRefreshRate(mode);
|
||||||
glfwWindowHint(GLFW_REFRESH_RATE, mode->refreshRate);
|
|
||||||
|
glfwWindowHint(GLFW_RED_BITS, red);
|
||||||
|
glfwWindowHint(GLFW_GREEN_BITS, green);
|
||||||
|
glfwWindowHint(GLFW_BLUE_BITS, blue);
|
||||||
|
glfwWindowHintDouble(GLFW_REFRESH_RATE, refreshRate);
|
||||||
|
|
||||||
printf("Testing mode %u on monitor %s: %s\n",
|
printf("Testing mode %u on monitor %s: %s\n",
|
||||||
(unsigned int) i,
|
(unsigned int) i,
|
||||||
glfwGetMonitorName(monitor),
|
glfwGetMonitorName(monitor),
|
||||||
format_mode(mode));
|
format_mode2(mode));
|
||||||
|
|
||||||
window = glfwCreateWindow(mode->width, mode->height,
|
window = glfwCreateWindow(width, height,
|
||||||
"Video Mode Test",
|
"Video Mode Test",
|
||||||
glfwGetPrimaryMonitor(),
|
monitor,
|
||||||
NULL);
|
NULL);
|
||||||
if (!window)
|
if (!window)
|
||||||
{
|
{
|
||||||
printf("Failed to enter mode %u: %s\n",
|
printf("Failed to enter mode %u: %s\n",
|
||||||
(unsigned int) i,
|
(unsigned int) i,
|
||||||
format_mode(mode));
|
format_mode2(mode));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -188,26 +262,26 @@ static void test_modes(GLFWmonitor* monitor)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
glGetIntegerv(GL_RED_BITS, ¤t.redBits);
|
glGetIntegerv(GL_RED_BITS, ¤tRed);
|
||||||
glGetIntegerv(GL_GREEN_BITS, ¤t.greenBits);
|
glGetIntegerv(GL_GREEN_BITS, ¤tGreen);
|
||||||
glGetIntegerv(GL_BLUE_BITS, ¤t.blueBits);
|
glGetIntegerv(GL_BLUE_BITS, ¤tBlue);
|
||||||
|
|
||||||
glfwGetWindowSize(window, ¤t.width, ¤t.height);
|
glfwGetWindowSize(window, ¤tWidth, ¤tHeight);
|
||||||
|
|
||||||
if (current.redBits != mode->redBits ||
|
if (currentRed != red ||
|
||||||
current.greenBits != mode->greenBits ||
|
currentGreen != green ||
|
||||||
current.blueBits != mode->blueBits)
|
currentBlue != blue)
|
||||||
{
|
{
|
||||||
printf("*** Color bit mismatch: (%i %i %i) instead of (%i %i %i)\n",
|
printf("*** Color bit mismatch: (%i %i %i) instead of (%i %i %i)\n",
|
||||||
current.redBits, current.greenBits, current.blueBits,
|
currentRed, currentGreen, currentBlue,
|
||||||
mode->redBits, mode->greenBits, mode->blueBits);
|
red, green, blue);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (current.width != mode->width || current.height != mode->height)
|
if (currentWidth != width || currentHeight != height)
|
||||||
{
|
{
|
||||||
printf("*** Size mismatch: %ix%i instead of %ix%i\n",
|
printf("*** Size mismatch: %ix%i instead of %ix%i\n",
|
||||||
current.width, current.height,
|
currentWidth, currentHeight,
|
||||||
mode->width, mode->height);
|
width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Closing window\n");
|
printf("Closing window\n");
|
||||||
@ -224,13 +298,16 @@ int main(int argc, char** argv)
|
|||||||
int ch, i, count, mode = LIST_MODE;
|
int ch, i, count, mode = LIST_MODE;
|
||||||
GLFWmonitor** monitors;
|
GLFWmonitor** monitors;
|
||||||
|
|
||||||
while ((ch = getopt(argc, argv, "th")) != -1)
|
while ((ch = getopt(argc, argv, "tho")) != -1)
|
||||||
{
|
{
|
||||||
switch (ch)
|
switch (ch)
|
||||||
{
|
{
|
||||||
case 'h':
|
case 'h':
|
||||||
usage();
|
usage();
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
|
case 'o':
|
||||||
|
mode = LIST_MODE_OLD;
|
||||||
|
break;
|
||||||
case 't':
|
case 't':
|
||||||
mode = TEST_MODE;
|
mode = TEST_MODE;
|
||||||
break;
|
break;
|
||||||
@ -252,6 +329,8 @@ int main(int argc, char** argv)
|
|||||||
for (i = 0; i < count; i++)
|
for (i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
if (mode == LIST_MODE)
|
if (mode == LIST_MODE)
|
||||||
|
list_modes2(monitors[i]);
|
||||||
|
else if (mode == LIST_MODE_OLD)
|
||||||
list_modes(monitors[i]);
|
list_modes(monitors[i]);
|
||||||
else if (mode == TEST_MODE)
|
else if (mode == TEST_MODE)
|
||||||
test_modes(monitors[i]);
|
test_modes(monitors[i]);
|
||||||
|
Loading…
Reference in New Issue
Block a user