Example #1
0
  /**
   * Constructs a cursor object using the pixels from an OpenGL Texture object and also the location
   * of the pointer hot point in the image pixels retrieved from the OpenGL Texture.
   *
   * @param image The OpenGL Texture object to retrieve the image data from.
   * @param xHot The x-coordinate of the cursor hotspot in pixels.
   * @param yHot The y-coordinate of the cursor hotspot in pixels.
   */
  public Cursor(Texture image, int xHot, int yHot) {
    int width = (int) image.getWidth();
    int height = (int) image.getHeight();

    GLFWImage glfWimage = GLFWImage.malloc();
    glfWimage.width(width);
    glfWimage.height(height);
    glfWimage.pixels(image.getImage2D(GL_RGBA, GL_UNSIGNED_BYTE));

    handle = glfwCreateCursor(glfWimage, xHot, yHot);

    if (handle == NULL) throw new SilenceException("Unable to load cursor from texture");

    glfWimage.free();
  }
Example #2
0
 /**
  * Constructs a cursor object using the pixels from a BufferedImage and also the location of the
  * pointer hot point in the image specified in pixels.
  *
  * @param image The BufferedImage that contains the cursor image.
  * @param xHot The x-coordinate of the cursor hotspot in pixels.
  * @param yHot The y-coordinate of the cursor hotspot in pixels.
  */
 public Cursor(BufferedImage image, int xHot, int yHot) {
   this(Texture.fromBufferedImage(image), xHot, yHot);
 }