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
+55 -55
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
immediately.
@code
@code{.c}
glfwPollEvents();
@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
input, @ref glfwWaitEvents is a better choice.
@code
@code{.c}
glfwWaitEvents();
@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
periodic updates, @ref glfwWaitEventsTimeout lets you specify a timeout.
@code
@code{.c}
glfwWaitEventsTimeout(0.7);
@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
glfwPostEmptyEvent.
@code
@code{.c}
glfwPostEmptyEvent();
@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
repeats, set a key callback.
@code
@code{.c}
glfwSetKeyCallback(window, key_callback);
@endcode
The callback function receives the [keyboard key](@ref keys), platform-specific
scancode, key action and [modifier bits](@ref mods).
@code
@code{.c}
void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
{
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
current platform with @ref glfwGetKeyScancode.
@code
@code{.c}
const int scancode = glfwGetKeyScancode(GLFW_KEY_X);
set_key_mapping(scancode, swap_weapons);
@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
also saved in per-window state arrays that can be polled with @ref glfwGetKey.
@code
@code{.c}
int state = glfwGetKey(window, GLFW_KEY_E);
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
key callback, but there is also the `GLFW_STICKY_KEYS` input mode.
@code
@code{.c}
glfwSetInputMode(window, GLFW_STICKY_KEYS, GLFW_TRUE);
@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
input events were generated, set the `GLFW_LOCK_KEY_MODS` input mode.
@code
@code{.c}
glfwSetInputMode(window, GLFW_LOCK_KEY_MODS, GLFW_TRUE);
@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.
@code
@code{.c}
glfwSetCharCallback(window, character_callback);
@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
that platform.
@code
@code{.c}
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
dependent name of printable keys with @ref glfwGetKeyName.
@code
@code{.c}
const char* key_name = glfwGetKeyName(GLFW_KEY_W, 0);
show_tutorial_hint("Press %s to move forward", key_name);
@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
position callback.
@code
@code{.c}
glfwSetCursorPosCallback(window, cursor_position_callback);
@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
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)
{
}
@@ -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
glfwGetCursorPos.
@code
@code{.c}
double xpos, ypos;
glfwGetCursorPos(window, &xpos, &ypos);
@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
`GLFW_CURSOR_DISABLED`.
@code
@code{.c}
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED);
@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
want it to behave normally, set the cursor mode to `GLFW_CURSOR_HIDDEN`.
@code
@code{.c}
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_HIDDEN);
@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
window, set the cursor mode to `GLFW_CURSOR_CAPTURED`.
@code
@code{.c}
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_CAPTURED);
@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`
cursor mode.
@code
@code{.c}
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_NORMAL);
@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
disabled by default.
@code
@code{.c}
if (glfwRawMouseMotionSupported())
glfwSetInputMode(window, GLFW_RAW_MOUSE_MOTION, GLFW_TRUE);
@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
cursor with the hot-spot in the upper-left corner:
@code
@code{.c}
unsigned char pixels[16 * 16 * 4];
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
theme can be created with @ref glfwCreateStandardCursor.
@code
@code{.c}
GLFWcursor* url_cursor = glfwCreateStandardCursor(GLFW_POINTING_HAND_CURSOR);
@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.
@code
@code{.c}
glfwDestroyCursor(cursor);
@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.
@code
@code{.c}
glfwSetCursor(window, cursor);
@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`.
@code
@code{.c}
glfwSetCursor(window, NULL);
@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
a window, set a cursor enter/leave callback.
@code
@code{.c}
glfwSetCursorEnterCallback(window, cursor_enter_callback);
@endcode
The callback function receives the new classification of the cursor.
@code
@code{.c}
void cursor_enter_callback(GLFWwindow* window, int 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
window with the [GLFW_HOVERED](@ref GLFW_HOVERED_attrib) window attribute.
@code
@code{.c}
if (glfwGetWindowAttrib(window, GLFW_HOVERED))
{
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
a mouse button callback.
@code
@code{.c}
glfwSetMouseButtonCallback(window, mouse_button_callback);
@endcode
The callback function receives the [mouse button](@ref buttons), button action
and [modifier bits](@ref mods).
@code
@code{.c}
void mouse_button_callback(GLFWwindow* window, int button, int action, int mods)
{
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
glfwGetMouseButton.
@code
@code{.c}
int state = glfwGetMouseButton(window, GLFW_MOUSE_BUTTON_LEFT);
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`
input mode.
@code
@code{.c}
glfwSetInputMode(window, GLFW_STICKY_MOUSE_BUTTONS, GLFW_TRUE);
@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
touchpad gesture, set a scroll callback.
@code
@code{.c}
glfwSetScrollCallback(window, scroll_callback);
@endcode
The callback function receives two-dimensional scroll offsets.
@code
@code{.c}
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
present with @ref glfwJoystickPresent.
@code
@code{.c}
int present = glfwJoystickPresent(GLFW_JOYSTICK_1);
@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
returned array.
@code
@code{.c}
int count;
const float* axes = glfwGetJoystickAxes(GLFW_JOYSTICK_5, &count);
@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
returned array.
@code
@code{.c}
int count;
const unsigned char* buttons = glfwGetJoystickButtons(GLFW_JOYSTICK_3, &count);
@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
reference documentation for the lifetime of the returned array.
@code
@code{.c}
int count;
const unsigned char* hats = glfwGetJoystickHats(GLFW_JOYSTICK_7, &count);
@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
the corresponding direction.
@code
@code{.c}
if (hats[2] & GLFW_HAT_RIGHT)
{
// 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
returned string.
@code
@code{.c}
const char* name = glfwGetJoystickName(GLFW_JOYSTICK_4);
@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
a joystick callback.
@code
@code{.c}
glfwSetJoystickCallback(joystick_callback);
@endcode
The callback function receives the ID of the joystick that has been connected
and disconnected and the event that occurred.
@code
@code{.c}
void joystick_callback(int jid, int event)
{
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
@ref glfwJoystickIsGamepad.
@code
@code{.c}
if (glfwJoystickIsGamepad(GLFW_JOYSTICK_2))
{
// 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
[joystick name](@ref joystick_name).
@code
@code{.c}
const char* name = glfwGetGamepadName(GLFW_JOYSTICK_7);
@endcode
To retrieve the gamepad state of a joystick, call @ref glfwGetGamepadState.
@code
@code{.c}
GLFWgamepadstate 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
glfwUpdateGamepadMappings.
@code
@code{.c}
const char* mappings = load_file_contents("game/data/gamecontrollerdb.txt");
glfwUpdateGamepadMappings(mappings);
@@ -898,7 +898,7 @@ and described above.
GLFW provides high-resolution time input, in seconds, with @ref glfwGetTime.
@code
@code{.c}
double seconds = glfwGetTime();
@endcode
@@ -908,7 +908,7 @@ nanosecond resolution.
You can modify the base time with @ref glfwSetTime.
@code
@code{.c}
glfwSetTime(4.0);
@endcode
@@ -918,7 +918,7 @@ from there.
You can also access the raw timer used to implement the functions above,
with @ref glfwGetTimerValue.
@code
@code{.c}
uint64_t value = glfwGetTimerValue();
@endcode
@@ -926,7 +926,7 @@ This value is in 1 / frequency seconds. The frequency of the raw
timer varies depending on the operating system and hardware. You can query the
frequency, in Hz, with @ref glfwGetTimerFrequency.
@code
@code{.c}
uint64_t frequency = glfwGetTimerFrequency();
@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
reference documentation for the lifetime of the returned string.
@code
@code{.c}
const char* text = glfwGetClipboardString(NULL);
if (text)
{
@@ -951,7 +951,7 @@ returned.
The contents of the system clipboard can be set to a UTF-8 encoded string with
@ref glfwSetClipboardString.
@code
@code{.c}
glfwSetClipboardString(NULL, "A string with words in it");
@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
a window, set a file drop callback.
@code
@code{.c}
glfwSetDropCallback(window, drop_callback);
@endcode
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)
{
int i;