sfml3-rb 0.2.2 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.yardopts +9 -0
- data/CHANGELOG.md +43 -17
- data/README.md +97 -29
- data/ext/audio/audio_enums.c +58 -20
- data/ext/audio/listener.c +89 -6
- data/ext/audio/music.c +206 -5
- data/ext/audio/sound.c +175 -5
- data/ext/audio/sound_buffer.c +189 -47
- data/ext/audio/sound_buffer_recorder.c +83 -16
- data/ext/audio/sound_recorder.c +172 -52
- data/ext/audio/sound_source_cone.c +108 -29
- data/ext/audio/sound_stream.c +178 -5
- data/ext/core/exceptions.c +10 -8
- data/ext/core/unicode.c +12 -2
- data/ext/ext.c +4 -0
- data/ext/graphics/blend_mode.c +203 -53
- data/ext/graphics/circle.c +271 -4
- data/ext/graphics/color.c +240 -90
- data/ext/graphics/drawable.c +15 -4
- data/ext/graphics/font.c +138 -25
- data/ext/graphics/glyph.c +31 -8
- data/ext/graphics/image.c +180 -37
- data/ext/graphics/polygon.c +293 -26
- data/ext/graphics/rect.c +211 -54
- data/ext/graphics/rectangle.c +279 -26
- data/ext/graphics/render_state.c +116 -2
- data/ext/graphics/render_texture.c +163 -2
- data/ext/graphics/shader.c +283 -17
- data/ext/graphics/shape.c +252 -26
- data/ext/graphics/sprite.c +216 -25
- data/ext/graphics/stencil_mode.c +148 -39
- data/ext/graphics/target.c +67 -22
- data/ext/graphics/target.h +15 -15
- data/ext/graphics/text.c +306 -6
- data/ext/graphics/texture.c +257 -3
- data/ext/graphics/transform.c +178 -5
- data/ext/graphics/transformable.c +126 -2
- data/ext/graphics/vertex.c +79 -2
- data/ext/graphics/vertex_array.c +128 -16
- data/ext/graphics/vertex_buffer.c +124 -2
- data/ext/graphics/view.c +130 -2
- data/ext/network/ftp.c +249 -10
- data/ext/network/http.c +156 -38
- data/ext/network/ip_address.c +107 -26
- data/ext/network/network_enums.c +248 -141
- data/ext/network/packet.c +273 -39
- data/ext/network/socket_selector.c +91 -19
- data/ext/network/tcp_listener.c +75 -16
- data/ext/network/tcp_socket.c +128 -25
- data/ext/network/udp_socket.c +122 -26
- data/ext/ports.rb +7 -0
- data/ext/system/buffer.c +41 -12
- data/ext/system/clock.c +68 -9
- data/ext/system/input_stream.c +94 -42
- data/ext/system/sleep.c +10 -2
- data/ext/system/time.c +172 -34
- data/ext/system/vec2.c +156 -35
- data/ext/system/vec3.c +166 -35
- data/ext/window/clipboard.c +47 -17
- data/ext/window/context.c +59 -9
- data/ext/window/context_settings.c +116 -38
- data/ext/window/cursor.c +39 -9
- data/ext/window/event.c +163 -42
- data/ext/window/joystick.c +69 -3
- data/ext/window/keyboard.c +168 -116
- data/ext/window/mouse.c +36 -2
- data/ext/window/sensor.c +28 -2
- data/ext/window/touch.c +20 -2
- data/ext/window/video_mode.c +90 -19
- data/ext/window/vulkan.c +34 -6
- data/ext/window/window.c +340 -16
- data/lib/sfml/version.rb +1 -1
- data/sig/audio/audio_enums.rbs +30 -0
- data/sig/audio/listener.rbs +16 -0
- data/sig/audio/music.rbs +56 -0
- data/sig/audio/sound.rbs +51 -0
- data/sig/audio/sound_buffer.rbs +17 -0
- data/sig/audio/sound_buffer_recorder.rbs +14 -0
- data/sig/audio/sound_recorder.rbs +17 -0
- data/sig/audio/sound_source_cone.rbs +14 -0
- data/sig/audio/sound_stream.rbs +51 -0
- data/sig/graphics/blend_mode.rbs +29 -0
- data/sig/graphics/circle.rbs +44 -0
- data/sig/graphics/color.rbs +39 -0
- data/sig/graphics/drawable.rbs +5 -0
- data/sig/graphics/font.rbs +20 -0
- data/sig/graphics/glyph.rbs +7 -0
- data/sig/graphics/image.rbs +22 -0
- data/sig/graphics/polygon.rbs +42 -0
- data/sig/graphics/rect.rbs +33 -0
- data/sig/graphics/rectangle.rbs +42 -0
- data/sig/graphics/render_state.rbs +21 -0
- data/sig/graphics/render_texture.rbs +37 -0
- data/sig/graphics/shader.rbs +39 -0
- data/sig/graphics/shape.rbs +38 -0
- data/sig/graphics/sprite.rbs +34 -0
- data/sig/graphics/stencil_mode.rbs +18 -0
- data/sig/graphics/target.rbs +10 -0
- data/sig/graphics/text.rbs +48 -0
- data/sig/graphics/texture.rbs +34 -0
- data/sig/graphics/transform.rbs +37 -0
- data/sig/graphics/transformable.rbs +25 -0
- data/sig/graphics/vertex.rbs +17 -0
- data/sig/graphics/vertex_array.rbs +17 -0
- data/sig/graphics/vertex_buffer.rbs +22 -0
- data/sig/graphics/view.rbs +24 -0
- data/sig/network/ftp.rbs +46 -0
- data/sig/network/http.rbs +27 -0
- data/sig/network/ip_address.rbs +22 -0
- data/sig/network/network_enums.rbs +95 -0
- data/sig/network/packet.rbs +40 -0
- data/sig/network/socket_selector.rbs +14 -0
- data/sig/network/tcp_listener.rbs +13 -0
- data/sig/network/tcp_socket.rbs +18 -0
- data/sig/network/udp_socket.rbs +17 -0
- data/sig/system/buffer.rbs +11 -0
- data/sig/system/clock.rbs +13 -0
- data/sig/system/input_stream.rbs +7 -0
- data/sig/system/sleep.rbs +3 -0
- data/sig/system/time.rbs +28 -0
- data/sig/system/vec2.rbs +26 -0
- data/sig/system/vec3.rbs +27 -0
- data/sig/window/clipboard.rbs +8 -0
- data/sig/window/context.rbs +11 -0
- data/sig/window/context_settings.rbs +20 -0
- data/sig/window/cursor.rbs +6 -0
- data/sig/window/event.rbs +20 -0
- data/sig/window/joystick.rbs +15 -0
- data/sig/window/keyboard.rbs +10 -0
- data/sig/window/mouse.rbs +9 -0
- data/sig/window/sensor.rbs +8 -0
- data/sig/window/touch.rbs +6 -0
- data/sig/window/video_mode.rbs +16 -0
- data/sig/window/vulkan.rbs +7 -0
- data/sig/window/window.rbs +57 -0
- metadata +66 -2
data/ext/window/video_mode.c
CHANGED
|
@@ -9,8 +9,12 @@
|
|
|
9
9
|
|
|
10
10
|
static VALUE rb_cMode;
|
|
11
11
|
|
|
12
|
-
static sfVideoMode
|
|
13
|
-
sfVideoMode
|
|
12
|
+
static sfVideoMode* VideoMode_alloc(unsigned width, unsigned height, unsigned bits, int* created) {
|
|
13
|
+
sfVideoMode* mode = malloc(sizeof(sfVideoMode));
|
|
14
|
+
|
|
15
|
+
if (mode == NULL) {
|
|
16
|
+
rb_raise(rb_eNoMemError, "failed to allocate video mode");
|
|
17
|
+
}
|
|
14
18
|
|
|
15
19
|
if (created != NULL) {
|
|
16
20
|
*created = 1;
|
|
@@ -23,18 +27,17 @@ static sfVideoMode *VideoMode_alloc(unsigned width, unsigned height, unsigned bi
|
|
|
23
27
|
return mode;
|
|
24
28
|
}
|
|
25
29
|
|
|
26
|
-
static void VideoMode_free(void
|
|
30
|
+
static void VideoMode_free(void* ptr) {
|
|
27
31
|
free(ptr);
|
|
28
32
|
}
|
|
29
33
|
|
|
30
34
|
static const rb_data_type_t VideoMode_data_type = {
|
|
31
35
|
.wrap_struct_name = "SFML::VideoMode",
|
|
32
36
|
.function = {.dmark = NULL, .dfree = VideoMode_free, .dsize = NULL},
|
|
33
|
-
.flags = RUBY_TYPED_FREE_IMMEDIATELY
|
|
34
|
-
};
|
|
37
|
+
.flags = RUBY_TYPED_FREE_IMMEDIATELY};
|
|
35
38
|
|
|
36
39
|
static VALUE VideoMode_from_c(sfVideoMode mode) {
|
|
37
|
-
sfVideoMode
|
|
40
|
+
sfVideoMode* ptr = VideoMode_alloc(mode.size.x, mode.size.y, mode.bitsPerPixel, NULL);
|
|
38
41
|
VALUE self = TypedData_Wrap_Struct(rb_cMode, &VideoMode_data_type, ptr);
|
|
39
42
|
|
|
40
43
|
rb_iv_set(self, "@width", UINT2NUM(mode.size.x));
|
|
@@ -44,20 +47,34 @@ static VALUE VideoMode_from_c(sfVideoMode mode) {
|
|
|
44
47
|
return self;
|
|
45
48
|
}
|
|
46
49
|
|
|
50
|
+
/* call-seq:
|
|
51
|
+
* VideoMode.new(width, height, bits_per_pixel) -> VideoMode
|
|
52
|
+
*
|
|
53
|
+
* Creates a video mode with the given +width+, +height+ and +bits_per_pixel+.
|
|
54
|
+
*
|
|
55
|
+
* @return [VideoMode]
|
|
56
|
+
*/
|
|
47
57
|
static VALUE VideoMode_new(VALUE klass, VALUE rb_width, VALUE rb_height, VALUE rb_bits) {
|
|
48
58
|
VALUE self;
|
|
49
59
|
VALUE argv[] = {rb_width, rb_height, rb_bits};
|
|
50
60
|
|
|
51
|
-
self = VideoMode_from_c(
|
|
52
|
-
{(unsigned)
|
|
53
|
-
|
|
54
|
-
});
|
|
61
|
+
self = VideoMode_from_c(
|
|
62
|
+
(sfVideoMode){{(unsigned)NUM2UINT(rb_width), (unsigned)NUM2UINT(rb_height)},
|
|
63
|
+
(unsigned)NUM2UINT(rb_bits)});
|
|
55
64
|
|
|
56
65
|
rb_obj_call_init(self, 3, argv);
|
|
57
66
|
|
|
58
67
|
return self;
|
|
59
68
|
}
|
|
60
69
|
|
|
70
|
+
/* call-seq: initialize(width, height, bits) -> self
|
|
71
|
+
*
|
|
72
|
+
* Stores the mode's dimensions; called internally by .new.
|
|
73
|
+
*
|
|
74
|
+
* @private Sets the ivars backing the #width/#height/#bits readers; called
|
|
75
|
+
* internally by .new.
|
|
76
|
+
* @return [self]
|
|
77
|
+
*/
|
|
61
78
|
static VALUE VideoMode_init(VALUE self, VALUE rb_width, VALUE rb_height, VALUE rb_bits) {
|
|
62
79
|
rb_iv_set(self, "@width", rb_width);
|
|
63
80
|
rb_iv_set(self, "@height", rb_height);
|
|
@@ -66,14 +83,27 @@ static VALUE VideoMode_init(VALUE self, VALUE rb_width, VALUE rb_height, VALUE r
|
|
|
66
83
|
return self;
|
|
67
84
|
}
|
|
68
85
|
|
|
86
|
+
/* call-seq: desktop_mode -> VideoMode
|
|
87
|
+
*
|
|
88
|
+
* Returns the current desktop video mode.
|
|
89
|
+
*
|
|
90
|
+
* @return [VideoMode] the current desktop video mode
|
|
91
|
+
*/
|
|
69
92
|
static VALUE VideoMode_desktop_mode(VALUE klass) {
|
|
70
93
|
return VideoMode_from_c(sfVideoMode_getDesktopMode());
|
|
71
94
|
}
|
|
72
95
|
|
|
96
|
+
/* call-seq: fullscreen_modes -> Array<VideoMode>
|
|
97
|
+
*
|
|
98
|
+
* Returns all fullscreen video modes supported by the current desktop.
|
|
99
|
+
*
|
|
100
|
+
* @return [Array<VideoMode>] all video modes supported in fullscreen mode,
|
|
101
|
+
* sorted from best to worst
|
|
102
|
+
*/
|
|
73
103
|
static VALUE VideoMode_fullscreen_modes(VALUE klass) {
|
|
74
104
|
size_t count = 0;
|
|
75
|
-
const sfVideoMode
|
|
76
|
-
VALUE array = rb_ary_new_capa((long)
|
|
105
|
+
const sfVideoMode* modes = sfVideoMode_getFullscreenModes(&count);
|
|
106
|
+
VALUE array = rb_ary_new_capa((long)count);
|
|
77
107
|
|
|
78
108
|
for (size_t i = 0; i < count; i++) {
|
|
79
109
|
rb_ary_push(array, VideoMode_from_c(modes[i]));
|
|
@@ -82,16 +112,36 @@ static VALUE VideoMode_fullscreen_modes(VALUE klass) {
|
|
|
82
112
|
return array;
|
|
83
113
|
}
|
|
84
114
|
|
|
115
|
+
/* call-seq: valid? -> true or false
|
|
116
|
+
*
|
|
117
|
+
* Returns +true+ if this mode is valid for fullscreen use.
|
|
118
|
+
*
|
|
119
|
+
* @return [Boolean] whether this mode is valid for fullscreen use on the
|
|
120
|
+
* current desktop
|
|
121
|
+
*/
|
|
85
122
|
static VALUE VideoMode_is_available(VALUE self) {
|
|
86
123
|
return BOOL2RB(sfVideoMode_isValid(*Get_Mode_Struct(self)));
|
|
87
124
|
}
|
|
88
125
|
|
|
126
|
+
/* call-seq: size -> Vector2
|
|
127
|
+
*
|
|
128
|
+
* Returns +width+ and +height+ as a Vector2.
|
|
129
|
+
*
|
|
130
|
+
* @return [Vector2] +width+ and +height+ as a vector
|
|
131
|
+
*/
|
|
89
132
|
static VALUE VideoMode_get_size(VALUE self) {
|
|
90
|
-
sfVideoMode
|
|
133
|
+
sfVideoMode* mode = Get_Mode_Struct(self);
|
|
91
134
|
|
|
92
|
-
return vec2f_to_rb((sfVector2f)
|
|
135
|
+
return vec2f_to_rb((sfVector2f){(float)mode->size.x, (float)mode->size.y});
|
|
93
136
|
}
|
|
94
137
|
|
|
138
|
+
/* call-seq:
|
|
139
|
+
* self == other -> true or false
|
|
140
|
+
*
|
|
141
|
+
* Returns +true+ if +other+ has the same size and bit depth.
|
|
142
|
+
*
|
|
143
|
+
* @return [Boolean]
|
|
144
|
+
*/
|
|
95
145
|
static VALUE VideoMode_eql(VALUE self, VALUE rb_other) {
|
|
96
146
|
sfVideoMode a = *Get_Mode_Struct(self);
|
|
97
147
|
sfVideoMode b;
|
|
@@ -102,11 +152,32 @@ static VALUE VideoMode_eql(VALUE self, VALUE rb_other) {
|
|
|
102
152
|
|
|
103
153
|
b = *Get_Mode_Struct(rb_other);
|
|
104
154
|
|
|
105
|
-
return BOOL2RB(a.size.x == b.size.x && a.size.y == b.size.y &&
|
|
155
|
+
return BOOL2RB(a.size.x == b.size.x && a.size.y == b.size.y &&
|
|
156
|
+
a.bitsPerPixel == b.bitsPerPixel);
|
|
106
157
|
}
|
|
107
158
|
|
|
108
|
-
|
|
109
|
-
|
|
159
|
+
/* Document-class: SFML::VideoMode
|
|
160
|
+
* A width/height/bits-per-pixel triple describing a display mode, as used
|
|
161
|
+
* for fullscreen windows.
|
|
162
|
+
*
|
|
163
|
+
* The +width+/+height+/+bits+ accessors below are declared with
|
|
164
|
+
* +rb_define_attr+ rather than +rb_define_method+; YARD's C parser cannot
|
|
165
|
+
* handle that declaration form (a confirmed YARD bug), so they are
|
|
166
|
+
* documented here instead of above their (nonexistent, ivar-backed)
|
|
167
|
+
* definitions.
|
|
168
|
+
*
|
|
169
|
+
* @!attribute [r] width
|
|
170
|
+
* Width in pixels.
|
|
171
|
+
* @return [Integer] width in pixels
|
|
172
|
+
* @!attribute [r] height
|
|
173
|
+
* Height in pixels.
|
|
174
|
+
* @return [Integer] height in pixels
|
|
175
|
+
* @!attribute [r] bits
|
|
176
|
+
* Bits per pixel.
|
|
177
|
+
* @return [Integer] bits per pixel
|
|
178
|
+
*/
|
|
179
|
+
void Init_VideoMode(VALUE rb_mSFML) {
|
|
180
|
+
rb_cMode = rb_define_class_under(rb_mSFML, "VideoMode", rb_cObject);
|
|
110
181
|
|
|
111
182
|
rb_define_singleton_method(rb_cMode, "new", VideoMode_new, 3);
|
|
112
183
|
rb_define_singleton_method(rb_cMode, "desktop_mode", VideoMode_desktop_mode, 0);
|
|
@@ -122,8 +193,8 @@ void Init_VideoMode(VALUE rb_module) {
|
|
|
122
193
|
rb_define_attr(rb_cMode, "bits", 1, 0);
|
|
123
194
|
}
|
|
124
195
|
|
|
125
|
-
sfVideoMode
|
|
126
|
-
sfVideoMode
|
|
196
|
+
sfVideoMode* Get_Mode_Struct(VALUE self) {
|
|
197
|
+
sfVideoMode* ptr;
|
|
127
198
|
TypedData_Get_Struct(self, sfVideoMode, &VideoMode_data_type, ptr);
|
|
128
199
|
return ptr;
|
|
129
200
|
}
|
data/ext/window/vulkan.c
CHANGED
|
@@ -5,7 +5,15 @@
|
|
|
5
5
|
#include "core/macros.h"
|
|
6
6
|
#include "core/sfml.h"
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
/* call-seq:
|
|
9
|
+
* available?(require_graphics = false) -> true or false
|
|
10
|
+
*
|
|
11
|
+
* Returns +true+ if Vulkan is available, optionally requiring graphics support.
|
|
12
|
+
*
|
|
13
|
+
* @return [Boolean] whether Vulkan is available, optionally also requiring
|
|
14
|
+
* graphics-capable support when +require_graphics+ is true
|
|
15
|
+
*/
|
|
16
|
+
static VALUE Vulkan_is_available(int argc, VALUE* argv, VALUE module) {
|
|
9
17
|
VALUE rb_require_graphics;
|
|
10
18
|
bool require_graphics = false;
|
|
11
19
|
|
|
@@ -18,14 +26,30 @@ static VALUE Vulkan_is_available(int argc, VALUE *argv, VALUE module) {
|
|
|
18
26
|
return BOOL2RB(sfVulkan_isAvailable(require_graphics));
|
|
19
27
|
}
|
|
20
28
|
|
|
29
|
+
/* call-seq:
|
|
30
|
+
* function(name) -> Integer
|
|
31
|
+
*
|
|
32
|
+
* Returns the address of the Vulkan function or extension +name+ as an
|
|
33
|
+
* Integer, or 0 when it is not available.
|
|
34
|
+
*
|
|
35
|
+
* @return [Integer] the address of the Vulkan function/extension +name+, as
|
|
36
|
+
* a raw pointer value, or 0 if it is not available
|
|
37
|
+
*/
|
|
21
38
|
static VALUE Vulkan_get_function(VALUE module, VALUE rb_name) {
|
|
22
|
-
return ULL2NUM((unsigned long long)
|
|
39
|
+
return ULL2NUM((unsigned long long)(uintptr_t)sfVulkan_getFunction(StringValueCStr(rb_name)));
|
|
23
40
|
}
|
|
24
41
|
|
|
42
|
+
/* call-seq: graphics_required_instance_extensions -> Array<String>
|
|
43
|
+
*
|
|
44
|
+
* Returns the Vulkan instance extensions needed to create a window surface.
|
|
45
|
+
*
|
|
46
|
+
* @return [Array<String>] the Vulkan instance extensions required to create
|
|
47
|
+
* a Vulkan surface for a Window
|
|
48
|
+
*/
|
|
25
49
|
static VALUE Vulkan_get_graphics_required_instance_extensions(VALUE module) {
|
|
26
50
|
size_t count = 0;
|
|
27
|
-
const char *
|
|
28
|
-
VALUE array = rb_ary_new_capa((long)
|
|
51
|
+
const char* const* extensions = sfVulkan_getGraphicsRequiredInstanceExtensions(&count);
|
|
52
|
+
VALUE array = rb_ary_new_capa((long)count);
|
|
29
53
|
|
|
30
54
|
for (size_t i = 0; i < count; i++) {
|
|
31
55
|
rb_ary_push(array, rb_str_new_cstr(extensions[i]));
|
|
@@ -34,8 +58,12 @@ static VALUE Vulkan_get_graphics_required_instance_extensions(VALUE module) {
|
|
|
34
58
|
return array;
|
|
35
59
|
}
|
|
36
60
|
|
|
37
|
-
|
|
38
|
-
|
|
61
|
+
/* Document-module: SFML::Vulkan
|
|
62
|
+
* Vulkan support queries. Vulkan handles (instances, surfaces, allocators)
|
|
63
|
+
* cross this binding as plain Integers; see Window#create_vulkan_surface.
|
|
64
|
+
*/
|
|
65
|
+
void Init_Vulkan(VALUE rb_mSFML) {
|
|
66
|
+
VALUE rb_mVulkan = rb_define_module_under(rb_mSFML, "Vulkan");
|
|
39
67
|
|
|
40
68
|
rb_define_module_function(rb_mVulkan, "available?", Vulkan_is_available, -1);
|
|
41
69
|
rb_define_module_function(rb_mVulkan, "function", Vulkan_get_function, 1);
|