sfml3-rb 0.0.1 → 0.2.2

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 (191) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +342 -0
  3. data/README.md +51 -14
  4. data/TODO.md +199 -0
  5. data/ext/audio/audio_enums.c +131 -0
  6. data/ext/audio/audio_enums.h +18 -0
  7. data/ext/audio/effect_processor.c +233 -0
  8. data/ext/audio/effect_processor.h +25 -0
  9. data/ext/audio/listener.c +83 -0
  10. data/ext/audio/listener.h +8 -0
  11. data/ext/audio/music.c +174 -0
  12. data/ext/audio/music.h +14 -0
  13. data/ext/audio/sound.c +139 -0
  14. data/ext/audio/sound.h +14 -0
  15. data/ext/audio/sound_buffer.c +274 -0
  16. data/ext/audio/sound_buffer.h +18 -0
  17. data/ext/audio/sound_buffer_recorder.c +109 -0
  18. data/ext/audio/sound_buffer_recorder.h +14 -0
  19. data/ext/audio/sound_recorder.c +268 -0
  20. data/ext/audio/sound_recorder.h +14 -0
  21. data/ext/audio/sound_source.h +13 -0
  22. data/ext/audio/sound_source.inc +271 -0
  23. data/ext/audio/sound_source_cone.c +138 -0
  24. data/ext/audio/sound_source_cone.h +20 -0
  25. data/ext/audio/sound_stream.c +294 -0
  26. data/ext/audio/sound_stream.h +14 -0
  27. data/ext/{exceptions.c → core/exceptions.c} +10 -8
  28. data/ext/{ext → core}/exceptions.h +3 -3
  29. data/ext/core/foreign_thread.c +149 -0
  30. data/ext/core/foreign_thread.h +31 -0
  31. data/ext/core/macros.h +8 -0
  32. data/ext/{ext → core}/sfml.h +5 -3
  33. data/ext/core/unicode.c +46 -0
  34. data/ext/core/unicode.h +25 -0
  35. data/ext/ext.c +125 -14
  36. data/ext/extconf.rb +51 -6
  37. data/ext/graphics/blend_mode.c +261 -0
  38. data/ext/graphics/blend_mode.h +18 -0
  39. data/ext/graphics/circle.c +319 -0
  40. data/ext/{ext/klass/drawable → graphics}/circle.h +3 -3
  41. data/ext/graphics/color.c +318 -0
  42. data/ext/graphics/color.h +37 -0
  43. data/ext/{drawable.c → graphics/drawable.c} +11 -11
  44. data/ext/graphics/drawable.h +10 -0
  45. data/ext/graphics/enums.c +123 -0
  46. data/ext/graphics/enums.h +20 -0
  47. data/ext/graphics/font.c +148 -0
  48. data/ext/graphics/font.h +14 -0
  49. data/ext/graphics/glyph.c +60 -0
  50. data/ext/graphics/glyph.h +14 -0
  51. data/ext/graphics/image.c +205 -0
  52. data/ext/graphics/image.h +16 -0
  53. data/ext/graphics/polygon.c +300 -0
  54. data/ext/graphics/polygon.h +10 -0
  55. data/ext/graphics/rect.c +287 -0
  56. data/ext/graphics/rect.h +30 -0
  57. data/ext/graphics/rectangle.c +302 -0
  58. data/ext/graphics/rectangle.h +10 -0
  59. data/ext/graphics/render_state.c +204 -0
  60. data/ext/graphics/render_state.h +18 -0
  61. data/ext/graphics/render_target.inc +181 -0
  62. data/ext/graphics/render_texture.c +182 -0
  63. data/ext/graphics/render_texture.h +14 -0
  64. data/ext/graphics/shader.c +540 -0
  65. data/ext/graphics/shader.h +14 -0
  66. data/ext/graphics/shape.c +311 -0
  67. data/ext/graphics/shape.h +10 -0
  68. data/ext/graphics/sprite.c +249 -0
  69. data/ext/graphics/sprite.h +10 -0
  70. data/ext/graphics/stencil_mode.c +211 -0
  71. data/ext/graphics/stencil_mode.h +18 -0
  72. data/ext/graphics/target.c +133 -0
  73. data/ext/graphics/target.h +40 -0
  74. data/ext/graphics/text.c +344 -0
  75. data/ext/graphics/text.h +10 -0
  76. data/ext/graphics/texture.c +379 -0
  77. data/ext/graphics/texture.h +16 -0
  78. data/ext/graphics/transform.c +372 -0
  79. data/ext/graphics/transform.h +35 -0
  80. data/ext/{transformable.c → graphics/transformable.c} +168 -144
  81. data/ext/{ext/klass → graphics}/transformable.h +3 -3
  82. data/ext/graphics/vertex.c +179 -0
  83. data/ext/graphics/vertex.h +23 -0
  84. data/ext/graphics/vertex_array.c +127 -0
  85. data/ext/graphics/vertex_array.h +10 -0
  86. data/ext/graphics/vertex_buffer.c +211 -0
  87. data/ext/graphics/vertex_buffer.h +14 -0
  88. data/ext/{view.c → graphics/view.c} +168 -169
  89. data/ext/{ext/klass → graphics}/view.h +3 -3
  90. data/ext/network/ftp.c +405 -0
  91. data/ext/network/ftp.h +20 -0
  92. data/ext/network/http.c +243 -0
  93. data/ext/network/http.h +18 -0
  94. data/ext/network/ip_address.c +164 -0
  95. data/ext/network/ip_address.h +20 -0
  96. data/ext/network/network_enums.c +298 -0
  97. data/ext/network/network_enums.h +26 -0
  98. data/ext/network/packet.c +189 -0
  99. data/ext/network/packet.h +14 -0
  100. data/ext/network/socket_selector.c +142 -0
  101. data/ext/network/socket_selector.h +14 -0
  102. data/ext/network/tcp_listener.c +115 -0
  103. data/ext/network/tcp_listener.h +14 -0
  104. data/ext/network/tcp_socket.c +199 -0
  105. data/ext/network/tcp_socket.h +17 -0
  106. data/ext/network/udp_socket.c +190 -0
  107. data/ext/network/udp_socket.h +14 -0
  108. data/ext/ports.rb +97 -21
  109. data/ext/system/buffer.c +77 -0
  110. data/ext/system/buffer.h +14 -0
  111. data/ext/system/clock.c +100 -0
  112. data/ext/{ext/klass → system}/clock.h +3 -3
  113. data/ext/system/input_stream.c +229 -0
  114. data/ext/system/input_stream.h +23 -0
  115. data/ext/system/sleep.c +16 -0
  116. data/ext/system/sleep.h +8 -0
  117. data/ext/system/time.c +218 -0
  118. data/ext/system/time.h +18 -0
  119. data/ext/system/vec2.c +251 -0
  120. data/ext/system/vec2.h +55 -0
  121. data/ext/system/vec3.c +219 -0
  122. data/ext/system/vec3.h +18 -0
  123. data/ext/window/clipboard.c +89 -0
  124. data/ext/window/clipboard.h +8 -0
  125. data/ext/window/context.c +70 -0
  126. data/ext/window/context.h +8 -0
  127. data/ext/window/context_settings.c +220 -0
  128. data/ext/window/context_settings.h +18 -0
  129. data/ext/window/cursor.c +56 -0
  130. data/ext/window/cursor.h +14 -0
  131. data/ext/window/event.c +216 -0
  132. data/ext/window/event.h +14 -0
  133. data/ext/{event_name.c → window/event_name.c} +2 -2
  134. data/ext/window/event_name.h +8 -0
  135. data/ext/window/input_enums.c +261 -0
  136. data/ext/window/input_enums.h +36 -0
  137. data/ext/window/joystick.c +60 -0
  138. data/ext/window/joystick.h +8 -0
  139. data/ext/{keyboard.c → window/keyboard.c} +74 -2
  140. data/ext/window/keyboard.h +12 -0
  141. data/ext/window/mouse.c +70 -0
  142. data/ext/window/mouse.h +8 -0
  143. data/ext/window/sensor.c +30 -0
  144. data/ext/window/sensor.h +8 -0
  145. data/ext/window/touch.c +49 -0
  146. data/ext/window/touch.h +8 -0
  147. data/ext/window/video_mode.c +133 -0
  148. data/ext/window/video_mode.h +14 -0
  149. data/ext/window/vulkan.c +44 -0
  150. data/ext/window/vulkan.h +8 -0
  151. data/ext/window/window.c +414 -0
  152. data/ext/{ext/klass → window}/window.h +3 -3
  153. data/lib/sfml/version.rb +4 -2
  154. data/lib/sfml.rb +2 -0
  155. metadata +163 -56
  156. data/ext/circle.c +0 -198
  157. data/ext/clock.c +0 -65
  158. data/ext/color.c +0 -43
  159. data/ext/event.c +0 -148
  160. data/ext/ext/klass/color.h +0 -26
  161. data/ext/ext/klass/drawable/image.h +0 -4
  162. data/ext/ext/klass/drawable/polygon.h +0 -4
  163. data/ext/ext/klass/drawable/rectangle.h +0 -4
  164. data/ext/ext/klass/drawable/sprite.h +0 -4
  165. data/ext/ext/klass/drawable/texture.h +0 -4
  166. data/ext/ext/klass/event/event_name.h +0 -8
  167. data/ext/ext/klass/event.h +0 -12
  168. data/ext/ext/klass/keyboard.h +0 -8
  169. data/ext/ext/klass/render_state.h +0 -16
  170. data/ext/ext/klass/target.h +0 -18
  171. data/ext/ext/klass/transform.h +0 -17
  172. data/ext/ext/klass/video_mode.h +0 -12
  173. data/ext/ext/module/drawable/drawable.h +0 -10
  174. data/ext/ext/module/transform.h +0 -18
  175. data/ext/ext/module.h +0 -10
  176. data/ext/ext/rect.h +0 -16
  177. data/ext/ext/style_name.h +0 -11
  178. data/ext/ext/vec2.h +0 -38
  179. data/ext/image.c +0 -5
  180. data/ext/polygon.c +0 -5
  181. data/ext/rect.c +0 -26
  182. data/ext/rectangle.c +0 -5
  183. data/ext/render_state.c +0 -109
  184. data/ext/sprite.c +0 -5
  185. data/ext/style_name.c +0 -15
  186. data/ext/target.c +0 -106
  187. data/ext/texture.c +0 -5
  188. data/ext/transform.c +0 -107
  189. data/ext/vec2.c +0 -42
  190. data/ext/video_mode.c +0 -78
  191. data/ext/window.c +0 -274
@@ -0,0 +1,379 @@
1
+ #include "graphics/texture.h"
2
+
3
+ #include <ruby.h>
4
+ #include <stdlib.h>
5
+ #include <string.h>
6
+
7
+ #include "graphics/image.h"
8
+ #include "graphics/rect.h"
9
+ #include "graphics/enums.h"
10
+ #include "system/input_stream.h"
11
+ #include "system/vec2.h"
12
+ #include "window/window.h"
13
+ #include "core/exceptions.h"
14
+ #include "core/macros.h"
15
+
16
+ static VALUE rb_cTexture;
17
+
18
+ typedef struct {
19
+ sfTexture* texture;
20
+ bool owns;
21
+ } Texture;
22
+
23
+ static void Texture_free(void* ptr) {
24
+ Texture* texture = ptr;
25
+
26
+ if (texture->owns) {
27
+ sfTexture_destroy(texture->texture);
28
+ }
29
+
30
+ free(texture);
31
+ }
32
+
33
+ static const rb_data_type_t Texture_data_type = {
34
+ .wrap_struct_name = "SFML::Texture",
35
+ .function = {.dmark = NULL, .dfree = Texture_free, .dsize = NULL},
36
+ .flags = RUBY_TYPED_FREE_IMMEDIATELY};
37
+
38
+ static VALUE Texture_wrap(VALUE klass, sfTexture* texture) {
39
+ Texture* ptr;
40
+
41
+ if (texture == NULL) {
42
+ rb_raise(rb_eRuntimeError, "failed to create texture");
43
+ }
44
+
45
+ ptr = malloc(sizeof(Texture));
46
+ ptr->texture = texture;
47
+ ptr->owns = true;
48
+
49
+ return TypedData_Wrap_Struct(klass, &Texture_data_type, ptr);
50
+ }
51
+
52
+ VALUE texture_from_borrowed(const sfTexture* texture) {
53
+ Texture* ptr;
54
+
55
+ if (texture == NULL) {
56
+ return Qnil;
57
+ }
58
+
59
+ ptr = malloc(sizeof(Texture));
60
+ ptr->texture = (sfTexture*)texture;
61
+ ptr->owns = false;
62
+
63
+ return TypedData_Wrap_Struct(rb_cTexture, &Texture_data_type, ptr);
64
+ }
65
+
66
+ /* Area stays NULL unless an argument was given, mirroring CSFML's "whole
67
+ texture" convention. The pointer stays valid for the call only. */
68
+ static const sfIntRect* Texture_area_ptr(VALUE rb_area, sfIntRect* storage) {
69
+ if (NIL_P(rb_area)) {
70
+ return NULL;
71
+ }
72
+
73
+ *storage = int_rect_from_rb(rb_area);
74
+
75
+ return storage;
76
+ }
77
+
78
+ static VALUE Texture_new(VALUE klass, VALUE rb_size) {
79
+ return Texture_wrap(klass, sfTexture_create(vec2u_from_rb(rb_size)));
80
+ }
81
+
82
+ static VALUE Texture_srgb(VALUE klass, VALUE rb_size) {
83
+ return Texture_wrap(klass, sfTexture_createSrgb(vec2u_from_rb(rb_size)));
84
+ }
85
+
86
+ static VALUE Texture_from_file(int argc, VALUE* argv, VALUE klass) {
87
+ VALUE rb_path, rb_area;
88
+ sfIntRect area;
89
+
90
+ rb_scan_args(argc, argv, "11", &rb_path, &rb_area);
91
+
92
+ return Texture_wrap(klass, sfTexture_createFromFile(StringValueCStr(rb_path),
93
+ Texture_area_ptr(rb_area, &area)));
94
+ }
95
+
96
+ static VALUE Texture_srgb_from_file(int argc, VALUE* argv, VALUE klass) {
97
+ VALUE rb_path, rb_area;
98
+ sfIntRect area;
99
+
100
+ rb_scan_args(argc, argv, "11", &rb_path, &rb_area);
101
+
102
+ return Texture_wrap(klass, sfTexture_createSrgbFromFile(StringValueCStr(rb_path),
103
+ Texture_area_ptr(rb_area, &area)));
104
+ }
105
+
106
+ static VALUE Texture_from_memory(int argc, VALUE* argv, VALUE klass) {
107
+ VALUE rb_data, rb_area;
108
+ sfIntRect area;
109
+
110
+ rb_scan_args(argc, argv, "11", &rb_data, &rb_area);
111
+ StringValue(rb_data);
112
+
113
+ return Texture_wrap(klass, sfTexture_createFromMemory(RSTRING_PTR(rb_data),
114
+ (size_t)RSTRING_LEN(rb_data),
115
+ Texture_area_ptr(rb_area, &area)));
116
+ }
117
+
118
+ static VALUE Texture_srgb_from_memory(int argc, VALUE* argv, VALUE klass) {
119
+ VALUE rb_data, rb_area;
120
+ sfIntRect area;
121
+
122
+ rb_scan_args(argc, argv, "11", &rb_data, &rb_area);
123
+ StringValue(rb_data);
124
+
125
+ return Texture_wrap(klass, sfTexture_createSrgbFromMemory(RSTRING_PTR(rb_data),
126
+ (size_t)RSTRING_LEN(rb_data),
127
+ Texture_area_ptr(rb_area, &area)));
128
+ }
129
+
130
+ static VALUE Texture_from_stream(int argc, VALUE* argv, VALUE klass) {
131
+ VALUE rb_stream, rb_area, holder = Qnil;
132
+ sfIntRect area;
133
+ sfInputStream* stream;
134
+
135
+ if (argc < 1 || argc > 2) {
136
+ raise_invalid_arguments_excepted(2, argc);
137
+ }
138
+
139
+ rb_stream = argv[0];
140
+ rb_area = (argc == 2) ? argv[1] : Qnil;
141
+ stream = input_stream_from_rb(rb_stream, &holder);
142
+
143
+ (void)holder;
144
+
145
+ return Texture_wrap(klass,
146
+ sfTexture_createFromStream(stream, Texture_area_ptr(rb_area, &area)));
147
+ }
148
+
149
+ static VALUE Texture_srgb_from_stream(int argc, VALUE* argv, VALUE klass) {
150
+ VALUE rb_stream, rb_area, holder = Qnil;
151
+ sfIntRect area;
152
+ sfInputStream* stream;
153
+
154
+ if (argc < 1 || argc > 2) {
155
+ raise_invalid_arguments_excepted(2, argc);
156
+ }
157
+
158
+ rb_stream = argv[0];
159
+ rb_area = (argc == 2) ? argv[1] : Qnil;
160
+ stream = input_stream_from_rb(rb_stream, &holder);
161
+
162
+ (void)holder;
163
+
164
+ return Texture_wrap(klass,
165
+ sfTexture_createSrgbFromStream(stream, Texture_area_ptr(rb_area, &area)));
166
+ }
167
+
168
+ static VALUE Texture_from_image(int argc, VALUE* argv, VALUE klass) {
169
+ VALUE rb_image, rb_area;
170
+ sfIntRect area;
171
+
172
+ rb_scan_args(argc, argv, "11", &rb_image, &rb_area);
173
+
174
+ if (!rb_obj_is_kind_of(rb_image, Get_Klass_Image())) {
175
+ raise_invalid_argument_class(Get_Klass_Image());
176
+ }
177
+
178
+ return Texture_wrap(klass, sfTexture_createFromImage(Get_Image_Struct(rb_image),
179
+ Texture_area_ptr(rb_area, &area)));
180
+ }
181
+
182
+ static VALUE Texture_srgb_from_image(int argc, VALUE* argv, VALUE klass) {
183
+ VALUE rb_image, rb_area;
184
+ sfIntRect area;
185
+
186
+ rb_scan_args(argc, argv, "11", &rb_image, &rb_area);
187
+
188
+ if (!rb_obj_is_kind_of(rb_image, Get_Klass_Image())) {
189
+ raise_invalid_argument_class(Get_Klass_Image());
190
+ }
191
+
192
+ return Texture_wrap(klass, sfTexture_createSrgbFromImage(Get_Image_Struct(rb_image),
193
+ Texture_area_ptr(rb_area, &area)));
194
+ }
195
+
196
+ static VALUE Texture_copy(VALUE self) {
197
+ return Texture_wrap(Get_Klass_Texture(), sfTexture_copy(Get_Texture_Struct(self)));
198
+ }
199
+
200
+ static VALUE Texture_get_size(VALUE self) {
201
+ sfVector2u size = sfTexture_getSize(Get_Texture_Struct(self));
202
+
203
+ return vec2f_to_rb((sfVector2f){(float)size.x, (float)size.y});
204
+ }
205
+
206
+ static VALUE Texture_resize(VALUE self, VALUE rb_size) {
207
+ return BOOL2RB(sfTexture_resize((sfTexture*)Get_Texture_Struct(self), vec2u_from_rb(rb_size)));
208
+ }
209
+
210
+ static VALUE Texture_resize_srgb(VALUE self, VALUE rb_size) {
211
+ return BOOL2RB(
212
+ sfTexture_resizeSrgb((sfTexture*)Get_Texture_Struct(self), vec2u_from_rb(rb_size)));
213
+ }
214
+
215
+ /* Exchanges the two textures' contents in place, so anything already holding
216
+ either object sees the swap. */
217
+ static VALUE Texture_swap(VALUE self, VALUE rb_other) {
218
+ if (!rb_obj_is_kind_of(rb_other, Get_Klass_Texture())) {
219
+ raise_invalid_argument_class(Get_Klass_Texture());
220
+ }
221
+
222
+ sfTexture_swap((sfTexture*)Get_Texture_Struct(self), (sfTexture*)Get_Texture_Struct(rb_other));
223
+
224
+ return self;
225
+ }
226
+
227
+ static VALUE Texture_copy_to_image(VALUE self) {
228
+ sfImage* image = sfTexture_copyToImage(Get_Texture_Struct(self));
229
+
230
+ if (image == NULL) {
231
+ rb_raise(rb_eRuntimeError, "failed to copy texture to image");
232
+ }
233
+
234
+ return image_from_c(image);
235
+ }
236
+
237
+ static VALUE Texture_update_from_pixels(VALUE self, VALUE rb_pixels, VALUE rb_size,
238
+ VALUE rb_offset) {
239
+ sfVector2u size = vec2u_from_rb(rb_size);
240
+ sfVector2u offset = vec2u_from_rb(rb_offset);
241
+
242
+ StringValue(rb_pixels);
243
+
244
+ if ((size_t)RSTRING_LEN(rb_pixels) < (size_t)size.x * size.y * 4) {
245
+ rb_raise(rb_eArgError, "pixel data too short");
246
+ }
247
+
248
+ sfTexture_updateFromPixels((sfTexture*)Get_Texture_Struct(self),
249
+ (const uint8_t*)RSTRING_PTR(rb_pixels), size, offset);
250
+
251
+ return self;
252
+ }
253
+
254
+ static VALUE Texture_update_from_image(VALUE self, VALUE rb_image, VALUE rb_offset) {
255
+ if (!rb_obj_is_kind_of(rb_image, Get_Klass_Image())) {
256
+ raise_invalid_argument_class(Get_Klass_Image());
257
+ }
258
+
259
+ sfTexture_updateFromImage((sfTexture*)Get_Texture_Struct(self), Get_Image_Struct(rb_image),
260
+ vec2u_from_rb(rb_offset));
261
+
262
+ return self;
263
+ }
264
+
265
+ static VALUE Texture_update_from_texture(VALUE self, VALUE rb_source, VALUE rb_offset) {
266
+ if (!rb_obj_is_kind_of(rb_source, rb_cTexture)) {
267
+ raise_invalid_argument_class(rb_cTexture);
268
+ }
269
+
270
+ sfTexture_updateFromTexture((sfTexture*)Get_Texture_Struct(self), Get_Texture_Struct(rb_source),
271
+ vec2u_from_rb(rb_offset));
272
+
273
+ return self;
274
+ }
275
+
276
+ static VALUE Texture_update_from_window(VALUE self, VALUE rb_window, VALUE rb_offset) {
277
+ if (!rb_obj_is_kind_of(rb_window, Get_Klass_Window())) {
278
+ raise_invalid_argument_class(Get_Klass_Window());
279
+ }
280
+
281
+ sfTexture_updateFromRenderWindow((sfTexture*)Get_Texture_Struct(self),
282
+ Get_Window_Struct(rb_window), vec2u_from_rb(rb_offset));
283
+
284
+ return self;
285
+ }
286
+
287
+ static VALUE Texture_set_smooth(VALUE self, VALUE rb_smooth) {
288
+ sfTexture_setSmooth((sfTexture*)Get_Texture_Struct(self), RTEST(rb_smooth));
289
+ return rb_smooth;
290
+ }
291
+
292
+ static VALUE Texture_is_smooth(VALUE self) {
293
+ return BOOL2RB(sfTexture_isSmooth(Get_Texture_Struct(self)));
294
+ }
295
+
296
+ static VALUE Texture_is_srgb(VALUE self) {
297
+ return BOOL2RB(sfTexture_isSrgb(Get_Texture_Struct(self)));
298
+ }
299
+
300
+ static VALUE Texture_set_repeated(VALUE self, VALUE rb_repeated) {
301
+ sfTexture_setRepeated((sfTexture*)Get_Texture_Struct(self), RTEST(rb_repeated));
302
+ return rb_repeated;
303
+ }
304
+
305
+ static VALUE Texture_is_repeated(VALUE self) {
306
+ return BOOL2RB(sfTexture_isRepeated(Get_Texture_Struct(self)));
307
+ }
308
+
309
+ static VALUE Texture_generate_mipmap(VALUE self) {
310
+ return BOOL2RB(sfTexture_generateMipmap((sfTexture*)Get_Texture_Struct(self)));
311
+ }
312
+
313
+ static VALUE Texture_get_native_handle(VALUE self) {
314
+ return UINT2NUM(sfTexture_getNativeHandle(Get_Texture_Struct(self)));
315
+ }
316
+
317
+ static VALUE Texture_bind(int argc, VALUE* argv, VALUE self) {
318
+ VALUE rb_coordinate_type;
319
+ sfCoordinateType type = sfCoordinateTypeNormalized;
320
+
321
+ rb_scan_args(argc, argv, "01", &rb_coordinate_type);
322
+
323
+ if (!NIL_P(rb_coordinate_type)) {
324
+ type = coordinate_type_from_rb(rb_coordinate_type);
325
+ }
326
+
327
+ sfTexture_bind(Get_Texture_Struct(self), type);
328
+
329
+ return self;
330
+ }
331
+
332
+ static VALUE Texture_maximum_size(VALUE klass) {
333
+ return UINT2NUM(sfTexture_getMaximumSize());
334
+ }
335
+
336
+ void Init_Texture(VALUE rb_module) {
337
+ rb_cTexture = rb_define_class_under(rb_module, "Texture", rb_cObject);
338
+
339
+ rb_define_singleton_method(rb_cTexture, "new", Texture_new, 1);
340
+ rb_define_singleton_method(rb_cTexture, "from_file", Texture_from_file, -1);
341
+ rb_define_singleton_method(rb_cTexture, "from_memory", Texture_from_memory, -1);
342
+ rb_define_singleton_method(rb_cTexture, "from_stream", Texture_from_stream, -1);
343
+ rb_define_singleton_method(rb_cTexture, "from_image", Texture_from_image, -1);
344
+ rb_define_singleton_method(rb_cTexture, "srgb", Texture_srgb, 1);
345
+ rb_define_singleton_method(rb_cTexture, "srgb_from_file", Texture_srgb_from_file, -1);
346
+ rb_define_singleton_method(rb_cTexture, "srgb_from_memory", Texture_srgb_from_memory, -1);
347
+ rb_define_singleton_method(rb_cTexture, "srgb_from_stream", Texture_srgb_from_stream, -1);
348
+ rb_define_singleton_method(rb_cTexture, "srgb_from_image", Texture_srgb_from_image, -1);
349
+ rb_define_singleton_method(rb_cTexture, "maximum_size", Texture_maximum_size, 0);
350
+
351
+ rb_define_method(rb_cTexture, "copy", Texture_copy, 0);
352
+ rb_define_method(rb_cTexture, "size", Texture_get_size, 0);
353
+ rb_define_method(rb_cTexture, "resize", Texture_resize, 1);
354
+ rb_define_method(rb_cTexture, "resize_srgb", Texture_resize_srgb, 1);
355
+ rb_define_method(rb_cTexture, "swap", Texture_swap, 1);
356
+ rb_define_method(rb_cTexture, "copy_to_image", Texture_copy_to_image, 0);
357
+ rb_define_method(rb_cTexture, "update_from_pixels", Texture_update_from_pixels, 3);
358
+ rb_define_method(rb_cTexture, "update_from_image", Texture_update_from_image, 2);
359
+ rb_define_method(rb_cTexture, "update_from_texture", Texture_update_from_texture, 2);
360
+ rb_define_method(rb_cTexture, "update_from_window", Texture_update_from_window, 2);
361
+ rb_define_method(rb_cTexture, "smooth=", Texture_set_smooth, 1);
362
+ rb_define_method(rb_cTexture, "smooth?", Texture_is_smooth, 0);
363
+ rb_define_method(rb_cTexture, "srgb?", Texture_is_srgb, 0);
364
+ rb_define_method(rb_cTexture, "repeated=", Texture_set_repeated, 1);
365
+ rb_define_method(rb_cTexture, "repeated?", Texture_is_repeated, 0);
366
+ rb_define_method(rb_cTexture, "generate_mipmap", Texture_generate_mipmap, 0);
367
+ rb_define_method(rb_cTexture, "native_handle", Texture_get_native_handle, 0);
368
+ rb_define_method(rb_cTexture, "bind", Texture_bind, -1);
369
+ }
370
+
371
+ VALUE Get_Klass_Texture(void) {
372
+ return rb_cTexture;
373
+ }
374
+
375
+ const sfTexture* Get_Texture_Struct(VALUE self) {
376
+ Texture* ptr;
377
+ TypedData_Get_Struct(self, Texture, &Texture_data_type, ptr);
378
+ return ptr->texture;
379
+ }
@@ -0,0 +1,16 @@
1
+ #ifndef SFML_RB_GRAPHICS_TEXTURE_H
2
+ #define SFML_RB_GRAPHICS_TEXTURE_H
3
+
4
+ #include <ruby.h>
5
+
6
+ #include "core/sfml.h"
7
+
8
+ void Init_Texture(VALUE rb_module);
9
+
10
+ VALUE Get_Klass_Texture(void);
11
+
12
+ const sfTexture *Get_Texture_Struct(VALUE self);
13
+
14
+ VALUE texture_from_borrowed(const sfTexture *texture);
15
+
16
+ #endif //SFML_RB_GRAPHICS_TEXTURE_H