ruby-sdl2 0.3.5 → 0.3.7
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/.gitignore +4 -1
- data/Gemfile +10 -0
- data/README.md +8 -3
- data/Rakefile +22 -2
- data/Steepfile +24 -0
- data/doc/DEVELOP.md +35 -0
- data/event.c +36 -32
- data/gamecontroller.c +31 -27
- data/gamecontroller.c.m4 +31 -27
- data/gl.c +63 -67
- data/gl.c.m4 +63 -67
- data/hint.c +3 -3
- data/joystick.c +16 -12
- data/joystick.c.m4 +16 -12
- data/key.c +21 -19
- data/key.c.m4 +21 -19
- data/lib/sdl2/version.rb +3 -3
- data/main.c +13 -16
- data/messagebox.c +7 -7
- data/mixer.c +54 -38
- data/mixer.c.m4 +54 -38
- data/mouse.c +3 -3
- data/rbs_collection.yaml +32 -0
- data/rubysdl2_internal.h +12 -1
- data/sample/test_read_pixels.rb +41 -0
- data/ttf.c +20 -17
- data/ttf.c.m4 +20 -17
- data/video.c +262 -143
- data/video.c.m4 +199 -112
- metadata +8 -6
data/video.c.m4
CHANGED
|
@@ -65,7 +65,20 @@ typedef struct Surface {
|
|
|
65
65
|
int need_to_free_pixels;
|
|
66
66
|
} Surface;
|
|
67
67
|
|
|
68
|
+
static void Window_free(Window*);
|
|
68
69
|
static void Renderer_free(Renderer*);
|
|
70
|
+
static void Texture_free(Texture*);
|
|
71
|
+
static void Surface_free(Surface*);
|
|
72
|
+
|
|
73
|
+
/* Forward-declare TypedData types (need free function declarations above) */
|
|
74
|
+
DEFINE_DATA_TYPE(Window, Window_free);
|
|
75
|
+
DEFINE_DATA_TYPE(SDL_DisplayMode, free);
|
|
76
|
+
DEFINE_DATA_TYPE(Renderer, Renderer_free);
|
|
77
|
+
DEFINE_DATA_TYPE(Texture, Texture_free);
|
|
78
|
+
DEFINE_DATA_TYPE(Surface, Surface_free);
|
|
79
|
+
DEFINE_DATA_TYPE(SDL_Rect, free);
|
|
80
|
+
DEFINE_DATA_TYPE(SDL_Point, free);
|
|
81
|
+
|
|
69
82
|
static void Window_destroy_internal(Window* w)
|
|
70
83
|
{
|
|
71
84
|
int i;
|
|
@@ -89,12 +102,13 @@ static void Window_free(Window* w)
|
|
|
89
102
|
|
|
90
103
|
static VALUE Window_new(SDL_Window* window)
|
|
91
104
|
{
|
|
92
|
-
Window* w
|
|
105
|
+
Window* w;
|
|
106
|
+
VALUE obj = TypedData_Make_Struct(cWindow, Window, &Window_data_type, w);
|
|
93
107
|
w->window = window;
|
|
94
108
|
w->num_renderers = 0;
|
|
95
109
|
w->max_renderers = 4;
|
|
96
110
|
w->renderers = ALLOC_N(struct Renderer*, 4);
|
|
97
|
-
return
|
|
111
|
+
return obj;
|
|
98
112
|
}
|
|
99
113
|
|
|
100
114
|
DEFINE_GETTER(static, Window, cWindow, "SDL2::Window");
|
|
@@ -111,24 +125,24 @@ static VALUE Display_new(int index)
|
|
|
111
125
|
|
|
112
126
|
static VALUE DisplayMode_s_allocate(VALUE klass)
|
|
113
127
|
{
|
|
114
|
-
SDL_DisplayMode* mode
|
|
128
|
+
SDL_DisplayMode* mode;
|
|
129
|
+
VALUE obj = TypedData_Make_Struct(klass, SDL_DisplayMode, &SDL_DisplayMode_data_type, mode);
|
|
115
130
|
mode->format = mode->w = mode->h = mode->refresh_rate = 0;
|
|
116
131
|
mode->driverdata = NULL;
|
|
117
|
-
return
|
|
132
|
+
return obj;
|
|
118
133
|
}
|
|
119
134
|
|
|
120
135
|
static VALUE DisplayMode_new(SDL_DisplayMode* mode)
|
|
121
136
|
{
|
|
122
137
|
VALUE display_mode = DisplayMode_s_allocate(cDisplayMode);
|
|
123
138
|
SDL_DisplayMode* m;
|
|
124
|
-
|
|
139
|
+
TypedData_Get_Struct(display_mode, SDL_DisplayMode, &SDL_DisplayMode_data_type, m);
|
|
125
140
|
*m = *mode;
|
|
126
141
|
return display_mode;
|
|
127
142
|
}
|
|
128
143
|
|
|
129
144
|
DEFINE_GETTER(static, SDL_DisplayMode, cDisplayMode, "SDL2::Display::Mode");
|
|
130
145
|
|
|
131
|
-
static void Texture_free(Texture*);
|
|
132
146
|
static void Renderer_destroy_internal(Renderer* r)
|
|
133
147
|
{
|
|
134
148
|
int i;
|
|
@@ -167,14 +181,15 @@ static void Window_attach_renderer(Window* w, Renderer* r)
|
|
|
167
181
|
|
|
168
182
|
static VALUE Renderer_new(SDL_Renderer* renderer, Window* w)
|
|
169
183
|
{
|
|
170
|
-
Renderer* r
|
|
184
|
+
Renderer* r;
|
|
185
|
+
VALUE obj = TypedData_Make_Struct(cRenderer, Renderer, &Renderer_data_type, r);
|
|
171
186
|
r->renderer = renderer;
|
|
172
187
|
r->num_textures = 0;
|
|
173
188
|
r->max_textures = 16;
|
|
174
189
|
r->textures = ALLOC_N(Texture*, 16);
|
|
175
190
|
r->refcount = 1;
|
|
176
191
|
Window_attach_renderer(w, r);
|
|
177
|
-
return
|
|
192
|
+
return obj;
|
|
178
193
|
}
|
|
179
194
|
|
|
180
195
|
DEFINE_WRAPPER(SDL_Renderer, Renderer, renderer, cRenderer, "SDL2::Renderer");
|
|
@@ -209,11 +224,12 @@ static void Renderer_attach_texture(Renderer* r, Texture* t)
|
|
|
209
224
|
|
|
210
225
|
static VALUE Texture_new(SDL_Texture* texture, Renderer* r)
|
|
211
226
|
{
|
|
212
|
-
Texture* t
|
|
227
|
+
Texture* t;
|
|
228
|
+
VALUE obj = TypedData_Make_Struct(cTexture, Texture, &Texture_data_type, t);
|
|
213
229
|
t->texture = texture;
|
|
214
230
|
t->refcount = 1;
|
|
215
231
|
Renderer_attach_texture(r, t);
|
|
216
|
-
return
|
|
232
|
+
return obj;
|
|
217
233
|
}
|
|
218
234
|
|
|
219
235
|
DEFINE_WRAPPER(SDL_Texture, Texture, texture, cTexture, "SDL2::Texture");
|
|
@@ -231,10 +247,11 @@ static void Surface_free(Surface* s)
|
|
|
231
247
|
|
|
232
248
|
VALUE Surface_new(SDL_Surface* surface)
|
|
233
249
|
{
|
|
234
|
-
Surface* s
|
|
250
|
+
Surface* s;
|
|
251
|
+
VALUE obj = TypedData_Make_Struct(cSurface, Surface, &Surface_data_type, s);
|
|
235
252
|
s->surface = surface;
|
|
236
253
|
s->need_to_free_pixels = 0;
|
|
237
|
-
return
|
|
254
|
+
return obj;
|
|
238
255
|
}
|
|
239
256
|
|
|
240
257
|
DEFINE_WRAPPER(SDL_Surface, Surface, surface, cSurface, "SDL2::Surface");
|
|
@@ -352,13 +369,14 @@ static VALUE SDL2_s_video_init(VALUE self, VALUE driver_name)
|
|
|
352
369
|
*
|
|
353
370
|
*
|
|
354
371
|
* @!method destroy?
|
|
355
|
-
*
|
|
372
|
+
* @return [Boolean] true if the window is already destroyed.
|
|
356
373
|
*/
|
|
357
374
|
|
|
358
375
|
/*
|
|
359
376
|
* @overload create(title, x, y, w, h, flags)
|
|
360
377
|
* Create a window with the specified position (x,y), dimensions (w,h) and flags.
|
|
361
378
|
*
|
|
379
|
+
* @param [String] title title of the created window
|
|
362
380
|
* @param [Integer] x the x position of the left-top of the window
|
|
363
381
|
* @param [Integer] y the y position of the left-top of the window
|
|
364
382
|
* @param [Integer] w the width of the window
|
|
@@ -482,7 +500,7 @@ static VALUE Window_window_id(VALUE self)
|
|
|
482
500
|
/*
|
|
483
501
|
* Get information about the window.
|
|
484
502
|
*
|
|
485
|
-
* @return [SDL2::
|
|
503
|
+
* @return [SDL2::Display::Mode]
|
|
486
504
|
*/
|
|
487
505
|
static VALUE Window_display_mode(VALUE self)
|
|
488
506
|
{
|
|
@@ -519,7 +537,7 @@ static VALUE Window_brightness(VALUE self)
|
|
|
519
537
|
*
|
|
520
538
|
* @param brightness [Float] the brightness, 0.0 means complete dark and 1.0 means
|
|
521
539
|
* normal brightness.
|
|
522
|
-
* @return [
|
|
540
|
+
* @return [void]
|
|
523
541
|
*
|
|
524
542
|
* @see #brightness
|
|
525
543
|
*/
|
|
@@ -573,7 +591,7 @@ static VALUE Window_gamma_ramp(VALUE self)
|
|
|
573
591
|
* Set the window icon.
|
|
574
592
|
*
|
|
575
593
|
* @param icon [SDL2::Surface] the icon for the window
|
|
576
|
-
* @return [
|
|
594
|
+
* @return [void]
|
|
577
595
|
*/
|
|
578
596
|
static VALUE Window_set_icon(VALUE self, VALUE icon)
|
|
579
597
|
{
|
|
@@ -596,7 +614,7 @@ static VALUE Window_input_is_grabbed_p(VALUE self)
|
|
|
596
614
|
* Set the window's input grab mode.
|
|
597
615
|
*
|
|
598
616
|
* @param grabbed [Boolean] true to grub input, and false to release input
|
|
599
|
-
* @return [
|
|
617
|
+
* @return [void]
|
|
600
618
|
*
|
|
601
619
|
* @see #input_is_grabbed?
|
|
602
620
|
*/
|
|
@@ -625,7 +643,7 @@ static VALUE Window_set_int_int(void (*func)(SDL_Window*, int, int), VALUE windo
|
|
|
625
643
|
/*
|
|
626
644
|
* Get the maximum size of the window's client area.
|
|
627
645
|
*
|
|
628
|
-
* @return [Integer,Integer] maximum width and maximum height.
|
|
646
|
+
* @return [Array(Integer,Integer)] maximum width and maximum height.
|
|
629
647
|
*
|
|
630
648
|
* @see #maximum_size=
|
|
631
649
|
*/
|
|
@@ -638,10 +656,10 @@ static VALUE Window_maximum_size(VALUE self)
|
|
|
638
656
|
* @overload maximum_size=(size)
|
|
639
657
|
* Set the maximum size of the window's client area.
|
|
640
658
|
*
|
|
641
|
-
* @param size [
|
|
659
|
+
* @param size [Array(Integer, Integer)] maximum width and maximum height,
|
|
642
660
|
* the both must be positive.
|
|
643
661
|
*
|
|
644
|
-
* @return [
|
|
662
|
+
* @return [void]
|
|
645
663
|
*
|
|
646
664
|
* @see #maximum_size
|
|
647
665
|
*/
|
|
@@ -653,7 +671,7 @@ static VALUE Window_set_maximum_size(VALUE self, VALUE max_size)
|
|
|
653
671
|
/*
|
|
654
672
|
* Get the minimum size of the window's client area.
|
|
655
673
|
*
|
|
656
|
-
* @return [Integer,Integer] minimum width and minimum height.
|
|
674
|
+
* @return [Array(Integer,Integer)] minimum width and minimum height.
|
|
657
675
|
*
|
|
658
676
|
* @see #minimum_size=
|
|
659
677
|
*/
|
|
@@ -666,10 +684,10 @@ static VALUE Window_minimum_size(VALUE self)
|
|
|
666
684
|
* @overload minimum_size=(size)
|
|
667
685
|
* Set the minimum size of the window's client area.
|
|
668
686
|
*
|
|
669
|
-
* @param size [
|
|
687
|
+
* @param size [Array(Integer, Integer)] minimum width and minimum height,
|
|
670
688
|
* the both must be positive.
|
|
671
689
|
*
|
|
672
|
-
* @return [
|
|
690
|
+
* @return [void]
|
|
673
691
|
*
|
|
674
692
|
* @see #minimum_size
|
|
675
693
|
*/
|
|
@@ -681,7 +699,7 @@ static VALUE Window_set_minimum_size(VALUE self, VALUE min_size)
|
|
|
681
699
|
/*
|
|
682
700
|
* Get the position of the window.
|
|
683
701
|
*
|
|
684
|
-
* @return [Integer,Integer] the x position and the y position
|
|
702
|
+
* @return [Array(Integer,Integer)] the x position and the y position
|
|
685
703
|
*
|
|
686
704
|
* @see #position=
|
|
687
705
|
*/
|
|
@@ -694,11 +712,11 @@ static VALUE Window_position(VALUE self)
|
|
|
694
712
|
* @overload position=(xy)
|
|
695
713
|
* Set the position of the window
|
|
696
714
|
*
|
|
697
|
-
* @param xy [
|
|
715
|
+
* @param xy [Array(Integer, Integer)] the x position and the y position,
|
|
698
716
|
* {SDL2::Window::POS_CENTERED} and {SDL2::Window::POS_UNDEFINED}
|
|
699
717
|
* are available.
|
|
700
718
|
*
|
|
701
|
-
* @return [
|
|
719
|
+
* @return [void]
|
|
702
720
|
*
|
|
703
721
|
* @see #position
|
|
704
722
|
*/
|
|
@@ -710,7 +728,7 @@ static VALUE Window_set_position(VALUE self, VALUE xy)
|
|
|
710
728
|
/*
|
|
711
729
|
* Get the size of the window.
|
|
712
730
|
*
|
|
713
|
-
* @return [
|
|
731
|
+
* @return [Array(Integer, Integer)] the width and the height
|
|
714
732
|
*
|
|
715
733
|
* @see size=
|
|
716
734
|
*/
|
|
@@ -723,9 +741,9 @@ static VALUE Window_size(VALUE self)
|
|
|
723
741
|
* @overload size=(size)
|
|
724
742
|
* Set the size of the window.
|
|
725
743
|
*
|
|
726
|
-
* @param
|
|
744
|
+
* @param size [Array(Integer, Integer)] new width and new height
|
|
727
745
|
*
|
|
728
|
-
* @return [
|
|
746
|
+
* @return [void]
|
|
729
747
|
*
|
|
730
748
|
* @see #size
|
|
731
749
|
*/
|
|
@@ -765,7 +783,7 @@ static VALUE Window_bordered(VALUE self)
|
|
|
765
783
|
* @param bordered [Boolean] true for bordered window, anad false for
|
|
766
784
|
* borderless window
|
|
767
785
|
*
|
|
768
|
-
* @return [
|
|
786
|
+
* @return [void]
|
|
769
787
|
*
|
|
770
788
|
* @see #bordered
|
|
771
789
|
*/
|
|
@@ -780,7 +798,7 @@ static VALUE Window_set_bordered(VALUE self, VALUE bordered)
|
|
|
780
798
|
* Set the title of the window.
|
|
781
799
|
*
|
|
782
800
|
* @param title [String] the title
|
|
783
|
-
* @return [
|
|
801
|
+
* @return [void]
|
|
784
802
|
*
|
|
785
803
|
* @see #title
|
|
786
804
|
*/
|
|
@@ -870,7 +888,7 @@ static VALUE Window_fullscreen_mode(VALUE self)
|
|
|
870
888
|
* @param flag [Integer] 0 for window mode, {SDL2::Window::Flags::FULLSCREEN} for
|
|
871
889
|
* fullscreen mode, and {SDL2::Flags::Window::FULLSCREEN_DESKTOP} for fullscreen
|
|
872
890
|
* at the current desktop resolution.
|
|
873
|
-
* @return [
|
|
891
|
+
* @return [void]
|
|
874
892
|
*
|
|
875
893
|
* @see #fullscreen_mode
|
|
876
894
|
*/
|
|
@@ -884,7 +902,7 @@ static VALUE Window_set_fullscreen_mode(VALUE self, VALUE flags)
|
|
|
884
902
|
/*
|
|
885
903
|
* Get the size of the drawable region.
|
|
886
904
|
*
|
|
887
|
-
* @return [
|
|
905
|
+
* @return [Array(Integer, Integer)] the width and height of the region
|
|
888
906
|
*/
|
|
889
907
|
static VALUE Window_gl_drawable_size(VALUE self)
|
|
890
908
|
{
|
|
@@ -962,7 +980,7 @@ static VALUE Window_debug_info(VALUE self)
|
|
|
962
980
|
*
|
|
963
981
|
* @!attribute [r] name
|
|
964
982
|
* The name of the display
|
|
965
|
-
* @return [
|
|
983
|
+
* @return [String]
|
|
966
984
|
*
|
|
967
985
|
*/
|
|
968
986
|
|
|
@@ -1322,6 +1340,54 @@ static VALUE Renderer_present(VALUE self)
|
|
|
1322
1340
|
return Qnil;
|
|
1323
1341
|
}
|
|
1324
1342
|
|
|
1343
|
+
/*
|
|
1344
|
+
* @overload read_pixels(rect, format)
|
|
1345
|
+
* Read pixels from the current rendering target.
|
|
1346
|
+
*
|
|
1347
|
+
* ## Remarks
|
|
1348
|
+
*
|
|
1349
|
+
* **WARNING**: This is a very slow operation, and should not be used frequently.
|
|
1350
|
+
* If you're using this on the main rendering target, it should be called after
|
|
1351
|
+
* rendering and before {#present}.
|
|
1352
|
+
*
|
|
1353
|
+
* @param [SDL2::Rect,nil] rect the area to read, or nil for the entire target
|
|
1354
|
+
* @param [SDL2::PixelFormat,Integer] format the desired pixel format
|
|
1355
|
+
* (0 to use the format of the rendering target)
|
|
1356
|
+
* @return [String] raw pixel data as a binary string
|
|
1357
|
+
*/
|
|
1358
|
+
static VALUE Renderer_read_pixels(VALUE self, VALUE rect, VALUE format)
|
|
1359
|
+
{
|
|
1360
|
+
SDL_Renderer* renderer = Get_SDL_Renderer(self);
|
|
1361
|
+
SDL_Rect sdl_rect;
|
|
1362
|
+
SDL_Rect* rect_ptr = NULL;
|
|
1363
|
+
Uint32 fmt = uint32_for_format(format);
|
|
1364
|
+
int w, h, pitch;
|
|
1365
|
+
void* pixels;
|
|
1366
|
+
|
|
1367
|
+
if (rect != Qnil) {
|
|
1368
|
+
sdl_rect = *Get_SDL_Rect(rect);
|
|
1369
|
+
rect_ptr = &sdl_rect;
|
|
1370
|
+
w = sdl_rect.w;
|
|
1371
|
+
h = sdl_rect.h;
|
|
1372
|
+
} else {
|
|
1373
|
+
HANDLE_ERROR(SDL_GetRendererOutputSize(renderer, &w, &h));
|
|
1374
|
+
}
|
|
1375
|
+
|
|
1376
|
+
if (fmt == 0) {
|
|
1377
|
+
SDL_RendererInfo info;
|
|
1378
|
+
HANDLE_ERROR(SDL_GetRendererInfo(renderer, &info));
|
|
1379
|
+
pitch = w * SDL_BYTESPERPIXEL(info.texture_formats[0]);
|
|
1380
|
+
} else {
|
|
1381
|
+
pitch = w * SDL_BYTESPERPIXEL(fmt);
|
|
1382
|
+
}
|
|
1383
|
+
|
|
1384
|
+
pixels = ALLOCA_N(char, pitch * h);
|
|
1385
|
+
|
|
1386
|
+
HANDLE_ERROR(SDL_RenderReadPixels(renderer, rect_ptr, fmt, pixels, pitch));
|
|
1387
|
+
|
|
1388
|
+
return rb_str_new(pixels, pitch * h);
|
|
1389
|
+
}
|
|
1390
|
+
|
|
1325
1391
|
/*
|
|
1326
1392
|
* Crear the rendering target with the drawing color.
|
|
1327
1393
|
* @return [nil]
|
|
@@ -1336,7 +1402,7 @@ static VALUE Renderer_clear(VALUE self)
|
|
|
1336
1402
|
|
|
1337
1403
|
/*
|
|
1338
1404
|
* Get the color used for drawing operations
|
|
1339
|
-
* @return [
|
|
1405
|
+
* @return [Array(Integer,Integer,Integer,Integer)]
|
|
1340
1406
|
* red, green, blue, and alpha components of the drawing color
|
|
1341
1407
|
* (all components are more than or equal to 0 and less than and equal to 255)
|
|
1342
1408
|
*
|
|
@@ -1364,12 +1430,10 @@ static VALUE Renderer_draw_color(VALUE self)
|
|
|
1364
1430
|
* * {#fill_rect}
|
|
1365
1431
|
* * {#clear}
|
|
1366
1432
|
*
|
|
1367
|
-
* @param [
|
|
1368
|
-
* red, green, and
|
|
1369
|
-
* @param [[Integer, Integer, Integer, Integer]] color
|
|
1370
|
-
* red, green, blue, and alpha components used for drawing
|
|
1433
|
+
* @param [Array<Integer>] color
|
|
1434
|
+
* red, green, blue, and optionally alpha components used for drawing
|
|
1371
1435
|
*
|
|
1372
|
-
* @return [
|
|
1436
|
+
* @return [Array<Integer>]
|
|
1373
1437
|
*
|
|
1374
1438
|
* @see #draw_color
|
|
1375
1439
|
*/
|
|
@@ -1514,7 +1578,8 @@ static VALUE Renderer_clip_rect(VALUE self)
|
|
|
1514
1578
|
*
|
|
1515
1579
|
* Set the clip rectangle for the current target.
|
|
1516
1580
|
*
|
|
1517
|
-
* @
|
|
1581
|
+
* @param rect [SDL2::Rect]
|
|
1582
|
+
* @return [void]
|
|
1518
1583
|
* @see #clip_rect
|
|
1519
1584
|
*/
|
|
1520
1585
|
static VALUE Renderer_set_clip_rect(VALUE self, VALUE rect)
|
|
@@ -1538,7 +1603,7 @@ static VALUE Render_clip_enabled_p(VALUE self)
|
|
|
1538
1603
|
/*
|
|
1539
1604
|
* Get device indepndent resolution for rendering.
|
|
1540
1605
|
*
|
|
1541
|
-
* @return [
|
|
1606
|
+
* @return [Array(Integer, Integer)] the logical width and height
|
|
1542
1607
|
* @see #logical_size=
|
|
1543
1608
|
*/
|
|
1544
1609
|
static VALUE Renderer_logical_size(VALUE self)
|
|
@@ -1553,8 +1618,8 @@ static VALUE Renderer_logical_size(VALUE self)
|
|
|
1553
1618
|
*
|
|
1554
1619
|
* Set a device indepndent resolution for rendering.
|
|
1555
1620
|
*
|
|
1556
|
-
* @param w_and_h [
|
|
1557
|
-
* @return [
|
|
1621
|
+
* @param w_and_h [Array(Integer, Integer)] the width and height of the logical resolution
|
|
1622
|
+
* @return [void]
|
|
1558
1623
|
* @see #logical_size
|
|
1559
1624
|
*/
|
|
1560
1625
|
static VALUE Renderer_set_logical_size(VALUE self, VALUE wh)
|
|
@@ -1568,7 +1633,7 @@ static VALUE Renderer_set_logical_size(VALUE self, VALUE wh)
|
|
|
1568
1633
|
/*
|
|
1569
1634
|
* Get the drawing scale for the current target.
|
|
1570
1635
|
*
|
|
1571
|
-
* @return [
|
|
1636
|
+
* @return [Array(Integer, Integer)] horizontal and vertical scale factor
|
|
1572
1637
|
* @see #scale=
|
|
1573
1638
|
*/
|
|
1574
1639
|
static VALUE Renderer_scale(VALUE self)
|
|
@@ -1590,8 +1655,8 @@ static VALUE Renderer_scale(VALUE self)
|
|
|
1590
1655
|
* it will be handled using the appropriate
|
|
1591
1656
|
* quality hints. For best results use integer scaling factors.
|
|
1592
1657
|
*
|
|
1593
|
-
* @param scaleX_and_scaleY [
|
|
1594
|
-
* @return [
|
|
1658
|
+
* @param scaleX_and_scaleY [Array(Float, Float)] the horizontal and vertical scaling factors
|
|
1659
|
+
* @return [void]
|
|
1595
1660
|
* @see #scale
|
|
1596
1661
|
*/
|
|
1597
1662
|
static VALUE Renderer_set_scale(VALUE self, VALUE xy)
|
|
@@ -1621,7 +1686,7 @@ static VALUE Renderer_viewport(VALUE self)
|
|
|
1621
1686
|
* Set the drawing area for rendering on the current target.
|
|
1622
1687
|
*
|
|
1623
1688
|
* @param area [SDL2::Rect,nil] the drawing area, or nil to set the viewport to the entire target
|
|
1624
|
-
* @return [
|
|
1689
|
+
* @return [void]
|
|
1625
1690
|
* @see #viewport
|
|
1626
1691
|
*/
|
|
1627
1692
|
static VALUE Renderer_set_viewport(VALUE self, VALUE rect)
|
|
@@ -1643,7 +1708,7 @@ static VALUE Renderer_support_render_target_p(VALUE self)
|
|
|
1643
1708
|
/*
|
|
1644
1709
|
* Get the output size of a rendering context.
|
|
1645
1710
|
*
|
|
1646
|
-
* @return [
|
|
1711
|
+
* @return [Array(Integer, Integer)] the width and the height
|
|
1647
1712
|
*/
|
|
1648
1713
|
static VALUE Renderer_output_size(VALUE self)
|
|
1649
1714
|
{
|
|
@@ -1666,7 +1731,7 @@ static VALUE Renderer_output_size(VALUE self)
|
|
|
1666
1731
|
* @param [SDL2::Texture,nil] target the targeted texture, or nil
|
|
1667
1732
|
* for the default render target(i.e. screen)
|
|
1668
1733
|
*
|
|
1669
|
-
* @return [
|
|
1734
|
+
* @return [void]
|
|
1670
1735
|
*
|
|
1671
1736
|
* @see #render_target
|
|
1672
1737
|
*/
|
|
@@ -1776,6 +1841,8 @@ static VALUE Renderer_debug_info(VALUE self)
|
|
|
1776
1841
|
/*
|
|
1777
1842
|
* Destroy the texture and deallocate memory.
|
|
1778
1843
|
*
|
|
1844
|
+
* @return [void]
|
|
1845
|
+
*
|
|
1779
1846
|
* @see #destroy?
|
|
1780
1847
|
*/
|
|
1781
1848
|
static VALUE Texture_destroy(VALUE self)
|
|
@@ -1803,7 +1870,7 @@ static VALUE Texture_blend_mode(VALUE self)
|
|
|
1803
1870
|
* Set the blending model of the texture.
|
|
1804
1871
|
*
|
|
1805
1872
|
* @param mode [Integer] blending mode
|
|
1806
|
-
* @return [
|
|
1873
|
+
* @return [void]
|
|
1807
1874
|
*
|
|
1808
1875
|
* @see #blend_mode
|
|
1809
1876
|
*/
|
|
@@ -1833,7 +1900,7 @@ static VALUE Texture_alpha_mod(VALUE self)
|
|
|
1833
1900
|
*
|
|
1834
1901
|
* @param alpha [Integer] the alpha value multiplied into copy operation,
|
|
1835
1902
|
* from 0 to 255
|
|
1836
|
-
* @return [
|
|
1903
|
+
* @return [void]
|
|
1837
1904
|
*
|
|
1838
1905
|
* @see #alpha_mod
|
|
1839
1906
|
*/
|
|
@@ -1846,7 +1913,7 @@ static VALUE Texture_set_alpha_mod(VALUE self, VALUE alpha)
|
|
|
1846
1913
|
/*
|
|
1847
1914
|
* Get an additional color value used in render copy operations.
|
|
1848
1915
|
*
|
|
1849
|
-
* @return [
|
|
1916
|
+
* @return [Array(Integer, Integer, Integer)] the current red, green, and blue
|
|
1850
1917
|
* color value.
|
|
1851
1918
|
*/
|
|
1852
1919
|
static VALUE Texture_color_mod(VALUE self)
|
|
@@ -1860,9 +1927,9 @@ static VALUE Texture_color_mod(VALUE self)
|
|
|
1860
1927
|
* @overload color_mod=(rgb)
|
|
1861
1928
|
* Set an additional color value used in render copy operations.
|
|
1862
1929
|
*
|
|
1863
|
-
* @param rgb [
|
|
1930
|
+
* @param rgb [Array(Integer, Integer, Integer)] the red, green, and blue
|
|
1864
1931
|
* color value multiplied into copy operations.
|
|
1865
|
-
* @return [
|
|
1932
|
+
* @return [void]
|
|
1866
1933
|
*/
|
|
1867
1934
|
static VALUE Texture_set_color_mod(VALUE self, VALUE rgb)
|
|
1868
1935
|
{
|
|
@@ -2018,7 +2085,7 @@ static VALUE Surface_s_save_bmp(VALUE self, VALUE src, VALUE fname)
|
|
|
2018
2085
|
}
|
|
2019
2086
|
|
|
2020
2087
|
/*
|
|
2021
|
-
* @overload from_string(string, width,
|
|
2088
|
+
* @overload from_string(string, width, height, depth, pitch=nil, rmask=nil, gmask=nil, bmask=nil, amask=nil)
|
|
2022
2089
|
*
|
|
2023
2090
|
* Create a RGB surface from pixel data as String object.
|
|
2024
2091
|
*
|
|
@@ -2046,6 +2113,7 @@ static VALUE Surface_s_from_string(int argc, VALUE* argv, VALUE self)
|
|
|
2046
2113
|
SDL_Surface* surface;
|
|
2047
2114
|
void* pixels;
|
|
2048
2115
|
Surface* s;
|
|
2116
|
+
VALUE obj;
|
|
2049
2117
|
|
|
2050
2118
|
rb_scan_args(argc, argv, "45", &string, &width, &height, &depth,
|
|
2051
2119
|
&pitch, &Rmask, &Gmask, &Bmask, &Amask);
|
|
@@ -2072,10 +2140,10 @@ static VALUE Surface_s_from_string(int argc, VALUE* argv, VALUE self)
|
|
|
2072
2140
|
|
|
2073
2141
|
RB_GC_GUARD(string);
|
|
2074
2142
|
|
|
2075
|
-
|
|
2143
|
+
obj = TypedData_Make_Struct(cSurface, Surface, &Surface_data_type, s);
|
|
2076
2144
|
s->surface = surface;
|
|
2077
2145
|
s->need_to_free_pixels = 1;
|
|
2078
|
-
return
|
|
2146
|
+
return obj;
|
|
2079
2147
|
}
|
|
2080
2148
|
|
|
2081
2149
|
/*
|
|
@@ -2114,7 +2182,7 @@ static VALUE Surface_blend_mode(VALUE self)
|
|
|
2114
2182
|
* Set the blending mode of the surface used for blit operations.
|
|
2115
2183
|
*
|
|
2116
2184
|
* @param mode [Integer] the blending mode
|
|
2117
|
-
* @return [
|
|
2185
|
+
* @return [void]
|
|
2118
2186
|
* @see #blend_mode
|
|
2119
2187
|
*/
|
|
2120
2188
|
static VALUE Surface_set_blend_mode(VALUE self, VALUE mode)
|
|
@@ -2241,7 +2309,7 @@ static VALUE Surface_bytes_per_pixel(VALUE self)
|
|
|
2241
2309
|
*
|
|
2242
2310
|
* @param x [Integer] the x coordinate
|
|
2243
2311
|
* @param y [Integer] the y coordinate
|
|
2244
|
-
* @return [
|
|
2312
|
+
* @return [Array(Integer, Integer, Integer, Integer)]
|
|
2245
2313
|
* the red, green, blue, and alpha component of the specified pixel.
|
|
2246
2314
|
*
|
|
2247
2315
|
*/
|
|
@@ -2301,7 +2369,7 @@ static VALUE Surface_unset_color_key(VALUE self)
|
|
|
2301
2369
|
* the color key, pixel value (see {#pixel}) or pixel color (array of
|
|
2302
2370
|
* three or four integer elements).
|
|
2303
2371
|
*
|
|
2304
|
-
* @return [
|
|
2372
|
+
* @return [Integer, Array<Integer>] value
|
|
2305
2373
|
*
|
|
2306
2374
|
* @see #color_key
|
|
2307
2375
|
* @see #unset_color_key
|
|
@@ -2429,12 +2497,14 @@ static VALUE Surface_s_new(int argc, VALUE* argv, VALUE self)
|
|
|
2429
2497
|
#define FIELD_ACCESSOR(classname, typename, field) \
|
|
2430
2498
|
static VALUE classname##_##field(VALUE self) \
|
|
2431
2499
|
{ \
|
|
2432
|
-
typename* r;
|
|
2500
|
+
typename* r; \
|
|
2501
|
+
TypedData_Get_Struct(self, typename, &typename##_data_type, r); \
|
|
2433
2502
|
return INT2NUM(r->field); \
|
|
2434
2503
|
} \
|
|
2435
2504
|
static VALUE classname##_set_##field(VALUE self, VALUE val) \
|
|
2436
2505
|
{ \
|
|
2437
|
-
typename* r;
|
|
2506
|
+
typename* r; \
|
|
2507
|
+
TypedData_Get_Struct(self, typename, &typename##_data_type, r); \
|
|
2438
2508
|
r->field = NUM2INT(val); return val; \
|
|
2439
2509
|
}
|
|
2440
2510
|
|
|
@@ -2462,16 +2532,21 @@ static VALUE Surface_s_new(int argc, VALUE* argv, VALUE self)
|
|
|
2462
2532
|
* Height of the rectangle
|
|
2463
2533
|
* @return [Integer]
|
|
2464
2534
|
*
|
|
2465
|
-
* @!method self.[](
|
|
2535
|
+
* @!method self.[](x, y, w, h)
|
|
2466
2536
|
* Alias of new. See {#initialize}.
|
|
2537
|
+
*
|
|
2538
|
+
* @param x [Integer] X coordiante of the left-top point of the rectangle
|
|
2539
|
+
* @param y [Integer] Y coordiante of the left-top point of the rectangle
|
|
2540
|
+
* @param w [Integer] Width of the rectangle
|
|
2541
|
+
* @param h [Integer] Height of the rectangle
|
|
2467
2542
|
* @return [SDL2::Rect]
|
|
2468
2543
|
*/
|
|
2469
2544
|
static VALUE Rect_s_allocate(VALUE klass)
|
|
2470
2545
|
{
|
|
2471
|
-
SDL_Rect* rect
|
|
2546
|
+
SDL_Rect* rect;
|
|
2547
|
+
VALUE obj = TypedData_Make_Struct(klass, SDL_Rect, &SDL_Rect_data_type, rect);
|
|
2472
2548
|
rect->x = rect->y = rect->w = rect->h = 0;
|
|
2473
|
-
|
|
2474
|
-
return Data_Wrap_Struct(cRect, 0, free, rect);
|
|
2549
|
+
return obj;
|
|
2475
2550
|
}
|
|
2476
2551
|
|
|
2477
2552
|
/*
|
|
@@ -2499,7 +2574,7 @@ static VALUE Rect_initialize(int argc, VALUE* argv, VALUE self)
|
|
|
2499
2574
|
/* do nothing*/
|
|
2500
2575
|
} else if (argc == 4) {
|
|
2501
2576
|
SDL_Rect* rect;
|
|
2502
|
-
|
|
2577
|
+
TypedData_Get_Struct(self, SDL_Rect, &SDL_Rect_data_type, rect);
|
|
2503
2578
|
rect->x = NUM2INT(x); rect->y = NUM2INT(y);
|
|
2504
2579
|
rect->w = NUM2INT(w); rect->h = NUM2INT(h);
|
|
2505
2580
|
} else {
|
|
@@ -2574,7 +2649,7 @@ static VALUE Rect_union(VALUE self, VALUE other)
|
|
|
2574
2649
|
static VALUE Point_s_allocate(VALUE klass)
|
|
2575
2650
|
{
|
|
2576
2651
|
SDL_Point* point;
|
|
2577
|
-
return
|
|
2652
|
+
return TypedData_Make_Struct(klass, SDL_Point, &SDL_Point_data_type, point);
|
|
2578
2653
|
}
|
|
2579
2654
|
|
|
2580
2655
|
/*
|
|
@@ -2714,6 +2789,8 @@ PIXELFORMAT_ATTR_READER(fourcc_p, SDL_ISPIXELFORMAT_FOURCC, INT2BOOL);
|
|
|
2714
2789
|
* @overload ==(other)
|
|
2715
2790
|
* Return true if two pixel format is the same format.
|
|
2716
2791
|
*
|
|
2792
|
+
* @param other [SDL2::PixelFormat] other PixelFormat object
|
|
2793
|
+
*
|
|
2717
2794
|
* @return [Boolean]
|
|
2718
2795
|
*/
|
|
2719
2796
|
static VALUE PixelFormat_eq(VALUE self, VALUE other)
|
|
@@ -2833,45 +2910,45 @@ void rubysdl2_init_video(void)
|
|
|
2833
2910
|
#endif
|
|
2834
2911
|
rb_define_method(cWindow, "gl_swap", Window_gl_swap, 0);
|
|
2835
2912
|
|
|
2836
|
-
/* Indicate that you don't care what the window position is */
|
|
2913
|
+
/* @return [Integer] Indicate that you don't care what the window position is */
|
|
2837
2914
|
rb_define_const(cWindow, "POS_CENTERED", INT2NUM(SDL_WINDOWPOS_CENTERED));
|
|
2838
|
-
/* Indicate that the window position should be centered */
|
|
2915
|
+
/* @return [Integer] Indicate that the window position should be centered */
|
|
2839
2916
|
rb_define_const(cWindow, "POS_UNDEFINED", INT2NUM(SDL_WINDOWPOS_UNDEFINED));
|
|
2840
2917
|
|
|
2841
2918
|
mWindowFlags = rb_define_module_under(cWindow, "Flags");
|
|
2842
2919
|
/* define(`DEFINE_WINDOW_FLAGS_CONST',`rb_define_const(mWindowFlags, "$1", UINT2NUM(SDL_WINDOW_$1))') */
|
|
2843
|
-
/* fullscreen window */
|
|
2920
|
+
/* @return [Integer] fullscreen window */
|
|
2844
2921
|
DEFINE_WINDOW_FLAGS_CONST(FULLSCREEN);
|
|
2845
|
-
/* fullscreen window at the current desktop resolution */
|
|
2922
|
+
/* @return [Integer] fullscreen window at the current desktop resolution */
|
|
2846
2923
|
DEFINE_WINDOW_FLAGS_CONST(FULLSCREEN_DESKTOP);
|
|
2847
|
-
/* window usable with OpenGL context */
|
|
2924
|
+
/* @return [Integer] window usable with OpenGL context */
|
|
2848
2925
|
DEFINE_WINDOW_FLAGS_CONST(OPENGL);
|
|
2849
|
-
/* window is visible */
|
|
2926
|
+
/* @return [Integer] window is visible */
|
|
2850
2927
|
DEFINE_WINDOW_FLAGS_CONST(SHOWN);
|
|
2851
|
-
/* window is not visible */
|
|
2928
|
+
/* @return [Integer] window is not visible */
|
|
2852
2929
|
DEFINE_WINDOW_FLAGS_CONST(HIDDEN);
|
|
2853
|
-
/* no window decoration */
|
|
2930
|
+
/* @return [Integer] no window decoration */
|
|
2854
2931
|
DEFINE_WINDOW_FLAGS_CONST(BORDERLESS);
|
|
2855
|
-
/* window is resizable */
|
|
2932
|
+
/* @return [Integer] window is resizable */
|
|
2856
2933
|
DEFINE_WINDOW_FLAGS_CONST(RESIZABLE);
|
|
2857
|
-
/* window is minimized */
|
|
2934
|
+
/* @return [Integer] window is minimized */
|
|
2858
2935
|
DEFINE_WINDOW_FLAGS_CONST(MINIMIZED);
|
|
2859
|
-
/* window is maximized */
|
|
2936
|
+
/* @return [Integer] window is maximized */
|
|
2860
2937
|
DEFINE_WINDOW_FLAGS_CONST(MAXIMIZED);
|
|
2861
|
-
/* window has grabbed input focus */
|
|
2938
|
+
/* @return [Integer] window has grabbed input focus */
|
|
2862
2939
|
DEFINE_WINDOW_FLAGS_CONST(INPUT_GRABBED);
|
|
2863
|
-
/* window has input focus */
|
|
2940
|
+
/* @return [Integer] window has input focus */
|
|
2864
2941
|
DEFINE_WINDOW_FLAGS_CONST(INPUT_FOCUS);
|
|
2865
|
-
/* window has mouse focus */
|
|
2942
|
+
/* @return [Integer] window has mouse focus */
|
|
2866
2943
|
DEFINE_WINDOW_FLAGS_CONST(MOUSE_FOCUS);
|
|
2867
|
-
/* window is not created by SDL */
|
|
2944
|
+
/* @return [Integer] window is not created by SDL */
|
|
2868
2945
|
DEFINE_WINDOW_FLAGS_CONST(FOREIGN);
|
|
2869
2946
|
#ifdef HAVE_CONST_SDL_WINDOW_ALLOW_HIGHDPI
|
|
2870
|
-
/* window should be created in high-DPI mode if supported (>= SDL 2.0.1)*/
|
|
2947
|
+
/* @return [Integer] window should be created in high-DPI mode if supported (>= SDL 2.0.1)*/
|
|
2871
2948
|
DEFINE_WINDOW_FLAGS_CONST(ALLOW_HIGHDPI);
|
|
2872
2949
|
#endif
|
|
2873
2950
|
#ifdef HAVE_CONST_SDL_WINDOW_MOUSE_CAPTURE
|
|
2874
|
-
/* window has mouse caputred (>= SDL 2.0.4) */
|
|
2951
|
+
/* @return [Integer] window has mouse caputred (>= SDL 2.0.4) */
|
|
2875
2952
|
DEFINE_WINDOW_FLAGS_CONST(MOUSE_CAPTURE);
|
|
2876
2953
|
#endif
|
|
2877
2954
|
|
|
@@ -2910,6 +2987,7 @@ void rubysdl2_init_video(void)
|
|
|
2910
2987
|
rb_define_method(cRenderer, "copy", Renderer_copy, 3);
|
|
2911
2988
|
rb_define_method(cRenderer, "copy_ex", Renderer_copy_ex, 6);
|
|
2912
2989
|
rb_define_method(cRenderer, "present", Renderer_present, 0);
|
|
2990
|
+
rb_define_method(cRenderer, "read_pixels", Renderer_read_pixels, 2);
|
|
2913
2991
|
rb_define_method(cRenderer, "draw_color",Renderer_draw_color, 0);
|
|
2914
2992
|
rb_define_method(cRenderer, "draw_color=",Renderer_set_draw_color, 1);
|
|
2915
2993
|
rb_define_method(cRenderer, "clear", Renderer_clear, 0);
|
|
@@ -2941,33 +3019,33 @@ void rubysdl2_init_video(void)
|
|
|
2941
3019
|
mRendererFlags = rb_define_module_under(cRenderer, "Flags");
|
|
2942
3020
|
|
|
2943
3021
|
/* define(`DEFINE_RENDERER_FLAGS_CONST',`rb_define_const(mRendererFlags, "$1", UINT2NUM(SDL_RENDERER_$1))') */
|
|
2944
|
-
/* the renderer is a software fallback */
|
|
3022
|
+
/* @return [Integer] the renderer is a software fallback */
|
|
2945
3023
|
DEFINE_RENDERER_FLAGS_CONST(SOFTWARE);
|
|
2946
|
-
/* the renderer uses hardware acceleration */
|
|
3024
|
+
/* @return [Integer] the renderer uses hardware acceleration */
|
|
2947
3025
|
DEFINE_RENDERER_FLAGS_CONST(ACCELERATED);
|
|
2948
3026
|
#ifdef HAVE_CONST_SDL_RENDERER_PRESENTVSYNC
|
|
2949
|
-
/* present is synchronized with the refresh rate */
|
|
3027
|
+
/* @return [Integer] present is synchronized with the refresh rate */
|
|
2950
3028
|
DEFINE_RENDERER_FLAGS_CONST(PRESENTVSYNC);
|
|
2951
3029
|
#endif
|
|
2952
|
-
/* the renderer supports rendering to texture */
|
|
3030
|
+
/* @return [Integer] the renderer supports rendering to texture */
|
|
2953
3031
|
DEFINE_RENDERER_FLAGS_CONST(TARGETTEXTURE);
|
|
2954
3032
|
/* define(`DEFINE_SDL_FLIP_CONST',`rb_define_const(cRenderer, "FLIP_$1", INT2FIX(SDL_FLIP_$1))') */
|
|
2955
|
-
/* Do not flip, used in {Renderer#copy_ex} */
|
|
3033
|
+
/* @return [Integer] Do not flip, used in {Renderer#copy_ex} */
|
|
2956
3034
|
DEFINE_SDL_FLIP_CONST(NONE);
|
|
2957
|
-
/* Flip horizontally, used in {Renderer#copy_ex} */
|
|
3035
|
+
/* @return [Integer] Flip horizontally, used in {Renderer#copy_ex} */
|
|
2958
3036
|
DEFINE_SDL_FLIP_CONST(HORIZONTAL);
|
|
2959
|
-
/* Flip vertically, used in {Renderer#copy_ex} */
|
|
3037
|
+
/* @return [Integer] Flip vertically, used in {Renderer#copy_ex} */
|
|
2960
3038
|
DEFINE_SDL_FLIP_CONST(VERTICAL);
|
|
2961
3039
|
|
|
2962
3040
|
mBlendMode = rb_define_module_under(mSDL2, "BlendMode");
|
|
2963
3041
|
/* define(`DEFINE_BLENDMODE_CONST',`rb_define_const(mBlendMode, "$1", INT2FIX(SDL_BLENDMODE_$1))') */
|
|
2964
|
-
/* no blending (dstRGBA = srcRGBA) */
|
|
3042
|
+
/* @return [Integer] no blending (dstRGBA = srcRGBA) */
|
|
2965
3043
|
DEFINE_BLENDMODE_CONST(NONE);
|
|
2966
|
-
/* alpha blending (dstRGB = (srcRGB * srcA) + (dstRGB * (1-srcA), dstA = srcA + (dstA * (1-srcA)))*/
|
|
3044
|
+
/* @return [Integer] alpha blending (dstRGB = (srcRGB * srcA) + (dstRGB * (1-srcA), dstA = srcA + (dstA * (1-srcA)))*/
|
|
2967
3045
|
DEFINE_BLENDMODE_CONST(BLEND);
|
|
2968
|
-
/* additive blending (dstRGB = (srcRGB * srcA) + dstRGB, dstA = dstA) */
|
|
3046
|
+
/* @return [Integer] additive blending (dstRGB = (srcRGB * srcA) + dstRGB, dstA = dstA) */
|
|
2969
3047
|
DEFINE_BLENDMODE_CONST(ADD);
|
|
2970
|
-
/* color modulate (multiplicative) (dstRGB = srcRGB * dstRGB, dstA = dstA) */
|
|
3048
|
+
/* @return [Integer] color modulate (multiplicative) (dstRGB = srcRGB * dstRGB, dstA = dstA) */
|
|
2971
3049
|
DEFINE_BLENDMODE_CONST(MOD);
|
|
2972
3050
|
|
|
2973
3051
|
cTexture = rb_define_class_under(mSDL2, "Texture", rb_cObject);
|
|
@@ -2985,11 +3063,11 @@ void rubysdl2_init_video(void)
|
|
|
2985
3063
|
rb_define_method(cTexture, "inspect", Texture_inspect, 0);
|
|
2986
3064
|
rb_define_method(cTexture, "debug_info", Texture_debug_info, 0);
|
|
2987
3065
|
/* define(`DEFINE_TEXTUREAH_ACCESS_CONST', `rb_define_const(cTexture, "ACCESS_$1", INT2NUM(SDL_TEXTUREACCESS_$1))') */
|
|
2988
|
-
/* texture access pattern - changes rarely, not lockable */
|
|
3066
|
+
/* @return [Integer] texture access pattern code - changes rarely, not lockable */
|
|
2989
3067
|
DEFINE_TEXTUREAH_ACCESS_CONST(STATIC);
|
|
2990
|
-
/* texture access pattern - changes frequently, lockable */
|
|
3068
|
+
/* @return [Integer] texture access pattern code - changes frequently, lockable */
|
|
2991
3069
|
DEFINE_TEXTUREAH_ACCESS_CONST(STREAMING);
|
|
2992
|
-
/* texture access pattern - can be used as a render target */
|
|
3070
|
+
/* @return [Integer] texture access pattern code - can be used as a render target */
|
|
2993
3071
|
DEFINE_TEXTUREAH_ACCESS_CONST(TARGET);
|
|
2994
3072
|
|
|
2995
3073
|
|
|
@@ -3013,7 +3091,7 @@ void rubysdl2_init_video(void)
|
|
|
3013
3091
|
rb_define_method(cSurface, "pixel_color", Surface_pixel_color, 2);
|
|
3014
3092
|
rb_define_method(cSurface, "color_key", Surface_color_key, 0);
|
|
3015
3093
|
rb_define_method(cSurface, "color_key=", Surface_set_color_key, 1);
|
|
3016
|
-
rb_define_method(cSurface, "unset_color_key",
|
|
3094
|
+
rb_define_method(cSurface, "unset_color_key", Surface_unset_color_key, 0);
|
|
3017
3095
|
rb_define_method(cSurface, "pixels", Surface_pixels, 0);
|
|
3018
3096
|
rb_define_method(cSurface, "pitch", Surface_pitch, 0);
|
|
3019
3097
|
rb_define_method(cSurface, "bits_per_pixel", Surface_bits_per_pixel, 0);
|
|
@@ -3065,7 +3143,8 @@ void rubysdl2_init_video(void)
|
|
|
3065
3143
|
rb_define_method(cPixelFormat, "==", PixelFormat_eq, 1);
|
|
3066
3144
|
|
|
3067
3145
|
mPixelType = rb_define_module_under(cPixelFormat, "Type");
|
|
3068
|
-
/* define(`DEFINE_PIXELTYPE_CONST'
|
|
3146
|
+
/* define(`DEFINE_PIXELTYPE_CONST',`/$8* @return [Integer] *$8/
|
|
3147
|
+
rb_define_const(mPixelType, "$1", UINT2NUM(SDL_PIXELTYPE_$1))') */
|
|
3069
3148
|
DEFINE_PIXELTYPE_CONST(UNKNOWN);
|
|
3070
3149
|
DEFINE_PIXELTYPE_CONST(INDEX1);
|
|
3071
3150
|
DEFINE_PIXELTYPE_CONST(INDEX4);
|
|
@@ -3080,12 +3159,17 @@ void rubysdl2_init_video(void)
|
|
|
3080
3159
|
DEFINE_PIXELTYPE_CONST(ARRAYF32);
|
|
3081
3160
|
|
|
3082
3161
|
mBitmapOrder = rb_define_module_under(cPixelFormat, "BitmapOrder");
|
|
3162
|
+
/* @return [Integer] */
|
|
3083
3163
|
rb_define_const(mBitmapOrder, "NONE", UINT2NUM(SDL_BITMAPORDER_NONE));
|
|
3164
|
+
/* @return [Integer] */
|
|
3084
3165
|
rb_define_const(mBitmapOrder, "O_1234", UINT2NUM(SDL_BITMAPORDER_1234));
|
|
3166
|
+
/* @return [Integer] */
|
|
3085
3167
|
rb_define_const(mBitmapOrder, "O_4321", UINT2NUM(SDL_BITMAPORDER_4321));
|
|
3086
3168
|
|
|
3087
3169
|
mPackedOrder = rb_define_module_under(cPixelFormat, "PackedOrder");
|
|
3088
|
-
/*
|
|
3170
|
+
/*
|
|
3171
|
+
define(`DEFINE_PACKEDORDER_CONST',`/$8* @return [Integer] *$8/
|
|
3172
|
+
rb_define_const(mPackedOrder, "$1", UINT2NUM(SDL_PACKEDORDER_$1))') */
|
|
3089
3173
|
DEFINE_PACKEDORDER_CONST(NONE);
|
|
3090
3174
|
DEFINE_PACKEDORDER_CONST(XRGB);
|
|
3091
3175
|
DEFINE_PACKEDORDER_CONST(RGBX);
|
|
@@ -3097,7 +3181,8 @@ void rubysdl2_init_video(void)
|
|
|
3097
3181
|
DEFINE_PACKEDORDER_CONST(BGRA);
|
|
3098
3182
|
|
|
3099
3183
|
mArrayOrder = rb_define_module_under(cPixelFormat, "ArrayOrder");
|
|
3100
|
-
/* define(`DEFINE_ARRAYORDER_CONST'
|
|
3184
|
+
/* define(`DEFINE_ARRAYORDER_CONST',`/$8* @return [Integer] *$8/
|
|
3185
|
+
rb_define_const(mArrayOrder, "$1", UINT2NUM(SDL_ARRAYORDER_$1))') */
|
|
3101
3186
|
DEFINE_ARRAYORDER_CONST(NONE);
|
|
3102
3187
|
DEFINE_ARRAYORDER_CONST(RGB);
|
|
3103
3188
|
DEFINE_ARRAYORDER_CONST(RGBA);
|
|
@@ -3107,7 +3192,9 @@ void rubysdl2_init_video(void)
|
|
|
3107
3192
|
DEFINE_ARRAYORDER_CONST(ABGR);
|
|
3108
3193
|
|
|
3109
3194
|
mPackedLayout = rb_define_module_under(cPixelFormat, "PackedLayout");
|
|
3110
|
-
/* define(`DEFINE_PACKEDLAYOUT_CONST'
|
|
3195
|
+
/* define(`DEFINE_PACKEDLAYOUT_CONST',`/$8* @return [Integer] *$8/
|
|
3196
|
+
rb_define_const(mPackedLayout, "L_$1", UINT2NUM(SDL_PACKEDLAYOUT_$1))') */
|
|
3197
|
+
/* @return [Integer] */
|
|
3111
3198
|
rb_define_const(mPackedLayout, "NONE", UINT2NUM(SDL_PACKEDLAYOUT_NONE));
|
|
3112
3199
|
DEFINE_PACKEDLAYOUT_CONST(332);
|
|
3113
3200
|
DEFINE_PACKEDLAYOUT_CONST(4444);
|
|
@@ -3120,17 +3207,17 @@ void rubysdl2_init_video(void)
|
|
|
3120
3207
|
|
|
3121
3208
|
{
|
|
3122
3209
|
VALUE formats = rb_ary_new();
|
|
3123
|
-
/* -: Array of all available formats */
|
|
3210
|
+
/* -: @return [Array<SDL2::PixelFormat>] array of all available formats */
|
|
3124
3211
|
rb_define_const(cPixelFormat, "FORMATS", formats);
|
|
3125
3212
|
/* define(`DEFINE_PIXELFORMAT_CONST',`do {
|
|
3126
3213
|
VALUE format = PixelFormat_new(SDL_PIXELFORMAT_$1);
|
|
3127
|
-
$2
|
|
3214
|
+
/$8* -: @return [SDL2::PixelFormat] $2 *$8/
|
|
3128
3215
|
rb_define_const(cPixelFormat, "$1", format);
|
|
3129
3216
|
rb_ary_push(formats, format);
|
|
3130
3217
|
} while (0)')
|
|
3131
3218
|
*/
|
|
3132
3219
|
|
|
3133
|
-
DEFINE_PIXELFORMAT_CONST(UNKNOWN,
|
|
3220
|
+
DEFINE_PIXELFORMAT_CONST(UNKNOWN, Unused - reserved by SDL);
|
|
3134
3221
|
DEFINE_PIXELFORMAT_CONST(INDEX1LSB);
|
|
3135
3222
|
DEFINE_PIXELFORMAT_CONST(INDEX1MSB);
|
|
3136
3223
|
DEFINE_PIXELFORMAT_CONST(INDEX4LSB);
|
|
@@ -3285,13 +3372,13 @@ void rubysdl2_init_image(void)
|
|
|
3285
3372
|
rb_define_method(cRenderer, "load_texture", Renderer_load_texture, 1);
|
|
3286
3373
|
|
|
3287
3374
|
|
|
3288
|
-
/* Initialize the JPEG loader */
|
|
3375
|
+
/* @return [Integer] Initialize the JPEG loader */
|
|
3289
3376
|
rb_define_const(mIMG, "INIT_JPG", INT2NUM(IMG_INIT_JPG));
|
|
3290
|
-
/* Initialize the PNG loader */
|
|
3377
|
+
/* @return [Integer] Initialize the PNG loader */
|
|
3291
3378
|
rb_define_const(mIMG, "INIT_PNG", INT2NUM(IMG_INIT_PNG));
|
|
3292
|
-
/* Initialize the TIF loader */
|
|
3379
|
+
/* @return [Integer] Initialize the TIF loader */
|
|
3293
3380
|
rb_define_const(mIMG, "INIT_TIF", INT2NUM(IMG_INIT_TIF));
|
|
3294
|
-
/* Initialize the WEBP loader */
|
|
3381
|
+
/* @return [Integer] Initialize the WEBP loader */
|
|
3295
3382
|
rb_define_const(mIMG, "INIT_WEBP", INT2NUM(IMG_INIT_WEBP));
|
|
3296
3383
|
}
|
|
3297
3384
|
|