glfw 1.0.3 → 3.3.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +161 -0
- data/.yardopts +6 -0
- data/Gemfile +2 -4
- data/README.md +29 -33
- data/Rakefile +6 -4
- data/ext/glfw/common.c +159 -0
- data/ext/glfw/cursor.c +34 -30
- data/ext/glfw/extconf.rb +7 -17
- data/ext/glfw/glfw.c +122 -377
- data/ext/glfw/glfw.h +46 -41
- data/ext/glfw/image.c +96 -64
- data/ext/glfw/joystick.c +169 -0
- data/ext/glfw/monitor.c +231 -155
- data/ext/glfw/stb_image.h +7656 -0
- data/ext/glfw/window.c +708 -576
- data/glfw.gemspec +10 -9
- data/lib/glfw.rb +4 -14
- data/lib/glfw/constants.rb +365 -0
- data/lib/glfw/stubs.rb +234 -0
- data/lib/glfw/stubs/cursor.rb +21 -0
- data/lib/glfw/stubs/gamepad_state.rb +30 -0
- data/lib/glfw/stubs/image.rb +39 -0
- data/lib/glfw/stubs/joystick.rb +125 -0
- data/lib/glfw/stubs/monitor.rb +115 -0
- data/lib/glfw/stubs/video_mode.rb +32 -0
- data/lib/glfw/stubs/window.rb +626 -0
- data/lib/glfw/version.rb +8 -1
- metadata +31 -35
- data/.travis.yml +0 -5
- data/Makefile +0 -267
- data/ext/glfw/common.h +0 -46
- data/ext/glfw/cursor.h +0 -14
- data/ext/glfw/glfw3.h +0 -4248
- data/ext/glfw/glfw3native.h +0 -456
- data/ext/glfw/image.h +0 -14
- data/ext/glfw/ming32/WINDOWS USERS PLACE libglf3.a HERE.txt b/data/ext/glfw/ming32/WINDOWS USERS PLACE libglf3.a → HERE.txt +0 -0
- data/ext/glfw/ming64/WINDOWS USERS PLACE libglf3.a HERE.txt b/data/ext/glfw/ming64/WINDOWS USERS PLACE libglf3.a → HERE.txt +0 -0
- data/ext/glfw/monitor.h +0 -29
- data/ext/glfw/video_mode.c +0 -60
- data/ext/glfw/video_mode.h +0 -21
- data/ext/glfw/vulkan.c +0 -48
- data/ext/glfw/vulkan.h +0 -16
- data/ext/glfw/window.h +0 -87
data/ext/glfw/window.c
CHANGED
@@ -1,708 +1,840 @@
|
|
1
1
|
|
2
|
-
#include "
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
rb_define_alloc_func(rb_cGLFWwindow, rb_glfw_window_alloc);
|
30
|
-
rb_define_method(rb_cGLFWwindow, "initialize", rb_glfw_window_initialize, -1);
|
31
|
-
rb_define_method(rb_cGLFWwindow, "destroy", rb_glfw_window_destroy, 0);
|
32
|
-
rb_define_method(rb_cGLFWwindow, "show", rb_glfw_window_show, 0);
|
33
|
-
rb_define_method(rb_cGLFWwindow, "hide", rb_glfw_window_hide, 0);
|
34
|
-
rb_define_method(rb_cGLFWwindow, "minimize", rb_glfw_window_minimize, 0);
|
35
|
-
rb_define_method(rb_cGLFWwindow, "maximize", rb_glfw_window_maximize, 0);
|
36
|
-
rb_define_method(rb_cGLFWwindow, "restore", rb_glfw_window_restore, 0);
|
37
|
-
rb_define_method(rb_cGLFWwindow, "focus", rb_glfw_window_focus, 0);
|
38
|
-
rb_define_method(rb_cGLFWwindow, "closing?", rb_glfw_window_closing_p, 0);
|
39
|
-
rb_define_method(rb_cGLFWwindow, "close", rb_glfw_window_close, -1);
|
40
|
-
|
41
|
-
rb_define_method(rb_cGLFWwindow, "swap_buffers", rb_glfw_window_swap_buffers, 0);
|
42
|
-
rb_define_method(rb_cGLFWwindow, "make_current", rb_glfw_window_make_current, 0);
|
43
|
-
rb_define_method(rb_cGLFWwindow, "monitor", rb_glfw_window_get_monitor, 0);
|
44
|
-
rb_define_method(rb_cGLFWwindow, "set_monitor", rb_glfw_window_set_monitor, -1);
|
45
|
-
|
46
|
-
rb_define_method(rb_cGLFWwindow, "dimensions", rb_glfw_window_dimensions, 0);
|
47
|
-
rb_define_method(rb_cGLFWwindow, "position", rb_glfw_window_get_pos, 0);
|
48
|
-
rb_define_method(rb_cGLFWwindow, "move", rb_glfw_window_set_pos, 2);
|
49
|
-
rb_define_method(rb_cGLFWwindow, "size", rb_glfw_window_get_size, 0);
|
50
|
-
rb_define_method(rb_cGLFWwindow, "resize", rb_glfw_window_set_size, 2);
|
51
|
-
rb_define_method(rb_cGLFWwindow, "framebuffer_size", rb_glfw_window_get_framebuffer_size, 0);
|
52
|
-
rb_define_method(rb_cGLFWwindow, "x", rb_glfw_window_get_x, 0);
|
53
|
-
rb_define_method(rb_cGLFWwindow, "y", rb_glfw_window_get_y, 0);
|
54
|
-
rb_define_method(rb_cGLFWwindow, "width", rb_glfw_window_get_width, 0);
|
55
|
-
rb_define_method(rb_cGLFWwindow, "height", rb_glfw_window_get_height, 0);
|
56
|
-
rb_define_method(rb_cGLFWwindow, "x=", rb_glfw_window_set_x, 1);
|
57
|
-
rb_define_method(rb_cGLFWwindow, "y=", rb_glfw_window_set_y, 1);
|
58
|
-
rb_define_method(rb_cGLFWwindow, "width=", rb_glfw_window_set_width, 1);
|
59
|
-
rb_define_method(rb_cGLFWwindow, "height=", rb_glfw_window_set_height, 1);
|
60
|
-
|
61
|
-
rb_define_method(rb_cGLFWwindow, "focused?", rb_glfw_window_focused_p, 0);
|
62
|
-
rb_define_method(rb_cGLFWwindow, "minimized?", rb_glfw_window_minimized_p, 0);
|
63
|
-
rb_define_method(rb_cGLFWwindow, "maximized?", rb_glfw_window_maximized_p, 0);
|
64
|
-
rb_define_method(rb_cGLFWwindow, "visible?", rb_glfw_window_visible_p, 0);
|
65
|
-
rb_define_method(rb_cGLFWwindow, "resizable?", rb_glfw_window_resizable_p, 0);
|
66
|
-
rb_define_method(rb_cGLFWwindow, "decorated?", rb_glfw_window_decorated_p, 0);
|
67
|
-
rb_define_method(rb_cGLFWwindow, "topmost?", rb_glfw_window_floating_p, 0);
|
68
|
-
rb_define_method(rb_cGLFWwindow, "set_icon", rb_glfw_window_set_icon, -2);
|
69
|
-
rb_define_method(rb_cGLFWwindow, "enable_callback", rb_glfw_window_enable_callback, 2);
|
70
|
-
|
71
|
-
rb_define_method(rb_cGLFWwindow, "aspect_ratio", rb_glfw_window_aspect_ratio, 2);
|
72
|
-
rb_define_method(rb_cGLFWwindow, "size_limits", rb_glfw_window_limits, 4);
|
73
|
-
rb_define_method(rb_cGLFWwindow, "frame_size", rb_glfw_window_frame_size, 0);
|
74
|
-
|
75
|
-
rb_define_method(rb_cGLFWwindow, "set_cursor", rb_glfw_window_set_cursor, 1);
|
76
|
-
rb_define_method(rb_cGLFWwindow, "cursor_pos", rb_glfw_window_cursor_pos, 0);
|
77
|
-
rb_define_method(rb_cGLFWwindow, "set_cursor_pos", rb_glfw_window_set_cursor_pos, 2);
|
78
|
-
rb_define_method(rb_cGLFWwindow, "cursor", rb_glfw_window_get_input_cursor, 0);
|
79
|
-
rb_define_method(rb_cGLFWwindow, "cursor=", rb_glfw_window_set_input_cursor, 1);
|
80
|
-
rb_define_method(rb_cGLFWwindow, "sticky_keys", rb_glfw_window_get_input_sticky_keys, 0);
|
81
|
-
rb_define_method(rb_cGLFWwindow, "sticky_keys=", rb_glfw_window_set_input_sticky_keys, 1);
|
82
|
-
rb_define_method(rb_cGLFWwindow, "sticky_mouse", rb_glfw_window_get_input_sticky_mouse, 0);
|
83
|
-
rb_define_method(rb_cGLFWwindow, "sticky_mouse=", rb_glfw_window_set_input_sticky_mouse, 1);
|
84
|
-
|
85
|
-
rb_define_method(rb_cGLFWwindow, "key_down?", rb_glfw_window_get_key, 1);
|
86
|
-
rb_define_method(rb_cGLFWwindow, "mouse_down?", rb_glfw_window_get_mouse_button, 1);
|
87
|
-
|
88
|
-
// Callbacks
|
89
|
-
RB_CALLBACK(id_moved, "moved");
|
90
|
-
RB_CALLBACK(id_refreshed, "resized");
|
91
|
-
RB_CALLBACK(id_framebuffer_resized, "framebuffer_resized");
|
92
|
-
RB_CALLBACK(id_closing, "closing");
|
93
|
-
RB_CALLBACK(id_refreshed, "refreshed");
|
94
|
-
RB_CALLBACK(id_focus_changed, "focus_changed");
|
95
|
-
RB_CALLBACK(id_minimize_changed, "minimize_changed");
|
96
|
-
RB_CALLBACK(id_mouse_move, "mouse_move");
|
97
|
-
RB_CALLBACK(id_mouse_scroll, "mouse_scroll");
|
98
|
-
RB_CALLBACK(id_mouse_button, "mouse_button");
|
99
|
-
RB_CALLBACK(id_mouse_enter, "mouse_enter");
|
100
|
-
RB_CALLBACK(id_key, "key");
|
101
|
-
RB_CALLBACK(id_char, "char");
|
102
|
-
RB_CALLBACK(id_char_mods, "char_mods");
|
103
|
-
RB_CALLBACK(id_file_drop, "file_drop");
|
104
|
-
|
105
|
-
// Alias
|
106
|
-
rb_define_alias(rb_cGLFWwindow, "dispose", "destroy");
|
107
|
-
rb_define_alias(rb_cGLFWwindow, "iconify", "minimize");
|
108
|
-
rb_define_alias(rb_cGLFWwindow, "floating?", "topmost?");
|
109
|
-
rb_define_alias(rb_cGLFWwindow, "iconified?", "minimized?");
|
110
|
-
rb_define_alias(rb_cGLFWwindow, "iconify_changed", "minimize_changed");
|
111
|
-
}
|
112
|
-
|
113
|
-
static VALUE rb_glfw_window_alloc(VALUE klass) {
|
114
|
-
GLFWwindow *w = ruby_xmalloc(SIZEOF_INTPTR_T);
|
115
|
-
memset(w, 0, SIZEOF_INTPTR_T);
|
116
|
-
return Data_Wrap_Struct(klass, NULL, RUBY_DEFAULT_FREE, w);
|
117
|
-
}
|
118
|
-
|
119
|
-
// initialize(width, height, title = '', **options)
|
120
|
-
VALUE rb_glfw_window_initialize(int argc, VALUE *argv, VALUE self) {
|
121
|
-
// Initialize GLFW (does nothing and returns immediately if already called)
|
122
|
-
glfwInit();
|
123
|
-
|
124
|
-
GLFWmonitor *mon = NULL;
|
125
|
-
GLFWwindow *window, *other = NULL;
|
126
|
-
|
127
|
-
VALUE width, height, title, options, monitor, share;
|
128
|
-
|
129
|
-
rb_scan_args(argc, argv, "21:", &width, &height, &title, &options);
|
130
|
-
const char *str = NIL_P(title) ? "" : StringValueCStr(title);
|
131
|
-
|
132
|
-
if (!NIL_P(options)) {
|
133
|
-
// Monitor
|
134
|
-
if (RTEST(rb_hash_aref(options, STR2SYM("fullscreen")))) {
|
135
|
-
mon = glfwGetPrimaryMonitor();
|
136
|
-
} else {
|
137
|
-
monitor = rb_hash_aref(options, STR2SYM("monitor"));
|
138
|
-
if (!NIL_P(monitor))
|
139
|
-
Data_Get_Struct(monitor, GLFWmonitor, mon);
|
140
|
-
}
|
2
|
+
#include "glfw.h"
|
3
|
+
|
4
|
+
#define CB_WINDOW_RESIZE (0)
|
5
|
+
#define CB_FRAMEBUFFER_RESIZE (1)
|
6
|
+
#define CB_WINDOW_MOVE (2)
|
7
|
+
#define CB_WINDOW_CLOSE (3)
|
8
|
+
#define CB_WINDOW_REFRESH (4)
|
9
|
+
#define CB_WINDOW_FOCUS (5)
|
10
|
+
#define CB_WINDOW_MINIMIZE (6)
|
11
|
+
#define CB_WINDOW_MAXIMIZE (7)
|
12
|
+
#define CB_WINDOW_FILE_DROP (8)
|
13
|
+
#define CB_CURSOR_MOVE (9)
|
14
|
+
#define CB_SCROLL (10)
|
15
|
+
#define CB_KEY (11)
|
16
|
+
#define CB_BUTTON (12)
|
17
|
+
#define CB_CURSOR_ENTER (13)
|
18
|
+
#define CB_CHAR (14)
|
19
|
+
#define CB_WINDOW_SCALE (15)
|
20
|
+
|
21
|
+
#define CB_COUNT (16)
|
22
|
+
|
23
|
+
#define GET_WINDOW_ATTRIB(name, constant, to_ruby) \
|
24
|
+
static VALUE name(VALUE self) \
|
25
|
+
{ \
|
26
|
+
return to_ruby(glfwGetWindowAttrib(DATA_PTR(self), constant)); \
|
27
|
+
}
|
141
28
|
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
29
|
+
#define SET_WINDOW_ATTRIB(name, constant, to_c) \
|
30
|
+
static VALUE name(VALUE self, VALUE value) \
|
31
|
+
{ \
|
32
|
+
glfwSetWindowAttrib(DATA_PTR(self), constant, to_c(value)); \
|
33
|
+
return value; \
|
146
34
|
}
|
147
35
|
|
148
|
-
|
149
|
-
|
36
|
+
#define WINDOW_ATTRIBUTE(name, constant, to_ruby, to_c) \
|
37
|
+
GET_WINDOW_ATTRIB(rb_glfw_window_get_##name, constant, to_ruby) \
|
38
|
+
SET_WINDOW_ATTRIB(rb_glfw_window_set_##name, constant, to_c)
|
39
|
+
|
40
|
+
#define CALLBACK_PROC(name, glfw_callback, index) \
|
41
|
+
static VALUE rb_glfw_window_on_##name(VALUE self) \
|
42
|
+
{ \
|
43
|
+
GLFWwindow *window = DATA_PTR(self); \
|
44
|
+
GLFWruby *data = glfwGetWindowUserPointer(window); \
|
45
|
+
VALUE current = data->procs[index]; \
|
46
|
+
if (rb_block_given_p()) \
|
47
|
+
{ \
|
48
|
+
data->procs[index] = rb_block_proc(); \
|
49
|
+
glfw_callback(window, rb_glfw_window_cb_##name); \
|
50
|
+
} \
|
51
|
+
else \
|
52
|
+
{ \
|
53
|
+
data->procs[index] = Qnil; \
|
54
|
+
glfw_callback(window, NULL); \
|
55
|
+
} \
|
56
|
+
return RTEST(current) ? current : Qnil; \
|
57
|
+
}
|
150
58
|
|
151
|
-
|
152
|
-
|
59
|
+
#define WINDOW_INPUT_ATTR(name, constant) \
|
60
|
+
static VALUE rb_glfw_window_get_##name(VALUE self) \
|
61
|
+
{ \
|
62
|
+
return RB_BOOL(glfwGetInputMode(DATA_PTR(self), constant)); \
|
63
|
+
} \
|
64
|
+
static VALUE rb_glfw_window_set_##name(VALUE self, VALUE value) \
|
65
|
+
{ \
|
66
|
+
glfwSetInputMode(DATA_PTR(self), constant, RTEST(value)); \
|
67
|
+
return value; \
|
68
|
+
}
|
153
69
|
|
154
|
-
|
155
|
-
|
156
|
-
|
70
|
+
WINDOW_INPUT_ATTR(sticky_keys, GLFW_STICKY_KEYS)
|
71
|
+
WINDOW_INPUT_ATTR(sticky_buttons, GLFW_STICKY_MOUSE_BUTTONS)
|
72
|
+
WINDOW_INPUT_ATTR(lock_modifiers, GLFW_LOCK_KEY_MODS)
|
73
|
+
WINDOW_INPUT_ATTR(raw_mouse_motion, GLFW_RAW_MOUSE_MOTION)
|
74
|
+
|
75
|
+
typedef struct
|
76
|
+
{
|
77
|
+
VALUE window;
|
78
|
+
VALUE title;
|
79
|
+
VALUE icon;
|
80
|
+
VALUE cursor;
|
81
|
+
VALUE procs[CB_COUNT];
|
82
|
+
} GLFWruby;
|
83
|
+
|
84
|
+
VALUE cWindow;
|
85
|
+
|
86
|
+
static void rb_glfw_window_mark(void *window)
|
87
|
+
{
|
88
|
+
if (window)
|
89
|
+
{
|
90
|
+
GLFWruby *data = glfwGetWindowUserPointer(window);
|
91
|
+
if (data)
|
92
|
+
{
|
93
|
+
rb_gc_mark(data->window);
|
94
|
+
if (RTEST(data->title))
|
95
|
+
rb_gc_mark(data->title);
|
96
|
+
if (RTEST(data->icon))
|
97
|
+
rb_gc_mark(data->icon);
|
98
|
+
if (RTEST(data->cursor))
|
99
|
+
rb_gc_mark(data->cursor);
|
100
|
+
for (int i = 0; i < CB_COUNT; i++)
|
101
|
+
{
|
102
|
+
if (RTEST(data->procs[i]))
|
103
|
+
rb_gc_mark(data->procs[i]);
|
104
|
+
}
|
105
|
+
}
|
157
106
|
}
|
107
|
+
}
|
158
108
|
|
159
|
-
|
109
|
+
static void rb_glfw_window_cb_framebuffer_resize(GLFWwindow *window, int width, int height)
|
110
|
+
{
|
111
|
+
GLFWruby *data = glfwGetWindowUserPointer(window);
|
112
|
+
if (RTEST(data->procs[CB_FRAMEBUFFER_RESIZE]))
|
113
|
+
{
|
114
|
+
rb_proc_call(data->procs[CB_FRAMEBUFFER_RESIZE], rb_ary_new_from_args(2, INT2NUM(width), INT2NUM(height)));
|
115
|
+
}
|
160
116
|
}
|
161
117
|
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
118
|
+
static void rb_glfw_window_cb_resize(GLFWwindow *window, int width, int height)
|
119
|
+
{
|
120
|
+
GLFWruby *data = glfwGetWindowUserPointer(window);
|
121
|
+
if (RTEST(data->procs[CB_WINDOW_RESIZE]))
|
122
|
+
{
|
123
|
+
rb_proc_call(data->procs[CB_WINDOW_RESIZE], rb_ary_new_from_args(2, INT2NUM(width), INT2NUM(height)));
|
124
|
+
}
|
166
125
|
}
|
167
126
|
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
127
|
+
static void rb_glfw_window_cb_move(GLFWwindow *window, int x, int y)
|
128
|
+
{
|
129
|
+
GLFWruby *data = glfwGetWindowUserPointer(window);
|
130
|
+
if (RTEST(data->procs[CB_WINDOW_MOVE]))
|
131
|
+
{
|
132
|
+
rb_proc_call(data->procs[CB_WINDOW_MOVE], rb_ary_new_from_args(2, INT2NUM(x), INT2NUM(y)));
|
133
|
+
}
|
172
134
|
}
|
173
135
|
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
136
|
+
static void rb_glfw_window_cb_focus(GLFWwindow *window, int focused)
|
137
|
+
{
|
138
|
+
GLFWruby *data = glfwGetWindowUserPointer(window);
|
139
|
+
if (RTEST(data->procs[CB_WINDOW_FOCUS]))
|
140
|
+
{
|
141
|
+
rb_proc_call(data->procs[CB_WINDOW_FOCUS], rb_ary_new_from_args(1, RB_BOOL(focused)));
|
142
|
+
}
|
178
143
|
}
|
179
144
|
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
145
|
+
static void rb_glfw_window_cb_close(GLFWwindow *window)
|
146
|
+
{
|
147
|
+
GLFWruby *data = glfwGetWindowUserPointer(window);
|
148
|
+
if (RTEST(data->procs[CB_WINDOW_CLOSE]))
|
149
|
+
{
|
150
|
+
rb_proc_call(data->procs[CB_WINDOW_CLOSE], rb_ary_new());
|
151
|
+
}
|
184
152
|
}
|
185
153
|
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
154
|
+
static void rb_glfw_window_cb_refresh(GLFWwindow *window)
|
155
|
+
{
|
156
|
+
GLFWruby *data = glfwGetWindowUserPointer(window);
|
157
|
+
if (RTEST(data->procs[CB_WINDOW_REFRESH]))
|
158
|
+
{
|
159
|
+
rb_proc_call(data->procs[CB_WINDOW_REFRESH], rb_ary_new());
|
160
|
+
}
|
190
161
|
}
|
191
162
|
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
163
|
+
static void rb_glfw_window_cb_minimize(GLFWwindow *window, int minimized)
|
164
|
+
{
|
165
|
+
GLFWruby *data = glfwGetWindowUserPointer(window);
|
166
|
+
if (RTEST(data->procs[CB_WINDOW_MINIMIZE]))
|
167
|
+
{
|
168
|
+
rb_proc_call(data->procs[CB_WINDOW_MINIMIZE], rb_ary_new_from_args(1, RB_BOOL(minimized)));
|
169
|
+
}
|
196
170
|
}
|
197
171
|
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
172
|
+
static void rb_glfw_window_cb_maximize(GLFWwindow *window, int maximized)
|
173
|
+
{
|
174
|
+
GLFWruby *data = glfwGetWindowUserPointer(window);
|
175
|
+
if (RTEST(data->procs[CB_WINDOW_MAXIMIZE]))
|
176
|
+
{
|
177
|
+
rb_proc_call(data->procs[CB_WINDOW_MAXIMIZE], rb_ary_new_from_args(1, RB_BOOL(maximized)));
|
178
|
+
}
|
202
179
|
}
|
203
180
|
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
181
|
+
static void rb_glfw_window_cb_file_drop(GLFWwindow *window, int count, const char **paths)
|
182
|
+
{
|
183
|
+
GLFWruby *data = glfwGetWindowUserPointer(window);
|
184
|
+
if (RTEST(data->procs[CB_WINDOW_FILE_DROP]))
|
185
|
+
{
|
186
|
+
VALUE ary = rb_ary_new_capa(count);
|
187
|
+
for (int i = 0; i < count; i++)
|
188
|
+
{
|
189
|
+
rb_ary_store(ary, i, rb_str_new_cstr(paths[i]));
|
190
|
+
}
|
191
|
+
rb_proc_call(data->procs[CB_WINDOW_FILE_DROP], rb_ary_new_from_args(1, ary));
|
192
|
+
}
|
208
193
|
}
|
209
194
|
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
195
|
+
static void rb_glfw_window_cb_cursor_move(GLFWwindow *window, double x, double y)
|
196
|
+
{
|
197
|
+
GLFWruby *data = glfwGetWindowUserPointer(window);
|
198
|
+
if (RTEST(data->procs[CB_CURSOR_MOVE]))
|
199
|
+
{
|
200
|
+
rb_proc_call(data->procs[CB_CURSOR_MOVE], rb_ary_new_from_args(2, DBL2NUM(x), DBL2NUM(y)));
|
201
|
+
}
|
214
202
|
}
|
215
203
|
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
rb_ary_store(ary, 1, INT2NUM(y));
|
224
|
-
rb_ary_store(ary, 2, INT2NUM(width));
|
225
|
-
rb_ary_store(ary, 3, INT2NUM(height));
|
226
|
-
return ary;
|
204
|
+
static void rb_glfw_window_cb_scroll(GLFWwindow *window, double x, double y)
|
205
|
+
{
|
206
|
+
GLFWruby *data = glfwGetWindowUserPointer(window);
|
207
|
+
if (RTEST(data->procs[CB_SCROLL]))
|
208
|
+
{
|
209
|
+
rb_proc_call(data->procs[CB_SCROLL], rb_ary_new_from_args(2, DBL2NUM(x), DBL2NUM(y)));
|
210
|
+
}
|
227
211
|
}
|
228
212
|
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
213
|
+
static void rb_glfw_window_cb_key(GLFWwindow *window, int key, int scancode, int action, int mods)
|
214
|
+
{
|
215
|
+
GLFWruby *data = glfwGetWindowUserPointer(window);
|
216
|
+
if (RTEST(data->procs[CB_KEY]))
|
217
|
+
{
|
218
|
+
VALUE args = rb_ary_new_from_args(4, INT2NUM(key), INT2NUM(scancode), INT2NUM(action), INT2NUM(mods));
|
219
|
+
rb_proc_call(data->procs[CB_KEY], args);
|
220
|
+
}
|
237
221
|
}
|
238
222
|
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
223
|
+
static void rb_glfw_window_cb_mouse_button(GLFWwindow *window, int key, int action, int mods)
|
224
|
+
{
|
225
|
+
GLFWruby *data = glfwGetWindowUserPointer(window);
|
226
|
+
if (RTEST(data->procs[CB_BUTTON]))
|
227
|
+
{
|
228
|
+
VALUE args = rb_ary_new_from_args(3, INT2NUM(key), INT2NUM(action), INT2NUM(mods));
|
229
|
+
rb_proc_call(data->procs[CB_BUTTON], args);
|
230
|
+
}
|
243
231
|
}
|
244
232
|
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
return ary;
|
233
|
+
static void rb_glfw_window_cb_cursor_enter(GLFWwindow *window, int entered)
|
234
|
+
{
|
235
|
+
GLFWruby *data = glfwGetWindowUserPointer(window);
|
236
|
+
if (RTEST(data->procs[CB_CURSOR_ENTER]))
|
237
|
+
{
|
238
|
+
rb_proc_call(data->procs[CB_CURSOR_ENTER], rb_ary_new_from_args(1, RB_BOOL(entered)));
|
239
|
+
}
|
253
240
|
}
|
254
241
|
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
242
|
+
static void rb_glfw_window_cb_char(GLFWwindow *window, unsigned int codepoint)
|
243
|
+
{
|
244
|
+
GLFWruby *data = glfwGetWindowUserPointer(window);
|
245
|
+
if (RTEST(data->procs[CB_CHAR]))
|
246
|
+
{
|
247
|
+
rb_proc_call(data->procs[CB_CHAR], rb_ary_new_from_args(1, UINT2NUM(codepoint)));
|
248
|
+
}
|
259
249
|
}
|
260
250
|
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
rb_ary_store(ary, 1, INT2NUM(height));
|
268
|
-
return ary;
|
269
|
-
}
|
270
|
-
|
271
|
-
VALUE rb_glfw_window_get_x(VALUE self) {
|
272
|
-
WINDOW();
|
273
|
-
int x;
|
274
|
-
glfwGetWindowPos(w, &x, NULL);
|
275
|
-
return INT2NUM(x);
|
276
|
-
}
|
277
|
-
|
278
|
-
VALUE rb_glfw_window_get_y(VALUE self) {
|
279
|
-
WINDOW();
|
280
|
-
int y;
|
281
|
-
glfwGetWindowPos(w, NULL, &y);
|
282
|
-
return INT2NUM(y);
|
283
|
-
}
|
284
|
-
|
285
|
-
VALUE rb_glfw_window_set_x(VALUE self, VALUE x) {
|
286
|
-
WINDOW();
|
287
|
-
int y;
|
288
|
-
glfwGetWindowSize(w, NULL, &y);
|
289
|
-
glfwSetWindowSize(w, NUM2INT(x), y);
|
290
|
-
return x;
|
291
|
-
}
|
292
|
-
|
293
|
-
VALUE rb_glfw_window_set_y(VALUE self, VALUE y) {
|
294
|
-
WINDOW();
|
295
|
-
int x;
|
296
|
-
glfwGetWindowSize(w, &x, NULL);
|
297
|
-
glfwSetWindowSize(w, x, NUM2INT(y));
|
298
|
-
return y;
|
299
|
-
}
|
300
|
-
|
301
|
-
VALUE rb_glfw_window_get_width(VALUE self) {
|
302
|
-
WINDOW();
|
303
|
-
int width;
|
304
|
-
glfwGetWindowSize(w, &width, NULL);
|
305
|
-
return INT2NUM(width);
|
306
|
-
}
|
307
|
-
|
308
|
-
VALUE rb_glfw_window_get_height(VALUE self) {
|
309
|
-
WINDOW();
|
310
|
-
int height;
|
311
|
-
glfwGetWindowSize(w, NULL, &height);
|
312
|
-
return INT2NUM(height);
|
313
|
-
}
|
314
|
-
|
315
|
-
VALUE rb_glfw_window_set_width(VALUE self, VALUE width) {
|
316
|
-
WINDOW();
|
317
|
-
int height;
|
318
|
-
glfwGetWindowSize(w, NULL, &height);
|
319
|
-
glfwSetWindowSize(w, NUM2INT(width), height);
|
320
|
-
return width;
|
321
|
-
}
|
322
|
-
|
323
|
-
VALUE rb_glfw_window_set_height(VALUE self, VALUE height) {
|
324
|
-
WINDOW();
|
325
|
-
int width;
|
326
|
-
glfwGetWindowSize(w, &width, NULL);
|
327
|
-
glfwSetWindowSize(w, width, NUM2INT(height));
|
328
|
-
return height;
|
329
|
-
}
|
330
|
-
|
331
|
-
VALUE rb_glfw_window_closing_p(VALUE self) {
|
332
|
-
WINDOW();
|
333
|
-
return glfwWindowShouldClose(w) ? Qtrue : Qfalse;
|
334
|
-
}
|
335
|
-
|
336
|
-
VALUE rb_glfw_window_close(int argc, VALUE *argv, VALUE self) {
|
337
|
-
WINDOW();
|
338
|
-
switch (argc) {
|
339
|
-
case 0:
|
340
|
-
glfwSetWindowShouldClose(w, 1);
|
341
|
-
break;
|
342
|
-
case 1:
|
343
|
-
glfwSetWindowShouldClose(w, RTEST(argv[0]));
|
344
|
-
break;
|
345
|
-
default:
|
346
|
-
rb_raise(rb_eArgError, "wrong number of arguments (given %d, expected 0, 1)", argc);
|
347
|
-
break;
|
251
|
+
static void rb_glfw_window_cb_scale(GLFWwindow *window, float x, float y)
|
252
|
+
{
|
253
|
+
GLFWruby *data = glfwGetWindowUserPointer(window);
|
254
|
+
if (RTEST(data->procs[CB_WINDOW_SCALE]))
|
255
|
+
{
|
256
|
+
rb_proc_call(data->procs[CB_WINDOW_SCALE], rb_ary_new_from_args(2, DBL2NUM(x), DBL2NUM(y)));
|
348
257
|
}
|
349
|
-
return self;
|
350
258
|
}
|
351
259
|
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
260
|
+
CALLBACK_PROC(resize, glfwSetWindowSizeCallback, CB_WINDOW_RESIZE)
|
261
|
+
CALLBACK_PROC(framebuffer_resize, glfwSetFramebufferSizeCallback, CB_FRAMEBUFFER_RESIZE)
|
262
|
+
CALLBACK_PROC(move, glfwSetWindowPosCallback, CB_WINDOW_MOVE)
|
263
|
+
CALLBACK_PROC(focus, glfwSetWindowFocusCallback, CB_WINDOW_FOCUS)
|
264
|
+
CALLBACK_PROC(close, glfwSetWindowCloseCallback, CB_WINDOW_CLOSE)
|
265
|
+
CALLBACK_PROC(refresh, glfwSetWindowRefreshCallback, CB_WINDOW_REFRESH)
|
266
|
+
CALLBACK_PROC(minimize, glfwSetWindowIconifyCallback, CB_WINDOW_MINIMIZE)
|
267
|
+
CALLBACK_PROC(maximize, glfwSetWindowMaximizeCallback, CB_WINDOW_MAXIMIZE)
|
268
|
+
CALLBACK_PROC(file_drop, glfwSetDropCallback, CB_WINDOW_FILE_DROP)
|
269
|
+
CALLBACK_PROC(cursor_move, glfwSetCursorPosCallback, CB_CURSOR_MOVE)
|
270
|
+
CALLBACK_PROC(scroll, glfwSetScrollCallback, CB_SCROLL)
|
271
|
+
CALLBACK_PROC(key, glfwSetKeyCallback, CB_KEY)
|
272
|
+
CALLBACK_PROC(mouse_button, glfwSetMouseButtonCallback, CB_BUTTON)
|
273
|
+
CALLBACK_PROC(cursor_enter, glfwSetCursorEnterCallback, CB_CURSOR_ENTER)
|
274
|
+
CALLBACK_PROC(char, glfwSetCharCallback, CB_CHAR)
|
275
|
+
CALLBACK_PROC(scale, glfwSetWindowContentScaleCallback, CB_WINDOW_SCALE)
|
276
|
+
|
277
|
+
static VALUE rb_glfw_window_alloc(VALUE klass)
|
278
|
+
{
|
279
|
+
// GLFW handles allocating/freeing window pointers
|
280
|
+
return Data_Wrap_Struct(klass, rb_glfw_window_mark, NULL, NULL);
|
281
|
+
}
|
282
|
+
|
283
|
+
static VALUE rb_glfw_window_default_hints(VALUE glfw)
|
284
|
+
{
|
285
|
+
glfwDefaultWindowHints();
|
286
|
+
return Qnil;
|
356
287
|
}
|
357
288
|
|
358
|
-
VALUE
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
}
|
374
|
-
default:
|
375
|
-
rb_raise(rb_eArgError, "wrong number of arguments (given %d, expected 2, 4)", argc);
|
376
|
-
break;
|
289
|
+
static VALUE rb_glfw_window_hint(VALUE glfw, VALUE hint, VALUE value)
|
290
|
+
{
|
291
|
+
int h = NUM2INT(hint);
|
292
|
+
|
293
|
+
if (FIXNUM_P(value))
|
294
|
+
{
|
295
|
+
glfwWindowHint(h, NUM2INT(value));
|
296
|
+
}
|
297
|
+
else if (RB_TYPE_P(value, T_STRING))
|
298
|
+
{
|
299
|
+
glfwWindowHintString(h, StringValueCStr(value));
|
300
|
+
}
|
301
|
+
else
|
302
|
+
{
|
303
|
+
glfwWindowHint(h, RTEST(value));
|
377
304
|
}
|
378
|
-
return self;
|
379
|
-
}
|
380
305
|
|
381
|
-
|
382
|
-
WINDOW();
|
383
|
-
const char *str = rb_string_value_cstr(&title);
|
384
|
-
glfwSetWindowTitle(w, str);
|
385
|
-
return title;
|
306
|
+
return Qnil;
|
386
307
|
}
|
387
308
|
|
388
|
-
VALUE
|
389
|
-
|
390
|
-
|
391
|
-
|
309
|
+
static VALUE rb_glfw_window_eql(VALUE self, VALUE other)
|
310
|
+
{
|
311
|
+
if (CLASS_OF(self) != CLASS_OF(other))
|
312
|
+
return Qfalse;
|
392
313
|
|
393
|
-
|
394
|
-
WINDOW();
|
395
|
-
return glfwGetWindowAttrib(w, GLFW_ICONIFIED) ? Qtrue : Qfalse;
|
314
|
+
return RB_BOOL(DATA_PTR(self) == DATA_PTR(other));
|
396
315
|
}
|
397
316
|
|
398
|
-
VALUE
|
399
|
-
|
400
|
-
|
317
|
+
static VALUE rb_glfw_window_current(VALUE klass)
|
318
|
+
{
|
319
|
+
GLFWwindow *window = glfwGetCurrentContext();
|
320
|
+
return window ? Data_Wrap_Struct(klass, NULL, NULL, window) : Qnil;
|
401
321
|
}
|
402
322
|
|
403
|
-
VALUE
|
404
|
-
|
405
|
-
|
323
|
+
static VALUE rb_glfw_window_make_current(VALUE self)
|
324
|
+
{
|
325
|
+
glfwMakeContextCurrent(DATA_PTR(self));
|
326
|
+
return self;
|
406
327
|
}
|
407
328
|
|
408
|
-
VALUE
|
409
|
-
|
410
|
-
|
329
|
+
static VALUE rb_glfw_window_center(VALUE self)
|
330
|
+
{
|
331
|
+
GLFWwindow *window = DATA_PTR(self);
|
332
|
+
GLFWmonitor *monitor = glfwGetWindowMonitor(window);
|
333
|
+
|
334
|
+
// If monitor is not NULL, then window is fullscreen, do nothing.
|
335
|
+
if (!monitor)
|
336
|
+
{
|
337
|
+
monitor = glfwGetPrimaryMonitor();
|
338
|
+
|
339
|
+
int x, y, w, h, width, height;
|
340
|
+
glfwGetMonitorWorkarea(monitor, &x, &y, &w, &h);
|
341
|
+
glfwGetWindowSize(window, &width, &height);
|
342
|
+
|
343
|
+
x += ((w - width) / 2);
|
344
|
+
y += ((h - height) / 2);
|
345
|
+
glfwSetWindowPos(window, x, y);
|
346
|
+
}
|
347
|
+
return self;
|
411
348
|
}
|
412
349
|
|
413
|
-
VALUE
|
414
|
-
|
415
|
-
return
|
350
|
+
static VALUE rb_glfw_window_get_opacity(VALUE self)
|
351
|
+
{
|
352
|
+
return DBL2NUM(glfwGetWindowOpacity(DATA_PTR(self)));
|
416
353
|
}
|
417
354
|
|
418
|
-
VALUE
|
419
|
-
|
420
|
-
|
355
|
+
static VALUE rb_glfw_window_set_opacity(VALUE self, VALUE value)
|
356
|
+
{
|
357
|
+
glfwSetWindowOpacity(DATA_PTR(self), NUM2FLT(value));
|
358
|
+
return value;
|
421
359
|
}
|
422
360
|
|
423
|
-
VALUE
|
424
|
-
|
425
|
-
|
361
|
+
static VALUE rb_glfw_window_initialize(int argc, VALUE *argv, VALUE self)
|
362
|
+
{
|
363
|
+
if (!glfwInit())
|
364
|
+
rb_raise(eGLFWError, "failed to initialize GLFW");
|
365
|
+
|
366
|
+
VALUE w, h, title, opts;
|
367
|
+
rb_scan_args(argc, argv, "21:", &w, &h, &title, &opts);
|
368
|
+
|
369
|
+
// Validate width/height
|
370
|
+
int width, height;
|
371
|
+
width = NUM2INT(w);
|
372
|
+
height = NUM2INT(h);
|
373
|
+
if (width < 1)
|
374
|
+
rb_raise(rb_eArgError, "width must be greater than 0");
|
375
|
+
if (height < 1)
|
376
|
+
rb_raise(rb_eArgError, "height must be greater than 0");
|
377
|
+
|
378
|
+
GLFWwindow *window = NULL;
|
379
|
+
GLFWmonitor *monitor = NULL;
|
380
|
+
GLFWwindow *shared = NULL;
|
381
|
+
|
382
|
+
int center = GLFW_TRUE;
|
383
|
+
int vsync = GLFW_TRUE;
|
384
|
+
|
385
|
+
if (RTEST(opts))
|
386
|
+
{
|
387
|
+
VALUE opt = rb_hash_aref(opts, STR2SYM("center"));
|
388
|
+
if (opt != Qnil)
|
389
|
+
center = opt != Qfalse;
|
390
|
+
|
391
|
+
opt = rb_hash_aref(opts, STR2SYM("vsync"));
|
392
|
+
if (opt != Qnil)
|
393
|
+
vsync = opt != Qfalse;
|
394
|
+
|
395
|
+
opt = rb_hash_aref(opts, STR2SYM("monitor"));
|
396
|
+
if (RTEST(opt))
|
397
|
+
monitor = DATA_PTR(opt);
|
398
|
+
|
399
|
+
opt = rb_hash_aref(opts, STR2SYM("shared"));
|
400
|
+
if (RTEST(shared))
|
401
|
+
shared = DATA_PTR(opt);
|
402
|
+
|
403
|
+
if (RTEST(rb_hash_aref(opts, STR2SYM("full_window"))))
|
404
|
+
{
|
405
|
+
if (!monitor)
|
406
|
+
monitor = glfwGetPrimaryMonitor();
|
407
|
+
const GLFWvidmode *mode = glfwGetVideoMode(monitor);
|
408
|
+
|
409
|
+
glfwWindowHint(GLFW_RED_BITS, mode->redBits);
|
410
|
+
glfwWindowHint(GLFW_GREEN_BITS, mode->greenBits);
|
411
|
+
glfwWindowHint(GLFW_BLUE_BITS, mode->blueBits);
|
412
|
+
glfwWindowHint(GLFW_REFRESH_RATE, mode->refreshRate);
|
413
|
+
width = mode->width;
|
414
|
+
height = mode->height;
|
415
|
+
}
|
416
|
+
else if (RTEST(rb_hash_aref(opts, STR2SYM("fullscreen"))) && !monitor)
|
417
|
+
{
|
418
|
+
monitor = glfwGetPrimaryMonitor();
|
419
|
+
}
|
420
|
+
}
|
421
|
+
|
422
|
+
const char *caption = RTEST(title) ? StringValueCStr(title) : "";
|
423
|
+
window = glfwCreateWindow(width, height, caption, monitor, shared);
|
424
|
+
if (!window)
|
425
|
+
rb_raise(eGLFWError, "failed to create OpenGL context");
|
426
|
+
|
427
|
+
GLFWruby *data = ALLOC(GLFWruby);
|
428
|
+
memset(data, 0, sizeof(GLFWruby));
|
429
|
+
data->window = self;
|
430
|
+
data->title = title;
|
431
|
+
glfwSetWindowUserPointer(window, data);
|
432
|
+
|
433
|
+
RDATA(self)->data = window;
|
434
|
+
glfwMakeContextCurrent(window);
|
435
|
+
|
436
|
+
if (vsync)
|
437
|
+
glfwSwapInterval(1);
|
438
|
+
if (center)
|
439
|
+
rb_glfw_window_center(self);
|
440
|
+
|
441
|
+
if (rb_block_given_p())
|
442
|
+
{
|
443
|
+
rb_yield(self);
|
444
|
+
glfwDestroyWindow(window);
|
445
|
+
}
|
446
|
+
|
426
447
|
return Qnil;
|
427
448
|
}
|
428
449
|
|
429
|
-
VALUE
|
430
|
-
|
431
|
-
|
432
|
-
|
450
|
+
static VALUE rb_glfw_window_close(int argc, VALUE *argv, VALUE self)
|
451
|
+
{
|
452
|
+
int close = argc > 0 ? RTEST(argv[0]) : GLFW_TRUE;
|
453
|
+
glfwSetWindowShouldClose(DATA_PTR(self), close);
|
454
|
+
return self;
|
433
455
|
}
|
434
456
|
|
435
|
-
VALUE
|
436
|
-
|
437
|
-
|
438
|
-
glfwGetWindowFrameSize(w, &left, &top, &right, &bottom);
|
439
|
-
VALUE ary = rb_ary_new_capa(4);
|
440
|
-
rb_ary_store(ary, 0, INT2NUM(left));
|
441
|
-
rb_ary_store(ary, 1, INT2NUM(top));
|
442
|
-
rb_ary_store(ary, 2, INT2NUM(right));
|
443
|
-
rb_ary_store(ary, 3, INT2NUM(bottom));
|
444
|
-
return ary;
|
457
|
+
static VALUE rb_glfw_window_closing(VALUE self)
|
458
|
+
{
|
459
|
+
return RB_BOOL(glfwWindowShouldClose(DATA_PTR(self)));
|
445
460
|
}
|
446
461
|
|
447
|
-
VALUE
|
448
|
-
|
449
|
-
|
450
|
-
return
|
462
|
+
static VALUE rb_glfw_window_swap_buffers(VALUE self)
|
463
|
+
{
|
464
|
+
glfwSwapBuffers(DATA_PTR(self));
|
465
|
+
return Qnil;
|
451
466
|
}
|
452
467
|
|
453
|
-
VALUE
|
454
|
-
|
455
|
-
|
456
|
-
glfwSetClipboardString(w, StringValueCStr(utf8));
|
457
|
-
return str;
|
468
|
+
static VALUE rb_glfw_window_is_current(VALUE self)
|
469
|
+
{
|
470
|
+
return RB_BOOL(glfwGetCurrentContext() == DATA_PTR(self));
|
458
471
|
}
|
459
472
|
|
460
|
-
VALUE
|
461
|
-
|
462
|
-
|
463
|
-
|
473
|
+
static VALUE rb_glfw_window_show(VALUE self)
|
474
|
+
{
|
475
|
+
glfwShowWindow(DATA_PTR(self));
|
476
|
+
return self;
|
477
|
+
}
|
464
478
|
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
479
|
+
static VALUE rb_glfw_window_hide(VALUE self)
|
480
|
+
{
|
481
|
+
glfwHideWindow(DATA_PTR(self));
|
482
|
+
return self;
|
483
|
+
}
|
469
484
|
|
470
|
-
|
485
|
+
static VALUE rb_glfw_window_focus(VALUE self)
|
486
|
+
{
|
487
|
+
glfwFocusWindow(DATA_PTR(self));
|
488
|
+
return self;
|
489
|
+
}
|
471
490
|
|
472
|
-
|
491
|
+
static VALUE rb_glfw_window_minimize(VALUE self)
|
492
|
+
{
|
493
|
+
glfwIconifyWindow(DATA_PTR(self));
|
473
494
|
return self;
|
474
495
|
}
|
475
496
|
|
476
|
-
VALUE
|
477
|
-
|
478
|
-
|
497
|
+
static VALUE rb_glfw_window_maximize(VALUE self)
|
498
|
+
{
|
499
|
+
glfwMaximizeWindow(DATA_PTR(self));
|
500
|
+
return self;
|
479
501
|
}
|
480
502
|
|
481
|
-
VALUE
|
482
|
-
|
483
|
-
|
484
|
-
return
|
503
|
+
static VALUE rb_glfw_window_restore(VALUE self)
|
504
|
+
{
|
505
|
+
glfwRestoreWindow(DATA_PTR(self));
|
506
|
+
return self;
|
485
507
|
}
|
486
508
|
|
487
|
-
VALUE
|
488
|
-
|
489
|
-
|
509
|
+
static VALUE rb_glfw_window_destroy(VALUE self)
|
510
|
+
{
|
511
|
+
glfwDestroyWindow(DATA_PTR(self));
|
512
|
+
return Qnil;
|
490
513
|
}
|
491
514
|
|
492
|
-
VALUE
|
493
|
-
|
494
|
-
|
495
|
-
return
|
515
|
+
static VALUE rb_glfw_window_request_attention(VALUE self)
|
516
|
+
{
|
517
|
+
glfwRequestWindowAttention(DATA_PTR(self));
|
518
|
+
return self;
|
496
519
|
}
|
497
520
|
|
498
|
-
VALUE
|
499
|
-
|
500
|
-
|
521
|
+
static VALUE rb_glfw_window_monitor(VALUE self)
|
522
|
+
{
|
523
|
+
GLFWmonitor *monitor = glfwGetWindowMonitor(DATA_PTR(self));
|
524
|
+
return monitor ? Data_Wrap_Struct(cMonitor, NULL, NULL, monitor) : Qnil;
|
501
525
|
}
|
502
526
|
|
503
|
-
VALUE
|
504
|
-
|
505
|
-
|
506
|
-
return
|
527
|
+
static VALUE rb_glfw_window_get_title(VALUE self)
|
528
|
+
{
|
529
|
+
GLFWruby *data = glfwGetWindowUserPointer(DATA_PTR(self));
|
530
|
+
return data ? data->title : Qnil;
|
507
531
|
}
|
508
532
|
|
509
|
-
VALUE
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
return ary;
|
533
|
+
static VALUE rb_glfw_window_set_title(VALUE self, VALUE title)
|
534
|
+
{
|
535
|
+
GLFWwindow *window = DATA_PTR(self);
|
536
|
+
GLFWruby *data = glfwGetWindowUserPointer(window);
|
537
|
+
data->title = title;
|
538
|
+
glfwSetWindowTitle(window, RTEST(title) ? StringValueCStr(title) : "");
|
539
|
+
return title;
|
517
540
|
}
|
518
541
|
|
519
|
-
VALUE
|
520
|
-
|
521
|
-
|
522
|
-
|
542
|
+
static VALUE rb_glfw_window_framebuffer_size(VALUE self)
|
543
|
+
{
|
544
|
+
int w, h;
|
545
|
+
glfwGetFramebufferSize(DATA_PTR(self), &w, &h);
|
546
|
+
return rb_glfw_ivec2_create(cSize, w, h);
|
523
547
|
}
|
524
548
|
|
525
|
-
VALUE
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
return self;
|
549
|
+
static VALUE rb_glfw_window_get_size(VALUE self)
|
550
|
+
{
|
551
|
+
int w, h;
|
552
|
+
glfwGetWindowSize(DATA_PTR(self), &w, &h);
|
553
|
+
return rb_glfw_ivec2_create(cSize, w, h);
|
531
554
|
}
|
532
555
|
|
533
|
-
VALUE
|
534
|
-
|
535
|
-
|
556
|
+
static VALUE rb_glfw_window_set_size(VALUE self, VALUE size)
|
557
|
+
{
|
558
|
+
RBivec2 *v = DATA_PTR(size);
|
559
|
+
glfwSetWindowSize(DATA_PTR(self), v->x, v->y);
|
560
|
+
return size;
|
536
561
|
}
|
537
562
|
|
538
|
-
VALUE
|
539
|
-
|
540
|
-
|
563
|
+
static VALUE rb_glfw_window_get_position(VALUE self)
|
564
|
+
{
|
565
|
+
int x, y;
|
566
|
+
glfwGetWindowPos(DATA_PTR(self), &x, &y);
|
567
|
+
return rb_glfw_ivec2_create(cSize, x, y);
|
541
568
|
}
|
542
569
|
|
543
|
-
|
544
|
-
|
545
|
-
|
570
|
+
static VALUE rb_glfw_window_set_position(VALUE self, VALUE size)
|
571
|
+
{
|
572
|
+
RBivec2 *v = DATA_PTR(size);
|
573
|
+
glfwSetWindowPos(DATA_PTR(self), v->x, v->y);
|
574
|
+
return size;
|
575
|
+
}
|
546
576
|
|
547
|
-
VALUE
|
548
|
-
|
577
|
+
static VALUE rb_glfw_window_aspect_ratio(VALUE self, VALUE numerator, VALUE denominator)
|
578
|
+
{
|
579
|
+
glfwSetWindowAspectRatio(DATA_PTR(self), NUM2INT(numerator), NUM2INT(denominator));
|
549
580
|
return Qnil;
|
550
581
|
}
|
551
582
|
|
552
|
-
VALUE
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
switch (type) {
|
557
|
-
case GLFW_RB_MOVED:
|
558
|
-
glfwSetWindowPosCallback(w, state ? rb_glfw_window_moved : NULL);
|
559
|
-
break;
|
560
|
-
case GLFW_RB_RESIZED:
|
561
|
-
glfwSetWindowSizeCallback(w, state ? rb_glfw_window_resized : NULL);
|
562
|
-
break;
|
563
|
-
case GLFW_RB_FRAMEBUFFER_RESIZED:
|
564
|
-
glfwSetFramebufferSizeCallback(w, state ? rb_glfw_window_frame_buffer_resized : NULL);
|
565
|
-
break;
|
566
|
-
case GLFW_RB_CLOSING:
|
567
|
-
glfwSetWindowCloseCallback(w, state ? rb_glfw_window_closing : NULL);
|
568
|
-
break;
|
569
|
-
case GLFW_RB_REFRESHED:
|
570
|
-
glfwSetWindowRefreshCallback(w, state ? rb_glfw_window_refreshed : NULL);
|
571
|
-
break;
|
572
|
-
case GLFW_RB_FOCUS_CHANGED:
|
573
|
-
glfwSetWindowFocusCallback(w, state ? rb_glfw_window_focus_changed : NULL);
|
574
|
-
break;
|
575
|
-
case GLFW_RB_MINIMIZE_CHANGED:
|
576
|
-
glfwSetWindowIconifyCallback(w, state ? rb_glfw_window_minimize_changed : NULL);
|
577
|
-
break;
|
578
|
-
case GLFW_RB_MOUSE_MOVE:
|
579
|
-
glfwSetCursorPosCallback(w, state ? rb_glfw_window_cursor_mouse_move : NULL);
|
580
|
-
break;
|
581
|
-
case GLFW_RB_MOUSE_SCROLL:
|
582
|
-
glfwSetScrollCallback(w, state ? rb_glfw_window_cursor_mouse_scroll : NULL);
|
583
|
-
break;
|
584
|
-
case GLFW_RB_MOUSE_BUTTON:
|
585
|
-
glfwSetMouseButtonCallback(w, state ? rb_glfw_window_cursor_mouse_button : NULL);
|
586
|
-
break;
|
587
|
-
case GLFW_RB_MOUSE_ENTER:
|
588
|
-
glfwSetCursorEnterCallback(w, state ? rb_glfw_window_mouse_enter : NULL);
|
589
|
-
break;
|
590
|
-
case GLFW_RB_KEY:
|
591
|
-
glfwSetKeyCallback(w, state ? rb_glfw_window_key : NULL);
|
592
|
-
break;
|
593
|
-
case GLFW_RB_CHAR:
|
594
|
-
glfwSetCharCallback(w, state ? rb_glfw_window_char : NULL);
|
595
|
-
break;
|
596
|
-
case GLFW_RB_CHAR_MODS:
|
597
|
-
glfwSetCharModsCallback(w, state ? rb_glfw_window_char_mods : NULL);
|
598
|
-
break;
|
599
|
-
case GLFW_RB_FILE_DROP:
|
600
|
-
glfwSetDropCallback(w, state ? rb_glfw_window_file_drop : NULL);
|
601
|
-
break;
|
602
|
-
default:
|
603
|
-
rb_raise(rb_eArgError, "invalid callback identifier - %d", type);
|
604
|
-
break;
|
605
|
-
}
|
606
|
-
|
583
|
+
static VALUE rb_glfw_window_size_limits(VALUE self, VALUE minimum, VALUE maximum)
|
584
|
+
{
|
585
|
+
RBivec2 *min = DATA_PTR(minimum), *max = DATA_PTR(maximum);
|
586
|
+
glfwSetWindowSizeLimits(DATA_PTR(self), min->x, min->y, max->x, max->y);
|
607
587
|
return Qnil;
|
608
588
|
}
|
609
589
|
|
610
|
-
static
|
611
|
-
|
612
|
-
|
613
|
-
|
590
|
+
static VALUE rb_glfw_window_frame_size(VALUE self)
|
591
|
+
{
|
592
|
+
int left, top, right, bottom;
|
593
|
+
glfwGetWindowFrameSize(DATA_PTR(self), &left, &top, &right, &bottom);
|
594
|
+
return rb_ary_new_from_args(4, INT2NUM(left), INT2NUM(top), INT2NUM(right), INT2NUM(bottom));
|
614
595
|
}
|
615
596
|
|
616
|
-
static
|
617
|
-
|
618
|
-
|
619
|
-
|
597
|
+
static VALUE rb_glfw_window_get_icon(VALUE self)
|
598
|
+
{
|
599
|
+
GLFWruby *data = glfwGetWindowUserPointer(DATA_PTR(self));
|
600
|
+
return RTEST(data->icon) ? data->icon : Qnil;
|
620
601
|
}
|
621
602
|
|
622
|
-
static
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
603
|
+
static VALUE rb_glfw_window_set_icon(VALUE self, VALUE icon)
|
604
|
+
{
|
605
|
+
GLFWwindow *window = DATA_PTR(self);
|
606
|
+
if (!RTEST(icon))
|
607
|
+
{
|
608
|
+
glfwSetWindowIcon(window, 0, NULL);
|
609
|
+
}
|
610
|
+
else if (RB_TYPE_P(icon, T_DATA))
|
611
|
+
{
|
612
|
+
GLFWimage *image = DATA_PTR(icon);
|
613
|
+
glfwSetWindowIcon(window, 1, image);
|
614
|
+
}
|
615
|
+
else // Array
|
616
|
+
{
|
617
|
+
long len = rb_array_len(icon);
|
618
|
+
GLFWimage images[len];
|
619
|
+
for (long i = 0; i < len; i++)
|
620
|
+
{
|
621
|
+
VALUE img = rb_ary_entry(icon, i);
|
622
|
+
images[i] = *(GLFWimage *)(DATA_PTR(img));
|
623
|
+
}
|
624
|
+
glfwSetWindowIcon(window, (int)len, images);
|
625
|
+
}
|
627
626
|
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
rb_funcall(w, id_refreshed, 0);
|
627
|
+
GLFWruby *data = glfwGetWindowUserPointer(window);
|
628
|
+
data->icon = icon;
|
629
|
+
return icon;
|
632
630
|
}
|
633
631
|
|
634
|
-
static
|
635
|
-
|
636
|
-
|
637
|
-
|
632
|
+
static VALUE rb_glfw_window_get_cursor(VALUE self)
|
633
|
+
{
|
634
|
+
GLFWruby *data = glfwGetWindowUserPointer(DATA_PTR(self));
|
635
|
+
return RTEST(data->cursor) ? data->cursor : Qnil;
|
638
636
|
}
|
639
637
|
|
640
|
-
static
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
}
|
638
|
+
static VALUE rb_glfw_window_set_cursor(VALUE self, VALUE cursor)
|
639
|
+
{
|
640
|
+
GLFWwindow *window = DATA_PTR(self);
|
641
|
+
GLFWruby *data = glfwGetWindowUserPointer(window);
|
645
642
|
|
646
|
-
|
647
|
-
|
648
|
-
if (RTEST(w))
|
649
|
-
rb_funcall(w, id_framebuffer_resized, 2, INT2NUM(width), INT2NUM(height));
|
650
|
-
}
|
643
|
+
glfwSetCursor(window, DATA_PTR(cursor));
|
644
|
+
data->cursor = cursor;
|
651
645
|
|
652
|
-
|
653
|
-
VALUE w = (VALUE)glfwGetWindowUserPointer(window);
|
654
|
-
if (RTEST(w))
|
655
|
-
rb_funcall(w, id_mouse_move, 2, DBL2NUM(x), DBL2NUM(y));
|
646
|
+
return cursor;
|
656
647
|
}
|
657
648
|
|
658
|
-
static
|
659
|
-
|
660
|
-
|
661
|
-
|
649
|
+
static VALUE rb_glfw_window_content_scale(VALUE self)
|
650
|
+
{
|
651
|
+
float x, y;
|
652
|
+
glfwGetWindowContentScale(DATA_PTR(self), &x, &y);
|
653
|
+
return rb_glfw_vec2_create(cVec2, x, y);
|
662
654
|
}
|
663
655
|
|
664
|
-
static
|
665
|
-
|
666
|
-
|
667
|
-
|
656
|
+
static VALUE rb_glfw_window_get_cursor_pos(VALUE self)
|
657
|
+
{
|
658
|
+
double x, y;
|
659
|
+
glfwGetCursorPos(DATA_PTR(self), &x, &y);
|
660
|
+
return rb_glfw_vec2_create(cVec2, x, y);
|
668
661
|
}
|
669
662
|
|
670
|
-
static
|
671
|
-
|
672
|
-
|
673
|
-
|
663
|
+
static VALUE rb_glfw_window_set_cursor_pos(VALUE self, VALUE position)
|
664
|
+
{
|
665
|
+
RBvec2 *vec = DATA_PTR(position);
|
666
|
+
glfwSetCursorPos(DATA_PTR(self), vec->x, vec->y);
|
667
|
+
return position;
|
674
668
|
}
|
675
669
|
|
676
|
-
static
|
677
|
-
|
678
|
-
|
679
|
-
|
670
|
+
static VALUE rb_glfw_window_cursor_move(VALUE self, VALUE x, VALUE y)
|
671
|
+
{
|
672
|
+
glfwSetCursorPos(DATA_PTR(self), NUM2DBL(x), NUM2DBL(y));
|
673
|
+
return Qnil;
|
680
674
|
}
|
681
675
|
|
682
|
-
static
|
683
|
-
|
684
|
-
|
685
|
-
|
676
|
+
static VALUE rb_glfw_window_get_clipboard(VALUE self)
|
677
|
+
{
|
678
|
+
const char *str = glfwGetClipboardString(DATA_PTR(self));
|
679
|
+
return str ? rb_str_new_cstr(str) : Qnil;
|
686
680
|
}
|
687
681
|
|
688
|
-
static
|
689
|
-
|
690
|
-
|
691
|
-
|
682
|
+
static VALUE rb_glfw_window_set_clipboard(VALUE self, VALUE str)
|
683
|
+
{
|
684
|
+
const char *s = RTEST(str) ? StringValueCStr(str) : "";
|
685
|
+
glfwSetClipboardString(DATA_PTR(self), s);
|
686
|
+
return str;
|
692
687
|
}
|
693
688
|
|
694
|
-
static
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
pos = strchr(pos, '\\');
|
703
|
-
}
|
704
|
-
rb_ary_store(ary, i, rb_utf8_str_new_cstr(files[i]));
|
705
|
-
}
|
706
|
-
rb_funcall(w, id_file_drop, 1, ary);
|
707
|
-
}
|
689
|
+
static VALUE rb_glfw_window_change_monitor(VALUE self, VALUE monitor, VALUE position, VALUE size, VALUE hz)
|
690
|
+
{
|
691
|
+
GLFWmonitor *m = RTEST(monitor) ? DATA_PTR(monitor) : NULL;
|
692
|
+
RBivec2 *pos = DATA_PTR(position);
|
693
|
+
RBivec2 *sz = DATA_PTR(size);
|
694
|
+
|
695
|
+
glfwSetWindowMonitor(DATA_PTR(self), m, pos->x, pos->y, sz->x, sz->y, NUM2INT(hz));
|
696
|
+
return Qnil;
|
708
697
|
}
|
698
|
+
|
699
|
+
static VALUE rb_glfw_window_is_key(VALUE self, VALUE key)
|
700
|
+
{
|
701
|
+
return RB_BOOL(glfwGetKey(DATA_PTR(self), NUM2INT(key)));
|
702
|
+
}
|
703
|
+
|
704
|
+
static VALUE rb_glfw_window_is_button(VALUE self, VALUE button)
|
705
|
+
{
|
706
|
+
return RB_BOOL(glfwGetMouseButton(DATA_PTR(self), NUM2INT(button)));
|
707
|
+
}
|
708
|
+
|
709
|
+
static VALUE rb_glfw_window_get_cursor_mode(VALUE self)
|
710
|
+
{
|
711
|
+
return INT2NUM(glfwGetInputMode(DATA_PTR(self), GLFW_CURSOR));
|
712
|
+
}
|
713
|
+
|
714
|
+
static VALUE rb_glfw_window_set_cursor_mode(VALUE self, VALUE mode)
|
715
|
+
{
|
716
|
+
glfwSetInputMode(DATA_PTR(self), GLFW_CURSOR, NUM2INT(mode));
|
717
|
+
return mode;
|
718
|
+
}
|
719
|
+
|
720
|
+
static VALUE rb_glfw_window_is_fullscreen(VALUE self)
|
721
|
+
{
|
722
|
+
GLFWmonitor *monitor = glfwGetWindowMonitor(DATA_PTR(self));
|
723
|
+
return RB_BOOL(monitor != NULL);
|
724
|
+
}
|
725
|
+
|
726
|
+
WINDOW_ATTRIBUTE(topmost, GLFW_FLOATING, RB_BOOL, RTEST)
|
727
|
+
WINDOW_ATTRIBUTE(decorated, GLFW_DECORATED, RB_BOOL, RTEST)
|
728
|
+
WINDOW_ATTRIBUTE(resizable, GLFW_RESIZABLE, RB_BOOL, RTEST)
|
729
|
+
WINDOW_ATTRIBUTE(auto_focus, GLFW_FOCUS_ON_SHOW, RB_BOOL, RTEST)
|
730
|
+
WINDOW_ATTRIBUTE(visible, GLFW_VISIBLE, RB_BOOL, RTEST)
|
731
|
+
|
732
|
+
GET_WINDOW_ATTRIB(rb_glfw_window_is_focused, GLFW_FOCUSED, RB_BOOL)
|
733
|
+
GET_WINDOW_ATTRIB(rb_glfw_window_is_minimized, GLFW_ICONIFIED, RB_BOOL)
|
734
|
+
GET_WINDOW_ATTRIB(rb_glfw_window_is_maximized, GLFW_MAXIMIZED, RB_BOOL)
|
735
|
+
GET_WINDOW_ATTRIB(rb_glfw_window_is_hovered, GLFW_HOVERED, RB_BOOL)
|
736
|
+
|
737
|
+
void rb_glfw_window_init(void)
|
738
|
+
{
|
739
|
+
|
740
|
+
cWindow = rb_define_class_under(mGLFW, "Window", rb_cObject);
|
741
|
+
rb_define_alloc_func(cWindow, rb_glfw_window_alloc);
|
742
|
+
|
743
|
+
rb_define_singleton_method(cWindow, "hint", rb_glfw_window_hint, 2);
|
744
|
+
rb_define_singleton_method(cWindow, "default_hints", rb_glfw_window_default_hints, 0);
|
745
|
+
rb_define_singleton_method(cWindow, "current", rb_glfw_window_current, 0);
|
746
|
+
|
747
|
+
rb_define_method(cWindow, "initialize", rb_glfw_window_initialize, -1);
|
748
|
+
rb_define_method(cWindow, "destroy", rb_glfw_window_destroy, 0);
|
749
|
+
rb_define_method(cWindow, "make_current", rb_glfw_window_make_current, 0);
|
750
|
+
rb_define_method(cWindow, "current?", rb_glfw_window_is_current, 0);
|
751
|
+
rb_define_method(cWindow, "monitor", rb_glfw_window_monitor, 0);
|
752
|
+
rb_define_method(cWindow, "content_scale", rb_glfw_window_content_scale, 0);
|
753
|
+
|
754
|
+
rb_define_method(cWindow, "title", rb_glfw_window_get_title, 0);
|
755
|
+
rb_define_method(cWindow, "title=", rb_glfw_window_set_title, 1);
|
756
|
+
rb_define_method(cWindow, "icon", rb_glfw_window_get_icon, 0);
|
757
|
+
rb_define_method(cWindow, "icon=", rb_glfw_window_set_icon, 1);
|
758
|
+
rb_define_method(cWindow, "size", rb_glfw_window_get_size, 0);
|
759
|
+
rb_define_method(cWindow, "size=", rb_glfw_window_set_size, 1);
|
760
|
+
rb_define_method(cWindow, "position", rb_glfw_window_get_position, 0);
|
761
|
+
rb_define_method(cWindow, "position=", rb_glfw_window_set_position, 1);
|
762
|
+
rb_define_method(cWindow, "cursor", rb_glfw_window_get_cursor, 0);
|
763
|
+
rb_define_method(cWindow, "cursor=", rb_glfw_window_set_cursor, 1);
|
764
|
+
rb_define_method(cWindow, "cursor_pos", rb_glfw_window_get_cursor_pos, 0);
|
765
|
+
rb_define_method(cWindow, "cursor_pos=", rb_glfw_window_set_cursor_pos, 1);
|
766
|
+
rb_define_method(cWindow, "opacity", rb_glfw_window_get_opacity, 0);
|
767
|
+
rb_define_method(cWindow, "opacity=", rb_glfw_window_set_opacity, 1);
|
768
|
+
rb_define_method(cWindow, "topmost", rb_glfw_window_get_topmost, 0);
|
769
|
+
rb_define_method(cWindow, "topmost=", rb_glfw_window_set_topmost, 1);
|
770
|
+
rb_define_method(cWindow, "decorated", rb_glfw_window_get_decorated, 0);
|
771
|
+
rb_define_method(cWindow, "decorated=", rb_glfw_window_set_decorated, 1);
|
772
|
+
rb_define_method(cWindow, "resizable", rb_glfw_window_get_resizable, 0);
|
773
|
+
rb_define_method(cWindow, "resizable=", rb_glfw_window_set_resizable, 1);
|
774
|
+
rb_define_method(cWindow, "auto_focus", rb_glfw_window_get_auto_focus, 0);
|
775
|
+
rb_define_method(cWindow, "auto_focus=", rb_glfw_window_set_auto_focus, 1);
|
776
|
+
rb_define_method(cWindow, "visible", rb_glfw_window_get_visible, 0);
|
777
|
+
rb_define_method(cWindow, "visible=", rb_glfw_window_set_visible, 1);
|
778
|
+
rb_define_method(cWindow, "clipboard", rb_glfw_window_get_clipboard, 0);
|
779
|
+
rb_define_method(cWindow, "clipboard=", rb_glfw_window_set_clipboard, 1);
|
780
|
+
rb_define_method(cWindow, "cursor_mode", rb_glfw_window_get_cursor_mode, 0);
|
781
|
+
rb_define_method(cWindow, "cursor_mode=", rb_glfw_window_set_cursor_mode, 1);
|
782
|
+
|
783
|
+
rb_define_method(cWindow, "focused?", rb_glfw_window_is_focused, 0);
|
784
|
+
rb_define_method(cWindow, "minimized?", rb_glfw_window_is_minimized, 0);
|
785
|
+
rb_define_method(cWindow, "maximized?", rb_glfw_window_is_maximized, 0);
|
786
|
+
rb_define_method(cWindow, "hovered?", rb_glfw_window_is_hovered, 0);
|
787
|
+
rb_define_method(cWindow, "fullscreen?", rb_glfw_window_is_fullscreen, 0);
|
788
|
+
|
789
|
+
rb_define_method(cWindow, "aspect_ratio", rb_glfw_window_aspect_ratio, 2);
|
790
|
+
rb_define_method(cWindow, "size_limits", rb_glfw_window_size_limits, 2);
|
791
|
+
rb_define_method(cWindow, "frame_size", rb_glfw_window_frame_size, 0);
|
792
|
+
|
793
|
+
rb_define_method(cWindow, "move_cursor", rb_glfw_window_cursor_move, 2);
|
794
|
+
rb_define_method(cWindow, "framebuffer_size", rb_glfw_window_framebuffer_size, 0);
|
795
|
+
rb_define_method(cWindow, "center", rb_glfw_window_center, 0);
|
796
|
+
rb_define_method(cWindow, "close", rb_glfw_window_close, -1);
|
797
|
+
rb_define_method(cWindow, "closing?", rb_glfw_window_closing, 0);
|
798
|
+
rb_define_method(cWindow, "swap_buffers", rb_glfw_window_swap_buffers, 0);
|
799
|
+
rb_define_method(cWindow, "show", rb_glfw_window_show, 0);
|
800
|
+
rb_define_method(cWindow, "hide", rb_glfw_window_hide, 0);
|
801
|
+
rb_define_method(cWindow, "focus", rb_glfw_window_focus, 0);
|
802
|
+
rb_define_method(cWindow, "minimize", rb_glfw_window_minimize, 0);
|
803
|
+
rb_define_method(cWindow, "maximize", rb_glfw_window_maximize, 0);
|
804
|
+
rb_define_method(cWindow, "restore", rb_glfw_window_restore, 0);
|
805
|
+
rb_define_method(cWindow, "request_attention", rb_glfw_window_request_attention, 0);
|
806
|
+
rb_define_method(cWindow, "change_monitor", rb_glfw_window_change_monitor, 4);
|
807
|
+
|
808
|
+
rb_define_method(cWindow, "key?", rb_glfw_window_is_key, 1);
|
809
|
+
rb_define_method(cWindow, "mouse_button?", rb_glfw_window_is_button, 1);
|
810
|
+
rb_define_method(cWindow, "sticky_keys", rb_glfw_window_get_sticky_keys, 0);
|
811
|
+
rb_define_method(cWindow, "sticky_keys=", rb_glfw_window_set_sticky_keys, 1);
|
812
|
+
rb_define_method(cWindow, "sticky_buttons", rb_glfw_window_get_sticky_buttons, 0);
|
813
|
+
rb_define_method(cWindow, "sticky_buttons=", rb_glfw_window_set_sticky_buttons, 1);
|
814
|
+
rb_define_method(cWindow, "lock_modifiers", rb_glfw_window_get_lock_modifiers, 0);
|
815
|
+
rb_define_method(cWindow, "lock_modifiers=", rb_glfw_window_set_lock_modifiers, 1);
|
816
|
+
rb_define_method(cWindow, "raw_mouse_motion", rb_glfw_window_get_raw_mouse_motion, 0);
|
817
|
+
rb_define_method(cWindow, "raw_mouse_motion=", rb_glfw_window_set_raw_mouse_motion, 1);
|
818
|
+
|
819
|
+
rb_define_method(cWindow, "on_framebuffer_resize", rb_glfw_window_on_framebuffer_resize, 0);
|
820
|
+
rb_define_method(cWindow, "on_resize", rb_glfw_window_on_resize, 0);
|
821
|
+
rb_define_method(cWindow, "on_move", rb_glfw_window_on_move, 0);
|
822
|
+
rb_define_method(cWindow, "on_focus", rb_glfw_window_on_focus, 0);
|
823
|
+
rb_define_method(cWindow, "on_refresh", rb_glfw_window_on_refresh, 0);
|
824
|
+
rb_define_method(cWindow, "on_close", rb_glfw_window_on_close, 0);
|
825
|
+
rb_define_method(cWindow, "on_minimize", rb_glfw_window_on_minimize, 0);
|
826
|
+
rb_define_method(cWindow, "on_maximize", rb_glfw_window_on_maximize, 0);
|
827
|
+
rb_define_method(cWindow, "on_file_drop", rb_glfw_window_on_file_drop, 0);
|
828
|
+
rb_define_method(cWindow, "on_cursor_move", rb_glfw_window_on_cursor_move, 0);
|
829
|
+
rb_define_method(cWindow, "on_scroll", rb_glfw_window_on_scroll, 0);
|
830
|
+
rb_define_method(cWindow, "on_key", rb_glfw_window_on_key, 0);
|
831
|
+
rb_define_method(cWindow, "on_mouse_button", rb_glfw_window_on_mouse_button, 0);
|
832
|
+
rb_define_method(cWindow, "on_cursor_enter", rb_glfw_window_on_cursor_enter, 0);
|
833
|
+
rb_define_method(cWindow, "on_char", rb_glfw_window_on_char, 0);
|
834
|
+
rb_define_method(cWindow, "on_scale", rb_glfw_window_on_scale, 0);
|
835
|
+
|
836
|
+
rb_define_method(cWindow, "==", rb_glfw_window_eql, 1);
|
837
|
+
rb_define_method(cWindow, "eql?", rb_glfw_window_eql, 1);
|
838
|
+
|
839
|
+
rb_define_alias(cWindow, "dispose", "destroy");
|
840
|
+
}
|