text:
/*!

@page quick_guide Getting started

@tableofcontents

This guide takes you through writing a simple application using GLFW 3.  The
application will create a window and OpenGL context, render a rotating triangle
and exit when the user closes the window or presses _Escape_.  This guide will
introduce a few of the most commonly used functions, but there are many more.

This guide assumes no experience with earlier versions of GLFW.  If you
have used GLFW 2 in the past, read @ref moving_guide, as some functions
behave differently in GLFW 3.

@section quick_steps Step by step

@subsection quick_include Including the GLFW header

In the source files of your application where you use OpenGL or GLFW, you need
to include the GLFW 3 header file.

@code
#include <GLFW/glfw3.h>
@endcode

This defines all the constants, types and function prototypes of the GLFW API.
It also includes the OpenGL header from your development environment and
defines all the constants and types necessary for it to work on your platform
without including any platform-specific headers.

In other words:

- Do _not_ include the OpenGL header yourself, as GLFW does this for you in
  a platform-independent way
- Do _not_ include `windows.h` or other platform-specific headers unless
  you plan on using those APIs yourself
- If you _do_ need to include such headers, include them _before_ the GLFW
  header and it will detect this

On some platforms supported by GLFW the OpenGL header and link library only
expose older versions of OpenGL.  The most extreme case is Windows, which only
exposes OpenGL 1.2.  The easiest way to work around this is to use an
[extension loader library](@ref context_glext_auto).

If you are using such a library then you should include its header _before_ the
GLFW header.  This lets it replace the OpenGL header included by GLFW without
conflicts.  This example uses
[glad](https://github.com/Dav1dde/glad), but the same rule applies to all such
libraries.

@code
#include <glad/glad.h>
#include <GLFW/glfw3.h>
@endcode

@subsection quick_init_term Initializing and terminating GLFW

Before you can use most GLFW functions, the library must be initialized.  On
successful initialization, `GLFW_TRUE` is returned.  If an error occurred,
`GLFW_FALSE` is returned.

@code
if (!glfwInit())
{
    // Initialization failed
}
@endcode

Note that `GLFW_TRUE` and `GLFW_FALSE` are and will always be just one and zero.

When you are done using GLFW, typically just before the application exits, you
need to terminate GLFW.

@code
glfwTerminate();
@endcode

This destroys any remaining windows and releases any other resources allocated by
GLFW.  After this call, you must initialize GLFW again before using any GLFW
functions that require it.

@subsection quick_capture_error Setting an error callback

Most events are reported through callbacks, whether it's a key being pressed,
a GLFW window being moved, or an error occurring.  Callbacks are simply
C functions (or C++ static methods) that are called by GLFW with arguments
describing the event.

In case a GLFW function fails, an error is reported to the GLFW error callback.
You can receive these reports with an error callback.  This function must have
the signature below.  This simple error callback just prints the error
description to `stderr`.

@code
void error_callback(int error, const char* description)
{
    fprintf(stderr, "Error: %s\n", description);
}
@endcode

Callback functions must be set, so GLFW knows to call them.  The function to set
the error callback is one of the few GLFW functions that may be called before
initialization, which lets you be notified of errors both during and after
initialization.

@code
glfwSetErrorCallback(error_callback);
@endcode

@subsection quick_create_window Creating a window and context

The window and its OpenGL context are created with a single call to @ref
glfwCreateWindow, which returns a handle to the created combined window and
context object

@code
GLFWwindow* window = glfwCreateWindow(640, 480, "My Title", NULL, NULL);
if (!window)
{
    // Window or OpenGL context creation failed
}
@endcode

This creates a 640 by 480 windowed mode window with an OpenGL context.  If
window or OpenGL context creation fails, `NULL` will be returned.  You should
always check the return value.  While window creation rarely fails, context
creation depends on properly installed drivers and may fail even on machines
with the necessary hardware.

By default, the OpenGL context GLFW creates may have any version.  You can
require a minimum OpenGL version by setting the `GLFW_CONTEXT_VERSION_MAJOR` and
`GLFW_CONTEXT_VERSION_MINOR` hints _before_ creation.  If the required minimum
version is not supported on the machine, context (and window) creation fails.

@code
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
GLFWwindow* window = glfwCreateWindow(640, 480, "My Title", NULL, NULL);
if (!window)
{
    // Window or context creation failed
}
@endcode

The window handle is passed to all window related functions and is provided to
along to all window related callbacks, so they can tell which window received
the event.

When a window and context is no longer needed, destroy it.

@code
glfwDestroyWindow(window);
@endcode

Once this function is called, no more events will be delivered for that window
and its handle becomes invalid.

@subsection quick_context_current Making the OpenGL context current

Before you can use the OpenGL API, you must have a current OpenGL context.

@code
glfwMakeContextCurrent(window);
@endcode

The context will remain current until you make another context current or until
the window owning the current context is destroyed.

If you are using an [extension loader library](@ref context_glext_auto) to
access modern OpenGL then this is when to initialize it, as the loader needs
a current context to load from.  This example uses
[glad](https://github.com/Dav1dde/glad), but the same rule applies to all such
libraries.

@code
gladLoadGLLoader((GLADloadproc) glfwGetProcAddress);
@endcode

@subsection quick_window_close Checking the window close flag

Each window has a flag indicating whether the window should be closed.

When the user attempts to close the window, either by pressing the close widget
in the title bar or using a key combination like Alt+F4, this flag is set to 1.
Note that __the window isn't actually closed__, so you are expected to monitor
this flag and either destroy the window or give some kind of feedback to the
user.

@code
while (!glfwWindowShouldClose(window))
{
    // Keep running
}
@endcode

You can be notified when the user is attempting to close the window by setting
a close callback with @ref glfwSetWindowCloseCallback.  The callback will be
called immediately after the close flag has been set.

You can also set it yourself with @ref glfwSetWindowShouldClose.  This can be
useful if you want to interpret other kinds of input as closing the window, like
for example pressing the _Escape_ key.

@subsection quick_key_input Receiving input events

Each window has a large number of callbacks that can be set to receive all the
various kinds of events.  To receive key press and release events, create a key
callback function.

@code
static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
{
    if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS)
        glfwSetWindowShouldClose(window, GLFW_TRUE);
}
@endcode

The key callback, like other window related callbacks, are set per-window.

@code
glfwSetKeyCallback(window, key_callback);
@endcode

In order for event callbacks to be called when events occur, you need to process
events as described below.

@subsection quick_render Rendering with OpenGL

Once you have a current OpenGL context, you can use OpenGL normally.  In this
tutorial, a multi-colored rotating triangle will be rendered.  The framebuffer
size needs to be retrieved for `glViewport`.

@code
int width, height;
glfwGetFramebufferSize(window, &width, &height);
glViewport(0, 0, width, height);
@endcode

You can also set a framebuffer size callback using @ref
glfwSetFramebufferSizeCallback and be notified when the size changes.

Actual rendering with OpenGL is outside the scope of this tutorial, but there
are [many](https://open.gl/) [excellent](http://learnopengl.com/)
[tutorial](http://openglbook.com/) [sites](http://ogldev.atspace.co.uk/) that
teach modern OpenGL.  Some of them use GLFW to create the context and window
while others use GLUT or SDL, but remember that OpenGL itself always works the
same.

@subsection quick_timer Reading the timer

To create smooth animation, a time source is needed.  GLFW provides a timer that
returns the number of seconds since initialization.  The time source used is the
most accurate on each platform and generally has micro- or nanosecond
resolution.

@code
double time = glfwGetTime();
@endcode

@subsection quick_swap_buffers Swapping buffers

GLFW windows by default use double buffering.  That means that each window has
two 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, the buffers need to be swapped with one
another, so the back buffer becomes the front buffer and vice versa.

@code
glfwSwapBuffers(window);
@endcode

The swap interval indicates how many frames to wait until swapping the buffers,
commonly known as _vsync_.  By default, the swap interval is zero, meaning
buffer swapping will occur immediately.  On fast machines, many of those frames
will never be seen, as the screen is still only updated typically 60-75 times
per second, so this wastes a lot of CPU and GPU cycles.

Also, because the buffers will be swapped in the middle the screen update,
leading to [screen tearing](https://en.wikipedia.org/wiki/Screen_tearing).

For these reasons, applications will typically want to set the swap interval to
one.  It can be set to higher values, but this is usually not recommended,
because of the input latency it leads to.

@code
glfwSwapInterval(1);
@endcode

This function acts on the current context and will fail unless a context is
current.

@subsection quick_process_events Processing events

GLFW needs to communicate regularly with the window system both in order to
receive events and to show that the application hasn't locked up.  Event
processing must be done regularly while you have visible windows and is normally
done each frame after buffer swapping.

There are two methods for processing pending events; polling and waiting.  This
example will use event polling, which processes only those events that have
already been received and then returns immediately.

@code
glfwPollEvents();
@endcode

This is the best choice when rendering continually, like most games do.  If
instead you only need to update your rendering once you have received new input,
@ref glfwWaitEvents is a better choice.  It waits until at least one event has
been received, putting the thread to sleep in the meantime, and then processes
all received events.  This saves a great deal of CPU cycles and is useful for,
for example, many kinds of editing tools.

@section quick_example Putting it together

Now that you know how to initialize GLFW, create a window and poll for
keyboard input, it's possible to create a simple program.

This program creates a 640 by 480 windowed mode window and starts a loop that
clears the screen, renders a triangle and processes events until the user either
presses _Escape_ or closes the window.

@snippet simple.c code

The program above can be found in the
[source package](http://www.glfw.org/download.html) as `examples/simple.c`
and is compiled along with all other examples when you build GLFW.  If you
built GLFW from the source package then already have this as `simple.exe` on
Windows, `simple` on Linux or `simple.app` on OS X.

This tutorial used only a few of the many functions GLFW provides.  There are
guides for each of the areas covered by GLFW.  Each guide will introduce all the
functions for that category.

 - @ref intro_guide
 - @ref window_guide
 - @ref context_guide
 - @ref monitor_guide
 - @ref input_guide

You can access reference documentation for any GLFW function by clicking it and
the reference for each function links to related functions and guide sections.

The tutorial ends here.  Once you have written a program that uses GLFW, you
will need to compile and link it.  How to do that depends on the development
environment you are using and is best explained by the documentation for that
environment.  To learn about the details that are specific to GLFW, see
@ref build_guide.

*/


text:
/*!

@page window_guide Window guide

@tableofcontents

This guide introduces the window related functions of GLFW.  For details on
a specific function in this category, see the @ref window.  There are also
guides for the other areas of GLFW.

 - @ref intro_guide
 - @ref context_guide
 - @ref vulkan_guide
 - @ref monitor_guide
 - @ref input_guide

@section window_object Window objects

The @ref GLFWwindow object encapsulates both a window and a context.  They are
created with @ref glfwCreateWindow and destroyed with @ref glfwDestroyWindow, or
@ref glfwTerminate, if any remain.  As the window and context are inseparably
linked, the object pointer is used as both a context and window handle.

To see the event stream provided to the various window related callbacks, run
the `events` test program.

@subsection window_creation Window creation

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:

@code
GLFWwindow* window = glfwCreateWindow(640, 480, "My Title", NULL, NULL);
@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.

@subsubsection window_full_screen Full screen windows

To create a full screen window, you need to specify which monitor the window
should use.  In most cases, the user's primary monitor is a good choice.
For more information about retrieving monitors, see @ref monitor_monitors.

@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
or decorations.

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.

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
set for the chosen monitor as long as the window has input focus.  For more
information about retrieving video modes, see @ref monitor_modes.

Video mode field        | Corresponds to
----------------------- | ------------------------
GLFWvidmode.width       | `width` parameter
GLFWvidmode.height      | `height` parameter
GLFWvidmode.redBits     | `GLFW_RED_BITS` hint
GLFWvidmode.greenBits   | `GLFW_GREEN_BITS` hint
GLFWvidmode.blueBits    | `GLFW_BLUE_BITS` hint
GLFWvidmode.refreshRate | `GLFW_REFRESH_RATE` hint

Once you have a full screen window, you can change its resolution, refresh rate
and monitor with @ref glfwSetWindowMonitor.  If you just need change its
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
glfwCreateWindow.  If the window has an OpenGL or OpenGL ES context, it will be
unaffected.

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
the desktop.  This behavior can be disabled with the `GLFW_AUTO_ICONIFY` window
hint, for example if you wish to simultaneously cover multiple windows with full
screen windows.

@subsubsection window_windowed_full_screen "Windowed full screen" windows

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
such a window, simply request the current video mode.

@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

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.

@subsection window_destruction Window destruction

When a window is no longer needed, destroy it with @ref glfwDestroyWindow.

@code
glfwDestroyWindow(window);
@endcode

Window destruction always succeeds.  Before the actual destruction, all
callbacks are removed so no further events will be delivered for the window.
All windows remaining when @ref glfwTerminate is called are destroyed as well.

When a full screen window is destroyed, the original video mode of its monitor
is restored, but the gamma ramp is left untouched.

@subsection window_hints Window creation hints

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
initialized with @ref glfwInit, can be set individually with @ref glfwWindowHint
and reset all at once to their defaults with @ref glfwDefaultWindowHints.

Note that hints need to be set _before_ the creation of the window and context
you wish to have the specified attributes.

@subsubsection window_hints_hard Hard and soft constraints

Some window hints are hard constraints.  These must match the available
capabilities _exactly_ for window and context creation to succeed.  Hints
that are not hard constraints are matched as closely as possible, but the
resulting context and framebuffer may differ from what these hints requested.

The following hints are always hard constraints:
- `GLFW_STEREO`
- `GLFW_DOUBLEBUFFER`
- `GLFW_CLIENT_API`
- `GLFW_CONTEXT_CREATION_API`

The following additional hints are hard constraints when requesting an OpenGL
context, but are ignored when requesting an OpenGL ES context:
- `GLFW_OPENGL_FORWARD_COMPAT`
- `GLFW_OPENGL_PROFILE`

@subsubsection window_hints_wnd Window related hints

`GLFW_RESIZABLE` specifies whether the windowed mode window will be resizable
_by the user_.  The window will still be resizable using the @ref
glfwSetWindowSize function.  This hint is ignored for full screen windows.

`GLFW_VISIBLE` specifies whether the windowed mode window will be initially
visible.  This hint is ignored for full screen windows.

`GLFW_DECORATED` specifies whether the windowed mode window will have window
decorations such as a border, a close widget, etc.  An undecorated window may
still allow the user to generate close events on some platforms.  This hint is
ignored for full screen windows.

`GLFW_FOCUSED` specifies whether the windowed mode window will be given input
focus when created.  This hint is ignored for full screen and initially hidden
windows.

`GLFW_AUTO_ICONIFY` specifies whether the full screen window will
automatically iconify and restore the previous video mode on input focus loss.
This hint is ignored for windowed mode windows.

`GLFW_FLOATING` specifies whether the windowed mode window will be floating
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
full screen windows.  This hint is ignored for full screen windows.

`GLFW_MAXIMIZED` specifies whether the windowed mode window will be maximized
when created.  This hint is ignored for full screen windows.

@subsubsection window_hints_fb Framebuffer related hints

`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.  `GLFW_DONT_CARE` means the
application has no preference.

`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.  `GLFW_DONT_CARE` means the application has no
preference.

@par
Accumulation buffers are a legacy OpenGL feature and should not be used in new
code.

`GLFW_AUX_BUFFERS` specifies the desired number of auxiliary buffers.
`GLFW_DONT_CARE` means the application has no preference.

@par
Auxiliary buffers are a legacy OpenGL feature and should not be used in new
code.

`GLFW_STEREO` specifies whether to use stereoscopic rendering.  This is a hard
constraint.

`GLFW_SAMPLES` specifies the desired number of samples to use for multisampling.
Zero disables multisampling.  `GLFW_DONT_CARE` means the application has no
preference.

`GLFW_SRGB_CAPABLE` specifies whether the framebuffer should be sRGB capable.
If supported, a created OpenGL context will support the `GL_FRAMEBUFFER_SRGB`
enable, also called `GL_FRAMEBUFFER_SRGB_EXT`) for controlling sRGB rendering
and a created OpenGL ES context will always have sRGB rendering enabled.

`GLFW_DOUBLEBUFFER` specifies whether the framebuffer should be double buffered.
You nearly always want to use double buffering.  This is a hard constraint.

@subsubsection window_hints_mtr Monitor related hints

`GLFW_REFRESH_RATE` specifies the desired refresh rate for full screen windows.
If set to `GLFW_DONT_CARE`, the highest available refresh rate will be used.
This hint is ignored for windowed mode windows.

@subsubsection window_hints_ctx Context related hints

`GLFW_CLIENT_API` specifies which client API to create the context for.
Possible values are `GLFW_OPENGL_API`, `GLFW_OPENGL_ES_API` and `GLFW_NO_API`.
This is a hard constraint.

`GLFW_CONTEXT_CREATION_API` specifies which context creation API to use to
create the context.  Possible values are `GLFW_NATIVE_CONTEXT_API` and
`GLFW_EGL_CONTEXT_API`.  This is a hard constraint.  If no client API is
requested, this hint is ignored.

@par
__OS X:__ The EGL API is not available on this platform and requests to use it
will fail.

@par
__Wayland, Mir:__ The EGL API _is_ the native context creation API, so this hint
will have no effect.

@note An OpenGL extension loader library that assumes it knows which context
creation API is used on a given platform may fail if you change this hint.  This
can be resolved by having it load via @ref glfwGetProcAddress, which always uses
the selected API.

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

`GLFW_CONTEXT_VERSION_MAJOR` and `GLFW_CONTEXT_VERSION_MINOR` specify the client
API version that the created context must be compatible with.  The exact
behavior of these hints depend on the requested client API.

@par
__OpenGL:__ `GLFW_CONTEXT_VERSION_MAJOR` and `GLFW_CONTEXT_VERSION_MINOR` 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.

@par
While there is no way to ask the driver for a context of the highest supported
version, GLFW will attempt to provide this when you ask for a version 1.0
context, which is the default for these hints.

@par
__OpenGL ES:__ `GLFW_CONTEXT_VERSION_MAJOR` and `GLFW_CONTEXT_VERSION_MINOR` 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.

`GLFW_OPENGL_FORWARD_COMPAT` specifies whether the OpenGL context should be
forward-compatible, i.e. one where all functionality deprecated in the requested
version of OpenGL is removed.  This must only be used if the requested OpenGL
version is 3.0 or above.  If OpenGL ES is requested, this hint is ignored.

@par
Forward-compatibility is described in detail in the
[OpenGL Reference Manual](https://www.opengl.org/registry/).

`GLFW_OPENGL_DEBUG_CONTEXT` specifies whether to create a debug OpenGL context,
which may have additional error and performance issue reporting functionality.
If OpenGL ES is requested, this hint is ignored.

`GLFW_OPENGL_PROFILE` specifies which OpenGL profile to create the context for.
Possible values are one of `GLFW_OPENGL_CORE_PROFILE` or
`GLFW_OPENGL_COMPAT_PROFILE`, or `GLFW_OPENGL_ANY_PROFILE` to not request
a specific profile.  If requesting an OpenGL version below 3.2,
`GLFW_OPENGL_ANY_PROFILE` must be used.  If OpenGL ES is requested,
this hint is ignored.

@par
OpenGL profiles are described in detail in the
[OpenGL Reference Manual](https://www.opengl.org/registry/).

`GLFW_CONTEXT_ROBUSTNESS` specifies the robustness strategy to be used by the
context.  This can be one of `GLFW_NO_RESET_NOTIFICATION` or
`GLFW_LOSE_CONTEXT_ON_RESET`, or `GLFW_NO_ROBUSTNESS` to not request
a robustness strategy.

`GLFW_CONTEXT_RELEASE_BEHAVIOR` specifies the release behavior to be
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.

@par
Context release behaviors are described in detail by the
[GL_KHR_context_flush_control](https://www.opengl.org/registry/specs/KHR/context_flush_control.txt)
extension.

`GLFW_CONTEXT_NO_ERROR` specifies whether errors should be generated by the
context.  If enabled, situations that would have generated errors instead cause
undefined behavior.

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

@note This hint is experimental in its current state.  There are currently
(October 2015) no corresponding WGL or GLX extensions.  That makes this hint
a [hard constraint](@ref window_hints_hard) for those backends, as creation will
fail if unsupported context flags are requested.  Once the extensions are
available, they will be required and creation of `GL_KHR_no_error` contexts may
fail on early drivers where this flag is supported without those extensions
being listed.

@subsubsection window_hints_values Supported and default values

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`
`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`
`GLFW_CONTEXT_CREATION_API`     | `GLFW_NATIVE_CONTEXT_API`   | `GLFW_NATIVE_CONTEXT_API` or `GLFW_EGL_CONTEXT_API`
`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`
`GLFW_OPENGL_DEBUG_CONTEXT`     | `GLFW_FALSE`                | `GLFW_TRUE` or `GLFW_FALSE`
`GLFW_OPENGL_PROFILE`           | `GLFW_OPENGL_ANY_PROFILE`   | `GLFW_OPENGL_ANY_PROFILE`, `GLFW_OPENGL_COMPAT_PROFILE` or `GLFW_OPENGL_CORE_PROFILE`

@section window_events Window event processing

See @ref events.

@section window_properties Window properties and events

@subsection window_userptr User pointer

Each window has a user pointer that can be set with @ref
glfwSetWindowUserPointer and fetched with @ref glfwGetWindowUserPointer.  This
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`.

@subsection window_close Window closing and close flag

When the user attempts to close the window, for example by clicking the close
widget or using a key chord like Alt+F4, the _close flag_ of the window is set.
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

If you wish to be notified when the user attempts to close a window, set a close
callback.

@code
glfwSetWindowCloseCallback(window, window_close_callback);
@endcode

The callback function is called directly _after_ the close flag has been set.
It can be used for example to filter close requests and clear the close flag
again unless certain conditions are met.

@code
void window_close_callback(GLFWwindow* window)
{
    if (!time_to_close)
        glfwSetWindowShouldClose(window, GLFW_FALSE);
}
@endcode

@subsection window_size Window size

The size of a window can be changed with @ref glfwSetWindowSize.  For windowed
mode windows, this sets the size, in
[screen coordinates](@ref coordinate_systems) of the _client area_ or _content
area_ of the window.  The window system may impose limits on window size.

@code
glfwSetWindowSize(window, 640, 480);
@endcode

For full screen windows, the specified size becomes the new resolution of the
window's desired video mode.  The video mode most closely matching the new
desired video mode is set immediately.  The window is resized to fit the
resolution of the set video mode.

If you wish to be notified when a window is resized, whether by the user or
the system, set a size callback.

@code
glfwSetWindowSizeCallback(window, window_size_callback);
@endcode

The callback function receives the new size, in screen coordinates, of the
client area of the window when it is resized.

@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);
@endcode

@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
[framebuffer size](@ref window_fbsize), which is in pixels, for pixel-based
calls.

The above functions work with the size of the client area, but decorated windows
typically have title bars and window frames around this rectangle.  You can
retrieve the extents of these with @ref glfwGetWindowFrameSize.

@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
the client area to the corresponding edges of the full window.  As they are
distances and not coordinates, they are always zero or positive.

@subsection window_fbsize Framebuffer size

While the size of a window is measured in screen coordinates, OpenGL works with
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.

If you wish to be notified when the framebuffer of a window is resized, whether
by the user or the system, set a size callback.

@code
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
@endcode

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.

@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);
glViewport(0, 0, width, height);
@endcode

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.

@subsection window_sizelimits Window size limits

The minimum and maximum size of the client 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.

@code
glfwSetWindowSizeLimits(window, 200, 200, 400, 400);
@endcode

To specify only a minimum size or only a maximum one, set the other pair to
`GLFW_DONT_CARE`.

@code
glfwSetWindowSizeLimits(window, 640, 480, GLFW_DONT_CARE, GLFW_DONT_CARE);
@endcode

To disable size limits for a window, set them all to `GLFW_DONT_CARE`.

The aspect ratio of the client area of a windowed mode window can be enforced
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.

@code
glfwSetWindowAspectRatio(window, 16, 9);
@endcode

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
current aspect ratio, simply use its current size as the ratio.

@code
int width, height;
glfwGetWindowSize(window, &width, &height);
glfwSetWindowAspectRatio(window, width, height);
@endcode

To disable the aspect ratio limit for a window, set both terms to
`GLFW_DONT_CARE`.

You can have both size limits and aspect ratio set for a window, but the results
are undefined if they conflict.

@subsection window_pos Window position

The position of a windowed-mode window can be changed with @ref
glfwSetWindowPos.  This moves the window so that the upper-left corner of its
client area has the specified [screen coordinates](@ref coordinate_systems).
The window system may put limitations on window placement.

@code
glfwSetWindowPos(window, 100, 100);
@endcode

If you wish to be notified when a window is moved, whether by the user, system
or your own code, set a position callback.

@code
glfwSetWindowPosCallback(window, window_pos_callback);
@endcode

The callback function receives the new position of the upper-left corner of the
client area when the window is moved.

@code
void window_pos_callback(GLFWwindow* window, int xpos, int ypos)
{
}
@endcode

There is also @ref glfwGetWindowPos for directly retrieving the current position
of the client area of the window.

@code
int xpos, ypos;
glfwGetWindowPos(window, &xpos, &ypos);
@endcode

@subsection window_title Window title

All GLFW windows have a title, although undecorated or full screen windows may
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.

@code
glfwSetWindowTitle(window, "My Window");
@endcode

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
glfwSetWindowTitle(window, "カウボーイビバップ");
@endcode

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

@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

To revert to the default window icon, pass in an empty image array.

@code
glfwSetWindowIcon(window, 0, NULL);
@endcode

@subsection window_monitor Window monitor

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.

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.

@subsection window_iconify Window iconification

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.

Iconified windows can be restored with @ref glfwRestoreWindow.

@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
the user, system or your own code, set a iconify callback.

@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

You can also get the current iconification state with @ref glfwGetWindowAttrib.

@code
int iconified = glfwGetWindowAttrib(window, GLFW_ICONIFIED);
@endcode

@subsection window_hide Window visibility

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

Windowed mode windows can be created initially hidden with the `GLFW_VISIBLE`
[window hint](@ref window_hints_wnd).  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.

You can also get the current visibility state with @ref glfwGetWindowAttrib.

@code
int visible = glfwGetWindowAttrib(window, GLFW_VISIBLE);
@endcode

@subsection window_focus Window input focus

Windows can be given input focus and brought to the front with @ref
glfwFocusWindow.

@code
glfwFocusWindow(window);
@endcode

If you wish to be notified when a window gains or loses input focus, whether by
the user, system or your own code, set a focus callback.

@code
glfwSetWindowFocusCallback(window, window_focus_callback);
@endcode

The callback function receives changes in the input focus state of the window.

@code
void window_focus_callback(GLFWwindow* window, int focused)
{
    if (focused)
    {
        // The window gained input focus
    }
    else
    {
        // The window lost input focus
    }
}
@endcode

You can also get the current input focus state with @ref glfwGetWindowAttrib.

@code
int focused = glfwGetWindowAttrib(window, GLFW_FOCUSED);
@endcode

@subsection window_refresh Window damage and refresh

If you wish to be notified when the contents of a window is damaged and needs
to be refreshed, set a window refresh callback.

@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
window contents are saved off-screen, this callback might only be called when
the window or framebuffer is resized.

@subsection window_attribs Window attributes

Windows have a number of attributes that can be returned using @ref
glfwGetWindowAttrib.  Some reflect state that may change during the lifetime of
the window, while others reflect the corresponding hints and are fixed at the
time of creation.  Some are related to the actual window and others to its
context.

@code
if (glfwGetWindowAttrib(window, GLFW_FOCUSED))
{
    // window has input focus
}
@endcode

@subsubsection window_attribs_wnd Window related attributes

`GLFW_FOCUSED` indicates whether the specified window has input focus.  Initial
input focus is controlled by the [window hint](@ref window_hints_wnd) with the
same name.

`GLFW_ICONIFIED` indicates whether the specified window is iconified, whether by
the user or with @ref glfwIconifyWindow.

`GLFW_MAXIMIZED` indicates whether the specified window is maximized, whether by
the user or with @ref glfwMaximizeWindow.

`GLFW_VISIBLE` indicates whether the specified window is visible.  Window
visibility can be controlled with @ref glfwShowWindow and @ref glfwHideWindow
and initial visibility is controlled by the [window hint](@ref window_hints_wnd)
with the same name.

`GLFW_RESIZABLE` indicates whether the specified window is resizable _by the
user_.  This is set on creation with the [window hint](@ref window_hints_wnd)
  with the same name.

`GLFW_DECORATED` indicates whether the specified window has decorations such as
a border, a close widget, etc.  This is set on creation with the
[window hint](@ref window_hints_wnd) with the same name.

`GLFW_FLOATING` indicates whether the specified window is floating, also called
topmost or always-on-top.  This is controlled by the
[window hint](@ref window_hints_wnd) with the same name.

@subsubsection window_attribs_ctx Context related attributes

`GLFW_CLIENT_API` indicates the client API provided by the window's context;
either `GLFW_OPENGL_API`, `GLFW_OPENGL_ES_API` or `GLFW_NO_API`.

`GLFW_CONTEXT_CREATION_API` indicates the context creation API used to create
the window's context; either `GLFW_NATIVE_CONTEXT_API` or
`GLFW_EGL_CONTEXT_API`.

`GLFW_CONTEXT_VERSION_MAJOR`, `GLFW_CONTEXT_VERSION_MINOR` and
`GLFW_CONTEXT_REVISION` indicate the client API version of the window's context.

`GLFW_OPENGL_FORWARD_COMPAT` is `GLFW_TRUE` if the window's context is an OpenGL
forward-compatible one, or `GLFW_FALSE` otherwise.

`GLFW_OPENGL_DEBUG_CONTEXT` is `GLFW_TRUE` if the window's context is an OpenGL
debug context, or `GLFW_FALSE` otherwise.

`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.

`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.

@subsubsection window_attribs_fb Framebuffer related attributes

GLFW does not expose attributes of the default framebuffer (i.e. the framebuffer
attached to the window) as these can be queried directly with either OpenGL,
OpenGL ES or Vulkan.

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
alpha sizes are queried from the `GL_BACK_LEFT`, while the depth and stencil
sizes are queried from the `GL_DEPTH` and `GL_STENCIL` attachments,
respectively.

@section buffer_swap Buffer swapping

GLFW windows are by default double buffered.  That means that you have two
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

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
monitor refreshes the driver wait should from the time @ref glfwSwapBuffers was
called before swapping the buffers:

@code
glfwSwapInterval(1);
@endcode

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.

Note that this may not work on all machines, as some drivers have
user-controlled settings that override any swap interval the application
requests.

*/

repo_language: C

mime_type: text/x-c


text:
/*!

@page vulkan_guide Vulkan guide

@tableofcontents

This guide is intended to fill the gaps between the [Vulkan
documentation](https://www.khronos.org/vulkan/) and the rest of the GLFW
documentation and is not a replacement for either.  It assumes some familiarity
with Vulkan concepts like loaders, devices, queues and surfaces and leaves it to
the Vulkan documentation to explain the details of Vulkan functions.

To develop for Vulkan you should install an SDK for your platform, for example
the [LunarG Vulkan SDK](https://vulkan.lunarg.com/).  Apart from the headers and
libraries, it also provides the validation layers necessary for development.

The GLFW library does not need the Vulkan SDK to enable support for Vulkan.
However, any Vulkan-specific test and example programs are built only if the
CMake files find a Vulkan SDK.

For details on a specific function in this category, see the @ref vulkan.  There
are also guides for the other areas of the GLFW API.

 - @ref intro_guide
 - @ref window_guide
 - @ref context_guide
 - @ref monitor_guide
 - @ref input_guide

@section vulkan_include Including the Vulkan and GLFW header files

To include the Vulkan header, define [GLFW_INCLUDE_VULKAN](@ref build_macros)
before including the GLFW header.

@code
#define GLFW_INCLUDE_VULKAN
#include <GLFW/glfw3.h>
@endcode

If you instead want to include the Vulkan header from a custom location or use
your own custom Vulkan header then do this before the GLFW header.

@code
#include <path/to/vulkan.h>
#include <GLFW/glfw3.h>
@endcode

Unless a Vulkan header is included, either by the GLFW header or above it, any
GLFW functions that take or return Vulkan types will not be declared.

The `VK_USE_PLATFORM_*_KHR` macros do not need to be defined for the Vulkan part
of GLFW to work.  Define them only if you are using these extensions directly.

@section vulkan_support Querying for Vulkan support

If you are linking directly against the Vulkan loader then you can skip this
section.  The canonical desktop loader library exports all Vulkan core and
Khronos extension functions, allowing them to be called directly.

If you are loading the Vulkan loader dynamically instead of linking directly
against it, you can check for the availability of a loader with @ref
glfwVulkanSupported.

@code
if (glfwVulkanSupported())
{
    // Vulkan is available, at least for compute
}
@endcode

This function returns `GLFW_TRUE` if the Vulkan loader was found.  This check is
performed by @ref glfwInit.

If no loader was found, calling any other Vulkan related GLFW function will
generate a @ref GLFW_API_UNAVAILABLE error.

@subsection vulkan_proc Querying Vulkan function pointers

To load any Vulkan core or extension function from the found loader, call @ref
glfwGetInstanceProcAddress.  To load functions needed for instance creation,
pass `NULL` as the instance.

@code
PFN_vkCreateInstance pfnCreateInstance = (PFN_vkCreateInstance)
    glfwGetInstanceProcAddress(NULL, "vkCreateInstance");
@endcode

Once you have created an instance, you can load from it all other Vulkan core
functions and functions from any instance extensions you enabled.

@code
PFN_vkCreateDevice pfnCreateDevice = (PFN_vkCreateDevice)
    glfwGetInstanceProcAddress(instance, "vkCreateDevice");
@endcode

This function in turn calls `vkGetInstanceProcAddr`.  If that fails, the
function falls back to a platform-specific query of the Vulkan loader (i.e.
`dlsym` or `GetProcAddress`).  If that also fails, the function returns `NULL`.
For more information about `vkGetInstanceProcAddr`, see the Vulkan
documentation.

Vulkan also provides `vkGetDeviceProcAddr` for loading device-specific versions
of Vulkan function.  This function can be retrieved from an instance with @ref
glfwGetInstanceProcAddress.

@code
PFN_vkGetDeviceProcAddr pfnGetDeviceProcAddr = (PFN_vkGetDeviceProcAddr)
    glfwGetInstanceProcAddress(instance, "vkGetDeviceProcAddr");
@endcode

Device-specific functions may execute a little bit faster, due to not having to
dispatch internally based on the device passed to them.  For more information
about `vkGetDeviceProcAddr`, see the Vulkan documentation.

@section vulkan_ext Querying required Vulkan extensions

To do anything useful with Vulkan you need to create an instance.  If you want
to use Vulkan to render to a window, you must enable the instance extensions
GLFW requires to create Vulkan surfaces.

To query the instance extensions required, call @ref
glfwGetRequiredInstanceExtensions.

@code
uint32_t count;
const char** extensions = glfwGetRequiredInstanceExtensions(&count);
@endcode

These extensions must all be enabled when creating instances that are going to
be passed to @ref glfwGetPhysicalDevicePresentationSupport and @ref
glfwCreateWindowSurface.  The set of extensions will vary depending on platform
and may also vary depending on graphics drivers and other factors.

If it fails it will return `NULL` and GLFW will not be able to create Vulkan
window surfaces.  You can still use Vulkan for off-screen rendering and compute
work.

The returned array will always contain `VK_KHR_surface`, so if you don't
require any additional extensions you can pass this list directly to the
`VkInstanceCreateInfo` struct.

@code
VkInstanceCreateInfo ici;

memset(&ici, 0, sizeof(ici));
ici.enabledExtensionCount = count;
ici.ppEnabledExtensionNames = extensions;
...
@endcode

Additional extensions may be required by future versions of GLFW.  You should
check whether any extensions you wish to enable are already in the returned
array, as it is an error to specify an extension more than once in the
`VkInstanceCreateInfo` struct.

@section vulkan_present Querying for Vulkan presentation support

Not every queue family of every Vulkan device can present images to surfaces.
To check whether a specific queue family of a physical device supports image
presentation without first having to create a window and surface, call @ref
glfwGetPhysicalDevicePresentationSupport.

@code
if (glfwGetPhysicalDevicePresentationSupport(instance, physical_device, queue_family_index))
{
    // Queue family supports image presentation
}
@endcode

The `VK_KHR_surface` extension additionally provides the
`vkGetPhysicalDeviceSurfaceSupportKHR` function, which performs the same test on
an existing Vulkan surface.

@section vulkan_window Creating the window

Unless you will be using OpenGL or OpenGL ES with the same window as Vulkan,
there is no need to create a context.  You can disable context creation with the
[GLFW_CLIENT_API](@ref window_hints_ctx) hint.

@code
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
GLFWwindow* window = glfwCreateWindow(640, 480, "Window Title", NULL, NULL);
@endcode

See @ref context_less for more information.

@section vulkan_surface Creating a Vulkan window surface

You can create a Vulkan surface (as defined by the `VK_KHR_surface` extension)
for a GLFW window with @ref glfwCreateWindowSurface.

@code
VkSurfaceKHR surface;
VkResult err = glfwCreateWindowSurface(instance, window, NULL, &surface);
if (err)
{
    // Window surface creation failed
}
@endcode

It is your responsibility to destroy the surface.  GLFW does not destroy it for
you.  Call `vkDestroySurfaceKHR` function from the same extension to destroy it.

*/


text:
set(glfw_DOCS_SOURCES
    "${GLFW_SOURCE_DIR}/include/GLFW/glfw3.h"
    "${GLFW_SOURCE_DIR}/include/GLFW/glfw3native.h"
    "${GLFW_SOURCE_DIR}/docs/main.dox"
    "${GLFW_SOURCE_DIR}/docs/news.dox"
    "${GLFW_SOURCE_DIR}/docs/moving.dox"
    "${GLFW_SOURCE_DIR}/docs/quick.dox"
    "${GLFW_SOURCE_DIR}/docs/compile.dox"
    "${GLFW_SOURCE_DIR}/docs/build.dox"
    "${GLFW_SOURCE_DIR}/docs/intro.dox"
    "${GLFW_SOURCE_DIR}/docs/context.dox"
    "${GLFW_SOURCE_DIR}/docs/monitor.dox"
    "${GLFW_SOURCE_DIR}/docs/window.dox"
    "${GLFW_SOURCE_DIR}/docs/input.dox"
    "${GLFW_SOURCE_DIR}/docs/vulkan.dox"
    "${GLFW_SOURCE_DIR}/docs/compat.dox")

if (GLFW_DOCUMENT_INTERNALS)
    list(APPEND glfw_DOCS_SOURCES "${GLFW_SOURCE_DIR}/src/internal.h")
endif()

foreach(arg ${glfw_DOCS_SOURCES})
    set(GLFW_DOCS_SOURCES "${GLFW_DOCS_SOURCES} ${arg}")
endforeach()

configure_file(Doxyfile.in Doxyfile @ONLY)

add_custom_target(docs ALL "${DOXYGEN_EXECUTABLE}"
                  WORKING_DIRECTORY "${GLFW_BINARY_DIR}/docs"
                  COMMENT "Generating HTML documentation" VERBATIM)


text:
<doxygenlayout version="1.0">
  <!-- Generated by doxygen 1.8.3.1 -->
  <!-- Navigation index tabs for HTML output -->
  <navindex>
    <tab type="mainpage" visible="yes" title="Introduction"/>
    <tab type="pages" visible="yes" title="Guides" intro=""/>
    <tab type="modules" visible="yes" title="Reference" intro=""/>
    <tab type="namespaces" visible="yes" title="">
      <tab type="namespacelist" visible="yes" title="" intro=""/>
      <tab type="namespacemembers" visible="yes" title="" intro=""/>
    </tab>
    <tab type="classes" visible="no" title="">
      <tab type="classlist" visible="yes" title="" intro=""/>
      <tab type="classindex" visible="$ALPHABETICAL_INDEX" title=""/>
      <tab type="hierarchy" visible="yes" title="" intro=""/>
      <tab type="classmembers" visible="yes" title="" intro=""/>
    </tab>
    <tab type="files" visible="yes" title="Header Files">
      <tab type="filelist" visible="yes" title="" intro=""/>
      <tab type="globals" visible="yes" title="" intro=""/>
    </tab>
    <tab type="examples" visible="yes" title="" intro=""/>
  </navindex>

  <!-- Layout definition for a class page -->
  <class>
    <briefdescription visible="yes"/>
    <includes visible="$SHOW_INCLUDE_FILES"/>
    <inheritancegraph visible="$CLASS_GRAPH"/>
    <collaborationgraph visible="$COLLABORATION_GRAPH"/>
    <memberdecl>
      <nestedclasses visible="yes" title=""/>
      <publictypes title=""/>
      <publicslots title=""/>
      <signals title=""/>
      <publicmethods title=""/>
      <publicstaticmethods title=""/>
      <publicattributes title=""/>
      <publicstaticattributes title=""/>
      <protectedtypes title=""/>
      <protectedslots title=""/>
      <protectedmethods title=""/>
      <protectedstaticmethods title=""/>
      <protectedattributes title=""/>
      <protectedstaticattributes title=""/>
      <packagetypes title=""/>
      <packagemethods title=""/>
      <packagestaticmethods title=""/>
      <packageattributes title=""/>
      <packagestaticattributes title=""/>
      <properties title=""/>
      <events title=""/>
      <privatetypes title=""/>
      <privateslots title=""/>
      <privatemethods title=""/>
      <privatestaticmethods title=""/>
      <privateattributes title=""/>
      <privatestaticattributes title=""/>
      <friends title=""/>
      <related title="" subtitle=""/>
      <membergroups visible="yes"/>
    </memberdecl>
    <detaileddescription title=""/>
    <memberdef>
      <inlineclasses title=""/>
      <typedefs title=""/>
      <enums title=""/>
      <constructors title=""/>
      <functions title=""/>
      <related title=""/>
      <variables title=""/>
      <properties title=""/>
      <events title=""/>
    </memberdef>
    <allmemberslink visible="yes"/>
    <usedfiles visible="$SHOW_USED_FILES"/>
    <authorsection visible="yes"/>
  </class>

  <!-- Layout definition for a namespace page -->
  <namespace>
    <briefdescription visible="yes"/>
    <memberdecl>
      <nestednamespaces visible="yes" title=""/>
      <classes visible="yes" title=""/>
      <typedefs title=""/>
      <enums title=""/>
      <functions title=""/>
      <variables title=""/>
      <membergroups visible="yes"/>
    </memberdecl>
    <detaileddescription title=""/>
    <memberdef>
      <inlineclasses title=""/>
      <typedefs title=""/>
      <enums title=""/>
      <functions title=""/>
      <variables title=""/>
    </memberdef>
    <authorsection visible="yes"/>
  </namespace>

  <!-- Layout definition for a file page -->
  <file>
    <briefdescription visible="yes"/>
    <includes visible="$SHOW_INCLUDE_FILES"/>
    <includegraph visible="$INCLUDE_GRAPH"/>
    <includedbygraph visible="$INCLUDED_BY_GRAPH"/>
    <sourcelink visible="yes"/>
    <memberdecl>
      <classes visible="yes" title=""/>
      <namespaces visible="yes" title=""/>
      <defines title=""/>
      <typedefs title=""/>
      <enums title=""/>
      <functions title=""/>
      <variables title=""/>
      <membergroups visible="yes"/>
    </memberdecl>
    <detaileddescription title=""/>
    <memberdef>
      <inlineclasses title=""/>
      <defines title=""/>
      <typedefs title=""/>
      <enums title=""/>
      <functions title=""/>
      <variables title=""/>
    </memberdef>
    <authorsection/>
  </file>

  <!-- Layout definition for a group page -->
  <group>
    <briefdescription visible="yes"/>
    <detaileddescription title="Description"/>
    <groupgraph visible="$GROUP_GRAPHS"/>
    <memberdecl>
      <nestedgroups visible="yes" title=""/>
      <dirs visible="yes" title=""/>
      <files visible="yes" title=""/>
      <namespaces visible="yes" title=""/>
      <classes visible="yes" title=""/>
      <defines title=""/>
      <typedefs title=""/>
      <enums title=""/>
      <enumvalues title=""/>
      <functions title=""/>
      <variables title=""/>
      <signals title=""/>
      <publicslots title=""/>
      <protectedslots title=""/>
      <privateslots title=""/>
      <events title=""/>
      <properties title=""/>
      <friends title=""/>
      <membergroups visible="yes"/>
    </memberdecl>
    <memberdef>
      <pagedocs/>
      <inlineclasses title=""/>
      <defines title=""/>
      <typedefs title=""/>
      <enums title=""/>
      <enumvalues title=""/>
      <functions title=""/>
      <variables title=""/>
      <signals title=""/>
      <publicslots title=""/>
      <protectedslots title=""/>
      <privateslots title=""/>
      <events title=""/>
      <properties title=""/>
      <friends title=""/>
    </memberdef>
    <authorsection visible="yes"/>
  </group>

  <!-- Layout definition for a directory page -->
  <directory>
    <briefdescription visible="yes"/>
    <directorygraph visible="yes"/>
    <memberdecl>
      <dirs visible="yes"/>
      <files visible="yes"/>
    </memberdecl>
    <detaileddescription title=""/>
  </directory>
</doxygenlayout>