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
@@ -1,6 +1,7 @@
1
1
  #include "graphics/texture.h"
2
2
 
3
3
  #include <ruby.h>
4
+ #include <stdint.h>
4
5
  #include <stdlib.h>
5
6
  #include <string.h>
6
7
 
@@ -75,14 +76,40 @@ static const sfIntRect* Texture_area_ptr(VALUE rb_area, sfIntRect* storage) {
75
76
  return storage;
76
77
  }
77
78
 
79
+ /* call-seq:
80
+ * Texture.new(size) -> Texture
81
+ *
82
+ * Creates an empty texture with the given +width+ and +height+.
83
+ *
84
+ * @return [Texture] an empty texture of +size+ (a Vector2 or 2-element Array)
85
+ * @raise [RuntimeError] if creation fails
86
+ */
78
87
  static VALUE Texture_new(VALUE klass, VALUE rb_size) {
79
88
  return Texture_wrap(klass, sfTexture_create(vec2u_from_rb(rb_size)));
80
89
  }
81
90
 
91
+ /* call-seq:
92
+ * Texture.srgb(size) -> Texture
93
+ *
94
+ * Creates an empty texture with an sRGB format.
95
+ *
96
+ * @return [Texture] an empty sRGB-encoded texture of +size+
97
+ * @raise [RuntimeError] if creation fails
98
+ */
82
99
  static VALUE Texture_srgb(VALUE klass, VALUE rb_size) {
83
100
  return Texture_wrap(klass, sfTexture_createSrgb(vec2u_from_rb(rb_size)));
84
101
  }
85
102
 
103
+ /* call-seq:
104
+ * Texture.from_file(path) -> Texture
105
+ * Texture.from_file(path, area) -> Texture
106
+ *
107
+ * Loads a texture from the image file at +filename+.
108
+ *
109
+ * @return [Texture] loaded from the file at +path+, cropped to +area+ (a
110
+ * Rect) if given
111
+ * @raise [RuntimeError] if loading fails
112
+ */
86
113
  static VALUE Texture_from_file(int argc, VALUE* argv, VALUE klass) {
87
114
  VALUE rb_path, rb_area;
88
115
  sfIntRect area;
@@ -93,6 +120,16 @@ static VALUE Texture_from_file(int argc, VALUE* argv, VALUE klass) {
93
120
  Texture_area_ptr(rb_area, &area)));
94
121
  }
95
122
 
123
+ /* call-seq:
124
+ * Texture.srgb_from_file(path) -> Texture
125
+ * Texture.srgb_from_file(path, area) -> Texture
126
+ *
127
+ * Loads an sRGB texture from the image file at +filename+.
128
+ *
129
+ * @return [Texture] sRGB-encoded, loaded from the file at +path+, cropped
130
+ * to +area+ (a Rect) if given
131
+ * @raise [RuntimeError] if loading fails
132
+ */
96
133
  static VALUE Texture_srgb_from_file(int argc, VALUE* argv, VALUE klass) {
97
134
  VALUE rb_path, rb_area;
98
135
  sfIntRect area;
@@ -103,6 +140,16 @@ static VALUE Texture_srgb_from_file(int argc, VALUE* argv, VALUE klass) {
103
140
  Texture_area_ptr(rb_area, &area)));
104
141
  }
105
142
 
143
+ /* call-seq:
144
+ * Texture.from_memory(data) -> Texture
145
+ * Texture.from_memory(data, area) -> Texture
146
+ *
147
+ * Loads a texture from an in-memory image buffer.
148
+ *
149
+ * @return [Texture] decoded from the encoded image bytes in +data+ (a
150
+ * String), cropped to +area+ (a Rect) if given
151
+ * @raise [RuntimeError] if decoding fails
152
+ */
106
153
  static VALUE Texture_from_memory(int argc, VALUE* argv, VALUE klass) {
107
154
  VALUE rb_data, rb_area;
108
155
  sfIntRect area;
@@ -115,6 +162,16 @@ static VALUE Texture_from_memory(int argc, VALUE* argv, VALUE klass) {
115
162
  Texture_area_ptr(rb_area, &area)));
116
163
  }
117
164
 
165
+ /* call-seq:
166
+ * Texture.srgb_from_memory(data) -> Texture
167
+ * Texture.srgb_from_memory(data, area) -> Texture
168
+ *
169
+ * Loads an sRGB texture from an in-memory image buffer.
170
+ *
171
+ * @return [Texture] sRGB-encoded, decoded from the encoded image bytes in
172
+ * +data+ (a String), cropped to +area+ (a Rect) if given
173
+ * @raise [RuntimeError] if decoding fails
174
+ */
118
175
  static VALUE Texture_srgb_from_memory(int argc, VALUE* argv, VALUE klass) {
119
176
  VALUE rb_data, rb_area;
120
177
  sfIntRect area;
@@ -127,6 +184,16 @@ static VALUE Texture_srgb_from_memory(int argc, VALUE* argv, VALUE klass) {
127
184
  Texture_area_ptr(rb_area, &area)));
128
185
  }
129
186
 
187
+ /* call-seq:
188
+ * Texture.from_stream(stream) -> Texture
189
+ * Texture.from_stream(stream, area) -> Texture
190
+ *
191
+ * Loads a texture from the image data read from +stream+.
192
+ *
193
+ * @return [Texture] decoded from +stream+ (an InputStream), cropped to
194
+ * +area+ (a Rect) if given
195
+ * @raise [RuntimeError] if decoding fails
196
+ */
130
197
  static VALUE Texture_from_stream(int argc, VALUE* argv, VALUE klass) {
131
198
  VALUE rb_stream, rb_area, holder = Qnil;
132
199
  sfIntRect area;
@@ -146,6 +213,16 @@ static VALUE Texture_from_stream(int argc, VALUE* argv, VALUE klass) {
146
213
  sfTexture_createFromStream(stream, Texture_area_ptr(rb_area, &area)));
147
214
  }
148
215
 
216
+ /* call-seq:
217
+ * Texture.srgb_from_stream(stream) -> Texture
218
+ * Texture.srgb_from_stream(stream, area) -> Texture
219
+ *
220
+ * Loads an sRGB texture from the image data read from +stream+.
221
+ *
222
+ * @return [Texture] sRGB-encoded, decoded from +stream+ (an InputStream),
223
+ * cropped to +area+ (a Rect) if given
224
+ * @raise [RuntimeError] if decoding fails
225
+ */
149
226
  static VALUE Texture_srgb_from_stream(int argc, VALUE* argv, VALUE klass) {
150
227
  VALUE rb_stream, rb_area, holder = Qnil;
151
228
  sfIntRect area;
@@ -165,6 +242,17 @@ static VALUE Texture_srgb_from_stream(int argc, VALUE* argv, VALUE klass) {
165
242
  sfTexture_createSrgbFromStream(stream, Texture_area_ptr(rb_area, &area)));
166
243
  }
167
244
 
245
+ /* call-seq:
246
+ * Texture.from_image(image) -> Texture
247
+ * Texture.from_image(image, area) -> Texture
248
+ *
249
+ * Creates a texture from the pixels of an existing Image.
250
+ *
251
+ * @return [Texture] built from +image+ (an Image), cropped to +area+ (a
252
+ * Rect) if given
253
+ * @raise [TypeError] if +image+ is not an Image
254
+ * @raise [RuntimeError] if creation fails
255
+ */
168
256
  static VALUE Texture_from_image(int argc, VALUE* argv, VALUE klass) {
169
257
  VALUE rb_image, rb_area;
170
258
  sfIntRect area;
@@ -179,6 +267,17 @@ static VALUE Texture_from_image(int argc, VALUE* argv, VALUE klass) {
179
267
  Texture_area_ptr(rb_area, &area)));
180
268
  }
181
269
 
270
+ /* call-seq:
271
+ * Texture.srgb_from_image(image) -> Texture
272
+ * Texture.srgb_from_image(image, area) -> Texture
273
+ *
274
+ * Creates an sRGB texture from the pixels of an existing Image.
275
+ *
276
+ * @return [Texture] sRGB-encoded, built from +image+ (an Image), cropped to
277
+ * +area+ (a Rect) if given
278
+ * @raise [TypeError] if +image+ is not an Image
279
+ * @raise [RuntimeError] if creation fails
280
+ */
182
281
  static VALUE Texture_srgb_from_image(int argc, VALUE* argv, VALUE klass) {
183
282
  VALUE rb_image, rb_area;
184
283
  sfIntRect area;
@@ -193,20 +292,47 @@ static VALUE Texture_srgb_from_image(int argc, VALUE* argv, VALUE klass) {
193
292
  Texture_area_ptr(rb_area, &area)));
194
293
  }
195
294
 
295
+ /* call-seq: copy -> Texture
296
+ *
297
+ * Returns a deep copy of the object.
298
+ *
299
+ * @return [Texture] an independent copy
300
+ */
196
301
  static VALUE Texture_copy(VALUE self) {
197
302
  return Texture_wrap(Get_Klass_Texture(), sfTexture_copy(Get_Texture_Struct(self)));
198
303
  }
199
304
 
305
+ /* call-seq: size -> Vector2
306
+ *
307
+ * Returns the object's size.
308
+ *
309
+ * @return [Vector2]
310
+ */
200
311
  static VALUE Texture_get_size(VALUE self) {
201
312
  sfVector2u size = sfTexture_getSize(Get_Texture_Struct(self));
202
313
 
203
314
  return vec2f_to_rb((sfVector2f){(float)size.x, (float)size.y});
204
315
  }
205
316
 
317
+ /* call-seq:
318
+ * resize(size) -> true or false
319
+ *
320
+ * Resizes the texture in place. Existing pixel data is lost.
321
+ *
322
+ * @return [Boolean] whether resizing succeeded
323
+ */
206
324
  static VALUE Texture_resize(VALUE self, VALUE rb_size) {
207
325
  return BOOL2RB(sfTexture_resize((sfTexture*)Get_Texture_Struct(self), vec2u_from_rb(rb_size)));
208
326
  }
209
327
 
328
+ /* call-seq:
329
+ * resize_srgb(size) -> true or false
330
+ *
331
+ * Resizes the texture in place as sRGB-encoded. Existing pixel data is
332
+ * lost.
333
+ *
334
+ * @return [Boolean] whether resizing succeeded
335
+ */
210
336
  static VALUE Texture_resize_srgb(VALUE self, VALUE rb_size) {
211
337
  return BOOL2RB(
212
338
  sfTexture_resizeSrgb((sfTexture*)Get_Texture_Struct(self), vec2u_from_rb(rb_size)));
@@ -214,6 +340,14 @@ static VALUE Texture_resize_srgb(VALUE self, VALUE rb_size) {
214
340
 
215
341
  /* Exchanges the two textures' contents in place, so anything already holding
216
342
  either object sees the swap. */
343
+ /* call-seq:
344
+ * swap(other) -> self
345
+ *
346
+ * Swaps the contents with +other+.
347
+ *
348
+ * @return [self]
349
+ * @raise [TypeError] if +other+ is not a Texture
350
+ */
217
351
  static VALUE Texture_swap(VALUE self, VALUE rb_other) {
218
352
  if (!rb_obj_is_kind_of(rb_other, Get_Klass_Texture())) {
219
353
  raise_invalid_argument_class(Get_Klass_Texture());
@@ -224,6 +358,13 @@ static VALUE Texture_swap(VALUE self, VALUE rb_other) {
224
358
  return self;
225
359
  }
226
360
 
361
+ /* call-seq: copy_to_image -> Image
362
+ *
363
+ * Copies the texture's pixels into +image+.
364
+ *
365
+ * @return [Image] the texture's pixels, read back from the GPU
366
+ * @raise [RuntimeError] if the copy fails
367
+ */
227
368
  static VALUE Texture_copy_to_image(VALUE self) {
228
369
  sfImage* image = sfTexture_copyToImage(Get_Texture_Struct(self));
229
370
 
@@ -234,14 +375,34 @@ static VALUE Texture_copy_to_image(VALUE self) {
234
375
  return image_from_c(image);
235
376
  }
236
377
 
378
+ /* call-seq:
379
+ * update_from_pixels(pixels, size, offset) -> self
380
+ *
381
+ * Overwrites a +size+ region of the texture at +offset+ with +pixels+ (a
382
+ * String of raw RGBA8 bytes, +size.x * size.y * 4+ long).
383
+ *
384
+ * @return [self]
385
+ * @raise [ArgumentError] if +pixels+ is shorter than required
386
+ */
237
387
  static VALUE Texture_update_from_pixels(VALUE self, VALUE rb_pixels, VALUE rb_size,
238
388
  VALUE rb_offset) {
239
389
  sfVector2u size = vec2u_from_rb(rb_size);
240
390
  sfVector2u offset = vec2u_from_rb(rb_offset);
391
+ size_t expected;
392
+
393
+ /* size.x * size.y * 4 as a bare size_t multiplication can wrap on the
394
+ 32-bit targets this gem ships; check before multiplying rather than
395
+ after so a wrapped-to-near-zero "expected" can't slip a too-short
396
+ buffer past the length check below (see the identical fix in
397
+ graphics/image.c). */
398
+ if (size.x != 0 && size.y > (SIZE_MAX / 4) / size.x) {
399
+ rb_raise(rb_eArgError, "texture dimensions too large");
400
+ }
401
+ expected = (size_t)size.x * size.y * 4;
241
402
 
242
403
  StringValue(rb_pixels);
243
404
 
244
- if ((size_t)RSTRING_LEN(rb_pixels) < (size_t)size.x * size.y * 4) {
405
+ if ((size_t)RSTRING_LEN(rb_pixels) < expected) {
245
406
  rb_raise(rb_eArgError, "pixel data too short");
246
407
  }
247
408
 
@@ -251,6 +412,14 @@ static VALUE Texture_update_from_pixels(VALUE self, VALUE rb_pixels, VALUE rb_si
251
412
  return self;
252
413
  }
253
414
 
415
+ /* call-seq:
416
+ * update_from_image(image, offset) -> self
417
+ *
418
+ * Updates the texture from the pixels of +image+.
419
+ *
420
+ * @return [self]
421
+ * @raise [TypeError] if +image+ is not an Image
422
+ */
254
423
  static VALUE Texture_update_from_image(VALUE self, VALUE rb_image, VALUE rb_offset) {
255
424
  if (!rb_obj_is_kind_of(rb_image, Get_Klass_Image())) {
256
425
  raise_invalid_argument_class(Get_Klass_Image());
@@ -262,6 +431,14 @@ static VALUE Texture_update_from_image(VALUE self, VALUE rb_image, VALUE rb_offs
262
431
  return self;
263
432
  }
264
433
 
434
+ /* call-seq:
435
+ * update_from_texture(source, offset) -> self
436
+ *
437
+ * Updates the texture from the pixels of another texture.
438
+ *
439
+ * @return [self]
440
+ * @raise [TypeError] if +source+ is not a Texture
441
+ */
265
442
  static VALUE Texture_update_from_texture(VALUE self, VALUE rb_source, VALUE rb_offset) {
266
443
  if (!rb_obj_is_kind_of(rb_source, rb_cTexture)) {
267
444
  raise_invalid_argument_class(rb_cTexture);
@@ -273,6 +450,14 @@ static VALUE Texture_update_from_texture(VALUE self, VALUE rb_source, VALUE rb_o
273
450
  return self;
274
451
  }
275
452
 
453
+ /* call-seq:
454
+ * update_from_window(window, offset) -> self
455
+ *
456
+ * Updates the texture from the contents of a window.
457
+ *
458
+ * @return [self]
459
+ * @raise [TypeError] if +window+ is not a Window
460
+ */
276
461
  static VALUE Texture_update_from_window(VALUE self, VALUE rb_window, VALUE rb_offset) {
277
462
  if (!rb_obj_is_kind_of(rb_window, Get_Klass_Window())) {
278
463
  raise_invalid_argument_class(Get_Klass_Window());
@@ -284,36 +469,90 @@ static VALUE Texture_update_from_window(VALUE self, VALUE rb_window, VALUE rb_of
284
469
  return self;
285
470
  }
286
471
 
472
+ /* call-seq:
473
+ * smooth=(value) -> true or false
474
+ *
475
+ * Enables or disables smooth rendering.
476
+ *
477
+ * @return [Boolean] +value+
478
+ */
287
479
  static VALUE Texture_set_smooth(VALUE self, VALUE rb_smooth) {
288
480
  sfTexture_setSmooth((sfTexture*)Get_Texture_Struct(self), RTEST(rb_smooth));
289
481
  return rb_smooth;
290
482
  }
291
483
 
484
+ /* call-seq: smooth? -> true or false
485
+ *
486
+ * Returns +true+ if smooth rendering is enabled.
487
+ *
488
+ * @return [Boolean]
489
+ */
292
490
  static VALUE Texture_is_smooth(VALUE self) {
293
491
  return BOOL2RB(sfTexture_isSmooth(Get_Texture_Struct(self)));
294
492
  }
295
493
 
494
+ /* call-seq: srgb? -> true or false
495
+ *
496
+ * Returns +true+ if the texture uses an sRGB format.
497
+ *
498
+ * @return [Boolean]
499
+ */
296
500
  static VALUE Texture_is_srgb(VALUE self) {
297
501
  return BOOL2RB(sfTexture_isSrgb(Get_Texture_Struct(self)));
298
502
  }
299
503
 
504
+ /* call-seq:
505
+ * repeated=(value) -> true or false
506
+ *
507
+ * Enables or disables texture repeating.
508
+ *
509
+ * @return [Boolean] +value+
510
+ */
300
511
  static VALUE Texture_set_repeated(VALUE self, VALUE rb_repeated) {
301
512
  sfTexture_setRepeated((sfTexture*)Get_Texture_Struct(self), RTEST(rb_repeated));
302
513
  return rb_repeated;
303
514
  }
304
515
 
516
+ /* call-seq: repeated? -> true or false
517
+ *
518
+ * Returns +true+ if texture repeating is enabled.
519
+ *
520
+ * @return [Boolean]
521
+ */
305
522
  static VALUE Texture_is_repeated(VALUE self) {
306
523
  return BOOL2RB(sfTexture_isRepeated(Get_Texture_Struct(self)));
307
524
  }
308
525
 
526
+ /* call-seq: generate_mipmap -> true or false
527
+ *
528
+ * Generates the mipmap pyramid for the texture.
529
+ *
530
+ * @return [Boolean] whether mipmap generation succeeded
531
+ */
309
532
  static VALUE Texture_generate_mipmap(VALUE self) {
310
533
  return BOOL2RB(sfTexture_generateMipmap((sfTexture*)Get_Texture_Struct(self)));
311
534
  }
312
535
 
536
+ /* call-seq: native_handle -> Integer
537
+ *
538
+ * Returns the underlying OpenGL handle.
539
+ *
540
+ * @return [Integer] the underlying OpenGL texture handle
541
+ */
313
542
  static VALUE Texture_get_native_handle(VALUE self) {
314
543
  return UINT2NUM(sfTexture_getNativeHandle(Get_Texture_Struct(self)));
315
544
  }
316
545
 
546
+ /* call-seq:
547
+ * bind -> self
548
+ * bind(coordinate_type) -> self
549
+ *
550
+ * Activates this texture for rendering. +coordinate_type+ selects
551
+ * normalized (0..1) or pixel texture coordinates and defaults to
552
+ * normalized.
553
+ *
554
+ * @return [self]
555
+ */
317
556
  static VALUE Texture_bind(int argc, VALUE* argv, VALUE self) {
318
557
  VALUE rb_coordinate_type;
319
558
  sfCoordinateType type = sfCoordinateTypeNormalized;
@@ -329,12 +568,27 @@ static VALUE Texture_bind(int argc, VALUE* argv, VALUE self) {
329
568
  return self;
330
569
  }
331
570
 
571
+ /* call-seq:
572
+ * Texture.maximum_size -> Integer
573
+ *
574
+ * Returns the maximum texture size supported by the GPU.
575
+ *
576
+ * @return [Integer] the maximum texture size supported by the current
577
+ * OpenGL implementation
578
+ */
332
579
  static VALUE Texture_maximum_size(VALUE klass) {
333
580
  return UINT2NUM(sfTexture_getMaximumSize());
334
581
  }
335
582
 
336
- void Init_Texture(VALUE rb_module) {
337
- rb_cTexture = rb_define_class_under(rb_module, "Texture", rb_cObject);
583
+ /* Document-class: SFML::Texture
584
+ * An image living in GPU memory, usable for rendering (Sprite, Text,
585
+ * Shape) or as a render target (RenderTexture#texture).
586
+ *
587
+ * #smooth?/#smooth=, #srgb?, and #repeated?/#repeated= control sampling;
588
+ * see each method for details.
589
+ */
590
+ void Init_Texture(VALUE rb_mSFML) {
591
+ rb_cTexture = rb_define_class_under(rb_mSFML, "Texture", rb_cObject);
338
592
 
339
593
  rb_define_singleton_method(rb_cTexture, "new", Texture_new, 1);
340
594
  rb_define_singleton_method(rb_cTexture, "from_file", Texture_from_file, -1);