2013-05-27 15:10:34 +00:00
|
|
|
/*!
|
|
|
|
|
2016-02-19 09:29:13 +00:00
|
|
|
@page window_guide Window guide
|
2017-11-17 03:34:18 +00:00
|
|
|
|
2013-04-10 23:07:07 +00:00
|
|
|
@tableofcontents
|
|
|
|
|
2016-02-19 09:29:13 +00:00
|
|
|
This guide introduces the window related functions of GLFW. For details on
|
2016-08-11 17:04:21 +00:00
|
|
|
a specific function in this category, see the @ref window. There are also
|
|
|
|
guides for the other areas of GLFW.
|
2013-04-10 23:07:07 +00:00
|
|
|
|
2016-02-19 09:29:13 +00:00
|
|
|
- @ref intro_guide
|
|
|
|
- @ref context_guide
|
2016-08-11 17:04:21 +00:00
|
|
|
- @ref vulkan_guide
|
2016-02-19 09:29:13 +00:00
|
|
|
- @ref monitor_guide
|
|
|
|
- @ref input_guide
|
2014-09-18 13:03:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
@section window_object Window objects
|
2013-04-10 23:07:07 +00:00
|
|
|
|
|
|
|
The @ref GLFWwindow object encapsulates both a window and a context. They are
|
2015-01-18 00:55:25 +00:00
|
|
|
created with @ref glfwCreateWindow and destroyed with @ref glfwDestroyWindow, or
|
|
|
|
@ref glfwTerminate, if any remain. As the window and context are inseparably
|
2013-05-27 15:10:34 +00:00
|
|
|
linked, the object pointer is used as both a context and window handle.
|
2013-04-10 23:07:07 +00:00
|
|
|
|
2015-01-11 17:25:54 +00:00
|
|
|
To see the event stream provided to the various window related callbacks, run
|
|
|
|
the `events` test program.
|
|
|
|
|
2013-04-10 23:07:07 +00:00
|
|
|
|
2014-09-18 13:03:29 +00:00
|
|
|
@subsection window_creation Window creation
|
2013-07-07 10:06:59 +00:00
|
|
|
|
2014-09-18 13:03:29 +00:00
|
|
|
A window and its OpenGL or OpenGL ES context are created with @ref
|
|
|
|
glfwCreateWindow, which returns a handle to the created window object. For
|
|
|
|
example, this creates a 640 by 480 windowed mode window:
|
2013-07-07 10:06:59 +00:00
|
|
|
|
|
|
|
@code
|
|
|
|
GLFWwindow* window = glfwCreateWindow(640, 480, "My Title", NULL, NULL);
|
2014-09-18 13:03:29 +00:00
|
|
|
@endcode
|
|
|
|
|
|
|
|
If window creation fails, `NULL` will be returned, so it is necessary to check
|
|
|
|
the return value.
|
|
|
|
|
|
|
|
The window handle is passed to all window related functions and is provided to
|
|
|
|
along with all input events, so event handlers can tell which window received
|
|
|
|
the event.
|
2013-07-07 10:06:59 +00:00
|
|
|
|
2014-10-02 15:35:10 +00:00
|
|
|
|
|
|
|
@subsubsection window_full_screen Full screen windows
|
|
|
|
|
2013-07-07 10:06:59 +00:00
|
|
|
To create a full screen window, you need to specify which monitor the window
|
2014-10-02 15:35:10 +00:00
|
|
|
should use. In most cases, the user's primary monitor is a good choice.
|
2017-11-17 03:34:18 +00:00
|
|
|
For more information about retrieving monitors, see @ref monitor_monitors.
|
2013-07-07 10:06:59 +00:00
|
|
|
|
|
|
|
@code
|
|
|
|
GLFWwindow* window = glfwCreateWindow(640, 480, "My Title", glfwGetPrimaryMonitor(), NULL);
|
|
|
|
@endcode
|
|
|
|
|
|
|
|
Full screen windows cover the entire display area of a monitor, have no border
|
2014-10-02 15:35:10 +00:00
|
|
|
or decorations.
|
|
|
|
|
2016-02-23 11:26:42 +00:00
|
|
|
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
|
|
|
|
with the same function.
|
|
|
|
|
2014-10-07 17:23:35 +00:00
|
|
|
Each field of the @ref GLFWvidmode structure corresponds to a function parameter
|
|
|
|
or window hint and combine to form the _desired video mode_ for that window.
|
|
|
|
The supported video mode most closely matching the desired video mode will be
|
2015-01-18 00:55:25 +00:00
|
|
|
set for the chosen monitor as long as the window has input focus. For more
|
2014-10-07 17:23:35 +00:00
|
|
|
information about retrieving video modes, see @ref monitor_modes.
|
2014-10-02 15:35:10 +00:00
|
|
|
|
|
|
|
Video mode field | Corresponds to
|
2018-11-11 17:49:47 +00:00
|
|
|
---------------- | --------------
|
2019-04-05 16:19:10 +00:00
|
|
|
GLFWvidmode.width | `width` parameter of @ref glfwCreateWindow
|
|
|
|
GLFWvidmode.height | `height` parameter of @ref glfwCreateWindow
|
2016-12-06 00:14:23 +00:00
|
|
|
GLFWvidmode.redBits | @ref GLFW_RED_BITS hint
|
|
|
|
GLFWvidmode.greenBits | @ref GLFW_GREEN_BITS hint
|
|
|
|
GLFWvidmode.blueBits | @ref GLFW_BLUE_BITS hint
|
|
|
|
GLFWvidmode.refreshRate | @ref GLFW_REFRESH_RATE hint
|
2014-10-02 15:35:10 +00:00
|
|
|
|
2016-02-23 11:26:42 +00:00
|
|
|
Once you have a full screen window, you can change its resolution, refresh rate
|
2017-10-22 14:27:17 +00:00
|
|
|
and monitor with @ref glfwSetWindowMonitor. If you only need change its
|
2016-02-23 11:26:42 +00:00
|
|
|
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
|
2016-08-17 14:48:22 +00:00
|
|
|
glfwCreateWindow. If the window has an OpenGL or OpenGL ES context, it will be
|
|
|
|
unaffected.
|
2014-10-02 15:35:10 +00:00
|
|
|
|
|
|
|
By default, the original video mode of the monitor will be restored and the
|
|
|
|
window iconified if it loses input focus, to allow the user to switch back to
|
2016-12-06 00:14:23 +00:00
|
|
|
the desktop. This behavior can be disabled with the
|
|
|
|
[GLFW_AUTO_ICONIFY](@ref GLFW_AUTO_ICONIFY_hint) window hint, for example if you
|
2017-10-18 14:48:21 +00:00
|
|
|
wish to simultaneously cover multiple monitors with full screen windows.
|
2013-07-07 10:06:59 +00:00
|
|
|
|
2017-11-01 20:32:50 +00:00
|
|
|
If a monitor is disconnected, all windows that are full screen on that monitor
|
|
|
|
will be switched to windowed mode. See @ref monitor_event for more information.
|
2017-02-20 12:45:11 +00:00
|
|
|
|
2014-12-29 03:38:02 +00:00
|
|
|
|
2014-12-18 15:21:15 +00:00
|
|
|
@subsubsection window_windowed_full_screen "Windowed full screen" windows
|
|
|
|
|
2015-02-22 03:10:24 +00:00
|
|
|
If the closest match for the desired video mode is the current one, the video
|
|
|
|
mode will not be changed, making window creation faster and application
|
|
|
|
switching much smoother. This is sometimes called _windowed full screen_ or
|
|
|
|
_borderless full screen_ window and counts as a full screen window. To create
|
2017-10-22 14:27:17 +00:00
|
|
|
such a window, request the current video mode.
|
2014-10-02 15:35:10 +00:00
|
|
|
|
|
|
|
@code
|
|
|
|
const GLFWvidmode* mode = glfwGetVideoMode(monitor);
|
|
|
|
|
|
|
|
glfwWindowHint(GLFW_RED_BITS, mode->redBits);
|
|
|
|
glfwWindowHint(GLFW_GREEN_BITS, mode->greenBits);
|
|
|
|
glfwWindowHint(GLFW_BLUE_BITS, mode->blueBits);
|
|
|
|
glfwWindowHint(GLFW_REFRESH_RATE, mode->refreshRate);
|
|
|
|
|
|
|
|
GLFWwindow* window = glfwCreateWindow(mode->width, mode->height, "My Title", monitor, NULL);
|
|
|
|
@endcode
|
|
|
|
|
2016-02-23 11:26:42 +00:00
|
|
|
This also works for windowed mode windows that are made full screen.
|
|
|
|
|
|
|
|
@code
|
|
|
|
const GLFWvidmode* mode = glfwGetVideoMode(monitor);
|
|
|
|
|
|
|
|
glfwSetWindowMonitor(window, monitor, 0, 0, mode->width, mode->height, mode->refreshRate);
|
|
|
|
@endcode
|
|
|
|
|
|
|
|
Note that @ref glfwGetVideoMode returns the _current_ video mode of a monitor,
|
|
|
|
so if you already have a full screen window on that monitor that you want to
|
|
|
|
make windowed full screen, you need to have saved the desktop resolution before.
|
|
|
|
|
2013-07-07 10:06:59 +00:00
|
|
|
|
2014-09-18 13:03:29 +00:00
|
|
|
@subsection window_destruction Window destruction
|
2013-07-07 10:06:59 +00:00
|
|
|
|
2014-09-18 13:03:29 +00:00
|
|
|
When a window is no longer needed, destroy it with @ref glfwDestroyWindow.
|
2013-07-07 10:06:59 +00:00
|
|
|
|
|
|
|
@code
|
|
|
|
glfwDestroyWindow(window);
|
|
|
|
@endcode
|
|
|
|
|
2014-09-18 13:03:29 +00:00
|
|
|
Window destruction always succeeds. Before the actual destruction, all
|
|
|
|
callbacks are removed so no further events will be delivered for the window.
|
2014-10-07 17:23:35 +00:00
|
|
|
All windows remaining when @ref glfwTerminate is called are destroyed as well.
|
2013-07-07 10:06:59 +00:00
|
|
|
|
2014-09-18 13:03:29 +00:00
|
|
|
When a full screen window is destroyed, the original video mode of its monitor
|
|
|
|
is restored, but the gamma ramp is left untouched.
|
2013-07-07 10:06:59 +00:00
|
|
|
|
2013-10-12 18:00:16 +00:00
|
|
|
|
2014-09-18 13:03:29 +00:00
|
|
|
@subsection window_hints Window creation hints
|
2013-04-10 23:07:07 +00:00
|
|
|
|
2013-05-27 15:10:34 +00:00
|
|
|
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. These hints are set to their default values each time the library is
|
2017-12-12 09:54:18 +00:00
|
|
|
initialized with @ref glfwInit. Integer value hints can be set individually
|
|
|
|
with @ref glfwWindowHint and string value hints with @ref glfwWindowHintString.
|
|
|
|
You can reset all at once to their defaults with @ref glfwDefaultWindowHints.
|
2013-04-10 23:07:07 +00:00
|
|
|
|
2016-12-06 23:41:54 +00:00
|
|
|
Some hints are platform specific. These are always valid to set on any
|
|
|
|
platform but they will only affect their specific platform. Other platforms
|
2017-10-22 14:27:17 +00:00
|
|
|
will ignore them. Setting these hints requires no platform specific headers or
|
|
|
|
calls.
|
2016-12-06 23:41:54 +00:00
|
|
|
|
2017-12-12 09:54:18 +00:00
|
|
|
@note Window hints need to be set before the creation of the window and context
|
|
|
|
you wish to have the specified attributes. They function as additional
|
|
|
|
arguments to @ref glfwCreateWindow.
|
2013-04-10 23:07:07 +00:00
|
|
|
|
|
|
|
|
2014-09-18 13:03:29 +00:00
|
|
|
@subsubsection window_hints_hard Hard and soft constraints
|
2013-04-10 23:07:07 +00:00
|
|
|
|
|
|
|
Some window hints are hard constraints. These must match the available
|
2014-10-02 15:35:10 +00:00
|
|
|
capabilities _exactly_ for window and context creation to succeed. Hints
|
2013-04-10 23:07:07 +00:00
|
|
|
that are not hard constraints are matched as closely as possible, but the
|
2015-03-26 11:42:30 +00:00
|
|
|
resulting context and framebuffer may differ from what these hints requested.
|
2013-04-10 23:07:07 +00:00
|
|
|
|
2014-04-23 11:30:11 +00:00
|
|
|
The following hints are always hard constraints:
|
2016-12-06 00:14:23 +00:00
|
|
|
- @ref GLFW_STEREO
|
|
|
|
- @ref GLFW_DOUBLEBUFFER
|
|
|
|
- [GLFW_CLIENT_API](@ref GLFW_CLIENT_API_hint)
|
|
|
|
- [GLFW_CONTEXT_CREATION_API](@ref GLFW_CONTEXT_CREATION_API_hint)
|
2013-04-10 23:07:07 +00:00
|
|
|
|
2014-04-23 11:30:11 +00:00
|
|
|
The following additional hints are hard constraints when requesting an OpenGL
|
|
|
|
context, but are ignored when requesting an OpenGL ES context:
|
2016-12-06 00:14:23 +00:00
|
|
|
- [GLFW_OPENGL_FORWARD_COMPAT](@ref GLFW_OPENGL_FORWARD_COMPAT_hint)
|
|
|
|
- [GLFW_OPENGL_PROFILE](@ref GLFW_OPENGL_PROFILE_hint)
|
2013-04-10 23:07:07 +00:00
|
|
|
|
|
|
|
|
2014-09-18 13:03:29 +00:00
|
|
|
@subsubsection window_hints_wnd Window related hints
|
2013-05-27 15:10:34 +00:00
|
|
|
|
2016-12-06 00:14:23 +00:00
|
|
|
@anchor GLFW_RESIZABLE_hint
|
|
|
|
__GLFW_RESIZABLE__ specifies whether the windowed mode window will be resizable
|
2014-10-02 15:35:10 +00:00
|
|
|
_by the user_. The window will still be resizable using the @ref
|
2017-02-13 14:36:06 +00:00
|
|
|
glfwSetWindowSize function. Possible values are `GLFW_TRUE` and `GLFW_FALSE`.
|
|
|
|
This hint is ignored for full screen and undecorated windows.
|
2013-05-27 15:10:34 +00:00
|
|
|
|
2016-12-06 00:14:23 +00:00
|
|
|
@anchor GLFW_VISIBLE_hint
|
|
|
|
__GLFW_VISIBLE__ specifies whether the windowed mode window will be initially
|
2017-02-13 14:36:06 +00:00
|
|
|
visible. Possible values are `GLFW_TRUE` and `GLFW_FALSE`. This hint is
|
|
|
|
ignored for full screen windows.
|
2013-05-27 15:10:34 +00:00
|
|
|
|
2016-12-06 00:14:23 +00:00
|
|
|
@anchor GLFW_DECORATED_hint
|
|
|
|
__GLFW_DECORATED__ specifies whether the windowed mode window will have window
|
2016-11-25 11:43:15 +00:00
|
|
|
decorations such as a border, a close widget, etc. An undecorated window will
|
|
|
|
not be resizable by the user but will still allow the user to generate close
|
2017-02-13 14:36:06 +00:00
|
|
|
events on some platforms. Possible values are `GLFW_TRUE` and `GLFW_FALSE`.
|
|
|
|
This hint is ignored for full screen windows.
|
2014-04-08 13:32:34 +00:00
|
|
|
|
2016-12-06 00:14:23 +00:00
|
|
|
@anchor GLFW_FOCUSED_hint
|
|
|
|
__GLFW_FOCUSED__ specifies whether the windowed mode window will be given input
|
2017-02-13 14:36:06 +00:00
|
|
|
focus when created. Possible values are `GLFW_TRUE` and `GLFW_FALSE`. This
|
|
|
|
hint is ignored for full screen and initially hidden windows.
|
2014-06-20 11:39:06 +00:00
|
|
|
|
2016-12-06 00:14:23 +00:00
|
|
|
@anchor GLFW_AUTO_ICONIFY_hint
|
|
|
|
__GLFW_AUTO_ICONIFY__ specifies whether the full screen window will
|
2015-01-18 00:55:25 +00:00
|
|
|
automatically iconify and restore the previous video mode on input focus loss.
|
2017-02-13 14:36:06 +00:00
|
|
|
Possible values are `GLFW_TRUE` and `GLFW_FALSE`. This hint is ignored for
|
|
|
|
windowed mode windows.
|
2013-05-27 15:10:34 +00:00
|
|
|
|
2016-12-06 00:14:23 +00:00
|
|
|
@anchor GLFW_FLOATING_hint
|
|
|
|
__GLFW_FLOATING__ specifies whether the windowed mode window will be floating
|
2015-04-19 11:48:25 +00:00
|
|
|
above other regular windows, also called topmost or always-on-top. This is
|
|
|
|
intended primarily for debugging purposes and cannot be used to implement proper
|
2017-02-13 14:36:06 +00:00
|
|
|
full screen windows. Possible values are `GLFW_TRUE` and `GLFW_FALSE`. This
|
|
|
|
hint is ignored for full screen windows.
|
2014-05-23 12:01:02 +00:00
|
|
|
|
2016-12-06 00:14:23 +00:00
|
|
|
@anchor GLFW_MAXIMIZED_hint
|
|
|
|
__GLFW_MAXIMIZED__ specifies whether the windowed mode window will be maximized
|
2017-02-13 14:36:06 +00:00
|
|
|
when created. Possible values are `GLFW_TRUE` and `GLFW_FALSE`. This hint is
|
|
|
|
ignored for full screen windows.
|
2015-10-13 10:50:59 +00:00
|
|
|
|
2017-02-06 14:03:50 +00:00
|
|
|
@anchor GLFW_CENTER_CURSOR_hint
|
|
|
|
__GLFW_CENTER_CURSOR__ specifies whether the cursor should be centered over
|
2017-02-13 14:36:06 +00:00
|
|
|
newly created full screen windows. Possible values are `GLFW_TRUE` and
|
|
|
|
`GLFW_FALSE`. This hint is ignored for windowed mode windows.
|
2017-02-06 14:03:50 +00:00
|
|
|
|
2017-11-07 21:50:01 +00:00
|
|
|
@anchor GLFW_TRANSPARENT_FRAMEBUFFER_hint
|
|
|
|
__GLFW_TRANSPARENT_FRAMEBUFFER__ specifies whether the window framebuffer will
|
|
|
|
be transparent. If enabled and supported by the system, the window framebuffer
|
2017-09-18 16:10:57 +00:00
|
|
|
alpha channel will be used to combine the framebuffer with the background. This
|
|
|
|
does not affect window decorations. Possible values are `GLFW_TRUE` and
|
|
|
|
`GLFW_FALSE`.
|
|
|
|
|
2018-05-29 13:51:36 +00:00
|
|
|
@anchor GLFW_FOCUS_ON_SHOW_hint
|
|
|
|
__GLFW_FOCUS_ON_SHOW__ specifies whether the window will be given input
|
2021-05-12 16:53:06 +00:00
|
|
|
focus when @ref glfwShowWindow is called. Possible values are `GLFW_TRUE` and
|
|
|
|
`GLFW_FALSE`.
|
2013-05-27 15:10:34 +00:00
|
|
|
|
2018-08-31 11:33:48 +00:00
|
|
|
@anchor GLFW_SCALE_TO_MONITOR
|
|
|
|
__GLFW_SCALE_TO_MONITOR__ specified whether the window content area should be
|
|
|
|
resized based on the [monitor content scale](@ref monitor_scale) of any monitor
|
|
|
|
it is placed on. This includes the initial placement when the window is
|
|
|
|
created. Possible values are `GLFW_TRUE` and `GLFW_FALSE`.
|
|
|
|
|
|
|
|
This hint only has an effect on platforms where screen coordinates and pixels
|
|
|
|
always map 1:1 such as Windows and X11. On platforms like macOS the resolution
|
|
|
|
of the framebuffer is changed independently of the window size.
|
|
|
|
|
2020-07-08 21:21:28 +00:00
|
|
|
@anchor GLFW_MOUSE_PASSTHROUGH_hint
|
|
|
|
__GLFW_MOUSE_PASSTHROUGH__ specifies whether the window is transparent to mouse
|
|
|
|
input, letting any mouse events pass through to whatever window is behind it.
|
|
|
|
This is only supported for undecorated windows. Decorated windows with this
|
|
|
|
enabled will behave differently between platforms. Possible values are
|
|
|
|
`GLFW_TRUE` and `GLFW_FALSE`.
|
|
|
|
|
2021-10-26 12:25:03 +00:00
|
|
|
@anchor GLFW_POSITION_X
|
|
|
|
@anchor GLFW_POSITION_Y
|
|
|
|
__GLFW_POSITION_X__ and __GLFW_POSITION_Y__ specify the desired initial position
|
|
|
|
of the window. The window manager may modify or ignore these coordinates. If
|
|
|
|
either or both of these hints are set to `GLFW_ANY_POSITION` then the window
|
|
|
|
manager will position the window where it thinks the user will prefer it.
|
|
|
|
Possible values are any valid screen coordinates and `GLFW_ANY_POSITION`.
|
|
|
|
|
2018-08-31 11:33:48 +00:00
|
|
|
|
2014-09-18 13:03:29 +00:00
|
|
|
@subsubsection window_hints_fb Framebuffer related hints
|
2013-04-10 23:07:07 +00:00
|
|
|
|
2016-12-06 00:14:23 +00:00
|
|
|
@anchor GLFW_RED_BITS
|
|
|
|
@anchor GLFW_GREEN_BITS
|
|
|
|
@anchor GLFW_BLUE_BITS
|
|
|
|
@anchor GLFW_ALPHA_BITS
|
|
|
|
@anchor GLFW_DEPTH_BITS
|
|
|
|
@anchor GLFW_STENCIL_BITS
|
|
|
|
__GLFW_RED_BITS__, __GLFW_GREEN_BITS__, __GLFW_BLUE_BITS__, __GLFW_ALPHA_BITS__,
|
|
|
|
__GLFW_DEPTH_BITS__ and __GLFW_STENCIL_BITS__ specify the desired bit depths of
|
|
|
|
the various components of the default framebuffer. A value of `GLFW_DONT_CARE`
|
|
|
|
means the application has no preference.
|
|
|
|
|
|
|
|
@anchor GLFW_ACCUM_RED_BITS
|
|
|
|
@anchor GLFW_ACCUM_GREEN_BITS
|
|
|
|
@anchor GLFW_ACCUM_BLUE_BITS
|
|
|
|
@anchor GLFW_ACCUM_ALPHA_BITS
|
|
|
|
__GLFW_ACCUM_RED_BITS__, __GLFW_ACCUM_GREEN_BITS__, __GLFW_ACCUM_BLUE_BITS__ and
|
|
|
|
__GLFW_ACCUM_ALPHA_BITS__ specify the desired bit depths of the various
|
|
|
|
components of the accumulation buffer. A value of `GLFW_DONT_CARE` means the
|
2014-04-08 16:57:43 +00:00
|
|
|
application has no preference.
|
2013-04-10 23:07:07 +00:00
|
|
|
|
2014-10-07 21:37:59 +00:00
|
|
|
Accumulation buffers are a legacy OpenGL feature and should not be used in new
|
|
|
|
code.
|
2014-04-23 11:30:11 +00:00
|
|
|
|
2016-12-06 00:14:23 +00:00
|
|
|
@anchor GLFW_AUX_BUFFERS
|
|
|
|
__GLFW_AUX_BUFFERS__ specifies the desired number of auxiliary buffers. A value
|
|
|
|
of `GLFW_DONT_CARE` means the application has no preference.
|
2013-04-10 23:07:07 +00:00
|
|
|
|
2014-10-07 21:37:59 +00:00
|
|
|
Auxiliary buffers are a legacy OpenGL feature and should not be used in new
|
|
|
|
code.
|
2014-04-23 11:30:11 +00:00
|
|
|
|
2016-12-06 00:14:23 +00:00
|
|
|
@anchor GLFW_STEREO
|
2017-02-13 14:36:06 +00:00
|
|
|
__GLFW_STEREO__ specifies whether to use OpenGL stereoscopic rendering.
|
|
|
|
Possible values are `GLFW_TRUE` and `GLFW_FALSE`. This is a hard constraint.
|
2013-04-10 23:07:07 +00:00
|
|
|
|
2016-12-06 00:14:23 +00:00
|
|
|
@anchor GLFW_SAMPLES
|
|
|
|
__GLFW_SAMPLES__ specifies the desired number of samples to use for
|
|
|
|
multisampling. Zero disables multisampling. A value of `GLFW_DONT_CARE` means
|
|
|
|
the application has no preference.
|
2013-04-10 23:07:07 +00:00
|
|
|
|
2016-12-06 00:14:23 +00:00
|
|
|
@anchor GLFW_SRGB_CAPABLE
|
|
|
|
__GLFW_SRGB_CAPABLE__ specifies whether the framebuffer should be sRGB capable.
|
2017-02-13 14:36:06 +00:00
|
|
|
Possible values are `GLFW_TRUE` and `GLFW_FALSE`.
|
2013-04-10 23:07:07 +00:00
|
|
|
|
2021-05-12 16:53:06 +00:00
|
|
|
@note __OpenGL:__ If enabled and supported by the system, the
|
|
|
|
`GL_FRAMEBUFFER_SRGB` enable will control sRGB rendering. By default, sRGB
|
|
|
|
rendering will be disabled.
|
2017-05-11 11:34:22 +00:00
|
|
|
|
2021-05-12 16:53:06 +00:00
|
|
|
@note __OpenGL ES:__ If enabled and supported by the system, the context will
|
|
|
|
always have sRGB rendering enabled.
|
2017-05-11 11:34:22 +00:00
|
|
|
|
2016-12-06 00:14:23 +00:00
|
|
|
@anchor GLFW_DOUBLEBUFFER
|
2021-05-13 19:38:46 +00:00
|
|
|
@anchor GLFW_DOUBLEBUFFER_hint
|
2016-12-06 00:14:23 +00:00
|
|
|
__GLFW_DOUBLEBUFFER__ specifies whether the framebuffer should be double
|
|
|
|
buffered. You nearly always want to use double buffering. This is a hard
|
2017-02-13 14:36:06 +00:00
|
|
|
constraint. Possible values are `GLFW_TRUE` and `GLFW_FALSE`.
|
2014-04-24 17:21:10 +00:00
|
|
|
|
2013-05-30 18:42:50 +00:00
|
|
|
|
2014-09-18 13:03:29 +00:00
|
|
|
@subsubsection window_hints_mtr Monitor related hints
|
2013-04-10 23:07:07 +00:00
|
|
|
|
2016-12-06 00:14:23 +00:00
|
|
|
@anchor GLFW_REFRESH_RATE
|
|
|
|
__GLFW_REFRESH_RATE__ specifies the desired refresh rate for full screen
|
|
|
|
windows. A value of `GLFW_DONT_CARE` means the highest available refresh rate
|
|
|
|
will be used. This hint is ignored for windowed mode windows.
|
2013-04-10 23:07:07 +00:00
|
|
|
|
|
|
|
|
2014-09-18 13:03:29 +00:00
|
|
|
@subsubsection window_hints_ctx Context related hints
|
|
|
|
|
2016-12-06 00:14:23 +00:00
|
|
|
@anchor GLFW_CLIENT_API_hint
|
|
|
|
__GLFW_CLIENT_API__ specifies which client API to create the context for.
|
2015-11-05 12:44:15 +00:00
|
|
|
Possible values are `GLFW_OPENGL_API`, `GLFW_OPENGL_ES_API` and `GLFW_NO_API`.
|
|
|
|
This is a hard constraint.
|
2014-09-18 13:03:29 +00:00
|
|
|
|
2016-12-06 00:14:23 +00:00
|
|
|
@anchor GLFW_CONTEXT_CREATION_API_hint
|
|
|
|
__GLFW_CONTEXT_CREATION_API__ specifies which context creation API to use to
|
2017-02-28 18:23:25 +00:00
|
|
|
create the context. Possible values are `GLFW_NATIVE_CONTEXT_API`,
|
|
|
|
`GLFW_EGL_CONTEXT_API` and `GLFW_OSMESA_CONTEXT_API`. This is a hard
|
|
|
|
constraint. If no client API is requested, this hint is ignored.
|
2016-03-28 11:19:31 +00:00
|
|
|
|
2021-05-12 16:53:06 +00:00
|
|
|
An [extension loader library](@ref context_glext_auto) that assumes it knows
|
|
|
|
which API was used to create the current context may fail if you change this
|
|
|
|
hint. This can be resolved by having it load functions via @ref
|
|
|
|
glfwGetProcAddress.
|
2016-03-28 11:19:31 +00:00
|
|
|
|
2021-05-12 16:53:06 +00:00
|
|
|
@note @wayland The EGL API _is_ the native context creation API, so this hint
|
|
|
|
will have no effect.
|
2017-02-28 18:23:25 +00:00
|
|
|
|
2021-05-12 16:53:06 +00:00
|
|
|
@note @x11 On some Linux systems, creating contexts via both the native and EGL
|
|
|
|
APIs in a single process will cause the application to segfault. Stick to one
|
|
|
|
API or the other on Linux for now.
|
2016-03-28 11:19:31 +00:00
|
|
|
|
2021-05-12 16:53:06 +00:00
|
|
|
@note __OSMesa:__ As its name implies, an OpenGL context created with OSMesa
|
|
|
|
does not update the window contents when its buffers are swapped. Use OpenGL
|
|
|
|
functions or the OSMesa native access functions @ref glfwGetOSMesaColorBuffer
|
|
|
|
and @ref glfwGetOSMesaDepthBuffer to retrieve the framebuffer contents.
|
2016-08-11 17:04:21 +00:00
|
|
|
|
2016-12-06 00:14:23 +00:00
|
|
|
@anchor GLFW_CONTEXT_VERSION_MAJOR_hint
|
|
|
|
@anchor GLFW_CONTEXT_VERSION_MINOR_hint
|
|
|
|
__GLFW_CONTEXT_VERSION_MAJOR__ and __GLFW_CONTEXT_VERSION_MINOR__ specify the
|
|
|
|
client API version that the created context must be compatible with. The exact
|
2014-10-07 17:23:35 +00:00
|
|
|
behavior of these hints depend on the requested client API.
|
2013-04-10 23:07:07 +00:00
|
|
|
|
|
|
|
While there is no way to ask the driver for a context of the highest supported
|
2014-10-07 17:23:35 +00:00
|
|
|
version, GLFW will attempt to provide this when you ask for a version 1.0
|
|
|
|
context, which is the default for these hints.
|
|
|
|
|
2021-05-12 16:53:06 +00:00
|
|
|
Do not confuse these hints with @ref GLFW_VERSION_MAJOR and @ref
|
|
|
|
GLFW_VERSION_MINOR, which provide the API version of the GLFW header.
|
|
|
|
|
|
|
|
@note __OpenGL:__ These hints are not hard constraints, but creation will fail
|
|
|
|
if the OpenGL version of the created context is less than the one requested. It
|
|
|
|
is therefore perfectly safe to use the default of version 1.0 for legacy code
|
|
|
|
and you will still get backwards-compatible contexts of version 3.0 and above
|
|
|
|
when available.
|
|
|
|
|
|
|
|
@note __OpenGL ES:__ These hints are not hard constraints, but creation will
|
|
|
|
fail if the OpenGL ES version of the created context is less than the one
|
|
|
|
requested. Additionally, OpenGL ES 1.x cannot be returned if 2.0 or later was
|
|
|
|
requested, and vice versa. This is because OpenGL ES 3.x is backward compatible
|
|
|
|
with 2.0, but OpenGL ES 2.0 is not backward compatible with 1.x.
|
2013-04-10 23:07:07 +00:00
|
|
|
|
2019-10-18 11:21:59 +00:00
|
|
|
@note @macos The OS only supports core profile contexts for OpenGL versions 3.2
|
|
|
|
and later. Before creating an OpenGL context of version 3.2 or later you must
|
|
|
|
set the [GLFW_OPENGL_PROFILE](@ref GLFW_OPENGL_PROFILE_hint) hint accordingly.
|
|
|
|
OpenGL 3.0 and 3.1 contexts are not supported at all on macOS.
|
2016-12-03 18:32:00 +00:00
|
|
|
|
2016-12-06 00:14:23 +00:00
|
|
|
@anchor GLFW_OPENGL_FORWARD_COMPAT_hint
|
|
|
|
__GLFW_OPENGL_FORWARD_COMPAT__ specifies whether the OpenGL context should be
|
2014-09-18 13:03:29 +00:00
|
|
|
forward-compatible, i.e. one where all functionality deprecated in the requested
|
2015-12-13 13:07:27 +00:00
|
|
|
version of OpenGL is removed. This must only be used if the requested OpenGL
|
2015-01-05 15:46:04 +00:00
|
|
|
version is 3.0 or above. If OpenGL ES is requested, this hint is ignored.
|
2013-04-10 23:07:07 +00:00
|
|
|
|
2014-09-18 13:03:29 +00:00
|
|
|
Forward-compatibility is described in detail in the
|
2014-08-14 23:04:03 +00:00
|
|
|
[OpenGL Reference Manual](https://www.opengl.org/registry/).
|
|
|
|
|
2020-06-26 16:35:48 +00:00
|
|
|
@anchor GLFW_CONTEXT_DEBUG_hint
|
2016-12-06 00:14:23 +00:00
|
|
|
@anchor GLFW_OPENGL_DEBUG_CONTEXT_hint
|
2020-06-26 16:35:48 +00:00
|
|
|
__GLFW_CONTEXT_DEBUG__ specifies whether the context should be created in debug
|
|
|
|
mode, which may provide additional error and diagnostic reporting functionality.
|
|
|
|
Possible values are `GLFW_TRUE` and `GLFW_FALSE`.
|
2020-06-18 01:23:08 +00:00
|
|
|
|
|
|
|
Debug contexts for OpenGL and OpenGL ES are described in detail by the
|
|
|
|
[GL_KHR_debug](https://www.khronos.org/registry/OpenGL/extensions/KHR/KHR_debug.txt)
|
|
|
|
extension.
|
2013-04-10 23:07:07 +00:00
|
|
|
|
2021-05-12 16:53:06 +00:00
|
|
|
@note `GLFW_CONTEXT_DEBUG` is the new name introduced in GLFW 3.4. The older
|
2020-09-01 19:29:59 +00:00
|
|
|
`GLFW_OPENGL_DEBUG_CONTEXT` name is also available for compatibility.
|
|
|
|
|
2016-12-06 00:14:23 +00:00
|
|
|
@anchor GLFW_OPENGL_PROFILE_hint
|
|
|
|
__GLFW_OPENGL_PROFILE__ specifies which OpenGL profile to create the context
|
|
|
|
for. Possible values are one of `GLFW_OPENGL_CORE_PROFILE` or
|
2014-09-18 13:03:29 +00:00
|
|
|
`GLFW_OPENGL_COMPAT_PROFILE`, or `GLFW_OPENGL_ANY_PROFILE` to not request
|
|
|
|
a specific profile. If requesting an OpenGL version below 3.2,
|
2016-12-06 00:14:23 +00:00
|
|
|
`GLFW_OPENGL_ANY_PROFILE` must be used. If OpenGL ES is requested, this hint
|
|
|
|
is ignored.
|
2013-04-10 23:07:07 +00:00
|
|
|
|
2014-09-18 13:03:29 +00:00
|
|
|
OpenGL profiles are described in detail in the
|
2014-08-14 23:04:03 +00:00
|
|
|
[OpenGL Reference Manual](https://www.opengl.org/registry/).
|
|
|
|
|
2016-12-06 00:14:23 +00:00
|
|
|
@anchor GLFW_CONTEXT_ROBUSTNESS_hint
|
|
|
|
__GLFW_CONTEXT_ROBUSTNESS__ specifies the robustness strategy to be used by the
|
2014-09-18 13:03:29 +00:00
|
|
|
context. This can be one of `GLFW_NO_RESET_NOTIFICATION` or
|
2013-04-10 23:07:07 +00:00
|
|
|
`GLFW_LOSE_CONTEXT_ON_RESET`, or `GLFW_NO_ROBUSTNESS` to not request
|
|
|
|
a robustness strategy.
|
|
|
|
|
2016-12-06 00:14:23 +00:00
|
|
|
@anchor GLFW_CONTEXT_RELEASE_BEHAVIOR_hint
|
|
|
|
__GLFW_CONTEXT_RELEASE_BEHAVIOR__ specifies the release behavior to be
|
2014-08-21 17:21:45 +00:00
|
|
|
used by the context. Possible values are one of `GLFW_ANY_RELEASE_BEHAVIOR`,
|
|
|
|
`GLFW_RELEASE_BEHAVIOR_FLUSH` or `GLFW_RELEASE_BEHAVIOR_NONE`. If the
|
|
|
|
behavior is `GLFW_ANY_RELEASE_BEHAVIOR`, the default behavior of the context
|
|
|
|
creation API will be used. If the behavior is `GLFW_RELEASE_BEHAVIOR_FLUSH`,
|
|
|
|
the pipeline will be flushed whenever the context is released from being the
|
|
|
|
current one. If the behavior is `GLFW_RELEASE_BEHAVIOR_NONE`, the pipeline will
|
|
|
|
not be flushed on release.
|
|
|
|
|
2014-09-18 13:03:29 +00:00
|
|
|
Context release behaviors are described in detail by the
|
2014-08-21 17:21:45 +00:00
|
|
|
[GL_KHR_context_flush_control](https://www.opengl.org/registry/specs/KHR/context_flush_control.txt)
|
|
|
|
extension.
|
|
|
|
|
2016-12-06 00:14:23 +00:00
|
|
|
@anchor GLFW_CONTEXT_NO_ERROR_hint
|
|
|
|
__GLFW_CONTEXT_NO_ERROR__ specifies whether errors should be generated by the
|
2017-02-13 14:36:06 +00:00
|
|
|
context. Possible values are `GLFW_TRUE` and `GLFW_FALSE`. If enabled,
|
|
|
|
situations that would have generated errors instead cause undefined behavior.
|
2015-08-10 10:46:14 +00:00
|
|
|
|
|
|
|
The no error mode for OpenGL and OpenGL ES is described in detail by the
|
|
|
|
[GL_KHR_no_error](https://www.opengl.org/registry/specs/KHR/no_error.txt)
|
|
|
|
extension.
|
|
|
|
|
2013-04-10 23:07:07 +00:00
|
|
|
|
2021-08-29 19:53:44 +00:00
|
|
|
@subsubsection window_hints_win32 Win32 specific hints
|
2019-08-20 17:00:59 +00:00
|
|
|
|
|
|
|
@anchor GLFW_WIN32_KEYBOARD_MENU_hint
|
|
|
|
__GLFW_WIN32_KEYBOARD_MENU__ specifies whether to allow access to the window
|
|
|
|
menu via the Alt+Space and Alt-and-then-Space keyboard shortcuts. This is
|
|
|
|
ignored on other platforms.
|
|
|
|
|
|
|
|
|
2021-08-29 19:53:44 +00:00
|
|
|
@subsubsection window_hints_osx macOS specific hints
|
2016-12-06 23:41:54 +00:00
|
|
|
|
|
|
|
@anchor GLFW_COCOA_RETINA_FRAMEBUFFER_hint
|
|
|
|
__GLFW_COCOA_RETINA_FRAMEBUFFER__ specifies whether to use full resolution
|
2017-02-13 14:36:06 +00:00
|
|
|
framebuffers on Retina displays. Possible values are `GLFW_TRUE` and
|
|
|
|
`GLFW_FALSE`. This is ignored on other platforms.
|
2016-12-06 23:41:54 +00:00
|
|
|
|
2017-12-12 15:45:38 +00:00
|
|
|
@anchor GLFW_COCOA_FRAME_NAME_hint
|
|
|
|
__GLFW_COCOA_FRAME_NAME__ specifies the UTF-8 encoded name to use for autosaving
|
|
|
|
the window frame, or if empty disables frame autosaving for the window. This is
|
|
|
|
ignored on other platforms. This is set with @ref glfwWindowHintString.
|
2017-01-01 18:41:50 +00:00
|
|
|
|
2017-01-27 11:02:09 +00:00
|
|
|
@anchor GLFW_COCOA_GRAPHICS_SWITCHING_hint
|
|
|
|
__GLFW_COCOA_GRAPHICS_SWITCHING__ specifies whether to in Automatic Graphics
|
|
|
|
Switching, i.e. to allow the system to choose the integrated GPU for the OpenGL
|
|
|
|
context and move it between GPUs if necessary or whether to force it to always
|
|
|
|
run on the discrete GPU. This only affects systems with both integrated and
|
2017-02-13 14:36:06 +00:00
|
|
|
discrete GPUs. Possible values are `GLFW_TRUE` and `GLFW_FALSE`. This is
|
|
|
|
ignored on other platforms.
|
2017-01-27 11:02:09 +00:00
|
|
|
|
|
|
|
Simpler programs and tools may want to enable this to save power, while games
|
|
|
|
and other applications performing advanced rendering will want to leave it
|
|
|
|
disabled.
|
|
|
|
|
|
|
|
A bundled application that wishes to participate in Automatic Graphics Switching
|
|
|
|
should also declare this in its `Info.plist` by setting the
|
|
|
|
`NSSupportsAutomaticGraphicsSwitching` key to `true`.
|
|
|
|
|
2016-12-06 23:41:54 +00:00
|
|
|
|
2017-12-12 09:54:18 +00:00
|
|
|
@subsubsection window_hints_x11 X11 specific window hints
|
|
|
|
|
2019-04-01 16:36:30 +00:00
|
|
|
@anchor GLFW_X11_CLASS_NAME_hint
|
|
|
|
@anchor GLFW_X11_INSTANCE_NAME_hint
|
2017-12-12 09:54:18 +00:00
|
|
|
__GLFW_X11_CLASS_NAME__ and __GLFW_X11_INSTANCE_NAME__ specifies the desired
|
2022-09-09 15:35:48 +00:00
|
|
|
ASCII encoded class and instance parts of the ICCCM `WM_CLASS` window property. Both
|
|
|
|
hints need to be set to something other than an empty string for them to take effect.
|
2017-12-12 09:54:18 +00:00
|
|
|
These are set with @ref glfwWindowHintString.
|
|
|
|
|
2022-05-27 00:33:28 +00:00
|
|
|
@subsubsection window_hints_wayland Wayland specific window hints
|
|
|
|
|
|
|
|
@anchor GLFW_WAYLAND_APP_ID_hint
|
|
|
|
__GLFW_WAYLAND_APP_ID__ specifies the Wayland app_id for a window, used
|
|
|
|
by window managers to identify types of windows. This is set with
|
|
|
|
@ref glfwWindowHintString.
|
|
|
|
|
2017-12-12 09:54:18 +00:00
|
|
|
|
2014-09-18 13:03:29 +00:00
|
|
|
@subsubsection window_hints_values Supported and default values
|
|
|
|
|
2016-12-06 00:14:23 +00:00
|
|
|
Window hint | Default value | Supported values
|
|
|
|
----------------------------- | --------------------------- | ----------------
|
|
|
|
GLFW_RESIZABLE | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE`
|
|
|
|
GLFW_VISIBLE | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE`
|
|
|
|
GLFW_DECORATED | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE`
|
|
|
|
GLFW_FOCUSED | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE`
|
|
|
|
GLFW_AUTO_ICONIFY | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE`
|
|
|
|
GLFW_FLOATING | `GLFW_FALSE` | `GLFW_TRUE` or `GLFW_FALSE`
|
|
|
|
GLFW_MAXIMIZED | `GLFW_FALSE` | `GLFW_TRUE` or `GLFW_FALSE`
|
2016-08-18 15:47:54 +00:00
|
|
|
GLFW_CENTER_CURSOR | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE`
|
2017-11-07 21:50:01 +00:00
|
|
|
GLFW_TRANSPARENT_FRAMEBUFFER | `GLFW_FALSE` | `GLFW_TRUE` or `GLFW_FALSE`
|
2018-05-29 13:51:36 +00:00
|
|
|
GLFW_FOCUS_ON_SHOW | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE`
|
2018-08-31 11:33:48 +00:00
|
|
|
GLFW_SCALE_TO_MONITOR | `GLFW_FALSE` | `GLFW_TRUE` or `GLFW_FALSE`
|
2020-07-08 21:21:28 +00:00
|
|
|
GLFW_MOUSE_PASSTHROUGH | `GLFW_FALSE` | `GLFW_TRUE` or `GLFW_FALSE`
|
2021-10-26 12:25:03 +00:00
|
|
|
GLFW_POSITION_X | `GLFW_ANY_POSITION` | Any valid screen x-coordinate or `GLFW_ANY_POSITION`
|
|
|
|
GLFW_POSITION_Y | `GLFW_ANY_POSITION` | Any valid screen y-coordinate or `GLFW_ANY_POSITION`
|
2016-12-06 00:14:23 +00:00
|
|
|
GLFW_RED_BITS | 8 | 0 to `INT_MAX` or `GLFW_DONT_CARE`
|
|
|
|
GLFW_GREEN_BITS | 8 | 0 to `INT_MAX` or `GLFW_DONT_CARE`
|
|
|
|
GLFW_BLUE_BITS | 8 | 0 to `INT_MAX` or `GLFW_DONT_CARE`
|
|
|
|
GLFW_ALPHA_BITS | 8 | 0 to `INT_MAX` or `GLFW_DONT_CARE`
|
|
|
|
GLFW_DEPTH_BITS | 24 | 0 to `INT_MAX` or `GLFW_DONT_CARE`
|
|
|
|
GLFW_STENCIL_BITS | 8 | 0 to `INT_MAX` or `GLFW_DONT_CARE`
|
|
|
|
GLFW_ACCUM_RED_BITS | 0 | 0 to `INT_MAX` or `GLFW_DONT_CARE`
|
|
|
|
GLFW_ACCUM_GREEN_BITS | 0 | 0 to `INT_MAX` or `GLFW_DONT_CARE`
|
|
|
|
GLFW_ACCUM_BLUE_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_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_STEREO | `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_CLIENT_API | `GLFW_OPENGL_API` | `GLFW_OPENGL_API`, `GLFW_OPENGL_ES_API` or `GLFW_NO_API`
|
2017-02-28 18:23:25 +00:00
|
|
|
GLFW_CONTEXT_CREATION_API | `GLFW_NATIVE_CONTEXT_API` | `GLFW_NATIVE_CONTEXT_API`, `GLFW_EGL_CONTEXT_API` or `GLFW_OSMESA_CONTEXT_API`
|
2016-12-06 00:14:23 +00:00
|
|
|
GLFW_CONTEXT_VERSION_MAJOR | 1 | Any valid major version number of the chosen client API
|
|
|
|
GLFW_CONTEXT_VERSION_MINOR | 0 | Any valid minor version number of the chosen client API
|
|
|
|
GLFW_CONTEXT_ROBUSTNESS | `GLFW_NO_ROBUSTNESS` | `GLFW_NO_ROBUSTNESS`, `GLFW_NO_RESET_NOTIFICATION` or `GLFW_LOSE_CONTEXT_ON_RESET`
|
|
|
|
GLFW_CONTEXT_RELEASE_BEHAVIOR | `GLFW_ANY_RELEASE_BEHAVIOR` | `GLFW_ANY_RELEASE_BEHAVIOR`, `GLFW_RELEASE_BEHAVIOR_FLUSH` or `GLFW_RELEASE_BEHAVIOR_NONE`
|
|
|
|
GLFW_OPENGL_FORWARD_COMPAT | `GLFW_FALSE` | `GLFW_TRUE` or `GLFW_FALSE`
|
2020-06-26 16:35:48 +00:00
|
|
|
GLFW_CONTEXT_DEBUG | `GLFW_FALSE` | `GLFW_TRUE` or `GLFW_FALSE`
|
2016-12-06 00:14:23 +00:00
|
|
|
GLFW_OPENGL_PROFILE | `GLFW_OPENGL_ANY_PROFILE` | `GLFW_OPENGL_ANY_PROFILE`, `GLFW_OPENGL_COMPAT_PROFILE` or `GLFW_OPENGL_CORE_PROFILE`
|
2019-08-20 17:00:59 +00:00
|
|
|
GLFW_WIN32_KEYBOARD_MENU | `GLFW_FALSE` | `GLFW_TRUE` or `GLFW_FALSE`
|
2016-12-06 23:41:54 +00:00
|
|
|
GLFW_COCOA_RETINA_FRAMEBUFFER | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE`
|
2017-12-12 15:45:38 +00:00
|
|
|
GLFW_COCOA_FRAME_NAME | `""` | A UTF-8 encoded frame autosave name
|
2017-01-27 11:02:09 +00:00
|
|
|
GLFW_COCOA_GRAPHICS_SWITCHING | `GLFW_FALSE` | `GLFW_TRUE` or `GLFW_FALSE`
|
2017-12-12 09:54:18 +00:00
|
|
|
GLFW_X11_CLASS_NAME | `""` | An ASCII encoded `WM_CLASS` class name
|
|
|
|
GLFW_X11_INSTANCE_NAME | `""` | An ASCII encoded `WM_CLASS` instance name
|
2022-05-27 00:33:28 +00:00
|
|
|
GLFW_WAYLAND_APP_ID | `""` | An ASCII encoded Wayland `app_id` name
|
2014-09-18 13:03:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
@section window_events Window event processing
|
|
|
|
|
2015-01-18 00:55:25 +00:00
|
|
|
See @ref events.
|
2014-09-18 13:03:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
@section window_properties Window properties and events
|
|
|
|
|
|
|
|
@subsection window_userptr User pointer
|
|
|
|
|
|
|
|
Each window has a user pointer that can be set with @ref
|
2017-12-07 15:19:57 +00:00
|
|
|
glfwSetWindowUserPointer and queried with @ref glfwGetWindowUserPointer. This
|
2014-09-18 13:03:29 +00:00
|
|
|
can be used for any purpose you need and will not be modified by GLFW throughout
|
|
|
|
the life-time of the window.
|
|
|
|
|
|
|
|
The initial value of the pointer is `NULL`.
|
|
|
|
|
|
|
|
|
2015-01-18 00:55:25 +00:00
|
|
|
@subsection window_close Window closing and close flag
|
2013-04-10 23:07:07 +00:00
|
|
|
|
|
|
|
When the user attempts to close the window, for example by clicking the close
|
2014-10-02 15:35:10 +00:00
|
|
|
widget or using a key chord like Alt+F4, the _close flag_ of the window is set.
|
2013-05-27 15:10:34 +00:00
|
|
|
The window is however not actually destroyed and, unless you watch for this
|
|
|
|
state change, nothing further happens.
|
|
|
|
|
|
|
|
The current state of the close flag is returned by @ref glfwWindowShouldClose
|
|
|
|
and can be set or cleared directly with @ref glfwSetWindowShouldClose. A common
|
|
|
|
pattern is to use the close flag as a main loop condition.
|
|
|
|
|
|
|
|
@code
|
|
|
|
while (!glfwWindowShouldClose(window))
|
|
|
|
{
|
|
|
|
render(window);
|
|
|
|
|
|
|
|
glfwSwapBuffers(window);
|
|
|
|
glfwPollEvents();
|
|
|
|
}
|
|
|
|
@endcode
|
|
|
|
|
2014-09-18 13:03:29 +00:00
|
|
|
If you wish to be notified when the user attempts to close a window, set a close
|
2014-10-02 15:35:10 +00:00
|
|
|
callback.
|
2013-05-27 15:10:34 +00:00
|
|
|
|
|
|
|
@code
|
|
|
|
glfwSetWindowCloseCallback(window, window_close_callback);
|
|
|
|
@endcode
|
|
|
|
|
2014-10-02 15:35:10 +00:00
|
|
|
The callback function is called directly _after_ the close flag has been set.
|
2014-09-18 13:03:29 +00:00
|
|
|
It can be used for example to filter close requests and clear the close flag
|
|
|
|
again unless certain conditions are met.
|
2013-05-27 15:10:34 +00:00
|
|
|
|
|
|
|
@code
|
|
|
|
void window_close_callback(GLFWwindow* window)
|
|
|
|
{
|
|
|
|
if (!time_to_close)
|
2015-08-23 17:30:04 +00:00
|
|
|
glfwSetWindowShouldClose(window, GLFW_FALSE);
|
2013-05-27 15:10:34 +00:00
|
|
|
}
|
|
|
|
@endcode
|
|
|
|
|
|
|
|
|
2015-01-18 00:55:25 +00:00
|
|
|
@subsection window_size Window size
|
2013-05-27 15:10:34 +00:00
|
|
|
|
|
|
|
The size of a window can be changed with @ref glfwSetWindowSize. For windowed
|
2014-10-07 21:37:59 +00:00
|
|
|
mode windows, this sets the size, in
|
2019-01-22 19:54:16 +00:00
|
|
|
[screen coordinates](@ref coordinate_systems) of the _content area_ or _content
|
2014-10-07 21:37:59 +00:00
|
|
|
area_ of the window. The window system may impose limits on window size.
|
2013-05-27 15:10:34 +00:00
|
|
|
|
|
|
|
@code
|
2014-10-02 15:35:10 +00:00
|
|
|
glfwSetWindowSize(window, 640, 480);
|
2013-05-27 15:10:34 +00:00
|
|
|
@endcode
|
|
|
|
|
2014-10-02 15:35:10 +00:00
|
|
|
For full screen windows, the specified size becomes the new resolution of the
|
2016-02-23 11:26:42 +00:00
|
|
|
window's desired video mode. The video mode most closely matching the new
|
2014-10-02 15:35:10 +00:00
|
|
|
desired video mode is set immediately. The window is resized to fit the
|
|
|
|
resolution of the set video mode.
|
|
|
|
|
2017-10-29 15:27:15 +00:00
|
|
|
If you wish to be notified when a window is resized, whether by the user, the
|
|
|
|
system or your own code, set a size callback.
|
2013-05-27 15:10:34 +00:00
|
|
|
|
|
|
|
@code
|
|
|
|
glfwSetWindowSizeCallback(window, window_size_callback);
|
|
|
|
@endcode
|
|
|
|
|
2014-10-07 21:37:59 +00:00
|
|
|
The callback function receives the new size, in screen coordinates, of the
|
2019-01-22 19:54:16 +00:00
|
|
|
content area of the window when the window is resized.
|
2013-05-27 15:10:34 +00:00
|
|
|
|
|
|
|
@code
|
|
|
|
void window_size_callback(GLFWwindow* window, int width, int height)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
@endcode
|
|
|
|
|
|
|
|
There is also @ref glfwGetWindowSize for directly retrieving the current size of
|
|
|
|
a window.
|
|
|
|
|
|
|
|
@code
|
|
|
|
int width, height;
|
|
|
|
glfwGetWindowSize(window, &width, &height);
|
2013-07-07 10:06:59 +00:00
|
|
|
@endcode
|
|
|
|
|
2014-04-23 11:30:11 +00:00
|
|
|
@note Do not pass the window size to `glViewport` or other pixel-based OpenGL
|
|
|
|
calls. The window size is in screen coordinates, not pixels. Use the
|
2014-09-18 13:03:29 +00:00
|
|
|
[framebuffer size](@ref window_fbsize), which is in pixels, for pixel-based
|
|
|
|
calls.
|
|
|
|
|
2019-01-22 19:54:16 +00:00
|
|
|
The above functions work with the size of the content area, but decorated
|
|
|
|
windows typically have title bars and window frames around this rectangle. You
|
|
|
|
can retrieve the extents of these with @ref glfwGetWindowFrameSize.
|
2014-09-18 13:03:29 +00:00
|
|
|
|
|
|
|
@code
|
|
|
|
int left, top, right, bottom;
|
|
|
|
glfwGetWindowFrameSize(window, &left, &top, &right, &bottom);
|
|
|
|
@endcode
|
|
|
|
|
|
|
|
The returned values are the distances, in screen coordinates, from the edges of
|
2019-01-22 19:54:16 +00:00
|
|
|
the content area to the corresponding edges of the full window. As they are
|
2014-09-18 13:03:29 +00:00
|
|
|
distances and not coordinates, they are always zero or positive.
|
2014-04-23 11:30:11 +00:00
|
|
|
|
2013-07-07 10:06:59 +00:00
|
|
|
|
2014-09-18 13:03:29 +00:00
|
|
|
@subsection window_fbsize Framebuffer size
|
2013-07-07 10:06:59 +00:00
|
|
|
|
|
|
|
While the size of a window is measured in screen coordinates, OpenGL works with
|
2014-10-07 21:37:59 +00:00
|
|
|
pixels. The size you pass into `glViewport`, for example, should be in pixels.
|
|
|
|
On some machines screen coordinates and pixels are the same, but on others they
|
|
|
|
will not be. There is a second set of functions to retrieve the size, in
|
|
|
|
pixels, of the framebuffer of a window.
|
2013-07-07 10:06:59 +00:00
|
|
|
|
|
|
|
If you wish to be notified when the framebuffer of a window is resized, whether
|
2014-10-02 15:35:10 +00:00
|
|
|
by the user or the system, set a size callback.
|
2013-07-07 10:06:59 +00:00
|
|
|
|
|
|
|
@code
|
|
|
|
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
|
|
|
|
@endcode
|
|
|
|
|
2014-09-18 13:03:29 +00:00
|
|
|
The callback function receives the new size of the framebuffer when it is
|
|
|
|
resized, which can for example be used to update the OpenGL viewport.
|
2013-07-07 10:06:59 +00:00
|
|
|
|
|
|
|
@code
|
|
|
|
void framebuffer_size_callback(GLFWwindow* window, int width, int height)
|
|
|
|
{
|
|
|
|
glViewport(0, 0, width, height);
|
|
|
|
}
|
|
|
|
@endcode
|
|
|
|
|
|
|
|
There is also @ref glfwGetFramebufferSize for directly retrieving the current
|
|
|
|
size of the framebuffer of a window.
|
|
|
|
|
|
|
|
@code
|
|
|
|
int width, height;
|
|
|
|
glfwGetFramebufferSize(window, &width, &height);
|
2013-05-27 15:10:34 +00:00
|
|
|
glViewport(0, 0, width, height);
|
|
|
|
@endcode
|
|
|
|
|
2015-01-11 22:33:14 +00:00
|
|
|
The size of a framebuffer may change independently of the size of a window, for
|
|
|
|
example if the window is dragged between a regular monitor and a high-DPI one.
|
2013-07-07 10:06:59 +00:00
|
|
|
|
2013-05-27 15:10:34 +00:00
|
|
|
|
2017-08-29 17:19:00 +00:00
|
|
|
@subsection window_scale Window content scale
|
|
|
|
|
|
|
|
The content scale for a window can be retrieved with @ref
|
|
|
|
glfwGetWindowContentScale.
|
|
|
|
|
|
|
|
@code
|
|
|
|
float xscale, yscale;
|
|
|
|
glfwGetWindowContentScale(window, &xscale, &yscale);
|
|
|
|
@endcode
|
|
|
|
|
2019-04-01 16:36:30 +00:00
|
|
|
The content scale is the ratio between the current DPI and the platform's
|
|
|
|
default DPI. This is especially important for text and any UI elements. If the
|
|
|
|
pixel dimensions of your UI scaled by this look appropriate on your machine then
|
|
|
|
it should appear at a reasonable size on other machines regardless of their DPI
|
|
|
|
and scaling settings. This relies on the system DPI and scaling settings being
|
|
|
|
somewhat correct.
|
2017-08-29 17:19:00 +00:00
|
|
|
|
|
|
|
On systems where each monitors can have its own content scale, the window
|
|
|
|
content scale will depend on which monitor the system considers the window to be
|
|
|
|
on.
|
|
|
|
|
2017-12-11 20:26:40 +00:00
|
|
|
If you wish to be notified when the content scale of a window changes, whether
|
|
|
|
because of a system setting change or because it was moved to a monitor with
|
|
|
|
a different scale, set a content scale callback.
|
|
|
|
|
|
|
|
@code
|
|
|
|
glfwSetWindowContentScaleCallback(window, window_content_scale_callback);
|
|
|
|
@endcode
|
|
|
|
|
|
|
|
The callback function receives the new content scale of the window.
|
|
|
|
|
|
|
|
@code
|
|
|
|
void window_content_scale_callback(GLFWwindow* window, float xscale, float yscale)
|
|
|
|
{
|
|
|
|
set_interface_scale(xscale, yscale);
|
|
|
|
}
|
|
|
|
@endcode
|
|
|
|
|
2018-08-31 11:33:48 +00:00
|
|
|
On platforms where pixels and screen coordinates always map 1:1, the window
|
|
|
|
will need to be resized to appear the same size when it is moved to a monitor
|
|
|
|
with a different content scale. To have this done automatically both when the
|
|
|
|
window is created and when its content scale later changes, set the @ref
|
|
|
|
GLFW_SCALE_TO_MONITOR window hint.
|
|
|
|
|
2017-08-29 17:19:00 +00:00
|
|
|
|
2014-02-13 01:57:59 +00:00
|
|
|
@subsection window_sizelimits Window size limits
|
|
|
|
|
2019-01-22 19:54:16 +00:00
|
|
|
The minimum and maximum size of the content area of a windowed mode window can
|
|
|
|
be enforced with @ref glfwSetWindowSizeLimits. The user may resize the window
|
|
|
|
to any size and aspect ratio within the specified limits, unless the aspect
|
|
|
|
ratio is also set.
|
2014-02-13 01:57:59 +00:00
|
|
|
|
|
|
|
@code
|
|
|
|
glfwSetWindowSizeLimits(window, 200, 200, 400, 400);
|
|
|
|
@endcode
|
|
|
|
|
2015-10-19 14:01:42 +00:00
|
|
|
To specify only a minimum size or only a maximum one, set the other pair to
|
|
|
|
`GLFW_DONT_CARE`.
|
2014-02-13 01:57:59 +00:00
|
|
|
|
|
|
|
@code
|
2015-10-19 14:01:42 +00:00
|
|
|
glfwSetWindowSizeLimits(window, 640, 480, GLFW_DONT_CARE, GLFW_DONT_CARE);
|
2014-02-13 01:57:59 +00:00
|
|
|
@endcode
|
|
|
|
|
2015-10-19 14:01:42 +00:00
|
|
|
To disable size limits for a window, set them all to `GLFW_DONT_CARE`.
|
2014-02-13 01:57:59 +00:00
|
|
|
|
2019-01-22 19:54:16 +00:00
|
|
|
The aspect ratio of the content area of a windowed mode window can be enforced
|
2015-10-19 14:01:42 +00:00
|
|
|
with @ref glfwSetWindowAspectRatio. The user may resize the window freely
|
|
|
|
unless size limits are also set, but the size will be constrained to maintain
|
|
|
|
the aspect ratio.
|
2014-02-13 01:57:59 +00:00
|
|
|
|
|
|
|
@code
|
|
|
|
glfwSetWindowAspectRatio(window, 16, 9);
|
|
|
|
@endcode
|
|
|
|
|
2015-10-19 14:01:42 +00:00
|
|
|
The aspect ratio is specified as a numerator and denominator, corresponding to
|
|
|
|
the width and height, respectively. If you want a window to maintain its
|
2017-10-22 14:27:17 +00:00
|
|
|
current aspect ratio, use its current size as the ratio.
|
2014-02-13 01:57:59 +00:00
|
|
|
|
|
|
|
@code
|
2015-10-19 14:01:42 +00:00
|
|
|
int width, height;
|
|
|
|
glfwGetWindowSize(window, &width, &height);
|
|
|
|
glfwSetWindowAspectRatio(window, width, height);
|
2014-02-13 01:57:59 +00:00
|
|
|
@endcode
|
|
|
|
|
2015-10-19 14:01:42 +00:00
|
|
|
To disable the aspect ratio limit for a window, set both terms to
|
|
|
|
`GLFW_DONT_CARE`.
|
|
|
|
|
2014-02-13 01:57:59 +00:00
|
|
|
You can have both size limits and aspect ratio set for a window, but the results
|
|
|
|
are undefined if they conflict.
|
|
|
|
|
|
|
|
|
2015-01-18 00:55:25 +00:00
|
|
|
@subsection window_pos Window position
|
2013-05-27 15:10:34 +00:00
|
|
|
|
2021-10-26 12:25:03 +00:00
|
|
|
By default, the window manager chooses the position of new windowed mode
|
|
|
|
windows, based on its size and which monitor the user appears to be working on.
|
|
|
|
This is most often the right choice. If you need to create a window at
|
|
|
|
a specific position, you can set the desired position with the @ref
|
|
|
|
GLFW_POSITION_X and @ref GLFW_POSITION_Y window hints.
|
|
|
|
|
|
|
|
@code
|
|
|
|
glfwWindowHint(GLFW_POSITION_X, 70);
|
|
|
|
glfwWindowHint(GLFW_POSITION_Y, 83);
|
|
|
|
@endcode
|
|
|
|
|
|
|
|
To restore the previous behavior, set these hints to `GLFW_ANY_POSITION`.
|
|
|
|
|
|
|
|
The position of a windowed mode window can be changed with @ref
|
2013-05-27 15:10:34 +00:00
|
|
|
glfwSetWindowPos. This moves the window so that the upper-left corner of its
|
2019-01-22 19:54:16 +00:00
|
|
|
content area has the specified [screen coordinates](@ref coordinate_systems).
|
2015-01-05 15:46:04 +00:00
|
|
|
The window system may put limitations on window placement.
|
2013-05-27 15:10:34 +00:00
|
|
|
|
|
|
|
@code
|
|
|
|
glfwSetWindowPos(window, 100, 100);
|
|
|
|
@endcode
|
|
|
|
|
2017-10-29 15:27:15 +00:00
|
|
|
If you wish to be notified when a window is moved, whether by the user, the
|
|
|
|
system or your own code, set a position callback.
|
2013-05-27 15:10:34 +00:00
|
|
|
|
|
|
|
@code
|
|
|
|
glfwSetWindowPosCallback(window, window_pos_callback);
|
|
|
|
@endcode
|
|
|
|
|
2017-10-29 15:27:15 +00:00
|
|
|
The callback function receives the new position, in screen coordinates, of the
|
2019-01-22 19:54:16 +00:00
|
|
|
upper-left corner of the content area when the window is moved.
|
2013-05-27 15:10:34 +00:00
|
|
|
|
|
|
|
@code
|
2014-03-06 14:31:24 +00:00
|
|
|
void window_pos_callback(GLFWwindow* window, int xpos, int ypos)
|
2013-05-27 15:10:34 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
@endcode
|
|
|
|
|
|
|
|
There is also @ref glfwGetWindowPos for directly retrieving the current position
|
2019-01-22 19:54:16 +00:00
|
|
|
of the content area of the window.
|
2013-05-27 15:10:34 +00:00
|
|
|
|
|
|
|
@code
|
|
|
|
int xpos, ypos;
|
|
|
|
glfwGetWindowPos(window, &xpos, &ypos);
|
|
|
|
@endcode
|
|
|
|
|
|
|
|
|
2015-01-18 00:55:25 +00:00
|
|
|
@subsection window_title Window title
|
2013-05-27 15:10:34 +00:00
|
|
|
|
|
|
|
All GLFW windows have a title, although undecorated or full screen windows may
|
2014-09-18 13:03:29 +00:00
|
|
|
not display it or only display it in a task bar or similar interface. You can
|
|
|
|
set a UTF-8 encoded window title with @ref glfwSetWindowTitle.
|
2013-05-27 15:10:34 +00:00
|
|
|
|
|
|
|
@code
|
|
|
|
glfwSetWindowTitle(window, "My Window");
|
|
|
|
@endcode
|
|
|
|
|
2014-09-18 13:03:29 +00:00
|
|
|
The specified string is copied before the function returns, so there is no need
|
|
|
|
to keep it around.
|
|
|
|
|
|
|
|
As long as your source file is encoded as UTF-8, you can use any Unicode
|
|
|
|
characters directly in the source.
|
|
|
|
|
|
|
|
@code
|
2016-08-18 21:42:15 +00:00
|
|
|
glfwSetWindowTitle(window, "ラストエグザイル");
|
2014-09-18 13:03:29 +00:00
|
|
|
@endcode
|
|
|
|
|
2015-10-24 19:40:27 +00:00
|
|
|
If you are using C++11 or C11, you can use a UTF-8 string literal.
|
|
|
|
|
|
|
|
@code
|
|
|
|
glfwSetWindowTitle(window, u8"This is always a UTF-8 string");
|
|
|
|
@endcode
|
|
|
|
|
2014-09-18 13:03:29 +00:00
|
|
|
|
2016-03-07 13:55:30 +00:00
|
|
|
@subsection window_icon Window icon
|
|
|
|
|
|
|
|
Decorated windows have icons on some platforms. You can set this icon by
|
|
|
|
specifying a list of candidate images with @ref glfwSetWindowIcon.
|
|
|
|
|
|
|
|
@code
|
|
|
|
GLFWimage images[2];
|
|
|
|
images[0] = load_icon("my_icon.png");
|
|
|
|
images[1] = load_icon("my_icon_small.png");
|
|
|
|
|
|
|
|
glfwSetWindowIcon(window, 2, images);
|
|
|
|
@endcode
|
|
|
|
|
2017-06-06 16:17:58 +00:00
|
|
|
The image data is 32-bit, little-endian, non-premultiplied RGBA, i.e. eight bits
|
|
|
|
per channel with the red channel first. The pixels are arranged canonically as
|
|
|
|
sequential rows, starting from the top-left corner.
|
|
|
|
|
2016-03-07 13:55:30 +00:00
|
|
|
To revert to the default window icon, pass in an empty image array.
|
|
|
|
|
|
|
|
@code
|
|
|
|
glfwSetWindowIcon(window, 0, NULL);
|
|
|
|
@endcode
|
|
|
|
|
|
|
|
|
2015-01-18 00:55:25 +00:00
|
|
|
@subsection window_monitor Window monitor
|
2014-09-18 13:03:29 +00:00
|
|
|
|
|
|
|
Full screen windows are associated with a specific monitor. You can get the
|
|
|
|
handle for this monitor with @ref glfwGetWindowMonitor.
|
|
|
|
|
|
|
|
@code
|
|
|
|
GLFWmonitor* monitor = glfwGetWindowMonitor(window);
|
|
|
|
@endcode
|
|
|
|
|
|
|
|
This monitor handle is one of those returned by @ref glfwGetMonitors.
|
|
|
|
|
2016-02-23 11:26:42 +00:00
|
|
|
For windowed mode windows, this function returns `NULL`. This is how to tell
|
|
|
|
full screen windows from windowed mode windows.
|
|
|
|
|
|
|
|
You can move windows between monitors or between full screen and windowed mode
|
|
|
|
with @ref glfwSetWindowMonitor. When making a window full screen on the same or
|
|
|
|
on a different monitor, specify the desired monitor, resolution and refresh
|
|
|
|
rate. The position arguments are ignored.
|
|
|
|
|
|
|
|
@code
|
|
|
|
const GLFWvidmode* mode = glfwGetVideoMode(monitor);
|
|
|
|
|
|
|
|
glfwSetWindowMonitor(window, monitor, 0, 0, mode->width, mode->height, mode->refreshRate);
|
|
|
|
@endcode
|
|
|
|
|
|
|
|
When making the window windowed, specify the desired position and size. The
|
|
|
|
refresh rate argument is ignored.
|
|
|
|
|
|
|
|
@code
|
|
|
|
glfwSetWindowMonitor(window, NULL, xpos, ypos, width, height, 0);
|
|
|
|
@endcode
|
|
|
|
|
|
|
|
This restores any previous window settings such as whether it is decorated,
|
|
|
|
floating, resizable, has size or aspect ratio limits, etc.. To restore a window
|
|
|
|
that was originally windowed to its original size and position, save these
|
|
|
|
before making it full screen and then pass them in as above.
|
2014-09-18 13:03:29 +00:00
|
|
|
|
|
|
|
|
2015-01-18 00:55:25 +00:00
|
|
|
@subsection window_iconify Window iconification
|
2014-09-18 13:03:29 +00:00
|
|
|
|
|
|
|
Windows can be iconified (i.e. minimized) with @ref glfwIconifyWindow.
|
|
|
|
|
|
|
|
@code
|
|
|
|
glfwIconifyWindow(window);
|
|
|
|
@endcode
|
|
|
|
|
|
|
|
When a full screen window is iconified, the original video mode of its monitor
|
|
|
|
is restored until the user or application restores the window.
|
|
|
|
|
2016-06-16 11:09:28 +00:00
|
|
|
Iconified windows can be restored with @ref glfwRestoreWindow. This function
|
|
|
|
also restores windows from maximization.
|
2014-09-18 13:03:29 +00:00
|
|
|
|
|
|
|
@code
|
|
|
|
glfwRestoreWindow(window);
|
|
|
|
@endcode
|
|
|
|
|
|
|
|
When a full screen window is restored, the desired video mode is restored to its
|
|
|
|
monitor as well.
|
|
|
|
|
|
|
|
If you wish to be notified when a window is iconified or restored, whether by
|
2019-04-04 15:14:40 +00:00
|
|
|
the user, system or your own code, set an iconify callback.
|
2014-09-18 13:03:29 +00:00
|
|
|
|
|
|
|
@code
|
|
|
|
glfwSetWindowIconifyCallback(window, window_iconify_callback);
|
|
|
|
@endcode
|
|
|
|
|
|
|
|
The callback function receives changes in the iconification state of the window.
|
|
|
|
|
|
|
|
@code
|
|
|
|
void window_iconify_callback(GLFWwindow* window, int iconified)
|
|
|
|
{
|
|
|
|
if (iconified)
|
|
|
|
{
|
|
|
|
// The window was iconified
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// The window was restored
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@endcode
|
|
|
|
|
2015-01-05 15:46:04 +00:00
|
|
|
You can also get the current iconification state with @ref glfwGetWindowAttrib.
|
2014-09-18 13:03:29 +00:00
|
|
|
|
|
|
|
@code
|
|
|
|
int iconified = glfwGetWindowAttrib(window, GLFW_ICONIFIED);
|
|
|
|
@endcode
|
|
|
|
|
|
|
|
|
2016-06-16 11:09:28 +00:00
|
|
|
@subsection window_maximize Window maximization
|
|
|
|
|
|
|
|
Windows can be maximized (i.e. zoomed) with @ref glfwMaximizeWindow.
|
|
|
|
|
|
|
|
@code
|
|
|
|
glfwMaximizeWindow(window);
|
|
|
|
@endcode
|
|
|
|
|
|
|
|
Full screen windows cannot be maximized and passing a full screen window to this
|
|
|
|
function does nothing.
|
|
|
|
|
|
|
|
Maximized windows can be restored with @ref glfwRestoreWindow. This function
|
|
|
|
also restores windows from iconification.
|
|
|
|
|
|
|
|
@code
|
|
|
|
glfwRestoreWindow(window);
|
|
|
|
@endcode
|
|
|
|
|
|
|
|
If you wish to be notified when a window is maximized or restored, whether by
|
|
|
|
the user, system or your own code, set a maximize callback.
|
|
|
|
|
|
|
|
@code
|
|
|
|
glfwSetWindowMaximizeCallback(window, window_maximize_callback);
|
|
|
|
@endcode
|
|
|
|
|
|
|
|
The callback function receives changes in the maximization state of the window.
|
|
|
|
|
|
|
|
@code
|
|
|
|
void window_maximize_callback(GLFWwindow* window, int maximized)
|
|
|
|
{
|
|
|
|
if (maximized)
|
|
|
|
{
|
|
|
|
// The window was maximized
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// The window was restored
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@endcode
|
|
|
|
|
|
|
|
You can also get the current maximization state with @ref glfwGetWindowAttrib.
|
|
|
|
|
|
|
|
@code
|
|
|
|
int maximized = glfwGetWindowAttrib(window, GLFW_MAXIMIZED);
|
|
|
|
@endcode
|
|
|
|
|
2016-12-06 00:14:23 +00:00
|
|
|
By default, newly created windows are not maximized. You can change this
|
|
|
|
behavior by setting the [GLFW_MAXIMIZED](@ref GLFW_MAXIMIZED_hint) window hint
|
|
|
|
before creating the window.
|
|
|
|
|
|
|
|
@code
|
|
|
|
glfwWindowHint(GLFW_MAXIMIZED, GLFW_TRUE);
|
|
|
|
@endcode
|
|
|
|
|
2016-06-16 11:09:28 +00:00
|
|
|
|
2015-01-18 00:55:25 +00:00
|
|
|
@subsection window_hide Window visibility
|
2014-09-18 13:03:29 +00:00
|
|
|
|
|
|
|
Windowed mode windows can be hidden with @ref glfwHideWindow.
|
|
|
|
|
|
|
|
@code
|
|
|
|
glfwHideWindow(window);
|
|
|
|
@endcode
|
|
|
|
|
|
|
|
This makes the window completely invisible to the user, including removing it
|
|
|
|
from the task bar, dock or window list. Full screen windows cannot be hidden
|
|
|
|
and calling @ref glfwHideWindow on a full screen window does nothing.
|
|
|
|
|
|
|
|
Hidden windows can be shown with @ref glfwShowWindow.
|
|
|
|
|
|
|
|
@code
|
|
|
|
glfwShowWindow(window);
|
|
|
|
@endcode
|
|
|
|
|
2018-05-29 13:51:36 +00:00
|
|
|
By default, this function will also set the input focus to that window. Set
|
|
|
|
the [GLFW_FOCUS_ON_SHOW](@ref GLFW_FOCUS_ON_SHOW_hint) window hint to change
|
|
|
|
this behavior for all newly created windows, or change the behavior for an
|
|
|
|
existing window with @ref glfwSetWindowAttrib.
|
2014-09-18 13:03:29 +00:00
|
|
|
|
2015-01-05 15:46:04 +00:00
|
|
|
You can also get the current visibility state with @ref glfwGetWindowAttrib.
|
2014-09-18 13:03:29 +00:00
|
|
|
|
|
|
|
@code
|
|
|
|
int visible = glfwGetWindowAttrib(window, GLFW_VISIBLE);
|
|
|
|
@endcode
|
|
|
|
|
2016-12-06 00:14:23 +00:00
|
|
|
By default, newly created windows are visible. You can change this behavior by
|
|
|
|
setting the [GLFW_VISIBLE](@ref GLFW_VISIBLE_hint) window hint before creating
|
|
|
|
the window.
|
|
|
|
|
|
|
|
@code
|
|
|
|
glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE);
|
|
|
|
@endcode
|
|
|
|
|
|
|
|
Windows created hidden are completely invisible to the user until shown. This
|
|
|
|
can be useful if you need to set up your window further before showing it, for
|
|
|
|
example moving it to a specific location.
|
|
|
|
|
2014-09-18 13:03:29 +00:00
|
|
|
|
2015-01-18 00:55:25 +00:00
|
|
|
@subsection window_focus Window input focus
|
2014-09-18 13:03:29 +00:00
|
|
|
|
2016-02-21 14:42:49 +00:00
|
|
|
Windows can be given input focus and brought to the front with @ref
|
|
|
|
glfwFocusWindow.
|
|
|
|
|
|
|
|
@code
|
|
|
|
glfwFocusWindow(window);
|
|
|
|
@endcode
|
|
|
|
|
2017-05-11 12:36:56 +00:00
|
|
|
Keep in mind that it can be very disruptive to the user when a window is forced
|
|
|
|
to the top. For a less disruptive way of getting the user's attention, see
|
|
|
|
[attention requests](@ref window_attention).
|
|
|
|
|
2015-01-18 00:55:25 +00:00
|
|
|
If you wish to be notified when a window gains or loses input focus, whether by
|
2014-10-02 15:35:10 +00:00
|
|
|
the user, system or your own code, set a focus callback.
|
2014-09-18 13:03:29 +00:00
|
|
|
|
|
|
|
@code
|
|
|
|
glfwSetWindowFocusCallback(window, window_focus_callback);
|
|
|
|
@endcode
|
|
|
|
|
2015-01-18 00:55:25 +00:00
|
|
|
The callback function receives changes in the input focus state of the window.
|
2014-09-18 13:03:29 +00:00
|
|
|
|
|
|
|
@code
|
|
|
|
void window_focus_callback(GLFWwindow* window, int focused)
|
|
|
|
{
|
|
|
|
if (focused)
|
|
|
|
{
|
2015-01-18 00:55:25 +00:00
|
|
|
// The window gained input focus
|
2014-09-18 13:03:29 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-01-18 00:55:25 +00:00
|
|
|
// The window lost input focus
|
2014-09-18 13:03:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
@endcode
|
|
|
|
|
2015-01-18 00:55:25 +00:00
|
|
|
You can also get the current input focus state with @ref glfwGetWindowAttrib.
|
2013-05-27 15:10:34 +00:00
|
|
|
|
|
|
|
@code
|
2014-09-18 13:03:29 +00:00
|
|
|
int focused = glfwGetWindowAttrib(window, GLFW_FOCUSED);
|
2013-05-27 15:10:34 +00:00
|
|
|
@endcode
|
|
|
|
|
2016-12-06 00:14:23 +00:00
|
|
|
By default, newly created windows are given input focus. You can change this
|
|
|
|
behavior by setting the [GLFW_FOCUSED](@ref GLFW_FOCUSED_hint) window hint
|
|
|
|
before creating the window.
|
|
|
|
|
|
|
|
@code
|
|
|
|
glfwWindowHint(GLFW_FOCUSED, GLFW_FALSE);
|
|
|
|
@endcode
|
|
|
|
|
2013-05-27 15:10:34 +00:00
|
|
|
|
2017-05-11 12:36:56 +00:00
|
|
|
@subsection window_attention Window attention request
|
|
|
|
|
|
|
|
If you wish to notify the user of an event without interrupting, you can request
|
|
|
|
attention with @ref glfwRequestWindowAttention.
|
|
|
|
|
|
|
|
@code
|
|
|
|
glfwRequestWindowAttention(window);
|
|
|
|
@endcode
|
|
|
|
|
|
|
|
The system will highlight the specified window, or on platforms where this is
|
|
|
|
not supported, the application as a whole. Once the user has given it
|
|
|
|
attention, the system will automatically end the request.
|
|
|
|
|
|
|
|
|
2023-03-08 13:10:00 +00:00
|
|
|
@subsection window_progress_indicator Window progress indicator
|
2023-02-05 01:50:53 +00:00
|
|
|
|
2023-03-08 13:10:00 +00:00
|
|
|
If you wish to display the progress of some action on the Dock icon or task bar, you can
|
|
|
|
do this with @ref glfwSetWindowProgressIndicator.
|
2023-02-05 03:19:15 +00:00
|
|
|
|
|
|
|
@code
|
2023-03-08 13:10:00 +00:00
|
|
|
glfwSetWindowProgressIndicator(window, GLFW_PROGRESS_INDICATOR_NORMAL, 0.5);
|
2023-02-05 03:19:15 +00:00
|
|
|
@endcode
|
|
|
|
|
2023-03-08 13:10:00 +00:00
|
|
|
There are different progress states available for you to use:
|
|
|
|
- @ref GLFW_PROGRESS_INDICATOR_DISABLED
|
|
|
|
- @ref GLFW_PROGRESS_INDICATOR_INDETERMINATE
|
|
|
|
- @ref GLFW_PROGRESS_INDICATOR_NORMAL
|
|
|
|
- @ref GLFW_PROGRESS_INDICATOR_ERROR
|
|
|
|
- @ref GLFW_PROGRESS_INDICATOR_PAUSED
|
2023-02-05 03:19:15 +00:00
|
|
|
|
|
|
|
The last argument is the progress percentage to display.
|
2023-03-02 12:50:16 +00:00
|
|
|
It has a valid range of 0.0 to 1.0.
|
2023-02-05 01:50:53 +00:00
|
|
|
|
|
|
|
|
2015-01-18 00:55:25 +00:00
|
|
|
@subsection window_refresh Window damage and refresh
|
2014-09-18 13:03:29 +00:00
|
|
|
|
|
|
|
If you wish to be notified when the contents of a window is damaged and needs
|
2014-10-02 15:35:10 +00:00
|
|
|
to be refreshed, set a window refresh callback.
|
2014-09-18 13:03:29 +00:00
|
|
|
|
|
|
|
@code
|
|
|
|
glfwSetWindowRefreshCallback(m_handle, window_refresh_callback);
|
|
|
|
@endcode
|
|
|
|
|
|
|
|
The callback function is called when the contents of the window needs to be
|
|
|
|
refreshed.
|
|
|
|
|
|
|
|
@code
|
|
|
|
void window_refresh_callback(GLFWwindow* window)
|
|
|
|
{
|
|
|
|
draw_editor_ui(window);
|
|
|
|
glfwSwapBuffers(window);
|
|
|
|
}
|
|
|
|
@endcode
|
|
|
|
|
|
|
|
@note On compositing window systems such as Aero, Compiz or Aqua, where the
|
2015-01-16 13:09:03 +00:00
|
|
|
window contents are saved off-screen, this callback might only be called when
|
|
|
|
the window or framebuffer is resized.
|
2014-09-18 13:03:29 +00:00
|
|
|
|
|
|
|
|
2017-09-18 16:10:57 +00:00
|
|
|
@subsection window_transparency Window transparency
|
|
|
|
|
2017-09-25 21:14:45 +00:00
|
|
|
GLFW supports two kinds of transparency for windows; framebuffer transparency
|
|
|
|
and whole window transparency. A single window may not use both methods. The
|
|
|
|
results of doing this are undefined.
|
|
|
|
|
|
|
|
Both methods require the platform to support it and not every version of every
|
|
|
|
platform GLFW supports does this, so there are mechanisms to check whether the
|
|
|
|
window really is transparent.
|
|
|
|
|
2017-09-18 16:10:57 +00:00
|
|
|
Window framebuffers can be made transparent on a per-pixel per-frame basis with
|
2017-11-07 21:50:01 +00:00
|
|
|
the [GLFW_TRANSPARENT_FRAMEBUFFER](@ref GLFW_TRANSPARENT_FRAMEBUFFER_hint)
|
|
|
|
window hint.
|
2017-09-18 16:10:57 +00:00
|
|
|
|
|
|
|
@code
|
2017-11-07 21:50:01 +00:00
|
|
|
glfwWindowHint(GLFW_TRANSPARENT_FRAMEBUFFER, GLFW_TRUE);
|
2017-09-18 16:10:57 +00:00
|
|
|
@endcode
|
|
|
|
|
2017-11-07 21:50:01 +00:00
|
|
|
If supported by the system, the window content area will be composited with the
|
2017-09-18 16:10:57 +00:00
|
|
|
background using the framebuffer per-pixel alpha channel. This requires desktop
|
|
|
|
compositing to be enabled on the system. It does not affect window decorations.
|
|
|
|
|
|
|
|
You can check whether the window framebuffer was successfully made transparent
|
2017-11-07 21:50:01 +00:00
|
|
|
with the
|
|
|
|
[GLFW_TRANSPARENT_FRAMEBUFFER](@ref GLFW_TRANSPARENT_FRAMEBUFFER_attrib)
|
|
|
|
window attribute.
|
2017-09-18 16:10:57 +00:00
|
|
|
|
|
|
|
@code
|
2017-11-07 21:50:01 +00:00
|
|
|
if (glfwGetWindowAttrib(window, GLFW_TRANSPARENT_FRAMEBUFFER))
|
2017-09-18 16:10:57 +00:00
|
|
|
{
|
|
|
|
// window framebuffer is currently transparent
|
|
|
|
}
|
|
|
|
@endcode
|
|
|
|
|
2017-09-25 21:14:45 +00:00
|
|
|
GLFW comes with an example that enabled framebuffer transparency called `gears`.
|
|
|
|
|
|
|
|
The opacity of the whole window, including any decorations, can be set with @ref
|
|
|
|
glfwSetWindowOpacity.
|
|
|
|
|
|
|
|
@code
|
|
|
|
glfwSetWindowOpacity(window, 0.5f);
|
|
|
|
@endcode
|
|
|
|
|
|
|
|
The opacity (or alpha) value is a positive finite number between zero and one,
|
|
|
|
where 0 (zero) is fully transparent and 1 (one) is fully opaque. The initial
|
|
|
|
opacity value for newly created windows is 1.
|
|
|
|
|
|
|
|
The current opacity of a window can be queried with @ref glfwGetWindowOpacity.
|
|
|
|
|
|
|
|
@code
|
|
|
|
float opacity = glfwGetWindowOpacity(window);
|
|
|
|
@endcode
|
|
|
|
|
|
|
|
If the system does not support whole window transparency, this function always
|
|
|
|
returns one.
|
|
|
|
|
|
|
|
GLFW comes with a test program that lets you control whole window transparency
|
2020-07-08 17:30:16 +00:00
|
|
|
at run-time called `window`.
|
2017-09-25 21:14:45 +00:00
|
|
|
|
2020-07-08 21:21:28 +00:00
|
|
|
If you want to use either of these transparency methods to display a temporary
|
|
|
|
overlay like for example a notification, the @ref GLFW_FLOATING and @ref
|
|
|
|
GLFW_MOUSE_PASSTHROUGH window hints and attributes may be useful.
|
|
|
|
|
2017-09-18 16:10:57 +00:00
|
|
|
|
2015-01-18 00:55:25 +00:00
|
|
|
@subsection window_attribs Window attributes
|
2013-05-27 15:10:34 +00:00
|
|
|
|
|
|
|
Windows have a number of attributes that can be returned using @ref
|
2016-09-29 23:52:22 +00:00
|
|
|
glfwGetWindowAttrib. Some reflect state that may change as a result of user
|
|
|
|
interaction, (e.g. whether it has input focus), while others reflect inherent
|
|
|
|
properties of the window (e.g. what kind of border it has). Some are related to
|
|
|
|
the window and others to its OpenGL or OpenGL ES context.
|
2013-05-27 15:10:34 +00:00
|
|
|
|
|
|
|
@code
|
|
|
|
if (glfwGetWindowAttrib(window, GLFW_FOCUSED))
|
|
|
|
{
|
|
|
|
// window has input focus
|
|
|
|
}
|
|
|
|
@endcode
|
|
|
|
|
2016-09-29 23:52:22 +00:00
|
|
|
The [GLFW_DECORATED](@ref GLFW_DECORATED_attrib),
|
|
|
|
[GLFW_RESIZABLE](@ref GLFW_RESIZABLE_attrib),
|
2018-05-29 13:51:36 +00:00
|
|
|
[GLFW_FLOATING](@ref GLFW_FLOATING_attrib),
|
|
|
|
[GLFW_AUTO_ICONIFY](@ref GLFW_AUTO_ICONIFY_attrib) and
|
|
|
|
[GLFW_FOCUS_ON_SHOW](@ref GLFW_FOCUS_ON_SHOW_attrib) window attributes can be
|
2016-09-29 23:52:22 +00:00
|
|
|
changed with @ref glfwSetWindowAttrib.
|
|
|
|
|
|
|
|
@code
|
|
|
|
glfwSetWindowAttrib(window, GLFW_RESIZABLE, GLFW_FALSE);
|
|
|
|
@endcode
|
|
|
|
|
|
|
|
|
2013-05-27 15:10:34 +00:00
|
|
|
|
2015-01-18 00:55:25 +00:00
|
|
|
@subsubsection window_attribs_wnd Window related attributes
|
2013-05-27 15:10:34 +00:00
|
|
|
|
2016-12-06 00:14:23 +00:00
|
|
|
@anchor GLFW_FOCUSED_attrib
|
|
|
|
__GLFW_FOCUSED__ indicates whether the specified window has input focus. See
|
|
|
|
@ref window_focus for details.
|
2013-05-27 15:10:34 +00:00
|
|
|
|
2016-12-06 00:14:23 +00:00
|
|
|
@anchor GLFW_ICONIFIED_attrib
|
|
|
|
__GLFW_ICONIFIED__ indicates whether the specified window is iconified.
|
|
|
|
See @ref window_iconify for details.
|
2015-10-13 10:50:59 +00:00
|
|
|
|
2016-12-06 00:14:23 +00:00
|
|
|
@anchor GLFW_MAXIMIZED_attrib
|
|
|
|
__GLFW_MAXIMIZED__ indicates whether the specified window is maximized. See
|
|
|
|
@ref window_maximize for details.
|
2013-05-27 15:10:34 +00:00
|
|
|
|
2018-01-04 12:50:58 +00:00
|
|
|
@anchor GLFW_HOVERED_attrib
|
|
|
|
__GLFW_HOVERED__ indicates whether the cursor is currently directly over the
|
2019-01-22 19:54:16 +00:00
|
|
|
content area of the window, with no other windows between. See @ref
|
|
|
|
cursor_enter for details.
|
2018-01-04 12:50:58 +00:00
|
|
|
|
2016-12-06 00:14:23 +00:00
|
|
|
@anchor GLFW_VISIBLE_attrib
|
|
|
|
__GLFW_VISIBLE__ indicates whether the specified window is visible. See @ref
|
|
|
|
window_hide for details.
|
2013-05-27 15:10:34 +00:00
|
|
|
|
2016-12-06 00:14:23 +00:00
|
|
|
@anchor GLFW_RESIZABLE_attrib
|
|
|
|
__GLFW_RESIZABLE__ indicates whether the specified window is resizable _by the
|
2016-09-29 23:52:22 +00:00
|
|
|
user_. This can be set before creation with the
|
|
|
|
[GLFW_RESIZABLE](@ref GLFW_RESIZABLE_hint) window hint or after with @ref
|
|
|
|
glfwSetWindowAttrib.
|
2013-05-27 15:10:34 +00:00
|
|
|
|
2016-12-06 00:14:23 +00:00
|
|
|
@anchor GLFW_DECORATED_attrib
|
2016-09-29 23:52:22 +00:00
|
|
|
__GLFW_DECORATED__ indicates whether the specified window has decorations such
|
|
|
|
as a border, a close widget, etc. This can be set before creation with the
|
|
|
|
[GLFW_DECORATED](@ref GLFW_DECORATED_hint) window hint or after with @ref
|
|
|
|
glfwSetWindowAttrib.
|
|
|
|
|
|
|
|
@anchor GLFW_AUTO_ICONIFY_attrib
|
|
|
|
__GLFW_AUTO_ICONIFY__ indicates whether the specified full screen window is
|
|
|
|
iconified on focus loss, a close widget, etc. This can be set before creation
|
|
|
|
with the [GLFW_AUTO_ICONIFY](@ref GLFW_AUTO_ICONIFY_hint) window hint or after
|
|
|
|
with @ref glfwSetWindowAttrib.
|
2013-05-27 15:10:34 +00:00
|
|
|
|
2016-12-06 00:14:23 +00:00
|
|
|
@anchor GLFW_FLOATING_attrib
|
|
|
|
__GLFW_FLOATING__ indicates whether the specified window is floating, also
|
2016-09-29 23:52:22 +00:00
|
|
|
called topmost or always-on-top. This can be set before creation with the
|
|
|
|
[GLFW_FLOATING](@ref GLFW_FLOATING_hint) window hint or after with @ref
|
|
|
|
glfwSetWindowAttrib.
|
2014-05-23 12:01:02 +00:00
|
|
|
|
2017-11-07 21:50:01 +00:00
|
|
|
@anchor GLFW_TRANSPARENT_FRAMEBUFFER_attrib
|
|
|
|
__GLFW_TRANSPARENT_FRAMEBUFFER__ indicates whether the specified window has
|
|
|
|
a transparent framebuffer, i.e. the window contents is composited with the
|
|
|
|
background using the window framebuffer alpha channel. See @ref
|
|
|
|
window_transparency for details.
|
2017-09-18 16:10:57 +00:00
|
|
|
|
2018-05-29 13:51:36 +00:00
|
|
|
@anchor GLFW_FOCUS_ON_SHOW_attrib
|
|
|
|
__GLFW_FOCUS_ON_SHOW__ specifies whether the window will be given input
|
|
|
|
focus when @ref glfwShowWindow is called. This can be set before creation
|
|
|
|
with the [GLFW_FOCUS_ON_SHOW](@ref GLFW_FOCUS_ON_SHOW_hint) window hint or
|
|
|
|
after with @ref glfwSetWindowAttrib.
|
2013-05-27 15:10:34 +00:00
|
|
|
|
2020-07-08 21:21:28 +00:00
|
|
|
@anchor GLFW_MOUSE_PASSTHROUGH_attrib
|
|
|
|
__GLFW_MOUSE_PASSTHROUGH__ specifies whether the window is transparent to mouse
|
|
|
|
input, letting any mouse events pass through to whatever window is behind it.
|
|
|
|
This can be set before creation with the
|
|
|
|
[GLFW_MOUSE_PASSTHROUGH](@ref GLFW_MOUSE_PASSTHROUGH_hint) window hint or after
|
|
|
|
with @ref glfwSetWindowAttrib. This is only supported for undecorated windows.
|
|
|
|
Decorated windows with this enabled will behave differently between platforms.
|
|
|
|
|
|
|
|
|
2015-01-18 00:55:25 +00:00
|
|
|
@subsubsection window_attribs_ctx Context related attributes
|
2013-05-27 15:10:34 +00:00
|
|
|
|
2016-12-06 00:14:23 +00:00
|
|
|
@anchor GLFW_CLIENT_API_attrib
|
|
|
|
__GLFW_CLIENT_API__ indicates the client API provided by the window's context;
|
2015-11-05 12:44:15 +00:00
|
|
|
either `GLFW_OPENGL_API`, `GLFW_OPENGL_ES_API` or `GLFW_NO_API`.
|
2013-05-27 15:10:34 +00:00
|
|
|
|
2016-12-06 00:14:23 +00:00
|
|
|
@anchor GLFW_CONTEXT_CREATION_API_attrib
|
|
|
|
__GLFW_CONTEXT_CREATION_API__ indicates the context creation API used to create
|
2017-02-28 18:23:25 +00:00
|
|
|
the window's context; either `GLFW_NATIVE_CONTEXT_API`, `GLFW_EGL_CONTEXT_API`
|
|
|
|
or `GLFW_OSMESA_CONTEXT_API`.
|
2016-03-28 11:19:31 +00:00
|
|
|
|
2016-12-06 00:14:23 +00:00
|
|
|
@anchor GLFW_CONTEXT_VERSION_MAJOR_attrib
|
|
|
|
@anchor GLFW_CONTEXT_VERSION_MINOR_attrib
|
|
|
|
@anchor GLFW_CONTEXT_REVISION_attrib
|
|
|
|
__GLFW_CONTEXT_VERSION_MAJOR__, __GLFW_CONTEXT_VERSION_MINOR__ and
|
|
|
|
__GLFW_CONTEXT_REVISION__ indicate the client API version of the window's
|
|
|
|
context.
|
2013-05-27 15:10:34 +00:00
|
|
|
|
2017-05-05 17:05:00 +00:00
|
|
|
@note Do not confuse these attributes with `GLFW_VERSION_MAJOR`,
|
|
|
|
`GLFW_VERSION_MINOR` and `GLFW_VERSION_REVISION` which provide the API version
|
|
|
|
of the GLFW header.
|
|
|
|
|
2016-12-06 00:14:23 +00:00
|
|
|
@anchor GLFW_OPENGL_FORWARD_COMPAT_attrib
|
|
|
|
__GLFW_OPENGL_FORWARD_COMPAT__ is `GLFW_TRUE` if the window's context is an
|
|
|
|
OpenGL forward-compatible one, or `GLFW_FALSE` otherwise.
|
|
|
|
|
2020-06-26 16:35:48 +00:00
|
|
|
@anchor GLFW_CONTEXT_DEBUG_attrib
|
2016-12-06 00:14:23 +00:00
|
|
|
@anchor GLFW_OPENGL_DEBUG_CONTEXT_attrib
|
2020-06-26 16:35:48 +00:00
|
|
|
__GLFW_CONTEXT_DEBUG__ is `GLFW_TRUE` if the window's context is in debug
|
2020-06-28 17:21:36 +00:00
|
|
|
mode, or `GLFW_FALSE` otherwise.
|
2016-12-06 00:14:23 +00:00
|
|
|
|
2020-09-01 19:29:59 +00:00
|
|
|
@par
|
|
|
|
This is the new name, introduced in GLFW 3.4. The older
|
|
|
|
`GLFW_OPENGL_DEBUG_CONTEXT` name is also available for compatibility.
|
|
|
|
|
2016-12-06 00:14:23 +00:00
|
|
|
@anchor GLFW_OPENGL_PROFILE_attrib
|
|
|
|
__GLFW_OPENGL_PROFILE__ indicates the OpenGL profile used by the context. This
|
|
|
|
is `GLFW_OPENGL_CORE_PROFILE` or `GLFW_OPENGL_COMPAT_PROFILE` if the context
|
|
|
|
uses a known profile, or `GLFW_OPENGL_ANY_PROFILE` if the OpenGL profile is
|
|
|
|
unknown or the context is an OpenGL ES context. Note that the returned profile
|
|
|
|
may not match the profile bits of the context flags, as GLFW will try other
|
|
|
|
means of detecting the profile when no bits are set.
|
|
|
|
|
2019-05-19 19:41:57 +00:00
|
|
|
@anchor GLFW_CONTEXT_RELEASE_BEHAVIOR_attrib
|
|
|
|
__GLFW_CONTEXT_RELEASE_BEHAVIOR__ indicates the release used by the context.
|
|
|
|
Possible values are one of `GLFW_ANY_RELEASE_BEHAVIOR`,
|
|
|
|
`GLFW_RELEASE_BEHAVIOR_FLUSH` or `GLFW_RELEASE_BEHAVIOR_NONE`. If the
|
|
|
|
behavior is `GLFW_ANY_RELEASE_BEHAVIOR`, the default behavior of the context
|
|
|
|
creation API will be used. If the behavior is `GLFW_RELEASE_BEHAVIOR_FLUSH`,
|
|
|
|
the pipeline will be flushed whenever the context is released from being the
|
|
|
|
current one. If the behavior is `GLFW_RELEASE_BEHAVIOR_NONE`, the pipeline will
|
|
|
|
not be flushed on release.
|
|
|
|
|
|
|
|
@anchor GLFW_CONTEXT_NO_ERROR_attrib
|
|
|
|
__GLFW_CONTEXT_NO_ERROR__ indicates whether errors are generated by the context.
|
|
|
|
Possible values are `GLFW_TRUE` and `GLFW_FALSE`. If enabled, situations that
|
|
|
|
would have generated errors instead cause undefined behavior.
|
|
|
|
|
2016-12-06 00:14:23 +00:00
|
|
|
@anchor GLFW_CONTEXT_ROBUSTNESS_attrib
|
|
|
|
__GLFW_CONTEXT_ROBUSTNESS__ indicates the robustness strategy used by the
|
|
|
|
context. This is `GLFW_LOSE_CONTEXT_ON_RESET` or `GLFW_NO_RESET_NOTIFICATION`
|
|
|
|
if the window's context supports robustness, or `GLFW_NO_ROBUSTNESS` otherwise.
|
2013-05-27 15:10:34 +00:00
|
|
|
|
|
|
|
|
2015-03-29 12:18:49 +00:00
|
|
|
@subsubsection window_attribs_fb Framebuffer related attributes
|
|
|
|
|
2021-05-13 19:38:46 +00:00
|
|
|
GLFW does not expose most attributes of the default framebuffer (i.e. the
|
|
|
|
framebuffer attached to the window) as these can be queried directly with either
|
|
|
|
OpenGL, OpenGL ES or Vulkan. The one exception is
|
|
|
|
[GLFW_DOUBLEBUFFER](@ref GLFW_DOUBLEBUFFER_attrib), as this is not provided by
|
|
|
|
OpenGL ES.
|
2015-03-29 12:18:49 +00:00
|
|
|
|
|
|
|
If you are using version 3.0 or later of OpenGL or OpenGL ES, the
|
|
|
|
`glGetFramebufferAttachmentParameteriv` function can be used to retrieve the
|
|
|
|
number of bits for the red, green, blue, alpha, depth and stencil buffer
|
|
|
|
channels. Otherwise, the `glGetIntegerv` function can be used.
|
|
|
|
|
|
|
|
The number of MSAA samples are always retrieved with `glGetIntegerv`. For
|
|
|
|
contexts supporting framebuffer objects, the number of samples of the currently
|
|
|
|
bound framebuffer is returned.
|
|
|
|
|
|
|
|
Attribute | glGetIntegerv | glGetFramebufferAttachmentParameteriv
|
|
|
|
------------ | ----------------- | -------------------------------------
|
|
|
|
Red bits | `GL_RED_BITS` | `GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE`
|
|
|
|
Green bits | `GL_GREEN_BITS` | `GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE`
|
|
|
|
Blue bits | `GL_BLUE_BITS` | `GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE`
|
|
|
|
Alpha bits | `GL_ALPHA_BITS` | `GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE`
|
|
|
|
Depth bits | `GL_DEPTH_BITS` | `GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE`
|
|
|
|
Stencil bits | `GL_STENCIL_BITS` | `GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE`
|
|
|
|
MSAA samples | `GL_SAMPLES` | _Not provided by this function_
|
|
|
|
|
|
|
|
When calling `glGetFramebufferAttachmentParameteriv`, the red, green, blue and
|
2016-03-29 08:45:06 +00:00
|
|
|
alpha sizes are queried from the `GL_BACK_LEFT`, while the depth and stencil
|
|
|
|
sizes are queried from the `GL_DEPTH` and `GL_STENCIL` attachments,
|
2015-03-29 12:18:49 +00:00
|
|
|
respectively.
|
|
|
|
|
2021-05-13 19:38:46 +00:00
|
|
|
@anchor GLFW_DOUBLEBUFFER_attrib
|
|
|
|
__GLFW_DOUBLEBUFFER__ indicates whether the specified window is double-buffered
|
|
|
|
when rendering with OpenGL or OpenGL ES. This can be set before creation with
|
|
|
|
the [GLFW_DOUBLEBUFFER](@ref GLFW_DOUBLEBUFFER_hint) window hint.
|
|
|
|
|
2015-03-29 12:18:49 +00:00
|
|
|
|
2015-01-18 00:55:25 +00:00
|
|
|
@section buffer_swap Buffer swapping
|
2013-05-27 15:10:34 +00:00
|
|
|
|
2014-04-24 17:21:10 +00:00
|
|
|
GLFW windows are by default double buffered. That means that you have two
|
2013-05-27 15:10:34 +00:00
|
|
|
rendering buffers; a front buffer and a back buffer. The front buffer is
|
|
|
|
the one being displayed and the back buffer the one you render to.
|
|
|
|
|
|
|
|
When the entire frame has been rendered, it is time to swap the back and the
|
|
|
|
front buffers in order to display what has been rendered and begin rendering
|
|
|
|
a new frame. This is done with @ref glfwSwapBuffers.
|
|
|
|
|
|
|
|
@code
|
|
|
|
glfwSwapBuffers(window);
|
|
|
|
@endcode
|
2013-04-10 23:07:07 +00:00
|
|
|
|
2013-05-27 15:10:34 +00:00
|
|
|
Sometimes it can be useful to select when the buffer swap will occur. With the
|
|
|
|
function @ref glfwSwapInterval it is possible to select the minimum number of
|
2019-11-01 12:27:44 +00:00
|
|
|
monitor refreshes the driver should wait from the time @ref glfwSwapBuffers was
|
2014-09-18 13:03:29 +00:00
|
|
|
called before swapping the buffers:
|
2013-04-10 23:07:07 +00:00
|
|
|
|
2013-05-27 15:10:34 +00:00
|
|
|
@code
|
|
|
|
glfwSwapInterval(1);
|
|
|
|
@endcode
|
2013-04-10 23:07:07 +00:00
|
|
|
|
2013-05-27 15:10:34 +00:00
|
|
|
If the interval is zero, the swap will take place immediately when @ref
|
|
|
|
glfwSwapBuffers is called without waiting for a refresh. Otherwise at least
|
|
|
|
interval retraces will pass between each buffer swap. Using a swap interval of
|
|
|
|
zero can be useful for benchmarking purposes, when it is not desirable to
|
|
|
|
measure the time it takes to wait for the vertical retrace. However, a swap
|
|
|
|
interval of one lets you avoid tearing.
|
2013-04-10 23:07:07 +00:00
|
|
|
|
2013-11-24 22:31:15 +00:00
|
|
|
Note that this may not work on all machines, as some drivers have
|
|
|
|
user-controlled settings that override any swap interval the application
|
2015-05-21 12:48:11 +00:00
|
|
|
requests.
|
2013-04-10 23:07:07 +00:00
|
|
|
|
2017-11-27 00:18:51 +00:00
|
|
|
A context that supports either the `WGL_EXT_swap_control_tear` or the
|
|
|
|
`GLX_EXT_swap_control_tear` extension also accepts _negative_ swap intervals,
|
|
|
|
which allows the driver to swap immediately even if a frame arrives a little bit
|
|
|
|
late. This trades the risk of visible tears for greater framerate stability.
|
|
|
|
You can check for these extensions with @ref glfwExtensionSupported.
|
|
|
|
|
2013-04-10 23:07:07 +00:00
|
|
|
*/
|