sfml3-rb 0.2.2 → 0.3.1
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 +67 -16
- data/README.md +123 -32
- data/TODO.md +18 -11
- data/ext/audio/audio_enums.c +58 -20
- data/ext/audio/listener.c +89 -6
- data/ext/audio/music.c +212 -5
- data/ext/audio/sound.c +218 -9
- data/ext/audio/sound_buffer.c +197 -47
- data/ext/audio/sound_buffer_recorder.c +90 -18
- data/ext/audio/sound_recorder.c +188 -58
- data/ext/audio/sound_source_cone.c +127 -33
- data/ext/audio/sound_stream.c +204 -21
- data/ext/core/exceptions.c +10 -8
- data/ext/core/unicode.c +12 -2
- data/ext/ext.c +8 -0
- data/ext/graphics/blend_mode.c +218 -60
- data/ext/graphics/circle.c +300 -16
- data/ext/graphics/color.c +253 -94
- data/ext/graphics/drawable.c +16 -4
- data/ext/graphics/font.c +144 -25
- data/ext/graphics/glyph.c +38 -8
- data/ext/graphics/image.c +205 -41
- data/ext/graphics/polygon.c +317 -30
- data/ext/graphics/rect.c +225 -60
- data/ext/graphics/rectangle.c +307 -35
- data/ext/graphics/render_state.c +124 -12
- data/ext/graphics/render_texture.c +191 -14
- data/ext/graphics/render_window.c +55 -0
- data/ext/graphics/render_window.h +10 -0
- data/ext/graphics/shader.c +289 -17
- data/ext/graphics/shape.c +265 -32
- data/ext/graphics/sprite.c +245 -30
- data/ext/graphics/stencil_mode.c +163 -46
- data/ext/graphics/target.c +121 -43
- data/ext/graphics/target.h +31 -17
- data/ext/graphics/text.c +339 -19
- data/ext/graphics/texture.c +291 -6
- data/ext/graphics/transform.c +178 -5
- data/ext/graphics/transformable.c +127 -12
- data/ext/graphics/vertex.c +98 -6
- data/ext/graphics/vertex_array.c +142 -21
- data/ext/graphics/vertex_buffer.c +154 -12
- data/ext/graphics/view.c +140 -6
- data/ext/network/ftp.c +278 -12
- data/ext/network/http.c +179 -44
- data/ext/network/ip_address.c +127 -35
- data/ext/network/network_enums.c +248 -141
- data/ext/network/packet.c +280 -41
- data/ext/network/socket_selector.c +98 -21
- data/ext/network/tcp_listener.c +82 -18
- data/ext/network/tcp_socket.c +135 -27
- data/ext/network/udp_socket.c +129 -28
- data/ext/ports.rb +7 -0
- data/ext/system/buffer.c +47 -16
- data/ext/system/clock.c +77 -12
- data/ext/system/input_stream.c +113 -51
- data/ext/system/sleep.c +10 -2
- data/ext/system/time.c +182 -40
- data/ext/system/vec2.c +166 -39
- data/ext/system/vec3.c +177 -39
- data/ext/window/clipboard.c +47 -17
- data/ext/window/context.c +66 -13
- data/ext/window/context_settings.c +132 -42
- data/ext/window/cursor.c +45 -9
- data/ext/window/event.c +164 -53
- data/ext/window/joystick.c +69 -3
- data/ext/window/keyboard.c +168 -116
- data/ext/window/mouse.c +64 -13
- data/ext/window/sensor.c +28 -2
- data/ext/window/touch.c +32 -12
- data/ext/window/video_mode.c +93 -31
- data/ext/window/vulkan.c +34 -6
- data/ext/window/window.c +228 -229
- data/ext/window/window.h +4 -4
- data/ext/window/window_base.c +251 -0
- data/ext/window/window_base.h +43 -0
- data/ext/window/window_base.inc +236 -0
- 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_target.rbs +18 -0
- data/sig/graphics/render_texture.rbs +39 -0
- data/sig/graphics/render_window.rbs +7 -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 +8 -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 +23 -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/sfml/version.rbs +3 -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 +34 -0
- data/sig/window/window_base.rbs +33 -0
- metadata +76 -3
data/ext/graphics/render_state.c
CHANGED
|
@@ -56,25 +56,41 @@ static VALUE RenderStates_wrap(VALUE klass, RenderStates* states) {
|
|
|
56
56
|
return TypedData_Wrap_Struct(klass, &RenderStates_data_type, states);
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
static VALUE
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
static VALUE RenderStates_alloc(VALUE klass) {
|
|
60
|
+
return RenderStates_wrap(klass, RenderStates_create());
|
|
61
|
+
}
|
|
62
62
|
|
|
63
|
+
/* call-seq:
|
|
64
|
+
* RenderState.new -> RenderState
|
|
65
|
+
* RenderState.new(matrix) -> RenderState
|
|
66
|
+
*
|
|
67
|
+
* Creates a render state with SFML's default blend mode, stencil mode and
|
|
68
|
+
* coordinate type, and identity transform unless +matrix+ (a 3x3
|
|
69
|
+
* row-major Array, see Transform) is given.
|
|
70
|
+
*
|
|
71
|
+
* @return [RenderState]
|
|
72
|
+
* @raise [ArgumentError] if given more than one argument
|
|
73
|
+
*/
|
|
74
|
+
static VALUE RenderStates_initialize(int argc, VALUE* argv, VALUE self) {
|
|
63
75
|
if (argc > 1) {
|
|
64
76
|
raise_invalid_arguments_excepted(1, argc);
|
|
65
77
|
}
|
|
66
78
|
|
|
67
|
-
states = RenderStates_create();
|
|
68
|
-
|
|
69
79
|
if (argc == 1) {
|
|
70
|
-
|
|
80
|
+
Get_RenderState_Struct(self)->transform = Transform_ArrayToTransform(argv[0]);
|
|
71
81
|
}
|
|
72
82
|
|
|
73
|
-
self = RenderStates_wrap(klass, states);
|
|
74
|
-
|
|
75
83
|
return self;
|
|
76
84
|
}
|
|
77
85
|
|
|
86
|
+
/* call-seq:
|
|
87
|
+
* transform=(matrix) -> self
|
|
88
|
+
* matrix=(matrix) -> self
|
|
89
|
+
*
|
|
90
|
+
* +matrix+ is a 3x3 row-major Array, see Transform.
|
|
91
|
+
*
|
|
92
|
+
* @return [self]
|
|
93
|
+
*/
|
|
78
94
|
static VALUE RenderStates_set_transform(VALUE self, VALUE rb_matrix) {
|
|
79
95
|
sfRenderStates* states = Get_RenderState_Struct(self);
|
|
80
96
|
|
|
@@ -83,32 +99,77 @@ static VALUE RenderStates_set_transform(VALUE self, VALUE rb_matrix) {
|
|
|
83
99
|
return self;
|
|
84
100
|
}
|
|
85
101
|
|
|
102
|
+
/* call-seq: transform -> Array
|
|
103
|
+
*
|
|
104
|
+
* Also available as #matrix.
|
|
105
|
+
*
|
|
106
|
+
* @return [Array] the 3x3 row-major transform matrix
|
|
107
|
+
*/
|
|
86
108
|
static VALUE RenderStates_get_transform(VALUE self) {
|
|
87
109
|
return Transform_MatrixToArray(Get_RenderState_Struct(self)->transform.matrix);
|
|
88
110
|
}
|
|
89
111
|
|
|
112
|
+
/* call-seq: blend_mode -> BlendMode
|
|
113
|
+
*
|
|
114
|
+
* Returns the state's blend mode.
|
|
115
|
+
*
|
|
116
|
+
* @return [BlendMode]
|
|
117
|
+
*/
|
|
90
118
|
static VALUE RenderStates_get_blend_mode(VALUE self) {
|
|
91
119
|
return blend_mode_to_rb(Get_RenderState_Struct(self)->blendMode);
|
|
92
120
|
}
|
|
93
121
|
|
|
122
|
+
/* call-seq:
|
|
123
|
+
* blend_mode=(value) -> BlendMode
|
|
124
|
+
*
|
|
125
|
+
* Sets the state's blend mode.
|
|
126
|
+
*
|
|
127
|
+
* @return [BlendMode] +value+
|
|
128
|
+
*/
|
|
94
129
|
static VALUE RenderStates_set_blend_mode(VALUE self, VALUE rb_mode) {
|
|
95
130
|
Get_RenderState_Struct(self)->blendMode = blend_mode_from_rb(rb_mode);
|
|
96
131
|
return rb_mode;
|
|
97
132
|
}
|
|
98
133
|
|
|
134
|
+
/* call-seq: stencil_mode -> StencilMode
|
|
135
|
+
*
|
|
136
|
+
* Returns the state's stencil mode.
|
|
137
|
+
*
|
|
138
|
+
* @return [StencilMode]
|
|
139
|
+
*/
|
|
99
140
|
static VALUE RenderStates_get_stencil_mode(VALUE self) {
|
|
100
141
|
return stencil_mode_to_rb(Get_RenderState_Struct(self)->stencilMode);
|
|
101
142
|
}
|
|
102
143
|
|
|
144
|
+
/* call-seq:
|
|
145
|
+
* stencil_mode=(value) -> StencilMode
|
|
146
|
+
*
|
|
147
|
+
* Sets the state's stencil mode.
|
|
148
|
+
*
|
|
149
|
+
* @return [StencilMode] +value+
|
|
150
|
+
*/
|
|
103
151
|
static VALUE RenderStates_set_stencil_mode(VALUE self, VALUE rb_mode) {
|
|
104
152
|
Get_RenderState_Struct(self)->stencilMode = stencil_mode_from_rb(rb_mode);
|
|
105
153
|
return rb_mode;
|
|
106
154
|
}
|
|
107
155
|
|
|
156
|
+
/* call-seq: coordinate_type -> Symbol
|
|
157
|
+
*
|
|
158
|
+
* Returns the state's texture coordinate type.
|
|
159
|
+
*
|
|
160
|
+
* @return [Symbol] either +:pixels+ or +:normalized+
|
|
161
|
+
*/
|
|
108
162
|
static VALUE RenderStates_get_coordinate_type(VALUE self) {
|
|
109
163
|
return ID2SYM(rb_intern(coordinate_type_name(Get_RenderState_Struct(self)->coordinateType)));
|
|
110
164
|
}
|
|
111
165
|
|
|
166
|
+
/* call-seq:
|
|
167
|
+
* coordinate_type=(value) -> Symbol
|
|
168
|
+
*
|
|
169
|
+
* +value+ is +:pixels+ or +:normalized+.
|
|
170
|
+
*
|
|
171
|
+
* @return [Symbol] +value+
|
|
172
|
+
*/
|
|
112
173
|
static VALUE RenderStates_set_coordinate_type(VALUE self, VALUE rb_type) {
|
|
113
174
|
Get_RenderState_Struct(self)->coordinateType = coordinate_type_from_rb(rb_type);
|
|
114
175
|
return rb_type;
|
|
@@ -119,10 +180,23 @@ static RenderStates* Get_RenderStates_Wrapper(VALUE self) {
|
|
|
119
180
|
return (RenderStates*)Get_RenderState_Struct(self);
|
|
120
181
|
}
|
|
121
182
|
|
|
183
|
+
/* call-seq: texture -> Texture or nil
|
|
184
|
+
*
|
|
185
|
+
* Returns the object's texture, or +nil+ if it has none.
|
|
186
|
+
*
|
|
187
|
+
* @return [Texture, nil]
|
|
188
|
+
*/
|
|
122
189
|
static VALUE RenderStates_get_texture(VALUE self) {
|
|
123
190
|
return Get_RenderStates_Wrapper(self)->rb_texture;
|
|
124
191
|
}
|
|
125
192
|
|
|
193
|
+
/* call-seq:
|
|
194
|
+
* texture=(value) -> Texture or nil
|
|
195
|
+
*
|
|
196
|
+
* Sets the object's texture.
|
|
197
|
+
*
|
|
198
|
+
* @return [Texture, nil] +value+
|
|
199
|
+
*/
|
|
126
200
|
static VALUE RenderStates_set_texture(VALUE self, VALUE rb_texture) {
|
|
127
201
|
RenderStates* states = Get_RenderStates_Wrapper(self);
|
|
128
202
|
|
|
@@ -142,10 +216,23 @@ static VALUE RenderStates_set_texture(VALUE self, VALUE rb_texture) {
|
|
|
142
216
|
return rb_texture;
|
|
143
217
|
}
|
|
144
218
|
|
|
219
|
+
/* call-seq: shader -> Shader or nil
|
|
220
|
+
*
|
|
221
|
+
* Returns the state's shader, or +nil+ if it has none.
|
|
222
|
+
*
|
|
223
|
+
* @return [Shader, nil]
|
|
224
|
+
*/
|
|
145
225
|
static VALUE RenderStates_get_shader(VALUE self) {
|
|
146
226
|
return Get_RenderStates_Wrapper(self)->rb_shader;
|
|
147
227
|
}
|
|
148
228
|
|
|
229
|
+
/* call-seq:
|
|
230
|
+
* shader=(value) -> Shader or nil
|
|
231
|
+
*
|
|
232
|
+
* Sets the state's shader.
|
|
233
|
+
*
|
|
234
|
+
* @return [Shader, nil] +value+
|
|
235
|
+
*/
|
|
149
236
|
static VALUE RenderStates_set_shader(VALUE self, VALUE rb_shader) {
|
|
150
237
|
RenderStates* states = Get_RenderStates_Wrapper(self);
|
|
151
238
|
|
|
@@ -165,10 +252,35 @@ static VALUE RenderStates_set_shader(VALUE self, VALUE rb_shader) {
|
|
|
165
252
|
return rb_shader;
|
|
166
253
|
}
|
|
167
254
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
255
|
+
/* Document-class: SFML::RenderState
|
|
256
|
+
* The set of render states (transform, blend mode, stencil mode,
|
|
257
|
+
* coordinate type, texture, shader) applied when drawing a Drawable to a
|
|
258
|
+
* render target.
|
|
259
|
+
*
|
|
260
|
+
* @!attribute transform
|
|
261
|
+
* The object's transform matrix.
|
|
262
|
+
* @return [Array] the 3x3 row-major transform matrix
|
|
263
|
+
* @!attribute blend_mode
|
|
264
|
+
* The blend mode applied to the draw.
|
|
265
|
+
* @return [BlendMode]
|
|
266
|
+
* @!attribute stencil_mode
|
|
267
|
+
* The stencil mode applied to the draw.
|
|
268
|
+
* @return [StencilMode]
|
|
269
|
+
* @!attribute coordinate_type
|
|
270
|
+
* The type of texture coordinates used.
|
|
271
|
+
* @return [Symbol] either +:pixels+ or +:normalized+
|
|
272
|
+
* @!attribute texture
|
|
273
|
+
* The object's texture, or +nil+ if it has none.
|
|
274
|
+
* @return [Texture, nil]
|
|
275
|
+
* @!attribute shader
|
|
276
|
+
* The shader applied to the draw, or +nil+ if none.
|
|
277
|
+
* @return [Shader, nil]
|
|
278
|
+
*/
|
|
279
|
+
void Init_RenderState(VALUE rb_mSFML) {
|
|
280
|
+
rb_cRenderState = rb_define_class_under(rb_mSFML, "RenderState", rb_cObject);
|
|
281
|
+
|
|
282
|
+
rb_define_alloc_func(rb_cRenderState, RenderStates_alloc);
|
|
283
|
+
rb_define_method(rb_cRenderState, "initialize", RenderStates_initialize, -1);
|
|
172
284
|
|
|
173
285
|
// setters
|
|
174
286
|
rb_define_method(rb_cRenderState, "transform=", RenderStates_set_transform, 1);
|
|
@@ -15,7 +15,9 @@
|
|
|
15
15
|
static VALUE rb_cRenderTexture;
|
|
16
16
|
|
|
17
17
|
static void RenderTexture_free(void* ptr) {
|
|
18
|
-
|
|
18
|
+
if (ptr != NULL) {
|
|
19
|
+
sfRenderTexture_destroy(ptr);
|
|
20
|
+
}
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
static const rb_data_type_t RenderTexture_data_type = {
|
|
@@ -29,39 +31,87 @@ sfRenderTexture* Get_RenderTexture_Struct(VALUE self) {
|
|
|
29
31
|
return ptr;
|
|
30
32
|
}
|
|
31
33
|
|
|
32
|
-
static VALUE
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
static VALUE RenderTexture_initialize_copy(VALUE self, VALUE other) {
|
|
35
|
+
(void)other;
|
|
36
|
+
rb_raise(rb_eTypeError, "can't copy a %s", rb_obj_classname(self));
|
|
37
|
+
}
|
|
36
38
|
|
|
37
|
-
|
|
39
|
+
static VALUE RenderTexture_alloc(VALUE klass) {
|
|
40
|
+
return TypedData_Wrap_Struct(klass, &RenderTexture_data_type, NULL);
|
|
38
41
|
}
|
|
39
42
|
|
|
40
|
-
|
|
43
|
+
/* call-seq:
|
|
44
|
+
* RenderTexture.new(size) -> RenderTexture
|
|
45
|
+
* RenderTexture.new(size, settings) -> RenderTexture
|
|
46
|
+
*
|
|
47
|
+
* +settings+ is currently accepted but ignored.
|
|
48
|
+
*
|
|
49
|
+
* @return [RenderTexture]
|
|
50
|
+
* @raise [RuntimeError] if creation fails
|
|
51
|
+
*/
|
|
52
|
+
static VALUE RenderTexture_initialize(int argc, VALUE* argv, VALUE self) {
|
|
41
53
|
VALUE rb_size, rb_settings;
|
|
54
|
+
sfRenderTexture* render_texture;
|
|
42
55
|
|
|
43
56
|
rb_scan_args(argc, argv, "11", &rb_size, &rb_settings);
|
|
44
57
|
|
|
45
58
|
(void)rb_settings;
|
|
46
59
|
|
|
47
|
-
|
|
60
|
+
render_texture = sfRenderTexture_create(vec2u_from_rb(rb_size), NULL);
|
|
61
|
+
|
|
62
|
+
if (render_texture == NULL) {
|
|
63
|
+
rb_raise(rb_eRuntimeError, "failed to create render texture");
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
DATA_PTR(self) = render_texture;
|
|
67
|
+
|
|
68
|
+
return self;
|
|
48
69
|
}
|
|
49
70
|
|
|
71
|
+
/* call-seq: size -> Vector2
|
|
72
|
+
*
|
|
73
|
+
* Returns the object's size.
|
|
74
|
+
*
|
|
75
|
+
* @return [Vector2]
|
|
76
|
+
*/
|
|
50
77
|
static VALUE RenderTexture_get_size(VALUE self) {
|
|
51
78
|
sfVector2u size = sfRenderTexture_getSize(Get_RenderTexture_Struct(self));
|
|
52
79
|
|
|
53
80
|
return vec2f_to_rb((sfVector2f){(float)size.x, (float)size.y});
|
|
54
81
|
}
|
|
55
82
|
|
|
83
|
+
/* call-seq:
|
|
84
|
+
* active=(value) -> true or false
|
|
85
|
+
*
|
|
86
|
+
* Activates or deactivates this render texture as the current OpenGL
|
|
87
|
+
* rendering target on the calling thread.
|
|
88
|
+
*
|
|
89
|
+
* @return [Boolean] whether the operation succeeded
|
|
90
|
+
*/
|
|
56
91
|
static VALUE RenderTexture_set_active(VALUE self, VALUE rb_active) {
|
|
57
92
|
return BOOL2RB(sfRenderTexture_setActive(Get_RenderTexture_Struct(self), RTEST(rb_active)));
|
|
58
93
|
}
|
|
59
94
|
|
|
95
|
+
/* call-seq: display -> self
|
|
96
|
+
*
|
|
97
|
+
* Updates the target texture with everything drawn so far. Call this after
|
|
98
|
+
* drawing and before reading #texture.
|
|
99
|
+
*
|
|
100
|
+
* @return [self]
|
|
101
|
+
*/
|
|
60
102
|
static VALUE RenderTexture_display(VALUE self) {
|
|
61
103
|
sfRenderTexture_display(Get_RenderTexture_Struct(self));
|
|
62
104
|
return self;
|
|
63
105
|
}
|
|
64
106
|
|
|
107
|
+
/* call-seq:
|
|
108
|
+
* clear -> self
|
|
109
|
+
* clear(color) -> self
|
|
110
|
+
*
|
|
111
|
+
* Clears the render texture to +color+ (a Color, default black).
|
|
112
|
+
*
|
|
113
|
+
* @return [self]
|
|
114
|
+
*/
|
|
65
115
|
static VALUE RenderTexture_clear(int argc, VALUE* argv, VALUE self) {
|
|
66
116
|
VALUE rb_color;
|
|
67
117
|
sfColor color = sfBlack;
|
|
@@ -77,6 +127,14 @@ static VALUE RenderTexture_clear(int argc, VALUE* argv, VALUE self) {
|
|
|
77
127
|
return self;
|
|
78
128
|
}
|
|
79
129
|
|
|
130
|
+
/* call-seq:
|
|
131
|
+
* view=(value) -> self
|
|
132
|
+
*
|
|
133
|
+
* Sets the target's current view.
|
|
134
|
+
*
|
|
135
|
+
* @return [self]
|
|
136
|
+
* @raise [TypeError] if +value+ is not a View
|
|
137
|
+
*/
|
|
80
138
|
static VALUE RenderTexture_set_view(VALUE self, VALUE rb_view) {
|
|
81
139
|
if (!rb_obj_is_kind_of(rb_view, Get_Klass_View())) {
|
|
82
140
|
raise_invalid_argument_class(Get_Klass_View());
|
|
@@ -87,41 +145,102 @@ static VALUE RenderTexture_set_view(VALUE self, VALUE rb_view) {
|
|
|
87
145
|
return self;
|
|
88
146
|
}
|
|
89
147
|
|
|
148
|
+
/* call-seq: view -> View
|
|
149
|
+
*
|
|
150
|
+
* Returns the target's current view.
|
|
151
|
+
*
|
|
152
|
+
* @return [View] a copy of the current view
|
|
153
|
+
*/
|
|
90
154
|
static VALUE RenderTexture_get_view(VALUE self) {
|
|
91
155
|
return Get_Casting_View(sfView_copy(sfRenderTexture_getView(Get_RenderTexture_Struct(self))));
|
|
92
156
|
}
|
|
93
157
|
|
|
158
|
+
/* call-seq: default_view -> View
|
|
159
|
+
*
|
|
160
|
+
* Returns the view covering the whole render target.
|
|
161
|
+
*
|
|
162
|
+
* @return [View] a copy of the view covering the render texture's full area
|
|
163
|
+
*/
|
|
94
164
|
static VALUE RenderTexture_get_default_view(VALUE self) {
|
|
95
165
|
return Get_Casting_View(
|
|
96
166
|
sfView_copy(sfRenderTexture_getDefaultView(Get_RenderTexture_Struct(self))));
|
|
97
167
|
}
|
|
98
168
|
|
|
169
|
+
/* call-seq: texture -> Texture
|
|
170
|
+
*
|
|
171
|
+
* Returns the target texture, whose contents update after each #display.
|
|
172
|
+
*
|
|
173
|
+
* @return [Texture] the target texture, borrowed -- its contents update
|
|
174
|
+
* after each #display
|
|
175
|
+
*/
|
|
99
176
|
static VALUE RenderTexture_get_texture(VALUE self) {
|
|
100
177
|
return texture_from_borrowed(sfRenderTexture_getTexture(Get_RenderTexture_Struct(self)));
|
|
101
178
|
}
|
|
102
179
|
|
|
180
|
+
/* call-seq:
|
|
181
|
+
* smooth=(value) -> true or false
|
|
182
|
+
*
|
|
183
|
+
* Enables or disables smooth rendering.
|
|
184
|
+
*
|
|
185
|
+
* @return [Boolean] +value+
|
|
186
|
+
*/
|
|
103
187
|
static VALUE RenderTexture_set_smooth(VALUE self, VALUE rb_smooth) {
|
|
104
188
|
sfRenderTexture_setSmooth(Get_RenderTexture_Struct(self), RTEST(rb_smooth));
|
|
105
189
|
return rb_smooth;
|
|
106
190
|
}
|
|
107
191
|
|
|
192
|
+
/* call-seq: smooth? -> true or false
|
|
193
|
+
*
|
|
194
|
+
* Returns +true+ if smooth rendering is enabled.
|
|
195
|
+
*
|
|
196
|
+
* @return [Boolean]
|
|
197
|
+
*/
|
|
108
198
|
static VALUE RenderTexture_is_smooth(VALUE self) {
|
|
109
199
|
return BOOL2RB(sfRenderTexture_isSmooth(Get_RenderTexture_Struct(self)));
|
|
110
200
|
}
|
|
111
201
|
|
|
202
|
+
/* call-seq:
|
|
203
|
+
* repeated=(value) -> true or false
|
|
204
|
+
*
|
|
205
|
+
* Enables or disables texture repeating.
|
|
206
|
+
*
|
|
207
|
+
* @return [Boolean] +value+
|
|
208
|
+
*/
|
|
112
209
|
static VALUE RenderTexture_set_repeated(VALUE self, VALUE rb_repeated) {
|
|
113
210
|
sfRenderTexture_setRepeated(Get_RenderTexture_Struct(self), RTEST(rb_repeated));
|
|
114
211
|
return rb_repeated;
|
|
115
212
|
}
|
|
116
213
|
|
|
214
|
+
/* call-seq: repeated? -> true or false
|
|
215
|
+
*
|
|
216
|
+
* Returns +true+ if texture repeating is enabled.
|
|
217
|
+
*
|
|
218
|
+
* @return [Boolean]
|
|
219
|
+
*/
|
|
117
220
|
static VALUE RenderTexture_is_repeated(VALUE self) {
|
|
118
221
|
return BOOL2RB(sfRenderTexture_isRepeated(Get_RenderTexture_Struct(self)));
|
|
119
222
|
}
|
|
120
223
|
|
|
224
|
+
/* call-seq: generate_mipmap -> true or false
|
|
225
|
+
*
|
|
226
|
+
* Generates the mipmap pyramid for the texture.
|
|
227
|
+
*
|
|
228
|
+
* @return [Boolean] whether mipmap generation succeeded
|
|
229
|
+
*/
|
|
121
230
|
static VALUE RenderTexture_generate_mipmap(VALUE self) {
|
|
122
231
|
return BOOL2RB(sfRenderTexture_generateMipmap(Get_RenderTexture_Struct(self)));
|
|
123
232
|
}
|
|
124
233
|
|
|
234
|
+
/* call-seq:
|
|
235
|
+
* draw(drawable) -> self
|
|
236
|
+
* draw(drawable, state) -> self
|
|
237
|
+
*
|
|
238
|
+
* Draws +drawable+ (anything responding to +#draw+, i.e. including
|
|
239
|
+
* Drawable) using +state+ (a RenderState, default the identity state).
|
|
240
|
+
*
|
|
241
|
+
* @return [self]
|
|
242
|
+
* @raise [ArgumentError] if given no arguments or more than 2
|
|
243
|
+
*/
|
|
125
244
|
static VALUE RenderTexture_draw(int argc, VALUE* argv, VALUE self) {
|
|
126
245
|
VALUE rb_drawable, rb_state;
|
|
127
246
|
|
|
@@ -132,12 +251,18 @@ static VALUE RenderTexture_draw(int argc, VALUE* argv, VALUE self) {
|
|
|
132
251
|
rb_drawable = argv[0];
|
|
133
252
|
rb_state = (argc == 2) ? argv[1] : Get_New_RenderState();
|
|
134
253
|
|
|
135
|
-
rb_funcall(
|
|
136
|
-
rb_state);
|
|
254
|
+
rb_funcall(rb_drawable, rb_intern("draw"), 2, self, rb_state);
|
|
137
255
|
|
|
138
256
|
return self;
|
|
139
257
|
}
|
|
140
258
|
|
|
259
|
+
/* call-seq:
|
|
260
|
+
* RenderTexture.maximum_antialiasing_level -> Integer
|
|
261
|
+
*
|
|
262
|
+
* Returns the maximum supported antialiasing level.
|
|
263
|
+
*
|
|
264
|
+
* @return [Integer]
|
|
265
|
+
*/
|
|
141
266
|
static VALUE RenderTexture_maximum_antialiasing_level(VALUE klass) {
|
|
142
267
|
return UINT2NUM(sfRenderTexture_getMaximumAntiAliasingLevel());
|
|
143
268
|
}
|
|
@@ -150,10 +275,62 @@ static VALUE RenderTexture_maximum_antialiasing_level(VALUE klass) {
|
|
|
150
275
|
#undef RT_METHOD
|
|
151
276
|
#undef RT_HANDLE
|
|
152
277
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
278
|
+
/* Document-class: SFML::RenderTexture
|
|
279
|
+
* An off-screen render target backed by a Texture: anything drawable can be
|
|
280
|
+
* drawn onto it, then read back via #texture (after #display).
|
|
281
|
+
*
|
|
282
|
+
* The methods below are shared with Window via the render_target.inc
|
|
283
|
+
* fragment (see ext/graphics/render_target.inc) and documented here
|
|
284
|
+
* directly since the fragment hides their function bodies from the
|
|
285
|
+
* doc-comment scanner. Window's own docs restate the same list.
|
|
286
|
+
*
|
|
287
|
+
* @!method srgb?
|
|
288
|
+
* Returns +true+ if the render texture uses an sRGB format.
|
|
289
|
+
* @return [Boolean]
|
|
290
|
+
* @!method clear_stencil(value)
|
|
291
|
+
* Clears the stencil buffer with the given value.
|
|
292
|
+
* @return [self]
|
|
293
|
+
* @!method clear_color_and_stencil(color, stencil)
|
|
294
|
+
* Clears the color and stencil buffers in one pass.
|
|
295
|
+
* @return [self]
|
|
296
|
+
* @!method viewport(view = nil)
|
|
297
|
+
* Returns the current viewport in pixels; +view+ defaults to the target's current view.
|
|
298
|
+
* @return [Rect] the current viewport in pixels; +view+ defaults to the target's current view
|
|
299
|
+
* @!method scissor(view = nil)
|
|
300
|
+
* Returns the current scissor rectangle in pixels; +view+ defaults to the target's current view.
|
|
301
|
+
* @return [Rect] the current scissor rectangle in pixels; +view+ defaults to the target's current
|
|
302
|
+
* view
|
|
303
|
+
* @!method map_pixel_to_coords(point, view = nil)
|
|
304
|
+
* Converts a pixel position to world coordinates, using the inverse of the view transform.
|
|
305
|
+
* @return [Vector2]
|
|
306
|
+
* @!method map_coords_to_pixel(point, view = nil)
|
|
307
|
+
* Converts a world position to pixel coordinates.
|
|
308
|
+
* @return [Vector2]
|
|
309
|
+
* @!method push_gl_states
|
|
310
|
+
* Saves the current OpenGL states before custom drawing.
|
|
311
|
+
* @return [self]
|
|
312
|
+
* @!method pop_gl_states
|
|
313
|
+
* Restores the OpenGL states saved by #push_gl_states.
|
|
314
|
+
* @return [self]
|
|
315
|
+
* @!method reset_gl_states
|
|
316
|
+
* Resets the OpenGL states to those SFML expects.
|
|
317
|
+
* @return [self]
|
|
318
|
+
* @!method draw_primitives(vertices, primitive, state = nil)
|
|
319
|
+
* Draws raw vertex primitives using the given primitive type and render state.
|
|
320
|
+
* @return [self]
|
|
321
|
+
* @!method draw_vertex_buffer_range(buffer, first, count, state = nil)
|
|
322
|
+
* Draws a range of vertices from a VertexBuffer.
|
|
323
|
+
* @return [self]
|
|
324
|
+
*/
|
|
325
|
+
void Init_RenderTexture(VALUE rb_mSFML) {
|
|
326
|
+
rb_cRenderTexture = rb_define_class_under(rb_mSFML, "RenderTexture", rb_cObject);
|
|
327
|
+
|
|
328
|
+
rb_include_module(rb_cRenderTexture, Get_Module_RenderTarget());
|
|
329
|
+
|
|
330
|
+
rb_define_alloc_func(rb_cRenderTexture, RenderTexture_alloc);
|
|
331
|
+
rb_define_method(rb_cRenderTexture, "initialize", RenderTexture_initialize, -1);
|
|
332
|
+
rb_define_private_method(rb_cRenderTexture, "initialize_copy", RenderTexture_initialize_copy,
|
|
333
|
+
1);
|
|
157
334
|
rb_define_singleton_method(rb_cRenderTexture, "maximum_antialiasing_level",
|
|
158
335
|
RenderTexture_maximum_antialiasing_level, 0);
|
|
159
336
|
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
#include "graphics/render_window.h"
|
|
2
|
+
|
|
3
|
+
#include <ruby.h>
|
|
4
|
+
|
|
5
|
+
#include "graphics/render_state.h"
|
|
6
|
+
#include "graphics/target.h"
|
|
7
|
+
#include "window/window.h"
|
|
8
|
+
#include "window/window_base.h"
|
|
9
|
+
#include "core/exceptions.h"
|
|
10
|
+
#include "core/macros.h"
|
|
11
|
+
|
|
12
|
+
static VALUE rb_cRenderWindow;
|
|
13
|
+
|
|
14
|
+
/* call-seq:
|
|
15
|
+
* draw(drawable, state = nil) -> self
|
|
16
|
+
*
|
|
17
|
+
* Draws +drawable+ into the window. Unlike Window#draw this hands +self+ to the
|
|
18
|
+
* drawable, because a RenderWindow is a RenderTarget.
|
|
19
|
+
*
|
|
20
|
+
* @return [self]
|
|
21
|
+
* @raise [ArgumentError] if given no arguments or more than 2
|
|
22
|
+
*/
|
|
23
|
+
static VALUE RenderWindow_draw(int argc, VALUE* argv, VALUE self) {
|
|
24
|
+
VALUE rb_drawable, rb_state;
|
|
25
|
+
|
|
26
|
+
if (argc == 0 || argc > 2) {
|
|
27
|
+
raise_invalid_arguments_excepted(-1, argc);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
rb_drawable = argv[0];
|
|
31
|
+
rb_state = (argc == 2) ? argv[1] : Get_New_RenderState();
|
|
32
|
+
|
|
33
|
+
rb_funcall(rb_drawable, rb_intern("draw"), 2, self, rb_state);
|
|
34
|
+
|
|
35
|
+
return self;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/* Document-class: SFML::RenderWindow
|
|
39
|
+
* A SFML::Window that is also a SFML::RenderTarget, so it can be handed
|
|
40
|
+
* directly to a drawable's #draw as well as drawn into with #draw. Creation,
|
|
41
|
+
* events and every window method come from Window (and WindowBase); the
|
|
42
|
+
* render-target surface is listed on SFML::RenderTarget.
|
|
43
|
+
*/
|
|
44
|
+
void Init_RenderWindow(VALUE rb_mSFML) {
|
|
45
|
+
rb_cRenderWindow = rb_define_class_under(rb_mSFML, "RenderWindow", Get_Klass_Window());
|
|
46
|
+
|
|
47
|
+
rb_define_alloc_func(rb_cRenderWindow, Window_alloc);
|
|
48
|
+
rb_define_method(rb_cRenderWindow, "draw", RenderWindow_draw, -1);
|
|
49
|
+
|
|
50
|
+
rb_include_module(rb_cRenderWindow, Get_Module_RenderTarget());
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
VALUE Get_Klass_RenderWindow(void) {
|
|
54
|
+
return rb_cRenderWindow;
|
|
55
|
+
}
|