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.
data/video.c 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 = ALLOC(Window);
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 Data_Wrap_Struct(cWindow, 0, Window_free, w);
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 = ALLOC(SDL_DisplayMode);
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 Data_Wrap_Struct(klass, 0, free, mode);
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
- Data_Get_Struct(display_mode, SDL_DisplayMode, m);
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 = ALLOC(Renderer);
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 Data_Wrap_Struct(cRenderer, 0, Renderer_free, r);
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 = ALLOC(Texture);
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 Data_Wrap_Struct(cTexture, 0, Texture_free, t);
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 = ALLOC(Surface);
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 Data_Wrap_Struct(cSurface, 0, Surface_free, s);
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
- * Return true if the window is already destroyed.
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::Window::Mode]
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 [brightness]
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 [icon]
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 [grabbed]
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 [[Integer, Integer]] maximum width and maximum height,
659
+ * @param size [Array(Integer, Integer)] maximum width and maximum height,
642
660
  * the both must be positive.
643
661
  *
644
- * @return [size]
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 [[Integer, Integer]] minimum width and minimum height,
687
+ * @param size [Array(Integer, Integer)] minimum width and minimum height,
670
688
  * the both must be positive.
671
689
  *
672
- * @return [size]
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 [[Integer, Integer]] the x position and the y position,
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 [size]
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 [[Integer, Integer]] the width and the height
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 wh [[Integer, Integer]] new width and new height
744
+ * @param size [Array(Integer, Integer)] new width and new height
727
745
  *
728
- * @return [size]
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 [bordered]
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 [title]
801
+ * @return [void]
784
802
  *
785
803
  * @see #title
786
804
  */
@@ -885,7 +903,7 @@ static VALUE Window_fullscreen_mode(VALUE self)
885
903
  * @param flag [Integer] 0 for window mode, {SDL2::Window::Flags::FULLSCREEN} for
886
904
  * fullscreen mode, and {SDL2::Flags::Window::FULLSCREEN_DESKTOP} for fullscreen
887
905
  * at the current desktop resolution.
888
- * @return [flag]
906
+ * @return [void]
889
907
  *
890
908
  * @see #fullscreen_mode
891
909
  */
@@ -899,7 +917,7 @@ static VALUE Window_set_fullscreen_mode(VALUE self, VALUE flags)
899
917
  /*
900
918
  * Get the size of the drawable region.
901
919
  *
902
- * @return [[Integer, Integer]] the width and height of the region
920
+ * @return [Array(Integer, Integer)] the width and height of the region
903
921
  */
904
922
  static VALUE Window_gl_drawable_size(VALUE self)
905
923
  {
@@ -977,7 +995,7 @@ static VALUE Window_debug_info(VALUE self)
977
995
  *
978
996
  * @!attribute [r] name
979
997
  * The name of the display
980
- * @return [Stirng]
998
+ * @return [String]
981
999
  *
982
1000
  */
983
1001
 
@@ -1337,6 +1355,54 @@ static VALUE Renderer_present(VALUE self)
1337
1355
  return Qnil;
1338
1356
  }
1339
1357
 
1358
+ /*
1359
+ * @overload read_pixels(rect, format)
1360
+ * Read pixels from the current rendering target.
1361
+ *
1362
+ * ## Remarks
1363
+ *
1364
+ * **WARNING**: This is a very slow operation, and should not be used frequently.
1365
+ * If you're using this on the main rendering target, it should be called after
1366
+ * rendering and before {#present}.
1367
+ *
1368
+ * @param [SDL2::Rect,nil] rect the area to read, or nil for the entire target
1369
+ * @param [SDL2::PixelFormat,Integer] format the desired pixel format
1370
+ * (0 to use the format of the rendering target)
1371
+ * @return [String] raw pixel data as a binary string
1372
+ */
1373
+ static VALUE Renderer_read_pixels(VALUE self, VALUE rect, VALUE format)
1374
+ {
1375
+ SDL_Renderer* renderer = Get_SDL_Renderer(self);
1376
+ SDL_Rect sdl_rect;
1377
+ SDL_Rect* rect_ptr = NULL;
1378
+ Uint32 fmt = uint32_for_format(format);
1379
+ int w, h, pitch;
1380
+ void* pixels;
1381
+
1382
+ if (rect != Qnil) {
1383
+ sdl_rect = *Get_SDL_Rect(rect);
1384
+ rect_ptr = &sdl_rect;
1385
+ w = sdl_rect.w;
1386
+ h = sdl_rect.h;
1387
+ } else {
1388
+ HANDLE_ERROR(SDL_GetRendererOutputSize(renderer, &w, &h));
1389
+ }
1390
+
1391
+ if (fmt == 0) {
1392
+ SDL_RendererInfo info;
1393
+ HANDLE_ERROR(SDL_GetRendererInfo(renderer, &info));
1394
+ pitch = w * SDL_BYTESPERPIXEL(info.texture_formats[0]);
1395
+ } else {
1396
+ pitch = w * SDL_BYTESPERPIXEL(fmt);
1397
+ }
1398
+
1399
+ pixels = ALLOCA_N(char, pitch * h);
1400
+
1401
+ HANDLE_ERROR(SDL_RenderReadPixels(renderer, rect_ptr, fmt, pixels, pitch));
1402
+
1403
+ return rb_str_new(pixels, pitch * h);
1404
+ }
1405
+
1340
1406
  /*
1341
1407
  * Crear the rendering target with the drawing color.
1342
1408
  * @return [nil]
@@ -1351,7 +1417,7 @@ static VALUE Renderer_clear(VALUE self)
1351
1417
 
1352
1418
  /*
1353
1419
  * Get the color used for drawing operations
1354
- * @return [[Integer,Integer,Integer,Integer]]
1420
+ * @return [Array(Integer,Integer,Integer,Integer)]
1355
1421
  * red, green, blue, and alpha components of the drawing color
1356
1422
  * (all components are more than or equal to 0 and less than and equal to 255)
1357
1423
  *
@@ -1379,12 +1445,10 @@ static VALUE Renderer_draw_color(VALUE self)
1379
1445
  * * {#fill_rect}
1380
1446
  * * {#clear}
1381
1447
  *
1382
- * @param [[Integer, Integer, Integer]] color
1383
- * red, green, and blue components used for drawing
1384
- * @param [[Integer, Integer, Integer, Integer]] color
1385
- * red, green, blue, and alpha components used for drawing
1448
+ * @param [Array<Integer>] color
1449
+ * red, green, blue, and optionally alpha components used for drawing
1386
1450
  *
1387
- * @return [color]
1451
+ * @return [Array<Integer>]
1388
1452
  *
1389
1453
  * @see #draw_color
1390
1454
  */
@@ -1529,7 +1593,8 @@ static VALUE Renderer_clip_rect(VALUE self)
1529
1593
  *
1530
1594
  * Set the clip rectangle for the current target.
1531
1595
  *
1532
- * @return [rect]
1596
+ * @param rect [SDL2::Rect]
1597
+ * @return [void]
1533
1598
  * @see #clip_rect
1534
1599
  */
1535
1600
  static VALUE Renderer_set_clip_rect(VALUE self, VALUE rect)
@@ -1553,7 +1618,7 @@ static VALUE Render_clip_enabled_p(VALUE self)
1553
1618
  /*
1554
1619
  * Get device indepndent resolution for rendering.
1555
1620
  *
1556
- * @return [[Integer, Integer]] the logical width and height
1621
+ * @return [Array(Integer, Integer)] the logical width and height
1557
1622
  * @see #logical_size=
1558
1623
  */
1559
1624
  static VALUE Renderer_logical_size(VALUE self)
@@ -1568,8 +1633,8 @@ static VALUE Renderer_logical_size(VALUE self)
1568
1633
  *
1569
1634
  * Set a device indepndent resolution for rendering.
1570
1635
  *
1571
- * @param w_and_h [[Integer, Integer]] the width and height of the logical resolution
1572
- * @return [w_and_h]
1636
+ * @param w_and_h [Array(Integer, Integer)] the width and height of the logical resolution
1637
+ * @return [void]
1573
1638
  * @see #logical_size
1574
1639
  */
1575
1640
  static VALUE Renderer_set_logical_size(VALUE self, VALUE wh)
@@ -1583,7 +1648,7 @@ static VALUE Renderer_set_logical_size(VALUE self, VALUE wh)
1583
1648
  /*
1584
1649
  * Get the drawing scale for the current target.
1585
1650
  *
1586
- * @return [[Integer, Integer]] horizontal and vertical scale factor
1651
+ * @return [Array(Integer, Integer)] horizontal and vertical scale factor
1587
1652
  * @see #scale=
1588
1653
  */
1589
1654
  static VALUE Renderer_scale(VALUE self)
@@ -1605,8 +1670,8 @@ static VALUE Renderer_scale(VALUE self)
1605
1670
  * it will be handled using the appropriate
1606
1671
  * quality hints. For best results use integer scaling factors.
1607
1672
  *
1608
- * @param scaleX_and_scaleY [[Float, Float]] the horizontal and vertical scaling factors
1609
- * @return [scaleX_and_scaleY]
1673
+ * @param scaleX_and_scaleY [Array(Float, Float)] the horizontal and vertical scaling factors
1674
+ * @return [void]
1610
1675
  * @see #scale
1611
1676
  */
1612
1677
  static VALUE Renderer_set_scale(VALUE self, VALUE xy)
@@ -1636,7 +1701,7 @@ static VALUE Renderer_viewport(VALUE self)
1636
1701
  * Set the drawing area for rendering on the current target.
1637
1702
  *
1638
1703
  * @param area [SDL2::Rect,nil] the drawing area, or nil to set the viewport to the entire target
1639
- * @return [area]
1704
+ * @return [void]
1640
1705
  * @see #viewport
1641
1706
  */
1642
1707
  static VALUE Renderer_set_viewport(VALUE self, VALUE rect)
@@ -1658,7 +1723,7 @@ static VALUE Renderer_support_render_target_p(VALUE self)
1658
1723
  /*
1659
1724
  * Get the output size of a rendering context.
1660
1725
  *
1661
- * @return [[Integer, Integer]] the width and the height
1726
+ * @return [Array(Integer, Integer)] the width and the height
1662
1727
  */
1663
1728
  static VALUE Renderer_output_size(VALUE self)
1664
1729
  {
@@ -1681,7 +1746,7 @@ static VALUE Renderer_output_size(VALUE self)
1681
1746
  * @param [SDL2::Texture,nil] target the targeted texture, or nil
1682
1747
  * for the default render target(i.e. screen)
1683
1748
  *
1684
- * @return [target]
1749
+ * @return [void]
1685
1750
  *
1686
1751
  * @see #render_target
1687
1752
  */
@@ -1791,6 +1856,8 @@ static VALUE Renderer_debug_info(VALUE self)
1791
1856
  /*
1792
1857
  * Destroy the texture and deallocate memory.
1793
1858
  *
1859
+ * @return [void]
1860
+ *
1794
1861
  * @see #destroy?
1795
1862
  */
1796
1863
  static VALUE Texture_destroy(VALUE self)
@@ -1818,7 +1885,7 @@ static VALUE Texture_blend_mode(VALUE self)
1818
1885
  * Set the blending model of the texture.
1819
1886
  *
1820
1887
  * @param mode [Integer] blending mode
1821
- * @return [mode]
1888
+ * @return [void]
1822
1889
  *
1823
1890
  * @see #blend_mode
1824
1891
  */
@@ -1848,7 +1915,7 @@ static VALUE Texture_alpha_mod(VALUE self)
1848
1915
  *
1849
1916
  * @param alpha [Integer] the alpha value multiplied into copy operation,
1850
1917
  * from 0 to 255
1851
- * @return [alpha]
1918
+ * @return [void]
1852
1919
  *
1853
1920
  * @see #alpha_mod
1854
1921
  */
@@ -1861,7 +1928,7 @@ static VALUE Texture_set_alpha_mod(VALUE self, VALUE alpha)
1861
1928
  /*
1862
1929
  * Get an additional color value used in render copy operations.
1863
1930
  *
1864
- * @return [[Integer, Integer, Integer]] the current red, green, and blue
1931
+ * @return [Array(Integer, Integer, Integer)] the current red, green, and blue
1865
1932
  * color value.
1866
1933
  */
1867
1934
  static VALUE Texture_color_mod(VALUE self)
@@ -1875,9 +1942,9 @@ static VALUE Texture_color_mod(VALUE self)
1875
1942
  * @overload color_mod=(rgb)
1876
1943
  * Set an additional color value used in render copy operations.
1877
1944
  *
1878
- * @param rgb [[Integer, Integer, Integer]] the red, green, and blue
1945
+ * @param rgb [Array(Integer, Integer, Integer)] the red, green, and blue
1879
1946
  * color value multiplied into copy operations.
1880
- * @return [rgb]
1947
+ * @return [void]
1881
1948
  */
1882
1949
  static VALUE Texture_set_color_mod(VALUE self, VALUE rgb)
1883
1950
  {
@@ -2033,7 +2100,7 @@ static VALUE Surface_s_save_bmp(VALUE self, VALUE src, VALUE fname)
2033
2100
  }
2034
2101
 
2035
2102
  /*
2036
- * @overload from_string(string, width, heigth, depth, pitch=nil, rmask=nil, gmask=nil, bmask=nil, amask=nil)
2103
+ * @overload from_string(string, width, height, depth, pitch=nil, rmask=nil, gmask=nil, bmask=nil, amask=nil)
2037
2104
  *
2038
2105
  * Create a RGB surface from pixel data as String object.
2039
2106
  *
@@ -2061,6 +2128,7 @@ static VALUE Surface_s_from_string(int argc, VALUE* argv, VALUE self)
2061
2128
  SDL_Surface* surface;
2062
2129
  void* pixels;
2063
2130
  Surface* s;
2131
+ VALUE obj;
2064
2132
 
2065
2133
  rb_scan_args(argc, argv, "45", &string, &width, &height, &depth,
2066
2134
  &pitch, &Rmask, &Gmask, &Bmask, &Amask);
@@ -2087,10 +2155,10 @@ static VALUE Surface_s_from_string(int argc, VALUE* argv, VALUE self)
2087
2155
 
2088
2156
  RB_GC_GUARD(string);
2089
2157
 
2090
- s = ALLOC(Surface);
2158
+ obj = TypedData_Make_Struct(cSurface, Surface, &Surface_data_type, s);
2091
2159
  s->surface = surface;
2092
2160
  s->need_to_free_pixels = 1;
2093
- return Data_Wrap_Struct(cSurface, 0, Surface_free, s);
2161
+ return obj;
2094
2162
  }
2095
2163
 
2096
2164
  /*
@@ -2129,7 +2197,7 @@ static VALUE Surface_blend_mode(VALUE self)
2129
2197
  * Set the blending mode of the surface used for blit operations.
2130
2198
  *
2131
2199
  * @param mode [Integer] the blending mode
2132
- * @return [mode]
2200
+ * @return [void]
2133
2201
  * @see #blend_mode
2134
2202
  */
2135
2203
  static VALUE Surface_set_blend_mode(VALUE self, VALUE mode)
@@ -2256,7 +2324,7 @@ static VALUE Surface_bytes_per_pixel(VALUE self)
2256
2324
  *
2257
2325
  * @param x [Integer] the x coordinate
2258
2326
  * @param y [Integer] the y coordinate
2259
- * @return [[Integer, Integer, Integer, Integer]]
2327
+ * @return [Array(Integer, Integer, Integer, Integer)]
2260
2328
  * the red, green, blue, and alpha component of the specified pixel.
2261
2329
  *
2262
2330
  */
@@ -2316,7 +2384,7 @@ static VALUE Surface_unset_color_key(VALUE self)
2316
2384
  * the color key, pixel value (see {#pixel}) or pixel color (array of
2317
2385
  * three or four integer elements).
2318
2386
  *
2319
- * @return [key]
2387
+ * @return [Integer, Array<Integer>] value
2320
2388
  *
2321
2389
  * @see #color_key
2322
2390
  * @see #unset_color_key
@@ -2444,12 +2512,14 @@ static VALUE Surface_s_new(int argc, VALUE* argv, VALUE self)
2444
2512
  #define FIELD_ACCESSOR(classname, typename, field) \
2445
2513
  static VALUE classname##_##field(VALUE self) \
2446
2514
  { \
2447
- typename* r; Data_Get_Struct(self, typename, r); \
2515
+ typename* r; \
2516
+ TypedData_Get_Struct(self, typename, &typename##_data_type, r); \
2448
2517
  return INT2NUM(r->field); \
2449
2518
  } \
2450
2519
  static VALUE classname##_set_##field(VALUE self, VALUE val) \
2451
2520
  { \
2452
- typename* r; Data_Get_Struct(self, typename, r); \
2521
+ typename* r; \
2522
+ TypedData_Get_Struct(self, typename, &typename##_data_type, r); \
2453
2523
  r->field = NUM2INT(val); return val; \
2454
2524
  }
2455
2525
 
@@ -2477,16 +2547,21 @@ static VALUE Surface_s_new(int argc, VALUE* argv, VALUE self)
2477
2547
  * Height of the rectangle
2478
2548
  * @return [Integer]
2479
2549
  *
2480
- * @!method self.[](*args)
2550
+ * @!method self.[](x, y, w, h)
2481
2551
  * Alias of new. See {#initialize}.
2552
+ *
2553
+ * @param x [Integer] X coordiante of the left-top point of the rectangle
2554
+ * @param y [Integer] Y coordiante of the left-top point of the rectangle
2555
+ * @param w [Integer] Width of the rectangle
2556
+ * @param h [Integer] Height of the rectangle
2482
2557
  * @return [SDL2::Rect]
2483
2558
  */
2484
2559
  static VALUE Rect_s_allocate(VALUE klass)
2485
2560
  {
2486
- SDL_Rect* rect = ALLOC(SDL_Rect);
2561
+ SDL_Rect* rect;
2562
+ VALUE obj = TypedData_Make_Struct(klass, SDL_Rect, &SDL_Rect_data_type, rect);
2487
2563
  rect->x = rect->y = rect->w = rect->h = 0;
2488
-
2489
- return Data_Wrap_Struct(cRect, 0, free, rect);
2564
+ return obj;
2490
2565
  }
2491
2566
 
2492
2567
  /*
@@ -2514,7 +2589,7 @@ static VALUE Rect_initialize(int argc, VALUE* argv, VALUE self)
2514
2589
  /* do nothing*/
2515
2590
  } else if (argc == 4) {
2516
2591
  SDL_Rect* rect;
2517
- Data_Get_Struct(self, SDL_Rect, rect);
2592
+ TypedData_Get_Struct(self, SDL_Rect, &SDL_Rect_data_type, rect);
2518
2593
  rect->x = NUM2INT(x); rect->y = NUM2INT(y);
2519
2594
  rect->w = NUM2INT(w); rect->h = NUM2INT(h);
2520
2595
  } else {
@@ -2589,7 +2664,7 @@ static VALUE Rect_union(VALUE self, VALUE other)
2589
2664
  static VALUE Point_s_allocate(VALUE klass)
2590
2665
  {
2591
2666
  SDL_Point* point;
2592
- return Data_Make_Struct(klass, SDL_Point, 0, free, point);
2667
+ return TypedData_Make_Struct(klass, SDL_Point, &SDL_Point_data_type, point);
2593
2668
  }
2594
2669
 
2595
2670
  /*
@@ -2749,6 +2824,8 @@ static VALUE PixelFormat_fourcc_p(VALUE self)
2749
2824
  * @overload ==(other)
2750
2825
  * Return true if two pixel format is the same format.
2751
2826
  *
2827
+ * @param other [SDL2::PixelFormat] other PixelFormat object
2828
+ *
2752
2829
  * @return [Boolean]
2753
2830
  */
2754
2831
  static VALUE PixelFormat_eq(VALUE self, VALUE other)
@@ -2874,45 +2951,45 @@ void rubysdl2_init_video(void)
2874
2951
  #endif
2875
2952
  rb_define_method(cWindow, "gl_swap", Window_gl_swap, 0);
2876
2953
 
2877
- /* Indicate that you don't care what the window position is */
2954
+ /* @return [Integer] Indicate that you don't care what the window position is */
2878
2955
  rb_define_const(cWindow, "POS_CENTERED", INT2NUM(SDL_WINDOWPOS_CENTERED));
2879
- /* Indicate that the window position should be centered */
2956
+ /* @return [Integer] Indicate that the window position should be centered */
2880
2957
  rb_define_const(cWindow, "POS_UNDEFINED", INT2NUM(SDL_WINDOWPOS_UNDEFINED));
2881
2958
 
2882
2959
  mWindowFlags = rb_define_module_under(cWindow, "Flags");
2883
2960
  /* */
2884
- /* fullscreen window */
2961
+ /* @return [Integer] fullscreen window */
2885
2962
  rb_define_const(mWindowFlags, "FULLSCREEN", UINT2NUM(SDL_WINDOW_FULLSCREEN));
2886
- /* fullscreen window at the current desktop resolution */
2963
+ /* @return [Integer] fullscreen window at the current desktop resolution */
2887
2964
  rb_define_const(mWindowFlags, "FULLSCREEN_DESKTOP", UINT2NUM(SDL_WINDOW_FULLSCREEN_DESKTOP));
2888
- /* window usable with OpenGL context */
2965
+ /* @return [Integer] window usable with OpenGL context */
2889
2966
  rb_define_const(mWindowFlags, "OPENGL", UINT2NUM(SDL_WINDOW_OPENGL));
2890
- /* window is visible */
2967
+ /* @return [Integer] window is visible */
2891
2968
  rb_define_const(mWindowFlags, "SHOWN", UINT2NUM(SDL_WINDOW_SHOWN));
2892
- /* window is not visible */
2969
+ /* @return [Integer] window is not visible */
2893
2970
  rb_define_const(mWindowFlags, "HIDDEN", UINT2NUM(SDL_WINDOW_HIDDEN));
2894
- /* no window decoration */
2971
+ /* @return [Integer] no window decoration */
2895
2972
  rb_define_const(mWindowFlags, "BORDERLESS", UINT2NUM(SDL_WINDOW_BORDERLESS));
2896
- /* window is resizable */
2973
+ /* @return [Integer] window is resizable */
2897
2974
  rb_define_const(mWindowFlags, "RESIZABLE", UINT2NUM(SDL_WINDOW_RESIZABLE));
2898
- /* window is minimized */
2975
+ /* @return [Integer] window is minimized */
2899
2976
  rb_define_const(mWindowFlags, "MINIMIZED", UINT2NUM(SDL_WINDOW_MINIMIZED));
2900
- /* window is maximized */
2977
+ /* @return [Integer] window is maximized */
2901
2978
  rb_define_const(mWindowFlags, "MAXIMIZED", UINT2NUM(SDL_WINDOW_MAXIMIZED));
2902
- /* window has grabbed input focus */
2979
+ /* @return [Integer] window has grabbed input focus */
2903
2980
  rb_define_const(mWindowFlags, "INPUT_GRABBED", UINT2NUM(SDL_WINDOW_INPUT_GRABBED));
2904
- /* window has input focus */
2981
+ /* @return [Integer] window has input focus */
2905
2982
  rb_define_const(mWindowFlags, "INPUT_FOCUS", UINT2NUM(SDL_WINDOW_INPUT_FOCUS));
2906
- /* window has mouse focus */
2983
+ /* @return [Integer] window has mouse focus */
2907
2984
  rb_define_const(mWindowFlags, "MOUSE_FOCUS", UINT2NUM(SDL_WINDOW_MOUSE_FOCUS));
2908
- /* window is not created by SDL */
2985
+ /* @return [Integer] window is not created by SDL */
2909
2986
  rb_define_const(mWindowFlags, "FOREIGN", UINT2NUM(SDL_WINDOW_FOREIGN));
2910
2987
  #ifdef HAVE_CONST_SDL_WINDOW_ALLOW_HIGHDPI
2911
- /* window should be created in high-DPI mode if supported (>= SDL 2.0.1)*/
2988
+ /* @return [Integer] window should be created in high-DPI mode if supported (>= SDL 2.0.1)*/
2912
2989
  rb_define_const(mWindowFlags, "ALLOW_HIGHDPI", UINT2NUM(SDL_WINDOW_ALLOW_HIGHDPI));
2913
2990
  #endif
2914
2991
  #ifdef HAVE_CONST_SDL_WINDOW_MOUSE_CAPTURE
2915
- /* window has mouse caputred (>= SDL 2.0.4) */
2992
+ /* @return [Integer] window has mouse caputred (>= SDL 2.0.4) */
2916
2993
  rb_define_const(mWindowFlags, "MOUSE_CAPTURE", UINT2NUM(SDL_WINDOW_MOUSE_CAPTURE));
2917
2994
  #endif
2918
2995
 
@@ -2951,6 +3028,7 @@ void rubysdl2_init_video(void)
2951
3028
  rb_define_method(cRenderer, "copy", Renderer_copy, 3);
2952
3029
  rb_define_method(cRenderer, "copy_ex", Renderer_copy_ex, 6);
2953
3030
  rb_define_method(cRenderer, "present", Renderer_present, 0);
3031
+ rb_define_method(cRenderer, "read_pixels", Renderer_read_pixels, 2);
2954
3032
  rb_define_method(cRenderer, "draw_color",Renderer_draw_color, 0);
2955
3033
  rb_define_method(cRenderer, "draw_color=",Renderer_set_draw_color, 1);
2956
3034
  rb_define_method(cRenderer, "clear", Renderer_clear, 0);
@@ -2982,33 +3060,33 @@ void rubysdl2_init_video(void)
2982
3060
  mRendererFlags = rb_define_module_under(cRenderer, "Flags");
2983
3061
 
2984
3062
  /* */
2985
- /* the renderer is a software fallback */
3063
+ /* @return [Integer] the renderer is a software fallback */
2986
3064
  rb_define_const(mRendererFlags, "SOFTWARE", UINT2NUM(SDL_RENDERER_SOFTWARE));
2987
- /* the renderer uses hardware acceleration */
3065
+ /* @return [Integer] the renderer uses hardware acceleration */
2988
3066
  rb_define_const(mRendererFlags, "ACCELERATED", UINT2NUM(SDL_RENDERER_ACCELERATED));
2989
3067
  #ifdef HAVE_CONST_SDL_RENDERER_PRESENTVSYNC
2990
- /* present is synchronized with the refresh rate */
3068
+ /* @return [Integer] present is synchronized with the refresh rate */
2991
3069
  rb_define_const(mRendererFlags, "PRESENTVSYNC", UINT2NUM(SDL_RENDERER_PRESENTVSYNC));
2992
3070
  #endif
2993
- /* the renderer supports rendering to texture */
3071
+ /* @return [Integer] the renderer supports rendering to texture */
2994
3072
  rb_define_const(mRendererFlags, "TARGETTEXTURE", UINT2NUM(SDL_RENDERER_TARGETTEXTURE));
2995
3073
  /* */
2996
- /* Do not flip, used in {Renderer#copy_ex} */
3074
+ /* @return [Integer] Do not flip, used in {Renderer#copy_ex} */
2997
3075
  rb_define_const(cRenderer, "FLIP_NONE", INT2FIX(SDL_FLIP_NONE));
2998
- /* Flip horizontally, used in {Renderer#copy_ex} */
3076
+ /* @return [Integer] Flip horizontally, used in {Renderer#copy_ex} */
2999
3077
  rb_define_const(cRenderer, "FLIP_HORIZONTAL", INT2FIX(SDL_FLIP_HORIZONTAL));
3000
- /* Flip vertically, used in {Renderer#copy_ex} */
3078
+ /* @return [Integer] Flip vertically, used in {Renderer#copy_ex} */
3001
3079
  rb_define_const(cRenderer, "FLIP_VERTICAL", INT2FIX(SDL_FLIP_VERTICAL));
3002
3080
 
3003
3081
  mBlendMode = rb_define_module_under(mSDL2, "BlendMode");
3004
3082
  /* */
3005
- /* no blending (dstRGBA = srcRGBA) */
3083
+ /* @return [Integer] no blending (dstRGBA = srcRGBA) */
3006
3084
  rb_define_const(mBlendMode, "NONE", INT2FIX(SDL_BLENDMODE_NONE));
3007
- /* alpha blending (dstRGB = (srcRGB * srcA) + (dstRGB * (1-srcA), dstA = srcA + (dstA * (1-srcA)))*/
3085
+ /* @return [Integer] alpha blending (dstRGB = (srcRGB * srcA) + (dstRGB * (1-srcA), dstA = srcA + (dstA * (1-srcA)))*/
3008
3086
  rb_define_const(mBlendMode, "BLEND", INT2FIX(SDL_BLENDMODE_BLEND));
3009
- /* additive blending (dstRGB = (srcRGB * srcA) + dstRGB, dstA = dstA) */
3087
+ /* @return [Integer] additive blending (dstRGB = (srcRGB * srcA) + dstRGB, dstA = dstA) */
3010
3088
  rb_define_const(mBlendMode, "ADD", INT2FIX(SDL_BLENDMODE_ADD));
3011
- /* color modulate (multiplicative) (dstRGB = srcRGB * dstRGB, dstA = dstA) */
3089
+ /* @return [Integer] color modulate (multiplicative) (dstRGB = srcRGB * dstRGB, dstA = dstA) */
3012
3090
  rb_define_const(mBlendMode, "MOD", INT2FIX(SDL_BLENDMODE_MOD));
3013
3091
 
3014
3092
  cTexture = rb_define_class_under(mSDL2, "Texture", rb_cObject);
@@ -3029,11 +3107,11 @@ void rubysdl2_init_video(void)
3029
3107
  rb_define_method(cTexture, "inspect", Texture_inspect, 0);
3030
3108
  rb_define_method(cTexture, "debug_info", Texture_debug_info, 0);
3031
3109
  /* */
3032
- /* texture access pattern - changes rarely, not lockable */
3110
+ /* @return [Integer] texture access pattern code - changes rarely, not lockable */
3033
3111
  rb_define_const(cTexture, "ACCESS_STATIC", INT2NUM(SDL_TEXTUREACCESS_STATIC));
3034
- /* texture access pattern - changes frequently, lockable */
3112
+ /* @return [Integer] texture access pattern code - changes frequently, lockable */
3035
3113
  rb_define_const(cTexture, "ACCESS_STREAMING", INT2NUM(SDL_TEXTUREACCESS_STREAMING));
3036
- /* texture access pattern - can be used as a render target */
3114
+ /* @return [Integer] texture access pattern code - can be used as a render target */
3037
3115
  rb_define_const(cTexture, "ACCESS_TARGET", INT2NUM(SDL_TEXTUREACCESS_TARGET));
3038
3116
 
3039
3117
 
@@ -3058,7 +3136,7 @@ void rubysdl2_init_video(void)
3058
3136
  rb_define_method(cSurface, "pixel_color", Surface_pixel_color, 2);
3059
3137
  rb_define_method(cSurface, "color_key", Surface_color_key, 0);
3060
3138
  rb_define_method(cSurface, "color_key=", Surface_set_color_key, 1);
3061
- rb_define_method(cSurface, "unset_color_key", Surface_set_color_key, 0);
3139
+ rb_define_method(cSurface, "unset_color_key", Surface_unset_color_key, 0);
3062
3140
  rb_define_method(cSurface, "pixels", Surface_pixels, 0);
3063
3141
  rb_define_method(cSurface, "pitch", Surface_pitch, 0);
3064
3142
  rb_define_method(cSurface, "bits_per_pixel", Surface_bits_per_pixel, 0);
@@ -3117,278 +3195,319 @@ void rubysdl2_init_video(void)
3117
3195
 
3118
3196
  mPixelType = rb_define_module_under(cPixelFormat, "Type");
3119
3197
  /* */
3198
+ /* @return [Integer] */
3120
3199
  rb_define_const(mPixelType, "UNKNOWN", UINT2NUM(SDL_PIXELTYPE_UNKNOWN));
3200
+ /* @return [Integer] */
3121
3201
  rb_define_const(mPixelType, "INDEX1", UINT2NUM(SDL_PIXELTYPE_INDEX1));
3202
+ /* @return [Integer] */
3122
3203
  rb_define_const(mPixelType, "INDEX4", UINT2NUM(SDL_PIXELTYPE_INDEX4));
3204
+ /* @return [Integer] */
3123
3205
  rb_define_const(mPixelType, "INDEX8", UINT2NUM(SDL_PIXELTYPE_INDEX8));
3206
+ /* @return [Integer] */
3124
3207
  rb_define_const(mPixelType, "PACKED8", UINT2NUM(SDL_PIXELTYPE_PACKED8));
3208
+ /* @return [Integer] */
3125
3209
  rb_define_const(mPixelType, "PACKED16", UINT2NUM(SDL_PIXELTYPE_PACKED16));
3210
+ /* @return [Integer] */
3126
3211
  rb_define_const(mPixelType, "PACKED32", UINT2NUM(SDL_PIXELTYPE_PACKED32));
3212
+ /* @return [Integer] */
3127
3213
  rb_define_const(mPixelType, "ARRAYU8", UINT2NUM(SDL_PIXELTYPE_ARRAYU8));
3214
+ /* @return [Integer] */
3128
3215
  rb_define_const(mPixelType, "ARRAYU16", UINT2NUM(SDL_PIXELTYPE_ARRAYU16));
3216
+ /* @return [Integer] */
3129
3217
  rb_define_const(mPixelType, "ARRAYU32", UINT2NUM(SDL_PIXELTYPE_ARRAYU32));
3218
+ /* @return [Integer] */
3130
3219
  rb_define_const(mPixelType, "ARRAYF16", UINT2NUM(SDL_PIXELTYPE_ARRAYF16));
3220
+ /* @return [Integer] */
3131
3221
  rb_define_const(mPixelType, "ARRAYF32", UINT2NUM(SDL_PIXELTYPE_ARRAYF32));
3132
3222
 
3133
3223
  mBitmapOrder = rb_define_module_under(cPixelFormat, "BitmapOrder");
3224
+ /* @return [Integer] */
3134
3225
  rb_define_const(mBitmapOrder, "NONE", UINT2NUM(SDL_BITMAPORDER_NONE));
3226
+ /* @return [Integer] */
3135
3227
  rb_define_const(mBitmapOrder, "O_1234", UINT2NUM(SDL_BITMAPORDER_1234));
3228
+ /* @return [Integer] */
3136
3229
  rb_define_const(mBitmapOrder, "O_4321", UINT2NUM(SDL_BITMAPORDER_4321));
3137
3230
 
3138
3231
  mPackedOrder = rb_define_module_under(cPixelFormat, "PackedOrder");
3139
- /* */
3232
+ /*
3233
+ */
3234
+ /* @return [Integer] */
3140
3235
  rb_define_const(mPackedOrder, "NONE", UINT2NUM(SDL_PACKEDORDER_NONE));
3236
+ /* @return [Integer] */
3141
3237
  rb_define_const(mPackedOrder, "XRGB", UINT2NUM(SDL_PACKEDORDER_XRGB));
3238
+ /* @return [Integer] */
3142
3239
  rb_define_const(mPackedOrder, "RGBX", UINT2NUM(SDL_PACKEDORDER_RGBX));
3240
+ /* @return [Integer] */
3143
3241
  rb_define_const(mPackedOrder, "ARGB", UINT2NUM(SDL_PACKEDORDER_ARGB));
3242
+ /* @return [Integer] */
3144
3243
  rb_define_const(mPackedOrder, "RGBA", UINT2NUM(SDL_PACKEDORDER_RGBA));
3244
+ /* @return [Integer] */
3145
3245
  rb_define_const(mPackedOrder, "XBGR", UINT2NUM(SDL_PACKEDORDER_XBGR));
3246
+ /* @return [Integer] */
3146
3247
  rb_define_const(mPackedOrder, "BGRX", UINT2NUM(SDL_PACKEDORDER_BGRX));
3248
+ /* @return [Integer] */
3147
3249
  rb_define_const(mPackedOrder, "ABGR", UINT2NUM(SDL_PACKEDORDER_ABGR));
3250
+ /* @return [Integer] */
3148
3251
  rb_define_const(mPackedOrder, "BGRA", UINT2NUM(SDL_PACKEDORDER_BGRA));
3149
3252
 
3150
3253
  mArrayOrder = rb_define_module_under(cPixelFormat, "ArrayOrder");
3151
3254
  /* */
3255
+ /* @return [Integer] */
3152
3256
  rb_define_const(mArrayOrder, "NONE", UINT2NUM(SDL_ARRAYORDER_NONE));
3257
+ /* @return [Integer] */
3153
3258
  rb_define_const(mArrayOrder, "RGB", UINT2NUM(SDL_ARRAYORDER_RGB));
3259
+ /* @return [Integer] */
3154
3260
  rb_define_const(mArrayOrder, "RGBA", UINT2NUM(SDL_ARRAYORDER_RGBA));
3261
+ /* @return [Integer] */
3155
3262
  rb_define_const(mArrayOrder, "ARGB", UINT2NUM(SDL_ARRAYORDER_ARGB));
3263
+ /* @return [Integer] */
3156
3264
  rb_define_const(mArrayOrder, "BGR", UINT2NUM(SDL_ARRAYORDER_BGR));
3265
+ /* @return [Integer] */
3157
3266
  rb_define_const(mArrayOrder, "BGRA", UINT2NUM(SDL_ARRAYORDER_BGRA));
3267
+ /* @return [Integer] */
3158
3268
  rb_define_const(mArrayOrder, "ABGR", UINT2NUM(SDL_ARRAYORDER_ABGR));
3159
3269
 
3160
3270
  mPackedLayout = rb_define_module_under(cPixelFormat, "PackedLayout");
3161
3271
  /* */
3272
+ /* @return [Integer] */
3162
3273
  rb_define_const(mPackedLayout, "NONE", UINT2NUM(SDL_PACKEDLAYOUT_NONE));
3274
+ /* @return [Integer] */
3163
3275
  rb_define_const(mPackedLayout, "L_332", UINT2NUM(SDL_PACKEDLAYOUT_332));
3276
+ /* @return [Integer] */
3164
3277
  rb_define_const(mPackedLayout, "L_4444", UINT2NUM(SDL_PACKEDLAYOUT_4444));
3278
+ /* @return [Integer] */
3165
3279
  rb_define_const(mPackedLayout, "L_1555", UINT2NUM(SDL_PACKEDLAYOUT_1555));
3280
+ /* @return [Integer] */
3166
3281
  rb_define_const(mPackedLayout, "L_5551", UINT2NUM(SDL_PACKEDLAYOUT_5551));
3282
+ /* @return [Integer] */
3167
3283
  rb_define_const(mPackedLayout, "L_565", UINT2NUM(SDL_PACKEDLAYOUT_565));
3284
+ /* @return [Integer] */
3168
3285
  rb_define_const(mPackedLayout, "L_8888", UINT2NUM(SDL_PACKEDLAYOUT_8888));
3286
+ /* @return [Integer] */
3169
3287
  rb_define_const(mPackedLayout, "L_2101010", UINT2NUM(SDL_PACKEDLAYOUT_2101010));
3288
+ /* @return [Integer] */
3170
3289
  rb_define_const(mPackedLayout, "L_1010102", UINT2NUM(SDL_PACKEDLAYOUT_1010102));
3171
3290
 
3172
3291
  {
3173
3292
  VALUE formats = rb_ary_new();
3174
- /* -: Array of all available formats */
3293
+ /* -: @return [Array<SDL2::PixelFormat>] array of all available formats */
3175
3294
  rb_define_const(cPixelFormat, "FORMATS", formats);
3176
3295
  /*
3177
3296
  */
3178
3297
 
3179
3298
  do {
3180
3299
  VALUE format = PixelFormat_new(SDL_PIXELFORMAT_UNKNOWN);
3181
- /* -: PixelFormat: Unused - reserved by SDL */
3300
+ /* -: @return [SDL2::PixelFormat] Unused - reserved by SDL */
3182
3301
  rb_define_const(cPixelFormat, "UNKNOWN", format);
3183
3302
  rb_ary_push(formats, format);
3184
3303
  } while (0);
3185
3304
  do {
3186
3305
  VALUE format = PixelFormat_new(SDL_PIXELFORMAT_INDEX1LSB);
3187
-
3306
+ /* -: @return [SDL2::PixelFormat] */
3188
3307
  rb_define_const(cPixelFormat, "INDEX1LSB", format);
3189
3308
  rb_ary_push(formats, format);
3190
3309
  } while (0);
3191
3310
  do {
3192
3311
  VALUE format = PixelFormat_new(SDL_PIXELFORMAT_INDEX1MSB);
3193
-
3312
+ /* -: @return [SDL2::PixelFormat] */
3194
3313
  rb_define_const(cPixelFormat, "INDEX1MSB", format);
3195
3314
  rb_ary_push(formats, format);
3196
3315
  } while (0);
3197
3316
  do {
3198
3317
  VALUE format = PixelFormat_new(SDL_PIXELFORMAT_INDEX4LSB);
3199
-
3318
+ /* -: @return [SDL2::PixelFormat] */
3200
3319
  rb_define_const(cPixelFormat, "INDEX4LSB", format);
3201
3320
  rb_ary_push(formats, format);
3202
3321
  } while (0);
3203
3322
  do {
3204
3323
  VALUE format = PixelFormat_new(SDL_PIXELFORMAT_INDEX4MSB);
3205
-
3324
+ /* -: @return [SDL2::PixelFormat] */
3206
3325
  rb_define_const(cPixelFormat, "INDEX4MSB", format);
3207
3326
  rb_ary_push(formats, format);
3208
3327
  } while (0);
3209
3328
  do {
3210
3329
  VALUE format = PixelFormat_new(SDL_PIXELFORMAT_INDEX8);
3211
-
3330
+ /* -: @return [SDL2::PixelFormat] */
3212
3331
  rb_define_const(cPixelFormat, "INDEX8", format);
3213
3332
  rb_ary_push(formats, format);
3214
3333
  } while (0);
3215
3334
  do {
3216
3335
  VALUE format = PixelFormat_new(SDL_PIXELFORMAT_RGB332);
3217
-
3336
+ /* -: @return [SDL2::PixelFormat] */
3218
3337
  rb_define_const(cPixelFormat, "RGB332", format);
3219
3338
  rb_ary_push(formats, format);
3220
3339
  } while (0);
3221
3340
  do {
3222
3341
  VALUE format = PixelFormat_new(SDL_PIXELFORMAT_RGB444);
3223
-
3342
+ /* -: @return [SDL2::PixelFormat] */
3224
3343
  rb_define_const(cPixelFormat, "RGB444", format);
3225
3344
  rb_ary_push(formats, format);
3226
3345
  } while (0);
3227
3346
  do {
3228
3347
  VALUE format = PixelFormat_new(SDL_PIXELFORMAT_RGB555);
3229
-
3348
+ /* -: @return [SDL2::PixelFormat] */
3230
3349
  rb_define_const(cPixelFormat, "RGB555", format);
3231
3350
  rb_ary_push(formats, format);
3232
3351
  } while (0);
3233
3352
  do {
3234
3353
  VALUE format = PixelFormat_new(SDL_PIXELFORMAT_BGR555);
3235
-
3354
+ /* -: @return [SDL2::PixelFormat] */
3236
3355
  rb_define_const(cPixelFormat, "BGR555", format);
3237
3356
  rb_ary_push(formats, format);
3238
3357
  } while (0);
3239
3358
  do {
3240
3359
  VALUE format = PixelFormat_new(SDL_PIXELFORMAT_ARGB4444);
3241
-
3360
+ /* -: @return [SDL2::PixelFormat] */
3242
3361
  rb_define_const(cPixelFormat, "ARGB4444", format);
3243
3362
  rb_ary_push(formats, format);
3244
3363
  } while (0);
3245
3364
  do {
3246
3365
  VALUE format = PixelFormat_new(SDL_PIXELFORMAT_RGBA4444);
3247
-
3366
+ /* -: @return [SDL2::PixelFormat] */
3248
3367
  rb_define_const(cPixelFormat, "RGBA4444", format);
3249
3368
  rb_ary_push(formats, format);
3250
3369
  } while (0);
3251
3370
  do {
3252
3371
  VALUE format = PixelFormat_new(SDL_PIXELFORMAT_ABGR4444);
3253
-
3372
+ /* -: @return [SDL2::PixelFormat] */
3254
3373
  rb_define_const(cPixelFormat, "ABGR4444", format);
3255
3374
  rb_ary_push(formats, format);
3256
3375
  } while (0);
3257
3376
  do {
3258
3377
  VALUE format = PixelFormat_new(SDL_PIXELFORMAT_BGRA4444);
3259
-
3378
+ /* -: @return [SDL2::PixelFormat] */
3260
3379
  rb_define_const(cPixelFormat, "BGRA4444", format);
3261
3380
  rb_ary_push(formats, format);
3262
3381
  } while (0);
3263
3382
  do {
3264
3383
  VALUE format = PixelFormat_new(SDL_PIXELFORMAT_ARGB1555);
3265
-
3384
+ /* -: @return [SDL2::PixelFormat] */
3266
3385
  rb_define_const(cPixelFormat, "ARGB1555", format);
3267
3386
  rb_ary_push(formats, format);
3268
3387
  } while (0);
3269
3388
  do {
3270
3389
  VALUE format = PixelFormat_new(SDL_PIXELFORMAT_RGBA5551);
3271
-
3390
+ /* -: @return [SDL2::PixelFormat] */
3272
3391
  rb_define_const(cPixelFormat, "RGBA5551", format);
3273
3392
  rb_ary_push(formats, format);
3274
3393
  } while (0);
3275
3394
  do {
3276
3395
  VALUE format = PixelFormat_new(SDL_PIXELFORMAT_ABGR1555);
3277
-
3396
+ /* -: @return [SDL2::PixelFormat] */
3278
3397
  rb_define_const(cPixelFormat, "ABGR1555", format);
3279
3398
  rb_ary_push(formats, format);
3280
3399
  } while (0);
3281
3400
  do {
3282
3401
  VALUE format = PixelFormat_new(SDL_PIXELFORMAT_BGRA5551);
3283
-
3402
+ /* -: @return [SDL2::PixelFormat] */
3284
3403
  rb_define_const(cPixelFormat, "BGRA5551", format);
3285
3404
  rb_ary_push(formats, format);
3286
3405
  } while (0);
3287
3406
  do {
3288
3407
  VALUE format = PixelFormat_new(SDL_PIXELFORMAT_RGB565);
3289
-
3408
+ /* -: @return [SDL2::PixelFormat] */
3290
3409
  rb_define_const(cPixelFormat, "RGB565", format);
3291
3410
  rb_ary_push(formats, format);
3292
3411
  } while (0);
3293
3412
  do {
3294
3413
  VALUE format = PixelFormat_new(SDL_PIXELFORMAT_BGR565);
3295
-
3414
+ /* -: @return [SDL2::PixelFormat] */
3296
3415
  rb_define_const(cPixelFormat, "BGR565", format);
3297
3416
  rb_ary_push(formats, format);
3298
3417
  } while (0);
3299
3418
  do {
3300
3419
  VALUE format = PixelFormat_new(SDL_PIXELFORMAT_RGB24);
3301
-
3420
+ /* -: @return [SDL2::PixelFormat] */
3302
3421
  rb_define_const(cPixelFormat, "RGB24", format);
3303
3422
  rb_ary_push(formats, format);
3304
3423
  } while (0);
3305
3424
  do {
3306
3425
  VALUE format = PixelFormat_new(SDL_PIXELFORMAT_BGR24);
3307
-
3426
+ /* -: @return [SDL2::PixelFormat] */
3308
3427
  rb_define_const(cPixelFormat, "BGR24", format);
3309
3428
  rb_ary_push(formats, format);
3310
3429
  } while (0);
3311
3430
  do {
3312
3431
  VALUE format = PixelFormat_new(SDL_PIXELFORMAT_RGB888);
3313
-
3432
+ /* -: @return [SDL2::PixelFormat] */
3314
3433
  rb_define_const(cPixelFormat, "RGB888", format);
3315
3434
  rb_ary_push(formats, format);
3316
3435
  } while (0);
3317
3436
  do {
3318
3437
  VALUE format = PixelFormat_new(SDL_PIXELFORMAT_RGBX8888);
3319
-
3438
+ /* -: @return [SDL2::PixelFormat] */
3320
3439
  rb_define_const(cPixelFormat, "RGBX8888", format);
3321
3440
  rb_ary_push(formats, format);
3322
3441
  } while (0);
3323
3442
  do {
3324
3443
  VALUE format = PixelFormat_new(SDL_PIXELFORMAT_BGR888);
3325
-
3444
+ /* -: @return [SDL2::PixelFormat] */
3326
3445
  rb_define_const(cPixelFormat, "BGR888", format);
3327
3446
  rb_ary_push(formats, format);
3328
3447
  } while (0);
3329
3448
  do {
3330
3449
  VALUE format = PixelFormat_new(SDL_PIXELFORMAT_BGRX8888);
3331
-
3450
+ /* -: @return [SDL2::PixelFormat] */
3332
3451
  rb_define_const(cPixelFormat, "BGRX8888", format);
3333
3452
  rb_ary_push(formats, format);
3334
3453
  } while (0);
3335
3454
  do {
3336
3455
  VALUE format = PixelFormat_new(SDL_PIXELFORMAT_ARGB8888);
3337
-
3456
+ /* -: @return [SDL2::PixelFormat] */
3338
3457
  rb_define_const(cPixelFormat, "ARGB8888", format);
3339
3458
  rb_ary_push(formats, format);
3340
3459
  } while (0);
3341
3460
  do {
3342
3461
  VALUE format = PixelFormat_new(SDL_PIXELFORMAT_RGBA8888);
3343
-
3462
+ /* -: @return [SDL2::PixelFormat] */
3344
3463
  rb_define_const(cPixelFormat, "RGBA8888", format);
3345
3464
  rb_ary_push(formats, format);
3346
3465
  } while (0);
3347
3466
  do {
3348
3467
  VALUE format = PixelFormat_new(SDL_PIXELFORMAT_ABGR8888);
3349
-
3468
+ /* -: @return [SDL2::PixelFormat] */
3350
3469
  rb_define_const(cPixelFormat, "ABGR8888", format);
3351
3470
  rb_ary_push(formats, format);
3352
3471
  } while (0);
3353
3472
  do {
3354
3473
  VALUE format = PixelFormat_new(SDL_PIXELFORMAT_BGRA8888);
3355
-
3474
+ /* -: @return [SDL2::PixelFormat] */
3356
3475
  rb_define_const(cPixelFormat, "BGRA8888", format);
3357
3476
  rb_ary_push(formats, format);
3358
3477
  } while (0);
3359
3478
  do {
3360
3479
  VALUE format = PixelFormat_new(SDL_PIXELFORMAT_ARGB2101010);
3361
-
3480
+ /* -: @return [SDL2::PixelFormat] */
3362
3481
  rb_define_const(cPixelFormat, "ARGB2101010", format);
3363
3482
  rb_ary_push(formats, format);
3364
3483
  } while (0);
3365
3484
  do {
3366
3485
  VALUE format = PixelFormat_new(SDL_PIXELFORMAT_YV12);
3367
-
3486
+ /* -: @return [SDL2::PixelFormat] */
3368
3487
  rb_define_const(cPixelFormat, "YV12", format);
3369
3488
  rb_ary_push(formats, format);
3370
3489
  } while (0);
3371
3490
  do {
3372
3491
  VALUE format = PixelFormat_new(SDL_PIXELFORMAT_IYUV);
3373
-
3492
+ /* -: @return [SDL2::PixelFormat] */
3374
3493
  rb_define_const(cPixelFormat, "IYUV", format);
3375
3494
  rb_ary_push(formats, format);
3376
3495
  } while (0);
3377
3496
  do {
3378
3497
  VALUE format = PixelFormat_new(SDL_PIXELFORMAT_YUY2);
3379
-
3498
+ /* -: @return [SDL2::PixelFormat] */
3380
3499
  rb_define_const(cPixelFormat, "YUY2", format);
3381
3500
  rb_ary_push(formats, format);
3382
3501
  } while (0);
3383
3502
  do {
3384
3503
  VALUE format = PixelFormat_new(SDL_PIXELFORMAT_UYVY);
3385
-
3504
+ /* -: @return [SDL2::PixelFormat] */
3386
3505
  rb_define_const(cPixelFormat, "UYVY", format);
3387
3506
  rb_ary_push(formats, format);
3388
3507
  } while (0);
3389
3508
  do {
3390
3509
  VALUE format = PixelFormat_new(SDL_PIXELFORMAT_YVYU);
3391
-
3510
+ /* -: @return [SDL2::PixelFormat] */
3392
3511
  rb_define_const(cPixelFormat, "YVYU", format);
3393
3512
  rb_ary_push(formats, format);
3394
3513
  } while (0);
@@ -3511,13 +3630,13 @@ void rubysdl2_init_image(void)
3511
3630
  rb_define_method(cRenderer, "load_texture", Renderer_load_texture, 1);
3512
3631
 
3513
3632
 
3514
- /* Initialize the JPEG loader */
3633
+ /* @return [Integer] Initialize the JPEG loader */
3515
3634
  rb_define_const(mIMG, "INIT_JPG", INT2NUM(IMG_INIT_JPG));
3516
- /* Initialize the PNG loader */
3635
+ /* @return [Integer] Initialize the PNG loader */
3517
3636
  rb_define_const(mIMG, "INIT_PNG", INT2NUM(IMG_INIT_PNG));
3518
- /* Initialize the TIF loader */
3637
+ /* @return [Integer] Initialize the TIF loader */
3519
3638
  rb_define_const(mIMG, "INIT_TIF", INT2NUM(IMG_INIT_TIF));
3520
- /* Initialize the WEBP loader */
3639
+ /* @return [Integer] Initialize the WEBP loader */
3521
3640
  rb_define_const(mIMG, "INIT_WEBP", INT2NUM(IMG_INIT_WEBP));
3522
3641
  }
3523
3642