glfwCreateCursor function

Pointer<GLFWcursor> glfwCreateCursor(
  1. Pointer<GLFWimage> image,
  2. int xhot,
  3. int yhot
)

! @brief Creates a custom cursor.

Creates a new custom cursor image that can be set for a window with @ref glfwSetCursor. The cursor can be destroyed with @ref glfwDestroyCursor. Any remaining cursors are destroyed by @ref glfwTerminate.

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.

@paramin image The desired cursor image. @paramin xhot The desired x-coordinate, in pixels, of the cursor hotspot. @paramin yhot The desired y-coordinate, in pixels, of the cursor hotspot. @return The handle of the created cursor, or NULL if an error(@ref error_handling) occurred.

@errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref GLFW_INVALID_VALUE and @ref GLFW_PLATFORM_ERROR.

@pointer_lifetime The specified image data is copied before this function returns.

@thread_safety This function must only be called from the main thread.

@sa @ref cursor_object @sa @ref glfwDestroyCursor @sa @ref glfwCreateStandardCursor

@since Added in version 3.1.

@ingroup input

GLFWAPI GLFWcursor* glfwCreateCursor(const GLFWimage* image, int xhot, int yhot)

Implementation

Pointer<GLFWcursor> glfwCreateCursor(
    Pointer<GLFWimage> image, int xhot, int yhot) {
  final glfwCreateCursorLookupFunction = libglfw.lookupFunction<
      Pointer<GLFWcursor> Function(
          Pointer<GLFWimage> image, Int32 xhot, Int32 yhot),
      Pointer<GLFWcursor> Function(
          Pointer<GLFWimage> image, int xhot, int yhot)>('glfwCreateCursor');
  return glfwCreateCursorLookupFunction(image, xhot, yhot);
}