glfw 0.1.0 → 0.9.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +9 -3
- data/.idea/glfw.iml +10 -12
- data/.idea/misc.xml +6 -6
- data/.idea/modules.xml +7 -7
- data/.idea/workspace.xml +44 -159
- data/Makefile +267 -0
- data/README.md +78 -17
- data/Rakefile +15 -3
- data/ext/glfw/common.h +46 -0
- data/ext/glfw/cursor.c +42 -0
- data/ext/glfw/cursor.h +14 -0
- data/ext/glfw/extconf.rb +24 -0
- data/ext/glfw/glfw.c +438 -0
- data/ext/glfw/glfw.h +41 -0
- data/ext/glfw/glfw3.h +4248 -0
- data/ext/glfw/glfw3native.h +456 -0
- data/ext/glfw/image.c +77 -0
- data/ext/glfw/image.h +14 -0
- data/ext/glfw/lib/libglfw3.a +0 -0
- data/ext/glfw/monitor.c +209 -0
- data/ext/glfw/monitor.h +29 -0
- data/ext/glfw/video_mode.c +60 -0
- data/ext/glfw/video_mode.h +21 -0
- data/ext/glfw/vulkan.c +48 -0
- data/ext/glfw/vulkan.h +16 -0
- data/ext/glfw/window.c +708 -0
- data/ext/glfw/window.h +87 -0
- data/glfw-icon.png +0 -0
- data/glfw.gemspec +9 -10
- data/lib/glfw.rb +17 -123
- data/lib/glfw/version.rb +1 -1
- metadata +63 -12
- data/.rspec +0 -3
- data/lib/glfw/window.rb +0 -12
data/ext/glfw/image.c
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
|
2
|
+
#include "image.h"
|
3
|
+
|
4
|
+
VALUE rb_cGLFWimage;
|
5
|
+
|
6
|
+
void Init_glfw_image(VALUE module) {
|
7
|
+
rb_cGLFWimage = rb_define_class_under(module, "Image", rb_cObject);
|
8
|
+
rb_define_alloc_func(rb_cGLFWimage, rb_glfw_image_alloc);
|
9
|
+
rb_define_method(rb_cGLFWimage, "initialize", rb_glfw_image_initialize, -1);
|
10
|
+
|
11
|
+
rb_define_method(rb_cGLFWimage, "width", rb_glfw_image_width, 0);
|
12
|
+
rb_define_method(rb_cGLFWimage, "height", rb_glfw_image_height, 0);
|
13
|
+
rb_define_method(rb_cGLFWimage, "pixels", rb_glfw_image_pixels, 0);
|
14
|
+
|
15
|
+
rb_define_alias(rb_cGLFWimage, "columns", "width");
|
16
|
+
rb_define_alias(rb_cGLFWimage, "rows", "height");
|
17
|
+
rb_define_alias(rb_cGLFWimage, "to_blob", "pixels");
|
18
|
+
}
|
19
|
+
|
20
|
+
static VALUE rb_glfw_image_alloc(VALUE klass) {
|
21
|
+
GLFWimage *image = ALLOC(GLFWimage);
|
22
|
+
memset(image, 0, sizeof(GLFWimage));
|
23
|
+
return Data_Wrap_Struct(klass, NULL, RUBY_DEFAULT_FREE, image);
|
24
|
+
}
|
25
|
+
|
26
|
+
VALUE rb_glfw_image_initialize(int argc, VALUE *argv, VALUE self) {
|
27
|
+
if (argc == 2 || argc == 3)
|
28
|
+
{
|
29
|
+
GLFWimage *image = ALLOC(GLFWimage);
|
30
|
+
image->width = NUM2INT(argv[0]);
|
31
|
+
image->height = NUM2INT(argv[1]);
|
32
|
+
|
33
|
+
if (argc == 3)
|
34
|
+
{
|
35
|
+
if (RB_TYPE_P(argv[2], T_STRING))
|
36
|
+
{
|
37
|
+
image->pixels = StringValuePtr(argv[2]);
|
38
|
+
}
|
39
|
+
else
|
40
|
+
{
|
41
|
+
uint32_t packed = NUM2UINT(argv[2]);
|
42
|
+
int size = sizeof(uint32_t) * image->width * image->height;
|
43
|
+
image->pixels = malloc(size);
|
44
|
+
memset(image->pixels, packed, size);
|
45
|
+
}
|
46
|
+
}
|
47
|
+
else
|
48
|
+
{
|
49
|
+
int size = 4 * image->width * image->height;
|
50
|
+
image->pixels = malloc(size);
|
51
|
+
memset(image->pixels, 0, size);
|
52
|
+
}
|
53
|
+
RDATA(self)->data = image;
|
54
|
+
return Qnil;
|
55
|
+
}
|
56
|
+
|
57
|
+
rb_raise(rb_eArgError, "wrong number of arguments (given %d, expected 2, 3)", argc);
|
58
|
+
}
|
59
|
+
|
60
|
+
VALUE rb_glfw_image_width(VALUE self) {
|
61
|
+
GLFWimage *image;
|
62
|
+
Data_Get_Struct(self, GLFWimage, image);
|
63
|
+
return INT2NUM(image->width);
|
64
|
+
}
|
65
|
+
|
66
|
+
VALUE rb_glfw_image_height(VALUE self) {
|
67
|
+
GLFWimage *image;
|
68
|
+
Data_Get_Struct(self, GLFWimage, image);
|
69
|
+
return INT2NUM(image->height);
|
70
|
+
}
|
71
|
+
|
72
|
+
VALUE rb_glfw_image_pixels(VALUE self) {
|
73
|
+
GLFWimage *image;
|
74
|
+
Data_Get_Struct(self, GLFWimage, image);
|
75
|
+
int size = image->width * image->height * 4;
|
76
|
+
return rb_str_new(image->pixels, size);
|
77
|
+
}
|
data/ext/glfw/image.h
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
|
2
|
+
#ifndef GLFW_RB_IMAGE_H
|
3
|
+
#define GLFW_RB_IMAGE_H 1
|
4
|
+
|
5
|
+
#include "common.h"
|
6
|
+
|
7
|
+
void Init_glfw_image(VALUE module);
|
8
|
+
static VALUE rb_glfw_image_alloc(VALUE klass);
|
9
|
+
VALUE rb_glfw_image_initialize(int argc, VALUE *argv, VALUE self);
|
10
|
+
VALUE rb_glfw_image_width(VALUE self);
|
11
|
+
VALUE rb_glfw_image_height(VALUE self);
|
12
|
+
VALUE rb_glfw_image_pixels(VALUE self);
|
13
|
+
|
14
|
+
#endif /* GLFW_RB_IMAGE_H */
|
Binary file
|
data/ext/glfw/monitor.c
ADDED
@@ -0,0 +1,209 @@
|
|
1
|
+
|
2
|
+
#include "monitor.h"
|
3
|
+
|
4
|
+
VALUE rb_cGLFWmonitor;
|
5
|
+
|
6
|
+
void Init_glfw_monitor(VALUE module) {
|
7
|
+
rb_cGLFWmonitor = rb_define_class_under(module, "Monitor", rb_cObject);
|
8
|
+
|
9
|
+
rb_define_method(rb_cGLFWmonitor, "name", rb_glfw_monitor_name, 0);
|
10
|
+
rb_define_method(rb_cGLFWmonitor, "position", rb_glfw_monitor_pos, 0);
|
11
|
+
rb_define_method(rb_cGLFWmonitor, "size", rb_glfw_monitor_size, 0);
|
12
|
+
rb_define_method(rb_cGLFWmonitor, "x", rb_glfw_monitor_x, 0);
|
13
|
+
rb_define_method(rb_cGLFWmonitor, "y", rb_glfw_monitor_y, 0);
|
14
|
+
rb_define_method(rb_cGLFWmonitor, "width", rb_glfw_monitor_width, 0);
|
15
|
+
rb_define_method(rb_cGLFWmonitor, "height", rb_glfw_monitor_height, 0);
|
16
|
+
rb_define_method(rb_cGLFWmonitor, "dimensions", rb_glfw_monitor_dimensions, 0);
|
17
|
+
|
18
|
+
rb_define_method(rb_cGLFWmonitor, "gamma", rb_glfw_monitor_gamma, 1);
|
19
|
+
rb_define_method(rb_cGLFWmonitor, "gamma_ramp", rb_glfw_monitor_get_gamma_ramp, 0);
|
20
|
+
rb_define_method(rb_cGLFWmonitor, "set_gamma_ramp", rb_glfw_monitor_set_gamma_ramp, -1);
|
21
|
+
rb_define_method(rb_cGLFWmonitor, "video_mode", rb_glfw_monitor_video_mode, 0);
|
22
|
+
rb_define_method(rb_cGLFWmonitor, "video_modes", rb_glfw_monitor_video_modes, 0);
|
23
|
+
|
24
|
+
rb_define_singleton_method(rb_cGLFWmonitor, "primary", rb_glfw_monitor_primary, 0);
|
25
|
+
rb_define_const(rb_cGLFWmonitor, "NONE", rb_glfw_monitor_alloc(rb_cGLFWmonitor));
|
26
|
+
|
27
|
+
rb_funcall(rb_cGLFWmonitor, rb_intern("private_class_method"), 1, STR2SYM("new"));
|
28
|
+
}
|
29
|
+
|
30
|
+
static VALUE rb_glfw_monitor_alloc(VALUE klass) {
|
31
|
+
GLFWmonitor *monitor = ruby_xmalloc(SIZEOF_INTPTR_T);
|
32
|
+
memset(monitor, 0, SIZEOF_INTPTR_T);
|
33
|
+
return Data_Wrap_Struct(rb_cGLFWmonitor, NULL, RUBY_DEFAULT_FREE, monitor);
|
34
|
+
}
|
35
|
+
|
36
|
+
VALUE rb_glfw_monitor_name(VALUE self) {
|
37
|
+
MONITOR();
|
38
|
+
const char *name = glfwGetMonitorName(m);
|
39
|
+
return rb_str_new_cstr(name);
|
40
|
+
}
|
41
|
+
|
42
|
+
VALUE rb_glfw_monitor_pos(VALUE self) {
|
43
|
+
MONITOR();
|
44
|
+
int x, y;
|
45
|
+
glfwGetMonitorPos(m, &x, &y);
|
46
|
+
VALUE ary = rb_ary_new_capa(2);
|
47
|
+
rb_ary_store(ary, 0, INT2NUM(x));
|
48
|
+
rb_ary_store(ary, 1, INT2NUM(y));
|
49
|
+
return ary;
|
50
|
+
}
|
51
|
+
|
52
|
+
VALUE rb_glfw_monitor_size(VALUE self) {
|
53
|
+
MONITOR();
|
54
|
+
int width, height;
|
55
|
+
glfwGetMonitorPhysicalSize(m, &width, &height);
|
56
|
+
VALUE ary = rb_ary_new_capa(2);
|
57
|
+
rb_ary_store(ary, 0, INT2NUM(width));
|
58
|
+
rb_ary_store(ary, 1, INT2NUM(height));
|
59
|
+
return ary;
|
60
|
+
}
|
61
|
+
|
62
|
+
VALUE rb_glfw_monitor_x(VALUE self) {
|
63
|
+
MONITOR();
|
64
|
+
int x;
|
65
|
+
glfwGetMonitorPos(m, &x, NULL);
|
66
|
+
return INT2NUM(x);
|
67
|
+
}
|
68
|
+
|
69
|
+
VALUE rb_glfw_monitor_y(VALUE self) {
|
70
|
+
MONITOR();
|
71
|
+
int y;
|
72
|
+
glfwGetMonitorPos(m, NULL, &y);
|
73
|
+
return INT2NUM(y);
|
74
|
+
}
|
75
|
+
|
76
|
+
VALUE rb_glfw_monitor_width(VALUE self) {
|
77
|
+
MONITOR();
|
78
|
+
int width;
|
79
|
+
glfwGetMonitorPhysicalSize(m, &width, NULL);
|
80
|
+
return INT2NUM(width);
|
81
|
+
}
|
82
|
+
|
83
|
+
VALUE rb_glfw_monitor_height(VALUE self) {
|
84
|
+
MONITOR();
|
85
|
+
int height;
|
86
|
+
glfwGetMonitorPhysicalSize(m, NULL, &height);
|
87
|
+
return INT2NUM(height);
|
88
|
+
}
|
89
|
+
|
90
|
+
VALUE rb_glfw_monitor_dimensions(VALUE self) {
|
91
|
+
MONITOR();
|
92
|
+
int x, y, width, height;
|
93
|
+
glfwGetMonitorPos(m, &x, &y);
|
94
|
+
glfwGetMonitorPhysicalSize(m, &width, &height);
|
95
|
+
VALUE ary = rb_ary_new_capa(4);
|
96
|
+
rb_ary_store(ary, 0, INT2NUM(x));
|
97
|
+
rb_ary_store(ary, 1, INT2NUM(y));
|
98
|
+
rb_ary_store(ary, 2, INT2NUM(width));
|
99
|
+
rb_ary_store(ary, 3, INT2NUM(height));
|
100
|
+
return ary;
|
101
|
+
}
|
102
|
+
|
103
|
+
VALUE rb_glfw_monitor_get_gamma_ramp(VALUE self) {
|
104
|
+
MONITOR();
|
105
|
+
const GLFWgammaramp *ramp = glfwGetGammaRamp(m);
|
106
|
+
|
107
|
+
if (ramp == NULL)
|
108
|
+
return Qnil;
|
109
|
+
|
110
|
+
int count = ramp->size;
|
111
|
+
VALUE hash = rb_hash_new();
|
112
|
+
VALUE red = rb_ary_new_capa(count), green = rb_ary_new_capa(count), blue = rb_ary_new_capa(count);
|
113
|
+
|
114
|
+
for (int i = 0; i < count; i++) {
|
115
|
+
rb_ary_store(red, i, INT2NUM(ramp->red[i]));
|
116
|
+
rb_ary_store(green, i, INT2NUM(ramp->green[i]));
|
117
|
+
rb_ary_store(blue, i, INT2NUM(ramp->blue[i]));
|
118
|
+
}
|
119
|
+
|
120
|
+
rb_hash_aset(hash, ID2SYM(rb_intern("red")), red);
|
121
|
+
rb_hash_aset(hash, ID2SYM(rb_intern("green")), green);
|
122
|
+
rb_hash_aset(hash, ID2SYM(rb_intern("blue")), blue);
|
123
|
+
|
124
|
+
return hash;
|
125
|
+
}
|
126
|
+
|
127
|
+
VALUE rb_glfw_monitor_set_gamma_ramp(int argc, VALUE *argv, VALUE self) {
|
128
|
+
if (argc != 1 && argc != 3)
|
129
|
+
{
|
130
|
+
rb_raise(rb_eArgError, "wrong number of arguments (given %d, expected 1, 3)", argc);
|
131
|
+
return Qnil;
|
132
|
+
}
|
133
|
+
|
134
|
+
MONITOR();
|
135
|
+
VALUE red, green, blue;
|
136
|
+
|
137
|
+
if (argc == 1)
|
138
|
+
{
|
139
|
+
Check_Type(argv[0], T_HASH);
|
140
|
+
red = rb_hash_aref(argv[0], ID2SYM(rb_intern("red")));
|
141
|
+
green = rb_hash_aref(argv[0], ID2SYM(rb_intern("green")));
|
142
|
+
blue = rb_hash_aref(argv[0], ID2SYM(rb_intern("blue")));
|
143
|
+
}
|
144
|
+
else
|
145
|
+
{
|
146
|
+
red = argv[0];
|
147
|
+
green = argv[1];
|
148
|
+
blue = argv[2];
|
149
|
+
}
|
150
|
+
|
151
|
+
Check_Type(red, T_ARRAY);
|
152
|
+
Check_Type(green, T_ARRAY);
|
153
|
+
Check_Type(blue, T_ARRAY);
|
154
|
+
|
155
|
+
int size = rb_array_len(red);
|
156
|
+
if (rb_array_len(green) != size || rb_array_len(blue) != size)
|
157
|
+
{
|
158
|
+
rb_raise(rb_eRuntimeError, "red, green, and blue gamma ramps must all be of equal length");
|
159
|
+
return Qnil;
|
160
|
+
}
|
161
|
+
|
162
|
+
GLFWgammaramp *ramp = malloc(sizeof(GLFWgammaramp));
|
163
|
+
ramp->size = size;
|
164
|
+
ramp->red = malloc(sizeof(u_short) * size);
|
165
|
+
ramp->green = malloc(sizeof(u_short) * size);
|
166
|
+
ramp->blue = malloc(sizeof(u_short) * size);
|
167
|
+
|
168
|
+
for (int i = 0; i < size; i++)
|
169
|
+
{
|
170
|
+
ramp->red[i] = NUM2USHORT(rb_ary_entry(red, i));
|
171
|
+
ramp->green[i] = NUM2USHORT(rb_ary_entry(green, i));
|
172
|
+
ramp->blue[i] = NUM2USHORT(rb_ary_entry(blue, i));
|
173
|
+
}
|
174
|
+
|
175
|
+
glfwSetGammaRamp(m, ramp);
|
176
|
+
|
177
|
+
free(ramp);
|
178
|
+
return self;
|
179
|
+
}
|
180
|
+
|
181
|
+
VALUE rb_glfw_monitor_gamma(VALUE self, VALUE exponent) {
|
182
|
+
MONITOR();
|
183
|
+
float e = (float) NUM2DBL(exponent);
|
184
|
+
glfwSetGamma(m, e);
|
185
|
+
return exponent;
|
186
|
+
}
|
187
|
+
|
188
|
+
VALUE rb_glfw_monitor_primary(VALUE klass) {
|
189
|
+
GLFWmonitor *m = glfwGetPrimaryMonitor();
|
190
|
+
return Data_Wrap_Struct(klass, NULL, RUBY_DEFAULT_FREE, m);
|
191
|
+
}
|
192
|
+
|
193
|
+
VALUE rb_glfw_monitor_video_mode(VALUE self) {
|
194
|
+
MONITOR();
|
195
|
+
const GLFWvidmode *v = glfwGetVideoMode(m);
|
196
|
+
return Data_Wrap_Struct(rb_cGLFWvidmode, NULL, RUBY_DEFAULT_FREE, (void*) v);
|
197
|
+
}
|
198
|
+
|
199
|
+
VALUE rb_glfw_monitor_video_modes(VALUE self) {
|
200
|
+
MONITOR();
|
201
|
+
int count;
|
202
|
+
const GLFWvidmode *modes = glfwGetVideoModes(m, &count);
|
203
|
+
VALUE ary = rb_ary_new_capa(count);
|
204
|
+
for (int i = 0; i < count; i++)
|
205
|
+
{
|
206
|
+
rb_ary_store(ary, i, Data_Wrap_Struct(rb_cGLFWvidmode, NULL, RUBY_DEFAULT_FREE, (void*) &modes[i]));
|
207
|
+
}
|
208
|
+
return ary;
|
209
|
+
}
|
data/ext/glfw/monitor.h
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
|
2
|
+
#ifndef GLFW_RB_MONITOR_H
|
3
|
+
#define GLFW_RB_MONITOR_H 1
|
4
|
+
|
5
|
+
#include "common.h"
|
6
|
+
#include "monitor.h"
|
7
|
+
|
8
|
+
#define MONITOR() \
|
9
|
+
GLFWmonitor *m; \
|
10
|
+
Data_Get_Struct(self, GLFWmonitor, m)
|
11
|
+
|
12
|
+
void Init_glfw_monitor(VALUE module);
|
13
|
+
static VALUE rb_glfw_monitor_alloc(VALUE klass);
|
14
|
+
VALUE rb_glfw_monitor_name(VALUE self);
|
15
|
+
VALUE rb_glfw_monitor_pos(VALUE self);
|
16
|
+
VALUE rb_glfw_monitor_size(VALUE self);
|
17
|
+
VALUE rb_glfw_monitor_x(VALUE self);
|
18
|
+
VALUE rb_glfw_monitor_y(VALUE self);
|
19
|
+
VALUE rb_glfw_monitor_width(VALUE self);
|
20
|
+
VALUE rb_glfw_monitor_height(VALUE self);
|
21
|
+
VALUE rb_glfw_monitor_dimensions(VALUE self);
|
22
|
+
VALUE rb_glfw_monitor_get_gamma_ramp(VALUE self);
|
23
|
+
VALUE rb_glfw_monitor_set_gamma_ramp(int argc, VALUE *argv, VALUE self);
|
24
|
+
VALUE rb_glfw_monitor_gamma(VALUE self, VALUE exponent);
|
25
|
+
VALUE rb_glfw_monitor_video_mode(VALUE self);
|
26
|
+
VALUE rb_glfw_monitor_video_modes(VALUE self);
|
27
|
+
VALUE rb_glfw_monitor_primary(VALUE klass);
|
28
|
+
|
29
|
+
#endif /* GLFW_RB_MONITOR_H */
|
@@ -0,0 +1,60 @@
|
|
1
|
+
|
2
|
+
#include "video_mode.h"
|
3
|
+
|
4
|
+
VALUE rb_cGLFWvidmode;
|
5
|
+
|
6
|
+
void Init_glfw_vidmode(VALUE module) {
|
7
|
+
rb_cGLFWvidmode = rb_define_class_under(module, "VideoMode", rb_cObject);
|
8
|
+
|
9
|
+
rb_define_method(rb_cGLFWvidmode, "width", rb_glfw_vidmode_width, 0);
|
10
|
+
rb_define_method(rb_cGLFWvidmode, "height", rb_glfw_vidmode_height, 0);
|
11
|
+
rb_define_method(rb_cGLFWvidmode, "red_bits", rb_glfw_vidmode_red_bits, 0);
|
12
|
+
rb_define_method(rb_cGLFWvidmode, "green_bits", rb_glfw_vidmode_green_bits, 0);
|
13
|
+
rb_define_method(rb_cGLFWvidmode, "blue_bits", rb_glfw_vidmode_blue_bits, 0);
|
14
|
+
rb_define_method(rb_cGLFWvidmode, "refresh_rate", rb_glfw_vidmode_refresh_rate, 0);
|
15
|
+
|
16
|
+
rb_define_method(rb_cGLFWvidmode, "to_s", rb_glfw_vidmode_to_s, 0);
|
17
|
+
rb_funcall(rb_cGLFWvidmode, rb_intern("private_class_method"), 1, STR2SYM("new"));
|
18
|
+
}
|
19
|
+
|
20
|
+
static VALUE rb_glfw_vidmode_alloc(VALUE klass) {
|
21
|
+
GLFWvidmode *v = ALLOC(GLFWvidmode);
|
22
|
+
memset(v, 0, sizeof(GLFWvidmode));
|
23
|
+
return Data_Wrap_Struct(klass, NULL, RUBY_DEFAULT_FREE, v);
|
24
|
+
}
|
25
|
+
|
26
|
+
VALUE rb_glfw_vidmode_width(VALUE self) {
|
27
|
+
VIDMODE();
|
28
|
+
return INT2NUM(v->width);
|
29
|
+
}
|
30
|
+
|
31
|
+
VALUE rb_glfw_vidmode_height(VALUE self) {
|
32
|
+
VIDMODE();
|
33
|
+
return INT2NUM(v->height);
|
34
|
+
}
|
35
|
+
|
36
|
+
VALUE rb_glfw_vidmode_red_bits(VALUE self) {
|
37
|
+
VIDMODE();
|
38
|
+
return INT2NUM(v->redBits);
|
39
|
+
}
|
40
|
+
|
41
|
+
VALUE rb_glfw_vidmode_green_bits(VALUE self) {
|
42
|
+
VIDMODE();
|
43
|
+
return INT2NUM(v->greenBits);
|
44
|
+
}
|
45
|
+
|
46
|
+
VALUE rb_glfw_vidmode_blue_bits(VALUE self) {
|
47
|
+
VIDMODE();
|
48
|
+
return INT2NUM(v->blueBits);
|
49
|
+
}
|
50
|
+
|
51
|
+
VALUE rb_glfw_vidmode_refresh_rate(VALUE self) {
|
52
|
+
VIDMODE();
|
53
|
+
return INT2NUM(v->refreshRate);
|
54
|
+
}
|
55
|
+
|
56
|
+
VALUE rb_glfw_vidmode_to_s(VALUE self) {
|
57
|
+
VIDMODE();
|
58
|
+
return rb_sprintf("<%s: width:%d, height:%d, r:%d, g:%d, b:%d, rate:%dhz",
|
59
|
+
rb_class2name(CLASS_OF(self)), v->width, v->height, v->redBits, v->greenBits, v->blueBits, v->refreshRate);
|
60
|
+
}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
#ifndef GLFW_RB_VIDEOMODE_H
|
2
|
+
#define GLFW_RB_VIDEOMODE_H 1
|
3
|
+
|
4
|
+
#include "common.h"
|
5
|
+
|
6
|
+
#define VIDMODE() \
|
7
|
+
GLFWvidmode *v; \
|
8
|
+
Data_Get_Struct(self, GLFWvidmode, v)
|
9
|
+
|
10
|
+
void Init_glfw_vidmode(VALUE module);
|
11
|
+
static VALUE rb_glfw_vidmode_alloc(VALUE klass);
|
12
|
+
|
13
|
+
VALUE rb_glfw_vidmode_width(VALUE self);
|
14
|
+
VALUE rb_glfw_vidmode_height(VALUE self);
|
15
|
+
VALUE rb_glfw_vidmode_red_bits(VALUE self);
|
16
|
+
VALUE rb_glfw_vidmode_green_bits(VALUE self);
|
17
|
+
VALUE rb_glfw_vidmode_blue_bits(VALUE self);
|
18
|
+
VALUE rb_glfw_vidmode_refresh_rate(VALUE self);
|
19
|
+
VALUE rb_glfw_vidmode_to_s(VALUE self);
|
20
|
+
|
21
|
+
#endif /* GLFW_RB_VIDEOMODE_H */
|
data/ext/glfw/vulkan.c
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
|
2
|
+
#include "vulkan.h"
|
3
|
+
|
4
|
+
VALUE rb_cGLFWvulkan;
|
5
|
+
|
6
|
+
void Init_glfw_vulkan(VALUE module) {
|
7
|
+
rb_cGLFWvulkan = rb_define_class_under(module, "Vulkan", rb_cObject);
|
8
|
+
|
9
|
+
rb_define_method(rb_cGLFWvulkan, "create_surface", rb_glfw_vulkan_create_surface, 2);
|
10
|
+
rb_define_method(rb_cGLFWvulkan, "proc_address", rb_glfw_vulkan_proc_address, 1);
|
11
|
+
rb_define_method(rb_cGLFWvulkan, "device_support", rb_glfw_vulkan_device_support, 2);
|
12
|
+
|
13
|
+
rb_define_singleton_method(rb_cGLFWvulkan, "supported?", rb_glfw_vulkan_supported, 0);
|
14
|
+
rb_define_singleton_method(rb_cGLFWvulkan, "required_extensions", rb_glfw_vulkan_required_ext, 0);
|
15
|
+
|
16
|
+
// TODO: Implement once Vulkan support is better in GLFW
|
17
|
+
rb_funcall(rb_cGLFWvulkan, rb_intern("private_class_method"), 1, STR2SYM("new"));
|
18
|
+
}
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
VALUE rb_glfw_vulkan_supported(VALUE klass) {
|
23
|
+
return glfwVulkanSupported() ? Qtrue : Qfalse;
|
24
|
+
}
|
25
|
+
|
26
|
+
VALUE rb_glfw_vulkan_required_ext(VALUE klass) {
|
27
|
+
uint32_t count;
|
28
|
+
const char **exts = glfwGetRequiredInstanceExtensions(&count);
|
29
|
+
VALUE ary = rb_ary_new_capa(count);
|
30
|
+
for (int i = 0; i < count; i++)
|
31
|
+
rb_ary_store(ary, i, rb_str_new_cstr(exts[i]));
|
32
|
+
return ary;
|
33
|
+
}
|
34
|
+
|
35
|
+
VALUE rb_glfw_vulkan_create_surface(VALUE self, VALUE window, VALUE allocator) {
|
36
|
+
// TODO: glfwCreateWindowSurface
|
37
|
+
return Qnil;
|
38
|
+
}
|
39
|
+
|
40
|
+
VALUE rb_glfw_vulkan_proc_address(VALUE self, VALUE name) {
|
41
|
+
// TODO: glfwGetInstanceProcAddress
|
42
|
+
return Qnil;
|
43
|
+
}
|
44
|
+
|
45
|
+
VALUE rb_glfw_vulkan_device_support(VALUE self, VALUE device, VALUE family) {
|
46
|
+
// TODO: glfwGetPhysicalDevicePresentationSupport
|
47
|
+
return Qnil;
|
48
|
+
}
|