ruby-sdl2 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +1 -1
- data/doc/po/ja.po +9838 -641
- data/event.c +2 -2
- data/lib/sdl2/version.rb +2 -2
- data/messagebox.c +2 -2
- data/mixer.c.m4 +2 -2
- data/ttf.c.m4 +1 -1
- data/video.c.m4 +172 -151
- metadata +4 -4
data/event.c
CHANGED
@@ -923,7 +923,7 @@ static VALUE ControllerDevice_inspect(VALUE self)
|
|
923
923
|
* You don't handle the instance
|
924
924
|
* of this class directly, but you handle the instances of
|
925
925
|
* two subclasses of this subclasses:
|
926
|
-
* {SDL2::Event::FingerMotion} and {SDL2::Event::
|
926
|
+
* {SDL2::Event::FingerMotion}, {SDL2::Event::FingerDown}, and {SDL2::Event::FingerUp}.
|
927
927
|
*
|
928
928
|
* @attribute touch_id
|
929
929
|
* the touch device id
|
@@ -981,7 +981,7 @@ static VALUE EvTouchFinger_inspect(VALUE self)
|
|
981
981
|
* @return [Float]
|
982
982
|
*
|
983
983
|
* @attribute dy
|
984
|
-
* the distance moved in the
|
984
|
+
* the distance moved in the y-axis, normalized (0...1)
|
985
985
|
* @return [Float]
|
986
986
|
*
|
987
987
|
*/
|
data/lib/sdl2/version.rb
CHANGED
data/messagebox.c
CHANGED
@@ -46,7 +46,7 @@ static inline SDL_Window* Get_SDL_Window_or_NULL(VALUE win)
|
|
46
46
|
* @param [SDL2::Window,nil] parent the parent window, or nil for no parent
|
47
47
|
* @return [nil]
|
48
48
|
*
|
49
|
-
* @see .
|
49
|
+
* @see .show
|
50
50
|
*/
|
51
51
|
static VALUE MessageBox_s_show_simple_box(VALUE self, VALUE flag, VALUE title,
|
52
52
|
VALUE message, VALUE parent)
|
@@ -138,7 +138,7 @@ static void set_color_scheme(VALUE colors, VALUE sym, SDL_MessageBoxColor* color
|
|
138
138
|
* color scheme, or nil for the default color scheme
|
139
139
|
* @return [Integer] pressed button id
|
140
140
|
*
|
141
|
-
* @see .
|
141
|
+
* @see .show_simple_box
|
142
142
|
*/
|
143
143
|
static VALUE MessageBox_s_show(VALUE self, VALUE params)
|
144
144
|
{
|
data/mixer.c.m4
CHANGED
@@ -13,7 +13,7 @@ static VALUE mMusicChannel;
|
|
13
13
|
static VALUE playing_chunks = Qnil;
|
14
14
|
static VALUE playing_music = Qnil;
|
15
15
|
|
16
|
-
#define MIX_ERROR() do { HANDLE_ERROR(SDL_SetError(Mix_GetError())); } while(0)
|
16
|
+
#define MIX_ERROR() do { HANDLE_ERROR(SDL_SetError("%s", Mix_GetError())); } while(0)
|
17
17
|
#define HANDLE_MIX_ERROR(code) \
|
18
18
|
do { if ((code) < 0) { MIX_ERROR(); } } while (0)
|
19
19
|
|
@@ -124,7 +124,7 @@ DEFINE_WRAPPER(Mix_Music, Music, music, cMusic, "SDL2::Mixer::Music");
|
|
124
124
|
static VALUE Mixer_s_init(VALUE self, VALUE f)
|
125
125
|
{
|
126
126
|
int flags = NUM2INT(f);
|
127
|
-
if (Mix_Init(flags) & flags != flags)
|
127
|
+
if ((Mix_Init(flags) & flags) != flags)
|
128
128
|
rb_raise(eSDL2Error, "Couldn't initialize SDL_mixer");
|
129
129
|
|
130
130
|
return Qnil;
|
data/ttf.c.m4
CHANGED
@@ -8,7 +8,7 @@ static VALUE cTTF;
|
|
8
8
|
static VALUE mStyle;
|
9
9
|
static VALUE mHinting;
|
10
10
|
|
11
|
-
#define TTF_ERROR() do { HANDLE_ERROR(SDL_SetError(TTF_GetError())); } while (0)
|
11
|
+
#define TTF_ERROR() do { HANDLE_ERROR(SDL_SetError("%s", TTF_GetError())); } while (0)
|
12
12
|
#define HANDLE_TTF_ERROR(code) \
|
13
13
|
do { if ((code) < 0) { TTF_ERROR(); } } while (0)
|
14
14
|
|
data/video.c.m4
CHANGED
@@ -37,7 +37,7 @@ struct Texture;
|
|
37
37
|
#ifdef DEBUG_GC
|
38
38
|
#define GC_LOG(args) fprintf args
|
39
39
|
#else
|
40
|
-
#define GC_LOG(args)
|
40
|
+
#define GC_LOG(args)
|
41
41
|
#endif
|
42
42
|
|
43
43
|
typedef struct Window {
|
@@ -69,7 +69,7 @@ static void Renderer_free(Renderer*);
|
|
69
69
|
static void Window_destroy_internal(Window* w)
|
70
70
|
{
|
71
71
|
int i;
|
72
|
-
for (i=0; i<w->num_renderers; ++i)
|
72
|
+
for (i=0; i<w->num_renderers; ++i)
|
73
73
|
Renderer_free(w->renderers[i]);
|
74
74
|
w->num_renderers = w->max_renderers = 0;
|
75
75
|
free(w->renderers);
|
@@ -78,12 +78,12 @@ static void Window_destroy_internal(Window* w)
|
|
78
78
|
|
79
79
|
static void Window_free(Window* w)
|
80
80
|
{
|
81
|
-
|
81
|
+
|
82
82
|
GC_LOG((stderr, "Window free: %p\n", w));
|
83
83
|
Window_destroy_internal(w);
|
84
84
|
if (w->window && rubysdl2_is_active())
|
85
85
|
SDL_DestroyWindow(w->window);
|
86
|
-
|
86
|
+
|
87
87
|
free(w);
|
88
88
|
}
|
89
89
|
|
@@ -148,7 +148,7 @@ static void Renderer_free(Renderer* r)
|
|
148
148
|
{
|
149
149
|
GC_LOG((stderr, "Renderer free: %p (refcount=%d)\n", r, r->refcount));
|
150
150
|
Renderer_destroy_internal(r);
|
151
|
-
|
151
|
+
|
152
152
|
r->refcount--;
|
153
153
|
if (r->refcount == 0) {
|
154
154
|
free(r);
|
@@ -254,14 +254,14 @@ static VALUE RendererInfo_new(SDL_RendererInfo* info)
|
|
254
254
|
VALUE rinfo = rb_obj_alloc(cRendererInfo);
|
255
255
|
VALUE texture_formats = rb_ary_new();
|
256
256
|
unsigned int i;
|
257
|
-
|
257
|
+
|
258
258
|
rb_iv_set(rinfo, "@name", rb_usascii_str_new_cstr(info->name));
|
259
259
|
rb_iv_set(rinfo, "@texture_formats", texture_formats);
|
260
260
|
for (i=0; i<info->num_texture_formats; ++i)
|
261
261
|
rb_ary_push(texture_formats, PixelFormat_new(info->texture_formats[i]));
|
262
262
|
rb_iv_set(rinfo, "@max_texture_width", INT2NUM(info->max_texture_width));
|
263
263
|
rb_iv_set(rinfo, "@max_texture_height", INT2NUM(info->max_texture_height));
|
264
|
-
|
264
|
+
|
265
265
|
return rinfo;
|
266
266
|
}
|
267
267
|
|
@@ -273,7 +273,7 @@ SDL_Color Array_to_SDL_Color(VALUE ary)
|
|
273
273
|
color.r = color.g = color.b = 0; color.a = 255;
|
274
274
|
return color;
|
275
275
|
}
|
276
|
-
|
276
|
+
|
277
277
|
Check_Type(ary, T_ARRAY);
|
278
278
|
if (RARRAY_LEN(ary) != 3 && RARRAY_LEN(ary) != 4)
|
279
279
|
rb_raise(rb_eArgError, "wrong number of Array elements (%ld for 3 or 4)",
|
@@ -293,7 +293,7 @@ SDL_Color Array_to_SDL_Color(VALUE ary)
|
|
293
293
|
* Get the names of all video drivers.
|
294
294
|
*
|
295
295
|
* You can use the name as an argument of {.video_init}.
|
296
|
-
*
|
296
|
+
*
|
297
297
|
* @return [Array<String>]
|
298
298
|
*/
|
299
299
|
static VALUE SDL2_s_video_drivers(VALUE self)
|
@@ -322,12 +322,12 @@ static VALUE SDL2_s_current_video_driver(VALUE self)
|
|
322
322
|
}
|
323
323
|
|
324
324
|
/*
|
325
|
-
* @overload video_init(driver_name)
|
325
|
+
* @overload video_init(driver_name)
|
326
326
|
* Initialize the video subsystem, specifying a video driver.
|
327
|
-
*
|
327
|
+
*
|
328
328
|
* {.init} cannot specify a video driver, so you need to use
|
329
329
|
* this method to specify a driver.
|
330
|
-
*
|
330
|
+
*
|
331
331
|
* @param driver_name [String]
|
332
332
|
* @return [nil]
|
333
333
|
*
|
@@ -341,12 +341,12 @@ static VALUE SDL2_s_video_init(VALUE self, VALUE driver_name)
|
|
341
341
|
|
342
342
|
/*
|
343
343
|
* Document-class: SDL2::Window
|
344
|
-
*
|
344
|
+
*
|
345
345
|
* This class represents a window.
|
346
346
|
*
|
347
347
|
* If you want to create graphical application using Ruby/SDL, first you need to
|
348
348
|
* create a window.
|
349
|
-
*
|
349
|
+
*
|
350
350
|
* All of methods/class methods are available only after initializing video
|
351
351
|
* subsystem by {SDL2.init}.
|
352
352
|
*
|
@@ -364,9 +364,9 @@ static VALUE SDL2_s_video_init(VALUE self, VALUE driver_name)
|
|
364
364
|
* @param [Integer] w the width of the window
|
365
365
|
* @param [Integer] h the height of the window
|
366
366
|
* @param [Integer] flags 0, or one or more {Flags} OR'd together
|
367
|
-
*
|
367
|
+
*
|
368
368
|
* @return [SDL2::Window] created window
|
369
|
-
*
|
369
|
+
*
|
370
370
|
*/
|
371
371
|
static VALUE Window_s_create(VALUE self, VALUE title, VALUE x, VALUE y, VALUE w, VALUE h,
|
372
372
|
VALUE flags)
|
@@ -421,7 +421,7 @@ VALUE find_window_by_id(Uint32 id)
|
|
421
421
|
*
|
422
422
|
* You cannot call almost all methods after calling this method.
|
423
423
|
* The exception is {#destroy?}.
|
424
|
-
*
|
424
|
+
*
|
425
425
|
* @return [void]
|
426
426
|
*/
|
427
427
|
static VALUE Window_destroy(VALUE self)
|
@@ -445,10 +445,10 @@ static VALUE Window_create_renderer(VALUE self, VALUE index, VALUE flags)
|
|
445
445
|
SDL_Renderer* sdl_renderer;
|
446
446
|
VALUE renderer;
|
447
447
|
sdl_renderer = SDL_CreateRenderer(Get_SDL_Window(self), NUM2INT(index), NUM2UINT(flags));
|
448
|
-
|
448
|
+
|
449
449
|
if (sdl_renderer == NULL)
|
450
450
|
HANDLE_ERROR(-1);
|
451
|
-
|
451
|
+
|
452
452
|
renderer = Renderer_new(sdl_renderer, Get_Window(self));
|
453
453
|
rb_iv_set(self, "renderer", renderer);
|
454
454
|
return renderer;
|
@@ -568,7 +568,7 @@ static VALUE Window_gamma_ramp(VALUE self)
|
|
568
568
|
* @overload icon=(icon)
|
569
569
|
*
|
570
570
|
* Set the window icon.
|
571
|
-
*
|
571
|
+
*
|
572
572
|
* @param icon [SDL2::Surface] the icon for the window
|
573
573
|
* @return [icon]
|
574
574
|
*/
|
@@ -589,7 +589,7 @@ static VALUE Window_input_is_grabbed_p(VALUE self)
|
|
589
589
|
}
|
590
590
|
|
591
591
|
/*
|
592
|
-
* @overload input_is_grabbed=(grabbed)
|
592
|
+
* @overload input_is_grabbed=(grabbed)
|
593
593
|
* Set the window's input grab mode.
|
594
594
|
*
|
595
595
|
* @param grabbed [Boolean] true to grub input, and false to release input
|
@@ -632,7 +632,7 @@ static VALUE Window_maximum_size(VALUE self)
|
|
632
632
|
}
|
633
633
|
|
634
634
|
/*
|
635
|
-
* @overload maximum_size=(size)
|
635
|
+
* @overload maximum_size=(size)
|
636
636
|
* Set the maximum size of the window's client area.
|
637
637
|
*
|
638
638
|
* @param size [[Integer, Integer]] maximum width and maximum height,
|
@@ -660,7 +660,7 @@ static VALUE Window_minimum_size(VALUE self)
|
|
660
660
|
}
|
661
661
|
|
662
662
|
/*
|
663
|
-
* @overload minimum_size=(size)
|
663
|
+
* @overload minimum_size=(size)
|
664
664
|
* Set the minimum size of the window's client area.
|
665
665
|
*
|
666
666
|
* @param size [[Integer, Integer]] minimum width and minimum height,
|
@@ -688,7 +688,7 @@ static VALUE Window_position(VALUE self)
|
|
688
688
|
}
|
689
689
|
|
690
690
|
/*
|
691
|
-
* @overload position=(xy)
|
691
|
+
* @overload position=(xy)
|
692
692
|
* Set the position of the window
|
693
693
|
*
|
694
694
|
* @param xy [[Integer, Integer]] the x position and the y position,
|
@@ -708,7 +708,7 @@ static VALUE Window_set_position(VALUE self, VALUE xy)
|
|
708
708
|
* Get the size of the window.
|
709
709
|
*
|
710
710
|
* @return [[Integer, Integer]] the width and the height
|
711
|
-
*
|
711
|
+
*
|
712
712
|
* @see size=
|
713
713
|
*/
|
714
714
|
static VALUE Window_size(VALUE self)
|
@@ -723,7 +723,7 @@ static VALUE Window_size(VALUE self)
|
|
723
723
|
* @param wh [[Integer, Integer]] new width and new height
|
724
724
|
*
|
725
725
|
* @return [size]
|
726
|
-
*
|
726
|
+
*
|
727
727
|
* @see #size
|
728
728
|
*/
|
729
729
|
static VALUE Window_set_size(VALUE self, VALUE size)
|
@@ -756,7 +756,7 @@ static VALUE Window_bordered(VALUE self)
|
|
756
756
|
}
|
757
757
|
|
758
758
|
/*
|
759
|
-
* @overload bordered=(bordered)
|
759
|
+
* @overload bordered=(bordered)
|
760
760
|
* Set the border state of the window.
|
761
761
|
*
|
762
762
|
* @param bordered [Boolean] true for bordered window, anad false for
|
@@ -847,7 +847,7 @@ SIMPLE_WINDOW_METHOD(Restore, restore);
|
|
847
847
|
/*
|
848
848
|
* Get the fullscreen stete of the window
|
849
849
|
*
|
850
|
-
* @return [Integer] 0 for window mode, {SDL2::Window::Flags::FULLSCREEN} for
|
850
|
+
* @return [Integer] 0 for window mode, {SDL2::Window::Flags::FULLSCREEN} for
|
851
851
|
* fullscreen mode, and {SDL2::Window::Flags::FULLSCREEN_DESKTOP} for fullscreen
|
852
852
|
* at the current desktop resolution.
|
853
853
|
*
|
@@ -864,11 +864,11 @@ static VALUE Window_fullscreen_mode(VALUE self)
|
|
864
864
|
* @overload fullscreen_mode=(flag)
|
865
865
|
* Set the fullscreen state of the window
|
866
866
|
*
|
867
|
-
* @param flag [Integer] 0 for window mode, {SDL2::Window::Flags::FULLSCREEN} for
|
867
|
+
* @param flag [Integer] 0 for window mode, {SDL2::Window::Flags::FULLSCREEN} for
|
868
868
|
* fullscreen mode, and {SDL2::Flags::Window::FULLSCREEN_DESKTOP} for fullscreen
|
869
869
|
* at the current desktop resolution.
|
870
870
|
* @return [flag]
|
871
|
-
*
|
871
|
+
*
|
872
872
|
* @see #fullscreen_mode
|
873
873
|
*/
|
874
874
|
static VALUE Window_set_fullscreen_mode(VALUE self, VALUE flags)
|
@@ -928,7 +928,7 @@ static VALUE Window_debug_info(VALUE self)
|
|
928
928
|
if (w->renderers[i]->renderer)
|
929
929
|
++num_active_renderers;
|
930
930
|
rb_hash_aset(info, rb_str_new2("num_active_renderers"), INT2NUM(num_active_renderers));
|
931
|
-
|
931
|
+
|
932
932
|
return info;
|
933
933
|
}
|
934
934
|
|
@@ -936,7 +936,7 @@ static VALUE Window_debug_info(VALUE self)
|
|
936
936
|
* Document-module: SDL2::Window::Flags
|
937
937
|
*
|
938
938
|
* OR'd bits of the constants of this module represents window states.
|
939
|
-
*
|
939
|
+
*
|
940
940
|
* You can see a window state using {SDL2::Window#flags}
|
941
941
|
* and create a window with a specified
|
942
942
|
* state using flag parameter of {SDL2::Window.create}.
|
@@ -967,7 +967,7 @@ static VALUE Window_debug_info(VALUE self)
|
|
967
967
|
* Get all connected displays.
|
968
968
|
*
|
969
969
|
* @return [Array<SDL2::Display>]
|
970
|
-
*
|
970
|
+
*
|
971
971
|
*/
|
972
972
|
static VALUE Display_s_displays(VALUE self)
|
973
973
|
{
|
@@ -988,7 +988,7 @@ static int Display_index_int(VALUE display)
|
|
988
988
|
* Get available display modes of the display.
|
989
989
|
*
|
990
990
|
* @return [Array<SDL2::Display::Mode>]
|
991
|
-
*
|
991
|
+
*
|
992
992
|
*/
|
993
993
|
static VALUE Display_modes(VALUE self)
|
994
994
|
{
|
@@ -1008,7 +1008,7 @@ static VALUE Display_modes(VALUE self)
|
|
1008
1008
|
* Get the current display mode.
|
1009
1009
|
*
|
1010
1010
|
* @return [SDL2::Display::Mode]
|
1011
|
-
*
|
1011
|
+
*
|
1012
1012
|
* @see #desktop_mode
|
1013
1013
|
*/
|
1014
1014
|
static VALUE Display_current_mode(VALUE self)
|
@@ -1022,7 +1022,7 @@ static VALUE Display_current_mode(VALUE self)
|
|
1022
1022
|
* Get the desktop display mode.
|
1023
1023
|
*
|
1024
1024
|
* Normally, the return value of this method is
|
1025
|
-
* same as {#current_mode}. However,
|
1025
|
+
* same as {#current_mode}. However,
|
1026
1026
|
* when you use fullscreen and chagne the resolution,
|
1027
1027
|
* this method returns the previous native display mode,
|
1028
1028
|
* and not the current mode.
|
@@ -1037,12 +1037,12 @@ static VALUE Display_desktop_mode(VALUE self)
|
|
1037
1037
|
}
|
1038
1038
|
|
1039
1039
|
/*
|
1040
|
-
* @overload closest_mode(mode)
|
1040
|
+
* @overload closest_mode(mode)
|
1041
1041
|
* Get the available display mode closest match to **mode**.
|
1042
|
-
*
|
1042
|
+
*
|
1043
1043
|
* @param mode [SDL2::Display::Mode] the desired display mode
|
1044
1044
|
* @return [SDL2::Display::Mode]
|
1045
|
-
*
|
1045
|
+
*
|
1046
1046
|
*/
|
1047
1047
|
static VALUE Display_closest_mode(VALUE self, VALUE mode)
|
1048
1048
|
{
|
@@ -1111,7 +1111,7 @@ static VALUE DisplayMode_inspect(VALUE self)
|
|
1111
1111
|
return rb_sprintf("<%s: format=%s w=%d h=%d refresh_rate=%d>",
|
1112
1112
|
rb_obj_classname(self), SDL_GetPixelFormatName(mode->format),
|
1113
1113
|
mode->w, mode->h, mode->refresh_rate);
|
1114
|
-
|
1114
|
+
|
1115
1115
|
}
|
1116
1116
|
|
1117
1117
|
/* @return [SDL2::PixelFormat] the pixel format of the display mode */
|
@@ -1145,7 +1145,7 @@ static VALUE DisplayMode_refresh_rate(VALUE self)
|
|
1145
1145
|
*
|
1146
1146
|
* You can create a renderer using {SDL2::Window#create_renderer} and
|
1147
1147
|
* use it to draw figures on the window.
|
1148
|
-
*
|
1148
|
+
*
|
1149
1149
|
*
|
1150
1150
|
* @!method destroy?
|
1151
1151
|
* Return true if the renderer is {#destroy destroyed}.
|
@@ -1157,7 +1157,7 @@ static VALUE DisplayMode_refresh_rate(VALUE self)
|
|
1157
1157
|
* @overload drivers_info
|
1158
1158
|
* Return information of all available rendering contexts.
|
1159
1159
|
* @return [Array<SDL2::Renderer::Info>] information about rendering contexts
|
1160
|
-
*
|
1160
|
+
*
|
1161
1161
|
*/
|
1162
1162
|
static VALUE Renderer_s_drivers_info(VALUE self)
|
1163
1163
|
{
|
@@ -1189,16 +1189,16 @@ static VALUE Renderer_destroy(VALUE self)
|
|
1189
1189
|
* Create a new texture for the rendering context.
|
1190
1190
|
*
|
1191
1191
|
* You can use the following constants to specify access pattern
|
1192
|
-
*
|
1192
|
+
*
|
1193
1193
|
* * {SDL2::Texture::ACCESS_STATIC}
|
1194
1194
|
* * {SDL2::Texture::ACCESS_STREAMING}
|
1195
1195
|
* * {SDL2::Texture::ACCESS_TARGET}
|
1196
|
-
*
|
1196
|
+
*
|
1197
1197
|
* @param [SDL2::PixelFormat,Integer] format format of the texture
|
1198
1198
|
* @param [Integer] access texture access pattern
|
1199
1199
|
* @param [Integer] w the width ofthe texture in pixels
|
1200
1200
|
* @param [Integer] h the height ofthe texture in pixels
|
1201
|
-
*
|
1201
|
+
*
|
1202
1202
|
* @return [SDL2::Texture] the created texture
|
1203
1203
|
*
|
1204
1204
|
* @raise [SDL2::Error] raised when the texture cannot be created
|
@@ -1233,7 +1233,7 @@ static VALUE Renderer_create_texture_from(VALUE self, VALUE surface)
|
|
1233
1233
|
Get_SDL_Surface(surface));
|
1234
1234
|
if (texture == NULL)
|
1235
1235
|
SDL_ERROR();
|
1236
|
-
|
1236
|
+
|
1237
1237
|
return Texture_new(texture, Get_Renderer(self));
|
1238
1238
|
}
|
1239
1239
|
|
@@ -1257,7 +1257,7 @@ static SDL_Point* Get_SDL_Point_or_NULL(VALUE point)
|
|
1257
1257
|
* rendering target; the texture will be stretched to fill the given rectangle
|
1258
1258
|
*
|
1259
1259
|
* @return [void]
|
1260
|
-
*
|
1260
|
+
*
|
1261
1261
|
* @see #copy_ex
|
1262
1262
|
*/
|
1263
1263
|
static VALUE Renderer_copy(VALUE self, VALUE texture, VALUE srcrect, VALUE dstrect)
|
@@ -1276,12 +1276,12 @@ static VALUE Renderer_copy(VALUE self, VALUE texture, VALUE srcrect, VALUE dstre
|
|
1276
1276
|
* it top-bottom and/or left-right.
|
1277
1277
|
*
|
1278
1278
|
* You can use the following constants to specify the horizontal/vertical flip:
|
1279
|
-
*
|
1279
|
+
*
|
1280
1280
|
* * {SDL2::Renderer::FLIP_HORIZONTAL} - flip horizontally
|
1281
1281
|
* * {SDL2::Renderer::FLIP_VERTICAL} - flip vertically
|
1282
1282
|
* * {SDL2::Renderer::FLIP_NONE} - do not flip, equal to zero
|
1283
1283
|
*
|
1284
|
-
*
|
1284
|
+
*
|
1285
1285
|
* @param [SDL2::Texture] texture the source texture
|
1286
1286
|
* @param [SDL2::Rect,nil] srcrect the source rectangle, or nil for the entire texture
|
1287
1287
|
* @param [SDL2::Rect,nil] dstrect the destination rectangle, or nil for the entire
|
@@ -1322,7 +1322,7 @@ static VALUE Renderer_present(VALUE self)
|
|
1322
1322
|
/*
|
1323
1323
|
* Crear the rendering target with the drawing color.
|
1324
1324
|
* @return [nil]
|
1325
|
-
*
|
1325
|
+
*
|
1326
1326
|
* @see #draw_color=
|
1327
1327
|
*/
|
1328
1328
|
static VALUE Renderer_clear(VALUE self)
|
@@ -1331,12 +1331,12 @@ static VALUE Renderer_clear(VALUE self)
|
|
1331
1331
|
return Qnil;
|
1332
1332
|
}
|
1333
1333
|
|
1334
|
-
/*
|
1334
|
+
/*
|
1335
1335
|
* Get the color used for drawing operations
|
1336
1336
|
* @return [[Integer,Integer,Integer,Integer]]
|
1337
1337
|
* red, green, blue, and alpha components of the drawing color
|
1338
1338
|
* (all components are more than or equal to 0 and less than and equal to 255)
|
1339
|
-
*
|
1339
|
+
*
|
1340
1340
|
* @see #draw_color=
|
1341
1341
|
*/
|
1342
1342
|
static VALUE Renderer_draw_color(VALUE self)
|
@@ -1354,29 +1354,29 @@ static VALUE Renderer_draw_color(VALUE self)
|
|
1354
1354
|
* and less than and equal to 255
|
1355
1355
|
*
|
1356
1356
|
* This method effects the following methods.
|
1357
|
-
*
|
1357
|
+
*
|
1358
1358
|
* * {#draw_line}
|
1359
1359
|
* * {#draw_point}
|
1360
1360
|
* * {#draw_rect}
|
1361
1361
|
* * {#fill_rect}
|
1362
1362
|
* * {#clear}
|
1363
|
-
*
|
1363
|
+
*
|
1364
1364
|
* @param [[Integer, Integer, Integer]] color
|
1365
1365
|
* red, green, and blue components used for drawing
|
1366
1366
|
* @param [[Integer, Integer, Integer, Integer]] color
|
1367
1367
|
* red, green, blue, and alpha components used for drawing
|
1368
1368
|
*
|
1369
1369
|
* @return [color]
|
1370
|
-
*
|
1370
|
+
*
|
1371
1371
|
* @see #draw_color
|
1372
1372
|
*/
|
1373
1373
|
static VALUE Renderer_set_draw_color(VALUE self, VALUE rgba)
|
1374
1374
|
{
|
1375
1375
|
SDL_Color color = Array_to_SDL_Color(rgba);
|
1376
|
-
|
1376
|
+
|
1377
1377
|
HANDLE_ERROR(SDL_SetRenderDrawColor(Get_SDL_Renderer(self),
|
1378
1378
|
color.r, color.g, color.b, color.a));
|
1379
|
-
|
1379
|
+
|
1380
1380
|
return rgba;
|
1381
1381
|
}
|
1382
1382
|
|
@@ -1418,7 +1418,7 @@ static VALUE Renderer_draw_point(VALUE self, VALUE x, VALUE y)
|
|
1418
1418
|
* Draw a rectangle using drawing color given by {#draw_color=}.
|
1419
1419
|
*
|
1420
1420
|
* @param [SDL2::Rect] rect the drawing rectangle
|
1421
|
-
*
|
1421
|
+
*
|
1422
1422
|
* @return [nil]
|
1423
1423
|
*/
|
1424
1424
|
static VALUE Renderer_draw_rect(VALUE self, VALUE rect)
|
@@ -1432,7 +1432,7 @@ static VALUE Renderer_draw_rect(VALUE self, VALUE rect)
|
|
1432
1432
|
* Draw a filled rectangle using drawing color given by {#draw_color=}.
|
1433
1433
|
*
|
1434
1434
|
* @param [SDL2::Rect] rect the drawing rectangle
|
1435
|
-
*
|
1435
|
+
*
|
1436
1436
|
* @return [nil]
|
1437
1437
|
*/
|
1438
1438
|
static VALUE Renderer_fill_rect(VALUE self, VALUE rect)
|
@@ -1458,7 +1458,7 @@ static VALUE Renderer_info(VALUE self)
|
|
1458
1458
|
* {#fill_rect} and {#draw_line}.
|
1459
1459
|
*
|
1460
1460
|
* @return [Integer]
|
1461
|
-
*
|
1461
|
+
*
|
1462
1462
|
* @see #draw_blend_mode=
|
1463
1463
|
* @see SDL2::BlendMode
|
1464
1464
|
*/
|
@@ -1474,7 +1474,7 @@ static VALUE Renderer_draw_blend_mode(VALUE self)
|
|
1474
1474
|
* Set the blend mode used for drawing operations.
|
1475
1475
|
*
|
1476
1476
|
* This method effects the following methods.
|
1477
|
-
*
|
1477
|
+
*
|
1478
1478
|
* * {#draw_line}
|
1479
1479
|
* * {#draw_point}
|
1480
1480
|
* * {#draw_rect}
|
@@ -1549,7 +1549,7 @@ static VALUE Renderer_logical_size(VALUE self)
|
|
1549
1549
|
* @overload logical_size=(w_and_h)
|
1550
1550
|
*
|
1551
1551
|
* Set a device indepndent resolution for rendering.
|
1552
|
-
*
|
1552
|
+
*
|
1553
1553
|
* @param w_and_h [[Integer, Integer]] the width and height of the logical resolution
|
1554
1554
|
* @return [w_and_h]
|
1555
1555
|
* @see #logical_size
|
@@ -1582,7 +1582,7 @@ static VALUE Renderer_scale(VALUE self)
|
|
1582
1582
|
*
|
1583
1583
|
* The drawing coordinates are scaled by the x/y scaling factors before they are used by the renderer.
|
1584
1584
|
* This allows resolution independent drawing with a single coordinate system.
|
1585
|
-
*
|
1585
|
+
*
|
1586
1586
|
* If this results in scaling or subpixel drawing by the rendering backend,
|
1587
1587
|
* it will be handled using the appropriate
|
1588
1588
|
* quality hints. For best results use integer scaling factors.
|
@@ -1614,7 +1614,7 @@ static VALUE Renderer_viewport(VALUE self)
|
|
1614
1614
|
}
|
1615
1615
|
|
1616
1616
|
/*
|
1617
|
-
* @overload viewport=(area)
|
1617
|
+
* @overload viewport=(area)
|
1618
1618
|
* Set the drawing area for rendering on the current target.
|
1619
1619
|
*
|
1620
1620
|
* @param area [SDL2::Rect,nil] the drawing area, or nil to set the viewport to the entire target
|
@@ -1652,19 +1652,19 @@ static VALUE Renderer_output_size(VALUE self)
|
|
1652
1652
|
/*
|
1653
1653
|
* @overload render_target=(target)
|
1654
1654
|
* Set a texture as the current render target.
|
1655
|
-
*
|
1655
|
+
*
|
1656
1656
|
* Some renderers have ability to render to a texture instead of a screen.
|
1657
1657
|
* You can judge whether your renderer has this ability using
|
1658
1658
|
* {#support_render_target?}.
|
1659
|
-
*
|
1659
|
+
*
|
1660
1660
|
* The target texture musbe be {#create_texture created} with the
|
1661
1661
|
* {SDL2::Texture::ACCESS_TARGET} flag.
|
1662
|
-
*
|
1662
|
+
*
|
1663
1663
|
* @param [SDL2::Texture,nil] target the targeted texture, or nil
|
1664
1664
|
* for the default render target(i.e. screen)
|
1665
1665
|
*
|
1666
1666
|
* @return [target]
|
1667
|
-
*
|
1667
|
+
*
|
1668
1668
|
* @see #render_target
|
1669
1669
|
*/
|
1670
1670
|
static VALUE Renderer_set_render_target(VALUE self, VALUE target)
|
@@ -1714,7 +1714,7 @@ static VALUE Renderer_debug_info(VALUE self)
|
|
1714
1714
|
++num_active_textures;
|
1715
1715
|
rb_hash_aset(info, rb_str_new2("num_active_textures"), INT2NUM(num_active_textures));
|
1716
1716
|
rb_hash_aset(info, rb_str_new2("refcount"), INT2NUM(r->refcount));
|
1717
|
-
|
1717
|
+
|
1718
1718
|
return info;
|
1719
1719
|
}
|
1720
1720
|
|
@@ -1731,7 +1731,7 @@ static VALUE Renderer_debug_info(VALUE self)
|
|
1731
1731
|
*
|
1732
1732
|
* @!attribute [r] max_texture_width
|
1733
1733
|
* @return [Integer] maximum texture width
|
1734
|
-
*
|
1734
|
+
*
|
1735
1735
|
* @!attribute [r] max_texture_height
|
1736
1736
|
* @return [Integer] maximum texture height
|
1737
1737
|
*/
|
@@ -1741,7 +1741,7 @@ static VALUE Renderer_debug_info(VALUE self)
|
|
1741
1741
|
*
|
1742
1742
|
* The OR'd bits of the constants of this module represents
|
1743
1743
|
* the state of renderers.
|
1744
|
-
*
|
1744
|
+
*
|
1745
1745
|
* You can use this flag
|
1746
1746
|
* {SDL2::Window#create_renderer when you create a new renderer}.
|
1747
1747
|
* No flags(==0) gives priority to available ACCELERATED renderers.
|
@@ -1785,7 +1785,7 @@ static VALUE Texture_destroy(VALUE self)
|
|
1785
1785
|
* Get the blending mode of the texture.
|
1786
1786
|
*
|
1787
1787
|
* @return [Integer] blend mode
|
1788
|
-
*
|
1788
|
+
*
|
1789
1789
|
* @see #blend_mode=
|
1790
1790
|
*/
|
1791
1791
|
static VALUE Texture_blend_mode(VALUE self)
|
@@ -1825,7 +1825,7 @@ static VALUE Texture_alpha_mod(VALUE self)
|
|
1825
1825
|
}
|
1826
1826
|
|
1827
1827
|
/*
|
1828
|
-
* @overload alpha_mod=(alpha)
|
1828
|
+
* @overload alpha_mod=(alpha)
|
1829
1829
|
* Set an additional alpha value used in render copy operations.
|
1830
1830
|
*
|
1831
1831
|
* @param alpha [Integer] the alpha value multiplied into copy operation,
|
@@ -1854,9 +1854,9 @@ static VALUE Texture_color_mod(VALUE self)
|
|
1854
1854
|
}
|
1855
1855
|
|
1856
1856
|
/*
|
1857
|
-
* @overload color_mod=(rgb)
|
1857
|
+
* @overload color_mod=(rgb)
|
1858
1858
|
* Set an additional color value used in render copy operations.
|
1859
|
-
*
|
1859
|
+
*
|
1860
1860
|
* @param rgb [[Integer, Integer, Integer]] the red, green, and blue
|
1861
1861
|
* color value multiplied into copy operations.
|
1862
1862
|
* @return [rgb]
|
@@ -1885,13 +1885,13 @@ static VALUE Texture_format(VALUE self)
|
|
1885
1885
|
* Get the access pattern allowed for the texture.
|
1886
1886
|
*
|
1887
1887
|
* The return value is one of the following:
|
1888
|
-
*
|
1888
|
+
*
|
1889
1889
|
* * {SDL2::Texture::ACCESS_STATIC}
|
1890
1890
|
* * {SDL2::Texture::ACCESS_STREAMING}
|
1891
1891
|
* * {SDL2::Texture::ACCESS_TARGET}
|
1892
1892
|
*
|
1893
1893
|
* @return [Integer]
|
1894
|
-
*
|
1894
|
+
*
|
1895
1895
|
* @see SDL2::Renderer#create_texture
|
1896
1896
|
*/
|
1897
1897
|
static VALUE Texture_access_pattern(VALUE self)
|
@@ -1905,7 +1905,7 @@ static VALUE Texture_access_pattern(VALUE self)
|
|
1905
1905
|
* Get the width of the texture.
|
1906
1906
|
*
|
1907
1907
|
* @return [Integer]
|
1908
|
-
*
|
1908
|
+
*
|
1909
1909
|
* @see SDL2::Renderer#create_texture
|
1910
1910
|
*/
|
1911
1911
|
static VALUE Texture_w(VALUE self)
|
@@ -1919,7 +1919,7 @@ static VALUE Texture_w(VALUE self)
|
|
1919
1919
|
* Get the height of the texture.
|
1920
1920
|
*
|
1921
1921
|
* @return [Integer]
|
1922
|
-
*
|
1922
|
+
*
|
1923
1923
|
* @see SDL2::Renderer#create_texture
|
1924
1924
|
*/
|
1925
1925
|
static VALUE Texture_h(VALUE self)
|
@@ -1937,7 +1937,7 @@ static VALUE Texture_inspect(VALUE self)
|
|
1937
1937
|
int access, w, h;
|
1938
1938
|
if (!t->texture)
|
1939
1939
|
return rb_sprintf("<%s: (destroyed)>", rb_obj_classname(self));
|
1940
|
-
|
1940
|
+
|
1941
1941
|
HANDLE_ERROR(SDL_QueryTexture(t->texture, &format, &access, &w, &h));
|
1942
1942
|
return rb_sprintf("<%s:%p format=%s access=%d w=%d h=%d>",
|
1943
1943
|
rb_obj_classname(self), (void*)self, SDL_GetPixelFormatName(format),
|
@@ -1994,6 +1994,26 @@ static VALUE Surface_s_load_bmp(VALUE self, VALUE fname)
|
|
1994
1994
|
return Surface_new(surface);
|
1995
1995
|
}
|
1996
1996
|
|
1997
|
+
/*
|
1998
|
+
* @overload save_bmp(src, path)
|
1999
|
+
* Save a surface to bmp file.
|
2000
|
+
*
|
2001
|
+
* @param src [SDL2::Surface] surface source
|
2002
|
+
* @param path [String] bmp file path
|
2003
|
+
* @return [Integer]
|
2004
|
+
* @raise [SDL2::Error] raised when an error occurs.
|
2005
|
+
*
|
2006
|
+
*/
|
2007
|
+
static VALUE Surface_s_save_bmp(VALUE self, VALUE src, VALUE fname)
|
2008
|
+
{
|
2009
|
+
SDL_Surface* surface = Get_SDL_Surface(src);
|
2010
|
+
|
2011
|
+
if (surface == NULL)
|
2012
|
+
HANDLE_ERROR(-1);
|
2013
|
+
|
2014
|
+
return INT2NUM(SDL_SaveBMP(surface, StringValueCStr(fname)));
|
2015
|
+
}
|
2016
|
+
|
1997
2017
|
/*
|
1998
2018
|
* @overload from_string(string, width, heigth, depth, pitch=nil, rmask=nil, gmask=nil, bmask=nil, amask=nil)
|
1999
2019
|
*
|
@@ -2001,7 +2021,7 @@ static VALUE Surface_s_load_bmp(VALUE self, VALUE fname)
|
|
2001
2021
|
*
|
2002
2022
|
* If rmask, gmask, bmask are omitted, the default masks are used.
|
2003
2023
|
* If amask is omitted, alpha mask is considered to be zero.
|
2004
|
-
*
|
2024
|
+
*
|
2005
2025
|
* @param string [String] the pixel data
|
2006
2026
|
* @param width [Integer] the width of the creating surface
|
2007
2027
|
* @param height [Integer] the height of the creating surface
|
@@ -2014,7 +2034,7 @@ static VALUE Surface_s_load_bmp(VALUE self, VALUE fname)
|
|
2014
2034
|
* @param amask [Integer] the alpha mask of a pixel
|
2015
2035
|
* @return [SDL2::Surface] a new surface
|
2016
2036
|
* @raise [SDL2::Error] raised when an error occurs in C SDL library
|
2017
|
-
*
|
2037
|
+
*
|
2018
2038
|
*/
|
2019
2039
|
static VALUE Surface_s_from_string(int argc, VALUE* argv, VALUE self)
|
2020
2040
|
{
|
@@ -2023,7 +2043,7 @@ static VALUE Surface_s_from_string(int argc, VALUE* argv, VALUE self)
|
|
2023
2043
|
SDL_Surface* surface;
|
2024
2044
|
void* pixels;
|
2025
2045
|
Surface* s;
|
2026
|
-
|
2046
|
+
|
2027
2047
|
rb_scan_args(argc, argv, "45", &string, &width, &height, &depth,
|
2028
2048
|
&pitch, &Rmask, &Gmask, &Bmask, &Amask);
|
2029
2049
|
StringValue(string);
|
@@ -2046,7 +2066,7 @@ static VALUE Surface_s_from_string(int argc, VALUE* argv, VALUE self)
|
|
2046
2066
|
surface = SDL_CreateRGBSurfaceFrom(pixels, w, h, d, p, r, g, b, a);
|
2047
2067
|
if (!surface)
|
2048
2068
|
SDL_ERROR();
|
2049
|
-
|
2069
|
+
|
2050
2070
|
RB_GC_GUARD(string);
|
2051
2071
|
|
2052
2072
|
s = ALLOC(Surface);
|
@@ -2115,7 +2135,7 @@ static VALUE Surface_must_lock_p(VALUE self)
|
|
2115
2135
|
* Lock the surface.
|
2116
2136
|
*
|
2117
2137
|
* @return [nil]
|
2118
|
-
*
|
2138
|
+
*
|
2119
2139
|
* @see #unlock
|
2120
2140
|
* @see #must_lock?
|
2121
2141
|
*/
|
@@ -2129,7 +2149,7 @@ static VALUE Surface_lock(VALUE self)
|
|
2129
2149
|
* Unlock the surface.
|
2130
2150
|
*
|
2131
2151
|
* @return [nil]
|
2132
|
-
*
|
2152
|
+
*
|
2133
2153
|
* @see #lock
|
2134
2154
|
*/
|
2135
2155
|
static VALUE Surface_unlock(VALUE self)
|
@@ -2139,7 +2159,7 @@ static VALUE Surface_unlock(VALUE self)
|
|
2139
2159
|
}
|
2140
2160
|
|
2141
2161
|
/*
|
2142
|
-
* @overload pixel(x, y)
|
2162
|
+
* @overload pixel(x, y)
|
2143
2163
|
* Get a pixel data at (**x**, **y**)
|
2144
2164
|
*
|
2145
2165
|
* @param x [Integer] the x coordinate
|
@@ -2147,7 +2167,7 @@ static VALUE Surface_unlock(VALUE self)
|
|
2147
2167
|
* @return [Integer] pixel data
|
2148
2168
|
*
|
2149
2169
|
* @see #pixel_color
|
2150
|
-
*
|
2170
|
+
*
|
2151
2171
|
*/
|
2152
2172
|
static VALUE Surface_pixel(VALUE self, VALUE x_coord, VALUE y_coord)
|
2153
2173
|
{
|
@@ -2157,7 +2177,7 @@ static VALUE Surface_pixel(VALUE self, VALUE x_coord, VALUE y_coord)
|
|
2157
2177
|
int offset;
|
2158
2178
|
Uint32 pixel = 0;
|
2159
2179
|
int i;
|
2160
|
-
|
2180
|
+
|
2161
2181
|
if (x < 0 || x >= surface->w || y < 0 || y >= surface->h)
|
2162
2182
|
rb_raise(rb_eArgError, "(%d, %d) out of range for %dx%d",
|
2163
2183
|
x, y, surface->w, surface->h);
|
@@ -2271,7 +2291,7 @@ static VALUE Surface_unset_color_key(VALUE self)
|
|
2271
2291
|
}
|
2272
2292
|
|
2273
2293
|
/*
|
2274
|
-
* @overload color_key=(key)
|
2294
|
+
* @overload color_key=(key)
|
2275
2295
|
* Set the color key of the surface
|
2276
2296
|
*
|
2277
2297
|
* @param key [Integer, Array<Integer>]
|
@@ -2288,9 +2308,9 @@ static VALUE Surface_set_color_key(VALUE self, VALUE key)
|
|
2288
2308
|
SDL_Surface* surface = Get_SDL_Surface(self);
|
2289
2309
|
if (key == Qnil)
|
2290
2310
|
return Surface_unset_color_key(self);
|
2291
|
-
|
2311
|
+
|
2292
2312
|
HANDLE_ERROR(SDL_SetColorKey(surface, SDL_TRUE, pixel_value(key, surface->format)));
|
2293
|
-
|
2313
|
+
|
2294
2314
|
return key;
|
2295
2315
|
}
|
2296
2316
|
|
@@ -2374,7 +2394,7 @@ static VALUE Surface_s_blit(VALUE self, VALUE src, VALUE srcrect, VALUE dst, VAL
|
|
2374
2394
|
* @param gmask [Integer] the green mask of a pixel
|
2375
2395
|
* @param bmask [Integer] the blue mask of a pixel
|
2376
2396
|
* @param amask [Integer] the alpha mask of a pixel
|
2377
|
-
*
|
2397
|
+
*
|
2378
2398
|
* @return [SDL2::Surface]
|
2379
2399
|
*/
|
2380
2400
|
static VALUE Surface_s_new(int argc, VALUE* argv, VALUE self)
|
@@ -2382,14 +2402,14 @@ static VALUE Surface_s_new(int argc, VALUE* argv, VALUE self)
|
|
2382
2402
|
VALUE width, height, depth;
|
2383
2403
|
Uint32 Rmask, Gmask, Bmask, Amask;
|
2384
2404
|
SDL_Surface * surface;
|
2385
|
-
|
2405
|
+
|
2386
2406
|
if (argc == 3) {
|
2387
2407
|
rb_scan_args(argc, argv, "30", &width, &height, &depth);
|
2388
2408
|
Rmask = Gmask = Bmask = Amask = 0;
|
2389
2409
|
} else if (argc == 7) {
|
2390
2410
|
VALUE rm, gm, bm, am;
|
2391
2411
|
rb_scan_args(argc, argv, "70", &width, &height, &depth, &rm, &gm, &bm, &am);
|
2392
|
-
Rmask = NUM2UINT(rm); Gmask = NUM2UINT(gm);
|
2412
|
+
Rmask = NUM2UINT(rm); Gmask = NUM2UINT(gm);
|
2393
2413
|
Bmask = NUM2UINT(bm); Amask = NUM2UINT(am);
|
2394
2414
|
} else {
|
2395
2415
|
rb_raise(rb_eArgError, "wrong number of arguments (%d for 4 or 7)", argc);
|
@@ -2447,23 +2467,23 @@ static VALUE Rect_s_allocate(VALUE klass)
|
|
2447
2467
|
{
|
2448
2468
|
SDL_Rect* rect = ALLOC(SDL_Rect);
|
2449
2469
|
rect->x = rect->y = rect->w = rect->h = 0;
|
2450
|
-
|
2470
|
+
|
2451
2471
|
return Data_Wrap_Struct(cRect, 0, free, rect);
|
2452
2472
|
}
|
2453
2473
|
|
2454
|
-
/*
|
2474
|
+
/*
|
2455
2475
|
* Create a new SDL2::Rect object
|
2456
2476
|
*
|
2457
2477
|
* @return [SDL2::Rect]
|
2458
|
-
*
|
2478
|
+
*
|
2459
2479
|
* @overload initialze(x, y, w, h)
|
2460
2480
|
* Create a new SDL2::Rect object
|
2461
|
-
*
|
2481
|
+
*
|
2462
2482
|
* @param x [Integer] X coordiante of the left-top point of the rectangle
|
2463
2483
|
* @param y [Integer] Y coordiante of the left-top point of the rectangle
|
2464
2484
|
* @param w [Integer] Width of the rectangle
|
2465
2485
|
* @param h [Integer] Height of the rectangle
|
2466
|
-
*
|
2486
|
+
*
|
2467
2487
|
* @overload initialize
|
2468
2488
|
* Create a new SDL2::Rect object whose x, w, w, and h are all
|
2469
2489
|
* zero.
|
@@ -2506,7 +2526,7 @@ FIELD_ACCESSOR(Rect, SDL_Rect, h);
|
|
2506
2526
|
* Returns the intersection rect of self and other.
|
2507
2527
|
*
|
2508
2528
|
* If there is no intersection, returns nil.
|
2509
|
-
*
|
2529
|
+
*
|
2510
2530
|
* @return [SDL2::Rect, nil]
|
2511
2531
|
* @param [SDL2::Rect] other rectangle
|
2512
2532
|
*/
|
@@ -2534,10 +2554,10 @@ static VALUE Rect_union(VALUE self, VALUE other)
|
|
2534
2554
|
return result;
|
2535
2555
|
}
|
2536
2556
|
|
2537
|
-
/*
|
2557
|
+
/*
|
2538
2558
|
* Document-class: SDL2::Point
|
2539
2559
|
*
|
2540
|
-
* This class represents a point in SDL library.
|
2560
|
+
* This class represents a point in SDL library.
|
2541
2561
|
* Some method requires this method.
|
2542
2562
|
*
|
2543
2563
|
* @!attribute [rw] x
|
@@ -2556,16 +2576,16 @@ static VALUE Point_s_allocate(VALUE klass)
|
|
2556
2576
|
|
2557
2577
|
/*
|
2558
2578
|
* Create a new point object.
|
2559
|
-
*
|
2579
|
+
*
|
2560
2580
|
* @overload initialize(x, y)
|
2561
2581
|
* @param x the x coordinate of the point
|
2562
2582
|
* @param y the y coordinate of the point
|
2563
|
-
*
|
2583
|
+
*
|
2564
2584
|
* @overload initialize
|
2565
2585
|
* x and y of the created point object are initialized by 0
|
2566
2586
|
*
|
2567
2587
|
* @return [SDL2::Point]
|
2568
|
-
*
|
2588
|
+
*
|
2569
2589
|
*/
|
2570
2590
|
static VALUE Point_initialize(int argc, VALUE* argv, VALUE self)
|
2571
2591
|
{
|
@@ -2609,7 +2629,7 @@ FIELD_ACCESSOR(Point, SDL_Point, y);
|
|
2609
2629
|
* @overload initialze(format)
|
2610
2630
|
*
|
2611
2631
|
* Initialize pixel format from the given integer representing a fomrmat.
|
2612
|
-
*
|
2632
|
+
*
|
2613
2633
|
* @param format [Integer] an unsigned integer as a pixel formats
|
2614
2634
|
*/
|
2615
2635
|
static VALUE PixelForamt_initialize(VALUE self, VALUE format)
|
@@ -2638,7 +2658,7 @@ define(`PIXELFORMAT_ATTR_READER',
|
|
2638
2658
|
|
2639
2659
|
/*
|
2640
2660
|
* Get the human readable name of the pixel format
|
2641
|
-
*
|
2661
|
+
*
|
2642
2662
|
* @return [String]
|
2643
2663
|
*/
|
2644
2664
|
PIXELFORMAT_ATTR_READER(name, SDL_GetPixelFormatName, utf8str_new_cstr);
|
@@ -2687,7 +2707,7 @@ PIXELFORMAT_ATTR_READER(alpha_p, SDL_ISPIXELFORMAT_ALPHA, INT2BOOL);
|
|
2687
2707
|
*/
|
2688
2708
|
PIXELFORMAT_ATTR_READER(fourcc_p, SDL_ISPIXELFORMAT_FOURCC, INT2BOOL);
|
2689
2709
|
|
2690
|
-
/*
|
2710
|
+
/*
|
2691
2711
|
* @overload ==(other)
|
2692
2712
|
* Return true if two pixel format is the same format.
|
2693
2713
|
*
|
@@ -2763,15 +2783,15 @@ static VALUE ScreenSaver_enabled_p(VALUE self)
|
|
2763
2783
|
define(`DEFINE_C_ACCESSOR',`rb_define_method($2, "$3", $1_$3, 0);
|
2764
2784
|
rb_define_method($2, "$3=", $1_set_$3, 1)')
|
2765
2785
|
*/
|
2766
|
-
|
2786
|
+
|
2767
2787
|
void rubysdl2_init_video(void)
|
2768
2788
|
{
|
2769
2789
|
rb_define_module_function(mSDL2, "video_drivers", SDL2_s_video_drivers, 0);
|
2770
2790
|
rb_define_module_function(mSDL2, "current_video_driver", SDL2_s_current_video_driver, 0);
|
2771
2791
|
rb_define_module_function(mSDL2, "video_init", SDL2_s_video_init, 1);
|
2772
|
-
|
2792
|
+
|
2773
2793
|
cWindow = rb_define_class_under(mSDL2, "Window", rb_cObject);
|
2774
|
-
|
2794
|
+
|
2775
2795
|
rb_undef_alloc_func(cWindow);
|
2776
2796
|
rb_define_singleton_method(cWindow, "create", Window_s_create, 6);
|
2777
2797
|
rb_define_singleton_method(cWindow, "all_windows", Window_s_all_windows, 0);
|
@@ -2817,11 +2837,11 @@ void rubysdl2_init_video(void)
|
|
2817
2837
|
|
2818
2838
|
mWindowFlags = rb_define_module_under(cWindow, "Flags");
|
2819
2839
|
/* define(`DEFINE_WINDOW_FLAGS_CONST',`rb_define_const(mWindowFlags, "$1", UINT2NUM(SDL_WINDOW_$1))') */
|
2820
|
-
/* fullscreen window */
|
2840
|
+
/* fullscreen window */
|
2821
2841
|
DEFINE_WINDOW_FLAGS_CONST(FULLSCREEN);
|
2822
2842
|
/* fullscreen window at the current desktop resolution */
|
2823
2843
|
DEFINE_WINDOW_FLAGS_CONST(FULLSCREEN_DESKTOP);
|
2824
|
-
/* window usable with OpenGL context */
|
2844
|
+
/* window usable with OpenGL context */
|
2825
2845
|
DEFINE_WINDOW_FLAGS_CONST(OPENGL);
|
2826
2846
|
/* window is visible */
|
2827
2847
|
DEFINE_WINDOW_FLAGS_CONST(SHOWN);
|
@@ -2829,7 +2849,7 @@ void rubysdl2_init_video(void)
|
|
2829
2849
|
DEFINE_WINDOW_FLAGS_CONST(HIDDEN);
|
2830
2850
|
/* no window decoration */
|
2831
2851
|
DEFINE_WINDOW_FLAGS_CONST(BORDERLESS);
|
2832
|
-
/* window is resizable */
|
2852
|
+
/* window is resizable */
|
2833
2853
|
DEFINE_WINDOW_FLAGS_CONST(RESIZABLE);
|
2834
2854
|
/* window is minimized */
|
2835
2855
|
DEFINE_WINDOW_FLAGS_CONST(MINIMIZED);
|
@@ -2853,17 +2873,17 @@ void rubysdl2_init_video(void)
|
|
2853
2873
|
#endif
|
2854
2874
|
|
2855
2875
|
cDisplay = rb_define_class_under(mSDL2, "Display", rb_cObject);
|
2856
|
-
|
2876
|
+
|
2857
2877
|
rb_define_module_function(cDisplay, "displays", Display_s_displays, 0);
|
2858
2878
|
rb_define_attr(cDisplay, "index", 1, 0);
|
2859
2879
|
rb_define_attr(cDisplay, "name", 1, 0);
|
2860
|
-
rb_define_method(cDisplay, "modes", Display_modes, 0);
|
2880
|
+
rb_define_method(cDisplay, "modes", Display_modes, 0);
|
2861
2881
|
rb_define_method(cDisplay, "current_mode", Display_current_mode, 0);
|
2862
2882
|
rb_define_method(cDisplay, "desktop_mode", Display_desktop_mode, 0);
|
2863
2883
|
rb_define_method(cDisplay, "closest_mode", Display_closest_mode, 1);
|
2864
2884
|
rb_define_method(cDisplay, "bounds", Display_bounds, 0);
|
2865
2885
|
|
2866
|
-
|
2886
|
+
|
2867
2887
|
cDisplayMode = rb_define_class_under(cDisplay, "Mode", rb_cObject);
|
2868
2888
|
|
2869
2889
|
rb_define_alloc_func(cDisplayMode, DisplayMode_s_allocate);
|
@@ -2873,10 +2893,10 @@ void rubysdl2_init_video(void)
|
|
2873
2893
|
rb_define_method(cDisplayMode, "w", DisplayMode_w, 0);
|
2874
2894
|
rb_define_method(cDisplayMode, "h", DisplayMode_h, 0);
|
2875
2895
|
rb_define_method(cDisplayMode, "refresh_rate", DisplayMode_refresh_rate, 0);
|
2876
|
-
|
2877
|
-
|
2896
|
+
|
2897
|
+
|
2878
2898
|
cRenderer = rb_define_class_under(mSDL2, "Renderer", rb_cObject);
|
2879
|
-
|
2899
|
+
|
2880
2900
|
rb_undef_alloc_func(cRenderer);
|
2881
2901
|
rb_define_singleton_method(cRenderer, "drivers_info", Renderer_s_drivers_info, 0);
|
2882
2902
|
rb_define_method(cRenderer, "destroy?", Renderer_destroy_p, 0);
|
@@ -2912,11 +2932,11 @@ void rubysdl2_init_video(void)
|
|
2912
2932
|
rb_define_method(cRenderer, "render_target", Renderer_render_target, 0);
|
2913
2933
|
rb_define_method(cRenderer, "render_target=", Renderer_set_render_target, 1);
|
2914
2934
|
rb_define_method(cRenderer, "reset_render_target", Renderer_reset_render_target, 0);
|
2915
|
-
|
2935
|
+
|
2916
2936
|
rb_define_method(cRenderer, "info", Renderer_info, 0);
|
2917
2937
|
|
2918
2938
|
mRendererFlags = rb_define_module_under(cRenderer, "Flags");
|
2919
|
-
|
2939
|
+
|
2920
2940
|
/* define(`DEFINE_RENDERER_FLAGS_CONST',`rb_define_const(mRendererFlags, "$1", UINT2NUM(SDL_RENDERER_$1))') */
|
2921
2941
|
/* the renderer is a software fallback */
|
2922
2942
|
DEFINE_RENDERER_FLAGS_CONST(SOFTWARE);
|
@@ -2926,7 +2946,7 @@ void rubysdl2_init_video(void)
|
|
2926
2946
|
/* present is synchronized with the refresh rate */
|
2927
2947
|
DEFINE_RENDERER_FLAGS_CONST(PRESENTVSYNC);
|
2928
2948
|
#endif
|
2929
|
-
/* the renderer supports rendering to texture */
|
2949
|
+
/* the renderer supports rendering to texture */
|
2930
2950
|
DEFINE_RENDERER_FLAGS_CONST(TARGETTEXTURE);
|
2931
2951
|
/* define(`DEFINE_SDL_FLIP_CONST',`rb_define_const(cRenderer, "FLIP_$1", INT2FIX(SDL_FLIP_$1))') */
|
2932
2952
|
/* Do not flip, used in {Renderer#copy_ex} */
|
@@ -2935,7 +2955,7 @@ void rubysdl2_init_video(void)
|
|
2935
2955
|
DEFINE_SDL_FLIP_CONST(HORIZONTAL);
|
2936
2956
|
/* Flip vertically, used in {Renderer#copy_ex} */
|
2937
2957
|
DEFINE_SDL_FLIP_CONST(VERTICAL);
|
2938
|
-
|
2958
|
+
|
2939
2959
|
mBlendMode = rb_define_module_under(mSDL2, "BlendMode");
|
2940
2960
|
/* define(`DEFINE_BLENDMODE_CONST',`rb_define_const(mBlendMode, "$1", INT2FIX(SDL_BLENDMODE_$1))') */
|
2941
2961
|
/* no blending (dstRGBA = srcRGBA) */
|
@@ -2946,9 +2966,9 @@ void rubysdl2_init_video(void)
|
|
2946
2966
|
DEFINE_BLENDMODE_CONST(ADD);
|
2947
2967
|
/* color modulate (multiplicative) (dstRGB = srcRGB * dstRGB, dstA = dstA) */
|
2948
2968
|
DEFINE_BLENDMODE_CONST(MOD);
|
2949
|
-
|
2969
|
+
|
2950
2970
|
cTexture = rb_define_class_under(mSDL2, "Texture", rb_cObject);
|
2951
|
-
|
2971
|
+
|
2952
2972
|
rb_undef_alloc_func(cTexture);
|
2953
2973
|
rb_define_method(cTexture, "destroy?", Texture_destroy_p, 0);
|
2954
2974
|
rb_define_method(cTexture, "destroy", Texture_destroy, 0);
|
@@ -2969,11 +2989,12 @@ void rubysdl2_init_video(void)
|
|
2969
2989
|
/* texture access pattern - can be used as a render target */
|
2970
2990
|
DEFINE_TEXTUREAH_ACCESS_CONST(TARGET);
|
2971
2991
|
|
2972
|
-
|
2992
|
+
|
2973
2993
|
cSurface = rb_define_class_under(mSDL2, "Surface", rb_cObject);
|
2974
|
-
|
2994
|
+
|
2975
2995
|
rb_undef_alloc_func(cSurface);
|
2976
2996
|
rb_define_singleton_method(cSurface, "load_bmp", Surface_s_load_bmp, 1);
|
2997
|
+
rb_define_singleton_method(cSurface, "save_bmp", Surface_s_save_bmp, 2);
|
2977
2998
|
rb_define_singleton_method(cSurface, "blit", Surface_s_blit, 4);
|
2978
2999
|
rb_define_singleton_method(cSurface, "new", Surface_s_new, -1);
|
2979
3000
|
rb_define_singleton_method(cSurface, "from_string", Surface_s_from_string, -1);
|
@@ -2994,7 +3015,7 @@ void rubysdl2_init_video(void)
|
|
2994
3015
|
rb_define_method(cSurface, "pitch", Surface_pitch, 0);
|
2995
3016
|
rb_define_method(cSurface, "bits_per_pixel", Surface_bits_per_pixel, 0);
|
2996
3017
|
rb_define_method(cSurface, "bytes_per_pixel", Surface_bytes_per_pixel, 0);
|
2997
|
-
|
3018
|
+
|
2998
3019
|
cRect = rb_define_class_under(mSDL2, "Rect", rb_cObject);
|
2999
3020
|
|
3000
3021
|
rb_define_alloc_func(cRect, Rect_s_allocate);
|
@@ -3007,7 +3028,7 @@ void rubysdl2_init_video(void)
|
|
3007
3028
|
DEFINE_C_ACCESSOR(Rect, cRect, h);
|
3008
3029
|
rb_define_method(cRect, "union", Rect_union, 1);
|
3009
3030
|
rb_define_method(cRect, "intersection", Rect_intersection, 1);
|
3010
|
-
|
3031
|
+
|
3011
3032
|
cPoint = rb_define_class_under(mSDL2, "Point", rb_cObject);
|
3012
3033
|
|
3013
3034
|
rb_define_alloc_func(cPoint, Point_s_allocate);
|
@@ -3017,14 +3038,14 @@ void rubysdl2_init_video(void)
|
|
3017
3038
|
DEFINE_C_ACCESSOR(Point, cPoint, x);
|
3018
3039
|
DEFINE_C_ACCESSOR(Point, cPoint, y);
|
3019
3040
|
|
3020
|
-
|
3041
|
+
|
3021
3042
|
cRendererInfo = rb_define_class_under(cRenderer, "Info", rb_cObject);
|
3022
3043
|
define_attr_readers(cRendererInfo, "name", "flags", "texture_formats",
|
3023
3044
|
"max_texture_width", "max_texture_height", NULL);
|
3024
|
-
|
3025
|
-
|
3045
|
+
|
3046
|
+
|
3026
3047
|
cPixelFormat = rb_define_class_under(mSDL2, "PixelFormat", rb_cObject);
|
3027
|
-
|
3048
|
+
|
3028
3049
|
rb_define_method(cPixelFormat, "initialize", PixelForamt_initialize, 1);
|
3029
3050
|
rb_define_attr(cPixelFormat, "format", 1, 0);
|
3030
3051
|
rb_define_method(cPixelFormat, "name", PixelFormat_name, 0);
|
@@ -3059,7 +3080,7 @@ void rubysdl2_init_video(void)
|
|
3059
3080
|
rb_define_const(mBitmapOrder, "NONE", UINT2NUM(SDL_BITMAPORDER_NONE));
|
3060
3081
|
rb_define_const(mBitmapOrder, "O_1234", UINT2NUM(SDL_BITMAPORDER_1234));
|
3061
3082
|
rb_define_const(mBitmapOrder, "O_4321", UINT2NUM(SDL_BITMAPORDER_4321));
|
3062
|
-
|
3083
|
+
|
3063
3084
|
mPackedOrder = rb_define_module_under(cPixelFormat, "PackedOrder");
|
3064
3085
|
/* define(`DEFINE_PACKEDORDER_CONST',`rb_define_const(mPackedOrder, "$1", UINT2NUM(SDL_PACKEDORDER_$1))') */
|
3065
3086
|
DEFINE_PACKEDORDER_CONST(NONE);
|
@@ -3093,7 +3114,7 @@ void rubysdl2_init_video(void)
|
|
3093
3114
|
DEFINE_PACKEDLAYOUT_CONST(8888);
|
3094
3115
|
DEFINE_PACKEDLAYOUT_CONST(2101010);
|
3095
3116
|
DEFINE_PACKEDLAYOUT_CONST(1010102);
|
3096
|
-
|
3117
|
+
|
3097
3118
|
{
|
3098
3119
|
VALUE formats = rb_ary_new();
|
3099
3120
|
/* -: Array of all available formats */
|
@@ -3105,7 +3126,7 @@ void rubysdl2_init_video(void)
|
|
3105
3126
|
rb_ary_push(formats, format);
|
3106
3127
|
} while (0)')
|
3107
3128
|
*/
|
3108
|
-
|
3129
|
+
|
3109
3130
|
DEFINE_PIXELFORMAT_CONST(UNKNOWN, /* -: PixelFormat: Unused - reserved by SDL */);
|
3110
3131
|
DEFINE_PIXELFORMAT_CONST(INDEX1LSB);
|
3111
3132
|
DEFINE_PIXELFORMAT_CONST(INDEX1MSB);
|
@@ -3149,12 +3170,12 @@ void rubysdl2_init_video(void)
|
|
3149
3170
|
rb_define_module_function(mScreenSaver, "enable", ScreenSaver_enable, 0);
|
3150
3171
|
rb_define_module_function(mScreenSaver, "disable", ScreenSaver_disable, 0);
|
3151
3172
|
rb_define_module_function(mScreenSaver, "enabled?", ScreenSaver_enabled_p, 0);
|
3152
|
-
|
3153
|
-
|
3173
|
+
|
3174
|
+
|
3154
3175
|
rb_gc_register_address(&hash_windowid_to_window);
|
3155
3176
|
hash_windowid_to_window = rb_hash_new();
|
3156
3177
|
}
|
3157
|
-
|
3178
|
+
|
3158
3179
|
#ifdef HAVE_SDL_IMAGE_H
|
3159
3180
|
#include <SDL_image.h>
|
3160
3181
|
|
@@ -3165,15 +3186,15 @@ static VALUE mIMG;
|
|
3165
3186
|
*
|
3166
3187
|
* This module provides the interface to SDL_image. You can load
|
3167
3188
|
* many kinds of image files using this modules.
|
3168
|
-
*
|
3189
|
+
*
|
3169
3190
|
* This module provides only initialization interface {SDL2::IMG.init}.
|
3170
3191
|
* After calling init, you can load image files using {SDL2::Surface.load}.
|
3171
3192
|
*/
|
3172
3193
|
|
3173
3194
|
/*
|
3174
3195
|
* @overload init(flags)
|
3175
|
-
* Initialize SDL_image.
|
3176
|
-
*
|
3196
|
+
* Initialize SDL_image.
|
3197
|
+
*
|
3177
3198
|
* You can specify the supporting image formats by bitwise OR'd of the
|
3178
3199
|
* following constants.
|
3179
3200
|
*
|
@@ -3185,7 +3206,7 @@ static VALUE mIMG;
|
|
3185
3206
|
* You need to initialize SDL_image to check whether specified format
|
3186
3207
|
* is supported by your environment. If your environment does not
|
3187
3208
|
* support required support format, you have a {SDL2::Error} exception.
|
3188
|
-
*
|
3209
|
+
*
|
3189
3210
|
* @param [Integer] flags submodule bits
|
3190
3211
|
* @return [nil]
|
3191
3212
|
*
|
@@ -3194,18 +3215,18 @@ static VALUE mIMG;
|
|
3194
3215
|
static VALUE IMG_s_init(VALUE self, VALUE f)
|
3195
3216
|
{
|
3196
3217
|
int flags = NUM2INT(f);
|
3197
|
-
if (IMG_Init(flags) & flags != flags)
|
3218
|
+
if ((IMG_Init(flags) & flags) != flags)
|
3198
3219
|
rb_raise(eSDL2Error, "Couldn't initialze SDL_image");
|
3199
3220
|
return Qnil;
|
3200
3221
|
}
|
3201
3222
|
|
3202
3223
|
/*
|
3203
|
-
* @overload load(file)
|
3224
|
+
* @overload load(file)
|
3204
3225
|
* Load file and create a new {SDL2::Surface}.
|
3205
3226
|
*
|
3206
3227
|
* This method uses SDL_image. SDL_image supports following formats:
|
3207
3228
|
* BMP, CUR, GIF, ICO, JPG, LBP, PCX, PNG, PNM, TGA, TIF, XCF, XPM, and XV.
|
3208
|
-
*
|
3229
|
+
*
|
3209
3230
|
* @param [String] file the image file name to load a surface from
|
3210
3231
|
* @return [SDL2::Surface] Created surface
|
3211
3232
|
*
|
@@ -3219,7 +3240,7 @@ static VALUE Surface_s_load(VALUE self, VALUE fname)
|
|
3219
3240
|
{
|
3220
3241
|
SDL_Surface* surface = IMG_Load(StringValueCStr(fname));
|
3221
3242
|
if (!surface) {
|
3222
|
-
SDL_SetError(IMG_GetError());
|
3243
|
+
SDL_SetError("%s", IMG_GetError());
|
3223
3244
|
SDL_ERROR();
|
3224
3245
|
}
|
3225
3246
|
return Surface_new(surface);
|
@@ -3246,7 +3267,7 @@ static VALUE Renderer_load_texture(VALUE self, VALUE fname)
|
|
3246
3267
|
{
|
3247
3268
|
SDL_Texture* texture = IMG_LoadTexture(Get_SDL_Renderer(self), StringValueCStr(fname));
|
3248
3269
|
if (!texture) {
|
3249
|
-
SDL_SetError(IMG_GetError());
|
3270
|
+
SDL_SetError("%s", IMG_GetError());
|
3250
3271
|
SDL_ERROR();
|
3251
3272
|
}
|
3252
3273
|
return Texture_new(texture, Get_Renderer(self));
|
@@ -3259,7 +3280,7 @@ void rubysdl2_init_image(void)
|
|
3259
3280
|
|
3260
3281
|
rb_define_singleton_method(cSurface, "load", Surface_s_load, 1);
|
3261
3282
|
rb_define_method(cRenderer, "load_texture", Renderer_load_texture, 1);
|
3262
|
-
|
3283
|
+
|
3263
3284
|
|
3264
3285
|
/* Initialize the JPEG loader */
|
3265
3286
|
rb_define_const(mIMG, "INIT_JPG", INT2NUM(IMG_INIT_JPG));
|