Class GLFW


  • public class GLFW
    extends java.lang.Object
    Native bindings to the GLFW library.

    GLFW is a free, Open Source, multi-platform library for opening a window, creating an OpenGL context and managing input. It is easy to integrate into existing applications and does not lay claim to the main loop.

    • Method Detail

      • glfwInit

        public static boolean glfwInit()
        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.

        Note
        • This function must only be called from the main thread.
        • macOS: This function will change the current directory of the application to the `Contents/Resources` subdirectory of the application's bundle, if present. This can be disabled with the COCOA_CHDIR_RESOURCES init hint.
        Returns:
        TRUE if successful, or FALSE if an error occurred.
        Since:
        version 1.0
      • glfwTerminate

        public static void glfwTerminate()
        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.

        Note
        • This function may be called before Init.
        • This function must only be called from the main thread.
        • This function must not be called from a callback.
        • No window's context may be current on another thread when this function is called.
        Since:
        version 1.0
      • glfwInitHint

        public static void glfwInitHint​(int hint,
                                        int value)
        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 simply ignore them. Setting these hints requires no platform specific headers or functions.

        Note
        • This function may be called before Init.
        • This function must only be called from the main thread.
        Parameters:
        hint - the init hint to set. One of:
        JOYSTICK_HAT_BUTTONSCOCOA_CHDIR_RESOURCESCOCOA_MENUBAR
        value - the new value of the init hint
        Since:
        version 3.3
      • nglfwGetVersion

        public static void nglfwGetVersion​(long major,
                                           long minor,
                                           long rev)
        Unsafe version of: GetVersion
      • glfwGetVersion

        public static void glfwGetVersion​(@Nullable
                                          java.nio.IntBuffer major,
                                          @Nullable
                                          java.nio.IntBuffer minor,
                                          @Nullable
                                          java.nio.IntBuffer rev)
        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.
        Note
        • Any or all of the version arguments may be NULL.
        • This function always succeeds.
        • This function may be called before Init.
        • This function may be called from any thread.
        Parameters:
        major - where to store the major version number, or NULL
        minor - where to store the minor version number, or NULL
        rev - where to store the revision number, or NULL
        Since:
        version 1.0
      • nglfwGetVersionString

        public static long nglfwGetVersionString()
        Unsafe version of: GetVersionString
      • glfwGetVersionString

        public static java.lang.String glfwGetVersionString()
        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 function already provides the version of the library binary in numerical format.

        Note
        • This function always succeeds.
        • This function may be called before Init.
        • This function may be called from any thread.
        • The returned string is static and compile-time generated.
        Returns:
        the ASCII encoded GLFW version string
        Since:
        version 3.0
      • nglfwGetError

        public static int nglfwGetError​(long description)
        Unsafe version of: GetError
      • glfwGetError

        public static int glfwGetError​(@Nullable
                                       PointerBuffer description)
        Returns and clears the last error for the calling thread.

        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 NO_ERROR (zero), and the description pointer is set to NULL.

        Note
        • This function may be called before Init.
        • This function may be called from any thread.
        • The returned string is allocated and freed by GLFW. You should not free it yourself. It is guaranteed to be valid only until the next error occurs or the library is terminated.
        Parameters:
        description - where to store the error description pointer, or NULL
        Returns:
        the last error code for the calling thread, or NO_ERROR (zero)
        Since:
        version 3.3
      • nglfwSetErrorCallback

        public static long nglfwSetErrorCallback​(long cbfun)
        Unsafe version of: SetErrorCallback
      • glfwSetErrorCallback

        @Nullable
        public static GLFWErrorCallback glfwSetErrorCallback​(@Nullable
                                                             GLFWErrorCallbackI cbfun)
        Sets the error callback, which is called with an error code and a human-readable description each time a GLFW error occurs.

        The error code is set before the callback is called. Calling GetError from the error callback will return the same value as the error code argument.

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

        Once set, the error callback remains set even after the library has been terminated.

        Note
        • This function may be called before Init.
        • This function must only be called from the main thread.
        Parameters:
        cbfun - the new callback or NULL to remove the currently set callback
        Returns:
        the previously set callback, or NULL if no callback was set
        Since:
        version 3.0
      • nglfwGetMonitors

        public static long nglfwGetMonitors​(long count)
        Unsafe version of: GetMonitors
        Parameters:
        count - where to store the number of monitors in the returned array. This is set to zero if an error occurred.
      • glfwGetMonitors

        @Nullable
        public static PointerBuffer glfwGetMonitors()
        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.

        The returned array is allocated and freed by GLFW. You should not free it yourself. It is guaranteed to be valid only until the monitor configuration changes or the library is terminated.

        This function must only be called from the main thread.

        Returns:
        an array of monitor handlers, or NULL if no monitors were found or if an error occurred
        Since:
        version 3.0
      • glfwGetPrimaryMonitor

        public static long glfwGetPrimaryMonitor()
        Returns the primary monitor. This is usually the monitor where elements like the task bar or global menu bar are located.

        This function must only be called from the main thread.

        The primary monitor is always first in the array returned by GetMonitors.

        Returns:
        the primary monitor, or NULL if no monitors were found or if an error occurred
        Since:
        version 3.0
      • nglfwGetMonitorPos

        public static void nglfwGetMonitorPos​(long monitor,
                                              long xpos,
                                              long ypos)
        Unsafe version of: GetMonitorPos
      • glfwGetMonitorPos

        public static void glfwGetMonitorPos​(long monitor,
                                             @Nullable
                                             java.nio.IntBuffer xpos,
                                             @Nullable
                                             java.nio.IntBuffer ypos)
        Returns the position, in screen coordinates, of the upper-left corner of the specified monitor.

        Any or all of the position arguments may be NULL. If an error occurs, all non-NULL position arguments will be set to zero.

        This function must only be called from the main thread.

        Parameters:
        monitor - the monitor to query
        xpos - where to store the monitor x-coordinate, or NULL
        ypos - where to store the monitor y-coordinate, or NULL
        Since:
        version 3.0
      • nglfwGetMonitorPhysicalSize

        public static void nglfwGetMonitorPhysicalSize​(long monitor,
                                                       long widthMM,
                                                       long heightMM)
        Unsafe version of: GetMonitorPhysicalSize
      • glfwGetMonitorPhysicalSize

        public static void glfwGetMonitorPhysicalSize​(long monitor,
                                                      @Nullable
                                                      java.nio.IntBuffer widthMM,
                                                      @Nullable
                                                      java.nio.IntBuffer heightMM)
        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 data is incorrect or because the driver does not report it accurately.

        Any or all of the size arguments may be NULL. If an error occurs, all non-NULL size arguments will be set to zero.

        Note
        • This function must only be called from the main thread.
        • Windows: The OS calculates the returned physical size from the current resolution and system DPI instead of querying the monitor EDID data.
        Parameters:
        monitor - the monitor to query
        widthMM - where to store the width, in millimetres, of the monitor's display area, or NULL
        heightMM - where to store the height, in millimetres, of the monitor's display area, or NULL
        Since:
        version 3.0
      • nglfwGetMonitorContentScale

        public static void nglfwGetMonitorContentScale​(long monitor,
                                                       long xscale,
                                                       long yscale)
        Unsafe version of: GetMonitorContentScale
      • glfwGetMonitorContentScale

        public static void glfwGetMonitorContentScale​(long monitor,
                                                      @Nullable
                                                      java.nio.FloatBuffer xscale,
                                                      @Nullable
                                                      java.nio.FloatBuffer yscale)
        Retrieves the content scale for the specified monitor.

        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.

        This function must only be called from the main thread.

        Parameters:
        monitor - the monitor to query
        xscale - where to store the x-axis content scale, or NULL
        yscale - where to store the y-axis content scale, or NULL
        Since:
        version 3.3
      • nglfwGetMonitorName

        public static long nglfwGetMonitorName​(long monitor)
        Unsafe version of: GetMonitorName
      • glfwGetMonitorName

        @Nullable
        public static java.lang.String glfwGetMonitorName​(long monitor)
        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.

        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.

        Parameters:
        monitor - the monitor to query
        Returns:
        the UTF-8 encoded name of the monitor, or NULL if an error occurred
        Since:
        version 3.0
      • glfwSetMonitorUserPointer

        public static void glfwSetMonitorUserPointer​(long monitor,
                                                     long pointer)
        Sets the user pointer of the specified monitor.

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

        This function may be called from the monitor callback, even for a monitor that is being disconnected.

        This function may be called from any thread. Access is not synchronized.

        Parameters:
        monitor - the monitor whose pointer to set
        pointer - the new value
        Since:
        version 3.3
      • glfwGetMonitorUserPointer

        public static long glfwGetMonitorUserPointer​(long monitor)
        Returns the user pointer of the specified monitor.

        This function returns the current value of the user-defined pointer of the specified monitor. The initial value is NULL.

        This function may be called from the monitor callback, even for a monitor that is being disconnected.

        This function may be called from any thread. Access is not synchronized.

        Parameters:
        monitor - the monitor whose pointer to return
        Since:
        version 3.3
      • nglfwSetMonitorCallback

        public static long nglfwSetMonitorCallback​(long cbfun)
        Unsafe version of: SetMonitorCallback
      • glfwSetMonitorCallback

        @Nullable
        public static GLFWMonitorCallback glfwSetMonitorCallback​(@Nullable
                                                                 GLFWMonitorCallbackI cbfun)
        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.

        This function must only be called from the main thread.

        Parameters:
        cbfun - the new callback, or NULL to remove the currently set callback
        Returns:
        the previously set callback, or NULL if no callback was set or the library had not been initialized
        Since:
        version 3.0
      • nglfwGetVideoModes

        public static long nglfwGetVideoModes​(long monitor,
                                              long count)
        Unsafe version of: GetVideoModes
        Parameters:
        count - where to store the number of video modes in the returned array. This is set to zero if an error occurred.
      • glfwGetVideoModes

        @Nullable
        public static GLFWVidMode.Buffer glfwGetVideoModes​(long monitor)
        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).

        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.

        Parameters:
        monitor - the monitor to query
        Returns:
        an array of video modes, or NULL if an error occurred
        Since:
        version 1.0
      • nglfwGetVideoMode

        public static long nglfwGetVideoMode​(long monitor)
        Unsafe version of: GetVideoMode
      • glfwGetVideoMode

        @Nullable
        public static GLFWVidMode glfwGetVideoMode​(long monitor)
        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.

        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.

        Parameters:
        monitor - the monitor to query
        Returns:
        the current mode of the monitor, or NULL if an error occurred
        Since:
        version 3.0
      • glfwSetGamma

        public static void glfwSetGamma​(long monitor,
                                        float gamma)
        Generates a 256-element gamma ramp from the specified exponent and then calls SetGammaRamp with it. The value must be a finite number greater than zero.

        The software controlled gamma ramp is applied in addition to the hardware gamma correction, which today is usually an approximation of sRGB gamma. This means that setting a perfectly linear ramp, or gamma 1.0, will produce the default (usually sRGB-like) behavior.

        For gamma correct rendering with OpenGL or OpenGL ES, see the SRGB_CAPABLE hint.

        Notes:

        • This function must only be called from the main thread.
        • Wayland: Gamma handling is a privileged protocol, this function will thus never be implemented and emits PLATFORM_ERROR.
        Parameters:
        monitor - the monitor whose gamma ramp to set
        gamma - the desired exponent
        Since:
        version 3.0
      • nglfwGetGammaRamp

        public static long nglfwGetGammaRamp​(long monitor)
        Unsafe version of: GetGammaRamp
      • glfwGetGammaRamp

        @Nullable
        public static GLFWGammaRamp glfwGetGammaRamp​(long monitor)
        Returns the current gamma ramp of the specified monitor.

        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.

        Notes:

        • This function must only be called from the main thread.
        • Wayland: Gamma handling is a privileged protocol, this function will thus never be implemented and emits PLATFORM_ERROR while returning NULL.
        Parameters:
        monitor - the monitor to query
        Returns:
        the current gamma ramp, or NULL if an error occurred
        Since:
        version 3.0
      • nglfwSetGammaRamp

        public static void nglfwSetGammaRamp​(long monitor,
                                             long ramp)
        Unsafe version of: SetGammaRamp
      • glfwSetGammaRamp

        public static void glfwSetGammaRamp​(long monitor,
                                            GLFWGammaRamp ramp)
        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.

        The software controlled gamma ramp is applied in addition to the hardware gamma correction, which today is usually an approximation of sRGB gamma. This means that setting a perfectly linear ramp, or gamma 1.0, will produce the default (usually sRGB-like) behavior.

        For gamma correct rendering with OpenGL or OpenGL ES, see the SRGB_CAPABLE hint.

        Note
        • This function must only be called from the main thread.
        • Gamma ramp sizes other than 256 are not supported by all hardware
        • Windows: The gamma ramp size must be 256.
        • Wayland: Gamma handling is a privileged protocol, this function will thus never be implemented and emits PLATFORM_ERROR.
        • The specified gamma ramp is copied before this function returns.
        Parameters:
        monitor - the monitor whose gamma ramp to set
        ramp - the gamma ramp to use
        Since:
        version 3.0
      • glfwDefaultWindowHints

        public static void glfwDefaultWindowHints()
        Resets all window hints to their default values. See WindowHint for details.

        This function must only be called from the main thread.

        Since:
        version 3.0
      • nglfwWindowHintString

        public static void nglfwWindowHintString​(int hint,
                                                 long value)
        Unsafe version of: WindowHintString
      • glfwWindowHintString

        public static void glfwWindowHintString​(int hint,
                                                java.nio.ByteBuffer value)
        
        public static void glfwWindowHintString​(int hint,
                                                java.lang.CharSequence value)
        
        Sets the specified window hint to the desired value.

        This function sets hints for the next call to CreateWindow. The hints, once set, retain their values until changed by a call to this function or DefaultWindowHints, or until the library is terminated.

        Only string type hints can be set with this function. Integer value hints are set with WindowHint.

        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.

        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.

        Supported and default values
        NameDefault valueSupported values
        COCOA_FRAME_NAME""A UTF-8 encoded frame autosave name
        X11_CLASS_NAME""An ASCII encoded WM_CLASS class name
        X11_INSTANCE_NAME""An ASCII encoded WM_CLASS instance name

        This function must only be called from the main thread.

        Parameters:
        hint - the window hint to set. One of:
        COCOA_FRAME_NAMEX11_CLASS_NAMEX11_INSTANCE_NAME
        value - the new value of the window hint. The specified string is copied before this function returns.
        Since:
        version 3.3
      • nglfwCreateWindow

        public static long nglfwCreateWindow​(int width,
                                             int height,
                                             long title,
                                             long monitor,
                                             long share)
        Unsafe version of: CreateWindow
      • glfwCreateWindow

        public static long glfwCreateWindow​(int width,
                                            int height,
                                            java.nio.ByteBuffer title,
                                            long monitor,
                                            long share)
        
        public static long glfwCreateWindow​(int width,
                                            int height,
                                            java.lang.CharSequence title,
                                            long monitor,
                                            long share)
        
        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 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, use queries like GetWindowAttrib and GetWindowSize and GetFramebufferSize.

        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 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 full screen.

        Once you have created the window, you can switch it between windowed and full screen mode with SetWindowMonitor. 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 and then show it.

        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.

        The swap interval is not set during window creation and the initial value may vary depending on driver settings and defaults.

        Note
        • This function must only be called from the main thread.
        • 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_APPLICATION icon will be used instead. To set a different icon, see SetWindowIcon.
        • Windows: The context to share resources with may not be current on any other thread.
        • The OS only supports forward-compatible core profile contexts for OpenGL versions 3.2 and later. Before creating an OpenGL context of version 3.2 or later you must set the OPENGL_FORWARD_COMPAT and OPENGL_PROFILE hints accordingly. OpenGL 3.0 and 3.1 contexts are not supported at all on macOS.
        • macOS: 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.
        • macOS: The first time a window is created the menu bar is created. If GLFW finds a `MainMenu.nib` it is loaded and assumed to contain a menu bar. Otherwise a minimal menu bar is created manually with common commands like Hide, Quit and About. The About entry opens a minimal about dialog with information from the application's bundle. Menu bar creation can be disabled entirely with the COCOA_MENUBAR init hint.
        • macOS: On macOS 10.10 and later the window frame will not be rendered at full resolution on Retina displays unless the COCOA_RETINA_FRAMEBUFFER hint is TRUE and the NSHighResolutionCapable key is enabled in the application bundle's Info.plist. For more information, see High Resolution Guidelines for macOS in the Mac Developer Library.
        • macOS: When activating frame autosaving with COCOA_FRAME_NAME, the specified window size and position may be overridden by previously saved values.
        • 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.
        • X11: The class part of the WM_CLASS window property will by default be set to the window title passed to this function. The instance part will use the contents of the RESOURCE_NAME environment variable, if present and not empty, or fall back to the window title. Set the X11_CLASS_NAME and X11_INSTANCE_NAME window hints to override this.
        • Wayland: The window frame is currently very simple, only allowing window resize or move. A compositor can still emit close, maximize or fullscreen events, using for example a keybind mechanism. Additionally, the wp_viewporter protocol is required for this feature, otherwise the window will not be decorated.
        • Wayland: A full screen window will not attempt to change the mode, no matter what the requested size or refresh rate.
        • Wayland: Screensaver inhibition requires the idle-inhibit protocol to be implemented in the user's compositor.
        Parameters:
        width - the desired width, in screen coordinates, of the window
        height - the desired height, in screen coordinates, of the window
        title - initial, UTF-8 encoded window title
        monitor - the monitor to use for fullscreen mode, or NULL for windowed mode
        share - the window whose context to share resources with, or NULL to not share resources
        Returns:
        the handle of the created window, or NULL if an error occurred
        Since:
        version 1.0
      • glfwDestroyWindow

        public static void glfwDestroyWindow​(long window)
        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.

        Note
        • This function must only be called from the main thread.
        • This function must not be called from a callback.
        • The context of the specified window must not be current on any other thread when this function is called.
        Parameters:
        window - the window to destroy
        Since:
        version 1.0
      • glfwWindowShouldClose

        public static boolean glfwWindowShouldClose​(long window)
        Returns the value of the close flag of the specified window.

        This function may be called from any thread.

        Parameters:
        window - the window to query
        Returns:
        the value of the close flag
        Since:
        version 3.0
      • glfwSetWindowShouldClose

        public static void glfwSetWindowShouldClose​(long window,
                                                    boolean value)
        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.

        This function may be called from any thread. Access is not synchronized.

        Parameters:
        window - the window whose flag to change
        value - the new value
        Since:
        version 3.0
      • nglfwSetWindowTitle

        public static void nglfwSetWindowTitle​(long window,
                                               long title)
        Unsafe version of: SetWindowTitle
      • glfwSetWindowTitle

        public static void glfwSetWindowTitle​(long window,
                                              java.nio.ByteBuffer title)
        
        public static void glfwSetWindowTitle​(long window,
                                              java.lang.CharSequence title)
        
        Sets the window title, encoded as UTF-8, of the specified window.

        This function must only be called from the main thread.

        macOS: The window title will not be updated until the next time you process events.

        Parameters:
        window - the window whose title to change
        title - the UTF-8 encoded window title
        Since:
        version 1.0
      • nglfwSetWindowIcon

        public static void nglfwSetWindowIcon​(long window,
                                              int count,
                                              long images)
        Unsafe version of: SetWindowIcon
        Parameters:
        count - the number of images in the specified array, or zero to revert to the default window icon
      • glfwSetWindowIcon

        public static void glfwSetWindowIcon​(long window,
                                             @Nullable
                                             GLFWImage.Buffer images)
        Sets the icon for the specified window.

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

        Notes:

        • This function must only be called from the main thread.
        • The specified image data is copied before this function returns.
        • macOS: 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.
        • Wayland: There is no existing protocol to change an icon, the window will thus inherit the one defined in the application's desktop file. This function always emits PLATFORM_ERROR.
        Parameters:
        window - the window whose icon to set
        images - the images to create the icon from. This is ignored if count is zero.
        Since:
        version 3.2
      • nglfwGetWindowPos

        public static void nglfwGetWindowPos​(long window,
                                             long xpos,
                                             long ypos)
        Unsafe version of: GetWindowPos
      • glfwGetWindowPos

        public static void glfwGetWindowPos​(long window,
                                            @Nullable
                                            java.nio.IntBuffer xpos,
                                            @Nullable
                                            java.nio.IntBuffer ypos)
        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 NULL. If an error occurs, all non-NULL position arguments will be set to zero.

        Notes:

        • This function must only be called from the main thread.
        • Wayland: There is no way for an application to retrieve the global position of its windows, this function will always emit PLATFORM_ERROR.
        Parameters:
        window - the window to query
        xpos - where to store the x-coordinate of the upper-left corner of the client area, or NULL
        ypos - where to store the y-coordinate of the upper-left corner of the client area, or NULL
        Since:
        version 3.0
      • glfwSetWindowPos

        public static void glfwSetWindowPos​(long window,
                                            int xpos,
                                            int ypos)
        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.

        Notes:

        • This function must only be called from the main thread.
        • Wayland: There is no way for an application to set the global position of its windows, this function will always emit PLATFORM_ERROR.
        Parameters:
        window - the window to query
        xpos - the x-coordinate of the upper-left corner of the client area
        ypos - the y-coordinate of the upper-left corner of the client area
        Since:
        version 1.0
      • nglfwGetWindowSize

        public static void nglfwGetWindowSize​(long window,
                                              long width,
                                              long height)
        Unsafe version of: GetWindowSize
      • glfwGetWindowSize

        public static void glfwGetWindowSize​(long window,
                                             @Nullable
                                             java.nio.IntBuffer width,
                                             @Nullable
                                             java.nio.IntBuffer height)
        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.

        Any or all of the size arguments may be NULL. If an error occurs, all non-NULL size arguments will be set to zero.

        This function must only be called from the main thread.

        Parameters:
        window - the window whose size to retrieve
        width - where to store the width, in screen coordinates, of the client area, or NULL
        height - where to store the height, in screen coordinates, of the client area, or NULL
        Since:
        version 1.0
      • glfwSetWindowSizeLimits

        public static void glfwSetWindowSizeLimits​(long window,
                                                   int minwidth,
                                                   int minheight,
                                                   int maxwidth,
                                                   int maxheight)
        Sets the size limits of the client area of the specified window. If the window is full screen, the size limits only take effect if 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.

        Notes:

        • This function must only be called from the main thread.
        • Wayland: The size limits will not be applied until the window is actually resized, either by the user or by the compositor.
        Parameters:
        window - the window to set limits for
        minwidth - the minimum width, in screen coordinates, of the client area, or DONT_CARE
        minheight - the minimum height, in screen coordinates, of the client area, or DONT_CARE
        maxwidth - the maximum width, in screen coordinates, of the client area, or DONT_CARE
        maxheight - the maximum height, in screen coordinates, of the client area, or DONT_CARE
        Since:
        version 3.2
      • glfwSetWindowAspectRatio

        public static void glfwSetWindowAspectRatio​(long window,
                                                    int numer,
                                                    int denom)
        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 DONT_CARE 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.

        Notes:

        • This function must only be called from the main thread.
        • Wayland: The aspect ratio will not be applied until the window is actually resized, either by the user or by the compositor.
        Parameters:
        window - the window to set limits for
        numer - the numerator of the desired aspect ratio, or DONT_CARE
        denom - the denominator of the desired aspect ratio, or DONT_CARE
        Since:
        version 3.2
      • glfwSetWindowSize

        public static void glfwSetWindowSize​(long window,
                                             int width,
                                             int height)
        Sets the size, in pixels, 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.

        The window manager may put limits on what sizes are allowed. GLFW cannot and should not override these limits.

        Notes:

        • This function must only be called from the main thread.
        • Wayland: A full screen window will not attempt to change the mode, no matter what the requested size.
        Parameters:
        window - the window to resize
        width - the desired width, in screen coordinates, of the window client area
        height - the desired height, in screen coordinates, of the window client area
        Since:
        version 1.0
      • nglfwGetFramebufferSize

        public static void nglfwGetFramebufferSize​(long window,
                                                   long width,
                                                   long height)
        Unsafe version of: GetFramebufferSize
      • glfwGetFramebufferSize

        public static void glfwGetFramebufferSize​(long window,
                                                  @Nullable
                                                  java.nio.IntBuffer width,
                                                  @Nullable
                                                  java.nio.IntBuffer height)
        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.

        Any or all of the size arguments may be NULL. If an error occurs, all non-NULL size arguments will be set to zero.

        This function must only be called from the main thread.

        Parameters:
        window - the window whose framebuffer to query
        width - where to store the width, in pixels, of the framebuffer, or NULL
        height - where to store the height, in pixels, of the framebuffer, or NULL
        Since:
        version 3.0
      • nglfwGetWindowFrameSize

        public static void nglfwGetWindowFrameSize​(long window,
                                                   long left,
                                                   long top,
                                                   long right,
                                                   long bottom)
        Unsafe version of: GetWindowFrameSize
      • glfwGetWindowFrameSize

        public static void glfwGetWindowFrameSize​(long window,
                                                  @Nullable
                                                  java.nio.IntBuffer left,
                                                  @Nullable
                                                  java.nio.IntBuffer top,
                                                  @Nullable
                                                  java.nio.IntBuffer right,
                                                  @Nullable
                                                  java.nio.IntBuffer bottom)
        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 NULL. If an error occurs, all non-NULL size arguments will be set to zero.

        This function must only be called from the main thread.

        Parameters:
        window - the window whose frame size to query
        left - where to store the size, in screen coordinates, of the left edge of the window frame, or NULL
        top - where to store the size, in screen coordinates, of the top edge of the window frame, or NULL
        right - where to store the size, in screen coordinates, of the right edge of the window frame, or NULL
        bottom - where to store the size, in screen coordinates, of the bottom edge of the window frame, or NULL
        Since:
        version 3.1
      • nglfwGetWindowContentScale

        public static void nglfwGetWindowContentScale​(long window,
                                                      long xscale,
                                                      long yscale)
        Unsafe version of: GetWindowContentScale
      • glfwGetWindowContentScale

        public static void glfwGetWindowContentScale​(long window,
                                                     @Nullable
                                                     java.nio.FloatBuffer xscale,
                                                     @Nullable
                                                     java.nio.FloatBuffer yscale)
        Retrieves the content scale for the specified window.

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

        On systems where each monitor can have its own content scale, the window content scale will depend on which monitor the system considers the window to be on.

        Parameters:
        window - the window to query
        xscale - where to store the x-axis content scale, or NULL
        yscale - where to store the y-axis content scale, or NULL
        Since:
        version 3.3
      • glfwGetWindowOpacity

        public static float glfwGetWindowOpacity​(long window)
        Returns the opacity of the whole 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.

        This function must only be called from the main thread.

        Parameters:
        window - the window to query
        Returns:
        the opacity value of the specified window
        Since:
        version 3.3
      • glfwSetWindowOpacity

        public static void glfwSetWindowOpacity​(long window,
                                                float opacity)
        Sets the opacity of the whole window.

        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.

        This function must only be called from the main thread.

        Parameters:
        window - the window to set the opacity for
        opacity - the desired opacity of the specified window
        Since:
        version 3.3
      • glfwIconifyWindow

        public static void glfwIconifyWindow​(long window)
        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.

        Notes:

        • This function must only be called from the main thread.
        • Wayland: There is no concept of iconification in wl_shell, this function will emit PLATFORM_ERROR when using this deprecated protocol.
        Parameters:
        window - the window to iconify
        Since:
        version 2.1
      • glfwRestoreWindow

        public static void glfwRestoreWindow​(long window)
        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.

        This function must only be called from the main thread.

        Parameters:
        window - the window to restore
        Since:
        version 2.1
      • glfwMaximizeWindow

        public static void glfwMaximizeWindow​(long window)
        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.

        This function may only be called from the main thread.

        Parameters:
        window - the window to maximize
        Since:
        version 3.2
      • glfwShowWindow

        public static void glfwShowWindow​(long window)
        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.

        By default, windowed mode windows are focused when shown. Set the FOCUS_ON_SHOW window hint to change this behavior for all newly created windows, or change the behavior for an existing window with SetWindowAttrib.

        This function must only be called from the main thread.

        Parameters:
        window - the window to make visible
        Since:
        version 3.0
      • glfwHideWindow

        public static void glfwHideWindow​(long window)
        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.

        This function must only be called from the main thread.

        Parameters:
        window - the window to hide
        Since:
        version 3.0
      • glfwFocusWindow

        public static void glfwFocusWindow​(long window)
        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 hint to disable this behavior.

        Also by default, windowed mode windows are focused when shown with ShowWindow. Set the FOCUS_ON_SHOW window hint 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.

        For a less disruptive way of getting the user's attention, see RequestWindowAttention.

        Notes:

        • This function must only be called from the main thread.
        • Wayland: It is not possible for an application to bring its windows to front, this function will always emit PLATFORM_ERROR.
        Parameters:
        window - the window to give input focus
        Since:
        version 3.2
      • glfwRequestWindowAttention

        public static void glfwRequestWindowAttention​(long window)
        Requests user attention to the specified 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.

        Note
        • This function must only be called from the main thread.
        • macOS: Attention is requested to the application as a whole, not the specific window.
        Parameters:
        window - the window to request attention to
        Since:
        version 3.3
      • glfwGetWindowMonitor

        public static long glfwGetWindowMonitor​(long window)
        Returns the handle of the monitor that the specified window is in full screen on.

        This function must only be called from the main thread.

        Parameters:
        window - the window to query
        Returns:
        the monitor, or NULL if the window is in windowed mode or an error occurred
        Since:
        version 3.0
      • glfwSetWindowMonitor

        public static void glfwSetWindowMonitor​(long window,
                                                long monitor,
                                                int xpos,
                                                int ypos,
                                                int width,
                                                int height,
                                                int refreshRate)
        Sets the mode, monitor, video mode and placement of a window.

        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.

        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.

        Notes:

        • This function must only be called from the main thread.
        • Wayland: The desired window position is ignored, as there is no way for an application to set this property.
        • Wayland: Setting the window to full screen will not attempt to change the mode, no matter what the requested size or refresh rate.
        Parameters:
        window - the window whose monitor, size or video mode to set
        monitor - the desired monitor, or NULL to set windowed mode
        xpos - the desired x-coordinate of the upper-left corner of the client area
        ypos - the desired y-coordinate of the upper-left corner of the client area
        width - the desired with, in screen coordinates, of the client area or video mode
        height - the desired height, in screen coordinates, of the client area or video mode
        refreshRate - the desired refresh rate, in Hz, of the video mode, or DONT_CARE
        Since:
        version 3.2
      • glfwSetWindowAttrib

        public static void glfwSetWindowAttrib​(long window,
                                               int attrib,
                                               int value)
        Sets an attribute of the specified window.

        This function must only be called from the main thread.

        Parameters:
        window - the window to set the attribute for
        attrib - the attribute to set.

        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.

        Calling GetWindowAttrib will always return the latest value, even if that value is ignored by the current mode of the window. One of:

        DECORATEDRESIZABLEFLOATINGAUTO_ICONIFYFOCUS_ON_SHOW
        value - the value to set
        Since:
        version 3.3
      • glfwSetWindowUserPointer

        public static void glfwSetWindowUserPointer​(long window,
                                                    long pointer)
        Sets the user-defined pointer of the specified window. The current value is retained until the window is destroyed. The initial value is NULL.

        This function may be called from any thread. Access is not synchronized.

        Parameters:
        window - the window whose pointer to set
        pointer - the new value
        Since:
        version 3.0
      • glfwGetWindowUserPointer

        public static long glfwGetWindowUserPointer​(long window)
        Returns the current value of the user-defined pointer of the specified window. The initial value is NULL.

        This function may be called from any thread. Access is not synchronized.

        Parameters:
        window - the window whose pointer to return
        Since:
        version 3.0
      • nglfwSetWindowPosCallback

        public static long nglfwSetWindowPosCallback​(long window,
                                                     long cbfun)
        Unsafe version of: SetWindowPosCallback
      • glfwSetWindowPosCallback

        @Nullable
        public static GLFWWindowPosCallback glfwSetWindowPosCallback​(long window,
                                                                     @Nullable
                                                                     GLFWWindowPosCallbackI cbfun)
        Sets the position callback of the specified window, which is called when the window is moved. The callback is provided with the position, in screen coordinates, of the upper-left corner of the client area of the window.

        Notes:

        • This function must only be called from the main thread.
        • Wayland: This callback will never be called, as there is no way for an application to know its global position.
        Parameters:
        window - the window whose callback to set
        cbfun - the new callback or NULL to remove the currently set callback
        Returns:
        the previously set callback, or NULL if no callback was set or the library had not been initialized
        Since:
        version 1.0
      • nglfwSetWindowSizeCallback

        public static long nglfwSetWindowSizeCallback​(long window,
                                                      long cbfun)
        Unsafe version of: SetWindowSizeCallback
      • glfwSetWindowSizeCallback

        @Nullable
        public static GLFWWindowSizeCallback glfwSetWindowSizeCallback​(long window,
                                                                       @Nullable
                                                                       GLFWWindowSizeCallbackI cbfun)
        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.

        This function must only be called from the main thread.

        Parameters:
        window - the window whose callback to set
        cbfun - the new callback or NULL to remove the currently set callback
        Returns:
        the previously set callback, or NULL if no callback was set or the library had not been initialized
        Since:
        version 1.0
      • nglfwSetWindowCloseCallback

        public static long nglfwSetWindowCloseCallback​(long window,
                                                       long cbfun)
        Unsafe version of: SetWindowCloseCallback
      • glfwSetWindowCloseCallback

        @Nullable
        public static GLFWWindowCloseCallback glfwSetWindowCloseCallback​(long window,
                                                                         @Nullable
                                                                         GLFWWindowCloseCallbackI cbfun)
        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.

        The close callback is not triggered by DestroyWindow.

        Note
        • This function must only be called from the main thread.
        • macOS: Selecting Quit from the application menu will trigger the close callback for all windows.
        Parameters:
        window - the window whose callback to set
        cbfun - the new callback or NULL to remove the currently set callback
        Returns:
        the previously set callback, or NULL if no callback was set or the library had not been initialized
        Since:
        version 2.5
      • nglfwSetWindowRefreshCallback

        public static long nglfwSetWindowRefreshCallback​(long window,
                                                         long cbfun)
        Unsafe version of: SetWindowRefreshCallback
      • glfwSetWindowRefreshCallback

        @Nullable
        public static GLFWWindowRefreshCallback glfwSetWindowRefreshCallback​(long window,
                                                                             @Nullable
                                                                             GLFWWindowRefreshCallbackI cbfun)
        Sets the refresh callback of the specified window, which is called when the client 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 or Aqua, where the window contents are saved off-screen, this callback may be called only very infrequently or never at all.

        This function must only be called from the main thread.

        Parameters:
        window - the window whose callback to set
        cbfun - the new callback or NULL to remove the currently set callback
        Returns:
        the previously set callback, or NULL if no callback was set or the library had not been initialized
        Since:
        version 2.5
      • nglfwSetWindowFocusCallback

        public static long nglfwSetWindowFocusCallback​(long window,
                                                       long cbfun)
        Unsafe version of: SetWindowFocusCallback
      • glfwSetWindowFocusCallback

        @Nullable
        public static GLFWWindowFocusCallback glfwSetWindowFocusCallback​(long window,
                                                                         @Nullable
                                                                         GLFWWindowFocusCallbackI cbfun)
        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 and SetMouseButtonCallback.

        This function must only be called from the main thread.

        Parameters:
        window - the window whose callback to set
        cbfun - the new callback or NULL to remove the currently set callback
        Returns:
        the previously set callback, or NULL if no callback was set or the library had not been initialized
        Since:
        version 3.0
      • nglfwSetWindowIconifyCallback

        public static long nglfwSetWindowIconifyCallback​(long window,
                                                         long cbfun)
        Unsafe version of: SetWindowIconifyCallback
      • glfwSetWindowIconifyCallback

        @Nullable
        public static GLFWWindowIconifyCallback glfwSetWindowIconifyCallback​(long window,
                                                                             @Nullable
                                                                             GLFWWindowIconifyCallbackI cbfun)
        Sets the iconification callback of the specified window, which is called when the window is iconified or restored.

        Notes:

        • This function must only be called from the main thread.
        • Wayland: The wl_shell protocol has no concept of iconification, this callback will never be called when using this deprecated protocol.
        Parameters:
        window - the window whose callback to set
        cbfun - the new callback or NULL to remove the currently set callback
        Returns:
        the previously set callback, or NULL if no callback was set or the library had not been initialized
        Since:
        version 3.0
      • nglfwSetWindowMaximizeCallback

        public static long nglfwSetWindowMaximizeCallback​(long window,
                                                          long cbfun)
        Unsafe version of: SetWindowMaximizeCallback
      • glfwSetWindowMaximizeCallback

        @Nullable
        public static GLFWWindowMaximizeCallback glfwSetWindowMaximizeCallback​(long window,
                                                                               @Nullable
                                                                               GLFWWindowMaximizeCallbackI cbfun)
        Sets the maximization callback of the specified window, which is called when the window is maximized or restored.

        This function must only be called from the main thread.

        Parameters:
        window - the window whose callback to set
        cbfun - the new callback or NULL to remove the currently set callback
        Returns:
        the previously set callback, or NULL if no callback was set or the library had not been initialized
        Since:
        version 3.3
      • nglfwSetFramebufferSizeCallback

        public static long nglfwSetFramebufferSizeCallback​(long window,
                                                           long cbfun)
        Unsafe version of: SetFramebufferSizeCallback
      • glfwSetFramebufferSizeCallback

        @Nullable
        public static GLFWFramebufferSizeCallback glfwSetFramebufferSizeCallback​(long window,
                                                                                 @Nullable
                                                                                 GLFWFramebufferSizeCallbackI cbfun)
        Sets the framebuffer resize callback of the specified window, which is called when the framebuffer of the specified window is resized.

        This function must only be called from the main thread.

        Parameters:
        window - the window whose callback to set
        cbfun - the new callback or NULL to remove the currently set callback
        Returns:
        the previously set callback, or NULL if no callback was set or the library had not been initialized
        Since:
        version 3.0
      • nglfwSetWindowContentScaleCallback

        public static long nglfwSetWindowContentScaleCallback​(long window,
                                                              long cbfun)
      • glfwSetWindowContentScaleCallback

        @Nullable
        public static GLFWWindowContentScaleCallback glfwSetWindowContentScaleCallback​(long window,
                                                                                       @Nullable
                                                                                       GLFWWindowContentScaleCallbackI cbfun)
        Sets the window content scale callback for the specified window, which is called when the content scale of the specified window changes.

        This function must only be called from the main thread.

        Parameters:
        window - the window whose callback to set
        cbfun - the new callback or NULL to remove the currently set callback
        Returns:
        the previously set callback, or NULL if no callback was set or the library had not been initialized
        Since:
        version 3.3
      • glfwPollEvents

        public static void glfwPollEvents()
        Processes all pending events.

        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.

        Note
        • This function must only be called from the main thread.
        • This function must not be called from a callback.
        Since:
        version 1.0
      • glfwWaitEvents

        public static void glfwWaitEvents()
        Waits until events are queued and processes them.

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

        Note
        • This function must only be called from the main thread.
        • This function must not be called from a callback.
        Since:
        version 2.5
      • glfwWaitEventsTimeout

        public static void glfwWaitEventsTimeout​(double timeout)
        Waits with timeout until events are queued and processes them.

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

        Note
        • This function must only be called from the main thread.
        • This function must not be called from a callback.
        Parameters:
        timeout - the maximum amount of time, in seconds, to wait
        Since:
        version 3.2
      • glfwPostEmptyEvent

        public static void glfwPostEmptyEvent()
        Posts an empty event from the current thread to the main thread event queue, causing WaitEvents or WaitEventsTimeout 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.

        This function may be called from any thread.

        Since:
        version 3.1
      • glfwGetInputMode

        public static int glfwGetInputMode​(long window,
                                           int mode)
        Returns the value of an input option for the specified window.

        This function must only be called from the main thread.

        Parameters:
        window - the window to query
        mode - the input mode whose value to return. One of:
        CURSORSTICKY_KEYSSTICKY_MOUSE_BUTTONSLOCK_KEY_MODS
        Returns:
        the input mode value
        Since:
        version 3.0
      • glfwSetInputMode

        public static void glfwSetInputMode​(long window,
                                            int mode,
                                            int value)
        Sets an input option for the specified window.

        If mode is CURSOR, the value must be one of the following cursor modes:

        • CURSOR_NORMAL makes the cursor visible and behaving normally.
        • CURSOR_HIDDEN makes the cursor invisible when it is over the client area of the window but does not restrict the cursor from leaving.
        • CURSOR_DISABLED hides and grabs the cursor, providing virtual and unlimited cursor movement. This is useful for implementing for example 3D camera controls.

        If mode is STICKY_KEYS, 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 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 mode is STICKY_MOUSE_BUTTONS, 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 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.

        If mode is LOCK_KEY_MODS, 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 MOD_CAPS_LOCK bit set when the event was generated with Caps Lock on, and the MOD_NUM_LOCK bit when Num Lock was on.

        This function must only be called from the main thread.

        Parameters:
        window - the window whose input mode to set
        mode - the input mode to set. One of:
        CURSORSTICKY_KEYSSTICKY_MOUSE_BUTTONS
        value - the new value of the specified input mode
        Since:
        GFLW 3.0
      • nglfwGetKeyName

        public static long nglfwGetKeyName​(int key,
                                           int scancode)
        Unsafe version of: GetKeyName
      • glfwGetKeyName

        @Nullable
        public static java.lang.String glfwGetKeyName​(int key,
                                                      int scancode)
        Returns the layout-specific name of the specified printable key.

        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 KEY_UNKNOWN, the scancode is used to identify the key, otherwise the scancode is ignored. If you specify a non-printable key, or KEY_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.

        The returned string is allocated and freed by GLFW. You should not free it yourself. It is valid until the next call to GetKeyName, or until the library is terminated.

        This function must only be called from the main thread.

        Parameters:
        key - the key to query, or KEY_UNKNOWN
        scancode - the scancode of the key to query
        Returns:
        the UTF-8 encoded, layout-specific name of the key, or NULL
        Since:
        version 3.2
      • glfwGetKeyScancode

        public static int glfwGetKeyScancode​(int key)
        Returns the platform dependent scancode of the specified key.

        This function returns the platform dependent scancode of the specified key. This is intended for platform specific default keybindings.

        If the key is KEY_UNKNOWN or does not exist on the keyboard this method will return -1.

        This function may be called from any thread.

        Parameters:
        key - the key to query, or KEY_UNKNOWN
        Returns:
        the platform dependent scancode for the key, or -1 if an errror occurred
        Since:
        version 3.3
      • glfwGetKey

        public static int glfwGetKey​(long window,
                                     int key)
        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 STICKY_KEYS 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.

        Note
        • This function must only be called from the main thread.
        • KEY_UNKNOWN is not a valid key for this function.
        Parameters:
        window - the desired window
        key - the desired keyboard key
        Returns:
        one of PRESS or RELEASE
        Since:
        version 1.0
      • glfwGetMouseButton

        public static int glfwGetMouseButton​(long window,
                                             int button)
        Returns the last state reported for the specified mouse button to the specified window. The returned state is one of PRESS or RELEASE. The higher-level action REPEAT is only reported to the mouse button callback.

        If the STICKY_MOUSE_BUTTONS 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.

        This function must only be called from the main thread.

        Parameters:
        window - the desired window
        button - the desired mouse button
        Returns:
        one of PRESS or RELEASE
        Since:
        version 1.0
      • nglfwGetCursorPos

        public static void nglfwGetCursorPos​(long window,
                                             long xpos,
                                             long ypos)
        Unsafe version of: GetCursorPos
      • glfwGetCursorPos

        public static void glfwGetCursorPos​(long window,
                                            @Nullable
                                            java.nio.DoubleBuffer xpos,
                                            @Nullable
                                            java.nio.DoubleBuffer ypos)
        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 CURSOR_DISABLED) then the cursor position is unbounded and limited only by the minimum and maximum values of a double.

        The coordinates can be converted to their integer equivalents with the Math.floor(double) 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 NULL. If an error occurs, all non-NULL position arguments will be set to zero.

        This function must only be called from the main thread.

        Parameters:
        window - the desired window
        xpos - where to store the cursor x-coordinate, relative to the left edge of the client area, or NULL
        ypos - where to store the cursor y-coordinate, relative to the to top edge of the client area, or NULL.
        Since:
        version 1.0
      • glfwSetCursorPos

        public static void glfwSetCursorPos​(long window,
                                            double xpos,
                                            double ypos)
        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 CURSOR_DISABLED cursor mode that hides the cursor, transparently re-centers it and provides unconstrained cursor motion. See SetInputMode for more information.

        If the cursor mode is CURSOR_DISABLED then the cursor position is unconstrained and limited only by the minimum and maximum values of double.

        Notes:

        • This function must only be called from the main thread.
        • Wayland: This function will only work when the cursor mode is CURSOR_DISABLED, otherwise it will do nothing.
        Parameters:
        window - the desired window
        xpos - the desired x-coordinate, relative to the left edge of the client area
        ypos - the desired y-coordinate, relative to the top edge of the client area
        Since:
        version 1.0
      • nglfwCreateCursor

        public static long nglfwCreateCursor​(long image,
                                             int xhot,
                                             int yhot)
        Unsafe version of: CreateCursor
      • glfwCreateCursor

        public static long glfwCreateCursor​(GLFWImage image,
                                            int xhot,
                                            int yhot)
        Creates a new custom cursor image that can be set for a window with SetCursor. The cursor can be destroyed with DestroyCursor. 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.

        Note
        • This function must only be called from the main thread.
        • The specified image data is copied before this function returns.
        Parameters:
        image - the desired cursor image
        xhot - the desired x-coordinate, in pixels, of the cursor hotspot
        yhot - the desired y-coordinate, in pixels, of the cursor hotspot
        Returns:
        the handle of the created cursor, or NULL if an error occurred
        Since:
        version 3.1
      • glfwCreateStandardCursor

        public static long glfwCreateStandardCursor​(int shape)
        Returns a cursor with a standard shape, that can be set for a window with SetCursor.

        This function must only be called from the main thread.

        Parameters:
        shape - one of the standard shapes. One of:
        ARROW_CURSORIBEAM_CURSORCROSSHAIR_CURSORHAND_CURSORHRESIZE_CURSORVRESIZE_CURSOR
        Returns:
        a new cursor ready to use or NULL if an error occurred
        Since:
        version 3.1
      • glfwDestroyCursor

        public static void glfwDestroyCursor​(long cursor)
        Destroys a cursor previously created with CreateCursor. Any remaining cursors will be destroyed by Terminate.
        Note
        • This function must only be called from the main thread.
        • This function must not be called from a callback.
        Parameters:
        cursor - the cursor object to destroy
        Since:
        version 3.1
      • glfwSetCursor

        public static void glfwSetCursor​(long window,
                                         long cursor)
        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 CURSOR_NORMAL.

        On some platforms, the set cursor may not be visible unless the window also has input focus.

        This function must only be called from the main thread.

        Parameters:
        window - the window to set the system cursor for
        cursor - the cursor to set, or NULL to switch back to the default arrow cursor
        Since:
        version 3.1
      • nglfwSetKeyCallback

        public static long nglfwSetKeyCallback​(long window,
                                               long cbfun)
        Unsafe version of: SetKeyCallback
      • glfwSetKeyCallback

        @Nullable
        public static GLFWKeyCallback glfwSetKeyCallback​(long window,
                                                         @Nullable
                                                         GLFWKeyCallbackI cbfun)
        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 named after their values in the standard US keyboard layout. If you want to input text, use SetCharCallback 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 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 KEY_UNKNOWN, their state is not saved and so it cannot be queried with GetKey.

        Sometimes GLFW needs to generate synthetic key events, in which case the scancode may be zero.

        This function must only be called from the main thread.

        Parameters:
        window - the window whose callback to set
        cbfun - the new callback or NULL to remove the currently set callback
        Returns:
        the previously set callback, or NULL if no callback was set
        Since:
        version 1.0
      • nglfwSetCharCallback

        public static long nglfwSetCharCallback​(long window,
                                                long cbfun)
        Unsafe version of: SetCharCallback
      • glfwSetCharCallback

        @Nullable
        public static GLFWCharCallback glfwSetCharCallback​(long window,
                                                           @Nullable
                                                           GLFWCharCallbackI cbfun)
        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 SetKeyCallback 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 macOS or Alt key on Windows. There is SetCharModsCallback that receives these events.

        This function must only be called from the main thread.

        Parameters:
        window - the window whose callback to set
        cbfun - the new callback or NULL to remove the currently set callback
        Returns:
        the previously set callback, or NULL if no callback was set
        Since:
        version 2.4
      • nglfwSetCharModsCallback

        public static long nglfwSetCharModsCallback​(long window,
                                                    long cbfun)
        Unsafe version of: SetCharModsCallback
      • glfwSetCharModsCallback

        @Nullable
        public static GLFWCharModsCallback glfwSetCharModsCallback​(long window,
                                                                   @Nullable
                                                                   GLFWCharModsCallbackI cbfun)
        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 SetCharCallback. Like the character callback, 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 SetKeyCallback instead.

        This function must only be called from the main thread.

        Deprecared: scheduled for removal in version 4.0.

        Parameters:
        window - the window whose callback to set
        cbfun - the new callback or NULL to remove the currently set callback
        Returns:
        the previously set callback, or NULL if no callback was set
        Since:
        version 3.1
      • nglfwSetMouseButtonCallback

        public static long nglfwSetMouseButtonCallback​(long window,
                                                       long cbfun)
        Unsafe version of: SetMouseButtonCallback
      • glfwSetMouseButtonCallback

        @Nullable
        public static GLFWMouseButtonCallback glfwSetMouseButtonCallback​(long window,
                                                                         @Nullable
                                                                         GLFWMouseButtonCallbackI cbfun)
        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 has been called.

        This function must only be called from the main thread.

        Parameters:
        window - the window whose callback to set
        cbfun - the new callback or NULL to remove the currently set callback
        Returns:
        the previously set callback, or NULL if no callback was set
        Since:
        version 1.0
      • nglfwSetCursorPosCallback

        public static long nglfwSetCursorPosCallback​(long window,
                                                     long cbfun)
        Unsafe version of: SetCursorPosCallback
      • glfwSetCursorPosCallback

        @Nullable
        public static GLFWCursorPosCallback glfwSetCursorPosCallback​(long window,
                                                                     @Nullable
                                                                     GLFWCursorPosCallbackI cbfun)
        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.

        This function must only be called from the main thread.

        Parameters:
        window - the window whose callback to set
        cbfun - the new callback or NULL to remove the currently set callback
        Returns:
        the previously set callback, or NULL if no callback was set
        Since:
        version 1.0
      • nglfwSetCursorEnterCallback

        public static long nglfwSetCursorEnterCallback​(long window,
                                                       long cbfun)
        Unsafe version of: SetCursorEnterCallback
      • glfwSetCursorEnterCallback

        @Nullable
        public static GLFWCursorEnterCallback glfwSetCursorEnterCallback​(long window,
                                                                         @Nullable
                                                                         GLFWCursorEnterCallbackI cbfun)
        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.

        This function must only be called from the main thread.

        Parameters:
        window - the window whose callback to set
        cbfun - the new callback or NULL to remove the currently set callback
        Returns:
        the previously set callback, or NULL if no callback was set
        Since:
        version 3.0
      • nglfwSetScrollCallback

        public static long nglfwSetScrollCallback​(long window,
                                                  long cbfun)
        Unsafe version of: SetScrollCallback
      • glfwSetScrollCallback

        @Nullable
        public static GLFWScrollCallback glfwSetScrollCallback​(long window,
                                                               @Nullable
                                                               GLFWScrollCallbackI cbfun)
        Sets the scroll callback of the specified window, which is called when a scrolling device is used.

        The scroll callback receives all scrolling input, like that from a mouse wheel or a touchpad scrolling area.

        This function must only be called from the main thread.

        Parameters:
        window - the window whose callback to set
        cbfun - the new callback or NULL to remove the currently set callback
        Returns:
        the previously set callback, or NULL if no callback was set
        Since:
        version 2.1
      • nglfwSetDropCallback

        public static long nglfwSetDropCallback​(long window,
                                                long cbfun)
        Unsafe version of: SetDropCallback
      • glfwSetDropCallback

        @Nullable
        public static GLFWDropCallback glfwSetDropCallback​(long window,
                                                           @Nullable
                                                           GLFWDropCallbackI cbfun)
        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.

        Notes:

        • This function must only be called from the main thread.
        • Wayland: File drop is currently unimplemented.
        Parameters:
        window - the window whose callback to set
        cbfun - the new callback or NULL to remove the currently set callback
        Returns:
        the previously set callback, or NULL if no callback was set
        Since:
        version 3.1
      • glfwJoystickPresent

        public static boolean glfwJoystickPresent​(int jid)
        Returns whether the specified joystick is present.

        This function must only be called from the main thread.

        Parameters:
        jid - joystick to query
        Returns:
        TRUE if the joystick is present, or FALSE otherwise
        Since:
        version 3.0
      • nglfwGetJoystickAxes

        public static long nglfwGetJoystickAxes​(int jid,
                                                long count)
        Unsafe version of: GetJoystickAxes
        Parameters:
        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.
      • glfwGetJoystickAxes

        @Nullable
        public static java.nio.FloatBuffer glfwGetJoystickAxes​(int jid)
        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.

        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.

        Parameters:
        jid - the joystick to query
        Returns:
        an array of axis values, or NULL if the joystick is not present
        Since:
        version 2.2
      • nglfwGetJoystickButtons

        public static long nglfwGetJoystickButtons​(int jid,
                                                   long count)
        Unsafe version of: GetJoystickButtons
        Parameters:
        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.
      • glfwGetJoystickButtons

        @Nullable
        public static java.nio.ByteBuffer glfwGetJoystickButtons​(int jid)
        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, the button array also includes all hats, each represented as four buttons. The hats are in the same order as returned by GetJoystickHats and are in the order up, right, down and left. To disable these extra buttons, set the JOYSTICK_HAT_BUTTONS 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.

        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.

        Parameters:
        jid - the joystick to query
        Returns:
        an array of button states, or NULL if the joystick is not present
        Since:
        version 2.2
      • nglfwGetJoystickHats

        public static long nglfwGetJoystickHats​(int jid,
                                                long count)
        Unsafe version of: GetJoystickHats
        Parameters:
        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.
      • glfwGetJoystickHats

        @Nullable
        public static java.nio.ByteBuffer glfwGetJoystickHats​(int jid)
        Returns the state of all hats of the specified joystick.

        This function returns the state of all hats of the specified joystick. Each element in the array is one of the following values:

        
         Name                | Value
         ------------------- | ------------------------------
         GLFW_HAT_CENTERED   | 0
         GLFW_HAT_UP         | 1
         GLFW_HAT_RIGHT      | 2
         GLFW_HAT_DOWN       | 4
         GLFW_HAT_LEFT       | 8
         GLFW_HAT_RIGHT_UP   | GLFW_HAT_RIGHT | GLFW_HAT_UP
         GLFW_HAT_RIGHT_DOWN | GLFW_HAT_RIGHT | GLFW_HAT_DOWN
         GLFW_HAT_LEFT_UP    | GLFW_HAT_LEFT  | GLFW_HAT_UP
         GLFW_HAT_LEFT_DOWN  | GLFW_HAT_LEFT  | GLFW_HAT_DOWN

        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] & GLFW_HAT_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.

        Note
        • This function must only be called from the main thread.
        • 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.
        Parameters:
        jid - the joystick to query
        Returns:
        an array of hat states, or NULL if the joystick is not present or an error occurred
        Since:
        version 3.3
      • nglfwGetJoystickName

        public static long nglfwGetJoystickName​(int jid)
        Unsafe version of: GetJoystickName
      • glfwGetJoystickName

        @Nullable
        public static java.lang.String glfwGetJoystickName​(int jid)
        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.

        The returned string 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.

        Parameters:
        jid - the joystick to query
        Returns:
        the UTF-8 encoded name of the joystick, or NULL if the joystick is not present
        Since:
        version 3.0
      • nglfwGetJoystickGUID

        public static long nglfwGetJoystickGUID​(int jid)
        Unsafe version of: GetJoystickGUID
      • glfwGetJoystickGUID

        @Nullable
        public static java.lang.String glfwGetJoystickGUID​(int jid)
        Returns the SDL compatible GUID, as a UTF-8 encoded hexadecimal string, of the specified joystick.

        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.

        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.

        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.

        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.

        Parameters:
        jid - the joystick to query
        Returns:
        the UTF-8 encoded GUID of the joystick, or NULL if the joystick is not present or an error occurred
        Since:
        version 3.3
      • glfwSetJoystickUserPointer

        public static void glfwSetJoystickUserPointer​(int jid,
                                                      long pointer)
        Sets the user pointer of the specified joystick.

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

        This function may be called from the joystick callback, even for a joystick that is being disconnected.

        This function may be called from any thread. Access is not synchronized.

        Parameters:
        jid - the joystick whose pointer to set
        pointer - the new value
        Since:
        version 3.3
      • glfwGetJoystickUserPointer

        public static long glfwGetJoystickUserPointer​(int jid)
        Returns the user pointer of the specified joystick.

        This function returns the current value of the user-defined pointer of the specified joystick. The initial value is NULL.

        This function may be called from the joystick callback, even for a joystick that is being disconnected.

        This function may be called from any thread. Access is not synchronized.

        Parameters:
        jid - the joystick whose pointer to set
        Since:
        version 3.3
      • glfwJoystickIsGamepad

        public static boolean glfwJoystickIsGamepad​(int jid)
        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. Call JoystickPresent to check if a joystick is present regardless of whether it has a mapping.

        This function must only be called from the main thread.

        Parameters:
        jid - the joystick id to query
        Returns:
        true if a joystick is both present and has a gamepad mapping or false otherwise
        Since:
        version 3.3
      • nglfwSetJoystickCallback

        public static long nglfwSetJoystickCallback​(long cbfun)
        Unsafe version of: SetJoystickCallback
      • glfwSetJoystickCallback

        @Nullable
        public static GLFWJoystickCallback glfwSetJoystickCallback​(@Nullable
                                                                   GLFWJoystickCallbackI cbfun)
        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.

        For joystick connection and disconnection events to be delivered on all platforms, you need to call one of the event processing functions. Joystick disconnection may also be detected and the callback called by joystick functions. The function will then return whatever it returns if the joystick is not present.

        This function must only be called from the main thread.

        Parameters:
        cbfun - the new callback, or NULL to remove the currently set callback
        Returns:
        the previously set callback, or NULL if no callback was set or the library had not been initialized
        Since:
        version 3.2
      • nglfwUpdateGamepadMappings

        public static int nglfwUpdateGamepadMappings​(long string)
        Unsafe version of: UpdateGamepadMappings
      • glfwUpdateGamepadMappings

        public static boolean glfwUpdateGamepadMappings​(java.nio.ByteBuffer string)
        
        public static boolean glfwUpdateGamepadMappings​(java.lang.CharSequence string)
        
        Adds the specified SDL_GameControllerDB gamepad mappings.

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

        This function must only be called from the main thread.

        Parameters:
        string - the string containing the gamepad mappings
        Returns:
        true, or false if an error occurred
        Since:
        version 3.3
      • nglfwGetGamepadName

        public static long nglfwGetGamepadName​(int jid)
        Unsafe version of: GetGamepadName
      • glfwGetGamepadName

        @Nullable
        public static java.lang.String glfwGetGamepadName​(int jid)
        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. Call JoystickIsGamepad to check if a joystick 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.

        Parameters:
        jid - the joystick to query
        Returns:
        the UTF-8 encoded name of the gamepad, or NULL if the joystick is not present, does not have a mapping or an error occurred
        Since:
        version 3.3
      • nglfwGetGamepadState

        public static int nglfwGetGamepadState​(int jid,
                                               long state)
        Unsafe version of: GetGamepadState
      • glfwGetGamepadState

        public static boolean glfwGetGamepadState​(int jid,
                                                  GLFWGamepadState state)
        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 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 GLFWGamepadState. Unavailable buttons and axes will always report RELEASE and 0.0 respectively.

        This function must only be called from the main thread.

        Parameters:
        jid - the joystick to query
        state - the gamepad input state of the joystick
        Returns:
        true if successful, or false if no joystick is connected, it has no gamepad mapping or an error occurred
        Since:
        version 3.3
      • nglfwSetClipboardString

        public static void nglfwSetClipboardString​(long window,
                                                   long string)
        Unsafe version of: SetClipboardString
      • glfwSetClipboardString

        public static void glfwSetClipboardString​(long window,
                                                  java.nio.ByteBuffer string)
        
        public static void glfwSetClipboardString​(long window,
                                                  java.lang.CharSequence string)
        
        Sets the system clipboard to the specified, UTF-8 encoded string.

        The specified string is copied before this function returns.

        Notes:

        • This function must only be called from the main thread.
        • Wayland: Clipboard is currently unimplemented.
        Parameters:
        window - deprecated, any valid window or NULL.
        string - a UTF-8 encoded string
        Since:
        version 3.0
      • nglfwGetClipboardString

        public static long nglfwGetClipboardString​(long window)
        Unsafe version of: GetClipboardString
      • glfwGetClipboardString

        @Nullable
        public static java.lang.String glfwGetClipboardString​(long window)
        Returns the contents of the system clipboard, if it contains or is convertible to a UTF-8 encoded string. If the clipboard is empty or if its contents cannot be converted, NULL is returned and a FORMAT_UNAVAILABLE error is generated.

        The returned string is allocated and freed by GLFW. You should not free it yourself. It is valid until the next call to GetClipboardString or SetClipboardString, or until the library is terminated.

        Note
        • This function must 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 or SetClipboardString.
        • Wayland: Clipboard is currently unimplemented.
        Parameters:
        window - deprecated, any valid window or NULL.
        Returns:
        the contents of the clipboard as a UTF-8 encoded string, or NULL if an error occurred
        Since:
        version 3.0
      • glfwGetTime

        public static double glfwGetTime()
        Returns the value of the GLFW timer. Unless the timer has been set using SetTime, 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.

        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.

        Returns:
        the current value, in seconds, or zero if an error occurred
        Since:
        version 1.0
      • glfwSetTime

        public static void glfwSetTime​(double time)
        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.

        The upper limit of the timer is calculated as floor((264 - 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.

        Parameters:
        time - the new value, in seconds
        Since:
        version 2.2
      • glfwGetTimerValue

        public static long glfwGetTimerValue()
        Returns the current value of the raw timer.

        This function returns the current value of the raw timer, measured in 1 / frequency seconds. To get the frequency, call GetTimerFrequency.

        This function may be called from any thread.

        Returns:
        the value of the timer, or zero if an error occurred
        Since:
        version 3.2
      • glfwGetTimerFrequency

        public static long glfwGetTimerFrequency()
        Returns the frequency, in Hz, of the raw timer.

        This function may be called from any thread.

        Returns:
        the frequency of the timer, in Hz, or zero if an error occurred
        Since:
        version 3.2
      • glfwMakeContextCurrent

        public static void glfwMakeContextCurrent​(long window)
        Makes the OpenGL or OpenGL ES context of the specified window current on the calling thread. A context must only be made current on a single thread at a time and each thread can have only a single current context at a time.

        When moving a context between threads, you must make it non-current on the old thread before making it current on the new one.

        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 CONTEXT_RELEASE_BEHAVIOR window hint.

        The specified window must have an OpenGL or OpenGL ES context. Specifying a window without a context will generate a NO_WINDOW_CONTEXT error.

        This function may be called from any thread.

        Parameters:
        window - the window whose context to make current, or NULL to detach the current context
        Since:
        version 3.0
      • glfwGetCurrentContext

        public static long glfwGetCurrentContext()
        Returns the window whose OpenGL or OpenGL ES context is current on the calling thread.

        This function may be called from any thread.

        Returns:
        the window whose context is current, or NULL if no window's context is current
        Since:
        version 3.0
      • glfwSwapBuffers

        public static void glfwSwapBuffers​(long window)
        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 NO_WINDOW_CONTEXT error.

        This function does not apply to Vulkan. If you are rendering with Vulkan, vkQueuePresentKHR instead.

        EGL: The context of the specified window must be current on the calling thread.

        This function may be called from any thread.

        Parameters:
        window - the window whose buffers to swap
        Since:
        version 1.0
      • glfwSwapInterval

        public static void glfwSwapInterval​(int interval)
        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 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. For more information about swap tearing, see the extension specifications.

        A context must be current on the calling thread. Calling this function without a current context will cause a NO_CURRENT_CONTEXT error.

        This function does not apply to Vulkan. If you are rendering with Vulkan, see the present mode of your swapchain instead.

        Note
        • This function may be called from any thread.
        • This function is not called during window 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.
        Parameters:
        interval - the minimum number of screen updates to wait for until the buffers are swapped by SwapBuffers
        Since:
        version 1.0
      • nglfwExtensionSupported

        public static int nglfwExtensionSupported​(long extension)
        Unsafe version of: ExtensionSupported
      • glfwExtensionSupported

        public static boolean glfwExtensionSupported​(java.nio.ByteBuffer extension)
        
        public static boolean glfwExtensionSupported​(java.lang.CharSequence extension)
        
        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 NO_CURRENT_CONTEXT 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.

        This function does not apply to Vulkan. If you are using Vulkan, see glfwGetRequiredInstanceExtensions, vkEnumerateInstanceExtensionProperties and vkEnumerateDeviceExtensionProperties instead.

        This function may be called from any thread.

        Parameters:
        extension - the ASCII encoded name of the extension
        Returns:
        TRUE if the extension is available, or FALSE otherwise
        Since:
        version 1.0
      • nglfwGetProcAddress

        public static long nglfwGetProcAddress​(long procname)
        Unsafe version of: GetProcAddress
      • glfwGetProcAddress

        public static long glfwGetProcAddress​(java.nio.ByteBuffer procname)
        
        public static long glfwGetProcAddress​(java.lang.CharSequence procname)
        
        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 NO_CURRENT_CONTEXT error.

        This function does not apply to Vulkan. If you are rendering with Vulkan, glfwGetInstanceProcAddress, vkGetInstanceProcAddr and vkGetDeviceProcAddr instead.

        Note
        • 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.
        Parameters:
        procname - the ASCII encoded name of the function
        Returns:
        the address of the function, or NULL if an error occurred
        Since:
        version 1.0
      • glfwGetVersion

        public static void glfwGetVersion​(@Nullable
                                          int[] major,
                                          @Nullable
                                          int[] minor,
                                          @Nullable
                                          int[] rev)
        Array version of: GetVersion
      • glfwGetMonitorPos

        public static void glfwGetMonitorPos​(long monitor,
                                             @Nullable
                                             int[] xpos,
                                             @Nullable
                                             int[] ypos)
        Array version of: GetMonitorPos
      • glfwGetMonitorPhysicalSize

        public static void glfwGetMonitorPhysicalSize​(long monitor,
                                                      @Nullable
                                                      int[] widthMM,
                                                      @Nullable
                                                      int[] heightMM)
        Array version of: GetMonitorPhysicalSize
      • glfwGetMonitorContentScale

        public static void glfwGetMonitorContentScale​(long monitor,
                                                      @Nullable
                                                      float[] xscale,
                                                      @Nullable
                                                      float[] yscale)
        Array version of: GetMonitorContentScale
      • glfwGetWindowPos

        public static void glfwGetWindowPos​(long window,
                                            @Nullable
                                            int[] xpos,
                                            @Nullable
                                            int[] ypos)
        Array version of: GetWindowPos
      • glfwGetWindowSize

        public static void glfwGetWindowSize​(long window,
                                             @Nullable
                                             int[] width,
                                             @Nullable
                                             int[] height)
        Array version of: GetWindowSize
      • glfwGetFramebufferSize

        public static void glfwGetFramebufferSize​(long window,
                                                  @Nullable
                                                  int[] width,
                                                  @Nullable
                                                  int[] height)
        Array version of: GetFramebufferSize
      • glfwGetWindowFrameSize

        public static void glfwGetWindowFrameSize​(long window,
                                                  @Nullable
                                                  int[] left,
                                                  @Nullable
                                                  int[] top,
                                                  @Nullable
                                                  int[] right,
                                                  @Nullable
                                                  int[] bottom)
        Array version of: GetWindowFrameSize
      • glfwGetWindowContentScale

        public static void glfwGetWindowContentScale​(long window,
                                                     @Nullable
                                                     float[] xscale,
                                                     @Nullable
                                                     float[] yscale)
        Array version of: GetWindowContentScale
      • glfwGetCursorPos

        public static void glfwGetCursorPos​(long window,
                                            @Nullable
                                            double[] xpos,
                                            @Nullable
                                            double[] ypos)
        Array version of: GetCursorPos