Add language tags for C code sections

This commit is contained in:
Camilla Löwy 2024-02-13 20:16:04 +01:00
parent d93868bcf3
commit fb10e95f78
9 changed files with 224 additions and 224 deletions

View File

@ -21,7 +21,7 @@ the documentation for your development environment.
You should include the GLFW header in the source files where you use OpenGL or You should include the GLFW header in the source files where you use OpenGL or
GLFW. GLFW.
@code @code{.c}
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
@endcode @endcode
@ -50,7 +50,7 @@ ES header or extension loader header included before it and will then disable
the inclusion of the default OpenGL header. Most extension loaders also define the inclusion of the default OpenGL header. Most extension loaders also define
macros that disable similar headers below it. macros that disable similar headers below it.
@code @code{.c}
#include <glad/gl.h> #include <glad/gl.h>
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
@endcode @endcode
@ -61,7 +61,7 @@ macro. If yours doesn't or you don't know which one your users will pick, the
including the OpenGL header. This will also allow you to include the two including the OpenGL header. This will also allow you to include the two
headers in any order. headers in any order.
@code @code{.c}
#define GLFW_INCLUDE_NONE #define GLFW_INCLUDE_NONE
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
#include <glad/gl.h> #include <glad/gl.h>

View File

@ -47,7 +47,7 @@ When creating a window and its OpenGL or OpenGL ES context with @ref
glfwCreateWindow, you can specify another window whose context the new one glfwCreateWindow, you can specify another window whose context the new one
should share its objects (textures, vertex and element buffers, etc.) with. should share its objects (textures, vertex and element buffers, etc.) with.
@code @code{.c}
GLFWwindow* second_window = glfwCreateWindow(640, 480, "Second Window", NULL, first_window); GLFWwindow* second_window = glfwCreateWindow(640, 480, "Second Window", NULL, first_window);
@endcode @endcode
@ -70,7 +70,7 @@ GLFW doesn't support creating contexts without an associated window. However,
contexts with hidden windows can be created with the contexts with hidden windows can be created with the
[GLFW_VISIBLE](@ref GLFW_VISIBLE_hint) window hint. [GLFW_VISIBLE](@ref GLFW_VISIBLE_hint) window hint.
@code @code{.c}
glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE); glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE);
GLFWwindow* offscreen_context = glfwCreateWindow(640, 480, "", NULL, NULL); GLFWwindow* offscreen_context = glfwCreateWindow(640, 480, "", NULL, NULL);
@ -105,13 +105,13 @@ thread before making it current on the new one.
The context of a window is made current with @ref glfwMakeContextCurrent. The context of a window is made current with @ref glfwMakeContextCurrent.
@code @code{.c}
glfwMakeContextCurrent(window); glfwMakeContextCurrent(window);
@endcode @endcode
The window of the current context is returned by @ref glfwGetCurrentContext. The window of the current context is returned by @ref glfwGetCurrentContext.
@code @code{.c}
GLFWwindow* window = glfwGetCurrentContext(); GLFWwindow* window = glfwGetCurrentContext();
@endcode @endcode
@ -185,14 +185,14 @@ include the glad header file, which will replace the OpenGL header of your
development environment. By including the glad header before the GLFW header, development environment. By including the glad header before the GLFW header,
it suppresses the development environment's OpenGL or OpenGL ES header. it suppresses the development environment's OpenGL or OpenGL ES header.
@code @code{.c}
#include <glad/glad.h> #include <glad/glad.h>
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
@endcode @endcode
Finally, you need to initialize glad once you have a suitable current context. Finally, you need to initialize glad once you have a suitable current context.
@code @code{.c}
window = glfwCreateWindow(640, 480, "My Window", NULL, NULL); window = glfwCreateWindow(640, 480, "My Window", NULL, NULL);
if (!window) if (!window)
{ {
@ -215,7 +215,7 @@ check the actual OpenGL or OpenGL ES version with
a specific version is supported by the current context with the a specific version is supported by the current context with the
`GLAD_GL_VERSION_x_x` booleans. `GLAD_GL_VERSION_x_x` booleans.
@code @code{.c}
if (GLAD_GL_VERSION_3_2) if (GLAD_GL_VERSION_3_2)
{ {
// Call OpenGL 3.2+ specific code // Call OpenGL 3.2+ specific code
@ -225,7 +225,7 @@ if (GLAD_GL_VERSION_3_2)
To check whether a specific extension is supported, use the `GLAD_GL_xxx` To check whether a specific extension is supported, use the `GLAD_GL_xxx`
booleans. booleans.
@code @code{.c}
if (GLAD_GL_ARB_gl_spirv) if (GLAD_GL_ARB_gl_spirv)
{ {
// Use GL_ARB_gl_spirv // Use GL_ARB_gl_spirv
@ -267,7 +267,7 @@ to function) and `PROC` (procedure) are added to the ends.
To include the extension header, define @ref GLFW_INCLUDE_GLEXT before including To include the extension header, define @ref GLFW_INCLUDE_GLEXT before including
the GLFW header. the GLFW header.
@code @code{.c}
#define GLFW_INCLUDE_GLEXT #define GLFW_INCLUDE_GLEXT
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
@endcode @endcode
@ -280,7 +280,7 @@ drivers or a graphics card that lacks the necessary hardware features), so it
is necessary to check at run-time whether the context supports the extension. is necessary to check at run-time whether the context supports the extension.
This is done with @ref glfwExtensionSupported. This is done with @ref glfwExtensionSupported.
@code @code{.c}
if (glfwExtensionSupported("GL_ARB_gl_spirv")) if (glfwExtensionSupported("GL_ARB_gl_spirv"))
{ {
// The extension is supported by the current context // The extension is supported by the current context
@ -299,7 +299,7 @@ These functions often do not have entry points in the client API libraries of
your operating system, making it necessary to fetch them at run time. You can your operating system, making it necessary to fetch them at run time. You can
retrieve pointers to these functions with @ref glfwGetProcAddress. retrieve pointers to these functions with @ref glfwGetProcAddress.
@code @code{.c}
PFNGLSPECIALIZESHADERARBPROC pfnSpecializeShaderARB = glfwGetProcAddress("glSpecializeShaderARB"); PFNGLSPECIALIZESHADERARBPROC pfnSpecializeShaderARB = glfwGetProcAddress("glSpecializeShaderARB");
@endcode @endcode
@ -310,7 +310,7 @@ use a different prefix, like above, or some other naming scheme.
Now that all the pieces have been introduced, here is what they might look like Now that all the pieces have been introduced, here is what they might look like
when used together. when used together.
@code @code{.c}
#define GLFW_INCLUDE_GLEXT #define GLFW_INCLUDE_GLEXT
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>

View File

@ -42,7 +42,7 @@ There are three functions for processing pending events. @ref glfwPollEvents,
processes only those events that have already been received and then returns processes only those events that have already been received and then returns
immediately. immediately.
@code @code{.c}
glfwPollEvents(); glfwPollEvents();
@endcode @endcode
@ -51,7 +51,7 @@ This is the best choice when rendering continuously, like most games do.
If you only need to update the contents of the window when you receive new If you only need to update the contents of the window when you receive new
input, @ref glfwWaitEvents is a better choice. input, @ref glfwWaitEvents is a better choice.
@code @code{.c}
glfwWaitEvents(); glfwWaitEvents();
@endcode @endcode
@ -62,7 +62,7 @@ useful for, for example, editing tools.
If you want to wait for events but have UI elements or other tasks that need If you want to wait for events but have UI elements or other tasks that need
periodic updates, @ref glfwWaitEventsTimeout lets you specify a timeout. periodic updates, @ref glfwWaitEventsTimeout lets you specify a timeout.
@code @code{.c}
glfwWaitEventsTimeout(0.7); glfwWaitEventsTimeout(0.7);
@endcode @endcode
@ -74,7 +74,7 @@ If the main thread is sleeping in @ref glfwWaitEvents, you can wake it from
another thread by posting an empty event to the event queue with @ref another thread by posting an empty event to the event queue with @ref
glfwPostEmptyEvent. glfwPostEmptyEvent.
@code @code{.c}
glfwPostEmptyEvent(); glfwPostEmptyEvent();
@endcode @endcode
@ -108,14 +108,14 @@ same keyboard layout, input method or even operating system as you.
If you wish to be notified when a physical key is pressed or released or when it If you wish to be notified when a physical key is pressed or released or when it
repeats, set a key callback. repeats, set a key callback.
@code @code{.c}
glfwSetKeyCallback(window, key_callback); glfwSetKeyCallback(window, key_callback);
@endcode @endcode
The callback function receives the [keyboard key](@ref keys), platform-specific The callback function receives the [keyboard key](@ref keys), platform-specific
scancode, key action and [modifier bits](@ref mods). scancode, key action and [modifier bits](@ref mods).
@code @code{.c}
void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
{ {
if (key == GLFW_KEY_E && action == GLFW_PRESS) if (key == GLFW_KEY_E && action == GLFW_PRESS)
@ -149,7 +149,7 @@ different scancodes depending on the platform but they are safe to save to disk.
You can query the scancode for any [key token](@ref keys) supported on the You can query the scancode for any [key token](@ref keys) supported on the
current platform with @ref glfwGetKeyScancode. current platform with @ref glfwGetKeyScancode.
@code @code{.c}
const int scancode = glfwGetKeyScancode(GLFW_KEY_X); const int scancode = glfwGetKeyScancode(GLFW_KEY_X);
set_key_mapping(scancode, swap_weapons); set_key_mapping(scancode, swap_weapons);
@endcode @endcode
@ -157,7 +157,7 @@ set_key_mapping(scancode, swap_weapons);
The last reported state for every physical key with a [key token](@ref keys) is The last reported state for every physical key with a [key token](@ref keys) is
also saved in per-window state arrays that can be polled with @ref glfwGetKey. also saved in per-window state arrays that can be polled with @ref glfwGetKey.
@code @code{.c}
int state = glfwGetKey(window, GLFW_KEY_E); int state = glfwGetKey(window, GLFW_KEY_E);
if (state == GLFW_PRESS) if (state == GLFW_PRESS)
{ {
@ -177,7 +177,7 @@ If a pressed key is released again before you poll its state, you will have
missed the key press. The recommended solution for this is to use a missed the key press. The recommended solution for this is to use a
key callback, but there is also the `GLFW_STICKY_KEYS` input mode. key callback, but there is also the `GLFW_STICKY_KEYS` input mode.
@code @code{.c}
glfwSetInputMode(window, GLFW_STICKY_KEYS, GLFW_TRUE); glfwSetInputMode(window, GLFW_STICKY_KEYS, GLFW_TRUE);
@endcode @endcode
@ -190,7 +190,7 @@ the state will reset to `GLFW_RELEASE`, otherwise it will remain `GLFW_PRESS`.
If you wish to know what the state of the Caps Lock and Num Lock keys was when If you wish to know what the state of the Caps Lock and Num Lock keys was when
input events were generated, set the `GLFW_LOCK_KEY_MODS` input mode. input events were generated, set the `GLFW_LOCK_KEY_MODS` input mode.
@code @code{.c}
glfwSetInputMode(window, GLFW_LOCK_KEY_MODS, GLFW_TRUE); glfwSetInputMode(window, GLFW_LOCK_KEY_MODS, GLFW_TRUE);
@endcode @endcode
@ -217,7 +217,7 @@ you can treat the code point argument as native endian UTF-32.
If you wish to offer regular text input, set a character callback. If you wish to offer regular text input, set a character callback.
@code @code{.c}
glfwSetCharCallback(window, character_callback); glfwSetCharCallback(window, character_callback);
@endcode @endcode
@ -225,7 +225,7 @@ The callback function receives Unicode code points for key events that would
have led to regular text input and generally behaves as a standard text field on have led to regular text input and generally behaves as a standard text field on
that platform. that platform.
@code @code{.c}
void character_callback(GLFWwindow* window, unsigned int codepoint) void character_callback(GLFWwindow* window, unsigned int codepoint)
{ {
} }
@ -237,7 +237,7 @@ void character_callback(GLFWwindow* window, unsigned int codepoint)
If you wish to refer to keys by name, you can query the keyboard layout If you wish to refer to keys by name, you can query the keyboard layout
dependent name of printable keys with @ref glfwGetKeyName. dependent name of printable keys with @ref glfwGetKeyName.
@code @code{.c}
const char* key_name = glfwGetKeyName(GLFW_KEY_W, 0); const char* key_name = glfwGetKeyName(GLFW_KEY_W, 0);
show_tutorial_hint("Press %s to move forward", key_name); show_tutorial_hint("Press %s to move forward", key_name);
@endcode @endcode
@ -260,7 +260,7 @@ a custom image or a standard cursor shape from the system theme.
If you wish to be notified when the cursor moves over the window, set a cursor If you wish to be notified when the cursor moves over the window, set a cursor
position callback. position callback.
@code @code{.c}
glfwSetCursorPosCallback(window, cursor_position_callback); glfwSetCursorPosCallback(window, cursor_position_callback);
@endcode @endcode
@ -268,7 +268,7 @@ The callback functions receives the cursor position, measured in screen
coordinates but relative to the top-left corner of the window content area. On coordinates but relative to the top-left corner of the window content area. On
platforms that provide it, the full sub-pixel cursor position is passed on. platforms that provide it, the full sub-pixel cursor position is passed on.
@code @code{.c}
static void cursor_position_callback(GLFWwindow* window, double xpos, double ypos) static void cursor_position_callback(GLFWwindow* window, double xpos, double ypos)
{ {
} }
@ -277,7 +277,7 @@ static void cursor_position_callback(GLFWwindow* window, double xpos, double ypo
The cursor position is also saved per-window and can be polled with @ref The cursor position is also saved per-window and can be polled with @ref
glfwGetCursorPos. glfwGetCursorPos.
@code @code{.c}
double xpos, ypos; double xpos, ypos;
glfwGetCursorPos(window, &xpos, &ypos); glfwGetCursorPos(window, &xpos, &ypos);
@endcode @endcode
@ -295,7 +295,7 @@ If you wish to implement mouse motion based camera controls or other input
schemes that require unlimited mouse movement, set the cursor mode to schemes that require unlimited mouse movement, set the cursor mode to
`GLFW_CURSOR_DISABLED`. `GLFW_CURSOR_DISABLED`.
@code @code{.c}
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED); glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED);
@endcode @endcode
@ -311,7 +311,7 @@ other features of GLFW. It is not supported and will not work as robustly as
If you only wish the cursor to become hidden when it is over a window but still If you only wish the cursor to become hidden when it is over a window but still
want it to behave normally, set the cursor mode to `GLFW_CURSOR_HIDDEN`. want it to behave normally, set the cursor mode to `GLFW_CURSOR_HIDDEN`.
@code @code{.c}
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_HIDDEN); glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_HIDDEN);
@endcode @endcode
@ -320,7 +320,7 @@ This mode puts no limit on the motion of the cursor.
If you wish the cursor to be visible but confined to the content area of the If you wish the cursor to be visible but confined to the content area of the
window, set the cursor mode to `GLFW_CURSOR_CAPTURED`. window, set the cursor mode to `GLFW_CURSOR_CAPTURED`.
@code @code{.c}
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_CAPTURED); glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_CAPTURED);
@endcode @endcode
@ -330,7 +330,7 @@ leave unless the window loses focus.
To exit out of either of these special modes, restore the `GLFW_CURSOR_NORMAL` To exit out of either of these special modes, restore the `GLFW_CURSOR_NORMAL`
cursor mode. cursor mode.
@code @code{.c}
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_NORMAL); glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_NORMAL);
@endcode @endcode
@ -353,7 +353,7 @@ Call @ref glfwRawMouseMotionSupported to check if the current machine provides
raw motion and set the `GLFW_RAW_MOUSE_MOTION` input mode to enable it. It is raw motion and set the `GLFW_RAW_MOUSE_MOTION` input mode to enable it. It is
disabled by default. disabled by default.
@code @code{.c}
if (glfwRawMouseMotionSupported()) if (glfwRawMouseMotionSupported())
glfwSetInputMode(window, GLFW_RAW_MOUSE_MOTION, GLFW_TRUE); glfwSetInputMode(window, GLFW_RAW_MOUSE_MOTION, GLFW_TRUE);
@endcode @endcode
@ -376,7 +376,7 @@ A custom cursor is created with @ref glfwCreateCursor, which returns a handle to
the created cursor object. For example, this creates a 16x16 white square the created cursor object. For example, this creates a 16x16 white square
cursor with the hot-spot in the upper-left corner: cursor with the hot-spot in the upper-left corner:
@code @code{.c}
unsigned char pixels[16 * 16 * 4]; unsigned char pixels[16 * 16 * 4];
memset(pixels, 0xff, sizeof(pixels)); memset(pixels, 0xff, sizeof(pixels));
@ -401,7 +401,7 @@ sequential rows, starting from the top-left corner.
A cursor with a [standard shape](@ref shapes) from the current system cursor A cursor with a [standard shape](@ref shapes) from the current system cursor
theme can be created with @ref glfwCreateStandardCursor. theme can be created with @ref glfwCreateStandardCursor.
@code @code{.c}
GLFWcursor* url_cursor = glfwCreateStandardCursor(GLFW_POINTING_HAND_CURSOR); GLFWcursor* url_cursor = glfwCreateStandardCursor(GLFW_POINTING_HAND_CURSOR);
@endcode @endcode
@ -416,7 +416,7 @@ A few of these shapes are not available everywhere. If a shape is unavailable,
When a cursor is no longer needed, destroy it with @ref glfwDestroyCursor. When a cursor is no longer needed, destroy it with @ref glfwDestroyCursor.
@code @code{.c}
glfwDestroyCursor(cursor); glfwDestroyCursor(cursor);
@endcode @endcode
@ -429,7 +429,7 @@ mode. All remaining cursors are destroyed when @ref glfwTerminate is called.
A cursor can be set as current for a window with @ref glfwSetCursor. A cursor can be set as current for a window with @ref glfwSetCursor.
@code @code{.c}
glfwSetCursor(window, cursor); glfwSetCursor(window, cursor);
@endcode @endcode
@ -441,7 +441,7 @@ A single cursor may be set for any number of windows.
To revert to the default cursor, set the cursor of that window to `NULL`. To revert to the default cursor, set the cursor of that window to `NULL`.
@code @code{.c}
glfwSetCursor(window, NULL); glfwSetCursor(window, NULL);
@endcode @endcode
@ -454,13 +454,13 @@ default cursor. This does not affect the cursor mode.
If you wish to be notified when the cursor enters or leaves the content area of If you wish to be notified when the cursor enters or leaves the content area of
a window, set a cursor enter/leave callback. a window, set a cursor enter/leave callback.
@code @code{.c}
glfwSetCursorEnterCallback(window, cursor_enter_callback); glfwSetCursorEnterCallback(window, cursor_enter_callback);
@endcode @endcode
The callback function receives the new classification of the cursor. The callback function receives the new classification of the cursor.
@code @code{.c}
void cursor_enter_callback(GLFWwindow* window, int entered) void cursor_enter_callback(GLFWwindow* window, int entered)
{ {
if (entered) if (entered)
@ -477,7 +477,7 @@ void cursor_enter_callback(GLFWwindow* window, int entered)
You can query whether the cursor is currently inside the content area of the You can query whether the cursor is currently inside the content area of the
window with the [GLFW_HOVERED](@ref GLFW_HOVERED_attrib) window attribute. window with the [GLFW_HOVERED](@ref GLFW_HOVERED_attrib) window attribute.
@code @code{.c}
if (glfwGetWindowAttrib(window, GLFW_HOVERED)) if (glfwGetWindowAttrib(window, GLFW_HOVERED))
{ {
highlight_interface(); highlight_interface();
@ -490,14 +490,14 @@ if (glfwGetWindowAttrib(window, GLFW_HOVERED))
If you wish to be notified when a mouse button is pressed or released, set If you wish to be notified when a mouse button is pressed or released, set
a mouse button callback. a mouse button callback.
@code @code{.c}
glfwSetMouseButtonCallback(window, mouse_button_callback); glfwSetMouseButtonCallback(window, mouse_button_callback);
@endcode @endcode
The callback function receives the [mouse button](@ref buttons), button action The callback function receives the [mouse button](@ref buttons), button action
and [modifier bits](@ref mods). and [modifier bits](@ref mods).
@code @code{.c}
void mouse_button_callback(GLFWwindow* window, int button, int action, int mods) void mouse_button_callback(GLFWwindow* window, int button, int action, int mods)
{ {
if (button == GLFW_MOUSE_BUTTON_RIGHT && action == GLFW_PRESS) if (button == GLFW_MOUSE_BUTTON_RIGHT && action == GLFW_PRESS)
@ -511,7 +511,7 @@ The last reported state for every [supported mouse button](@ref buttons) is also
saved in per-window state arrays that can be polled with @ref saved in per-window state arrays that can be polled with @ref
glfwGetMouseButton. glfwGetMouseButton.
@code @code{.c}
int state = glfwGetMouseButton(window, GLFW_MOUSE_BUTTON_LEFT); int state = glfwGetMouseButton(window, GLFW_MOUSE_BUTTON_LEFT);
if (state == GLFW_PRESS) if (state == GLFW_PRESS)
{ {
@ -531,7 +531,7 @@ missed the button press. The recommended solution for this is to use a
mouse button callback, but there is also the `GLFW_STICKY_MOUSE_BUTTONS` mouse button callback, but there is also the `GLFW_STICKY_MOUSE_BUTTONS`
input mode. input mode.
@code @code{.c}
glfwSetInputMode(window, GLFW_STICKY_MOUSE_BUTTONS, GLFW_TRUE); glfwSetInputMode(window, GLFW_STICKY_MOUSE_BUTTONS, GLFW_TRUE);
@endcode @endcode
@ -550,13 +550,13 @@ The `GLFW_MOUSE_BUTTON_LAST` constant holds the highest value of any
If you wish to be notified when the user scrolls, whether with a mouse wheel or If you wish to be notified when the user scrolls, whether with a mouse wheel or
touchpad gesture, set a scroll callback. touchpad gesture, set a scroll callback.
@code @code{.c}
glfwSetScrollCallback(window, scroll_callback); glfwSetScrollCallback(window, scroll_callback);
@endcode @endcode
The callback function receives two-dimensional scroll offsets. The callback function receives two-dimensional scroll offsets.
@code @code{.c}
void scroll_callback(GLFWwindow* window, double xoffset, double yoffset) void scroll_callback(GLFWwindow* window, double xoffset, double yoffset)
{ {
} }
@ -573,7 +573,7 @@ referred to as joysticks. It supports up to sixteen joysticks, ranging from
`GLFW_JOYSTICK_LAST`. You can test whether a [joystick](@ref joysticks) is `GLFW_JOYSTICK_LAST`. You can test whether a [joystick](@ref joysticks) is
present with @ref glfwJoystickPresent. present with @ref glfwJoystickPresent.
@code @code{.c}
int present = glfwJoystickPresent(GLFW_JOYSTICK_1); int present = glfwJoystickPresent(GLFW_JOYSTICK_1);
@endcode @endcode
@ -601,7 +601,7 @@ The positions of all axes of a joystick are returned by @ref
glfwGetJoystickAxes. See the reference documentation for the lifetime of the glfwGetJoystickAxes. See the reference documentation for the lifetime of the
returned array. returned array.
@code @code{.c}
int count; int count;
const float* axes = glfwGetJoystickAxes(GLFW_JOYSTICK_5, &count); const float* axes = glfwGetJoystickAxes(GLFW_JOYSTICK_5, &count);
@endcode @endcode
@ -615,7 +615,7 @@ The states of all buttons of a joystick are returned by @ref
glfwGetJoystickButtons. See the reference documentation for the lifetime of the glfwGetJoystickButtons. See the reference documentation for the lifetime of the
returned array. returned array.
@code @code{.c}
int count; int count;
const unsigned char* buttons = glfwGetJoystickButtons(GLFW_JOYSTICK_3, &count); const unsigned char* buttons = glfwGetJoystickButtons(GLFW_JOYSTICK_3, &count);
@endcode @endcode
@ -632,7 +632,7 @@ the reference documentation for @ref glfwGetJoystickButtons for details.
The states of all hats are returned by @ref glfwGetJoystickHats. See the The states of all hats are returned by @ref glfwGetJoystickHats. See the
reference documentation for the lifetime of the returned array. reference documentation for the lifetime of the returned array.
@code @code{.c}
int count; int count;
const unsigned char* hats = glfwGetJoystickHats(GLFW_JOYSTICK_7, &count); const unsigned char* hats = glfwGetJoystickHats(GLFW_JOYSTICK_7, &count);
@endcode @endcode
@ -655,7 +655,7 @@ The diagonal directions are bitwise combinations of the primary (up, right, down
and left) directions and you can test for these individually by ANDing it with and left) directions and you can test for these individually by ANDing it with
the corresponding direction. the corresponding direction.
@code @code{.c}
if (hats[2] & GLFW_HAT_RIGHT) if (hats[2] & GLFW_HAT_RIGHT)
{ {
// State of hat 2 could be right-up, right or right-down // State of hat 2 could be right-up, right or right-down
@ -673,7 +673,7 @@ The human-readable, UTF-8 encoded name of a joystick is returned by @ref
glfwGetJoystickName. See the reference documentation for the lifetime of the glfwGetJoystickName. See the reference documentation for the lifetime of the
returned string. returned string.
@code @code{.c}
const char* name = glfwGetJoystickName(GLFW_JOYSTICK_4); const char* name = glfwGetJoystickName(GLFW_JOYSTICK_4);
@endcode @endcode
@ -698,14 +698,14 @@ The initial value of the pointer is `NULL`.
If you wish to be notified when a joystick is connected or disconnected, set If you wish to be notified when a joystick is connected or disconnected, set
a joystick callback. a joystick callback.
@code @code{.c}
glfwSetJoystickCallback(joystick_callback); glfwSetJoystickCallback(joystick_callback);
@endcode @endcode
The callback function receives the ID of the joystick that has been connected The callback function receives the ID of the joystick that has been connected
and disconnected and the event that occurred. and disconnected and the event that occurred.
@code @code{.c}
void joystick_callback(int jid, int event) void joystick_callback(int jid, int event)
{ {
if (event == GLFW_CONNECTED) if (event == GLFW_CONNECTED)
@ -748,7 +748,7 @@ a joystick is connected or the mappings are updated.
You can check whether a joystick is both present and has a gamepad mapping with You can check whether a joystick is both present and has a gamepad mapping with
@ref glfwJoystickIsGamepad. @ref glfwJoystickIsGamepad.
@code @code{.c}
if (glfwJoystickIsGamepad(GLFW_JOYSTICK_2)) if (glfwJoystickIsGamepad(GLFW_JOYSTICK_2))
{ {
// Use as gamepad // Use as gamepad
@ -762,13 +762,13 @@ You can query the human-readable name provided by the gamepad mapping with @ref
glfwGetGamepadName. This may or may not be the same as the glfwGetGamepadName. This may or may not be the same as the
[joystick name](@ref joystick_name). [joystick name](@ref joystick_name).
@code @code{.c}
const char* name = glfwGetGamepadName(GLFW_JOYSTICK_7); const char* name = glfwGetGamepadName(GLFW_JOYSTICK_7);
@endcode @endcode
To retrieve the gamepad state of a joystick, call @ref glfwGetGamepadState. To retrieve the gamepad state of a joystick, call @ref glfwGetGamepadState.
@code @code{.c}
GLFWgamepadstate state; GLFWgamepadstate state;
if (glfwGetGamepadState(GLFW_JOYSTICK_3, &state)) if (glfwGetGamepadState(GLFW_JOYSTICK_3, &state))
@ -818,7 +818,7 @@ GLFW contains a copy of the mappings available in
time of release. Newer ones can be added at runtime with @ref time of release. Newer ones can be added at runtime with @ref
glfwUpdateGamepadMappings. glfwUpdateGamepadMappings.
@code @code{.c}
const char* mappings = load_file_contents("game/data/gamecontrollerdb.txt"); const char* mappings = load_file_contents("game/data/gamecontrollerdb.txt");
glfwUpdateGamepadMappings(mappings); glfwUpdateGamepadMappings(mappings);
@ -898,7 +898,7 @@ and described above.
GLFW provides high-resolution time input, in seconds, with @ref glfwGetTime. GLFW provides high-resolution time input, in seconds, with @ref glfwGetTime.
@code @code{.c}
double seconds = glfwGetTime(); double seconds = glfwGetTime();
@endcode @endcode
@ -908,7 +908,7 @@ nanosecond resolution.
You can modify the base time with @ref glfwSetTime. You can modify the base time with @ref glfwSetTime.
@code @code{.c}
glfwSetTime(4.0); glfwSetTime(4.0);
@endcode @endcode
@ -918,7 +918,7 @@ from there.
You can also access the raw timer used to implement the functions above, You can also access the raw timer used to implement the functions above,
with @ref glfwGetTimerValue. with @ref glfwGetTimerValue.
@code @code{.c}
uint64_t value = glfwGetTimerValue(); uint64_t value = glfwGetTimerValue();
@endcode @endcode
@ -926,7 +926,7 @@ This value is in 1&nbsp;/&nbsp;frequency seconds. The frequency of the raw
timer varies depending on the operating system and hardware. You can query the timer varies depending on the operating system and hardware. You can query the
frequency, in Hz, with @ref glfwGetTimerFrequency. frequency, in Hz, with @ref glfwGetTimerFrequency.
@code @code{.c}
uint64_t frequency = glfwGetTimerFrequency(); uint64_t frequency = glfwGetTimerFrequency();
@endcode @endcode
@ -937,7 +937,7 @@ If the system clipboard contains a UTF-8 encoded string or if it can be
converted to one, you can retrieve it with @ref glfwGetClipboardString. See the converted to one, you can retrieve it with @ref glfwGetClipboardString. See the
reference documentation for the lifetime of the returned string. reference documentation for the lifetime of the returned string.
@code @code{.c}
const char* text = glfwGetClipboardString(NULL); const char* text = glfwGetClipboardString(NULL);
if (text) if (text)
{ {
@ -951,7 +951,7 @@ returned.
The contents of the system clipboard can be set to a UTF-8 encoded string with The contents of the system clipboard can be set to a UTF-8 encoded string with
@ref glfwSetClipboardString. @ref glfwSetClipboardString.
@code @code{.c}
glfwSetClipboardString(NULL, "A string with words in it"); glfwSetClipboardString(NULL, "A string with words in it");
@endcode @endcode
@ -961,13 +961,13 @@ glfwSetClipboardString(NULL, "A string with words in it");
If you wish to receive the paths of files and/or directories dropped on If you wish to receive the paths of files and/or directories dropped on
a window, set a file drop callback. a window, set a file drop callback.
@code @code{.c}
glfwSetDropCallback(window, drop_callback); glfwSetDropCallback(window, drop_callback);
@endcode @endcode
The callback function receives an array of paths encoded as UTF-8. The callback function receives an array of paths encoded as UTF-8.
@code @code{.c}
void drop_callback(GLFWwindow* window, int count, const char** paths) void drop_callback(GLFWwindow* window, int count, const char** paths)
{ {
int i; int i;

View File

@ -48,7 +48,7 @@ GLFW_NOT_INITIALIZED error.
The library is initialized with @ref glfwInit, which returns `GLFW_FALSE` if an The library is initialized with @ref glfwInit, which returns `GLFW_FALSE` if an
error occurred. error occurred.
@code @code{.c}
if (!glfwInit()) if (!glfwInit())
{ {
// Handle initialization failure // Handle initialization failure
@ -76,7 +76,7 @@ hint.
Initialization hints are set before @ref glfwInit and affect how the library Initialization hints are set before @ref glfwInit and affect how the library
behaves until termination. Hints are set with @ref glfwInitHint. behaves until termination. Hints are set with @ref glfwInitHint.
@code @code{.c}
glfwInitHint(GLFW_JOYSTICK_HAT_BUTTONS, GLFW_FALSE); glfwInitHint(GLFW_JOYSTICK_HAT_BUTTONS, GLFW_FALSE);
@endcode @endcode
@ -176,7 +176,7 @@ default, this is set to @ref GLFW_ANY_PLATFORM, which will look for supported wi
systems in order of priority and select the first one it finds. It can also be set to any systems in order of priority and select the first one it finds. It can also be set to any
specific platform to have GLFW only look for that one. specific platform to have GLFW only look for that one.
@code @code{.c}
glfwInitHint(GLFW_PLATFORM, GLFW_PLATFORM_X11); glfwInitHint(GLFW_PLATFORM, GLFW_PLATFORM_X11);
@endcode @endcode
@ -184,14 +184,14 @@ This mechanism also provides the Null platform, which is always supported but ne
explicitly requested. This platform is effectively a stub, emulating a window system on explicitly requested. This platform is effectively a stub, emulating a window system on
a single 1080p monitor, but will not interact with any actual window system. a single 1080p monitor, but will not interact with any actual window system.
@code @code{.c}
glfwInitHint(GLFW_PLATFORM, GLFW_PLATFORM_NULL); glfwInitHint(GLFW_PLATFORM, GLFW_PLATFORM_NULL);
@endcode @endcode
You can test whether a library binary was compiled with support for a specific platform You can test whether a library binary was compiled with support for a specific platform
with @ref glfwPlatformSupported. with @ref glfwPlatformSupported.
@code @code{.c}
if (glfwPlatformSupported(GLFW_PLATFORM_WAYLAND)) if (glfwPlatformSupported(GLFW_PLATFORM_WAYLAND))
glfwInitHint(GLFW_PLATFORM, GLFW_PLATFORM_WAYLAND); glfwInitHint(GLFW_PLATFORM, GLFW_PLATFORM_WAYLAND);
@endcode @endcode
@ -199,7 +199,7 @@ if (glfwPlatformSupported(GLFW_PLATFORM_WAYLAND))
Once GLFW has been initialized, you can query which platform was selected with @ref Once GLFW has been initialized, you can query which platform was selected with @ref
glfwGetPlatform. glfwGetPlatform.
@code @code{.c}
int platform = glfwGetPlatform(); int platform = glfwGetPlatform();
@endcode @endcode
@ -213,7 +213,7 @@ selected platform.
The heap memory allocator can be customized before initialization with @ref The heap memory allocator can be customized before initialization with @ref
glfwInitAllocator. glfwInitAllocator.
@code @code{.c}
GLFWallocator allocator; GLFWallocator allocator;
allocator.allocate = my_malloc; allocator.allocate = my_malloc;
allocator.reallocate = my_realloc; allocator.reallocate = my_realloc;
@ -235,7 +235,7 @@ The allocation function must have a signature matching @ref GLFWallocatefun. It
the desired size, in bytes, and the user pointer passed to @ref glfwInitAllocator and the desired size, in bytes, and the user pointer passed to @ref glfwInitAllocator and
returns the address to the allocated memory block. returns the address to the allocated memory block.
@code @code{.c}
void* my_malloc(size_t size, void* user) void* my_malloc(size_t size, void* user)
{ {
... ...
@ -250,7 +250,7 @@ It receives the memory block to be reallocated, the new desired size, in bytes,
pointer passed to @ref glfwInitAllocator and returns the address to the resized memory pointer passed to @ref glfwInitAllocator and returns the address to the resized memory
block. block.
@code @code{.c}
void* my_realloc(void* block, size_t size, void* user) void* my_realloc(void* block, size_t size, void* user)
{ {
... ...
@ -264,7 +264,7 @@ The deallocation function must have a function signature matching @ref GLFWdeall
It receives the memory block to be deallocated and the user pointer passed to @ref It receives the memory block to be deallocated and the user pointer passed to @ref
glfwInitAllocator. glfwInitAllocator.
@code @code{.c}
void my_free(void* block, void* user) void my_free(void* block, void* user)
{ {
... ...
@ -280,7 +280,7 @@ for a deallocation function. If the active one does not meet all of these, GLFW
Before your application exits, you should terminate the GLFW library if it has Before your application exits, you should terminate the GLFW library if it has
been initialized. This is done with @ref glfwTerminate. been initialized. This is done with @ref glfwTerminate.
@code @code{.c}
glfwTerminate(); glfwTerminate();
@endcode @endcode
@ -305,7 +305,7 @@ values.
The last [error code](@ref errors) for the calling thread can be queried at any The last [error code](@ref errors) for the calling thread can be queried at any
time with @ref glfwGetError. time with @ref glfwGetError.
@code @code{.c}
int code = glfwGetError(NULL); int code = glfwGetError(NULL);
if (code != GLFW_NO_ERROR) if (code != GLFW_NO_ERROR)
@ -324,7 +324,7 @@ can retrieve a UTF-8 encoded human-readable description along with the error
code. If no error has occurred since the last call, the description is set to code. If no error has occurred since the last call, the description is set to
`NULL`. `NULL`.
@code @code{.c}
const char* description; const char* description;
int code = glfwGetError(&description); int code = glfwGetError(&description);
@ -338,14 +338,14 @@ This means you must make a copy of it if you want to keep it.
You can also set an error callback, which will be called each time an error You can also set an error callback, which will be called each time an error
occurs. It is set with @ref glfwSetErrorCallback. occurs. It is set with @ref glfwSetErrorCallback.
@code @code{.c}
glfwSetErrorCallback(error_callback); glfwSetErrorCallback(error_callback);
@endcode @endcode
The error callback receives the same error code and human-readable description The error callback receives the same error code and human-readable description
returned by @ref glfwGetError. returned by @ref glfwGetError.
@code @code{.c}
void error_callback(int code, const char* description) void error_callback(int code, const char* description)
{ {
display_error_message(code, description); display_error_message(code, description);
@ -572,7 +572,7 @@ this to verify that the library binary is compatible with your application.
The compile-time version of GLFW is provided by the GLFW header with the The compile-time version of GLFW is provided by the GLFW header with the
`GLFW_VERSION_MAJOR`, `GLFW_VERSION_MINOR` and `GLFW_VERSION_REVISION` macros. `GLFW_VERSION_MAJOR`, `GLFW_VERSION_MINOR` and `GLFW_VERSION_REVISION` macros.
@code @code{.c}
printf("Compiled against GLFW %i.%i.%i\n", printf("Compiled against GLFW %i.%i.%i\n",
GLFW_VERSION_MAJOR, GLFW_VERSION_MAJOR,
GLFW_VERSION_MINOR, GLFW_VERSION_MINOR,
@ -585,7 +585,7 @@ printf("Compiled against GLFW %i.%i.%i\n",
The run-time version can be retrieved with @ref glfwGetVersion, a function that The run-time version can be retrieved with @ref glfwGetVersion, a function that
may be called regardless of whether GLFW is initialized. may be called regardless of whether GLFW is initialized.
@code @code{.c}
int major, minor, revision; int major, minor, revision;
glfwGetVersion(&major, &minor, &revision); glfwGetVersion(&major, &minor, &revision);
@ -624,14 +624,14 @@ The format of the string is as follows:
For example, compiling GLFW 3.4 with MinGW as a DLL for Windows, may result in a version string For example, compiling GLFW 3.4 with MinGW as a DLL for Windows, may result in a version string
like this: like this:
@code @code{.c}
3.4.0 Win32 WGL Null EGL OSMesa MinGW DLL 3.4.0 Win32 WGL Null EGL OSMesa MinGW DLL
@endcode @endcode
Compiling GLFW as a static library for Linux, with both Wayland and X11 enabled, may Compiling GLFW as a static library for Linux, with both Wayland and X11 enabled, may
result in a version string like this: result in a version string like this:
@code @code{.c}
3.4.0 Wayland X11 GLX Null EGL OSMesa monotonic 3.4.0 Wayland X11 GLX Null EGL OSMesa monotonic
@endcode @endcode

View File

@ -42,14 +42,14 @@ The primary monitor is returned by @ref glfwGetPrimaryMonitor. It is the user's
preferred monitor and is usually the one with global UI elements like task bar preferred monitor and is usually the one with global UI elements like task bar
or menu bar. or menu bar.
@code @code{.c}
GLFWmonitor* primary = glfwGetPrimaryMonitor(); GLFWmonitor* primary = glfwGetPrimaryMonitor();
@endcode @endcode
You can retrieve all currently connected monitors with @ref glfwGetMonitors. You can retrieve all currently connected monitors with @ref glfwGetMonitors.
See the reference documentation for the lifetime of the returned array. See the reference documentation for the lifetime of the returned array.
@code @code{.c}
int count; int count;
GLFWmonitor** monitors = glfwGetMonitors(&count); GLFWmonitor** monitors = glfwGetMonitors(&count);
@endcode @endcode
@ -64,14 +64,14 @@ disconnected.
If you wish to be notified when a monitor is connected or disconnected, set If you wish to be notified when a monitor is connected or disconnected, set
a monitor callback. a monitor callback.
@code @code{.c}
glfwSetMonitorCallback(monitor_callback); glfwSetMonitorCallback(monitor_callback);
@endcode @endcode
The callback function receives the handle for the monitor that has been The callback function receives the handle for the monitor that has been
connected or disconnected and the event that occurred. connected or disconnected and the event that occurred.
@code @code{.c}
void monitor_callback(GLFWmonitor* monitor, int event) void monitor_callback(GLFWmonitor* monitor, int event)
{ {
if (event == GLFW_CONNECTED) if (event == GLFW_CONNECTED)
@ -109,7 +109,7 @@ Video modes are represented as @ref GLFWvidmode structures. You can get an
array of the video modes supported by a monitor with @ref glfwGetVideoModes. array of the video modes supported by a monitor with @ref glfwGetVideoModes.
See the reference documentation for the lifetime of the returned array. See the reference documentation for the lifetime of the returned array.
@code @code{.c}
int count; int count;
GLFWvidmode* modes = glfwGetVideoModes(monitor, &count); GLFWvidmode* modes = glfwGetVideoModes(monitor, &count);
@endcode @endcode
@ -117,7 +117,7 @@ GLFWvidmode* modes = glfwGetVideoModes(monitor, &count);
To get the current video mode of a monitor call @ref glfwGetVideoMode. See the To get the current video mode of a monitor call @ref glfwGetVideoMode. See the
reference documentation for the lifetime of the returned pointer. reference documentation for the lifetime of the returned pointer.
@code @code{.c}
const GLFWvidmode* mode = glfwGetVideoMode(monitor); const GLFWvidmode* mode = glfwGetVideoMode(monitor);
@endcode @endcode
@ -132,7 +132,7 @@ retrieved with @ref glfwGetMonitorPhysicalSize. This has no relation to its
current _resolution_, i.e. the width and height of its current current _resolution_, i.e. the width and height of its current
[video mode](@ref monitor_modes). [video mode](@ref monitor_modes).
@code @code{.c}
int width_mm, height_mm; int width_mm, height_mm;
glfwGetMonitorPhysicalSize(monitor, &width_mm, &height_mm); glfwGetMonitorPhysicalSize(monitor, &width_mm, &height_mm);
@endcode @endcode
@ -147,7 +147,7 @@ useful. Instead, use the [monitor content scale](@ref monitor_scale) and
The content scale for a monitor can be retrieved with @ref The content scale for a monitor can be retrieved with @ref
glfwGetMonitorContentScale. glfwGetMonitorContentScale.
@code @code{.c}
float xscale, yscale; float xscale, yscale;
glfwGetMonitorContentScale(monitor, &xscale, &yscale); glfwGetMonitorContentScale(monitor, &xscale, &yscale);
@endcode @endcode
@ -170,7 +170,7 @@ The position of the monitor on the virtual desktop, in
[screen coordinates](@ref coordinate_systems), can be retrieved with @ref [screen coordinates](@ref coordinate_systems), can be retrieved with @ref
glfwGetMonitorPos. glfwGetMonitorPos.
@code @code{.c}
int xpos, ypos; int xpos, ypos;
glfwGetMonitorPos(monitor, &xpos, &ypos); glfwGetMonitorPos(monitor, &xpos, &ypos);
@endcode @endcode
@ -182,7 +182,7 @@ The area of a monitor not occupied by global task bars or menu bars is the work
area. This is specified in [screen coordinates](@ref coordinate_systems) and area. This is specified in [screen coordinates](@ref coordinate_systems) and
can be retrieved with @ref glfwGetMonitorWorkarea. can be retrieved with @ref glfwGetMonitorWorkarea.
@code @code{.c}
int xpos, ypos, width, height; int xpos, ypos, width, height;
glfwGetMonitorWorkarea(monitor, &xpos, &ypos, &width, &height); glfwGetMonitorWorkarea(monitor, &xpos, &ypos, &width, &height);
@endcode @endcode
@ -194,7 +194,7 @@ The human-readable, UTF-8 encoded name of a monitor is returned by @ref
glfwGetMonitorName. See the reference documentation for the lifetime of the glfwGetMonitorName. See the reference documentation for the lifetime of the
returned string. returned string.
@code @code{.c}
const char* name = glfwGetMonitorName(monitor); const char* name = glfwGetMonitorName(monitor);
@endcode @endcode
@ -219,7 +219,7 @@ The initial value of the pointer is `NULL`.
The gamma ramp of a monitor can be set with @ref glfwSetGammaRamp, which accepts The gamma ramp of a monitor can be set with @ref glfwSetGammaRamp, which accepts
a monitor handle and a pointer to a @ref GLFWgammaramp structure. a monitor handle and a pointer to a @ref GLFWgammaramp structure.
@code @code{.c}
GLFWgammaramp ramp; GLFWgammaramp ramp;
unsigned short red[256], green[256], blue[256]; unsigned short red[256], green[256], blue[256];
@ -245,7 +245,7 @@ ramp for that monitor.
The current gamma ramp for a monitor is returned by @ref glfwGetGammaRamp. See The current gamma ramp for a monitor is returned by @ref glfwGetGammaRamp. See
the reference documentation for the lifetime of the returned structure. the reference documentation for the lifetime of the returned structure.
@code @code{.c}
const GLFWgammaramp* ramp = glfwGetGammaRamp(monitor); const GLFWgammaramp* ramp = glfwGetGammaRamp(monitor);
@endcode @endcode
@ -253,7 +253,7 @@ If you wish to set a regular gamma ramp, you can have GLFW calculate it for you
from the desired exponent with @ref glfwSetGamma, which in turn calls @ref from the desired exponent with @ref glfwSetGamma, which in turn calls @ref
glfwSetGammaRamp with the resulting ramp. glfwSetGammaRamp with the resulting ramp.
@code @code{.c}
glfwSetGamma(monitor, 1.0); glfwSetGamma(monitor, 1.0);
@endcode @endcode

View File

@ -22,12 +22,12 @@ Unix-like systems, where it uses the
[soname](https://en.wikipedia.org/wiki/soname) `libglfw.so.3`. [soname](https://en.wikipedia.org/wiki/soname) `libglfw.so.3`.
@par Old syntax @par Old syntax
@code @code{.c}
#include <GL/glfw.h> #include <GL/glfw.h>
@endcode @endcode
@par New syntax @par New syntax
@code @code{.c}
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
@endcode @endcode
@ -95,12 +95,12 @@ the creation of DLLs and DLL link libraries, as there's no need to explicitly
disable `@n` entry point suffixes. disable `@n` entry point suffixes.
@par Old syntax @par Old syntax
@code @code{.c}
void GLFWCALL callback_function(...); void GLFWCALL callback_function(...);
@endcode @endcode
@par New syntax @par New syntax
@code @code{.c}
void callback_function(...); void callback_function(...);
@endcode @endcode
@ -114,12 +114,12 @@ a newly created window is returned by @ref glfwCreateWindow (formerly
[opaque](https://en.wikipedia.org/wiki/Opaque_data_type) type @ref GLFWwindow. [opaque](https://en.wikipedia.org/wiki/Opaque_data_type) type @ref GLFWwindow.
@par Old syntax @par Old syntax
@code @code{.c}
glfwSetWindowTitle("New Window Title"); glfwSetWindowTitle("New Window Title");
@endcode @endcode
@par New syntax @par New syntax
@code @code{.c}
glfwSetWindowTitle(window, "New Window Title"); glfwSetWindowTitle(window, "New Window Title");
@endcode @endcode
@ -134,12 +134,12 @@ GLFW 2 would have selected, but there are many other
[opaque](https://en.wikipedia.org/wiki/Opaque_data_type) type @ref GLFWmonitor. [opaque](https://en.wikipedia.org/wiki/Opaque_data_type) type @ref GLFWmonitor.
@par Old basic full screen @par Old basic full screen
@code @code{.c}
glfwOpenWindow(640, 480, 8, 8, 8, 0, 24, 0, GLFW_FULLSCREEN); glfwOpenWindow(640, 480, 8, 8, 8, 0, 24, 0, GLFW_FULLSCREEN);
@endcode @endcode
@par New basic full screen @par New basic full screen
@code @code{.c}
window = glfwCreateWindow(640, 480, "My Window", glfwGetPrimaryMonitor(), NULL); window = glfwCreateWindow(640, 480, "My Window", glfwGetPrimaryMonitor(), NULL);
@endcode @endcode
@ -156,7 +156,7 @@ buffer swap, which acts on a single window, the event processing functions act
on all windows at once. on all windows at once.
@par Old basic main loop @par Old basic main loop
@code @code{.c}
while (...) while (...)
{ {
// Process input // Process input
@ -166,7 +166,7 @@ while (...)
@endcode @endcode
@par New basic main loop @par New basic main loop
@code @code{.c}
while (...) while (...)
{ {
// Process input // Process input
@ -198,13 +198,13 @@ glfwGetFramebufferSize function. A framebuffer size callback has also been
added, which can be set with @ref glfwSetFramebufferSizeCallback. added, which can be set with @ref glfwSetFramebufferSizeCallback.
@par Old basic viewport setup @par Old basic viewport setup
@code @code{.c}
glfwGetWindowSize(&width, &height); glfwGetWindowSize(&width, &height);
glViewport(0, 0, width, height); glViewport(0, 0, width, height);
@endcode @endcode
@par New basic viewport setup @par New basic viewport setup
@code @code{.c}
glfwGetFramebufferSize(window, &width, &height); glfwGetFramebufferSize(window, &width, &height);
glViewport(0, 0, width, height); glViewport(0, 0, width, height);
@endcode @endcode
@ -227,7 +227,7 @@ You can query the close flag at any time with @ref glfwWindowShouldClose and set
it at any time with @ref glfwSetWindowShouldClose. it at any time with @ref glfwSetWindowShouldClose.
@par Old basic main loop @par Old basic main loop
@code @code{.c}
while (glfwGetWindowParam(GLFW_OPENED)) while (glfwGetWindowParam(GLFW_OPENED))
{ {
... ...
@ -235,7 +235,7 @@ while (glfwGetWindowParam(GLFW_OPENED))
@endcode @endcode
@par New basic main loop @par New basic main loop
@code @code{.c}
while (!glfwWindowShouldClose(window)) while (!glfwWindowShouldClose(window))
{ {
... ...
@ -248,12 +248,12 @@ event processing completes. You may however not call @ref glfwDestroyWindow
from the close callback (or any other window related callback). from the close callback (or any other window related callback).
@par Old syntax @par Old syntax
@code @code{.c}
int GLFWCALL window_close_callback(void); int GLFWCALL window_close_callback(void);
@endcode @endcode
@par New syntax @par New syntax
@code @code{.c}
void window_close_callback(GLFWwindow* window); void window_close_callback(GLFWwindow* window);
@endcode @endcode
@ -289,12 +289,12 @@ produce characters with diacritical marks. Even the Swedish keyboard layout
requires this for uncommon cases like ü. requires this for uncommon cases like ü.
@par Old syntax @par Old syntax
@code @code{.c}
void GLFWCALL character_callback(int character, int action); void GLFWCALL character_callback(int character, int action);
@endcode @endcode
@par New syntax @par New syntax
@code @code{.c}
void character_callback(GLFWwindow* window, int character); void character_callback(GLFWwindow* window, int character);
@endcode @endcode
@ -324,12 +324,12 @@ two-dimensional floating point scroll offsets. This allows you to receive
precise scroll data from for example modern touchpads. precise scroll data from for example modern touchpads.
@par Old syntax @par Old syntax
@code @code{.c}
void GLFWCALL mouse_wheel_callback(int position); void GLFWCALL mouse_wheel_callback(int position);
@endcode @endcode
@par New syntax @par New syntax
@code @code{.c}
void scroll_callback(GLFWwindow* window, double xoffset, double yoffset); void scroll_callback(GLFWwindow* window, double xoffset, double yoffset);
@endcode @endcode
@ -437,12 +437,12 @@ has been moved to GLFW 3, you can request that the GLFW header includes it by
defining @ref GLFW_INCLUDE_GLU before the inclusion of the GLFW header. defining @ref GLFW_INCLUDE_GLU before the inclusion of the GLFW header.
@par Old syntax @par Old syntax
@code @code{.c}
#include <GL/glfw.h> #include <GL/glfw.h>
@endcode @endcode
@par New syntax @par New syntax
@code @code{.c}
#define GLFW_INCLUDE_GLU #define GLFW_INCLUDE_GLU
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
@endcode @endcode

View File

@ -21,7 +21,7 @@ behave differently in GLFW 3.
In the source files of your application where you use GLFW, you need to include In the source files of your application where you use GLFW, you need to include
its header file. its header file.
@code @code{.c}
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
@endcode @endcode
@ -38,7 +38,7 @@ This example uses files generated by [glad](https://gen.glad.sh/). The GLFW
header can detect most such headers if they are included first and will then not header can detect most such headers if they are included first and will then not
include the one from your development environment. include the one from your development environment.
@code @code{.c}
#include <glad/gl.h> #include <glad/gl.h>
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
@endcode @endcode
@ -48,7 +48,7 @@ GLFW_INCLUDE_NONE before the GLFW header to explicitly disable inclusion of the
development environment header. This also allows the two headers to be included development environment header. This also allows the two headers to be included
in any order. in any order.
@code @code{.c}
#define GLFW_INCLUDE_NONE #define GLFW_INCLUDE_NONE
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
#include <glad/gl.h> #include <glad/gl.h>
@ -61,7 +61,7 @@ Before you can use most GLFW functions, the library must be initialized. On
successful initialization, `GLFW_TRUE` is returned. If an error occurred, successful initialization, `GLFW_TRUE` is returned. If an error occurred,
`GLFW_FALSE` is returned. `GLFW_FALSE` is returned.
@code @code{.c}
if (!glfwInit()) if (!glfwInit())
{ {
// Initialization failed // Initialization failed
@ -73,7 +73,7 @@ Note that `GLFW_TRUE` and `GLFW_FALSE` are and will always be one and zero.
When you are done using GLFW, typically just before the application exits, you When you are done using GLFW, typically just before the application exits, you
need to terminate GLFW. need to terminate GLFW.
@code @code{.c}
glfwTerminate(); glfwTerminate();
@endcode @endcode
@ -92,7 +92,7 @@ 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 You can receive these reports with an error callback. This function must have
the signature below but may do anything permitted in other callbacks. the signature below but may do anything permitted in other callbacks.
@code @code{.c}
void error_callback(int error, const char* description) void error_callback(int error, const char* description)
{ {
fprintf(stderr, "Error: %s\n", description); fprintf(stderr, "Error: %s\n", description);
@ -104,7 +104,7 @@ 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, which lets you be notified of errors both during and after
initialization. initialization.
@code @code{.c}
glfwSetErrorCallback(error_callback); glfwSetErrorCallback(error_callback);
@endcode @endcode
@ -115,7 +115,7 @@ 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 glfwCreateWindow, which returns a handle to the created combined window and
context object context object
@code @code{.c}
GLFWwindow* window = glfwCreateWindow(640, 480, "My Title", NULL, NULL); GLFWwindow* window = glfwCreateWindow(640, 480, "My Title", NULL, NULL);
if (!window) if (!window)
{ {
@ -138,7 +138,7 @@ You can select the OpenGL profile by setting the `GLFW_OPENGL_PROFILE` hint.
This program uses the core profile as that is the only profile macOS supports This program uses the core profile as that is the only profile macOS supports
for OpenGL 3.x and 4.x. for OpenGL 3.x and 4.x.
@code @code{.c}
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
@ -151,7 +151,7 @@ if (!window)
When a window and context is no longer needed, destroy it. When a window and context is no longer needed, destroy it.
@code @code{.c}
glfwDestroyWindow(window); glfwDestroyWindow(window);
@endcode @endcode
@ -163,7 +163,7 @@ and its handle becomes invalid.
Before you can use the OpenGL API, you must have a current OpenGL context. Before you can use the OpenGL API, you must have a current OpenGL context.
@code @code{.c}
glfwMakeContextCurrent(window); glfwMakeContextCurrent(window);
@endcode @endcode
@ -176,7 +176,7 @@ a current context to load from. This example uses
[glad](https://github.com/Dav1dde/glad), but the same rule applies to all such [glad](https://github.com/Dav1dde/glad), but the same rule applies to all such
libraries. libraries.
@code @code{.c}
gladLoadGL(glfwGetProcAddress); gladLoadGL(glfwGetProcAddress);
@endcode @endcode
@ -191,7 +191,7 @@ 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 this flag and either destroy the window or give some kind of feedback to the
user. user.
@code @code{.c}
while (!glfwWindowShouldClose(window)) while (!glfwWindowShouldClose(window))
{ {
// Keep running // Keep running
@ -213,7 +213,7 @@ 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 various kinds of events. To receive key press and release events, create a key
callback function. callback function.
@code @code{.c}
static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
{ {
if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS) if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS)
@ -223,7 +223,7 @@ static void key_callback(GLFWwindow* window, int key, int scancode, int action,
The key callback, like other window related callbacks, are set per-window. The key callback, like other window related callbacks, are set per-window.
@code @code{.c}
glfwSetKeyCallback(window, key_callback); glfwSetKeyCallback(window, key_callback);
@endcode @endcode
@ -237,7 +237,7 @@ Once you have a current OpenGL context, you can use OpenGL normally. In this
tutorial, a multicolored rotating triangle will be rendered. The framebuffer tutorial, a multicolored rotating triangle will be rendered. The framebuffer
size needs to be retrieved for `glViewport`. size needs to be retrieved for `glViewport`.
@code @code{.c}
int width, height; int width, height;
glfwGetFramebufferSize(window, &width, &height); glfwGetFramebufferSize(window, &width, &height);
glViewport(0, 0, width, height); glViewport(0, 0, width, height);
@ -265,7 +265,7 @@ returns the number of seconds since initialization. The time source used is the
most accurate on each platform and generally has micro- or nanosecond most accurate on each platform and generally has micro- or nanosecond
resolution. resolution.
@code @code{.c}
double time = glfwGetTime(); double time = glfwGetTime();
@endcode @endcode
@ -279,7 +279,7 @@ 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 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. another, so the back buffer becomes the front buffer and vice versa.
@code @code{.c}
glfwSwapBuffers(window); glfwSwapBuffers(window);
@endcode @endcode
@ -296,7 +296,7 @@ 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, one. It can be set to higher values, but this is usually not recommended,
because of the input latency it leads to. because of the input latency it leads to.
@code @code{.c}
glfwSwapInterval(1); glfwSwapInterval(1);
@endcode @endcode
@ -315,7 +315,7 @@ There are two methods for processing pending events; polling and waiting. This
example will use event polling, which processes only those events that have example will use event polling, which processes only those events that have
already been received and then returns immediately. already been received and then returns immediately.
@code @code{.c}
glfwPollEvents(); glfwPollEvents();
@endcode @endcode

View File

@ -45,7 +45,7 @@ you will need to direct GLFW to it. Pass your version of `vkGetInstanceProcAddr
glfwInitVulkanLoader before initializing GLFW and it will use that function for all Vulkan glfwInitVulkanLoader before initializing GLFW and it will use that function for all Vulkan
entry point retrieval. This prevents GLFW from dynamically loading the Vulkan loader. entry point retrieval. This prevents GLFW from dynamically loading the Vulkan loader.
@code @code{.c}
glfwInitVulkanLoader(vkGetInstanceProcAddr); glfwInitVulkanLoader(vkGetInstanceProcAddr);
@endcode @endcode
@ -59,7 +59,7 @@ bundle according to the LunarG SDK documentation. This is explained in more det
To have GLFW include the Vulkan header, define @ref GLFW_INCLUDE_VULKAN before including To have GLFW include the Vulkan header, define @ref GLFW_INCLUDE_VULKAN before including
the GLFW header. the GLFW header.
@code @code{.c}
#define GLFW_INCLUDE_VULKAN #define GLFW_INCLUDE_VULKAN
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
@endcode @endcode
@ -67,7 +67,7 @@ the GLFW header.
If you instead want to include the Vulkan header from a custom location or use 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. your own custom Vulkan header then do this before the GLFW header.
@code @code{.c}
#include <path/to/vulkan.h> #include <path/to/vulkan.h>
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
@endcode @endcode
@ -94,7 +94,7 @@ If you are loading the Vulkan loader dynamically instead of linking directly
against it, you can check for the availability of a loader and ICD with @ref against it, you can check for the availability of a loader and ICD with @ref
glfwVulkanSupported. glfwVulkanSupported.
@code @code{.c}
if (glfwVulkanSupported()) if (glfwVulkanSupported())
{ {
// Vulkan is available, at least for compute // Vulkan is available, at least for compute
@ -114,7 +114,7 @@ To load any Vulkan core or extension function from the found loader, call @ref
glfwGetInstanceProcAddress. To load functions needed for instance creation, glfwGetInstanceProcAddress. To load functions needed for instance creation,
pass `NULL` as the instance. pass `NULL` as the instance.
@code @code{.c}
PFN_vkCreateInstance pfnCreateInstance = (PFN_vkCreateInstance) PFN_vkCreateInstance pfnCreateInstance = (PFN_vkCreateInstance)
glfwGetInstanceProcAddress(NULL, "vkCreateInstance"); glfwGetInstanceProcAddress(NULL, "vkCreateInstance");
@endcode @endcode
@ -122,7 +122,7 @@ PFN_vkCreateInstance pfnCreateInstance = (PFN_vkCreateInstance)
Once you have created an instance, you can load from it all other Vulkan core Once you have created an instance, you can load from it all other Vulkan core
functions and functions from any instance extensions you enabled. functions and functions from any instance extensions you enabled.
@code @code{.c}
PFN_vkCreateDevice pfnCreateDevice = (PFN_vkCreateDevice) PFN_vkCreateDevice pfnCreateDevice = (PFN_vkCreateDevice)
glfwGetInstanceProcAddress(instance, "vkCreateDevice"); glfwGetInstanceProcAddress(instance, "vkCreateDevice");
@endcode @endcode
@ -137,7 +137,7 @@ Vulkan also provides `vkGetDeviceProcAddr` for loading device-specific versions
of Vulkan function. This function can be retrieved from an instance with @ref of Vulkan function. This function can be retrieved from an instance with @ref
glfwGetInstanceProcAddress. glfwGetInstanceProcAddress.
@code @code{.c}
PFN_vkGetDeviceProcAddr pfnGetDeviceProcAddr = (PFN_vkGetDeviceProcAddr) PFN_vkGetDeviceProcAddr pfnGetDeviceProcAddr = (PFN_vkGetDeviceProcAddr)
glfwGetInstanceProcAddress(instance, "vkGetDeviceProcAddr"); glfwGetInstanceProcAddress(instance, "vkGetDeviceProcAddr");
@endcode @endcode
@ -156,7 +156,7 @@ GLFW requires to create Vulkan surfaces.
To query the instance extensions required, call @ref To query the instance extensions required, call @ref
glfwGetRequiredInstanceExtensions. glfwGetRequiredInstanceExtensions.
@code @code{.c}
uint32_t count; uint32_t count;
const char** extensions = glfwGetRequiredInstanceExtensions(&count); const char** extensions = glfwGetRequiredInstanceExtensions(&count);
@endcode @endcode
@ -174,7 +174,7 @@ If successful the returned array will always include `VK_KHR_surface`, so if
you don't require any additional extensions you can pass this list directly to you don't require any additional extensions you can pass this list directly to
the `VkInstanceCreateInfo` struct. the `VkInstanceCreateInfo` struct.
@code @code{.c}
VkInstanceCreateInfo ici; VkInstanceCreateInfo ici;
memset(&ici, 0, sizeof(ici)); memset(&ici, 0, sizeof(ici));
@ -203,7 +203,7 @@ 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 presentation without first having to create a window and surface, call @ref
glfwGetPhysicalDevicePresentationSupport. glfwGetPhysicalDevicePresentationSupport.
@code @code{.c}
if (glfwGetPhysicalDevicePresentationSupport(instance, physical_device, queue_family_index)) if (glfwGetPhysicalDevicePresentationSupport(instance, physical_device, queue_family_index))
{ {
// Queue family supports image presentation // Queue family supports image presentation
@ -221,7 +221,7 @@ 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 there is no need to create a context. You can disable context creation with the
[GLFW_CLIENT_API](@ref GLFW_CLIENT_API_hint) hint. [GLFW_CLIENT_API](@ref GLFW_CLIENT_API_hint) hint.
@code @code{.c}
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API); glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
GLFWwindow* window = glfwCreateWindow(640, 480, "Window Title", NULL, NULL); GLFWwindow* window = glfwCreateWindow(640, 480, "Window Title", NULL, NULL);
@endcode @endcode
@ -234,7 +234,7 @@ See @ref context_less for more information.
You can create a Vulkan surface (as defined by the `VK_KHR_surface` extension) You can create a Vulkan surface (as defined by the `VK_KHR_surface` extension)
for a GLFW window with @ref glfwCreateWindowSurface. for a GLFW window with @ref glfwCreateWindowSurface.
@code @code{.c}
VkSurfaceKHR surface; VkSurfaceKHR surface;
VkResult err = glfwCreateWindowSurface(instance, window, NULL, &surface); VkResult err = glfwCreateWindowSurface(instance, window, NULL, &surface);
if (err) if (err)

View File

@ -32,7 +32,7 @@ A window and its OpenGL or OpenGL ES context are created with @ref
glfwCreateWindow, which returns a handle to the created window object. For glfwCreateWindow, which returns a handle to the created window object. For
example, this creates a 640 by 480 windowed mode window: example, this creates a 640 by 480 windowed mode window:
@code @code{.c}
GLFWwindow* window = glfwCreateWindow(640, 480, "My Title", NULL, NULL); GLFWwindow* window = glfwCreateWindow(640, 480, "My Title", NULL, NULL);
@endcode @endcode
@ -50,7 +50,7 @@ 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. should use. In most cases, the user's primary monitor is a good choice.
For more information about retrieving monitors, see @ref monitor_monitors. For more information about retrieving monitors, see @ref monitor_monitors.
@code @code{.c}
GLFWwindow* window = glfwCreateWindow(640, 480, "My Title", glfwGetPrimaryMonitor(), NULL); GLFWwindow* window = glfwCreateWindow(640, 480, "My Title", glfwGetPrimaryMonitor(), NULL);
@endcode @endcode
@ -101,7 +101,7 @@ switching much smoother. This is sometimes called _windowed full screen_ or
_borderless full screen_ window and counts as a full screen window. To create _borderless full screen_ window and counts as a full screen window. To create
such a window, request the current video mode. such a window, request the current video mode.
@code @code{.c}
const GLFWvidmode* mode = glfwGetVideoMode(monitor); const GLFWvidmode* mode = glfwGetVideoMode(monitor);
glfwWindowHint(GLFW_RED_BITS, mode->redBits); glfwWindowHint(GLFW_RED_BITS, mode->redBits);
@ -114,7 +114,7 @@ GLFWwindow* window = glfwCreateWindow(mode->width, mode->height, "My Title", mon
This also works for windowed mode windows that are made full screen. This also works for windowed mode windows that are made full screen.
@code @code{.c}
const GLFWvidmode* mode = glfwGetVideoMode(monitor); const GLFWvidmode* mode = glfwGetVideoMode(monitor);
glfwSetWindowMonitor(window, monitor, 0, 0, mode->width, mode->height, mode->refreshRate); glfwSetWindowMonitor(window, monitor, 0, 0, mode->width, mode->height, mode->refreshRate);
@ -129,7 +129,7 @@ make windowed full screen, you need to have saved the desktop resolution before.
When a window is no longer needed, destroy it with @ref glfwDestroyWindow. When a window is no longer needed, destroy it with @ref glfwDestroyWindow.
@code @code{.c}
glfwDestroyWindow(window); glfwDestroyWindow(window);
@endcode @endcode
@ -598,7 +598,7 @@ The current state of the close flag is returned by @ref glfwWindowShouldClose
and can be set or cleared directly with @ref glfwSetWindowShouldClose. A common and can be set or cleared directly with @ref glfwSetWindowShouldClose. A common
pattern is to use the close flag as a main loop condition. pattern is to use the close flag as a main loop condition.
@code @code{.c}
while (!glfwWindowShouldClose(window)) while (!glfwWindowShouldClose(window))
{ {
render(window); render(window);
@ -611,7 +611,7 @@ while (!glfwWindowShouldClose(window))
If you wish to be notified when the user attempts to close a window, set a close If you wish to be notified when the user attempts to close a window, set a close
callback. callback.
@code @code{.c}
glfwSetWindowCloseCallback(window, window_close_callback); glfwSetWindowCloseCallback(window, window_close_callback);
@endcode @endcode
@ -619,7 +619,7 @@ 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 It can be used for example to filter close requests and clear the close flag
again unless certain conditions are met. again unless certain conditions are met.
@code @code{.c}
void window_close_callback(GLFWwindow* window) void window_close_callback(GLFWwindow* window)
{ {
if (!time_to_close) if (!time_to_close)
@ -635,7 +635,7 @@ mode windows, this sets the size, in
[screen coordinates](@ref coordinate_systems) of the _content area_ or _content [screen coordinates](@ref coordinate_systems) of the _content area_ or _content
area_ of the window. The window system may impose limits on window size. area_ of the window. The window system may impose limits on window size.
@code @code{.c}
glfwSetWindowSize(window, 640, 480); glfwSetWindowSize(window, 640, 480);
@endcode @endcode
@ -647,14 +647,14 @@ resolution of the set video mode.
If you wish to be notified when a window is resized, whether by the user, the 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. system or your own code, set a size callback.
@code @code{.c}
glfwSetWindowSizeCallback(window, window_size_callback); glfwSetWindowSizeCallback(window, window_size_callback);
@endcode @endcode
The callback function receives the new size, in screen coordinates, of the The callback function receives the new size, in screen coordinates, of the
content area of the window when the window is resized. content area of the window when the window is resized.
@code @code{.c}
void window_size_callback(GLFWwindow* window, int width, int height) void window_size_callback(GLFWwindow* window, int width, int height)
{ {
} }
@ -663,7 +663,7 @@ void window_size_callback(GLFWwindow* window, int width, int height)
There is also @ref glfwGetWindowSize for directly retrieving the current size of There is also @ref glfwGetWindowSize for directly retrieving the current size of
a window. a window.
@code @code{.c}
int width, height; int width, height;
glfwGetWindowSize(window, &width, &height); glfwGetWindowSize(window, &width, &height);
@endcode @endcode
@ -677,7 +677,7 @@ 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 windows typically have title bars and window frames around this rectangle. You
can retrieve the extents of these with @ref glfwGetWindowFrameSize. can retrieve the extents of these with @ref glfwGetWindowFrameSize.
@code @code{.c}
int left, top, right, bottom; int left, top, right, bottom;
glfwGetWindowFrameSize(window, &left, &top, &right, &bottom); glfwGetWindowFrameSize(window, &left, &top, &right, &bottom);
@endcode @endcode
@ -698,14 +698,14 @@ pixels, of the framebuffer of a window.
If you wish to be notified when the framebuffer of a window is resized, whether 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. by the user or the system, set a size callback.
@code @code{.c}
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback); glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
@endcode @endcode
The callback function receives the new size of the framebuffer when it is 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. resized, which can for example be used to update the OpenGL viewport.
@code @code{.c}
void framebuffer_size_callback(GLFWwindow* window, int width, int height) void framebuffer_size_callback(GLFWwindow* window, int width, int height)
{ {
glViewport(0, 0, width, height); glViewport(0, 0, width, height);
@ -715,7 +715,7 @@ void framebuffer_size_callback(GLFWwindow* window, int width, int height)
There is also @ref glfwGetFramebufferSize for directly retrieving the current There is also @ref glfwGetFramebufferSize for directly retrieving the current
size of the framebuffer of a window. size of the framebuffer of a window.
@code @code{.c}
int width, height; int width, height;
glfwGetFramebufferSize(window, &width, &height); glfwGetFramebufferSize(window, &width, &height);
glViewport(0, 0, width, height); glViewport(0, 0, width, height);
@ -730,7 +730,7 @@ example if the window is dragged between a regular monitor and a high-DPI one.
The content scale for a window can be retrieved with @ref The content scale for a window can be retrieved with @ref
glfwGetWindowContentScale. glfwGetWindowContentScale.
@code @code{.c}
float xscale, yscale; float xscale, yscale;
glfwGetWindowContentScale(window, &xscale, &yscale); glfwGetWindowContentScale(window, &xscale, &yscale);
@endcode @endcode
@ -750,13 +750,13 @@ 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 because of a system setting change or because it was moved to a monitor with
a different scale, set a content scale callback. a different scale, set a content scale callback.
@code @code{.c}
glfwSetWindowContentScaleCallback(window, window_content_scale_callback); glfwSetWindowContentScaleCallback(window, window_content_scale_callback);
@endcode @endcode
The callback function receives the new content scale of the window. The callback function receives the new content scale of the window.
@code @code{.c}
void window_content_scale_callback(GLFWwindow* window, float xscale, float yscale) void window_content_scale_callback(GLFWwindow* window, float xscale, float yscale)
{ {
set_interface_scale(xscale, yscale); set_interface_scale(xscale, yscale);
@ -777,14 +777,14 @@ be enforced with @ref glfwSetWindowSizeLimits. The user may resize the window
to any size and aspect ratio within the specified limits, unless the aspect to any size and aspect ratio within the specified limits, unless the aspect
ratio is also set. ratio is also set.
@code @code{.c}
glfwSetWindowSizeLimits(window, 200, 200, 400, 400); glfwSetWindowSizeLimits(window, 200, 200, 400, 400);
@endcode @endcode
To specify only a minimum size or only a maximum one, set the other pair to To specify only a minimum size or only a maximum one, set the other pair to
`GLFW_DONT_CARE`. `GLFW_DONT_CARE`.
@code @code{.c}
glfwSetWindowSizeLimits(window, 640, 480, GLFW_DONT_CARE, GLFW_DONT_CARE); glfwSetWindowSizeLimits(window, 640, 480, GLFW_DONT_CARE, GLFW_DONT_CARE);
@endcode @endcode
@ -795,7 +795,7 @@ with @ref glfwSetWindowAspectRatio. The user may resize the window freely
unless size limits are also set, but the size will be constrained to maintain unless size limits are also set, but the size will be constrained to maintain
the aspect ratio. the aspect ratio.
@code @code{.c}
glfwSetWindowAspectRatio(window, 16, 9); glfwSetWindowAspectRatio(window, 16, 9);
@endcode @endcode
@ -803,7 +803,7 @@ 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 the width and height, respectively. If you want a window to maintain its
current aspect ratio, use its current size as the ratio. current aspect ratio, use its current size as the ratio.
@code @code{.c}
int width, height; int width, height;
glfwGetWindowSize(window, &width, &height); glfwGetWindowSize(window, &width, &height);
glfwSetWindowAspectRatio(window, width, height); glfwSetWindowAspectRatio(window, width, height);
@ -824,7 +824,7 @@ 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 a specific position, you can set the desired position with the @ref
GLFW_POSITION_X and @ref GLFW_POSITION_Y window hints. GLFW_POSITION_X and @ref GLFW_POSITION_Y window hints.
@code @code{.c}
glfwWindowHint(GLFW_POSITION_X, 70); glfwWindowHint(GLFW_POSITION_X, 70);
glfwWindowHint(GLFW_POSITION_Y, 83); glfwWindowHint(GLFW_POSITION_Y, 83);
@endcode @endcode
@ -836,21 +836,21 @@ glfwSetWindowPos. This moves the window so that the upper-left corner of its
content area has the specified [screen coordinates](@ref coordinate_systems). content area has the specified [screen coordinates](@ref coordinate_systems).
The window system may put limitations on window placement. The window system may put limitations on window placement.
@code @code{.c}
glfwSetWindowPos(window, 100, 100); glfwSetWindowPos(window, 100, 100);
@endcode @endcode
If you wish to be notified when a window is moved, whether by the user, the 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. system or your own code, set a position callback.
@code @code{.c}
glfwSetWindowPosCallback(window, window_pos_callback); glfwSetWindowPosCallback(window, window_pos_callback);
@endcode @endcode
The callback function receives the new position, in screen coordinates, of the The callback function receives the new position, in screen coordinates, of the
upper-left corner of the content area when the window is moved. upper-left corner of the content area when the window is moved.
@code @code{.c}
void window_pos_callback(GLFWwindow* window, int xpos, int ypos) void window_pos_callback(GLFWwindow* window, int xpos, int ypos)
{ {
} }
@ -859,7 +859,7 @@ void window_pos_callback(GLFWwindow* window, int xpos, int ypos)
There is also @ref glfwGetWindowPos for directly retrieving the current position There is also @ref glfwGetWindowPos for directly retrieving the current position
of the content area of the window. of the content area of the window.
@code @code{.c}
int xpos, ypos; int xpos, ypos;
glfwGetWindowPos(window, &xpos, &ypos); glfwGetWindowPos(window, &xpos, &ypos);
@endcode @endcode
@ -871,7 +871,7 @@ 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 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. set a UTF-8 encoded window title with @ref glfwSetWindowTitle.
@code @code{.c}
glfwSetWindowTitle(window, "My Window"); glfwSetWindowTitle(window, "My Window");
@endcode @endcode
@ -881,13 +881,13 @@ to keep it around.
As long as your source file is encoded as UTF-8, you can use any Unicode As long as your source file is encoded as UTF-8, you can use any Unicode
characters directly in the source. characters directly in the source.
@code @code{.c}
glfwSetWindowTitle(window, "ラストエグザイル"); glfwSetWindowTitle(window, "ラストエグザイル");
@endcode @endcode
If you are using C++11 or C11, you can use a UTF-8 string literal. If you are using C++11 or C11, you can use a UTF-8 string literal.
@code @code{.c}
glfwSetWindowTitle(window, u8"This is always a UTF-8 string"); glfwSetWindowTitle(window, u8"This is always a UTF-8 string");
@endcode @endcode
@ -897,7 +897,7 @@ glfwSetWindowTitle(window, u8"This is always a UTF-8 string");
Decorated windows have icons on some platforms. You can set this icon by Decorated windows have icons on some platforms. You can set this icon by
specifying a list of candidate images with @ref glfwSetWindowIcon. specifying a list of candidate images with @ref glfwSetWindowIcon.
@code @code{.c}
GLFWimage images[2]; GLFWimage images[2];
images[0] = load_icon("my_icon.png"); images[0] = load_icon("my_icon.png");
images[1] = load_icon("my_icon_small.png"); images[1] = load_icon("my_icon_small.png");
@ -911,7 +911,7 @@ sequential rows, starting from the top-left corner.
To revert to the default window icon, pass in an empty image array. To revert to the default window icon, pass in an empty image array.
@code @code{.c}
glfwSetWindowIcon(window, 0, NULL); glfwSetWindowIcon(window, 0, NULL);
@endcode @endcode
@ -921,7 +921,7 @@ glfwSetWindowIcon(window, 0, NULL);
Full screen windows are associated with a specific monitor. You can get the Full screen windows are associated with a specific monitor. You can get the
handle for this monitor with @ref glfwGetWindowMonitor. handle for this monitor with @ref glfwGetWindowMonitor.
@code @code{.c}
GLFWmonitor* monitor = glfwGetWindowMonitor(window); GLFWmonitor* monitor = glfwGetWindowMonitor(window);
@endcode @endcode
@ -935,7 +935,7 @@ with @ref glfwSetWindowMonitor. When making a window full screen on the same or
on a different monitor, specify the desired monitor, resolution and refresh on a different monitor, specify the desired monitor, resolution and refresh
rate. The position arguments are ignored. rate. The position arguments are ignored.
@code @code{.c}
const GLFWvidmode* mode = glfwGetVideoMode(monitor); const GLFWvidmode* mode = glfwGetVideoMode(monitor);
glfwSetWindowMonitor(window, monitor, 0, 0, mode->width, mode->height, mode->refreshRate); glfwSetWindowMonitor(window, monitor, 0, 0, mode->width, mode->height, mode->refreshRate);
@ -944,7 +944,7 @@ glfwSetWindowMonitor(window, monitor, 0, 0, mode->width, mode->height, mode->ref
When making the window windowed, specify the desired position and size. The When making the window windowed, specify the desired position and size. The
refresh rate argument is ignored. refresh rate argument is ignored.
@code @code{.c}
glfwSetWindowMonitor(window, NULL, xpos, ypos, width, height, 0); glfwSetWindowMonitor(window, NULL, xpos, ypos, width, height, 0);
@endcode @endcode
@ -958,7 +958,7 @@ before making it full screen and then pass them in as above.
Windows can be iconified (i.e. minimized) with @ref glfwIconifyWindow. Windows can be iconified (i.e. minimized) with @ref glfwIconifyWindow.
@code @code{.c}
glfwIconifyWindow(window); glfwIconifyWindow(window);
@endcode @endcode
@ -968,7 +968,7 @@ is restored until the user or application restores the window.
Iconified windows can be restored with @ref glfwRestoreWindow. This function Iconified windows can be restored with @ref glfwRestoreWindow. This function
also restores windows from maximization. also restores windows from maximization.
@code @code{.c}
glfwRestoreWindow(window); glfwRestoreWindow(window);
@endcode @endcode
@ -978,13 +978,13 @@ monitor as well.
If you wish to be notified when a window is iconified or restored, whether by If you wish to be notified when a window is iconified or restored, whether by
the user, system or your own code, set an iconify callback. the user, system or your own code, set an iconify callback.
@code @code{.c}
glfwSetWindowIconifyCallback(window, window_iconify_callback); glfwSetWindowIconifyCallback(window, window_iconify_callback);
@endcode @endcode
The callback function receives changes in the iconification state of the window. The callback function receives changes in the iconification state of the window.
@code @code{.c}
void window_iconify_callback(GLFWwindow* window, int iconified) void window_iconify_callback(GLFWwindow* window, int iconified)
{ {
if (iconified) if (iconified)
@ -1000,7 +1000,7 @@ void window_iconify_callback(GLFWwindow* window, int iconified)
You can also get the current iconification state with @ref glfwGetWindowAttrib. You can also get the current iconification state with @ref glfwGetWindowAttrib.
@code @code{.c}
int iconified = glfwGetWindowAttrib(window, GLFW_ICONIFIED); int iconified = glfwGetWindowAttrib(window, GLFW_ICONIFIED);
@endcode @endcode
@ -1009,7 +1009,7 @@ int iconified = glfwGetWindowAttrib(window, GLFW_ICONIFIED);
Windows can be maximized (i.e. zoomed) with @ref glfwMaximizeWindow. Windows can be maximized (i.e. zoomed) with @ref glfwMaximizeWindow.
@code @code{.c}
glfwMaximizeWindow(window); glfwMaximizeWindow(window);
@endcode @endcode
@ -1019,20 +1019,20 @@ function does nothing.
Maximized windows can be restored with @ref glfwRestoreWindow. This function Maximized windows can be restored with @ref glfwRestoreWindow. This function
also restores windows from iconification. also restores windows from iconification.
@code @code{.c}
glfwRestoreWindow(window); glfwRestoreWindow(window);
@endcode @endcode
If you wish to be notified when a window is maximized or restored, whether by 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. the user, system or your own code, set a maximize callback.
@code @code{.c}
glfwSetWindowMaximizeCallback(window, window_maximize_callback); glfwSetWindowMaximizeCallback(window, window_maximize_callback);
@endcode @endcode
The callback function receives changes in the maximization state of the window. The callback function receives changes in the maximization state of the window.
@code @code{.c}
void window_maximize_callback(GLFWwindow* window, int maximized) void window_maximize_callback(GLFWwindow* window, int maximized)
{ {
if (maximized) if (maximized)
@ -1048,7 +1048,7 @@ void window_maximize_callback(GLFWwindow* window, int maximized)
You can also get the current maximization state with @ref glfwGetWindowAttrib. You can also get the current maximization state with @ref glfwGetWindowAttrib.
@code @code{.c}
int maximized = glfwGetWindowAttrib(window, GLFW_MAXIMIZED); int maximized = glfwGetWindowAttrib(window, GLFW_MAXIMIZED);
@endcode @endcode
@ -1056,7 +1056,7 @@ By default, newly created windows are not maximized. You can change this
behavior by setting the [GLFW_MAXIMIZED](@ref GLFW_MAXIMIZED_hint) window hint behavior by setting the [GLFW_MAXIMIZED](@ref GLFW_MAXIMIZED_hint) window hint
before creating the window. before creating the window.
@code @code{.c}
glfwWindowHint(GLFW_MAXIMIZED, GLFW_TRUE); glfwWindowHint(GLFW_MAXIMIZED, GLFW_TRUE);
@endcode @endcode
@ -1065,7 +1065,7 @@ glfwWindowHint(GLFW_MAXIMIZED, GLFW_TRUE);
Windowed mode windows can be hidden with @ref glfwHideWindow. Windowed mode windows can be hidden with @ref glfwHideWindow.
@code @code{.c}
glfwHideWindow(window); glfwHideWindow(window);
@endcode @endcode
@ -1075,7 +1075,7 @@ and calling @ref glfwHideWindow on a full screen window does nothing.
Hidden windows can be shown with @ref glfwShowWindow. Hidden windows can be shown with @ref glfwShowWindow.
@code @code{.c}
glfwShowWindow(window); glfwShowWindow(window);
@endcode @endcode
@ -1086,7 +1086,7 @@ existing window with @ref glfwSetWindowAttrib.
You can also get the current visibility state with @ref glfwGetWindowAttrib. You can also get the current visibility state with @ref glfwGetWindowAttrib.
@code @code{.c}
int visible = glfwGetWindowAttrib(window, GLFW_VISIBLE); int visible = glfwGetWindowAttrib(window, GLFW_VISIBLE);
@endcode @endcode
@ -1094,7 +1094,7 @@ 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 setting the [GLFW_VISIBLE](@ref GLFW_VISIBLE_hint) window hint before creating
the window. the window.
@code @code{.c}
glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE); glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE);
@endcode @endcode
@ -1108,7 +1108,7 @@ example moving it to a specific location.
Windows can be given input focus and brought to the front with @ref Windows can be given input focus and brought to the front with @ref
glfwFocusWindow. glfwFocusWindow.
@code @code{.c}
glfwFocusWindow(window); glfwFocusWindow(window);
@endcode @endcode
@ -1119,13 +1119,13 @@ to the top. For a less disruptive way of getting the user's attention, see
If you wish to be notified when a window gains or loses input focus, whether by 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. the user, system or your own code, set a focus callback.
@code @code{.c}
glfwSetWindowFocusCallback(window, window_focus_callback); glfwSetWindowFocusCallback(window, window_focus_callback);
@endcode @endcode
The callback function receives changes in the input focus state of the window. The callback function receives changes in the input focus state of the window.
@code @code{.c}
void window_focus_callback(GLFWwindow* window, int focused) void window_focus_callback(GLFWwindow* window, int focused)
{ {
if (focused) if (focused)
@ -1141,7 +1141,7 @@ void window_focus_callback(GLFWwindow* window, int focused)
You can also get the current input focus state with @ref glfwGetWindowAttrib. You can also get the current input focus state with @ref glfwGetWindowAttrib.
@code @code{.c}
int focused = glfwGetWindowAttrib(window, GLFW_FOCUSED); int focused = glfwGetWindowAttrib(window, GLFW_FOCUSED);
@endcode @endcode
@ -1149,7 +1149,7 @@ 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 behavior by setting the [GLFW_FOCUSED](@ref GLFW_FOCUSED_hint) window hint
before creating the window. before creating the window.
@code @code{.c}
glfwWindowHint(GLFW_FOCUSED, GLFW_FALSE); glfwWindowHint(GLFW_FOCUSED, GLFW_FALSE);
@endcode @endcode
@ -1159,7 +1159,7 @@ glfwWindowHint(GLFW_FOCUSED, GLFW_FALSE);
If you wish to notify the user of an event without interrupting, you can request If you wish to notify the user of an event without interrupting, you can request
attention with @ref glfwRequestWindowAttention. attention with @ref glfwRequestWindowAttention.
@code @code{.c}
glfwRequestWindowAttention(window); glfwRequestWindowAttention(window);
@endcode @endcode
@ -1173,14 +1173,14 @@ attention, the system will automatically end the request.
If you wish to be notified when the contents of a window is damaged and needs If you wish to be notified when the contents of a window is damaged and needs
to be refreshed, set a window refresh callback. to be refreshed, set a window refresh callback.
@code @code{.c}
glfwSetWindowRefreshCallback(m_handle, window_refresh_callback); glfwSetWindowRefreshCallback(m_handle, window_refresh_callback);
@endcode @endcode
The callback function is called when the contents of the window needs to be The callback function is called when the contents of the window needs to be
refreshed. refreshed.
@code @code{.c}
void window_refresh_callback(GLFWwindow* window) void window_refresh_callback(GLFWwindow* window)
{ {
draw_editor_ui(window); draw_editor_ui(window);
@ -1207,7 +1207,7 @@ Window framebuffers can be made transparent on a per-pixel per-frame basis with
the [GLFW_TRANSPARENT_FRAMEBUFFER](@ref GLFW_TRANSPARENT_FRAMEBUFFER_hint) the [GLFW_TRANSPARENT_FRAMEBUFFER](@ref GLFW_TRANSPARENT_FRAMEBUFFER_hint)
window hint. window hint.
@code @code{.c}
glfwWindowHint(GLFW_TRANSPARENT_FRAMEBUFFER, GLFW_TRUE); glfwWindowHint(GLFW_TRANSPARENT_FRAMEBUFFER, GLFW_TRUE);
@endcode @endcode
@ -1220,7 +1220,7 @@ with the
[GLFW_TRANSPARENT_FRAMEBUFFER](@ref GLFW_TRANSPARENT_FRAMEBUFFER_attrib) [GLFW_TRANSPARENT_FRAMEBUFFER](@ref GLFW_TRANSPARENT_FRAMEBUFFER_attrib)
window attribute. window attribute.
@code @code{.c}
if (glfwGetWindowAttrib(window, GLFW_TRANSPARENT_FRAMEBUFFER)) if (glfwGetWindowAttrib(window, GLFW_TRANSPARENT_FRAMEBUFFER))
{ {
// window framebuffer is currently transparent // window framebuffer is currently transparent
@ -1232,7 +1232,7 @@ 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 The opacity of the whole window, including any decorations, can be set with @ref
glfwSetWindowOpacity. glfwSetWindowOpacity.
@code @code{.c}
glfwSetWindowOpacity(window, 0.5f); glfwSetWindowOpacity(window, 0.5f);
@endcode @endcode
@ -1242,7 +1242,7 @@ opacity value for newly created windows is 1.
The current opacity of a window can be queried with @ref glfwGetWindowOpacity. The current opacity of a window can be queried with @ref glfwGetWindowOpacity.
@code @code{.c}
float opacity = glfwGetWindowOpacity(window); float opacity = glfwGetWindowOpacity(window);
@endcode @endcode
@ -1265,7 +1265,7 @@ 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 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. the window and others to its OpenGL or OpenGL ES context.
@code @code{.c}
if (glfwGetWindowAttrib(window, GLFW_FOCUSED)) if (glfwGetWindowAttrib(window, GLFW_FOCUSED))
{ {
// window has input focus // window has input focus
@ -1279,7 +1279,7 @@ The [GLFW_DECORATED](@ref GLFW_DECORATED_attrib),
[GLFW_FOCUS_ON_SHOW](@ref GLFW_FOCUS_ON_SHOW_attrib) window attributes can be [GLFW_FOCUS_ON_SHOW](@ref GLFW_FOCUS_ON_SHOW_attrib) window attributes can be
changed with @ref glfwSetWindowAttrib. changed with @ref glfwSetWindowAttrib.
@code @code{.c}
glfwSetWindowAttrib(window, GLFW_RESIZABLE, GLFW_FALSE); glfwSetWindowAttrib(window, GLFW_RESIZABLE, GLFW_FALSE);
@endcode @endcode
@ -1465,7 +1465,7 @@ 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 front buffers in order to display what has been rendered and begin rendering
a new frame. This is done with @ref glfwSwapBuffers. a new frame. This is done with @ref glfwSwapBuffers.
@code @code{.c}
glfwSwapBuffers(window); glfwSwapBuffers(window);
@endcode @endcode
@ -1474,7 +1474,7 @@ function @ref glfwSwapInterval it is possible to select the minimum number of
monitor refreshes the driver should wait from the time @ref glfwSwapBuffers was monitor refreshes the driver should wait from the time @ref glfwSwapBuffers was
called before swapping the buffers: called before swapping the buffers:
@code @code{.c}
glfwSwapInterval(1); glfwSwapInterval(1);
@endcode @endcode