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
|
@@ -37,6 +37,15 @@ static VALUE RenderTexture_wrap(VALUE klass, sfRenderTexture* render_texture) {
|
|
|
37
37
|
return TypedData_Wrap_Struct(klass, &RenderTexture_data_type, render_texture);
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
/* call-seq:
|
|
41
|
+
* RenderTexture.new(size) -> RenderTexture
|
|
42
|
+
* RenderTexture.new(size, settings) -> RenderTexture
|
|
43
|
+
*
|
|
44
|
+
* +settings+ is currently accepted but ignored.
|
|
45
|
+
*
|
|
46
|
+
* @return [RenderTexture]
|
|
47
|
+
* @raise [RuntimeError] if creation fails
|
|
48
|
+
*/
|
|
40
49
|
static VALUE RenderTexture_new(int argc, VALUE* argv, VALUE klass) {
|
|
41
50
|
VALUE rb_size, rb_settings;
|
|
42
51
|
|
|
@@ -47,21 +56,50 @@ static VALUE RenderTexture_new(int argc, VALUE* argv, VALUE klass) {
|
|
|
47
56
|
return RenderTexture_wrap(klass, sfRenderTexture_create(vec2u_from_rb(rb_size), NULL));
|
|
48
57
|
}
|
|
49
58
|
|
|
59
|
+
/* call-seq: size -> Vector2
|
|
60
|
+
*
|
|
61
|
+
* Returns the object's size.
|
|
62
|
+
*
|
|
63
|
+
* @return [Vector2]
|
|
64
|
+
*/
|
|
50
65
|
static VALUE RenderTexture_get_size(VALUE self) {
|
|
51
66
|
sfVector2u size = sfRenderTexture_getSize(Get_RenderTexture_Struct(self));
|
|
52
67
|
|
|
53
68
|
return vec2f_to_rb((sfVector2f){(float)size.x, (float)size.y});
|
|
54
69
|
}
|
|
55
70
|
|
|
71
|
+
/* call-seq:
|
|
72
|
+
* active=(value) -> true or false
|
|
73
|
+
*
|
|
74
|
+
* Activates or deactivates this render texture as the current OpenGL
|
|
75
|
+
* rendering target on the calling thread.
|
|
76
|
+
*
|
|
77
|
+
* @return [Boolean] whether the operation succeeded
|
|
78
|
+
*/
|
|
56
79
|
static VALUE RenderTexture_set_active(VALUE self, VALUE rb_active) {
|
|
57
80
|
return BOOL2RB(sfRenderTexture_setActive(Get_RenderTexture_Struct(self), RTEST(rb_active)));
|
|
58
81
|
}
|
|
59
82
|
|
|
83
|
+
/* call-seq: display -> self
|
|
84
|
+
*
|
|
85
|
+
* Updates the target texture with everything drawn so far. Call this after
|
|
86
|
+
* drawing and before reading #texture.
|
|
87
|
+
*
|
|
88
|
+
* @return [self]
|
|
89
|
+
*/
|
|
60
90
|
static VALUE RenderTexture_display(VALUE self) {
|
|
61
91
|
sfRenderTexture_display(Get_RenderTexture_Struct(self));
|
|
62
92
|
return self;
|
|
63
93
|
}
|
|
64
94
|
|
|
95
|
+
/* call-seq:
|
|
96
|
+
* clear -> self
|
|
97
|
+
* clear(color) -> self
|
|
98
|
+
*
|
|
99
|
+
* Clears the render texture to +color+ (a Color, default black).
|
|
100
|
+
*
|
|
101
|
+
* @return [self]
|
|
102
|
+
*/
|
|
65
103
|
static VALUE RenderTexture_clear(int argc, VALUE* argv, VALUE self) {
|
|
66
104
|
VALUE rb_color;
|
|
67
105
|
sfColor color = sfBlack;
|
|
@@ -77,6 +115,14 @@ static VALUE RenderTexture_clear(int argc, VALUE* argv, VALUE self) {
|
|
|
77
115
|
return self;
|
|
78
116
|
}
|
|
79
117
|
|
|
118
|
+
/* call-seq:
|
|
119
|
+
* view=(value) -> self
|
|
120
|
+
*
|
|
121
|
+
* Sets the target's current view.
|
|
122
|
+
*
|
|
123
|
+
* @return [self]
|
|
124
|
+
* @raise [TypeError] if +value+ is not a View
|
|
125
|
+
*/
|
|
80
126
|
static VALUE RenderTexture_set_view(VALUE self, VALUE rb_view) {
|
|
81
127
|
if (!rb_obj_is_kind_of(rb_view, Get_Klass_View())) {
|
|
82
128
|
raise_invalid_argument_class(Get_Klass_View());
|
|
@@ -87,41 +133,102 @@ static VALUE RenderTexture_set_view(VALUE self, VALUE rb_view) {
|
|
|
87
133
|
return self;
|
|
88
134
|
}
|
|
89
135
|
|
|
136
|
+
/* call-seq: view -> View
|
|
137
|
+
*
|
|
138
|
+
* Returns the target's current view.
|
|
139
|
+
*
|
|
140
|
+
* @return [View] a copy of the current view
|
|
141
|
+
*/
|
|
90
142
|
static VALUE RenderTexture_get_view(VALUE self) {
|
|
91
143
|
return Get_Casting_View(sfView_copy(sfRenderTexture_getView(Get_RenderTexture_Struct(self))));
|
|
92
144
|
}
|
|
93
145
|
|
|
146
|
+
/* call-seq: default_view -> View
|
|
147
|
+
*
|
|
148
|
+
* Returns the view covering the whole render target.
|
|
149
|
+
*
|
|
150
|
+
* @return [View] a copy of the view covering the render texture's full area
|
|
151
|
+
*/
|
|
94
152
|
static VALUE RenderTexture_get_default_view(VALUE self) {
|
|
95
153
|
return Get_Casting_View(
|
|
96
154
|
sfView_copy(sfRenderTexture_getDefaultView(Get_RenderTexture_Struct(self))));
|
|
97
155
|
}
|
|
98
156
|
|
|
157
|
+
/* call-seq: texture -> Texture
|
|
158
|
+
*
|
|
159
|
+
* Returns the target texture, whose contents update after each #display.
|
|
160
|
+
*
|
|
161
|
+
* @return [Texture] the target texture, borrowed -- its contents update
|
|
162
|
+
* after each #display
|
|
163
|
+
*/
|
|
99
164
|
static VALUE RenderTexture_get_texture(VALUE self) {
|
|
100
165
|
return texture_from_borrowed(sfRenderTexture_getTexture(Get_RenderTexture_Struct(self)));
|
|
101
166
|
}
|
|
102
167
|
|
|
168
|
+
/* call-seq:
|
|
169
|
+
* smooth=(value) -> true or false
|
|
170
|
+
*
|
|
171
|
+
* Enables or disables smooth rendering.
|
|
172
|
+
*
|
|
173
|
+
* @return [Boolean] +value+
|
|
174
|
+
*/
|
|
103
175
|
static VALUE RenderTexture_set_smooth(VALUE self, VALUE rb_smooth) {
|
|
104
176
|
sfRenderTexture_setSmooth(Get_RenderTexture_Struct(self), RTEST(rb_smooth));
|
|
105
177
|
return rb_smooth;
|
|
106
178
|
}
|
|
107
179
|
|
|
180
|
+
/* call-seq: smooth? -> true or false
|
|
181
|
+
*
|
|
182
|
+
* Returns +true+ if smooth rendering is enabled.
|
|
183
|
+
*
|
|
184
|
+
* @return [Boolean]
|
|
185
|
+
*/
|
|
108
186
|
static VALUE RenderTexture_is_smooth(VALUE self) {
|
|
109
187
|
return BOOL2RB(sfRenderTexture_isSmooth(Get_RenderTexture_Struct(self)));
|
|
110
188
|
}
|
|
111
189
|
|
|
190
|
+
/* call-seq:
|
|
191
|
+
* repeated=(value) -> true or false
|
|
192
|
+
*
|
|
193
|
+
* Enables or disables texture repeating.
|
|
194
|
+
*
|
|
195
|
+
* @return [Boolean] +value+
|
|
196
|
+
*/
|
|
112
197
|
static VALUE RenderTexture_set_repeated(VALUE self, VALUE rb_repeated) {
|
|
113
198
|
sfRenderTexture_setRepeated(Get_RenderTexture_Struct(self), RTEST(rb_repeated));
|
|
114
199
|
return rb_repeated;
|
|
115
200
|
}
|
|
116
201
|
|
|
202
|
+
/* call-seq: repeated? -> true or false
|
|
203
|
+
*
|
|
204
|
+
* Returns +true+ if texture repeating is enabled.
|
|
205
|
+
*
|
|
206
|
+
* @return [Boolean]
|
|
207
|
+
*/
|
|
117
208
|
static VALUE RenderTexture_is_repeated(VALUE self) {
|
|
118
209
|
return BOOL2RB(sfRenderTexture_isRepeated(Get_RenderTexture_Struct(self)));
|
|
119
210
|
}
|
|
120
211
|
|
|
212
|
+
/* call-seq: generate_mipmap -> true or false
|
|
213
|
+
*
|
|
214
|
+
* Generates the mipmap pyramid for the texture.
|
|
215
|
+
*
|
|
216
|
+
* @return [Boolean] whether mipmap generation succeeded
|
|
217
|
+
*/
|
|
121
218
|
static VALUE RenderTexture_generate_mipmap(VALUE self) {
|
|
122
219
|
return BOOL2RB(sfRenderTexture_generateMipmap(Get_RenderTexture_Struct(self)));
|
|
123
220
|
}
|
|
124
221
|
|
|
222
|
+
/* call-seq:
|
|
223
|
+
* draw(drawable) -> self
|
|
224
|
+
* draw(drawable, state) -> self
|
|
225
|
+
*
|
|
226
|
+
* Draws +drawable+ (anything responding to +#draw+, i.e. including
|
|
227
|
+
* Drawable) using +state+ (a RenderState, default the identity state).
|
|
228
|
+
*
|
|
229
|
+
* @return [self]
|
|
230
|
+
* @raise [ArgumentError] if given no arguments or more than 2
|
|
231
|
+
*/
|
|
125
232
|
static VALUE RenderTexture_draw(int argc, VALUE* argv, VALUE self) {
|
|
126
233
|
VALUE rb_drawable, rb_state;
|
|
127
234
|
|
|
@@ -138,6 +245,13 @@ static VALUE RenderTexture_draw(int argc, VALUE* argv, VALUE self) {
|
|
|
138
245
|
return self;
|
|
139
246
|
}
|
|
140
247
|
|
|
248
|
+
/* call-seq:
|
|
249
|
+
* RenderTexture.maximum_antialiasing_level -> Integer
|
|
250
|
+
*
|
|
251
|
+
* Returns the maximum supported antialiasing level.
|
|
252
|
+
*
|
|
253
|
+
* @return [Integer]
|
|
254
|
+
*/
|
|
141
255
|
static VALUE RenderTexture_maximum_antialiasing_level(VALUE klass) {
|
|
142
256
|
return UINT2NUM(sfRenderTexture_getMaximumAntiAliasingLevel());
|
|
143
257
|
}
|
|
@@ -150,8 +264,55 @@ static VALUE RenderTexture_maximum_antialiasing_level(VALUE klass) {
|
|
|
150
264
|
#undef RT_METHOD
|
|
151
265
|
#undef RT_HANDLE
|
|
152
266
|
|
|
153
|
-
|
|
154
|
-
|
|
267
|
+
/* Document-class: SFML::RenderTexture
|
|
268
|
+
* An off-screen render target backed by a Texture: anything drawable can be
|
|
269
|
+
* drawn onto it, then read back via #texture (after #display).
|
|
270
|
+
*
|
|
271
|
+
* The methods below are shared with Window via the render_target.inc
|
|
272
|
+
* fragment (see ext/graphics/render_target.inc) and documented here
|
|
273
|
+
* directly since the fragment hides their function bodies from the
|
|
274
|
+
* doc-comment scanner. Window's own docs restate the same list.
|
|
275
|
+
*
|
|
276
|
+
* @!method srgb?
|
|
277
|
+
* Returns +true+ if the render texture uses an sRGB format.
|
|
278
|
+
* @return [Boolean]
|
|
279
|
+
* @!method clear_stencil(value)
|
|
280
|
+
* Clears the stencil buffer with the given value.
|
|
281
|
+
* @return [self]
|
|
282
|
+
* @!method clear_color_and_stencil(color, stencil)
|
|
283
|
+
* Clears the color and stencil buffers in one pass.
|
|
284
|
+
* @return [self]
|
|
285
|
+
* @!method viewport(view = nil)
|
|
286
|
+
* Returns the current viewport in pixels; +view+ defaults to the target's current view.
|
|
287
|
+
* @return [Rect] the current viewport in pixels; +view+ defaults to the target's current view
|
|
288
|
+
* @!method scissor(view = nil)
|
|
289
|
+
* Returns the current scissor rectangle in pixels; +view+ defaults to the target's current view.
|
|
290
|
+
* @return [Rect] the current scissor rectangle in pixels; +view+ defaults to the target's current
|
|
291
|
+
* view
|
|
292
|
+
* @!method map_pixel_to_coords(point, view = nil)
|
|
293
|
+
* Converts a pixel position to world coordinates, using the inverse of the view transform.
|
|
294
|
+
* @return [Vector2]
|
|
295
|
+
* @!method map_coords_to_pixel(point, view = nil)
|
|
296
|
+
* Converts a world position to pixel coordinates.
|
|
297
|
+
* @return [Vector2]
|
|
298
|
+
* @!method push_gl_states
|
|
299
|
+
* Saves the current OpenGL states before custom drawing.
|
|
300
|
+
* @return [self]
|
|
301
|
+
* @!method pop_gl_states
|
|
302
|
+
* Restores the OpenGL states saved by #push_gl_states.
|
|
303
|
+
* @return [self]
|
|
304
|
+
* @!method reset_gl_states
|
|
305
|
+
* Resets the OpenGL states to those SFML expects.
|
|
306
|
+
* @return [self]
|
|
307
|
+
* @!method draw_primitives(vertices, primitive, state = nil)
|
|
308
|
+
* Draws raw vertex primitives using the given primitive type and render state.
|
|
309
|
+
* @return [self]
|
|
310
|
+
* @!method draw_vertex_buffer_range(buffer, first, count, state = nil)
|
|
311
|
+
* Draws a range of vertices from a VertexBuffer.
|
|
312
|
+
* @return [self]
|
|
313
|
+
*/
|
|
314
|
+
void Init_RenderTexture(VALUE rb_mSFML) {
|
|
315
|
+
rb_cRenderTexture = rb_define_class_under(rb_mSFML, "RenderTexture", rb_cObject);
|
|
155
316
|
|
|
156
317
|
rb_define_singleton_method(rb_cRenderTexture, "new", RenderTexture_new, -1);
|
|
157
318
|
rb_define_singleton_method(rb_cRenderTexture, "maximum_antialiasing_level",
|