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.
Files changed (137) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +9 -0
  3. data/CHANGELOG.md +43 -17
  4. data/README.md +97 -29
  5. data/ext/audio/audio_enums.c +58 -20
  6. data/ext/audio/listener.c +89 -6
  7. data/ext/audio/music.c +206 -5
  8. data/ext/audio/sound.c +175 -5
  9. data/ext/audio/sound_buffer.c +189 -47
  10. data/ext/audio/sound_buffer_recorder.c +83 -16
  11. data/ext/audio/sound_recorder.c +172 -52
  12. data/ext/audio/sound_source_cone.c +108 -29
  13. data/ext/audio/sound_stream.c +178 -5
  14. data/ext/core/exceptions.c +10 -8
  15. data/ext/core/unicode.c +12 -2
  16. data/ext/ext.c +4 -0
  17. data/ext/graphics/blend_mode.c +203 -53
  18. data/ext/graphics/circle.c +271 -4
  19. data/ext/graphics/color.c +240 -90
  20. data/ext/graphics/drawable.c +15 -4
  21. data/ext/graphics/font.c +138 -25
  22. data/ext/graphics/glyph.c +31 -8
  23. data/ext/graphics/image.c +180 -37
  24. data/ext/graphics/polygon.c +293 -26
  25. data/ext/graphics/rect.c +211 -54
  26. data/ext/graphics/rectangle.c +279 -26
  27. data/ext/graphics/render_state.c +116 -2
  28. data/ext/graphics/render_texture.c +163 -2
  29. data/ext/graphics/shader.c +283 -17
  30. data/ext/graphics/shape.c +252 -26
  31. data/ext/graphics/sprite.c +216 -25
  32. data/ext/graphics/stencil_mode.c +148 -39
  33. data/ext/graphics/target.c +67 -22
  34. data/ext/graphics/target.h +15 -15
  35. data/ext/graphics/text.c +306 -6
  36. data/ext/graphics/texture.c +257 -3
  37. data/ext/graphics/transform.c +178 -5
  38. data/ext/graphics/transformable.c +126 -2
  39. data/ext/graphics/vertex.c +79 -2
  40. data/ext/graphics/vertex_array.c +128 -16
  41. data/ext/graphics/vertex_buffer.c +124 -2
  42. data/ext/graphics/view.c +130 -2
  43. data/ext/network/ftp.c +249 -10
  44. data/ext/network/http.c +156 -38
  45. data/ext/network/ip_address.c +107 -26
  46. data/ext/network/network_enums.c +248 -141
  47. data/ext/network/packet.c +273 -39
  48. data/ext/network/socket_selector.c +91 -19
  49. data/ext/network/tcp_listener.c +75 -16
  50. data/ext/network/tcp_socket.c +128 -25
  51. data/ext/network/udp_socket.c +122 -26
  52. data/ext/ports.rb +7 -0
  53. data/ext/system/buffer.c +41 -12
  54. data/ext/system/clock.c +68 -9
  55. data/ext/system/input_stream.c +94 -42
  56. data/ext/system/sleep.c +10 -2
  57. data/ext/system/time.c +172 -34
  58. data/ext/system/vec2.c +156 -35
  59. data/ext/system/vec3.c +166 -35
  60. data/ext/window/clipboard.c +47 -17
  61. data/ext/window/context.c +59 -9
  62. data/ext/window/context_settings.c +116 -38
  63. data/ext/window/cursor.c +39 -9
  64. data/ext/window/event.c +163 -42
  65. data/ext/window/joystick.c +69 -3
  66. data/ext/window/keyboard.c +168 -116
  67. data/ext/window/mouse.c +36 -2
  68. data/ext/window/sensor.c +28 -2
  69. data/ext/window/touch.c +20 -2
  70. data/ext/window/video_mode.c +90 -19
  71. data/ext/window/vulkan.c +34 -6
  72. data/ext/window/window.c +340 -16
  73. data/lib/sfml/version.rb +1 -1
  74. data/sig/audio/audio_enums.rbs +30 -0
  75. data/sig/audio/listener.rbs +16 -0
  76. data/sig/audio/music.rbs +56 -0
  77. data/sig/audio/sound.rbs +51 -0
  78. data/sig/audio/sound_buffer.rbs +17 -0
  79. data/sig/audio/sound_buffer_recorder.rbs +14 -0
  80. data/sig/audio/sound_recorder.rbs +17 -0
  81. data/sig/audio/sound_source_cone.rbs +14 -0
  82. data/sig/audio/sound_stream.rbs +51 -0
  83. data/sig/graphics/blend_mode.rbs +29 -0
  84. data/sig/graphics/circle.rbs +44 -0
  85. data/sig/graphics/color.rbs +39 -0
  86. data/sig/graphics/drawable.rbs +5 -0
  87. data/sig/graphics/font.rbs +20 -0
  88. data/sig/graphics/glyph.rbs +7 -0
  89. data/sig/graphics/image.rbs +22 -0
  90. data/sig/graphics/polygon.rbs +42 -0
  91. data/sig/graphics/rect.rbs +33 -0
  92. data/sig/graphics/rectangle.rbs +42 -0
  93. data/sig/graphics/render_state.rbs +21 -0
  94. data/sig/graphics/render_texture.rbs +37 -0
  95. data/sig/graphics/shader.rbs +39 -0
  96. data/sig/graphics/shape.rbs +38 -0
  97. data/sig/graphics/sprite.rbs +34 -0
  98. data/sig/graphics/stencil_mode.rbs +18 -0
  99. data/sig/graphics/target.rbs +10 -0
  100. data/sig/graphics/text.rbs +48 -0
  101. data/sig/graphics/texture.rbs +34 -0
  102. data/sig/graphics/transform.rbs +37 -0
  103. data/sig/graphics/transformable.rbs +25 -0
  104. data/sig/graphics/vertex.rbs +17 -0
  105. data/sig/graphics/vertex_array.rbs +17 -0
  106. data/sig/graphics/vertex_buffer.rbs +22 -0
  107. data/sig/graphics/view.rbs +24 -0
  108. data/sig/network/ftp.rbs +46 -0
  109. data/sig/network/http.rbs +27 -0
  110. data/sig/network/ip_address.rbs +22 -0
  111. data/sig/network/network_enums.rbs +95 -0
  112. data/sig/network/packet.rbs +40 -0
  113. data/sig/network/socket_selector.rbs +14 -0
  114. data/sig/network/tcp_listener.rbs +13 -0
  115. data/sig/network/tcp_socket.rbs +18 -0
  116. data/sig/network/udp_socket.rbs +17 -0
  117. data/sig/system/buffer.rbs +11 -0
  118. data/sig/system/clock.rbs +13 -0
  119. data/sig/system/input_stream.rbs +7 -0
  120. data/sig/system/sleep.rbs +3 -0
  121. data/sig/system/time.rbs +28 -0
  122. data/sig/system/vec2.rbs +26 -0
  123. data/sig/system/vec3.rbs +27 -0
  124. data/sig/window/clipboard.rbs +8 -0
  125. data/sig/window/context.rbs +11 -0
  126. data/sig/window/context_settings.rbs +20 -0
  127. data/sig/window/cursor.rbs +6 -0
  128. data/sig/window/event.rbs +20 -0
  129. data/sig/window/joystick.rbs +15 -0
  130. data/sig/window/keyboard.rbs +10 -0
  131. data/sig/window/mouse.rbs +9 -0
  132. data/sig/window/sensor.rbs +8 -0
  133. data/sig/window/touch.rbs +6 -0
  134. data/sig/window/video_mode.rbs +16 -0
  135. data/sig/window/vulkan.rbs +7 -0
  136. data/sig/window/window.rbs +57 -0
  137. 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
- void Init_RenderTexture(VALUE rb_module) {
154
- rb_cRenderTexture = rb_define_class_under(rb_module, "RenderTexture", rb_cObject);
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",