Class GLFW
Provides access to the GLFW API.
On Linux to use GLFW compiled for Wayland set the environment variable OPENTK_4_USE_WAYLAND=1
.
Inherited Members
Namespace: OpenTK.Windowing.GraphicsLibraryFramework
Assembly: OpenTK.Windowing.GraphicsLibraryFramework.dll
Syntax
public static class GLFW
Fields
DontCare
Gets an integer equal to GLFW_DONT_CARE. This can be used for several window hints to use the platform default.
Declaration
public const int DontCare = -1
Field Value
Type | Description |
---|---|
int |
Methods
CreateCursor(in Image, int, int)
Creates a new custom cursor image that can be set for a window with SetCursor(Window*, Cursor*).
The cursor can be destroyed with DestroyCursor(Cursor*). Any remaining cursors are destroyed by Terminate().
The pixels are 32-bit, little-endian, non-premultiplied RGBA, i.e. eight bits per channel with the red channel first. They are arranged canonically as packed sequential rows, starting from the top-left corner.
The cursor hotspot is specified in pixels, relative to the upper-left corner of the cursor image. Like all other coordinate systems in GLFW, the X-axis points to the right and the Y-axis points down.
Declaration
public static Cursor* CreateCursor(in Image image, int xHot, int yHot)
Parameters
Type | Name | Description |
---|---|---|
Image | image | The desired cursor image. |
int | xHot | The desired x-coordinate, in pixels, of the cursor hotspot. |
int | yHot | The desired y-coordinate, in pixels, of the cursor hotspot. |
Returns
Type | Description |
---|---|
Cursor* | The handle of the created cursor, or |
Remarks
The specified image data is copied before this function returns.
This function must only be called from the main thread.
Possible errors include NotInitialized and PlatformError.
CreateCursorRaw(Image*, int, int)
Creates a new custom cursor image that can be set for a window with SetCursor(Window*, Cursor*).
The cursor can be destroyed with DestroyCursor(Cursor*). Any remaining cursors are destroyed by Terminate().
The pixels are 32-bit, little-endian, non-premultiplied RGBA, i.e. eight bits per channel with the red channel first. They are arranged canonically as packed sequential rows, starting from the top-left corner.
The cursor hotspot is specified in pixels, relative to the upper-left corner of the cursor image. Like all other coordinate systems in GLFW, the X-axis points to the right and the Y-axis points down.
Declaration
public static Cursor* CreateCursorRaw(Image* image, int xHot, int yHot)
Parameters
Type | Name | Description |
---|---|---|
Image* | image | The desired cursor image. |
int | xHot | The desired x-coordinate, in pixels, of the cursor hotspot. |
int | yHot | The desired y-coordinate, in pixels, of the cursor hotspot. |
Returns
Type | Description |
---|---|
Cursor* | The handle of the created cursor, or |
Remarks
The specified image data is copied before this function returns.
This function must only be called from the main thread.
Possible errors include NotInitialized and PlatformError.
CreateStandardCursor(CursorShape)
Returns a cursor with a standard shape, that can be set for a window with SetCursor(Window*, Cursor*).
Declaration
public static Cursor* CreateStandardCursor(CursorShape shape)
Parameters
Type | Name | Description |
---|---|---|
CursorShape | shape | One of the standard shapes. |
Returns
Type | Description |
---|---|
Cursor* | A new cursor ready to use or |
Remarks
This function must only be called from the main thread.
Possible errors include NotInitialized, InvalidEnum and PlatformError.
CreateWindow(int, int, string, Monitor*, Window*)
This function creates a window and its associated OpenGL or OpenGL ES context. Most of the options controlling how the window and its context should be created are specified with window hints.
Successful creation does not change which context is current. Before you can use the newly created context, you need to make it current. For information about the share parameter, see Context object sharing.
The created window, framebuffer and context may differ from what you requested, as not all parameters and hints are hard constraints. This includes the size of the window, especially for full screen windows. To query the actual attributes of the created window, framebuffer and context, see GetWindowAttrib(Window*, WindowAttributeGetBool), GetWindowSize(Window*, out int, out int) and GetFramebufferSize(Window*, out int, out int).
To create a full screen window, you need to specify the monitor the window will cover. If no monitor is specified, the window will be windowed mode. Unless you have a way for the user to choose a specific monitor, it is recommended that you pick the primary monitor. For more information on how to query connected monitors, see Retrieving monitors.
For full screen windows, the specified size becomes the resolution of the window's desired video mode. As long as a full screen window is not iconified, the supported video mode most closely matching the desired video mode is set for the specified monitor. For more information about full screen windows, including the creation of so called windowed full screen or borderless full screen windows, see "Windowed full screen" windows .
Once you have created the window, you can switch it between windowed and full screen mode with SetWindowMonitor(Window*, Monitor*, int, int, int, int, int). If the window has an OpenGL or OpenGL ES context, it will be unaffected.
By default, newly created windows use the placement recommended by the window system. To create the window at a specific position, make it initially invisible using the Visible window hint, set its position(see SetWindowPos(Window*, int, int)) and then show it (see ShowWindow(Window*)).
As long as at least one full screen window is not iconified, the screensaver is prohibited from starting.
Window systems put limits on window sizes. Very large or very small window dimensions may be overridden by the window system on creation. Check the actual size after creation(see GetWindowSize(Window*, out int, out int) or SetWindowSizeCallback(Window*, WindowSizeCallback).
The swap interval is not set during window creation and the initial value may vary depending on driver settings and defaults.
Declaration
public static Window* CreateWindow(int width, int height, string title, Monitor* monitor, Window* share)
Parameters
Type | Name | Description |
---|---|---|
int | width | The desired width, in screen coordinates, of the window. This must be greater than zero. |
int | height | The desired height, in screen coordinates, of the window. This must be greater than zero. |
string | title | The initial, UTF-8 encoded window title. |
Monitor* | monitor | The monitor to use for full screen mode, or |
Window* | share | The window whose context to share resources with, or |
Returns
Type | Description |
---|---|
Window* | The handle of the created window, or |
Remarks
Windows: Window creation will fail if the Microsoft GDI software OpenGL implementation is the only one available.
Windows: If the executable has an icon resource named GLFW_ICON, it will be set as the initial icon for the window. If no such icon is present, the IDI_WINLOGO icon will be used instead. To set a different icon, see SetWindowIcon(Window*, ReadOnlySpan<Image>).
Windows: The context to share resources with must not be current on any other thread.
OS X: The GLFW window has no icon, as it is not a document window, but the dock icon will be the same as the application bundle's icon. For more information on bundles, see the Bundle Programming Guide in the Mac Developer Library.
OS X: The first time a window is created the menu bar is populated with common commands like Hide, Quit and About. The About entry opens a minimal about dialog with information from the application's bundle. The menu bar can be disabled with a compile-time option.
OS X: On OS X 10.10 and later the window frame will not be rendered at full resolution on Retina displays unless the NSHighResolutionCapable key is enabled in the application bundle's Info.plist. For more information, see High Resolution Guidelines for OS X in the Mac Developer Library. The GLFW test and example programs use a custom Info.plist template for this, which can be found as CMake/MacOSXBundleInfo.plist.in in the source tree.
X11: Some window managers will not respect the placement of initially hidden windows. X11: Due to the asynchronous nature of X11, it may take a moment for a window to reach its requested state. This means you may not be able to query the final size, position or other attributes directly after window creation.
This function must not be called from a callback.
This function must only be called from the main thread.
Possible errors include NotInitialized, InvalidEnum, InvalidValue, ApiUnavailable, VersionUnavailable, FormatUnavailable and PlatformError.
CreateWindowRaw(int, int, byte*, Monitor*, Window*)
This function creates a window and its associated OpenGL or OpenGL ES context. Most of the options controlling how the window and its context should be created are specified with window hints.
Successful creation does not change which context is current. Before you can use the newly created context, you need to make it current. For information about the share parameter, see Context object sharing.
The created window, framebuffer and context may differ from what you requested, as not all parameters and hints are hard constraints. This includes the size of the window, especially for full screen windows. To query the actual attributes of the created window, framebuffer and context, see GetWindowAttrib(Window*, WindowAttributeGetBool), GetWindowSize(Window*, out int, out int) and GetFramebufferSize(Window*, out int, out int).
To create a full screen window, you need to specify the monitor the window will cover. If no monitor is specified, the window will be windowed mode. Unless you have a way for the user to choose a specific monitor, it is recommended that you pick the primary monitor. For more information on how to query connected monitors, see Retrieving monitors.
For full screen windows, the specified size becomes the resolution of the window's desired video mode. As long as a full screen window is not iconified, the supported video mode most closely matching the desired video mode is set for the specified monitor. For more information about full screen windows, including the creation of so called windowed full screen or borderless full screen windows, see "Windowed full screen" windows .
Once you have created the window, you can switch it between windowed and full screen mode with SetWindowMonitor(Window*, Monitor*, int, int, int, int, int). If the window has an OpenGL or OpenGL ES context, it will be unaffected.
By default, newly created windows use the placement recommended by the window system. To create the window at a specific position, make it initially invisible using the Visible window hint, set its position(see SetWindowPos(Window*, int, int)) and then show it (see ShowWindow(Window*)).
As long as at least one full screen window is not iconified, the screensaver is prohibited from starting.
Window systems put limits on window sizes. Very large or very small window dimensions may be overridden by the window system on creation. Check the actual size after creation(see GetWindowSize(Window*, out int, out int) or SetWindowSizeCallback(Window*, WindowSizeCallback).
The swap interval is not set during window creation and the initial value may vary depending on driver settings and defaults.
Declaration
public static Window* CreateWindowRaw(int width, int height, byte* title, Monitor* monitor, Window* share)
Parameters
Type | Name | Description |
---|---|---|
int | width | The desired width, in screen coordinates, of the window. This must be greater than zero. |
int | height | The desired height, in screen coordinates, of the window. This must be greater than zero. |
byte* | title | The initial, UTF-8 encoded window title. |
Monitor* | monitor | The monitor to use for full screen mode, or |
Window* | share | The window whose context to share resources with, or |
Returns
Type | Description |
---|---|
Window* | The handle of the created window, or |
Remarks
Windows: Window creation will fail if the Microsoft GDI software OpenGL implementation is the only one available.
Windows: If the executable has an icon resource named GLFW_ICON, it will be set as the initial icon for the window. If no such icon is present, the IDI_WINLOGO icon will be used instead. To set a different icon, see SetWindowIcon(Window*, ReadOnlySpan<Image>).
Windows: The context to share resources with must not be current on any other thread.
OS X: The GLFW window has no icon, as it is not a document window, but the dock icon will be the same as the application bundle's icon. For more information on bundles, see the Bundle Programming Guide in the Mac Developer Library.
OS X: The first time a window is created the menu bar is populated with common commands like Hide, Quit and About. The About entry opens a minimal about dialog with information from the application's bundle. The menu bar can be disabled with a compile-time option.
OS X: On OS X 10.10 and later the window frame will not be rendered at full resolution on Retina displays unless the NSHighResolutionCapable key is enabled in the application bundle's Info.plist. For more information, see High Resolution Guidelines for OS X in the Mac Developer Library. The GLFW test and example programs use a custom Info.plist template for this, which can be found as CMake/MacOSXBundleInfo.plist.in in the source tree.
X11: Some window managers will not respect the placement of initially hidden windows. X11: Due to the asynchronous nature of X11, it may take a moment for a window to reach its requested state. This means you may not be able to query the final size, position or other attributes directly after window creation.
This function must not be called from a callback.
This function must only be called from the main thread.
Possible errors include NotInitialized, InvalidEnum, InvalidValue, ApiUnavailable, VersionUnavailable, FormatUnavailable and PlatformError.
CreateWindowSurface(VkHandle, Window*, void*, out VkHandle)
Creates a Vulkan surface for the specified window.
Declaration
public static int CreateWindowSurface(VkHandle instance, Window* window, void* allocator, out VkHandle surface)
Parameters
Type | Name | Description |
---|---|---|
VkHandle | instance | The Vulkan instance to create the surface in. |
Window* | window | The window to create the surface for. |
void* | allocator | The allocator to use, or |
VkHandle | surface | Where to store the handle of the surface.
This is set to |
Returns
Type | Description |
---|---|
int |
|
Remarks
This function creates a Vulkan surface for the specified window.
If the Vulkan loader or at least one minimally functional ICD were not found,
this function returns VK_ERROR_INITIALIZATION_FAILED
and generates a
ApiUnavailable error.
Call VulkanSupported() to check whether Vulkan is at least minimally available.
If the required window surface creation instance extensions are not available or
if the specified instance was not created with these extensions enabled,
this function returns VK_ERROR_EXTENSION_NOT_PRESENT
and generates a
ApiUnavailable error.
Call GetRequiredInstanceExtensions() to check what instance extensions are required.
The window surface cannot be shared with another API so the window must have been created with
the client api hint set to NoApi otherwise it generates a
InvalidValue error and returns VK_ERROR_NATIVE_WINDOW_IN_USE_KHR
.
The window surface must be destroyed before the specified Vulkan instance.
It is the responsibility of the caller to destroy the window surface.
GLFW does not destroy it for you. Call vkDestroySurfaceKHR
to destroy the surface.
Possible errors include NotInitialized, ApiUnavailable, PlatformError and InvalidValue.
If an error occurs before the creation call is made, GLFW returns the Vulkan error code most appropriate for the error. Appropriate use of VulkanSupported() and GetRequiredInstanceExtensions() should eliminate almost all occurrences of these errors.
macOS: This function currently only supports the VK_MVK_macos_surface
extension from MoltenVK.
macOS: This function creates and sets a CAMetalLayer
instance for the window content view,
which is required for MoltenVK to function.
This function may be called from any thread. For synchronization details of Vulkan objects, see the Vulkan specification.
DefaultWindowHints()
This function resets all window hints to their default values.
Declaration
public static void DefaultWindowHints()
Remarks
This function must only be called from the main thread.
DestroyCursor(Cursor*)
This function destroys a cursor previously created with CreateCursor(in Image, int, int). Any remaining cursors will be destroyed by Terminate().
If the specified cursor is current for any window, that window will be reverted to the default cursor. This does not affect the cursor mode.
Declaration
public static void DestroyCursor(Cursor* cursor)
Parameters
Type | Name | Description |
---|---|---|
Cursor* | cursor | The cursor object to destroy. |
Remarks
This function must not be called from a callback.
This function must only be called from the main thread.
Possible errors include NotInitialized and PlatformError.
DestroyWindow(Window*)
This function destroys the specified window and its context. On calling this function, no further callbacks will be called for that window.
If the context of the specified window is current on the main thread, it is detached before being destroyed.
Declaration
public static void DestroyWindow(Window* window)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window to destroy. |
Remarks
The context of the specified window must not be current on any other thread when this function is called.
This function must not be called from a callback.
This function must only be called from the main thread.
Possible errors include NotInitialized and PlatformError.
See Also
ExtensionSupported(string)
This function returns whether the specified API extension is supported by the current OpenGL or OpenGL ES context. It searches both for client API extension and context creation API extensions.
A context must be current on the calling thread. Calling this function without a current context will cause a NoWindowContext error.
As this functions retrieves and searches one or more extension strings each call, it is recommended that you cache its results if it is going to be used frequently. The extension strings will not change during the lifetime of a context, so there is no danger in doing this.
Declaration
public static bool ExtensionSupported(string extensionName)
Parameters
Type | Name | Description |
---|---|---|
string | extensionName | The ASCII encoded name of the extension. |
Returns
Type | Description |
---|---|
bool |
|
Remarks
This function may be called from any thread.
Possible errors include NotInitialized, NoContext, InvalidValue and PlatformError.
ExtensionSupportedRaw(byte*)
This function returns whether the specified API extension is supported by the current OpenGL or OpenGL ES context. It searches both for client API extension and context creation API extensions.
A context must be current on the calling thread. Calling this function without a current context will cause a NoWindowContext error.
As this functions retrieves and searches one or more extension strings each call, it is recommended that you cache its results if it is going to be used frequently. The extension strings will not change during the lifetime of a context, so there is no danger in doing this.
Declaration
public static bool ExtensionSupportedRaw(byte* extensionName)
Parameters
Type | Name | Description |
---|---|---|
byte* | extensionName | The ASCII encoded name of the extension. |
Returns
Type | Description |
---|---|
bool |
|
Remarks
This function may be called from any thread.
Possible errors include NotInitialized, NoContext, InvalidValue and PlatformError.
FocusWindow(Window*)
This function brings the specified window to front and sets input focus. The window should already be visible and not iconified.
By default, both windowed and full screen mode windows are focused when initially created. Set the Focused to disable this behavior.
Do not use this function to steal focus from other applications unless you are certain that is what the user wants. Focus stealing can be extremely disruptive.
Declaration
public static void FocusWindow(Window* window)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window to give input focus. |
Remarks
This function must only be called from the main thread.
Possible errors include NotInitialized and PlatformError.
GetClipboardString(Window*)
This function returns the contents of the system clipboard, if it contains or is convertible to a UTF-8 encoded string.
Declaration
public static string GetClipboardString(Window* window)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window that will request the clipboard contents. |
Returns
Type | Description |
---|---|
string | The contents of the clipboard as a UTF-8 encoded string, or |
Remarks
This function may only be called from the main thread.
The returned string is allocated and freed by GLFW. You should not free it yourself. The returned string is valid only until the next call to GetClipboardString(Window*) or SetClipboardString(Window*, string).
Possible errors include NotInitialized and PlatformError.
See Also
GetClipboardStringRaw(Window*)
This function returns the contents of the system clipboard, if it contains or is convertible to a UTF-8 encoded string.
Declaration
public static byte* GetClipboardStringRaw(Window* window)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window that will request the clipboard contents. |
Returns
Type | Description |
---|---|
byte* | The contents of the clipboard as a UTF-8 encoded string, or |
Remarks
This function may only be called from the main thread.
The returned string is allocated and freed by GLFW. You should not free it yourself. The returned string is valid only until the next call to GetClipboardString(Window*) or SetClipboardString(Window*, string).
Possible errors include NotInitialized and PlatformError.
See Also
GetCocoaMonitor(Monitor*)
Returns the CGDirectDisplayID
of the specified monitor.
Declaration
public static uint GetCocoaMonitor(Monitor* monitor)
Parameters
Type | Name | Description |
---|---|---|
Monitor* | monitor | The monitor to query. |
Returns
Type | Description |
---|---|
uint | The |
GetCocoaWindow(Window*)
Returns the NSWindow
of the specified window.
Declaration
public static IntPtr GetCocoaWindow(Window* window)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window to query. |
Returns
Type | Description |
---|---|
IntPtr | The |
GetCurrentContext()
This function returns the window whose OpenGL or OpenGL ES context is current on the calling thread.
Declaration
public static Window* GetCurrentContext()
Returns
Type | Description |
---|---|
Window* | The window whose context is current, or |
Remarks
This function may be called from any thread.
Possible errors include NotInitialized.
GetCursorPos(Window*, out double, out double)
This function returns the position of the cursor, in screen coordinates, relative to the upper-left corner of the client area of the specified window.
If the cursor is disabled (with CursorDisabled) then the cursor position is unbounded and limited only by the minimum and maximum values of a double.
The coordinate can be converted to their integer equivalents with the floor function. Casting directly to an integer type works for positive coordinates, but fails for negative ones.
Any or all of the position arguments may be out _
.
If an error occurs, all non-out _
position arguments will be set to zero.
Declaration
public static void GetCursorPos(Window* window, out double xPos, out double yPos)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The desired window. |
double | xPos | Where to store the cursor x-coordinate, relative to the left edge of the client area, or |
double | yPos | Where to store the cursor y-coordinate, relative to the to top edge of the client area, or |
Remarks
This function must only be called from the main thread.
Possible errors include NotInitialized and PlatformError.
GetCursorPosRaw(Window*, double*, double*)
This function returns the position of the cursor, in screen coordinates, relative to the upper-left corner of the client area of the specified window.
If the cursor is disabled (with CursorDisabled) then the cursor position is unbounded and limited only by the minimum and maximum values of a double.
The coordinate can be converted to their integer equivalents with the floor function. Casting directly to an integer type works for positive coordinates, but fails for negative ones.
Any or all of the position arguments may be out _
.
If an error occurs, all non-out _
position arguments will be set to zero.
Declaration
public static void GetCursorPosRaw(Window* window, double* xPos, double* yPos)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The desired window. |
double* | xPos | Where to store the cursor x-coordinate, relative to the left edge of the client area, or |
double* | yPos | Where to store the cursor y-coordinate, relative to the to top edge of the client area, or |
Remarks
This function must only be called from the main thread.
Possible errors include NotInitialized and PlatformError.
GetEGLContext(Window*)
Returns the EGLContext
of the specified window.
Declaration
public static IntPtr GetEGLContext(Window* window)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window to get the context from. |
Returns
Type | Description |
---|---|
IntPtr | The |
GetEGLDisplay()
Returns the EGLDisplay
used by GLFW.
Declaration
public static IntPtr GetEGLDisplay()
Returns
Type | Description |
---|---|
IntPtr | The |
GetEGLSurface(Window*)
Returns the EGLSurface
of the specified window.
Declaration
public static IntPtr GetEGLSurface(Window* window)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window to query. |
Returns
Type | Description |
---|---|
IntPtr | The |
GetError(out string)
This function returns and clears the error code of the last error that occurred on the calling thread, and optionally a UTF-8 encoded human-readable description of it.
If no error has occurred since the last call,
it returns NoError (zero) and the description pointer is set to null
.
Declaration
public static ErrorCode GetError(out string description)
Parameters
Type | Name | Description |
---|---|---|
string | description | Where to store the error description pointer, or |
Returns
Type | Description |
---|---|
ErrorCode | The last error code for the calling thread, or NoError (zero). |
Remarks
The returned string is allocated and freed by GLFW. You should not free it yourself. It is only guaranteed to be valid until the next error occurs or the library is terminated.
This function may be called before Init().
This function may be called from any thread.
See Also
GetErrorRaw(out byte*)
This function returns and clears the error code of the last error that occurred on the calling thread, and optionally a UTF-8 encoded human-readable description of it.
If no error has occurred since the last call,
it returns NoError (zero) and the description pointer is set to null
.
Declaration
public static ErrorCode GetErrorRaw(out byte* description)
Parameters
Type | Name | Description |
---|---|---|
byte* | description | Where to store the error description pointer, or |
Returns
Type | Description |
---|---|
ErrorCode | The last error code for the calling thread, or NoError (zero). |
Remarks
The returned string is allocated and freed by GLFW. You should not free it yourself. It is only guaranteed to be valid until the next error occurs or the library is terminated.
This function may be called before Init().
This function may be called from any thread.
See Also
GetFramebufferSize(Window*, out int, out int)
This function retrieves the size, in pixels, of the framebuffer of the specified window. If you wish to retrieve the size of the window in screen coordinates, see GetWindowSize(Window*, out int, out int).
Any or all of the size arguments may be out _
.
If an error occurs, all non-out _
size arguments will be set to zero.
Declaration
public static void GetFramebufferSize(Window* window, out int width, out int height)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window whose framebuffer to query. |
int | width | Where to store the width, in pixels, of the framebuffer. |
int | height | Where to store the height, in pixels, of the framebuffer. |
Remarks
This function must only be called from the main thread.
Possible errors include NotInitialized and PlatformError.
GetFramebufferSizeRaw(Window*, int*, int*)
This function retrieves the size, in pixels, of the framebuffer of the specified window. If you wish to retrieve the size of the window in screen coordinates, see GetWindowSize(Window*, out int, out int).
Any or all of the size arguments may be out _
.
If an error occurs, all non-out _
size arguments will be set to zero.
Declaration
public static void GetFramebufferSizeRaw(Window* window, int* width, int* height)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window whose framebuffer to query. |
int* | width | Where to store the width, in pixels, of the framebuffer. |
int* | height | Where to store the height, in pixels, of the framebuffer. |
Remarks
This function must only be called from the main thread.
Possible errors include NotInitialized and PlatformError.
GetGamepadName(int)
This function returns the human-readable name of the gamepad from the gamepad mapping assigned to the specified joystick.
If the specified joystick is not present or does not have a gamepad mapping
this function will return null
but will not generate an error.
Declaration
public static string GetGamepadName(int jid)
Parameters
Type | Name | Description |
---|---|---|
int | jid | The joystick to query. |
Returns
Type | Description |
---|---|
string | The UTF-8 encoded name of the gamepad, or |
Remarks
Call JoystickPresent(int) to check whether it is present regardless of whether it has a mapping.
The returned string is allocated and freed by GLFW. You should not free it yourself. It is valid until the specified joystick is disconnected, the gamepad mappings are updated or the library is terminated.
This function must only be called from the main thread.
GetGamepadNameRaw(int)
This function returns the human-readable name of the gamepad from the gamepad mapping assigned to the specified joystick.
If the specified joystick is not present or does not have a gamepad mapping
this function will return null
but will not generate an error.
Declaration
public static byte* GetGamepadNameRaw(int jid)
Parameters
Type | Name | Description |
---|---|---|
int | jid | The joystick to query. |
Returns
Type | Description |
---|---|
byte* | The UTF-8 encoded name of the gamepad, or |
Remarks
Call JoystickPresent(int) to check whether it is present regardless of whether it has a mapping.
The returned string is allocated and freed by GLFW. You should not free it yourself. It is valid until the specified joystick is disconnected, the gamepad mappings are updated or the library is terminated.
This function must only be called from the main thread.
GetGamepadState(int, out GamepadState)
This function retrieves the state of the specified joystick remapped to an Xbox-like gamepad.
If the specified joystick is not present or does not have a gamepad mapping
this function will return false
but will not generate an error.
Call JoystickPresent(int) to check whether it is present regardless of whether it has a mapping.
The Guide button may not be available for input as it is often hooked by the system or the Steam client.
Not all devices have all the buttons or axes provided by GamepadState. Unavailable buttons and axes will always report Release and 0.0 respectively.
Declaration
public static bool GetGamepadState(int jid, out GamepadState state)
Parameters
Type | Name | Description |
---|---|---|
int | jid | The joystick to query. |
GamepadState | state | The gamepad input state of the joystick. |
Returns
Type | Description |
---|---|
bool |
|
Remarks
This function must only be called from the main thread.
Possible errors include NotInitialized and InvalidEnum.
GetGamepadStateRaw(int, GamepadState*)
This function retrieves the state of the specified joystick remapped to an Xbox-like gamepad.
If the specified joystick is not present or does not have a gamepad mapping
this function will return false
but will not generate an error.
Call JoystickPresent(int) to check whether it is present regardless of whether it has a mapping.
The Guide button may not be available for input as it is often hooked by the system or the Steam client.
Not all devices have all the buttons or axes provided by GamepadState. Unavailable buttons and axes will always report Release and 0.0 respectively.
Declaration
public static bool GetGamepadStateRaw(int jid, GamepadState* state)
Parameters
Type | Name | Description |
---|---|---|
int | jid | The joystick to query. |
GamepadState* | state | The gamepad input state of the joystick. |
Returns
Type | Description |
---|---|
bool |
|
Remarks
This function must only be called from the main thread.
Possible errors include NotInitialized and InvalidEnum.
GetGammaRamp(Monitor*)
This function returns the current gamma ramp of the specified monitor.
Declaration
public static GammaRamp* GetGammaRamp(Monitor* monitor)
Parameters
Type | Name | Description |
---|---|---|
Monitor* | monitor | The monitor to query. |
Returns
Type | Description |
---|---|
GammaRamp* | The current gamma ramp, or |
Remarks
The returned structure and its arrays are allocated and freed by GLFW. You should not free them yourself. They are valid until the specified monitor is disconnected, this function is called again for that monitor or the library is terminated.
This function must only be called from the main thread.
Possible errors include NotInitialized and PlatformError.
GetGLXContext(Window*)
Returns the GLXContext
of the specified window.
Declaration
public static uint GetGLXContext(Window* window)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window to get the context from. |
Returns
Type | Description |
---|---|
uint | The |
GetGLXWindow(Window*)
Returns the GLXWindow
of the specified window.
Declaration
public static uint GetGLXWindow(Window* window)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window to query. |
Returns
Type | Description |
---|---|
uint | The |
GetInputMode(Window*, CursorStateAttribute)
This function returns the value of an input option for the specified window. The mode must be Cursor.
Declaration
public static CursorModeValue GetInputMode(Window* window, CursorStateAttribute mode)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window to query. |
CursorStateAttribute | mode |
Returns
Type | Description |
---|---|
CursorModeValue | The current cursor mode. |
Remarks
This function must only be called from the main thread.
Possible errors include NotInitialized and InvalidEnum.
See Also
GetInputMode(Window*, LockKeyModAttribute)
This function returns the value of an input option for the specified window. The mode must be LockKeyMods.
Declaration
public static bool GetInputMode(Window* window, LockKeyModAttribute mode)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window to query. |
LockKeyModAttribute | mode |
Returns
Type | Description |
---|---|
bool | Whether or not lock key mods are enabled or not. |
Remarks
This function must only be called from the main thread.
Possible errors include NotInitialized and InvalidEnum.
See Also
GetInputMode(Window*, RawMouseMotionAttribute)
This function returns the value of an input option for the specified window. The mode must be RawMouseMotion.
Declaration
public static bool GetInputMode(Window* window, RawMouseMotionAttribute mode)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window to query. |
RawMouseMotionAttribute | mode |
Returns
Type | Description |
---|---|
bool | Whether raw mouse motion is enabled or disabled for this window. |
Remarks
This function must only be called from the main thread.
Possible errors include NotInitialized and InvalidEnum.
See Also
GetInputMode(Window*, StickyAttributes)
This function returns the value of an input option for the specified window. The mode must be StickyKeys or StickyMouseButtons.
Declaration
public static bool GetInputMode(Window* window, StickyAttributes mode)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window to query. |
StickyAttributes | mode | Either StickyKeys or StickyMouseButtons. |
Returns
Type | Description |
---|---|
bool | Whether sticky keys or sticky mouse buttons are enabled depending on the value of |
Remarks
This function must only be called from the main thread.
Possible errors include NotInitialized and InvalidEnum.
See Also
GetInstanceProcAddress(VkHandle, string)
Returns the address of the specified Vulkan instance function.
Declaration
public static IntPtr GetInstanceProcAddress(VkHandle instance, string procName)
Parameters
Type | Name | Description |
---|---|---|
VkHandle | instance | The Vulkan instance to query, or |
string | procName | The ASCII encoded name of the function. |
Returns
Type | Description |
---|---|
IntPtr | The address of the function, or |
Remarks
This function returns the address of the specified Vulkan core or extension function for
the specified instance. If instance is set to null
it can return any function exported
from the Vulkan loader, including at least the following functions:
vkEnumerateInstanceExtensionProperties
vkEnumerateInstanceLayerProperties
vkCreateInstance
vkGetInstanceProcAddr
If Vulkan is not available on the machine, this function returns null
and generates
a NotInitialized error. Call VulkanSupported() to check
whether Vulkan is at least minimally available.
This function is equivalent to calling vkGetInstanceProcAddr
with a platform-specific
query of the Vulkan loader as a fallback.
Possible errors include NotInitialized and ApiUnavailable.
The returned function pointer is valid until the library is terminated.
GetInstanceProcAddressRaw(VkHandle, byte*)
Returns the address of the specified Vulkan instance function.
Declaration
public static IntPtr GetInstanceProcAddressRaw(VkHandle instance, byte* procName)
Parameters
Type | Name | Description |
---|---|---|
VkHandle | instance | The Vulkan instance to query, or |
byte* | procName | The ASCII encoded name of the function. |
Returns
Type | Description |
---|---|
IntPtr | The address of the function, or |
Remarks
This function returns the address of the specified Vulkan core or extension function for
the specified instance. If instance is set to null
it can return any function exported
from the Vulkan loader, including at least the following functions:
vkEnumerateInstanceExtensionProperties
vkEnumerateInstanceLayerProperties
vkCreateInstance
vkGetInstanceProcAddr
If Vulkan is not available on the machine, this function returns null
and generates
a NotInitialized error. Call VulkanSupported() to check
whether Vulkan is at least minimally available.
This function is equivalent to calling vkGetInstanceProcAddr
with a platform-specific
query of the Vulkan loader as a fallback.
Possible errors include NotInitialized and ApiUnavailable.
The returned function pointer is valid until the library is terminated.
GetJoystickAxes(int)
This function returns the values of all axes of the specified joystick. Each element in the array is a value between -1.0 and 1.0.
If the specified joystick is not present
this function will return null
but will not generate an error.
This can be used instead of first calling JoystickPresent(int).
Declaration
public static ReadOnlySpan<float> GetJoystickAxes(int jid)
Parameters
Type | Name | Description |
---|---|---|
int | jid | The joystick to query. |
Returns
Type | Description |
---|---|
ReadOnlySpan<float> | An array of axis values, or |
Remarks
The returned array is allocated and freed by GLFW. You should not free it yourself. It is valid until the specified joystick is disconnected or the library is terminated.
This function must only be called from the main thread.
Possible errors include NotInitialized, InvalidEnum and PlatformError.
GetJoystickAxesRaw(int, out int)
This function returns the values of all axes of the specified joystick. Each element in the array is a value between -1.0 and 1.0.
If the specified joystick is not present
this function will return null
but will not generate an error.
This can be used instead of first calling JoystickPresent(int).
Declaration
public static float* GetJoystickAxesRaw(int jid, out int count)
Parameters
Type | Name | Description |
---|---|---|
int | jid | The joystick to query. |
int | count | Where to store the number of axis values in the returned array. This is set to zero if the joystick is not present or an error occurred. |
Returns
Type | Description |
---|---|
float* | An array of axis values, or |
Remarks
The returned array is allocated and freed by GLFW. You should not free it yourself. It is valid until the specified joystick is disconnected or the library is terminated.
This function must only be called from the main thread.
Possible errors include NotInitialized, InvalidEnum and PlatformError.
GetJoystickAxesRaw(int, int*)
This function returns the values of all axes of the specified joystick. Each element in the array is a value between -1.0 and 1.0.
If the specified joystick is not present
this function will return null
but will not generate an error.
This can be used instead of first calling JoystickPresent(int).
Declaration
public static float* GetJoystickAxesRaw(int jid, int* count)
Parameters
Type | Name | Description |
---|---|---|
int | jid | The joystick to query. |
int* | count | Where to store the number of axis values in the returned array. This is set to zero if the joystick is not present or an error occurred. |
Returns
Type | Description |
---|---|
float* | An array of axis values, or |
Remarks
The returned array is allocated and freed by GLFW. You should not free it yourself. It is valid until the specified joystick is disconnected or the library is terminated.
This function must only be called from the main thread.
Possible errors include NotInitialized, InvalidEnum and PlatformError.
GetJoystickButtons(int)
This function returns the state of all buttons of the specified joystick. Each element in the array is either Press or Release.
For backward compatibility with earlier versions that did not have GetJoystickHats(int), the button array also includes all hats, each represented as four buttons.
The hats are in the same order as returned by GetJoystickHats(int) and are in the order up, right, down and left.
To disable these extra buttons, set the JoystickHatButtons init hint before initialization.
If the specified joystick is not present this function will return null
but will not generate an error.
This can be used instead of first calling JoystickPresent(int).
Declaration
public static ReadOnlySpan<JoystickInputAction> GetJoystickButtons(int jid)
Parameters
Type | Name | Description |
---|---|---|
int | jid | The joystick to query. |
Returns
Type | Description |
---|---|
ReadOnlySpan<JoystickInputAction> | An array of button states, or |
Remarks
The returned array is allocated and freed by GLFW. You should not free it yourself. It is valid until the specified joystick is disconnected or the library is terminated.
This function must only be called from the main thread.
Possible errors include NotInitialized, InvalidEnum and PlatformError.
GetJoystickButtonsRaw(int, out int)
This function returns the state of all buttons of the specified joystick. Each element in the array is either Press or Release.
For backward compatibility with earlier versions that did not have GetJoystickHats(int), the button array also includes all hats, each represented as four buttons.
The hats are in the same order as returned by GetJoystickHats(int) and are in the order up, right, down and left.
To disable these extra buttons, set the JoystickHatButtons init hint before initialization.
If the specified joystick is not present this function will return null
but will not generate an error.
This can be used instead of first calling JoystickPresent(int).
Declaration
public static JoystickInputAction* GetJoystickButtonsRaw(int jid, out int count)
Parameters
Type | Name | Description |
---|---|---|
int | jid | The joystick to query. |
int | count | Where to store the number of button states in the returned array. This is set to zero if the joystick is not present or an error occurred. |
Returns
Type | Description |
---|---|
JoystickInputAction* | An array of button states, or |
Remarks
The returned array is allocated and freed by GLFW. You should not free it yourself. It is valid until the specified joystick is disconnected or the library is terminated.
This function must only be called from the main thread.
Possible errors include NotInitialized, InvalidEnum and PlatformError.
GetJoystickButtonsRaw(int, int*)
This function returns the state of all buttons of the specified joystick. Each element in the array is either Press or Release.
For backward compatibility with earlier versions that did not have GetJoystickHats(int), the button array also includes all hats, each represented as four buttons.
The hats are in the same order as returned by GetJoystickHats(int) and are in the order up, right, down and left.
To disable these extra buttons, set the JoystickHatButtons init hint before initialization.
If the specified joystick is not present this function will return null
but will not generate an error.
This can be used instead of first calling JoystickPresent(int).
Declaration
public static JoystickInputAction* GetJoystickButtonsRaw(int jid, int* count)
Parameters
Type | Name | Description |
---|---|---|
int | jid | The joystick to query. |
int* | count | Where to store the number of button states in the returned array. This is set to zero if the joystick is not present or an error occurred. |
Returns
Type | Description |
---|---|
JoystickInputAction* | An array of button states, or |
Remarks
The returned array is allocated and freed by GLFW. You should not free it yourself. It is valid until the specified joystick is disconnected or the library is terminated.
This function must only be called from the main thread.
Possible errors include NotInitialized, InvalidEnum and PlatformError.
GetJoystickGUID(int)
This function returns the SDL compatible GUID, as a UTF-8 encoded hexadecimal string, of the specified joystick. The returned string is allocated and freed by GLFW. You should not free it yourself.
The GUID is what connects a joystick to a gamepad mapping. A connected joystick will always have a GUID even if there is no gamepad mapping assigned to it.
If the specified joystick is not present this function will return null
but will not generate an error.
This can be used instead of first calling JoystickPresent(int).
The GUID uses the format introduced in SDL 2.0.5. This GUID tries to uniquely identify the make and model of a joystick but does not identify a specific unit, e.g. all wired Xbox 360 controllers will have the same GUID on that platform. The GUID for a unit may vary between platforms depending on what hardware information the platform specific APIs provide.
Declaration
public static string GetJoystickGUID(int jid)
Parameters
Type | Name | Description |
---|---|---|
int | jid | The joystick to query. |
Returns
Type | Description |
---|---|
string | The UTF-8 encoded GUID of the joystick, or |
Remarks
The returned string is allocated and freed by GLFW. You should not free it yourself. It is valid until the specified joystick is disconnected or the library is terminated.
This function must only be called from the main thread.
Possible errors include NotInitialized, InvalidEnum and PlatformError.
GetJoystickGUIDRaw(int)
This function returns the SDL compatible GUID, as a UTF-8 encoded hexadecimal string, of the specified joystick. The returned string is allocated and freed by GLFW. You should not free it yourself.
The GUID is what connects a joystick to a gamepad mapping. A connected joystick will always have a GUID even if there is no gamepad mapping assigned to it.
If the specified joystick is not present this function will return null
but will not generate an error.
This can be used instead of first calling JoystickPresent(int).
The GUID uses the format introduced in SDL 2.0.5. This GUID tries to uniquely identify the make and model of a joystick but does not identify a specific unit, e.g. all wired Xbox 360 controllers will have the same GUID on that platform. The GUID for a unit may vary between platforms depending on what hardware information the platform specific APIs provide.
Declaration
public static byte* GetJoystickGUIDRaw(int jid)
Parameters
Type | Name | Description |
---|---|---|
int | jid | The joystick to query. |
Returns
Type | Description |
---|---|
byte* | The UTF-8 encoded GUID of the joystick, or |
Remarks
The returned string is allocated and freed by GLFW. You should not free it yourself. It is valid until the specified joystick is disconnected or the library is terminated.
This function must only be called from the main thread.
Possible errors include NotInitialized, InvalidEnum and PlatformError.
GetJoystickHats(int)
This function returns the state of all hats of the specified joystick. Each element in the array is one of the JoystickHats.
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.
if (hats[2].HasFlag(JoystickHats.Right))
{
// State of hat 2 could be right-up, right or right-down
}
If the specified joystick is not present, this function will return NULL but will not generate an error. This can be used instead of first calling JoystickPresent(int).
Declaration
public static ReadOnlySpan<JoystickHats> GetJoystickHats(int jid)
Parameters
Type | Name | Description |
---|---|---|
int | jid | The joystick to query. |
Returns
Type | Description |
---|---|
ReadOnlySpan<JoystickHats> | An array of hat states, or |
Remarks
The returned array is allocated and freed by GLFW. You should not free it yourself It is valid until the specified joystick is disconnected, this function is called again for that joystick or the library is terminated.
This function must only be called from the main thread.
Possible errors include NotInitialized, InvalidEnum and PlatformError.
GetJoystickHatsRaw(int, out int)
This function returns the state of all hats of the specified joystick. Each element in the array is one of the JoystickHats.
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.
if (hats[2].HasFlag(JoystickHats.Right))
{
// State of hat 2 could be right-up, right or right-down
}
If the specified joystick is not present, this function will return NULL but will not generate an error. This can be used instead of first calling JoystickPresent(int).
Declaration
public static JoystickHats* GetJoystickHatsRaw(int jid, out int count)
Parameters
Type | Name | Description |
---|---|---|
int | jid | The joystick to query. |
int | count | Where to store the number of hat states in the returned array. This is set to zero if the joystick is not present or an error occurred. |
Returns
Type | Description |
---|---|
JoystickHats* | An array of hat states, or |
Remarks
The returned array is allocated and freed by GLFW. You should not free it yourself It is valid until the specified joystick is disconnected, this function is called again for that joystick or the library is terminated.
This function must only be called from the main thread.
Possible errors include NotInitialized, InvalidEnum and PlatformError.
GetJoystickHatsRaw(int, int*)
This function returns the state of all hats of the specified joystick. Each element in the array is one of the JoystickHats.
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.
if (hats[2].HasFlag(JoystickHats.Right))
{
// State of hat 2 could be right-up, right or right-down
}
If the specified joystick is not present, this function will return NULL but will not generate an error. This can be used instead of first calling JoystickPresent(int).
Declaration
public static JoystickHats* GetJoystickHatsRaw(int jid, int* count)
Parameters
Type | Name | Description |
---|---|---|
int | jid | The joystick to query. |
int* | count | Where to store the number of hat states in the returned array. This is set to zero if the joystick is not present or an error occurred. |
Returns
Type | Description |
---|---|
JoystickHats* | An array of hat states, or |
Remarks
The returned array is allocated and freed by GLFW. You should not free it yourself It is valid until the specified joystick is disconnected, this function is called again for that joystick or the library is terminated.
This function must only be called from the main thread.
Possible errors include NotInitialized, InvalidEnum and PlatformError.
GetJoystickName(int)
This function returns the name, encoded as UTF-8, of the specified joystick.
If the specified joystick is not present this function will return null
but will not generate an error.
This can be used instead of first calling JoystickPresent(int).
Declaration
public static string GetJoystickName(int jid)
Parameters
Type | Name | Description |
---|---|---|
int | jid | The joystick to query. |
Returns
Type | Description |
---|---|
string | The UTF-8 encoded name of the joystick, or |
Remarks
The returned string is allocated and freed by GLFW. You should not free it yourself. It is valid until the specified joystick is disconnected or the library is terminated.
This function must only be called from the main thread.
Possible errors include NotInitialized, InvalidEnum and PlatformError.
GetJoystickNameRaw(int)
This function returns the name, encoded as UTF-8, of the specified joystick.
If the specified joystick is not present this function will return null
but will not generate an error.
This can be used instead of first calling JoystickPresent(int).
Declaration
public static byte* GetJoystickNameRaw(int jid)
Parameters
Type | Name | Description |
---|---|---|
int | jid | The joystick to query. |
Returns
Type | Description |
---|---|
byte* | The UTF-8 encoded name of the joystick, or |
Remarks
The returned string is allocated and freed by GLFW. You should not free it yourself. It is valid until the specified joystick is disconnected or the library is terminated.
This function must only be called from the main thread.
Possible errors include NotInitialized, InvalidEnum and PlatformError.
GetJoystickUserPointer(int)
This function returns the current value of the user-defined pointer of the specified joystick. The initial value is Zero.
This function may be called from the joystick callback, even for a joystick that is being disconnected.
Declaration
public static void* GetJoystickUserPointer(int jid)
Parameters
Type | Name | Description |
---|---|---|
int | jid | The joystick whose pointer to return. |
Returns
Type | Description |
---|---|
void* | The user-defined pointer of the given |
Remarks
This function may be called from any thread. Access is not synchronized.
Possible errors include NotInitialized.
GetKey(Window*, Keys)
This function returns the last state reported for the specified key to the specified window. The returned state is one of Press or Release. The higher-level action Repeat is only reported to the key callback.
If the StickyKeys input mode is enabled, this function returns Press the first time you call it for a key that was pressed, even if that key has already been released.
The key functions deal with physical keys, with key tokens named after their use on the standard US keyboard layout. If you want to input text, use the Unicode character callback instead.
The modifier key bit masks are not key tokens and cannot be used with this function.
Do not use this function to implement text input.
Declaration
public static InputAction GetKey(Window* window, Keys key)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The desired window. |
Keys | key | The desired keyboard key. Unknown is not a valid key for this function. |
Returns
Type | Description |
---|---|
InputAction |
Remarks
This function must only be called from the main thread.
Possible errors include NotInitialized and InvalidEnum.
GetKeyName(Keys, int)
This function returns the name of the specified printable key, encoded as UTF-8. This is typically the character that key would produce without any modifier keys, intended for displaying key bindings to the user.
For dead keys, it is typically the diacritic it would add to a character.
Do not use this function for text input. You will break text input for many languages even if it happens to work for yours.
If the key is Unknown, the scancode is used to identify the key, otherwise the scancode is ignored.
If you specify a non-printable key, or Unknown and a scancode that maps to a non-printable key,
this function returns null
but does not emit an error.
This behavior allows you to always pass in the arguments in the key callback without modification.
The printable keys are:
Names for printable keys depend on keyboard layout, while names for non-printable keys are the same across layouts but depend on the application language and should be localized along with other user interface text.
Declaration
public static string GetKeyName(Keys key, int scanCode)
Parameters
Type | Name | Description |
---|---|---|
Keys | key | The key to query, or Unknown. |
int | scanCode | The scancode of the key to query. |
Returns
Type | Description |
---|---|
string | The UTF-8 encoded, layout-specific name of the key, or |
Remarks
The returned string is allocated and freed by GLFW. You should not free it yourself. It is valid until the next call to GetKeyName(Keys, int), or until the library is terminated.
This function must only be called from the main thread.
Possible errors include NotInitialized and PlatformError.
GetKeyNameRaw(Keys, int)
This function returns the name of the specified printable key, encoded as UTF-8. This is typically the character that key would produce without any modifier keys, intended for displaying key bindings to the user.
For dead keys, it is typically the diacritic it would add to a character.
Do not use this function for text input. You will break text input for many languages even if it happens to work for yours.
If the key is Unknown, the scancode is used to identify the key, otherwise the scancode is ignored.
If you specify a non-printable key, or Unknown and a scancode that maps to a non-printable key,
this function returns null
but does not emit an error.
This behavior allows you to always pass in the arguments in the key callback without modification.
The printable keys are:
Names for printable keys depend on keyboard layout, while names for non-printable keys are the same across layouts but depend on the application language and should be localized along with other user interface text.
Declaration
public static byte* GetKeyNameRaw(Keys key, int scancode)
Parameters
Type | Name | Description |
---|---|---|
Keys | key | The key to query, or Unknown. |
int | scancode | The scancode of the key to query. |
Returns
Type | Description |
---|---|
byte* | The UTF-8 encoded, layout-specific name of the key, or |
Remarks
The returned string is allocated and freed by GLFW. You should not free it yourself. It is valid until the next call to GetKeyName(Keys, int), or until the library is terminated.
This function must only be called from the main thread.
Possible errors include NotInitialized and PlatformError.
GetKeyScancode(Keys)
This function returns the platform-specific scancode of the specified key.
If the key is Unknown or does not exist on the keyboard this method will return -1.
Declaration
public static int GetKeyScancode(Keys key)
Parameters
Type | Name | Description |
---|---|---|
Keys | key | Any named key. |
Returns
Type | Description |
---|---|
int | The platform-specific scancode for the key, or -1 if an error occurred. |
Remarks
This function may be called from any thread.
Possible errors include NotInitialized, InvalidEnum and PlatformError.
GetMonitorContentScale(Monitor*, out float, out float)
This function retrieves the content scale for the specified monitor.
The content scale is the ratio between the current DPI and the platform's default DPI.
If you scale all pixel dimensions by this scale then your content should appear at an appropriate size. This is especially important for text and any UI elements.
The content scale may depend on both the monitor resolution and pixel density and on user settings. It may be very different from the raw DPI calculated from the physical size and current resolution.
Declaration
public static void GetMonitorContentScale(Monitor* monitor, out float xScale, out float yScale)
Parameters
Type | Name | Description |
---|---|---|
Monitor* | monitor | The monitor to query. |
float | xScale | Where to store the x-axis content scale, or |
float | yScale | Where to store the y-axis content scale, or |
GetMonitorContentScaleRaw(Monitor*, float*, float*)
This function retrieves the content scale for the specified monitor.
The content scale is the ratio between the current DPI and the platform's default DPI.
If you scale all pixel dimensions by this scale then your content should appear at an appropriate size. This is especially important for text and any UI elements.
The content scale may depend on both the monitor resolution and pixel density and on user settings. It may be very different from the raw DPI calculated from the physical size and current resolution.
Declaration
public static void GetMonitorContentScaleRaw(Monitor* monitor, float* xScale, float* yScale)
Parameters
Type | Name | Description |
---|---|---|
Monitor* | monitor | The monitor to query. |
float* | xScale | Where to store the x-axis content scale, or |
float* | yScale | Where to store the y-axis content scale, or |
GetMonitorName(Monitor*)
This function returns a human-readable name, encoded as UTF-8, of the specified monitor. The name typically reflects the make and model of the monitor and is not guaranteed to be unique among the connected monitors.
Declaration
public static string GetMonitorName(Monitor* monitor)
Parameters
Type | Name | Description |
---|---|---|
Monitor* | monitor | The monitor to query. |
Returns
Type | Description |
---|---|
string | The UTF-8 encoded name of the monitor, or |
Remarks
The returned string is allocated and freed by GLFW. You should not free it yourself. It is valid until the specified monitor is disconnected or the library is terminated.
This function must only be called from the main thread.
Possible errors include NotInitialized.
GetMonitorNameRaw(Monitor*)
This function returns a human-readable name, encoded as UTF-8, of the specified monitor. The name typically reflects the make and model of the monitor and is not guaranteed to be unique among the connected monitors.
Declaration
public static byte* GetMonitorNameRaw(Monitor* monitor)
Parameters
Type | Name | Description |
---|---|---|
Monitor* | monitor | The monitor to query. |
Returns
Type | Description |
---|---|
byte* | The UTF-8 encoded name of the monitor, or |
Remarks
The returned string is allocated and freed by GLFW. You should not free it yourself. It is valid until the specified monitor is disconnected or the library is terminated.
This function must only be called from the main thread.
Possible errors include NotInitialized.
GetMonitorPhysicalSize(Monitor*, out int, out int)
This function returns the size, in millimetres, of the display area of the specified monitor.
Some systems do not provide accurate monitor size information, either because the monitor EDID(Extended Display Identification Data) data is incorrect or because the driver does not report it accurately.
Any or all of the size arguments may be out _
.
If an error occurs, all non-out _
size arguments will be set to zero.
Declaration
public static void GetMonitorPhysicalSize(Monitor* monitor, out int width, out int height)
Parameters
Type | Name | Description |
---|---|---|
Monitor* | monitor | The monitor to query. |
int | width | Where to store the width, in millimetres, of the monitor's display area, or |
int | height | Where to store the height, in millimetres, of the monitor's display area, or |
Remarks
Windows: calculates the returned physical size from the current resolution and system DPI instead of querying the monitor EDID data.
This function must only be called from the main thread.
Possible errors include NotInitialized.
GetMonitorPos(Monitor*, out int, out int)
This function returns the position, in screen coordinates, of the upper-left corner of the specified monitor.
Declaration
public static void GetMonitorPos(Monitor* monitor, out int x, out int y)
Parameters
Type | Name | Description |
---|---|---|
Monitor* | monitor | The monitor to query. |
int | x | Where to store the monitor x-coordinate, or |
int | y | Where to store the monitor y-coordinate, or |
Remarks
This function must only be called from the main thread.
Possible errors include NotInitialized and PlatformError.
GetMonitorPos(Monitor*, int*, int*)
This function returns the position, in screen coordinates, of the upper-left corner of the specified monitor.
Declaration
public static void GetMonitorPos(Monitor* monitor, int* x, int* y)
Parameters
Type | Name | Description |
---|---|---|
Monitor* | monitor | The monitor to query. |
int* | x | Where to store the monitor x-coordinate. |
int* | y | Where to store the monitor y-coordinate. |
Remarks
This function must only be called from the main thread.
Possible errors include NotInitialized and PlatformError.
GetMonitors()
This function returns an array of handles for all currently connected monitors. The primary monitor is always first in the returned array.
If no monitors were found, this function returns null
.
Declaration
public static Monitor*[] GetMonitors()
Returns
Type | Description |
---|---|
Monitor*[] | An array of monitor handles, or |
Remarks
The returned array is allocated and freed by GLFW. You should not free it yourself. It is only guaranteed to be valid until the monitor configuration changes or the library is terminated.
This function must only be called from the main thread.
Possible errors include NotInitialized.
See Also
GetMonitorsRaw(out int)
This function returns an array of handles for all currently connected monitors. The primary monitor is always first in the returned array.
If no monitors were found, this function returns null
.
Declaration
public static Monitor** GetMonitorsRaw(out int count)
Parameters
Type | Name | Description |
---|---|---|
int | count | Where to store the number of monitors in the returned array. This is set to zero if an error occurred. |
Returns
Type | Description |
---|---|
Monitor** | An array of monitor handles, or |
Remarks
The returned array is allocated and freed by GLFW. You should not free it yourself. It is only guaranteed to be valid until the monitor configuration changes or the library is terminated.
This function must only be called from the main thread.
Possible errors include NotInitialized.
See Also
GetMonitorsRaw(int*)
This function returns an array of handles for all currently connected monitors. The primary monitor is always first in the returned array.
If no monitors were found, this function returns null
.
Declaration
public static Monitor** GetMonitorsRaw(int* count)
Parameters
Type | Name | Description |
---|---|---|
int* | count | Where to store the number of monitors in the returned array. This is set to zero if an error occurred. |
Returns
Type | Description |
---|---|
Monitor** | An array of monitor handles, or |
Remarks
The returned array is allocated and freed by GLFW. You should not free it yourself. It is only guaranteed to be valid until the monitor configuration changes or the library is terminated.
This function must only be called from the main thread.
Possible errors include NotInitialized.
See Also
GetMonitorUserPointer(Monitor*)
This function returns the current value of the user-defined pointer of the specified monitor. The initial value is Zero.
This function may be called from the monitor callback, even for a monitor that is being disconnected.
Declaration
public static void* GetMonitorUserPointer(Monitor* monitor)
Parameters
Type | Name | Description |
---|---|---|
Monitor* | monitor | The monitor whose pointer to return. |
Returns
Type | Description |
---|---|
void* | The user-defined pointer of the given |
Remarks
This function may be called from any thread. Access is not synchronized.
Possible errors include NotInitialized.
GetMonitorWorkarea(Monitor*, out int, out int, out int, out int)
This function returns the position, in screen coordinates, of the upper-left corner of the work area of the specified monitor along with the work area size in screen coordinates. The work area is defined as the area of the monitor not occluded by the operating system task bar where present. If no task bar exists then the work area is the monitor resolution in screen coordinates.
Any or all of the position and size arguments may be NULL. If an error occurs, all non-NULL position and size arguments will be set to zero.
Declaration
public static void GetMonitorWorkarea(Monitor* monitor, out int x, out int y, out int width, out int height)
Parameters
Type | Name | Description |
---|---|---|
Monitor* | monitor | The monitor to query. |
int | x | Where to store the monitor x-coordinate. |
int | y | Where to store the monitor y-coordinate. |
int | width | Where to store the monitor width. |
int | height | Where to store the monitor height. |
Remarks
This function must only be called from the main thread.
Possible errors include GLFW_NOT_INITIALIZED and GLFW_PLATFORM_ERROR.
Added in version GLFW 3.3.
GetMonitorWorkarea(Monitor*, int*, int*, int*, int*)
This function returns the position, in screen coordinates, of the upper-left corner of the work area of the specified monitor along with the work area size in screen coordinates. The work area is defined as the area of the monitor not occluded by the operating system task bar where present. If no task bar exists then the work area is the monitor resolution in screen coordinates.
Any or all of the position and size arguments may be NULL. If an error occurs, all non-NULL position and size arguments will be set to zero.
Declaration
public static void GetMonitorWorkarea(Monitor* monitor, int* x, int* y, int* width, int* height)
Parameters
Type | Name | Description |
---|---|---|
Monitor* | monitor | The monitor to query. |
int* | x | Where to store the monitor x-coordinate, or NULL. |
int* | y | Where to store the monitor y-coordinate, or NULL. |
int* | width | Where to store the monitor width, or NULL. |
int* | height | Where to store the monitor height, or NULL. |
Remarks
This function must only be called from the main thread.
Possible errors include GLFW_NOT_INITIALIZED and GLFW_PLATFORM_ERROR.
Added in version GLFW 3.3.
GetMouseButton(Window*, MouseButton)
This function returns the last state reported for the specified mouse button to the specified window. The returned state is one of Press or Release.
If the StickyMouseButtons input mode is enabled, this function returns Press the first time you call it for a mouse button that was pressed, even if that mouse button has already been released.
Declaration
public static InputAction GetMouseButton(Window* window, MouseButton button)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The desired window. |
MouseButton | button | The desired mouse button. |
Returns
Type | Description |
---|---|
InputAction |
Remarks
This function must only be called from the main thread.
Possible errors include NotInitialized and InvalidEnum.
GetNSGLContext(Window*)
Returns the NSOpenGLContext
of the specified window.
Declaration
public static IntPtr GetNSGLContext(Window* window)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window to query. |
Returns
Type | Description |
---|---|
IntPtr | The |
GetOSMesaColorBuffer(Window*, out int, out int, out int, out IntPtr)
Retrieves the color buffer associated with the specified window.
Declaration
public static bool GetOSMesaColorBuffer(Window* window, out int width, out int height, out int format, out IntPtr buffer)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window to query. |
int | width | The width of the color buffer. |
int | height | The height of the color buffer. |
int | format | The OSMesa pixel format of the color buffer. |
IntPtr | buffer | The addess of the color buffer. |
Returns
Type | Description |
---|---|
bool |
|
GetOSMesaContext(Window*)
This function returns the mesa context associated with the window.
Declaration
public static IntPtr GetOSMesaContext(Window* window)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window to get the context from. |
Returns
Type | Description |
---|---|
IntPtr | The OSMesaContext of the specified window, or NULL if an error occurred. |
GetOSMesaDepthBuffer(Window*, out int, out int, out int, out IntPtr)
Retrieves the depth buffer associated with the specified window.
Declaration
public static bool GetOSMesaDepthBuffer(Window* window, out int width, out int height, out int bytesPerValue, out IntPtr buffer)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window to query. |
int | width | The width of the depth buffer. |
int | height | The height of the depth buffer. |
int | bytesPerValue | The number of bytes per depth buffer element. |
IntPtr | buffer | The address of the depth buffer. |
Returns
Type | Description |
---|---|
bool |
|
GetPhysicalDevicePresentationSupport(VkHandle, VkHandle, int)
Returns whether the specified queue family can present images.
Declaration
public static bool GetPhysicalDevicePresentationSupport(VkHandle instance, VkHandle device, int queueFamily)
Parameters
Type | Name | Description |
---|---|---|
VkHandle | instance | The instance that the physical device belongs to. |
VkHandle | device | The physical device that the queue family belongs to. |
int | queueFamily | The index of the queue family to query. |
Returns
Type | Description |
---|---|
bool |
|
Remarks
This function returns whether the specified queue family of the specified physical device supports presentation to the platform GLFW was built for.
If Vulkan or the required window surface creation instance extensions are not available
on the machine, or if the specified instance was not created with the required extensions,
this function returns false
and generates a ApiUnavailable error.
Call VulkanSupported() to check whether Vulkan is at least minimally available and
GetRequiredInstanceExtensions() to check what instance extensions are required.
Possible errors include NotInitialized and ApiUnavailable.
macOS: This function currently always returns true
, as the VK_MVK_macos_surface
extension does not provide a vkGetPhysicalDevice*PresentationSupport
type function.
This function may be called from any thread. For synchronization details of Vulkan objects, see the Vulkan specification.
GetPrimaryMonitor()
This function returns the primary monitor.
This is usually the monitor where elements like the task bar or global menu bar are located.
Declaration
public static Monitor* GetPrimaryMonitor()
Returns
Type | Description |
---|---|
Monitor* | The primary monitor, or |
Remarks
This function must only be called from the main thread.
The primary monitor is always first in the array returned by GetMonitors().
Possible errors include NotInitialized.
GetProcAddress(string)
This function returns the address of the specified OpenGL or OpenGL ES core or extension function, if it is supported by the current context. A context must be current on the calling thread. Calling this function without a current context will cause a NoContext error.
Declaration
public static IntPtr GetProcAddress(string procName)
Parameters
Type | Name | Description |
---|---|---|
string | procName | The name of the function. |
Returns
Type | Description |
---|---|
IntPtr | The address of the function, or |
Remarks
This function does not apply to Vulkan. If you are rendering with Vulkan, see GetInstanceProcAddress(VkHandle, string), vkGetInstanceProcAddr
and vkGetDeviceProcAddr
instead.
Possible errors include NotInitialized, NoContext and PlatformError.
The address of a given function is not guaranteed to be the same between contexts.
This function may return a non-null
address despite the associated version or extension not being available. Always check the context version or extension string first.
The returned function pointer is valid until the context is destroyed or the library is terminated.
This function may be called from any thread.
See Also
GetProcAddressRaw(byte*)
This function returns the address of the specified OpenGL or OpenGL ES core or extension function, if it is supported by the current context. A context must be current on the calling thread. Calling this function without a current context will cause a NoContext error.
Declaration
public static IntPtr GetProcAddressRaw(byte* procName)
Parameters
Type | Name | Description |
---|---|---|
byte* | procName | The ASCII-encoded name of the function. |
Returns
Type | Description |
---|---|
IntPtr | The address of the function, or |
Remarks
This function does not apply to Vulkan. If you are rendering with Vulkan, see GetInstanceProcAddress(VkHandle, string), vkGetInstanceProcAddr
and vkGetDeviceProcAddr
instead.
Possible errors include NotInitialized, NoContext and PlatformError.
The address of a given function is not guaranteed to be the same between contexts.
This function may return a non-null
address despite the associated version or extension not being available. Always check the context version or extension string first.
The returned function pointer is valid until the context is destroyed or the library is terminated.
This function may be called from any thread.
See Also
GetRequiredInstanceExtensions()
Returns the Vulkan instance extensions required by GLFW.
Declaration
public static string[] GetRequiredInstanceExtensions()
Returns
Type | Description |
---|---|
string[] | An array of ASCII encoded extension names, or |
Remarks
This function returns an array of names of Vulkan instance extensions required by GLFW for
creating Vulkan surfaces for GLFW windows. If successful, the list will always contains
VK_KHR_surface
, so if you don't require any additional extensions you can
pass this list directly to the VkInstanceCreateInfo
struct.
If Vulkan is not available on the machine, this function returns null
and generates
a NotInitialized error. Call VulkanSupported() to check
whether Vulkan is at least minimally available.
If Vulkan is available but no set of extensions allowing window surface creation was found,
this function returns null
. You may still use Vulkan for off-screen rendering and compute work.
Additional extensions may be required by future versions of GLFW.
You should check if any extensions you wish to enable are already in the returned array,
as it is an error to specify an extension more than once in the VkInstanceCreateInfo
struct.
macOS: This function currently only supports the VK_MVK_macos_surface
extension from MoltenVK.
Possible errors include NotInitialized and ApiUnavailable.
The returned array is allocated and freed by GLFW. You should not free it yourself. It is guaranteed to be valid only until the library is terminated.
This function may be called from any thread.
GetRequiredInstanceExtensionsRaw(out uint)
Returns the Vulkan instance extensions required by GLFW.
Declaration
public static byte** GetRequiredInstanceExtensionsRaw(out uint count)
Parameters
Type | Name | Description |
---|---|---|
uint | count | Where to store the number of extensions in the returned array. This is set to zero if an error occurred. |
Returns
Type | Description |
---|---|
byte** | An array of ASCII encoded extension names, or |
Remarks
This function returns an array of names of Vulkan instance extensions required by GLFW for
creating Vulkan surfaces for GLFW windows. If successful, the list will always contains
VK_KHR_surface
, so if you don't require any additional extensions you can
pass this list directly to the VkInstanceCreateInfo
struct.
If Vulkan is not available on the machine, this function returns null
and generates
a NotInitialized error. Call VulkanSupported() to check
whether Vulkan is at least minimally available.
If Vulkan is available but no set of extensions allowing window surface creation was found,
this function returns null
. You may still use Vulkan for off-screen rendering and compute work.
Additional extensions may be required by future versions of GLFW.
You should check if any extensions you wish to enable are already in the returned array,
as it is an error to specify an extension more than once in the VkInstanceCreateInfo
struct.
macOS: This function currently only supports the VK_MVK_macos_surface
extension from MoltenVK.
Possible errors include NotInitialized and ApiUnavailable.
The returned array is allocated and freed by GLFW. You should not free it yourself. It is guaranteed to be valid only until the library is terminated.
This function may be called from any thread.
GetRequiredInstanceExtensionsRaw(uint*)
Returns the Vulkan instance extensions required by GLFW.
Declaration
public static byte** GetRequiredInstanceExtensionsRaw(uint* count)
Parameters
Type | Name | Description |
---|---|---|
uint* | count | Where to store the number of extensions in the returned array. This is set to zero if an error occurred. |
Returns
Type | Description |
---|---|
byte** | An array of ASCII encoded extension names, or |
Remarks
This function returns an array of names of Vulkan instance extensions required by GLFW for
creating Vulkan surfaces for GLFW windows. If successful, the list will always contains
VK_KHR_surface
, so if you don't require any additional extensions you can
pass this list directly to the VkInstanceCreateInfo
struct.
If Vulkan is not available on the machine, this function returns null
and generates
a NotInitialized error. Call VulkanSupported() to check
whether Vulkan is at least minimally available.
If Vulkan is available but no set of extensions allowing window surface creation was found,
this function returns null
. You may still use Vulkan for off-screen rendering and compute work.
Additional extensions may be required by future versions of GLFW.
You should check if any extensions you wish to enable are already in the returned array,
as it is an error to specify an extension more than once in the VkInstanceCreateInfo
struct.
macOS: This function currently only supports the VK_MVK_macos_surface
extension from MoltenVK.
Possible errors include NotInitialized and ApiUnavailable.
The returned array is allocated and freed by GLFW. You should not free it yourself. It is guaranteed to be valid only until the library is terminated.
This function may be called from any thread.
GetTime()
This function returns the value of the GLFW timer.
Unless the timer has been set using SetTime(double), the timer measures time elapsed since GLFW was initialized.
The resolution of the timer is system dependent, but is usually on the order of a few micro- or nanoseconds. It uses the highest-resolution monotonic time source on each supported platform.
Declaration
public static double GetTime()
Returns
Type | Description |
---|---|
double | The current value, in seconds, or zero if an error occurred. |
Remarks
This function may be called from any thread.
Reading and writing of the internal timer offset is not atomic, so it needs to be externally synchronized with calls to SetTime(double).
Possible errors include NotInitialized.
GetTimerFrequency()
This function returns the frequency, in Hz, of the raw timer.
Declaration
public static long GetTimerFrequency()
Returns
Type | Description |
---|---|
long | he frequency of the timer, in Hz, or zero if an error occurred. |
Remarks
This function may be called from any thread.
Possible errors include NotInitialized.
GetTimerValue()
This function returns the current value of the raw timer, measured in 1 / frequency seconds. To get the frequency, call GetTimerFrequency().
Declaration
public static long GetTimerValue()
Returns
Type | Description |
---|---|
long | The value of the timer, or zero if an error occurred. |
Remarks
This function may be called from any thread.
Possible errors include NotInitialized.
GetVersion(out int, out int, out int)
This function retrieves the major, minor and revision numbers of the GLFW library. It is intended for when you are using GLFW as a shared library and want to ensure that you are using the minimum required version.
Any or all of the version arguments may be out _
.
Declaration
public static void GetVersion(out int major, out int minor, out int revision)
Parameters
Type | Name | Description |
---|---|---|
int | major | Where to store the major version number, or |
int | minor | Where to store the minor version number, or |
int | revision | Where to store the revision number, or |
Remarks
This function may be called before Init().
This function may be called from any thread.
GetVersionString()
This function returns the compile-time generated version string of the GLFW library binary.
It describes the version, platform, compiler and any platform-specific compile-time options.
It should not be confused with the OpenGL or OpenGL ES version string, queried with glGetString
.
Do not use the version string to parse the GLFW library version. The GetVersion(out int, out int, out int) function provides the version of the running library binary in numerical format.
Declaration
public static string GetVersionString()
Returns
Type | Description |
---|---|
string | The ASCII-encoded GLFW version string. |
Remarks
This function may be called before Init().
The returned string is static and compile-time generated.
This function may be called from any thread.
See Also
GetVersionStringRaw()
This function returns the compile-time generated version string of the GLFW library binary.
It describes the version, platform, compiler and any platform-specific compile-time options.
It should not be confused with the OpenGL or OpenGL ES version string, queried with glGetString
.
Do not use the version string to parse the GLFW library version. The GetVersion(out int, out int, out int) function provides the version of the running library binary in numerical format.
Declaration
public static byte* GetVersionStringRaw()
Returns
Type | Description |
---|---|
byte* | The ASCII-encoded GLFW version string. |
Remarks
This function may be called before Init().
The returned string is static and compile-time generated.
This function may be called from any thread.
See Also
GetVideoMode(Monitor*)
This function returns the current video mode of the specified monitor.
If you have created a full screen window for that monitor, the return value will depend on whether that window is iconified.
Declaration
public static VideoMode* GetVideoMode(Monitor* monitor)
Parameters
Type | Name | Description |
---|---|---|
Monitor* | monitor | The monitor to query. |
Returns
Type | Description |
---|---|
VideoMode* | The current mode of the monitor, or |
Remarks
The returned array is allocated and freed by GLFW You should not free it yourself. It is valid until the specified monitor is disconnected or the library is terminated.
This function must only be called from the main thread.
Possible errors include NotInitialized and PlatformError.
See Also
GetVideoModes(Monitor*)
This function returns an array of all video modes supported by the specified monitor. The returned array is sorted in ascending order, first by color bit depth (the sum of all channel depths) and then by resolution area (the product of width and height).
Declaration
public static VideoMode[] GetVideoModes(Monitor* monitor)
Parameters
Type | Name | Description |
---|---|---|
Monitor* | monitor | The monitor to query. |
Returns
Type | Description |
---|---|
VideoMode[] | An array of video modes, or |
Remarks
The returned array is allocated and freed by GLFW. You should not free it yourself. It is valid until the specified monitor is disconnected, this function is called again for that monitor, or the library is terminated.
This function must only be called from the main thread.
Possible errors include NotInitialized and PlatformError.
See Also
GetVideoModesRaw(Monitor*, out int)
This function returns an array of all video modes supported by the specified monitor. The returned array is sorted in ascending order, first by color bit depth (the sum of all channel depths) and then by resolution area (the product of width and height).
Declaration
public static VideoMode* GetVideoModesRaw(Monitor* monitor, out int count)
Parameters
Type | Name | Description |
---|---|---|
Monitor* | monitor | The monitor to query. |
int | count | Where to store the number of video modes in the returned array. This is set to zero if an error occurred. |
Returns
Type | Description |
---|---|
VideoMode* | An array of video modes, or |
Remarks
The returned array is allocated and freed by GLFW. You should not free it yourself. It is valid until the specified monitor is disconnected, this function is called again for that monitor, or the library is terminated.
This function must only be called from the main thread.
Possible errors include NotInitialized and PlatformError.
See Also
GetVideoModesRaw(Monitor*, int*)
This function returns an array of all video modes supported by the specified monitor. The returned array is sorted in ascending order, first by color bit depth (the sum of all channel depths) and then by resolution area (the product of width and height).
Declaration
public static VideoMode* GetVideoModesRaw(Monitor* monitor, int* count)
Parameters
Type | Name | Description |
---|---|---|
Monitor* | monitor | The monitor to query. |
int* | count | Where to store the number of video modes in the returned array. This is set to zero if an error occurred. |
Returns
Type | Description |
---|---|
VideoMode* | An array of video modes, or |
Remarks
The returned array is allocated and freed by GLFW. You should not free it yourself. It is valid until the specified monitor is disconnected, this function is called again for that monitor, or the library is terminated.
This function must only be called from the main thread.
Possible errors include NotInitialized and PlatformError.
See Also
GetWaylandDisplay()
Returns the struct wl_display*
used by GLFW.
Declaration
public static IntPtr GetWaylandDisplay()
Returns
Type | Description |
---|---|
IntPtr | The |
GetWaylandMonitor(Monitor*)
Returns the struct wl_output*
of the specified monitor.
Declaration
public static IntPtr GetWaylandMonitor(Monitor* monitor)
Parameters
Type | Name | Description |
---|---|---|
Monitor* | monitor | The monitor to query. |
Returns
Type | Description |
---|---|
IntPtr | The |
GetWaylandWindow(Window*)
Returns the main struct wl_surface*
of the specified window.
Declaration
public static IntPtr GetWaylandWindow(Window* window)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window to query. |
Returns
Type | Description |
---|---|
IntPtr | The main |
GetWGLContext(Window*)
Returns the HGLRC
of the specified window.
Declaration
public static IntPtr GetWGLContext(Window* window)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window to query. |
Returns
Type | Description |
---|---|
IntPtr | The |
GetWin32Adapter(Monitor*)
Returns the adapter device name of the specified monitor.
Declaration
public static string GetWin32Adapter(Monitor* monitor)
Parameters
Type | Name | Description |
---|---|---|
Monitor* | monitor | The monitor to query. |
Returns
Type | Description |
---|---|
string | The adapter device name (for example \.\DISPLAY1) of the specified monitor, or |
GetWin32Monitor(Monitor*)
Returns the display device name of the specified monitor.
Declaration
public static string GetWin32Monitor(Monitor* monitor)
Parameters
Type | Name | Description |
---|---|---|
Monitor* | monitor | The monitor to query. |
Returns
Type | Description |
---|---|
string | The display device name (for example \.\DISPLAY1\Monitor0) of the specified monitor, or NULL if an error occurred. |
GetWin32Window(Window*)
Returns the HWND
of the specified window..
Declaration
public static IntPtr GetWin32Window(Window* window)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window to query. |
Returns
Type | Description |
---|---|
IntPtr | The |
GetWindowAttrib(Window*, WindowAttributeGetBool)
This function returns the value of an attribute of the specified window or its OpenGL or OpenGL ES context.
Declaration
public static bool GetWindowAttrib(Window* window, WindowAttributeGetBool attribute)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window to query. |
WindowAttributeGetBool | attribute | The window attribute whose value to return. |
Returns
Type | Description |
---|---|
bool | The value of the attribute, or zero if an error occurred. |
Remarks
Framebuffer-related hints are not window attributes. See Framebuffer related attributes for more information.
This function must only be called from the main thread.
Possible errors include NotInitialized, InvalidEnum and PlatformError.
GetWindowAttrib(Window*, WindowAttributeGetClientApi)
This function returns the value of an attribute of the specified window or its OpenGL or OpenGL ES context.
Declaration
public static ClientApi GetWindowAttrib(Window* window, WindowAttributeGetClientApi attribute)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window to query. |
WindowAttributeGetClientApi | attribute | The window attribute whose value to return. |
Returns
Type | Description |
---|---|
ClientApi | The value of the attribute, or zero if an error occurred. |
Remarks
Framebuffer-related hints are not window attributes. See Framebuffer related attributes for more information.
This function must only be called from the main thread.
Possible errors include NotInitialized, InvalidEnum and PlatformError.
GetWindowAttrib(Window*, WindowAttributeGetContextApi)
This function returns the value of an attribute of the specified window or its OpenGL or OpenGL ES context.
Declaration
public static ContextApi GetWindowAttrib(Window* window, WindowAttributeGetContextApi attribute)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window to query. |
WindowAttributeGetContextApi | attribute | The window attribute whose value to return. |
Returns
Type | Description |
---|---|
ContextApi | The value of the attribute, or zero if an error occurred. |
Remarks
Framebuffer-related hints are not window attributes. See Framebuffer related attributes for more information.
This function must only be called from the main thread.
Possible errors include NotInitialized, InvalidEnum and PlatformError.
GetWindowAttrib(Window*, WindowAttributeGetInt)
This function returns the value of an attribute of the specified window or its OpenGL or OpenGL ES context.
Declaration
public static int GetWindowAttrib(Window* window, WindowAttributeGetInt attribute)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window to query. |
WindowAttributeGetInt | attribute | The window attribute whose value to return. |
Returns
Type | Description |
---|---|
int | The value of the attribute, or zero if an error occurred. |
Remarks
Framebuffer-related hints are not window attributes. See Framebuffer related attributes for more information.
This function must only be called from the main thread.
Possible errors include NotInitialized, InvalidEnum and PlatformError.
GetWindowAttrib(Window*, WindowAttributeGetOpenGlProfile)
This function returns the value of an attribute of the specified window or its OpenGL or OpenGL ES context.
Declaration
public static OpenGlProfile GetWindowAttrib(Window* window, WindowAttributeGetOpenGlProfile attribute)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window to query. |
WindowAttributeGetOpenGlProfile | attribute | The window attribute whose value to return. |
Returns
Type | Description |
---|---|
OpenGlProfile | The value of the attribute, or zero if an error occurred. |
Remarks
Framebuffer-related hints are not window attributes. See Framebuffer related attributes for more information.
This function must only be called from the main thread.
Possible errors include NotInitialized, InvalidEnum and PlatformError.
GetWindowAttrib(Window*, WindowAttributeGetReleaseBehavior)
This function returns the value of an attribute of the specified window or its OpenGL or OpenGL ES context.
Declaration
public static ReleaseBehavior GetWindowAttrib(Window* window, WindowAttributeGetReleaseBehavior attribute)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window to query. |
WindowAttributeGetReleaseBehavior | attribute | The window attribute whose value to return. |
Returns
Type | Description |
---|---|
ReleaseBehavior | The value of the attribute, or zero if an error occurred. |
Remarks
Framebuffer-related hints are not window attributes. See Framebuffer related attributes for more information.
This function must only be called from the main thread.
Possible errors include NotInitialized, InvalidEnum and PlatformError.
GetWindowAttrib(Window*, WindowAttributeGetRobustness)
This function returns the value of an attribute of the specified window or its OpenGL or OpenGL ES context.
Declaration
public static Robustness GetWindowAttrib(Window* window, WindowAttributeGetRobustness attribute)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window to query. |
WindowAttributeGetRobustness | attribute | The window attribute whose value to return. |
Returns
Type | Description |
---|---|
Robustness | The value of the attribute, or zero if an error occurred. |
Remarks
Framebuffer-related hints are not window attributes. See Framebuffer related attributes for more information.
This function must only be called from the main thread.
Possible errors include NotInitialized, InvalidEnum and PlatformError.
GetWindowContentScale(Window*, out float, out float)
This function retrieves the content scale for the specified window.
The content scale is the ratio between the current DPI and the platform's default DPI. This is especially important for text and any UI elements. If the pixel dimensions of your UI scaled by this look appropriate on your machine then it should appear at a reasonable size on other machines regardless of their DPI and scaling settings. This relies on the system DPI and scaling settings being somewhat correct.
On systems where each monitors can have its own content scale, the window content scale will depend on which monitor the system considers the window to be on.
Declaration
public static void GetWindowContentScale(Window* window, out float xScale, out float yScale)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window to query. |
float | xScale | Where to store the x-axis content scale, or |
float | yScale | Where to store the y-axis content scale, or |
Remarks
This function must only be called from the main thread.
Possible errors include NotInitialized and PlatformError.
GetWindowFrameSize(Window*, out int, out int, out int, out int)
This function retrieves the size, in screen coordinates, of each edge of the frame of the specified window.
This size includes the title bar, if the window has one. The size of the frame may vary depending on the window-related hints used to create it.
Because this function retrieves the size of each window frame edge and not the offset along a particular coordinate axis, the retrieved values will always be zero or positive.
Any or all of the size arguments may be out _
.
If an error occurs, all non-out _
size arguments will be set to zero.
Declaration
public static void GetWindowFrameSize(Window* window, out int left, out int top, out int right, out int bottom)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window whose frame size to query. |
int | left | Where to store the size, in screen coordinates, of the left edge of the window frame, or |
int | top | Where to store the size, in screen coordinates, of the top edge of the window frame, or |
int | right | Where to store the size, in screen coordinates, of the right edge of the window frame, or |
int | bottom | Where to store the size, in screen coordinates, of the bottom edge of the window frame, or |
Remarks
This function must only be called from the main thread.
Possible errors include NotInitialized and PlatformError.
GetWindowMonitor(Window*)
This function returns the handle of the monitor that the specified window is in full screen on.
Declaration
public static Monitor* GetWindowMonitor(Window* window)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window to query. |
Returns
Type | Description |
---|---|
Monitor* | The monitor, or |
Remarks
This function must only be called from the main thread.
Possible errors include NotInitialized.
See Also
GetWindowOpacity(Window*)
This function returns the opacity of the window, including any decorations.
The opacity (or alpha) value is a positive finite number between zero and one, where zero is fully transparent and one is fully opaque.
If the system does not support whole window transparency, this function always returns one.
The initial opacity value for newly created windows is one.
Declaration
public static float GetWindowOpacity(Window* window)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window to query. |
Returns
Type | Description |
---|---|
float | The opacity value of the specified window. |
Remarks
This function must only be called from the main thread.
Possible errors include NotInitialized and PlatformError.
See Also
GetWindowPos(Window*, out int, out int)
This function retrieves the position, in screen coordinates, of the upper-left corner of the client area of the specified window.
Any or all of the position arguments may be out _
.
If an error occurs, all non-out _
position arguments will be set to zero.
Declaration
public static void GetWindowPos(Window* window, out int x, out int y)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window to query. |
int | x | Where to store the x-coordinate of the upper-left corner of the client area. |
int | y | Where to store the y-coordinate of the upper-left corner of the client area. |
Remarks
This function must only be called from the main thread.
Possible errors include NotInitialized and PlatformError.
See Also
GetWindowPosRaw(Window*, int*, int*)
This function retrieves the position, in screen coordinates, of the upper-left corner of the client area of the specified window.
Any or all of the position arguments may be out _
.
If an error occurs, all non-out _
position arguments will be set to zero.
Declaration
public static void GetWindowPosRaw(Window* window, int* x, int* y)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window to query. |
int* | x | Where to store the x-coordinate of the upper-left corner of the client area. |
int* | y | Where to store the y-coordinate of the upper-left corner of the client area. |
Remarks
This function must only be called from the main thread.
Possible errors include NotInitialized and PlatformError.
See Also
GetWindowSize(Window*, out int, out int)
This function retrieves the size, in screen coordinates, of the client area of the specified window. If you wish to retrieve the size of the framebuffer of the window in pixels, see GetFramebufferSize(Window*, out int, out int).
Any or all of the size arguments may be out _
.
If an error occurs, all non-out _
size arguments will be set to zero.
Declaration
public static void GetWindowSize(Window* window, out int width, out int height)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window whose size to retrieve. |
int | width | Where to store the width, in screen coordinates, of the client area. |
int | height | Where to store the height, in screen coordinates, of the client area. |
Remarks
This function must only be called from the main thread.
Possible errors include NotInitialized and PlatformError.
See Also
GetWindowSizeRaw(Window*, int*, int*)
This function retrieves the size, in screen coordinates, of the client area of the specified window. If you wish to retrieve the size of the framebuffer of the window in pixels, see GetFramebufferSize(Window*, out int, out int).
Any or all of the size arguments may be out _
.
If an error occurs, all non-out _
size arguments will be set to zero.
Declaration
public static void GetWindowSizeRaw(Window* window, int* width, int* height)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window whose size to retrieve. |
int* | width | Where to store the width, in screen coordinates, of the client area. |
int* | height | Where to store the height, in screen coordinates, of the client area. |
Remarks
This function must only be called from the main thread.
Possible errors include NotInitialized and PlatformError.
See Also
GetWindowUserPointer(Window*)
This function returns the current value of the user-defined pointer of the specified window.
The initial value is Zero.
Declaration
public static void* GetWindowUserPointer(Window* window)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window whose pointer to return. |
Returns
Type | Description |
---|---|
void* | The user-defined pointer of the given |
Remarks
This function may be called from any thread. Access is not synchronized.
Possible errors include NotInitialized.
GetX11Adapter(Monitor*)
Returns the RRCrtc
of the specified monitor.
Declaration
public static UIntPtr GetX11Adapter(Monitor* monitor)
Parameters
Type | Name | Description |
---|---|---|
Monitor* | monitor | The monitor to query. |
Returns
Type | Description |
---|---|
UIntPtr | The |
GetX11Display()
Returns the Display
used by GLFW.
Declaration
public static IntPtr GetX11Display()
Returns
Type | Description |
---|---|
IntPtr | The |
GetX11Monitor(Monitor*)
Returns the RROutput
of the specified monitor.
Declaration
public static UIntPtr GetX11Monitor(Monitor* monitor)
Parameters
Type | Name | Description |
---|---|---|
Monitor* | monitor | The monitor to query. |
Returns
Type | Description |
---|---|
UIntPtr | The |
GetX11SelectionString()
Returns the contents of the current primary selection as a string.
Declaration
public static string GetX11SelectionString()
Returns
Type | Description |
---|---|
string | The contents of the selection as a string, or |
GetX11Window(Window*)
Returns the Window
of the specified window.
Declaration
public static UIntPtr GetX11Window(Window* window)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window to query. |
Returns
Type | Description |
---|---|
UIntPtr | The |
HideWindow(Window*)
This function hides the specified window if it was previously visible. If the window is already hidden or is in full screen mode, this function does nothing.
Declaration
public static void HideWindow(Window* window)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window to hide. |
Remarks
This function must only be called from the main thread.
Possible errors include NotInitialized and PlatformError.
IconifyWindow(Window*)
This function iconifies (minimizes) the specified window if it was previously restored. If the window is already iconified, this function does nothing.
If the specified window is a full screen window, the original monitor resolution is restored until the window is restored.
Declaration
public static void IconifyWindow(Window* window)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window to iconify. |
Remarks
This function must only be called from the main thread.
Possible errors include NotInitialized and PlatformError.
Init()
This function initializes the GLFW library. Before most GLFW functions can be used, GLFW must be initialized, and before an application terminates GLFW should be terminated in order to free any resources allocated during or after initialization.
If this function fails, it calls Terminate() before returning.
If it succeeds, you should call Terminate() before the application exits.
Additional calls to this function after successful initialization
but before termination will return true
immediately.
Declaration
public static bool Init()
Returns
Type | Description |
---|---|
bool |
|
Remarks
OS X: This function will change the current directory of the application to the Contents/Resources subdirectory of the application's bundle, if present.
This function must only be called from the main thread.
Possible errors include PlatformError.
InitHint(InitHintBool, bool)
This function sets hints for the next initialization of GLFW.
The values you set hints to are never reset by GLFW, but they only take effect during initialization.
Once GLFW has been initialized, any values you set will be ignored until the library is terminated and initialized again.
Some hints are platform specific. These may be set on any platform but they will only affect their specific platform. Other platforms will ignore them. Setting these hints requires no platform specific headers or functions.
Declaration
public static void InitHint(InitHintBool hintBool, bool value)
Parameters
Type | Name | Description |
---|---|---|
InitHintBool | hintBool | The InitHintBool to set. |
bool | value | The new value of the InitHintBool. |
Remarks
This function may be called before Init().
This function must only be called from the main thread.
Possible errors include InvalidEnum and InvalidValue.
InitHint(InitHintInt, int)
This function sets hints for the next initialization of GLFW.
The values you set hints to are never reset by GLFW, but they only take effect during initialization.
Once GLFW has been initialized, any values you set will be ignored until the library is terminated and initialized again.
Some hints are platform specific. These may be set on any platform but they will only affect their specific platform. Other platforms will ignore them. Setting these hints requires no platform specific headers or functions.
Declaration
public static void InitHint(InitHintInt hintInt, int value)
Parameters
Type | Name | Description |
---|---|---|
InitHintInt | hintInt | The InitHintInt to set. |
int | value | The new value of the InitHintBool. |
Remarks
This function may be called before Init().
This function must only be called from the main thread.
Possible errors include InvalidEnum and InvalidValue.
JoystickIsGamepad(int)
This function returns whether the specified joystick is both present and has a gamepad mapping.
If the specified joystick is present but does not have a gamepad mapping
this function will return false
but will not generate an error.
Declaration
public static bool JoystickIsGamepad(int jid)
Parameters
Type | Name | Description |
---|---|---|
int | jid | The joystick to query. |
Returns
Type | Description |
---|---|
bool |
|
Remarks
Call JoystickPresent(int) to check if a joystick is present regardless of whether it has a mapping.
This function must only be called from the main thread.
Possible errors include NotInitialized and InvalidEnum.
See Also
JoystickPresent(int)
This function returns whether the specified joystick is present.
There is no need to call this function before other functions that accept a joystick ID, as they all check for presence before performing any other work.
Declaration
public static bool JoystickPresent(int jid)
Parameters
Type | Name | Description |
---|---|---|
int | jid | The joystick to query. |
Returns
Type | Description |
---|---|
bool |
|
Remarks
This function must only be called from the main thread.
Possible errors include NotInitialized, InvalidEnum and PlatformError.
MakeContextCurrent(Window*)
This function makes the OpenGL or OpenGL ES context of the specified window current on the calling thread.
A context can only be made current on a single thread at a time and each thread can have only a single current context at a time.
By default, making a context non-current implicitly forces a pipeline flush.
On machines that support GL_KHR_context_flush_control
,
you can control whether a context performs this flush
by setting the ContextReleaseBehavior window hint.
The specified window must have an OpenGL or OpenGL ES context. Specifying a window without a context will generate a NoWindowContext error.
Declaration
public static void MakeContextCurrent(Window* window)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window whose context to make current, or |
Remarks
This function may be called from any thread.
Possible errors include NotInitialized, NoWindowContext and PlatformError.
See Also
MaximizeWindow(Window*)
This function maximizes the specified window if it was previously not maximized. If the window is already maximized, this function does nothing.
If the specified window is a full screen window, this function does nothing.
Declaration
public static void MaximizeWindow(Window* window)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window to maximize. |
Remarks
This function may only be called from the main thread.
Possible errors include NotInitialized and PlatformError.
PollEvents()
This function processes only those events that are already in the event queue and then returns immediately. Processing events will cause the window and input callbacks associated with those events to be called.
On some platforms, a window move, resize or menu operation will cause event processing to block. This is due to how event processing is designed on those platforms. You can use the window refresh callback to redraw the contents of your window when necessary during such operations.
On some platforms, certain events are sent directly to the application without going through the event queue, causing callbacks to be called outside of a call to one of the event processing functions.
Event processing is not required for joystick input to work.
Declaration
public static void PollEvents()
Remarks
This function must not be called from a callback.
This function must only be called from the main thread.
Possible errors include NotInitialized and PlatformError.
PostEmptyEvent()
This function posts an empty event from the current thread to the event queue, causing WaitEvents() or WaitEventsTimeout(double) to return.
If no windows exist, this function returns immediately. For synchronization of threads in applications that do not create windows, use your threading library of choice.
Declaration
public static void PostEmptyEvent()
Remarks
This function may be called from any thread.
Possible errors include NotInitialized and PlatformError.
RawMouseMotionSupported()
This function returns whether raw mouse motion is supported on the current system. This status does not change after GLFW has been initialized so you only need to check this once. If you attempt to enable raw motion on a system that does not support it, PlatformError will be emitted.
Raw mouse motion is closer to the actual motion of the mouse across a surface. It is not affected by the scaling and acceleration applied to the motion of the desktop cursor. That processing is suitable for a cursor while raw motion is better for controlling for example a 3D camera. Because of this, raw mouse motion is only provided when the cursor is disabled.
Declaration
public static bool RawMouseMotionSupported()
Returns
Type | Description |
---|---|
bool |
|
Remarks
This function must only be called from the main thread.
Possible errors include NotInitialized.
RequestWindowAttention(Window*)
This function requests user attention to the specified window. On platforms where this is not supported, attention is requested to the application as a whole.
Once the user has given attention, usually by focusing the window or application, the system will end the request automatically.
Declaration
public static void RequestWindowAttention(Window* window)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window to request attention to. |
Remarks
macOS: Attention is requested to the application as a whole, not the specific window.
This function must only be called from the main thread.
Possible errors include NotInitialized and PlatformError.
RestoreWindow(Window*)
This function restores the specified window if it was previously iconified (minimized) or maximized. If the window is already restored, this function does nothing.
If the specified window is a full screen window, the resolution chosen for the window is restored on the selected monitor.
Declaration
public static void RestoreWindow(Window* window)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window to restore. |
Remarks
This function must only be called from the main thread.
Possible errors include NotInitialized and PlatformError.
SetCharCallback(Window*, CharCallback)
This function sets the character callback of the specified window, which is called when a Unicode character is input.
The character callback is intended for Unicode text input. As it deals with characters, it is keyboard layout dependent, whereas the key callback is not. Characters do not map 1:1 to physical keys as a key may produce zero, one, or more characters.
If you want to know whether a specific physical key was pressed or released, see the key callback instead.
The character callback behaves as system text input normally does and will not be called if modifier keys are held down that would prevent normal text input on that platform, for example a Super (Command) key on OS X or Alt key on Windows.
There is a character with modifiers callback(SetCharModsCallback(Window*, CharModsCallback)) that receives these events.
Declaration
public static IntPtr SetCharCallback(Window* window, GLFWCallbacks.CharCallback callback)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window whose callback to set. |
GLFWCallbacks.CharCallback | callback | The new callback, or |
Returns
Type | Description |
---|---|
IntPtr | The previously set callback, or |
Remarks
This function must only be called from the main thread.
Possible errors include NotInitialized.
SetCharModsCallback(Window*, CharModsCallback)
This function sets the character with modifiers callback of the specified window, which is called when a Unicode character is input regardless of what modifier keys are used.
The character with modifiers callback is intended for implementing custom Unicode character input. For regular Unicode text input, see the character callback.
Like the character callback(SetCharCallback(Window*, CharCallback)), the character with modifiers callback deals with characters and is keyboard layout dependent. Characters do not map 1:1 to physical keys, as a key may produce zero, one, or more characters.
If you want to know whether a specific physical key was pressed or released, see the key callback(SetKeyCallback(Window*, KeyCallback)) instead.
Declaration
public static IntPtr SetCharModsCallback(Window* window, GLFWCallbacks.CharModsCallback callback)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window whose callback to set. |
GLFWCallbacks.CharModsCallback | callback | The new callback, or |
Returns
Type | Description |
---|---|
IntPtr | The previously set callback, or |
Remarks
This function must only be called from the main thread.
Possible errors include NotInitialized.
SetClipboardString(Window*, string)
This function sets the system clipboard to the specified, UTF-8 encoded string.
Declaration
public static void SetClipboardString(Window* window, string data)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window that will own the clipboard contents. |
string | data | A UTF-8 encoded string. |
Remarks
The specified string is copied before this function returns.
This function must only be called from the main thread.
Possible errors include NotInitialized and PlatformError.
See Also
SetClipboardStringRaw(Window*, byte*)
This function sets the system clipboard to the specified, UTF-8 encoded string.
Declaration
public static void SetClipboardStringRaw(Window* window, byte* data)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window that will own the clipboard contents. |
byte* | data | A UTF-8 encoded string. |
Remarks
The specified string is copied before this function returns.
This function must only be called from the main thread.
Possible errors include NotInitialized and PlatformError.
See Also
SetCursor(Window*, Cursor*)
This function sets the cursor image to be used when the cursor is over the client area of the specified window.
The set cursor will only be visible when the cursor mode of the window is CursorNormal.
On some platforms, the set cursor may not be visible unless the window also has input focus.
Declaration
public static void SetCursor(Window* window, Cursor* cursor)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window to set the cursor for. |
Cursor* | cursor | The cursor to set, or |
Remarks
This function must only be called from the main thread.
Possible errors include NotInitialized and PlatformError.
SetCursorEnterCallback(Window*, CursorEnterCallback)
This function sets the cursor boundary crossing callback of the specified window which is called when the cursor enters or leaves the client area of the window.
Declaration
public static IntPtr SetCursorEnterCallback(Window* window, GLFWCallbacks.CursorEnterCallback callback)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window whose callback to set. |
GLFWCallbacks.CursorEnterCallback | callback | The new callback, or |
Returns
Type | Description |
---|---|
IntPtr | The previously set callback, or |
Remarks
This function must only be called from the main thread.
Possible errors include NotInitialized.
SetCursorPos(Window*, double, double)
This function sets the position, in screen coordinates, of the cursor relative to the upper-left corner of the client area of the specified window.
The window must have input focus. If the window does not have input focus when this function is called, it fails silently.
Do not use this function to implement things like camera controls. GLFW already provides the CursorDisabled cursor mode that hides the cursor, transparently re-centers it and provides unconstrained cursor motion. See SetInputMode(Window*, CursorStateAttribute, CursorModeValue) for more information.
If the cursor mode is CursorDisabled then the cursor position is unconstrained and limited only by the minimum and maximum values of a double.
Declaration
public static void SetCursorPos(Window* window, double xPos, double yPos)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The desired window. |
double | xPos | The desired x-coordinate, relative to the left edge of the client area. |
double | yPos | The desired y-coordinate, relative to the top edge of the client area. |
Remarks
Wayland: This function will only work when the cursor mode is CursorDisabled, otherwise it will do nothing.
This function must only be called from the main thread.
Possible errors include NotInitialized and PlatformError.
SetCursorPosCallback(Window*, CursorPosCallback)
This function sets the cursor position callback of the specified window, which is called when the cursor is moved.
The callback is provided with the position, in screen coordinates, relative to the upper-left corner of the client area of the window.
Declaration
public static IntPtr SetCursorPosCallback(Window* window, GLFWCallbacks.CursorPosCallback callback)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window whose callback to set. |
GLFWCallbacks.CursorPosCallback | callback | The new callback, or |
Returns
Type | Description |
---|---|
IntPtr | The previously set callback, or |
Remarks
This function must only be called from the main thread.
Possible errors include NotInitialized.
SetDropCallback(Window*, DropCallback)
This function sets the file drop callback of the specified window, which is called when one or more dragged files are dropped on the window.
Because the path array and its strings may have been generated specifically for that event, they are not guaranteed to be valid after the callback has returned. If you wish to use them after the callback returns, you need to make a deep copy.
Declaration
public static IntPtr SetDropCallback(Window* window, GLFWCallbacks.DropCallback callback)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window whose callback to set. |
GLFWCallbacks.DropCallback | callback | The new file drop callback, or |
Returns
Type | Description |
---|---|
IntPtr | The previously set callback, or |
Remarks
This function must only be called from the main thread.
Possible errors include NotInitialized.
SetErrorCallback(ErrorCallback)
This function sets the error callback, which is called with an error code and a human-readable description each time a GLFW error occurs.
The error callback is called on the thread where the error occurred. If you are using GLFW from multiple threads, your error callback needs to be written accordingly.
Because the description string may have been generated specifically for that error, it is not guaranteed to be valid after the callback has returned. If you wish to use it after the callback returns, you need to make a deep copy.
Once set, the error callback remains set even after the library has been terminated.
Declaration
public static IntPtr SetErrorCallback(GLFWCallbacks.ErrorCallback callback)
Parameters
Type | Name | Description |
---|---|---|
GLFWCallbacks.ErrorCallback | callback | The new callback, or |
Returns
Type | Description |
---|---|
IntPtr | The previously set callback, or |
Remarks
This function may be called before Init().
This function must only be called from the main thread.
SetFramebufferSizeCallback(Window*, FramebufferSizeCallback)
This function sets the framebuffer resize callback of the specified window, which is called when the framebuffer of the specified window is resized.
Declaration
public static IntPtr SetFramebufferSizeCallback(Window* window, GLFWCallbacks.FramebufferSizeCallback callback)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window whose content scale changed. |
GLFWCallbacks.FramebufferSizeCallback | callback | The new callback, or |
Returns
Type | Description |
---|---|
IntPtr | The previously set callback, or |
Remarks
This function must only be called from the main thread.
Possible errors include NotInitialized.
See Also
SetGamma(Monitor*, float)
This function generates a 256-element gamma ramp from the specified exponent and then calls SetGamma(Monitor*, float) with it. The value must be a finite number greater than zero.
Declaration
public static void SetGamma(Monitor* monitor, float gamma)
Parameters
Type | Name | Description |
---|---|---|
Monitor* | monitor | The monitor whose gamma ramp to set. |
float | gamma | The desired exponent. |
Remarks
This function must only be called from the main thread.
Possible errors include NotInitialized, InvalidValue and PlatformError.
SetGammaRamp(Monitor*, GammaRamp*)
This function sets the current gamma ramp for the specified monitor.
The original gamma ramp for that monitor is saved by GLFW the first time this function is called and is restored by Terminate().
Declaration
public static void SetGammaRamp(Monitor* monitor, GammaRamp* ramp)
Parameters
Type | Name | Description |
---|---|---|
Monitor* | monitor | The monitor whose gamma ramp to set. |
GammaRamp* | ramp | The gamma ramp to use. |
Remarks
Gamma ramp sizes other than 256 are not supported by all platforms or graphics hardware.
Windows: The gamma ramp size must be 256.
The specified gamma ramp is copied before this function returns.
This function must only be called from the main thread.
Possible errors include NotInitialized and PlatformError.
SetInputMode(Window*, CursorStateAttribute, CursorModeValue)
This function sets an input mode option for the specified window. The mode must be Cursor.
If the mode is Cursor, the value must be one of the following cursor modes: - CursorNormal makes the cursor visible and behaving normally. - CursorHidden makes the cursor invisible when it is over the client area of the window but does not restrict the cursor from leaving. - CursorDisabled hides and grabs the cursor, providing virtual and unlimited cursor movement. This is useful for implementing for example 3D camera controls.
Declaration
public static void SetInputMode(Window* window, CursorStateAttribute mode, CursorModeValue value)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window whose input mode to set. |
CursorStateAttribute | mode | |
CursorModeValue | value | The new value of the specified input mode. |
Remarks
This function must only be called from the main thread.
Possible errors include NotInitialized, InvalidEnum and PlatformError.
SetInputMode(Window*, LockKeyModAttribute, bool)
This function sets an input mode option for the specified window. The mode must be LockKeyMods.
If the mode is LockKeyMods, the value must be either true to enable lock key modifier bits, or false to disable them. If enabled, callbacks that receive modifier bits will also have the caps lock modifier bit set when the event was generated with Caps Lock on, and the num lock modifier bit when Num Lock was on.
Declaration
public static void SetInputMode(Window* window, LockKeyModAttribute mode, bool value)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window whose input mode to set. |
LockKeyModAttribute | mode | The value LockKeyMods. |
bool | value | The new value of the specified input mode. |
Remarks
This function must only be called from the main thread.
Possible errors include NotInitialized, InvalidEnum and PlatformError.
SetInputMode(Window*, RawMouseMotionAttribute, bool)
This function sets an input mode option for the specified window. The mode must be RawMouseMotion.
If the mode is RawMouseMotion, the value must be either GLFW_TRUE to enable raw (unscaled and unaccelerated) mouse motion when the cursor is disabled, or GLFW_FALSE to disable it. If raw motion is not supported, attempting to set this will emit GLFW_PLATFORM_ERROR. Call glfwRawMouseMotionSupported to check for support.
Declaration
public static void SetInputMode(Window* window, RawMouseMotionAttribute mode, bool value)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window whose raw mouse motion mode to set. |
RawMouseMotionAttribute | mode | The value RawMouseMotion. |
bool | value | Whether raw mouse motion should be enabled or disabled. |
Remarks
This function must only be called from the main thread.
Possible errors include NotInitialized, InvalidEnum and PlatformError.
SetInputMode(Window*, StickyAttributes, bool)
This function sets an input mode option for the specified window. The mode must be StickyKeys or StickyMouseButtons.
If the mode is StickyKeys, the value must be either true
to enable sticky keys, or false
to disable it.
If sticky keys are enabled, a key press will ensure that GetKey(Window*, Keys) returns Press the next time it is called even if the key had been released before the call. This is useful when you are only interested in whether keys have been pressed but not when or in which order.
If the mode is StickyMouseButtons, the value must be either true
to enable sticky mouse buttons, or false
to disable it.
If sticky mouse buttons are enabled, a mouse button press will ensure that
GetMouseButton(Window*, MouseButton) returns Press the next time it is called even if the mouse button had been released before the call.
This is useful when you are only interested in whether mouse buttons have been pressed but not when or in which order.
Declaration
public static void SetInputMode(Window* window, StickyAttributes mode, bool value)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window whose input mode to set. |
StickyAttributes | mode | Either StickyKeys or StickyMouseButtons. |
bool | value | The new value of the specified input mode. |
Remarks
This function must only be called from the main thread.
Possible errors include NotInitialized, InvalidEnum and PlatformError.
SetJoystickCallback(JoystickCallback)
This function sets the joystick configuration callback, or removes the currently set callback. This is called when a joystick is connected to or disconnected from the system.
Declaration
public static IntPtr SetJoystickCallback(GLFWCallbacks.JoystickCallback callback)
Parameters
Type | Name | Description |
---|---|---|
GLFWCallbacks.JoystickCallback | callback | The new callback, or |
Returns
Type | Description |
---|---|
IntPtr | The previously set callback, or |
Remarks
This function must only be called from the main thread.
Possible errors include NotInitialized.
SetJoystickUserPointer(int, void*)
This function sets the user-defined pointer of the specified joystick. The current value is retained until the joystick is disconnected. The initial value is Zero.
This function may be called from the joystick callback, even for a joystick that is being disconnected.
Declaration
public static void SetJoystickUserPointer(int jid, void* ptr)
Parameters
Type | Name | Description |
---|---|---|
int | jid | The joystick whose pointer to set. |
void* | ptr | The new value. |
Remarks
This function may be called from any thread. Access is not synchronized.
Possible errors include NotInitialized.
SetKeyCallback(Window*, KeyCallback)
This function sets the key callback of the specified window, which is called when a key is pressed, repeated or released.
The key functions deal with physical keys, with layout independent key tokens(Keys) named after their values in the standard US keyboard layout. If you want to input text, use the character callback(SetCharCallback(Window*, CharCallback)) instead.
When a window loses input focus, it will generate synthetic key release events for all pressed keys. You can tell these events from user-generated events by the fact that the synthetic ones are generated after the focus loss event has been processed, i.e. after the window focus callback(SetWindowFocusCallback(Window*, WindowFocusCallback)) has been called.
The scancode of a key is specific to that platform or sometimes even to that machine. Scancodes are intended to allow users to bind keys that don't have a GLFW key token. Such keys have key set to Unknown, their state is not saved and so it cannot be queried with GetKey(Window*, Keys).
Sometimes GLFW needs to generate synthetic key events, in which case the scancode may be zero.
Declaration
public static IntPtr SetKeyCallback(Window* window, GLFWCallbacks.KeyCallback callback)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window whose callback to set. |
GLFWCallbacks.KeyCallback | callback | The new key callback, or |
Returns
Type | Description |
---|---|
IntPtr | The previously set callback, or |
Remarks
This function must only be called from the main thread.
Possible errors include NotInitialized.
SetMonitorCallback(MonitorCallback)
This function sets the monitor configuration callback, or removes the currently set callback. This is called when a monitor is connected to or disconnected from the system.
Declaration
public static IntPtr SetMonitorCallback(GLFWCallbacks.MonitorCallback callback)
Parameters
Type | Name | Description |
---|---|---|
GLFWCallbacks.MonitorCallback | callback | The new callback, or |
Returns
Type | Description |
---|---|
IntPtr | The previously set callback, or |
Remarks
This function must only be called from the main thread.
Possible errors include NotInitialized.
SetMonitorUserPointer(Monitor*, void*)
This function sets the user-defined pointer of the specified monitor. The current value is retained until the monitor is disconnected. The initial value is Zero.
This function may be called from the monitor callback, even for a monitor that is being disconnected.
Declaration
public static void SetMonitorUserPointer(Monitor* monitor, void* pointer)
Parameters
Type | Name | Description |
---|---|---|
Monitor* | monitor | The monitor whose pointer to set. |
void* | pointer | The new value. |
Remarks
This function may be called from any thread. Access is not synchronized.
Possible errors include NotInitialized.
SetMouseButtonCallback(Window*, MouseButtonCallback)
This function sets the mouse button callback of the specified window, which is called when a mouse button is pressed or released.
When a window loses input focus, it will generate synthetic mouse button release events for all pressed mouse buttons. You can tell these events from user-generated events by the fact that the synthetic ones are generated after the focus loss event has been processed, i.e. after the window focus callback(SetWindowFocusCallback(Window*, WindowFocusCallback)) has been called.
Declaration
public static IntPtr SetMouseButtonCallback(Window* window, GLFWCallbacks.MouseButtonCallback callback)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window whose callback to set. |
GLFWCallbacks.MouseButtonCallback | callback | The new callback, or |
Returns
Type | Description |
---|---|
IntPtr | The previously set callback, or |
Remarks
This function must only be called from the main thread.
Possible errors include NotInitialized.
SetScrollCallback(Window*, ScrollCallback)
This function sets the scroll callback of the specified window, which is called when a scrolling device is used, such as a mouse wheel or scrolling area of a touchpad.
The scroll callback receives all scrolling input, like that from a mouse wheel or a touchpad scrolling area.
Declaration
public static IntPtr SetScrollCallback(Window* window, GLFWCallbacks.ScrollCallback callback)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window whose callback to set. |
GLFWCallbacks.ScrollCallback | callback | The new scroll callback, or |
Returns
Type | Description |
---|---|
IntPtr | The previously set callback, or |
Remarks
This function must only be called from the main thread.
Possible errors include NotInitialized.
SetTime(double)
This function sets the value of the GLFW timer. It then continues to count up from that value. The value must be a positive finite number less than or equal to 18446744073.0, which is approximately 584.5 years.
Declaration
public static void SetTime(double time)
Parameters
Type | Name | Description |
---|---|---|
double | time | The new value, in seconds. |
Remarks
The upper limit of the timer is calculated as floor((2^64 - 1) / 109) and is due to implementations storing nanoseconds in 64 bits. The limit may be increased in the future.
This function may be called from any thread. Reading and writing of the internal timer offset is not atomic, so it needs to be externally synchronized with calls to GetTime().
Possible errors include NotInitialized and InvalidValue.
SetWindowAspectRatio(Window*, int, int)
This function sets the required aspect ratio of the client area of the specified window.
If the window is full screen, the aspect ratio only takes effect once it is made windowed.
If the window is not resizable, this function does nothing.
The aspect ratio is specified as a numerator and a denominator and both values must be greater than zero. For example, the common 16:9 aspect ratio is specified as 16 and 9, respectively.
If the numerator and denominator is set to DontCare then the aspect ratio limit is disabled.
The aspect ratio is applied immediately to a windowed mode window and may cause it to be resized.
Declaration
public static void SetWindowAspectRatio(Window* window, int numer, int denom)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window to set limits for. |
int | numer | The numerator of the desired aspect ratio, or DontCare. |
int | denom | The denominator of the desired aspect ratio, or DontCare. |
Remarks
If you set size limits and an aspect ratio that conflict, the results are undefined.
This function must only be called from the main thread.
Possible errors include NotInitialized, InvalidValue and PlatformError.
SetWindowAttrib(Window*, WindowAttribute, bool)
This function sets the value of an attribute of the specified window.
The supported attributes are Decorated, Resizable, Floating, AutoIconify and FocusOnShow.
Some of these attributes are ignored for full screen windows. The new value will take effect if the window is later made windowed.
Some of these attributes are ignored for windowed mode windows. The new value will take effect if the window is later made full screen.
Declaration
public static void SetWindowAttrib(Window* window, WindowAttribute attribute, bool value)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window to set the attribute for. |
WindowAttribute | attribute | A supported window attribute. |
bool | value |
|
Remarks
Calling GetWindowAttrib(Window*, WindowAttributeGetBool) will always return the latest value, even if that value is ignored by the current mode of the window.
This function must only be called from the main thread.
Possible errors include NotInitialized, InvalidEnum, InvalidValue and PlatformError.
SetWindowCloseCallback(Window*, WindowCloseCallback)
This function sets the close callback of the specified window, which is called when the user attempts to close the window, for example by clicking the close widget in the title bar.
The close flag is set before this callback is called, but you can modify it at any time with SetWindowShouldClose(Window*, bool).
The close callback is not triggered by DestroyWindow(Window*).
Declaration
public static IntPtr SetWindowCloseCallback(Window* window, GLFWCallbacks.WindowCloseCallback callback)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window whose callback to set. |
GLFWCallbacks.WindowCloseCallback | callback | The new callback, or |
Returns
Type | Description |
---|---|
IntPtr | The previously set callback, or |
Remarks
This function must only be called from the main thread.
OS X: Selecting Quit from the application menu will trigger the close callback for all windows.
Possible errors include NotInitialized.
SetWindowContentScaleCallback(Window*, WindowContentScaleCallback)
This function sets the window content scale callback of the specified window, which is called when the content scale of the specified window changes.
Declaration
public static IntPtr SetWindowContentScaleCallback(Window* window, GLFWCallbacks.WindowContentScaleCallback callback)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window whose content scale changed. |
GLFWCallbacks.WindowContentScaleCallback | callback | The new callback, or |
Returns
Type | Description |
---|---|
IntPtr | The previously set callback, or |
Remarks
This function must only be called from the main thread.
Possible errors include NotInitialized.
See Also
SetWindowFocusCallback(Window*, WindowFocusCallback)
This function sets the focus callback of the specified window, which is called when the window gains or loses input focus.
After the focus callback is called for a window that lost input focus, synthetic key and mouse button release events will be generated for all such that had been pressed. For more information, see SetKeyCallback(Window*, KeyCallback) and SetMouseButtonCallback(Window*, MouseButtonCallback).
Declaration
public static IntPtr SetWindowFocusCallback(Window* window, GLFWCallbacks.WindowFocusCallback callback)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window whose callback to set. |
GLFWCallbacks.WindowFocusCallback | callback | The new callback, or |
Returns
Type | Description |
---|---|
IntPtr | The previously set callback, or |
Remarks
This function must only be called from the main thread.
Possible errors include NotInitialized.
SetWindowIcon(Window*, ReadOnlySpan<Image>)
This function sets the icon of the specified window.
If passed an array of candidate images, those of or closest to the sizes desired by the system are selected.
If no images are specified, the window reverts to its default icon.
The desired image sizes varies depending on platform and system settings. The selected images will be rescaled as needed. Good sizes include 16x16, 32x32 and 48x48.
Declaration
public static void SetWindowIcon(Window* window, ReadOnlySpan<Image> images)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window whose icon to set. |
ReadOnlySpan<Image> | images | The images to create the icon from. If zero images are passed, the window is reset to the default icon. |
Remarks
This function must only be called from the main thread.
The specified image data is copied before this function returns.
OS X: The GLFW window has no icon, as it is not a document window, so this function does nothing. The dock icon will be the same as the application bundle's icon. For more information on bundles, see the Bundle Programming Guide in the Mac Developer Library.
SetWindowIconifyCallback(Window*, WindowIconifyCallback)
This function sets the iconification callback of the specified window, which is called when the window is iconified or restored.
Declaration
public static IntPtr SetWindowIconifyCallback(Window* window, GLFWCallbacks.WindowIconifyCallback callback)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window whose callback to set. |
GLFWCallbacks.WindowIconifyCallback | callback | The new callback, or |
Returns
Type | Description |
---|---|
IntPtr | The previously set callback, or |
Remarks
This function must only be called from the main thread.
Possible errors include NotInitialized.
SetWindowIconRaw(Window*, int, Image*)
This function sets the icon of the specified window.
If passed an array of candidate images, those of or closest to the sizes desired by the system are selected.
If no images are specified, the window reverts to its default icon.
The desired image sizes varies depending on platform and system settings. The selected images will be rescaled as needed. Good sizes include 16x16, 32x32 and 48x48.
Declaration
public static void SetWindowIconRaw(Window* window, int count, Image* images)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window whose icon to set. |
int | count | The number of images in the specified array, or zero to revert to the default window icon. |
Image* | images | The images to create the icon from. This is ignored if count is zero. |
Remarks
This function must only be called from the main thread.
The specified image data is copied before this function returns.
OS X: The GLFW window has no icon, as it is not a document window, so this function does nothing. The dock icon will be the same as the application bundle's icon. For more information on bundles, see the Bundle Programming Guide in the Mac Developer Library.
SetWindowMaximizeCallback(Window*, WindowMaximizeCallback)
This function sets the maximization callback of the specified window, which is called when the window is maximized or restored.
Declaration
public static IntPtr SetWindowMaximizeCallback(Window* window, GLFWCallbacks.WindowMaximizeCallback callback)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window whose callback to set. |
GLFWCallbacks.WindowMaximizeCallback | callback | The new callback, or |
Returns
Type | Description |
---|---|
IntPtr | The previously set callback, or |
Remarks
This function may only be called from the main thread.
Possible errors include NotInitialized.
See Also
SetWindowMonitor(Window*, Monitor*, int, int, int, int, int)
This function sets the monitor that the window uses for full screen mode or,
if the monitor is null
, makes it windowed mode.
When setting a monitor, this function updates the width, height and refresh rate of the desired video mode and switches to the video mode closest to it.
The window position is ignored when setting a monitor.
When the monitor is null
, the position, width and height are used to place the window client area.
The refresh rate is ignored when no monitor is specified.
If you only wish to update the resolution of a full screen window or the size of a windowed mode window, see SetWindowSize(Window*, int, int).
When a window transitions from full screen to windowed mode, this function restores any previous window settings such as whether it is decorated, floating, resizable, has size or aspect ratio limits, etc..
Declaration
public static void SetWindowMonitor(Window* window, Monitor* monitor, int x, int y, int width, int height, int refreshRate)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window whose monitor, size or video mode to set. |
Monitor* | monitor | The desired monitor, or |
int | x | The desired x-coordinate of the upper-left corner of the client area. |
int | y | The desired y-coordinate of the upper-left corner of the client area. |
int | width | The desired with, in screen coordinates, of the client area or video mode. |
int | height | The desired height, in screen coordinates, of the client area or video mode. |
int | refreshRate | The desired refresh rate, in Hz, of the video mode, or DontCare. |
Remarks
This function must only be called from the main thread.
Possible errors include NotInitialized and PlatformError.
See Also
SetWindowOpacity(Window*, float)
This function sets the opacity of the window, including any decorations.
The opacity (or alpha) value is a positive finite number between zero and one, where zero is fully transparent and one is fully opaque.
The initial opacity value for newly created windows is one.
A window created with framebuffer transparency may not use whole window transparency. The results of doing this are undefined.
Declaration
public static void SetWindowOpacity(Window* window, float opacity)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window to set the opacity for. |
float | opacity | The desired opacity of the specified window. |
Remarks
This function must only be called from the main thread.
Possible errors include NotInitialized and PlatformError.
See Also
SetWindowPos(Window*, int, int)
This function sets the position, in screen coordinates, of the upper-left corner of the client area of the specified windowed mode window.
If the window is a full screen window, this function does nothing.
Do not use this function to move an already visible window unless you have very good reasons for doing so, as it will confuse and annoy the user.
The window manager may put limits on what positions are allowed. GLFW cannot and should not override these limits.
Declaration
public static void SetWindowPos(Window* window, int x, int y)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window to query. |
int | x | The x-coordinate of the upper-left corner of the client area. |
int | y | The y-coordinate of the upper-left corner of the client area. |
Remarks
This function must only be called from the main thread.
Possible errors include NotInitialized and PlatformError.
See Also
SetWindowPosCallback(Window*, WindowPosCallback)
This function sets the position callback of the specified window, which is called when the window is moved.
The callback is provided with the screen position of the upper-left corner of the client area of the window.
Declaration
public static IntPtr SetWindowPosCallback(Window* window, GLFWCallbacks.WindowPosCallback callback)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window whose callback to set. |
GLFWCallbacks.WindowPosCallback | callback | The new callback, or |
Returns
Type | Description |
---|---|
IntPtr | The previously set callback, or |
Remarks
This function must only be called from the main thread.
Possible errors include NotInitialized.
SetWindowRefreshCallback(Window*, WindowRefreshCallback)
Sets the refresh callback for the specified window.
This function sets the refresh callback of the specified window, which is called when the content area of the window needs to be redrawn, for example if the window has been exposed after having been covered by another window.
On compositing window systems such as Aero, Compiz, Aqua or Wayland, where the window contents are saved off-screen, this callback may be called only very infrequently or never at all.
Declaration
public static IntPtr SetWindowRefreshCallback(Window* window, GLFWCallbacks.WindowRefreshCallback callback)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window whose callback to set. |
GLFWCallbacks.WindowRefreshCallback | callback | The new callback, or |
Returns
Type | Description |
---|---|
IntPtr | The previously set callback, or |
Remarks
This function must only be called from the main thread.
Possible errors include NotInitialized.
SetWindowShouldClose(Window*, bool)
This function sets the value of the close flag of the specified window.
This can be used to override the user's attempt to close the window, or to signal that it should be closed.
Declaration
public static void SetWindowShouldClose(Window* window, bool value)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window whose flag to change. |
bool | value | The new value. |
Remarks
This function may be called from any thread. Access is not synchronized.
Possible errors include NotInitialized.
SetWindowSize(Window*, int, int)
This function sets the size, in screen coordinates, of the client area of the specified window.
For full screen windows, this function updates the resolution of its desired video mode and switches to the video mode closest to it, without affecting the window's context.
As the context is unaffected, the bit depths of the framebuffer remain unchanged.
If you wish to update the refresh rate of the desired video mode in addition to its resolution, see SetWindowMonitor(Window*, Monitor*, int, int, int, int, int).
The window manager may put limits on what sizes are allowed. GLFW cannot and should not override these limits.
Declaration
public static void SetWindowSize(Window* window, int width, int height)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window to resize. |
int | width | The desired width, in screen coordinates, of the window client area. |
int | height | The desired height, in screen coordinates, of the window client area. |
Remarks
This function must only be called from the main thread.
Possible errors include NotInitialized and PlatformError.
See Also
SetWindowSizeCallback(Window*, WindowSizeCallback)
This function sets the size callback of the specified window, which is called when the window is resized.
The callback is provided with the size, in screen coordinates, of the client area of the window.
Declaration
public static IntPtr SetWindowSizeCallback(Window* window, GLFWCallbacks.WindowSizeCallback callback)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window whose callback to set. |
GLFWCallbacks.WindowSizeCallback | callback | The new callback, or |
Returns
Type | Description |
---|---|
IntPtr | The previously set callback, or |
Remarks
This function must only be called from the main thread.
Possible errors include NotInitialized.
SetWindowSizeLimits(Window*, int, int, int, int)
This function sets the size limits of the client area of the specified window.
If the window is full screen, the size limits only take effect once it is made windowed.
If the window is not resizable, this function does nothing.
The size limits are applied immediately to a windowed mode window and may cause it to be resized.
The maximum dimensions must be greater than or equal to the minimum dimensions and all must be greater than or equal to zero.
Declaration
public static void SetWindowSizeLimits(Window* window, int minWidth, int minHeight, int maxWidth, int maxHeight)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window to set limits for. |
int | minWidth | The minimum width, in screen coordinates, of the client area, or DontCare. |
int | minHeight | The minimum height, in screen coordinates, of the client area, or DontCare. |
int | maxWidth | The maximum width, in screen coordinates, of the client area, or DontCare. |
int | maxHeight | The maximum height, in screen coordinates, of the client area, or DontCare. |
Remarks
If you set size limits and an aspect ratio that conflict, the results are undefined.
This function must only be called from the main thread.
Possible errors include NotInitialized, InvalidValue and PlatformError.
SetWindowTitle(Window*, string)
This function sets the window title, encoded as UTF-8, of the specified window.
Declaration
public static void SetWindowTitle(Window* window, string title)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window whose title to change. |
string | title | The UTF-8 encoded window title. |
Remarks
This function must only be called from the main thread.
OS X: The window title will not be updated until the next time you process events.
Possible errors include NotInitialized and PlatformError.
SetWindowTitleRaw(Window*, byte*)
This function sets the window title, encoded as UTF-8, of the specified window.
Declaration
public static void SetWindowTitleRaw(Window* window, byte* title)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window whose title to change. |
byte* | title | The UTF-8 encoded window title. |
Remarks
This function must only be called from the main thread.
OS X: The window title will not be updated until the next time you process events.
Possible errors include NotInitialized and PlatformError.
SetWindowUserPointer(Window*, void*)
This function sets the user-defined pointer of the specified window.
The current value is retained until the window is destroyed. The initial value is Zero.
Declaration
public static void SetWindowUserPointer(Window* window, void* pointer)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window whose pointer to set. |
void* | pointer | The new value. |
Remarks
This function may be called from any thread. Access is not synchronized.
Possible errors include NotInitialized.
SetX11SelectionString(string)
Sets the current primary selection to the specified string.
Declaration
public static void SetX11SelectionString(string @string)
Parameters
Type | Name | Description |
---|---|---|
string | string | The string. |
ShowWindow(Window*)
This function makes the specified window visible if it was previously hidden.
If the window is already visible or is in full screen mode, this function does nothing.
Declaration
public static void ShowWindow(Window* window)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window to make visible. |
Remarks
This function must only be called from the main thread.
Possible errors include NotInitialized and PlatformError.
See Also
SwapBuffers(Window*)
This function swaps the front and back buffers of the specified window when rendering with OpenGL or OpenGL ES.
If the swap interval is greater than zero, the GPU driver waits the specified number of screen updates before swapping the buffers.
The specified window must have an OpenGL or OpenGL ES context. Specifying a window without a context will generate a NoWindowContext error.
Declaration
public static void SwapBuffers(Window* window)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window whose buffers to swap. |
Remarks
EGL: The context of the specified window must be current on the calling thread.
This function may be called from any thread.
Possible errors include NotInitialized, NoWindowContext and PlatformError.
SwapInterval(int)
This function sets the swap interval for the current OpenGL or OpenGL ES context, i.e. the number of screen updates to wait from the time SwapBuffers(Window*) was called before swapping the buffers and returning. This is sometimes called vertical synchronization, vertical retrace synchronization or just vsync.
A context that supports either of the WGL_EXT_swap_control_tear
and GLX_EXT_swap_control_tear
extensions also accepts negative swap intervals,
which allows the driver to swap immediately even if a frame arrives a little bit late.
You can check for these extensions with ExtensionSupported(string).
A context must be current on the calling thread. Calling this function without a current context will cause a NoContext error.
Declaration
public static void SwapInterval(int interval)
Parameters
Type | Name | Description |
---|---|---|
int | interval | The minimum number of screen updates to wait for until the buffers are swapped by SwapBuffers(Window*). |
Remarks
This function is not called during context creation, leaving the swap interval set to whatever is the default on that platform. This is done because some swap interval extensions used by GLFW do not allow the swap interval to be reset to zero once it has been set to a non-zero value.
Some GPU drivers do not honor the requested swap interval, either because of a user setting that overrides the application's request or due to bugs in the driver.
This function may be called from any thread.
Possible errors include NotInitialized, NoContext and PlatformError.
See Also
Terminate()
This function destroys all remaining windows and cursors, restores any modified gamma ramps and frees any other allocated resources. Once this function is called, you must again call Init() successfully before you will be able to use most GLFW functions.
If GLFW has been successfully initialized, this function should be called before the application exits.
If initialization fails, there is no need to call this function, as it is called by Init() before it returns failure.
Declaration
public static void Terminate()
Remarks
The contexts of any remaining windows must not be current on any other thread when this function is called.
This function may be called before Init().
This function must not be called from a callback.
This function must only be called from the main thread.
Possible errors include PlatformError.
UpdateGamepadMappings(string)
This function parses the specified ASCII encoded string and updates the internal list with any gamepad mappings it finds.
This string may contain either a single gamepad mapping or many mappings separated by newlines.
The parser supports the full format of the gamecontrollerdb.txt source file including empty lines and comments.
See Gamepad mappings for a description of the format.
If there is already a gamepad mapping for a given GUID in the internal list, it will be replaced by the one passed to this function. If the library is terminated and re-initialized the internal list will revert to the built-in default.
Declaration
public static bool UpdateGamepadMappings(string newMapping)
Parameters
Type | Name | Description |
---|---|---|
string | newMapping | The string containing the gamepad mappings. |
Returns
Type | Description |
---|---|
bool |
|
Remarks
This function must only be called from the main thread.
Possible errors include NotInitialized and InvalidValue.
UpdateGamepadMappingsRaw(byte*)
This function parses the specified ASCII encoded string and updates the internal list with any gamepad mappings it finds.
This string may contain either a single gamepad mapping or many mappings separated by newlines.
The parser supports the full format of the gamecontrollerdb.txt source file including empty lines and comments.
See Gamepad mappings for a description of the format.
If there is already a gamepad mapping for a given GUID in the internal list, it will be replaced by the one passed to this function. If the library is terminated and re-initialized the internal list will revert to the built-in default.
Declaration
public static bool UpdateGamepadMappingsRaw(byte* newMapping)
Parameters
Type | Name | Description |
---|---|---|
byte* | newMapping | The string containing the gamepad mappings. |
Returns
Type | Description |
---|---|
bool |
|
Remarks
This function must only be called from the main thread.
Possible errors include NotInitialized and InvalidValue.
VulkanSupported()
Returns whether the Vulkan loader and an ICD have been found.
Declaration
public static bool VulkanSupported()
Returns
Type | Description |
---|---|
bool |
|
Remarks
This function returns whether the Vulkan loader and any minimally functional ICD have been found.
The availability of a Vulkan loader and even an ICD does not by itself guarantee that surface creation or even instance creation is possible. For example, on Fermi systems Nvidia will install an ICD that provides no actual Vulkan support. Call GetRequiredInstanceExtensions() to check whether the extensions necessary for Vulkan surface creation are available and GetPhysicalDevicePresentationSupport(VkHandle, VkHandle, int) to check whether a queue family of a physical device supports image presentation.
Possible errors include NotInitialized.
This function may be called from any thread.
WaitEvents()
This function puts the calling thread to sleep until at least one event is available in the event queue.
Once one or more events are available, it behaves exactly like PollEvents(), i.e. the events in the queue are processed and the function then returns immediately.
Processing events will cause the window and input callbacks associated with those events to be called.
Since not all events are associated with callbacks, this function may return without a callback having been called even if you are monitoring all callbacks.
On some platforms, a window move, resize or menu operation will cause event processing to block. This is due to how event processing is designed on those platforms. You can use the window refresh callback (SetWindowRefreshCallback(Window*, WindowRefreshCallback)) to redraw the contents of your window when necessary during such operations.
On some platforms, certain callbacks may be called outside of a call to one of the event processing functions.
If no windows exist, this function returns immediately. For synchronization of threads in applications that do not create windows, use your threading library of choice.
Event processing is not required for joystick input to work.
Declaration
public static void WaitEvents()
Remarks
This function must only be called from the main thread.
This function must not be called from a callback.
Possible errors include NotInitialized and PlatformError.
See Also
WaitEventsTimeout(double)
This function puts the calling thread to sleep until at least one event is available in the event queue, or until the specified timeout is reached.
If one or more events are available, it behaves exactly like PollEvents(), i.e. the events in the queue are processed and the function then returns immediately.
Processing events will cause the window and input callbacks associated with those events to be called.
The timeout value must be a positive finite number.
Since not all events are associated with callbacks, this function may return without a callback having been called even if you are monitoring all callbacks.
On some platforms, a window move, resize or menu operation will cause event processing to block. This is due to how event processing is designed on those platforms.
You can use the window refresh callback (SetWindowRefreshCallback(Window*, WindowRefreshCallback)) to redraw the contents of your window when necessary during such operations.
On some platforms, certain callbacks may be called outside of a call to one of the event processing functions.
If no windows exist, this function returns immediately.
For synchronization of threads in applications that do not create windows, use your threading library of choice.
Event processing is not required for joystick input to work.
Declaration
public static void WaitEventsTimeout(double timeout)
Parameters
Type | Name | Description |
---|---|---|
double | timeout | The maximum amount of time, in seconds, to wait. |
Remarks
This function must only be called from the main thread.
This function must not be called from a callback.
See Also
WindowHint(WindowHintBool, bool)
This function sets hints for the next call to CreateWindow(int, int, string, Monitor*, Window*). The hints, once set, retain their values until changed by a call to WindowHint(WindowHintBool, bool) or DefaultWindowHints(), or until the library is terminated.
This function does not check whether the specified hint values are valid. If you set hints to invalid values this will instead be reported by the next call to CreateWindow(int, int, string, Monitor*, Window*).
Declaration
public static void WindowHint(WindowHintBool hint, bool value)
Parameters
Type | Name | Description |
---|---|---|
WindowHintBool | hint | The WindowHintInt to set. |
bool | value | The new value of the framebuffer attribute hint. |
Remarks
This function must only be called from the main thread.
Possible errors include NotInitialized and InvalidEnum.
See Also
WindowHint(WindowHintClientApi, ClientApi)
This function sets hints for the next call to CreateWindow(int, int, string, Monitor*, Window*). The hints, once set, retain their values until changed by a call to WindowHint(WindowHintClientApi, ClientApi) or DefaultWindowHints(), or until the library is terminated.
This function does not check whether the specified hint values are valid. If you set hints to invalid values this will instead be reported by the next call to CreateWindow(int, int, string, Monitor*, Window*).
Declaration
public static void WindowHint(WindowHintClientApi hint, ClientApi value)
Parameters
Type | Name | Description |
---|---|---|
WindowHintClientApi | hint | |
ClientApi | value | The new value of the window hint. |
Remarks
This function must only be called from the main thread.
Possible errors include NotInitialized and InvalidEnum.
See Also
WindowHint(WindowHintContextApi, ContextApi)
This function sets hints for the next call to CreateWindow(int, int, string, Monitor*, Window*). The hints, once set, retain their values until changed by a call to WindowHint(WindowHintContextApi, ContextApi) or DefaultWindowHints(), or until the library is terminated.
This function does not check whether the specified hint values are valid. If you set hints to invalid values this will instead be reported by the next call to CreateWindow(int, int, string, Monitor*, Window*).
Declaration
public static void WindowHint(WindowHintContextApi hint, ContextApi value)
Parameters
Type | Name | Description |
---|---|---|
WindowHintContextApi | hint | |
ContextApi | value | The new value of the window hint. |
Remarks
This function must only be called from the main thread.
Possible errors include NotInitialized and InvalidEnum.
See Also
WindowHint(WindowHintInt, int)
This function sets hints for the next call to CreateWindow(int, int, string, Monitor*, Window*). The hints, once set, retain their values until changed by a call to WindowHint(WindowHintInt, int) or DefaultWindowHints(), or until the library is terminated.
This function does not check whether the specified hint values are valid. If you set hints to invalid values this will instead be reported by the next call to CreateWindow(int, int, string, Monitor*, Window*).
Declaration
public static void WindowHint(WindowHintInt hint, int value)
Parameters
Type | Name | Description |
---|---|---|
WindowHintInt | hint | The WindowHintInt to set. |
int | value | The new value of the framebuffer attribute hint. |
Remarks
This function must only be called from the main thread.
Possible errors include NotInitialized and InvalidEnum.
See Also
WindowHint(WindowHintOpenGlProfile, OpenGlProfile)
This function sets hints for the next call to CreateWindow(int, int, string, Monitor*, Window*). The hints, once set, retain their values until changed by a call to WindowHint(WindowHintOpenGlProfile, OpenGlProfile) or DefaultWindowHints(), or until the library is terminated.
This function does not check whether the specified hint values are valid. If you set hints to invalid values this will instead be reported by the next call to CreateWindow(int, int, string, Monitor*, Window*).
Declaration
public static void WindowHint(WindowHintOpenGlProfile hint, OpenGlProfile value)
Parameters
Type | Name | Description |
---|---|---|
WindowHintOpenGlProfile | hint | |
OpenGlProfile | value | The new value of the window hint. |
Remarks
This function must only be called from the main thread.
Possible errors include NotInitialized and InvalidEnum.
See Also
WindowHint(WindowHintReleaseBehavior, ReleaseBehavior)
This function sets hints for the next call to CreateWindow(int, int, string, Monitor*, Window*). The hints, once set, retain their values until changed by a call to WindowHint(WindowHintReleaseBehavior, ReleaseBehavior) or DefaultWindowHints(), or until the library is terminated.
This function does not check whether the specified hint values are valid. If you set hints to invalid values this will instead be reported by the next call to CreateWindow(int, int, string, Monitor*, Window*).
Declaration
public static void WindowHint(WindowHintReleaseBehavior hint, ReleaseBehavior value)
Parameters
Type | Name | Description |
---|---|---|
WindowHintReleaseBehavior | hint | |
ReleaseBehavior | value | The new value of the window hint. |
Remarks
This function must only be called from the main thread.
Possible errors include NotInitialized and InvalidEnum.
See Also
WindowHint(WindowHintRobustness, Robustness)
This function sets hints for the next call to CreateWindow(int, int, string, Monitor*, Window*). The hints, once set, retain their values until changed by a call to WindowHint(WindowHintRobustness, Robustness) or DefaultWindowHints(), or until the library is terminated.
This function does not check whether the specified hint values are valid. If you set hints to invalid values this will instead be reported by the next call to CreateWindow(int, int, string, Monitor*, Window*).
Declaration
public static void WindowHint(WindowHintRobustness hint, Robustness value)
Parameters
Type | Name | Description |
---|---|---|
WindowHintRobustness | hint | |
Robustness | value | The new value of the window hint. |
Remarks
This function must only be called from the main thread.
Possible errors include NotInitialized and InvalidEnum.
See Also
WindowHint(WindowHintString, string)
Sets the specified window hint to the desired value.
This function sets hints for the next call to @ref glfwCreateWindow. The hints, once set, retain their values until changed by a call to this function or DefaultWindowHints(), or until the library is terminated.
This function does not check whether the specified hint values are valid. If you set hints to invalid values this will instead be reported by the next call to CreateWindow(int, int, string, Monitor*, Window*).
Some hints are platform specific. These may be set on any platform but they will only affect their specific platform. Other platforms will ignore them. Setting these hints requires no platform specific headers or functions.
Declaration
public static void WindowHint(WindowHintString hint, string value)
Parameters
Type | Name | Description |
---|---|---|
WindowHintString | hint | The window hint to set. |
string | value | The new value of the set hint. |
Remarks
Possible errors include NotInitialized InvalidEnum.
The string is copied before this function returns.
This function must only be called from the main thread.
WindowHintRaw(WindowHintString, byte*)
Sets the specified window hint to the desired value.
This function sets hints for the next call to @ref glfwCreateWindow. The hints, once set, retain their values until changed by a call to this function or DefaultWindowHints(), or until the library is terminated.
This function does not check whether the specified hint values are valid. If you set hints to invalid values this will instead be reported by the next call to CreateWindow(int, int, string, Monitor*, Window*).
Some hints are platform specific. These may be set on any platform but they will only affect their specific platform. Other platforms will ignore them. Setting these hints requires no platform specific headers or functions.
Declaration
public static void WindowHintRaw(WindowHintString hint, byte* value)
Parameters
Type | Name | Description |
---|---|---|
WindowHintString | hint | The window hint to set. |
byte* | value | The new value of the set hint. |
Remarks
Possible errors include NotInitialized InvalidEnum.
The string is copied before this function returns.
This function must only be called from the main thread.
WindowShouldClose(Window*)
This function returns the value of the close flag of the specified window.
Declaration
public static bool WindowShouldClose(Window* window)
Parameters
Type | Name | Description |
---|---|---|
Window* | window | The window to query. |
Returns
Type | Description |
---|---|
bool | The value of the close flag. |
Remarks
This function may be called from any thread. Access is not synchronized.
Possible errors include NotInitialized.