ruby-sdl2 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +3 -0
- data/README.md +5 -6
- data/Rakefile +13 -0
- data/clipboard.c +24 -0
- data/event.c +216 -5
- data/filesystem.c +27 -0
- data/gamecontroller.c +244 -30
- data/gamecontroller.c.m4 +408 -0
- data/gl.c.m4 +159 -9
- data/hint.c +51 -8
- data/key.c.m4 +6 -0
- data/lib/sdl2/version.rb +2 -2
- data/messagebox.c +40 -38
- data/mixer.c +138 -21
- data/mixer.c.m4 +1196 -0
- data/mouse.c +5 -5
- data/sample/message_box.rb +5 -5
- data/sample/primitives.rb +1 -1
- data/sample/test_video.rb +3 -3
- data/sample/testgl.rb +1 -1
- data/sample/testsprite.rb +5 -5
- data/ttf.c +193 -14
- data/ttf.c.m4 +375 -0
- data/video.c.m4 +465 -122
- metadata +6 -3
data/video.c.m4
CHANGED
@@ -8,15 +8,24 @@
|
|
8
8
|
#include <ruby/encoding.h>
|
9
9
|
|
10
10
|
static VALUE cWindow;
|
11
|
+
static VALUE mWindowFlags;
|
11
12
|
static VALUE cDisplay;
|
12
13
|
static VALUE cDisplayMode;
|
13
14
|
static VALUE cRenderer;
|
15
|
+
static VALUE mRendererFlags;
|
16
|
+
static VALUE mBlendMode;
|
14
17
|
static VALUE cTexture;
|
15
18
|
static VALUE cRect;
|
16
19
|
static VALUE cPoint;
|
17
20
|
static VALUE cSurface;
|
18
21
|
static VALUE cRendererInfo;
|
19
22
|
static VALUE cPixelFormat; /* NOTE: This is related to SDL_PixelFormatEnum, not SDL_PixelFormat */
|
23
|
+
static VALUE mPixelType;
|
24
|
+
static VALUE mBitmapOrder;
|
25
|
+
static VALUE mPackedOrder;
|
26
|
+
static VALUE mArrayOrder;
|
27
|
+
static VALUE mPackedLayout;
|
28
|
+
|
20
29
|
static VALUE mScreenSaver;
|
21
30
|
|
22
31
|
static VALUE hash_windowid_to_window = Qnil;
|
@@ -341,29 +350,6 @@ static VALUE SDL2_s_video_init(VALUE self, VALUE driver_name)
|
|
341
350
|
* All of methods/class methods are available only after initializing video
|
342
351
|
* subsystem by {SDL2.init}.
|
343
352
|
*
|
344
|
-
* # Window Flags
|
345
|
-
*
|
346
|
-
* OR'd bits of the following constants represents window states.
|
347
|
-
* You can see a window state using {#flags} and create a window with a specified
|
348
|
-
* state using flag parameter of {.create}.
|
349
|
-
*
|
350
|
-
* * {SDL2::Window::FULLSCREEN} - fullscreen window
|
351
|
-
* * {SDL2::Window::FULLSCREEN_DESKTOP} -
|
352
|
-
* fullscreen window at the current desktop resolution
|
353
|
-
* * {SDL2::Window::OPENGL} - window usable with OpenGL context
|
354
|
-
* * {SDL2::Window::SHOWN} - window is visible
|
355
|
-
* * {SDL2::Window::HIDDEN} - window is not visible
|
356
|
-
* * {SDL2::Window::BORDERLESS} - no window decoration
|
357
|
-
* * {SDL2::Window::RESIZABLE} - window is resizable
|
358
|
-
* * {SDL2::Window::MINIMIZDED} - window is minimized
|
359
|
-
* * {SDL2::Window::MAXIMIZED} - window is maximized
|
360
|
-
* * {SDL2::Window::INPUT_GRABBED} - window has grabbed input focus
|
361
|
-
* * {SDL2::Window::INPUT_FOCUS} - window has input focus
|
362
|
-
* * {SDL2::Window::MOUSE_FOCUS} - window has mouse focus
|
363
|
-
* * {SDL2::Window::FOREIGN} - window is not created by SDL
|
364
|
-
* * {SDL2::Window::ALLOW_HIGHDPI} - window should be created in high-DPI mode if supported
|
365
|
-
* * {SDL2::Window::MOUSE_CAPTURE} - window has mouse captured
|
366
|
-
*
|
367
353
|
*
|
368
354
|
* @!method destroy?
|
369
355
|
* Return true if the window is already destroyed.
|
@@ -377,7 +363,7 @@ static VALUE SDL2_s_video_init(VALUE self, VALUE driver_name)
|
|
377
363
|
* @param [Integer] y the y position of the left-top of the window
|
378
364
|
* @param [Integer] w the width of the window
|
379
365
|
* @param [Integer] h the height of the window
|
380
|
-
* @param [Integer] flags 0, or one or more
|
366
|
+
* @param [Integer] flags 0, or one or more {Flags} OR'd together
|
381
367
|
*
|
382
368
|
* @return [SDL2::Window] created window
|
383
369
|
*
|
@@ -541,7 +527,7 @@ static VALUE Window_set_brightness(VALUE self, VALUE brightness)
|
|
541
527
|
}
|
542
528
|
|
543
529
|
/*
|
544
|
-
* Get the
|
530
|
+
* Get the {SDL2::Window::Flags Window flag masks} of the window.
|
545
531
|
*
|
546
532
|
* @return [Integer] flags
|
547
533
|
* @see .create
|
@@ -861,8 +847,8 @@ SIMPLE_WINDOW_METHOD(Restore, restore);
|
|
861
847
|
/*
|
862
848
|
* Get the fullscreen stete of the window
|
863
849
|
*
|
864
|
-
* @return [Integer] 0 for window mode, SDL2::Window::FULLSCREEN for
|
865
|
-
* fullscreen mode, and SDL2::Window::FULLSCREEN_DESKTOP for fullscreen
|
850
|
+
* @return [Integer] 0 for window mode, {SDL2::Window::Flags::FULLSCREEN} for
|
851
|
+
* fullscreen mode, and {SDL2::Window::Flags::FULLSCREEN_DESKTOP} for fullscreen
|
866
852
|
* at the current desktop resolution.
|
867
853
|
*
|
868
854
|
* @see #fullscreen_mode=
|
@@ -878,8 +864,8 @@ static VALUE Window_fullscreen_mode(VALUE self)
|
|
878
864
|
* @overload fullscreen_mode=(flag)
|
879
865
|
* Set the fullscreen state of the window
|
880
866
|
*
|
881
|
-
* @param flag [Integer] 0 for window mode, SDL2::Window::FULLSCREEN for
|
882
|
-
* fullscreen mode, and SDL2::Window::FULLSCREEN_DESKTOP for fullscreen
|
867
|
+
* @param flag [Integer] 0 for window mode, {SDL2::Window::Flags::FULLSCREEN} for
|
868
|
+
* fullscreen mode, and {SDL2::Flags::Window::FULLSCREEN_DESKTOP} for fullscreen
|
883
869
|
* at the current desktop resolution.
|
884
870
|
* @return [flag]
|
885
871
|
*
|
@@ -891,13 +877,12 @@ static VALUE Window_set_fullscreen_mode(VALUE self, VALUE flags)
|
|
891
877
|
return flags;
|
892
878
|
}
|
893
879
|
|
894
|
-
|
880
|
+
#if SDL_VERSION_ATLEAST(2,0,1)
|
895
881
|
/*
|
896
882
|
* Get the size of the drawable region.
|
897
883
|
*
|
898
884
|
* @return [[Integer, Integer]] the width and height of the region
|
899
885
|
*/
|
900
|
-
#if SDL_VERSION_ATLEAST(2,0,1)
|
901
886
|
static VALUE Window_gl_drawable_size(VALUE self)
|
902
887
|
{
|
903
888
|
int w, h;
|
@@ -947,6 +932,17 @@ static VALUE Window_debug_info(VALUE self)
|
|
947
932
|
return info;
|
948
933
|
}
|
949
934
|
|
935
|
+
/*
|
936
|
+
* Document-module: SDL2::Window::Flags
|
937
|
+
*
|
938
|
+
* OR'd bits of the constants of this module represents window states.
|
939
|
+
*
|
940
|
+
* You can see a window state using {SDL2::Window#flags}
|
941
|
+
* and create a window with a specified
|
942
|
+
* state using flag parameter of {SDL2::Window.create}.
|
943
|
+
*
|
944
|
+
*/
|
945
|
+
|
950
946
|
/*
|
951
947
|
* Document-class: SDL2::Display
|
952
948
|
*
|
@@ -955,7 +951,16 @@ static VALUE Window_debug_info(VALUE self)
|
|
955
951
|
* This means that if you use dual screen, {.displays} returns two displays.
|
956
952
|
*
|
957
953
|
* This class handles color depth, resolution, and refresh rate of displays.
|
958
|
-
*
|
954
|
+
*
|
955
|
+
*
|
956
|
+
* @!attribute [r] index
|
957
|
+
* The index of the display, 0 origin
|
958
|
+
* @return [Integer]
|
959
|
+
*
|
960
|
+
* @!attribute [r] name
|
961
|
+
* The name of the display
|
962
|
+
* @return [Stirng]
|
963
|
+
*
|
959
964
|
*/
|
960
965
|
|
961
966
|
/*
|
@@ -1077,6 +1082,7 @@ static Uint32 uint32_for_format(VALUE format)
|
|
1077
1082
|
* An object of this class has information about color depth, refresh rate,
|
1078
1083
|
* and resolution of a display.
|
1079
1084
|
*
|
1085
|
+
*
|
1080
1086
|
*/
|
1081
1087
|
|
1082
1088
|
/*
|
@@ -1139,38 +1145,7 @@ static VALUE DisplayMode_refresh_rate(VALUE self)
|
|
1139
1145
|
*
|
1140
1146
|
* You can create a renderer using {SDL2::Window#create_renderer} and
|
1141
1147
|
* use it to draw figures on the window.
|
1142
|
-
*
|
1143
|
-
* # Flags
|
1144
|
-
* You can specify the OR'd bits of the following constants
|
1145
|
-
* {SDL2::Window#create_renderer when you create a new renderer}.
|
1146
|
-
*
|
1147
|
-
* * SDL2::Renderer::SOFTWARE - the renderer is a software fallback
|
1148
|
-
* * SDL2::Renderer::ACCELERATED - the renderer uses hardware acceleration
|
1149
|
-
* * SDL2::Renderer::PRESENTVSYNC - present is synchronized with the refresh rate
|
1150
|
-
* * SDL2::Renderer::TARGETTEXTURE - the renderer supports rendering to texture
|
1151
|
-
*
|
1152
|
-
* No flags(==0) gives priority to available ACCELERATED renderers
|
1153
|
-
*
|
1154
|
-
* # Blending modes
|
1155
|
-
* You can use 4 types of blending mode for rendering graphics
|
1156
|
-
* using Renderer class.
|
1157
|
-
*
|
1158
|
-
* You can change the blending mode using
|
1159
|
-
* {#draw_blend_mode=} and {SDL2::Texture#blend_mode=}.
|
1160
|
-
*
|
1161
|
-
* In the backend of SDL, opengl or direct3d blending
|
1162
|
-
* mechanism is used for blending operations.
|
1163
|
-
*
|
1164
|
-
* * SDL2::BLENDMODE_NONE - no blending (dstRGBA = srcRGBA)
|
1165
|
-
* * SDL2::BLENDMODE_BLEND - alpha blending
|
1166
|
-
* (dstRGB = (srcRGB * srcA) + (dstRGB * (1-srcA)),
|
1167
|
-
* dstA = srcA + (dstA * (1-srcA)))
|
1168
|
-
* * SDL2::BLENDMODE_ADD - additive blending
|
1169
|
-
* (dstRGB = (srcRGB * srcA) + dstRGB,
|
1170
|
-
* dstA = dstA)
|
1171
|
-
* * SDL2::BLENDMODE_MUL - color modulate
|
1172
|
-
* (dstRGB = srcRGB * dstRGB,
|
1173
|
-
* dstA = dstA)
|
1148
|
+
*
|
1174
1149
|
*
|
1175
1150
|
* @!method destroy?
|
1176
1151
|
* Return true if the renderer is {#destroy destroyed}.
|
@@ -1215,9 +1190,9 @@ static VALUE Renderer_destroy(VALUE self)
|
|
1215
1190
|
*
|
1216
1191
|
* You can use the following constants to specify access pattern
|
1217
1192
|
*
|
1218
|
-
* * SDL2::Texture::ACCESS_STATIC
|
1219
|
-
* * SDL2::Texture::ACCESS_STREAMING
|
1220
|
-
* * SDL2::Texture::ACCESS_TARGET
|
1193
|
+
* * {SDL2::Texture::ACCESS_STATIC}
|
1194
|
+
* * {SDL2::Texture::ACCESS_STREAMING}
|
1195
|
+
* * {SDL2::Texture::ACCESS_TARGET}
|
1221
1196
|
*
|
1222
1197
|
* @param [SDL2::PixelFormat,Integer] format format of the texture
|
1223
1198
|
* @param [Integer] access texture access pattern
|
@@ -1302,9 +1277,9 @@ static VALUE Renderer_copy(VALUE self, VALUE texture, VALUE srcrect, VALUE dstre
|
|
1302
1277
|
*
|
1303
1278
|
* You can use the following constants to specify the horizontal/vertical flip:
|
1304
1279
|
*
|
1305
|
-
* * SDL2::Renderer::FLIP_HORIZONTAL - flip horizontally
|
1306
|
-
* * SDL2::Renderer::FLIP_VERTICAL - flip vertically
|
1307
|
-
* * SDL2::Renderer::FLIP_NONE - do not flip, equal to zero
|
1280
|
+
* * {SDL2::Renderer::FLIP_HORIZONTAL} - flip horizontally
|
1281
|
+
* * {SDL2::Renderer::FLIP_VERTICAL} - flip vertically
|
1282
|
+
* * {SDL2::Renderer::FLIP_NONE} - do not flip, equal to zero
|
1308
1283
|
*
|
1309
1284
|
*
|
1310
1285
|
* @param [SDL2::Texture] texture the source texture
|
@@ -1482,11 +1457,10 @@ static VALUE Renderer_info(VALUE self)
|
|
1482
1457
|
* Get the blend mode used for drawing operations like
|
1483
1458
|
* {#fill_rect} and {#draw_line}.
|
1484
1459
|
*
|
1485
|
-
* For the blending modes, see [blending modes](#label-Blending+modes)
|
1486
|
-
*
|
1487
1460
|
* @return [Integer]
|
1488
1461
|
*
|
1489
1462
|
* @see #draw_blend_mode=
|
1463
|
+
* @see SDL2::BlendMode
|
1490
1464
|
*/
|
1491
1465
|
static VALUE Renderer_draw_blend_mode(VALUE self)
|
1492
1466
|
{
|
@@ -1511,7 +1485,7 @@ static VALUE Renderer_draw_blend_mode(VALUE self)
|
|
1511
1485
|
* @return mode
|
1512
1486
|
*
|
1513
1487
|
* @see #draw_blend_mode
|
1514
|
-
*
|
1488
|
+
* @see SDL2::BlendMode
|
1515
1489
|
*/
|
1516
1490
|
static VALUE Renderer_set_draw_blend_mode(VALUE self, VALUE mode)
|
1517
1491
|
{
|
@@ -1523,7 +1497,7 @@ static VALUE Renderer_set_draw_blend_mode(VALUE self, VALUE mode)
|
|
1523
1497
|
* Get the clip rectangle for the current target.
|
1524
1498
|
*
|
1525
1499
|
* @return [SDL2::Rect] the current clip rectangle
|
1526
|
-
*
|
1500
|
+
* @see {#clip_rect=}
|
1527
1501
|
*/
|
1528
1502
|
static VALUE Renderer_clip_rect(VALUE self)
|
1529
1503
|
{
|
@@ -1532,13 +1506,38 @@ static VALUE Renderer_clip_rect(VALUE self)
|
|
1532
1506
|
return rect;
|
1533
1507
|
}
|
1534
1508
|
|
1509
|
+
/*
|
1510
|
+
* @overload clip_rect=(rect)
|
1511
|
+
*
|
1512
|
+
* Set the clip rectangle for the current target.
|
1513
|
+
*
|
1514
|
+
* @return [rect]
|
1515
|
+
* @see #clip_rect
|
1516
|
+
*/
|
1517
|
+
static VALUE Renderer_set_clip_rect(VALUE self, VALUE rect)
|
1518
|
+
{
|
1519
|
+
HANDLE_ERROR(SDL_RenderSetClipRect(Get_SDL_Renderer(self), Get_SDL_Rect(rect)));
|
1520
|
+
return rect;
|
1521
|
+
}
|
1522
|
+
|
1535
1523
|
#if SDL_VERSION_ATLEAST(2,0,4)
|
1524
|
+
/*
|
1525
|
+
* Get whether clipping is enabled on the renderer.
|
1526
|
+
*
|
1527
|
+
* @note This method is available since SDL 2.0.4.
|
1528
|
+
*/
|
1536
1529
|
static VALUE Render_clip_enabled_p(VALUE self)
|
1537
1530
|
{
|
1538
1531
|
return INT2BOOL(SDL_RenderIsClipEnabled(Get_SDL_Renderer(self)));
|
1539
1532
|
}
|
1540
1533
|
#endif
|
1541
1534
|
|
1535
|
+
/*
|
1536
|
+
* Get device indepndent resolution for rendering.
|
1537
|
+
*
|
1538
|
+
* @return [[Integer, Integer]] the logical width and height
|
1539
|
+
* @see #logical_size=
|
1540
|
+
*/
|
1542
1541
|
static VALUE Renderer_logical_size(VALUE self)
|
1543
1542
|
{
|
1544
1543
|
int w, h;
|
@@ -1546,6 +1545,29 @@ static VALUE Renderer_logical_size(VALUE self)
|
|
1546
1545
|
return rb_ary_new3(2, INT2FIX(w), INT2FIX(h));
|
1547
1546
|
}
|
1548
1547
|
|
1548
|
+
/*
|
1549
|
+
* @overload logical_size=(w_and_h)
|
1550
|
+
*
|
1551
|
+
* Set a device indepndent resolution for rendering.
|
1552
|
+
*
|
1553
|
+
* @param w_and_h [[Integer, Integer]] the width and height of the logical resolution
|
1554
|
+
* @return [w_and_h]
|
1555
|
+
* @see #logical_size
|
1556
|
+
*/
|
1557
|
+
static VALUE Renderer_set_logical_size(VALUE self, VALUE wh)
|
1558
|
+
{
|
1559
|
+
HANDLE_ERROR(SDL_RenderSetLogicalSize(Get_SDL_Renderer(self),
|
1560
|
+
NUM2DBL(rb_ary_entry(wh, 0)),
|
1561
|
+
NUM2DBL(rb_ary_entry(wh, 1))));
|
1562
|
+
return wh;
|
1563
|
+
}
|
1564
|
+
|
1565
|
+
/*
|
1566
|
+
* Get the drawing scale for the current target.
|
1567
|
+
*
|
1568
|
+
* @return [[Integer, Integer]] horizontal and vertical scale factor
|
1569
|
+
* @see #scale=
|
1570
|
+
*/
|
1549
1571
|
static VALUE Renderer_scale(VALUE self)
|
1550
1572
|
{
|
1551
1573
|
float scaleX, scaleY;
|
@@ -1553,6 +1575,37 @@ static VALUE Renderer_scale(VALUE self)
|
|
1553
1575
|
return rb_ary_new3(2, DBL2NUM(scaleX), DBL2NUM(scaleY));
|
1554
1576
|
}
|
1555
1577
|
|
1578
|
+
/*
|
1579
|
+
* @overload scale=(scaleX_and_scaleY)
|
1580
|
+
*
|
1581
|
+
* Set the drawing scale for rendering.
|
1582
|
+
*
|
1583
|
+
* The drawing coordinates are scaled by the x/y scaling factors before they are used by the renderer.
|
1584
|
+
* This allows resolution independent drawing with a single coordinate system.
|
1585
|
+
*
|
1586
|
+
* If this results in scaling or subpixel drawing by the rendering backend,
|
1587
|
+
* it will be handled using the appropriate
|
1588
|
+
* quality hints. For best results use integer scaling factors.
|
1589
|
+
*
|
1590
|
+
* @param scaleX_and_scaleY [[Float, Float]] the horizontal and vertical scaling factors
|
1591
|
+
* @return [scaleX_and_scaleY]
|
1592
|
+
* @see #scale
|
1593
|
+
*/
|
1594
|
+
static VALUE Renderer_set_scale(VALUE self, VALUE xy)
|
1595
|
+
{
|
1596
|
+
float scaleX, scaleY;
|
1597
|
+
scaleX = NUM2DBL(rb_ary_entry(xy, 0));
|
1598
|
+
scaleY = NUM2DBL(rb_ary_entry(xy, 1));
|
1599
|
+
HANDLE_ERROR(SDL_RenderSetScale(Get_SDL_Renderer(self), scaleX, scaleY));
|
1600
|
+
return xy;
|
1601
|
+
}
|
1602
|
+
|
1603
|
+
/*
|
1604
|
+
* Get the drawing area for the current target.
|
1605
|
+
*
|
1606
|
+
* @return [SDL2::Rect] the current drawing area
|
1607
|
+
* @see #viewport=
|
1608
|
+
*/
|
1556
1609
|
static VALUE Renderer_viewport(VALUE self)
|
1557
1610
|
{
|
1558
1611
|
VALUE rect = rb_obj_alloc(cRect);
|
@@ -1560,6 +1613,20 @@ static VALUE Renderer_viewport(VALUE self)
|
|
1560
1613
|
return rect;
|
1561
1614
|
}
|
1562
1615
|
|
1616
|
+
/*
|
1617
|
+
* @overload viewport=(area)
|
1618
|
+
* Set the drawing area for rendering on the current target.
|
1619
|
+
*
|
1620
|
+
* @param area [SDL2::Rect,nil] the drawing area, or nil to set the viewport to the entire target
|
1621
|
+
* @return [area]
|
1622
|
+
* @see #viewport
|
1623
|
+
*/
|
1624
|
+
static VALUE Renderer_set_viewport(VALUE self, VALUE rect)
|
1625
|
+
{
|
1626
|
+
HANDLE_ERROR(SDL_RenderSetClipRect(Get_SDL_Renderer(self), Get_SDL_Rect_or_NULL(rect)));
|
1627
|
+
return rect;
|
1628
|
+
}
|
1629
|
+
|
1563
1630
|
/*
|
1564
1631
|
* Return true if the renderer supports render target.
|
1565
1632
|
*
|
@@ -1570,6 +1637,11 @@ static VALUE Renderer_support_render_target_p(VALUE self)
|
|
1570
1637
|
return INT2BOOL(SDL_RenderTargetSupported(Get_SDL_Renderer(self)));
|
1571
1638
|
}
|
1572
1639
|
|
1640
|
+
/*
|
1641
|
+
* Get the output size of a rendering context.
|
1642
|
+
*
|
1643
|
+
* @return [[Integer, Integer]] the width and the height
|
1644
|
+
*/
|
1573
1645
|
static VALUE Renderer_output_size(VALUE self)
|
1574
1646
|
{
|
1575
1647
|
int w, h;
|
@@ -1586,7 +1658,7 @@ static VALUE Renderer_output_size(VALUE self)
|
|
1586
1658
|
* {#support_render_target?}.
|
1587
1659
|
*
|
1588
1660
|
* The target texture musbe be {#create_texture created} with the
|
1589
|
-
* SDL2::Texture::ACCESS_TARGET flag.
|
1661
|
+
* {SDL2::Texture::ACCESS_TARGET} flag.
|
1590
1662
|
*
|
1591
1663
|
* @param [SDL2::Texture,nil] target the targeted texture, or nil
|
1592
1664
|
* for the default render target(i.e. screen)
|
@@ -1646,6 +1718,48 @@ static VALUE Renderer_debug_info(VALUE self)
|
|
1646
1718
|
return info;
|
1647
1719
|
}
|
1648
1720
|
|
1721
|
+
/*
|
1722
|
+
* Document-class: SDL2::Renderer::Info
|
1723
|
+
*
|
1724
|
+
* This class contains information of a rendering context.
|
1725
|
+
*
|
1726
|
+
* @!attribute [r] name
|
1727
|
+
* @return [String] the name of the renderer
|
1728
|
+
*
|
1729
|
+
* @!attribute [r] texture_formats
|
1730
|
+
* @return [Array<SDL2::PixelFormat>] available texture formats
|
1731
|
+
*
|
1732
|
+
* @!attribute [r] max_texture_width
|
1733
|
+
* @return [Integer] maximum texture width
|
1734
|
+
*
|
1735
|
+
* @!attribute [r] max_texture_height
|
1736
|
+
* @return [Integer] maximum texture height
|
1737
|
+
*/
|
1738
|
+
|
1739
|
+
/*
|
1740
|
+
* Document-module: SDL2::Renderer::Flags
|
1741
|
+
*
|
1742
|
+
* The OR'd bits of the constants of this module represents
|
1743
|
+
* the state of renderers.
|
1744
|
+
*
|
1745
|
+
* You can use this flag
|
1746
|
+
* {SDL2::Window#create_renderer when you create a new renderer}.
|
1747
|
+
* No flags(==0) gives priority to available ACCELERATED renderers.
|
1748
|
+
*/
|
1749
|
+
|
1750
|
+
/*
|
1751
|
+
* Document-module: SDL2::BlendMode
|
1752
|
+
*
|
1753
|
+
* Constants represent blend mode for {SDL2::Renderer.copy} and
|
1754
|
+
* drawing operations.
|
1755
|
+
*
|
1756
|
+
* You can change the blending mode using
|
1757
|
+
* {SDL2::Renderer#draw_blend_mode=} and {SDL2::Texture#blend_mode=}.
|
1758
|
+
*
|
1759
|
+
* In the backend of SDL, opengl or direct3d blending
|
1760
|
+
* mechanism is used for blending operations.
|
1761
|
+
*/
|
1762
|
+
|
1649
1763
|
/*
|
1650
1764
|
* Document-class: SDL2::Texture
|
1651
1765
|
*
|
@@ -1772,9 +1886,9 @@ static VALUE Texture_format(VALUE self)
|
|
1772
1886
|
*
|
1773
1887
|
* The return value is one of the following:
|
1774
1888
|
*
|
1775
|
-
* * SDL2::Texture::ACCESS_STATIC
|
1776
|
-
* * SDL2::Texture::ACCESS_STREAMING
|
1777
|
-
* * SDL2::Texture::ACCESS_TARGET
|
1889
|
+
* * {SDL2::Texture::ACCESS_STATIC}
|
1890
|
+
* * {SDL2::Texture::ACCESS_STREAMING}
|
1891
|
+
* * {SDL2::Texture::ACCESS_TARGET}
|
1778
1892
|
*
|
1779
1893
|
* @return [Integer]
|
1780
1894
|
*
|
@@ -2244,11 +2358,23 @@ static VALUE Surface_s_blit(VALUE self, VALUE src, VALUE srcrect, VALUE dst, VAL
|
|
2244
2358
|
}
|
2245
2359
|
|
2246
2360
|
/*
|
2361
|
+
* Create an empty RGB surface.
|
2362
|
+
*
|
2363
|
+
* If rmask, gmask, bmask are omitted, the default masks are used.
|
2364
|
+
* If amask is omitted, alpha mask is considered to be zero.
|
2365
|
+
*
|
2247
2366
|
* @overload new(width, height, depth)
|
2248
2367
|
* @overload new(width, height, depth, amask)
|
2249
2368
|
* @overload new(width, heigth, depth, rmask, gmask, bmask, amask)
|
2250
2369
|
*
|
2251
|
-
* @param width [Integer]
|
2370
|
+
* @param width [Integer] the width of the new surface
|
2371
|
+
* @param height [Integer] the height of the new surface
|
2372
|
+
* @param depth [Integer] the bit depth of the new surface
|
2373
|
+
* @param rmask [Integer] the red mask of a pixel
|
2374
|
+
* @param gmask [Integer] the green mask of a pixel
|
2375
|
+
* @param bmask [Integer] the blue mask of a pixel
|
2376
|
+
* @param amask [Integer] the alpha mask of a pixel
|
2377
|
+
*
|
2252
2378
|
* @return [SDL2::Surface]
|
2253
2379
|
*/
|
2254
2380
|
static VALUE Surface_s_new(int argc, VALUE* argv, VALUE self)
|
@@ -2464,32 +2590,109 @@ static VALUE Point_inspect(VALUE self)
|
|
2464
2590
|
FIELD_ACCESSOR(Point, SDL_Point, x);
|
2465
2591
|
FIELD_ACCESSOR(Point, SDL_Point, y);
|
2466
2592
|
|
2593
|
+
|
2594
|
+
/*
|
2595
|
+
* Document-class: SDL2::PixelFormat
|
2596
|
+
*
|
2597
|
+
* This class represents pixel format of textures, windows, and displays.
|
2598
|
+
*
|
2599
|
+
* In C level, SDL use unsigned integers as pixel formats. This class
|
2600
|
+
* wraps these integers. You can get the integers from {#format}.
|
2601
|
+
*
|
2602
|
+
* @!attribute [r] format
|
2603
|
+
* An integer representing the pixel format.
|
2604
|
+
*
|
2605
|
+
* @return [Integer]
|
2606
|
+
*/
|
2607
|
+
|
2608
|
+
/*
|
2609
|
+
* @overload initialze(format)
|
2610
|
+
*
|
2611
|
+
* Initialize pixel format from the given integer representing a fomrmat.
|
2612
|
+
*
|
2613
|
+
* @param format [Integer] an unsigned integer as a pixel formats
|
2614
|
+
*/
|
2467
2615
|
static VALUE PixelForamt_initialize(VALUE self, VALUE format)
|
2468
2616
|
{
|
2469
2617
|
rb_iv_set(self, "@format", format);
|
2470
2618
|
return Qnil;
|
2471
2619
|
}
|
2472
2620
|
|
2621
|
+
/*
|
2622
|
+
* Get the type of the format.
|
2623
|
+
*
|
2624
|
+
* @return [Integer] One of the constants of {Type} module.
|
2625
|
+
*/
|
2473
2626
|
static VALUE PixelFormat_type(VALUE self)
|
2474
2627
|
{
|
2475
2628
|
return UINT2NUM(SDL_PIXELTYPE(NUM2UINT(rb_iv_get(self, "@format"))));
|
2476
2629
|
}
|
2477
2630
|
|
2478
|
-
|
2479
|
-
|
2480
|
-
|
2481
|
-
|
2482
|
-
|
2631
|
+
/*
|
2632
|
+
define(`PIXELFORMAT_ATTR_READER',
|
2633
|
+
`static VALUE PixelFormat_$1(VALUE self)
|
2634
|
+
{
|
2635
|
+
return $3($2(NUM2UINT(rb_iv_get(self, "@format"))));
|
2636
|
+
}')
|
2637
|
+
*/
|
2483
2638
|
|
2639
|
+
/*
|
2640
|
+
* Get the human readable name of the pixel format
|
2641
|
+
*
|
2642
|
+
* @return [String]
|
2643
|
+
*/
|
2484
2644
|
PIXELFORMAT_ATTR_READER(name, SDL_GetPixelFormatName, utf8str_new_cstr);
|
2645
|
+
|
2646
|
+
/*
|
2647
|
+
* Get the ordering of channels or bits in the pixel format.
|
2648
|
+
*
|
2649
|
+
* @return [Integer] One of the constants of {BitmapOrder} module or {PackedOrder} module.
|
2650
|
+
*/
|
2485
2651
|
PIXELFORMAT_ATTR_READER(order, SDL_PIXELORDER, UINT2NUM);
|
2652
|
+
|
2653
|
+
/*
|
2654
|
+
* Get the channel bit pattern of the pixel format.
|
2655
|
+
*
|
2656
|
+
* @return [Integer] One of the constants of {PackedLayout} module.
|
2657
|
+
*/
|
2486
2658
|
PIXELFORMAT_ATTR_READER(layout, SDL_PIXELLAYOUT, UINT2NUM);
|
2659
|
+
|
2660
|
+
/*
|
2661
|
+
* Get the number of bits per pixel.
|
2662
|
+
*
|
2663
|
+
* @return [Integer]
|
2664
|
+
*/
|
2487
2665
|
PIXELFORMAT_ATTR_READER(bits_per_pixel, SDL_BITSPERPIXEL, INT2NUM);
|
2666
|
+
|
2667
|
+
/*
|
2668
|
+
* Get the number of bytes per pixel.
|
2669
|
+
*
|
2670
|
+
* @return [Integer]
|
2671
|
+
*/
|
2488
2672
|
PIXELFORMAT_ATTR_READER(bytes_per_pixel, SDL_BYTESPERPIXEL, INT2NUM);
|
2673
|
+
|
2674
|
+
/*
|
2675
|
+
* Return true if the pixel format have a palette.
|
2676
|
+
*/
|
2489
2677
|
PIXELFORMAT_ATTR_READER(indexed_p, SDL_ISPIXELFORMAT_INDEXED, INT2BOOL);
|
2678
|
+
|
2679
|
+
/*
|
2680
|
+
* Return true if the pixel format have an alpha channel.
|
2681
|
+
*/
|
2490
2682
|
PIXELFORMAT_ATTR_READER(alpha_p, SDL_ISPIXELFORMAT_ALPHA, INT2BOOL);
|
2683
|
+
|
2684
|
+
/*
|
2685
|
+
* Return true if the pixel format is not indexed, and not RGB(A),
|
2686
|
+
* for example, the pixel format is YUV.
|
2687
|
+
*/
|
2491
2688
|
PIXELFORMAT_ATTR_READER(fourcc_p, SDL_ISPIXELFORMAT_FOURCC, INT2BOOL);
|
2492
2689
|
|
2690
|
+
/*
|
2691
|
+
* @overload ==(other)
|
2692
|
+
* Return true if two pixel format is the same format.
|
2693
|
+
*
|
2694
|
+
* @return [Boolean]
|
2695
|
+
*/
|
2493
2696
|
static VALUE PixelFormat_eq(VALUE self, VALUE other)
|
2494
2697
|
{
|
2495
2698
|
if (!rb_obj_is_kind_of(other, cPixelFormat))
|
@@ -2498,6 +2701,7 @@ static VALUE PixelFormat_eq(VALUE self, VALUE other)
|
|
2498
2701
|
return INT2BOOL(rb_iv_get(self, "@format") == rb_iv_get(other, "@format"));
|
2499
2702
|
}
|
2500
2703
|
|
2704
|
+
/* @return [String] inspection string */
|
2501
2705
|
static VALUE PixelFormat_inspect(VALUE self)
|
2502
2706
|
{
|
2503
2707
|
Uint32 format = NUM2UINT(rb_iv_get(self, "@format"));
|
@@ -2512,18 +2716,44 @@ static VALUE PixelFormat_inspect(VALUE self)
|
|
2512
2716
|
INT2BOOLCSTR(SDL_ISPIXELFORMAT_FOURCC(format)));
|
2513
2717
|
}
|
2514
2718
|
|
2719
|
+
/*
|
2720
|
+
* Document-module: SDL2::ScreenSaver
|
2721
|
+
*
|
2722
|
+
* This module provides functions to disable and enable a screensaver.
|
2723
|
+
*/
|
2724
|
+
|
2725
|
+
/*
|
2726
|
+
* Enable screensaver.
|
2727
|
+
*
|
2728
|
+
* @return [nil]
|
2729
|
+
* @see .disable
|
2730
|
+
* @see .enabled?
|
2731
|
+
*/
|
2515
2732
|
static VALUE ScreenSaver_enable(VALUE self)
|
2516
2733
|
{
|
2517
2734
|
SDL_EnableScreenSaver();
|
2518
2735
|
return Qnil;
|
2519
2736
|
}
|
2520
2737
|
|
2738
|
+
/*
|
2739
|
+
* Disable screensaver.
|
2740
|
+
*
|
2741
|
+
* @return [nil]
|
2742
|
+
* @see .enable
|
2743
|
+
* @see .enabled?
|
2744
|
+
*/
|
2521
2745
|
static VALUE ScreenSaver_disable(VALUE self)
|
2522
2746
|
{
|
2523
2747
|
SDL_DisableScreenSaver();
|
2524
2748
|
return Qnil;
|
2525
2749
|
}
|
2526
2750
|
|
2751
|
+
/*
|
2752
|
+
* Return true if the screensaver is enabled.
|
2753
|
+
*
|
2754
|
+
* @see .enable
|
2755
|
+
* @see .disable
|
2756
|
+
*/
|
2527
2757
|
static VALUE ScreenSaver_enabled_p(VALUE self)
|
2528
2758
|
{
|
2529
2759
|
return INT2BOOL(SDL_IsScreenSaverEnabled());
|
@@ -2579,27 +2809,48 @@ void rubysdl2_init_video(void)
|
|
2579
2809
|
rb_define_method(cWindow, "gl_drawable_size", Window_gl_drawable_size, 0);
|
2580
2810
|
#endif
|
2581
2811
|
rb_define_method(cWindow, "gl_swap", Window_gl_swap, 0);
|
2812
|
+
|
2813
|
+
/* Indicate that you don't care what the window position is */
|
2582
2814
|
rb_define_const(cWindow, "POS_CENTERED", INT2NUM(SDL_WINDOWPOS_CENTERED));
|
2815
|
+
/* Indicate that the window position should be centered */
|
2583
2816
|
rb_define_const(cWindow, "POS_UNDEFINED", INT2NUM(SDL_WINDOWPOS_UNDEFINED));
|
2584
|
-
|
2585
|
-
|
2586
|
-
|
2587
|
-
|
2588
|
-
|
2589
|
-
|
2590
|
-
|
2591
|
-
|
2592
|
-
|
2593
|
-
|
2594
|
-
|
2595
|
-
|
2596
|
-
|
2597
|
-
|
2598
|
-
|
2817
|
+
|
2818
|
+
mWindowFlags = rb_define_module_under(cWindow, "Flags");
|
2819
|
+
/* define(`DEFINE_WINDOW_FLAGS_CONST',`rb_define_const(mWindowFlags, "$1", UINT2NUM(SDL_WINDOW_$1))') */
|
2820
|
+
/* fullscreen window */
|
2821
|
+
DEFINE_WINDOW_FLAGS_CONST(FULLSCREEN);
|
2822
|
+
/* fullscreen window at the current desktop resolution */
|
2823
|
+
DEFINE_WINDOW_FLAGS_CONST(FULLSCREEN_DESKTOP);
|
2824
|
+
/* window usable with OpenGL context */
|
2825
|
+
DEFINE_WINDOW_FLAGS_CONST(OPENGL);
|
2826
|
+
/* window is visible */
|
2827
|
+
DEFINE_WINDOW_FLAGS_CONST(SHOWN);
|
2828
|
+
/* window is not visible */
|
2829
|
+
DEFINE_WINDOW_FLAGS_CONST(HIDDEN);
|
2830
|
+
/* no window decoration */
|
2831
|
+
DEFINE_WINDOW_FLAGS_CONST(BORDERLESS);
|
2832
|
+
/* window is resizable */
|
2833
|
+
DEFINE_WINDOW_FLAGS_CONST(RESIZABLE);
|
2834
|
+
/* window is minimized */
|
2835
|
+
DEFINE_WINDOW_FLAGS_CONST(MINIMIZED);
|
2836
|
+
/* window is maximized */
|
2837
|
+
DEFINE_WINDOW_FLAGS_CONST(MAXIMIZED);
|
2838
|
+
/* window has grabbed input focus */
|
2839
|
+
DEFINE_WINDOW_FLAGS_CONST(INPUT_GRABBED);
|
2840
|
+
/* window has input focus */
|
2841
|
+
DEFINE_WINDOW_FLAGS_CONST(INPUT_FOCUS);
|
2842
|
+
/* window has mouse focus */
|
2843
|
+
DEFINE_WINDOW_FLAGS_CONST(MOUSE_FOCUS);
|
2844
|
+
/* window is not created by SDL */
|
2845
|
+
DEFINE_WINDOW_FLAGS_CONST(FOREIGN);
|
2599
2846
|
#ifdef SDL_WINDOW_ALLOW_HIGHDPI
|
2600
|
-
|
2847
|
+
/* window should be created in high-DPI mode if supported (>= SDL 2.0.1)*/
|
2848
|
+
DEFINE_WINDOW_FLAGS_CONST(ALLOW_HIGHDPI);
|
2849
|
+
#endif
|
2850
|
+
#ifdef SDL_WINDOW_MOSUE_CAPTURE
|
2851
|
+
/* window has mouse caputred (>= SDL 2.0.4) */
|
2852
|
+
DEFINE_WINDOW_FLAGS_CONST(MOUSE_CAPTURE);
|
2601
2853
|
#endif
|
2602
|
-
|
2603
2854
|
|
2604
2855
|
cDisplay = rb_define_class_under(mSDL2, "Display", rb_cObject);
|
2605
2856
|
|
@@ -2611,6 +2862,7 @@ void rubysdl2_init_video(void)
|
|
2611
2862
|
rb_define_method(cDisplay, "desktop_mode", Display_desktop_mode, 0);
|
2612
2863
|
rb_define_method(cDisplay, "closest_mode", Display_closest_mode, 1);
|
2613
2864
|
rb_define_method(cDisplay, "bounds", Display_bounds, 0);
|
2865
|
+
|
2614
2866
|
|
2615
2867
|
cDisplayMode = rb_define_class_under(cDisplay, "Mode", rb_cObject);
|
2616
2868
|
|
@@ -2621,7 +2873,7 @@ void rubysdl2_init_video(void)
|
|
2621
2873
|
rb_define_method(cDisplayMode, "w", DisplayMode_w, 0);
|
2622
2874
|
rb_define_method(cDisplayMode, "h", DisplayMode_h, 0);
|
2623
2875
|
rb_define_method(cDisplayMode, "refresh_rate", DisplayMode_refresh_rate, 0);
|
2624
|
-
|
2876
|
+
|
2625
2877
|
|
2626
2878
|
cRenderer = rb_define_class_under(mSDL2, "Renderer", rb_cObject);
|
2627
2879
|
|
@@ -2645,12 +2897,16 @@ void rubysdl2_init_video(void)
|
|
2645
2897
|
rb_define_method(cRenderer, "draw_blend_mode", Renderer_draw_blend_mode, 0);
|
2646
2898
|
rb_define_method(cRenderer, "draw_blend_mode=", Renderer_set_draw_blend_mode, 1);
|
2647
2899
|
rb_define_method(cRenderer, "clip_rect", Renderer_clip_rect, 0);
|
2900
|
+
rb_define_method(cRenderer, "clip_rect=", Renderer_set_clip_rect, 1);
|
2648
2901
|
#if SDL_VERSION_ATLEAST(2,0,4)
|
2649
2902
|
rb_define_method(cRenderer, "clip_enabled?", Render_clip_enabled_p, 0);
|
2650
2903
|
#endif
|
2651
2904
|
rb_define_method(cRenderer, "logical_size", Renderer_logical_size, 0);
|
2905
|
+
rb_define_method(cRenderer, "logical_size=", Renderer_set_logical_size, 1);
|
2652
2906
|
rb_define_method(cRenderer, "scale", Renderer_scale, 0);
|
2907
|
+
rb_define_method(cRenderer, "scale=", Renderer_set_scale, 1);
|
2653
2908
|
rb_define_method(cRenderer, "viewport", Renderer_viewport, 0);
|
2909
|
+
rb_define_method(cRenderer, "viewport=", Renderer_set_viewport, 1);
|
2654
2910
|
rb_define_method(cRenderer, "support_render_target?", Renderer_support_render_target_p, 0);
|
2655
2911
|
rb_define_method(cRenderer, "output_size", Renderer_output_size, 0);
|
2656
2912
|
rb_define_method(cRenderer, "render_target", Renderer_render_target, 0);
|
@@ -2658,24 +2914,37 @@ void rubysdl2_init_video(void)
|
|
2658
2914
|
rb_define_method(cRenderer, "reset_render_target", Renderer_reset_render_target, 0);
|
2659
2915
|
|
2660
2916
|
rb_define_method(cRenderer, "info", Renderer_info, 0);
|
2661
|
-
|
2662
|
-
|
2663
|
-
|
2664
|
-
|
2917
|
+
|
2918
|
+
mRendererFlags = rb_define_module_under(cRenderer, "Flags");
|
2919
|
+
|
2920
|
+
/* define(`DEFINE_RENDERER_FLAGS_CONST',`rb_define_const(mRendererFlags, "$1", UINT2NUM(SDL_RENDERER_$1))') */
|
2921
|
+
/* the renderer is a software fallback */
|
2922
|
+
DEFINE_RENDERER_FLAGS_CONST(SOFTWARE);
|
2923
|
+
/* the renderer uses hardware acceleration */
|
2924
|
+
DEFINE_RENDERER_FLAGS_CONST(ACCELERATED);
|
2665
2925
|
#ifdef SDL_RENDERER_PRESENTVSYNC
|
2666
|
-
|
2926
|
+
/* present is synchronized with the refresh rate */
|
2927
|
+
DEFINE_RENDERER_FLAGS_CONST(PRESENTVSYNC);
|
2667
2928
|
#endif
|
2668
|
-
|
2669
|
-
|
2670
|
-
rb_define_const(cRenderer, "FLIP_"
|
2929
|
+
/* the renderer supports rendering to texture */
|
2930
|
+
DEFINE_RENDERER_FLAGS_CONST(TARGETTEXTURE);
|
2931
|
+
/* define(`DEFINE_SDL_FLIP_CONST',`rb_define_const(cRenderer, "FLIP_$1", INT2FIX(SDL_FLIP_$1))') */
|
2932
|
+
/* Do not flip, used in {Renderer#copy_ex} */
|
2671
2933
|
DEFINE_SDL_FLIP_CONST(NONE);
|
2934
|
+
/* Flip horizontally, used in {Renderer#copy_ex} */
|
2672
2935
|
DEFINE_SDL_FLIP_CONST(HORIZONTAL);
|
2936
|
+
/* Flip vertically, used in {Renderer#copy_ex} */
|
2673
2937
|
DEFINE_SDL_FLIP_CONST(VERTICAL);
|
2674
|
-
|
2675
|
-
|
2938
|
+
|
2939
|
+
mBlendMode = rb_define_module_under(mSDL2, "BlendMode");
|
2940
|
+
/* define(`DEFINE_BLENDMODE_CONST',`rb_define_const(mBlendMode, "$1", INT2FIX(SDL_BLENDMODE_$1))') */
|
2941
|
+
/* no blending (dstRGBA = srcRGBA) */
|
2676
2942
|
DEFINE_BLENDMODE_CONST(NONE);
|
2943
|
+
/* alpha blending (dstRGB = (srcRGB * srcA) + (dstRGB * (1-srcA), dstA = srcA + (dstA * (1-srcA)))*/
|
2677
2944
|
DEFINE_BLENDMODE_CONST(BLEND);
|
2945
|
+
/* additive blending (dstRGB = (srcRGB * srcA) + dstRGB, dstA = dstA) */
|
2678
2946
|
DEFINE_BLENDMODE_CONST(ADD);
|
2947
|
+
/* color modulate (multiplicative) (dstRGB = srcRGB * dstRGB, dstA = dstA) */
|
2679
2948
|
DEFINE_BLENDMODE_CONST(MOD);
|
2680
2949
|
|
2681
2950
|
cTexture = rb_define_class_under(mSDL2, "Texture", rb_cObject);
|
@@ -2692,10 +2961,12 @@ void rubysdl2_init_video(void)
|
|
2692
2961
|
rb_define_method(cTexture, "h", Texture_h, 0);
|
2693
2962
|
rb_define_method(cTexture, "inspect", Texture_inspect, 0);
|
2694
2963
|
rb_define_method(cTexture, "debug_info", Texture_debug_info, 0);
|
2695
|
-
|
2696
|
-
|
2964
|
+
/* define(`DEFINE_TEXTUREAH_ACCESS_CONST', `rb_define_const(cTexture, "ACCESS_$1", INT2NUM(SDL_TEXTUREACCESS_$1))') */
|
2965
|
+
/* texture access pattern - changes rarely, not lockable */
|
2697
2966
|
DEFINE_TEXTUREAH_ACCESS_CONST(STATIC);
|
2967
|
+
/* texture access pattern - changes frequently, lockable */
|
2698
2968
|
DEFINE_TEXTUREAH_ACCESS_CONST(STREAMING);
|
2969
|
+
/* texture access pattern - can be used as a render target */
|
2699
2970
|
DEFINE_TEXTUREAH_ACCESS_CONST(TARGET);
|
2700
2971
|
|
2701
2972
|
|
@@ -2768,17 +3039,74 @@ void rubysdl2_init_video(void)
|
|
2768
3039
|
rb_define_method(cPixelFormat, "alpha?", PixelFormat_alpha_p, 0);
|
2769
3040
|
rb_define_method(cPixelFormat, "fourcc?", PixelFormat_fourcc_p, 0);
|
2770
3041
|
rb_define_method(cPixelFormat, "==", PixelFormat_eq, 1);
|
3042
|
+
|
3043
|
+
mPixelType = rb_define_module_under(cPixelFormat, "Type");
|
3044
|
+
/* define(`DEFINE_PIXELTYPE_CONST',`rb_define_const(mPixelType, "$1", UINT2NUM(SDL_PIXELTYPE_$1))') */
|
3045
|
+
DEFINE_PIXELTYPE_CONST(UNKNOWN);
|
3046
|
+
DEFINE_PIXELTYPE_CONST(INDEX1);
|
3047
|
+
DEFINE_PIXELTYPE_CONST(INDEX4);
|
3048
|
+
DEFINE_PIXELTYPE_CONST(INDEX8);
|
3049
|
+
DEFINE_PIXELTYPE_CONST(PACKED8);
|
3050
|
+
DEFINE_PIXELTYPE_CONST(PACKED16);
|
3051
|
+
DEFINE_PIXELTYPE_CONST(PACKED32);
|
3052
|
+
DEFINE_PIXELTYPE_CONST(ARRAYU8);
|
3053
|
+
DEFINE_PIXELTYPE_CONST(ARRAYU16);
|
3054
|
+
DEFINE_PIXELTYPE_CONST(ARRAYU32);
|
3055
|
+
DEFINE_PIXELTYPE_CONST(ARRAYF16);
|
3056
|
+
DEFINE_PIXELTYPE_CONST(ARRAYF32);
|
3057
|
+
|
3058
|
+
mBitmapOrder = rb_define_module_under(cPixelFormat, "BitmapOrder");
|
3059
|
+
rb_define_const(mBitmapOrder, "NONE", UINT2NUM(SDL_BITMAPORDER_NONE));
|
3060
|
+
rb_define_const(mBitmapOrder, "O_1234", UINT2NUM(SDL_BITMAPORDER_1234));
|
3061
|
+
rb_define_const(mBitmapOrder, "O_4321", UINT2NUM(SDL_BITMAPORDER_4321));
|
3062
|
+
|
3063
|
+
mPackedOrder = rb_define_module_under(cPixelFormat, "PackedOrder");
|
3064
|
+
/* define(`DEFINE_PACKEDORDER_CONST',`rb_define_const(mPackedOrder, "$1", UINT2NUM(SDL_PACKEDORDER_$1))') */
|
3065
|
+
DEFINE_PACKEDORDER_CONST(NONE);
|
3066
|
+
DEFINE_PACKEDORDER_CONST(XRGB);
|
3067
|
+
DEFINE_PACKEDORDER_CONST(RGBX);
|
3068
|
+
DEFINE_PACKEDORDER_CONST(ARGB);
|
3069
|
+
DEFINE_PACKEDORDER_CONST(RGBA);
|
3070
|
+
DEFINE_PACKEDORDER_CONST(XBGR);
|
3071
|
+
DEFINE_PACKEDORDER_CONST(BGRX);
|
3072
|
+
DEFINE_PACKEDORDER_CONST(ABGR);
|
3073
|
+
DEFINE_PACKEDORDER_CONST(BGRA);
|
3074
|
+
|
3075
|
+
mArrayOrder = rb_define_module_under(cPixelFormat, "ArrayOrder");
|
3076
|
+
/* define(`DEFINE_ARRAYORDER_CONST',`rb_define_const(mArrayOrder, "$1", UINT2NUM(SDL_ARRAYORDER_$1))') */
|
3077
|
+
DEFINE_ARRAYORDER_CONST(NONE);
|
3078
|
+
DEFINE_ARRAYORDER_CONST(RGB);
|
3079
|
+
DEFINE_ARRAYORDER_CONST(RGBA);
|
3080
|
+
DEFINE_ARRAYORDER_CONST(ARGB);
|
3081
|
+
DEFINE_ARRAYORDER_CONST(BGR);
|
3082
|
+
DEFINE_ARRAYORDER_CONST(BGRA);
|
3083
|
+
DEFINE_ARRAYORDER_CONST(ABGR);
|
3084
|
+
|
3085
|
+
mPackedLayout = rb_define_module_under(cPixelFormat, "PackedLayout");
|
3086
|
+
/* define(`DEFINE_PACKEDLAYOUT_CONST',`rb_define_const(mPackedLayout, "L_$1", UINT2NUM(SDL_PACKEDLAYOUT_$1))') */
|
3087
|
+
rb_define_const(mPackedLayout, "NONE", UINT2NUM(SDL_PACKEDLAYOUT_NONE));
|
3088
|
+
DEFINE_PACKEDLAYOUT_CONST(332);
|
3089
|
+
DEFINE_PACKEDLAYOUT_CONST(4444);
|
3090
|
+
DEFINE_PACKEDLAYOUT_CONST(1555);
|
3091
|
+
DEFINE_PACKEDLAYOUT_CONST(5551);
|
3092
|
+
DEFINE_PACKEDLAYOUT_CONST(565);
|
3093
|
+
DEFINE_PACKEDLAYOUT_CONST(8888);
|
3094
|
+
DEFINE_PACKEDLAYOUT_CONST(2101010);
|
3095
|
+
DEFINE_PACKEDLAYOUT_CONST(1010102);
|
2771
3096
|
|
2772
3097
|
{
|
2773
3098
|
VALUE formats = rb_ary_new();
|
3099
|
+
/* -: Array of all available formats */
|
2774
3100
|
rb_define_const(cPixelFormat, "FORMATS", formats);
|
2775
|
-
|
2776
|
-
|
2777
|
-
|
2778
|
-
rb_define_const(cPixelFormat,
|
2779
|
-
rb_ary_push(formats, format);
|
2780
|
-
} while (0)
|
2781
|
-
|
3101
|
+
/* define(`DEFINE_PIXELFORMAT_CONST',`do {
|
3102
|
+
VALUE format = PixelFormat_new(SDL_PIXELFORMAT_$1);
|
3103
|
+
$2
|
3104
|
+
rb_define_const(cPixelFormat, "$1", format);
|
3105
|
+
rb_ary_push(formats, format);
|
3106
|
+
} while (0)')
|
3107
|
+
*/
|
3108
|
+
|
3109
|
+
DEFINE_PIXELFORMAT_CONST(UNKNOWN, /* -: PixelFormat: Unused - reserved by SDL */);
|
2782
3110
|
DEFINE_PIXELFORMAT_CONST(INDEX1LSB);
|
2783
3111
|
DEFINE_PIXELFORMAT_CONST(INDEX1MSB);
|
2784
3112
|
DEFINE_PIXELFORMAT_CONST(INDEX4LSB);
|
@@ -2832,6 +3160,16 @@ void rubysdl2_init_video(void)
|
|
2832
3160
|
|
2833
3161
|
static VALUE mIMG;
|
2834
3162
|
|
3163
|
+
/*
|
3164
|
+
* Document-module: SDL2::IMG
|
3165
|
+
*
|
3166
|
+
* This module provides the interface to SDL_image. You can load
|
3167
|
+
* many kinds of image files using this modules.
|
3168
|
+
*
|
3169
|
+
* This module provides only initialization interface {SDL2::IMG.init}.
|
3170
|
+
* After calling init, you can load image files using {SDL2::Surface.load}.
|
3171
|
+
*/
|
3172
|
+
|
2835
3173
|
/*
|
2836
3174
|
* @overload init(flags)
|
2837
3175
|
* Initialize SDL_image.
|
@@ -2842,6 +3180,7 @@ static VALUE mIMG;
|
|
2842
3180
|
* * {SDL2::IMG::INIT_JPG}
|
2843
3181
|
* * {SDL2::IMG::INIT_PNG}
|
2844
3182
|
* * {SDL2::IMG::INIT_TIF}
|
3183
|
+
* * {SDL2::IMG::INIT_WEBP}
|
2845
3184
|
*
|
2846
3185
|
* You need to initialize SDL_image to check whether specified format
|
2847
3186
|
* is supported by your environment. If your environment does not
|
@@ -2921,10 +3260,14 @@ void rubysdl2_init_image(void)
|
|
2921
3260
|
rb_define_singleton_method(cSurface, "load", Surface_s_load, 1);
|
2922
3261
|
rb_define_method(cRenderer, "load_texture", Renderer_load_texture, 1);
|
2923
3262
|
|
2924
|
-
|
3263
|
+
|
3264
|
+
/* Initialize the JPEG loader */
|
2925
3265
|
rb_define_const(mIMG, "INIT_JPG", INT2NUM(IMG_INIT_JPG));
|
3266
|
+
/* Initialize the PNG loader */
|
2926
3267
|
rb_define_const(mIMG, "INIT_PNG", INT2NUM(IMG_INIT_PNG));
|
3268
|
+
/* Initialize the TIF loader */
|
2927
3269
|
rb_define_const(mIMG, "INIT_TIF", INT2NUM(IMG_INIT_TIF));
|
3270
|
+
/* Initialize the WEBP loader */
|
2928
3271
|
rb_define_const(mIMG, "INIT_WEBP", INT2NUM(IMG_INIT_WEBP));
|
2929
3272
|
}
|
2930
3273
|
|