Sha256: 7c7ac3884617520ec7d19cf213fbd2c9b0f1f0fb1438492edb79f308d0e07635

Contents?: true

Size: 1.03 KB

Versions: 1

Compression:

Stored size: 1.03 KB

Contents

#include "glfw.h"

VALUE cCursor;

static void rb_glfw_cursor_free(void *cursor)
{
    if (cursor)
        glfwDestroyCursor(cursor);
}

static VALUE rb_glfw_cursor_alloc(VALUE klass)
{
    return Data_Wrap_Struct(klass, NULL, rb_glfw_cursor_free, NULL);
}

static VALUE rb_glfw_cursor_initialize(int argc, VALUE *argv, VALUE self)
{
    VALUE img, x, y;
    rb_scan_args(argc, argv, "12", &img, &x, &y);

    GLFWcursor *cursor;

    if (RB_TYPE_P(img, T_DATA))
    {
        GLFWimage *image = DATA_PTR(img);
        int xhot = RTEST(x) ? NUM2INT(x) : 0;
        int yhot = RTEST(y) ? NUM2INT(y) : 0;
        cursor = glfwCreateCursor(image, xhot, yhot);
    }
    else
    {
        int shape = NUM2INT(img);
        cursor = glfwCreateStandardCursor(shape);
    }

    RDATA(self)->data = cursor;
    return Qnil;
}

void rb_glfw_cursor_init(void) {
    cCursor = rb_define_class_under(mGLFW, "Cursor", rb_cObject);

    rb_define_method(cCursor, "initialize", rb_glfw_cursor_initialize, -1);
    rb_define_alloc_func(cCursor, rb_glfw_cursor_alloc);
}

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
glfw-3.3.2.0 ext/glfw/cursor.c