ruby-sdl2 0.3.5 → 0.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +4 -1
- data/Gemfile +11 -0
- data/README.md +5 -2
- data/Rakefile +22 -2
- data/Steepfile +24 -0
- data/doc/DEVELOP.md +35 -0
- data/event.c +3 -3
- data/gamecontroller.c +26 -25
- data/gamecontroller.c.m4 +26 -25
- data/gl.c +56 -63
- data/gl.c.m4 +56 -63
- data/hint.c +3 -3
- data/joystick.c +11 -10
- data/joystick.c.m4 +11 -10
- data/key.c +21 -19
- data/key.c.m4 +21 -19
- data/lib/sdl2/version.rb +3 -3
- data/main.c +13 -16
- data/messagebox.c +7 -7
- data/mixer.c +41 -31
- data/mixer.c.m4 +41 -31
- data/mouse.c +3 -3
- data/rbs_collection.yaml +32 -0
- data/ttf.c +15 -15
- data/ttf.c.m4 +15 -15
- data/video.c +172 -122
- data/video.c.m4 +109 -91
- metadata +7 -3
data/gl.c.m4
CHANGED
@@ -115,8 +115,7 @@ static VALUE GLContext_make_current(VALUE self, VALUE window)
|
|
115
115
|
/*
|
116
116
|
* Get the current OpenGL context.
|
117
117
|
*
|
118
|
-
* @return [SDL2::GL::Context] the
|
119
|
-
* @return [nil] if there is no current context
|
118
|
+
* @return [SDL2::GL::Context,nil] the current context, nil if there is no current context
|
120
119
|
*
|
121
120
|
* @see #make_current
|
122
121
|
*/
|
@@ -130,6 +129,7 @@ static VALUE GLContext_s_current(VALUE self)
|
|
130
129
|
* Return true if the current context supports **extension**
|
131
130
|
*
|
132
131
|
* @param extension [String] the name of an extension
|
132
|
+
* @return [Boolean]
|
133
133
|
* @example
|
134
134
|
* SDL2::GL.extension_supported?("GL_EXT_framebuffer_blit")
|
135
135
|
*/
|
@@ -190,7 +190,7 @@ static VALUE GL_s_get_attribute(VALUE self, VALUE attr)
|
|
190
190
|
*
|
191
191
|
* @param attr [Integer] the OpenGL attribute to set
|
192
192
|
* @param value [Integer] the desired value for the attribute
|
193
|
-
* @return [
|
193
|
+
* @return [void]
|
194
194
|
*/
|
195
195
|
static VALUE GL_s_set_attribute(VALUE self, VALUE attr, VALUE value)
|
196
196
|
{
|
@@ -217,56 +217,48 @@ void rubysdl2_init_gl(void)
|
|
217
217
|
rb_define_module_function(mGL, "set_attribute", GL_s_set_attribute, 2);
|
218
218
|
|
219
219
|
/* define(`DEFINE_GL_ATTR_CONST',`rb_define_const(mGL, "$1", INT2NUM(SDL_GL_$1))') */
|
220
|
-
/* OpenGL attribute - minimal bits of red channel in color buffer, default is 3 */
|
220
|
+
/* @return [Integer] index for OpenGL attribute - minimal bits of red channel in color buffer, default is 3 */
|
221
221
|
DEFINE_GL_ATTR_CONST(RED_SIZE);
|
222
|
-
/* OpenGL attribute - minimal bits of green channel in color buffer, default is 3 */
|
222
|
+
/* @return [Integer] index for OpenGL attribute - minimal bits of green channel in color buffer, default is 3 */
|
223
223
|
DEFINE_GL_ATTR_CONST(GREEN_SIZE);
|
224
|
-
/* OpenGL attribute - minimal bits of blue channel in color buffer, default is 2 */
|
224
|
+
/* @return [Integer] index for OpenGL attribute - minimal bits of blue channel in color buffer, default is 2 */
|
225
225
|
DEFINE_GL_ATTR_CONST(BLUE_SIZE);
|
226
|
-
/* OpenGL attribute - minimal bits of alpha channel in color buffer, default is 0 */
|
226
|
+
/* @return [Integer] index for OpenGL attribute - minimal bits of alpha channel in color buffer, default is 0 */
|
227
227
|
DEFINE_GL_ATTR_CONST(ALPHA_SIZE);
|
228
|
-
/* OpenGL attribute - minimal bits of framebufer, default is 0 */
|
228
|
+
/* @return [Integer] index for OpenGL attribute - minimal bits of framebufer, default is 0 */
|
229
229
|
DEFINE_GL_ATTR_CONST(BUFFER_SIZE);
|
230
|
-
/* OpenGL attribute - whether the single buffer (0) or double buffer (1), default
|
231
|
-
is double buffer */
|
230
|
+
/* @return [Integer] index for OpenGL attribute - whether the single buffer (0) or double buffer (1), default is double buffer */
|
232
231
|
DEFINE_GL_ATTR_CONST(DOUBLEBUFFER);
|
233
|
-
/* OpenGL attribute - bits of depth buffer, default is 16 */
|
232
|
+
/* @return [Integer] index for OpenGL attribute - bits of depth buffer, default is 16 */
|
234
233
|
DEFINE_GL_ATTR_CONST(DEPTH_SIZE);
|
235
|
-
/* OpenGL attribute - bits of stencil buffer, default is 0 */
|
234
|
+
/* @return [Integer] index for OpenGL attribute - bits of stencil buffer, default is 0 */
|
236
235
|
DEFINE_GL_ATTR_CONST(STENCIL_SIZE);
|
237
|
-
/* OpenGL attribute - minimal bits of red channel in accumlation buffer,
|
238
|
-
default is 0 */
|
236
|
+
/* @return [Integer] index for OpenGL attribute - minimal bits of red channel in accumlation buffer, default is 0 */
|
239
237
|
DEFINE_GL_ATTR_CONST(ACCUM_RED_SIZE);
|
240
|
-
/* OpenGL attribute - minimal bits of green channel in accumlation buffer,
|
241
|
-
default is 0 */
|
238
|
+
/* @return [Integer] index for OpenGL attribute - minimal bits of green channel in accumlation buffer, default is 0 */
|
242
239
|
DEFINE_GL_ATTR_CONST(ACCUM_GREEN_SIZE);
|
243
|
-
/* OpenGL attribute - minimal bits of blue channel in accumlation buffer,
|
244
|
-
default is 0 */
|
240
|
+
/* @return [Integer] index for OpenGL attribute - minimal bits of blue channel in accumlation buffer, default is 0 */
|
245
241
|
DEFINE_GL_ATTR_CONST(ACCUM_BLUE_SIZE);
|
246
|
-
/* OpenGL attribute - minimal bits of alpha channel in accumlation buffer,
|
247
|
-
default is 0 */
|
242
|
+
/* @return [Integer] index for OpenGL attribute - minimal bits of alpha channel in accumlation buffer, default is 0 */
|
248
243
|
DEFINE_GL_ATTR_CONST(ACCUM_ALPHA_SIZE);
|
249
|
-
/* OpenGL attribute - whether output is stereo (1) or not (0), default is 0 */
|
244
|
+
/* @return [Integer] index for OpenGL attribute - whether output is stereo (1) or not (0), default is 0 */
|
250
245
|
DEFINE_GL_ATTR_CONST(STEREO);
|
251
|
-
/* OpenGL attribuite - the number of buffers used for multisampe anti-aliasing,
|
252
|
-
default is 0 */
|
246
|
+
/* @return [Integer] index for OpenGL attribuite - the number of buffers used for multisampe anti-aliasing, default is 0 */
|
253
247
|
DEFINE_GL_ATTR_CONST(MULTISAMPLEBUFFERS);
|
254
|
-
/* OpenGL attribute - the number of samples used around the current pixel
|
255
|
-
use for multisample anti-aliasing, default is 0 */
|
248
|
+
/* @return [Integer] index for OpenGL attribute - the number of samples used around the current pixel use for multisample anti-aliasing, default is 0 */
|
256
249
|
DEFINE_GL_ATTR_CONST(MULTISAMPLESAMPLES);
|
257
|
-
/* OpenGL attribute - 1 for requiring hardware acceleration, 0 for software rendering,
|
258
|
-
default is allowing either */
|
250
|
+
/* @return [Integer] index for OpenGL attribute - 1 for requiring hardware acceleration, 0 for software rendering, default is allowing either */
|
259
251
|
DEFINE_GL_ATTR_CONST(ACCELERATED_VISUAL);
|
260
|
-
/* OpenGL attribute - not used (deprecated) */
|
252
|
+
/* @return [Integer] index for OpenGL attribute - not used (deprecated) */
|
261
253
|
DEFINE_GL_ATTR_CONST(RETAINED_BACKING);
|
262
|
-
/* OpenGL attribute - OpenGL context major version */
|
254
|
+
/* @return [Integer] index for OpenGL attribute - OpenGL context major version */
|
263
255
|
DEFINE_GL_ATTR_CONST(CONTEXT_MAJOR_VERSION);
|
264
|
-
/* OpenGL attribute - OpenGL context minor version */
|
256
|
+
/* @return [Integer] index for OpenGL attribute - OpenGL context minor version */
|
265
257
|
DEFINE_GL_ATTR_CONST(CONTEXT_MINOR_VERSION);
|
266
258
|
/*
|
267
259
|
* INT2NUM(SDL_GL_CONTEXT_FLAGS):
|
268
260
|
*
|
269
|
-
* OpenGL attribute - the bit combination of following constants, or 0.
|
261
|
+
* @return [Integer] index for OpenGL attribute - the bit combination of following constants, or 0.
|
270
262
|
* default is 0
|
271
263
|
*
|
272
264
|
* * {SDL2::GL::CONTEXT_DEBUG_FLAG}
|
@@ -282,7 +274,7 @@ void rubysdl2_init_gl(void)
|
|
282
274
|
DEFINE_GL_ATTR_CONST(CONTEXT_FLAGS);
|
283
275
|
/* INT2NUM(SDL_GL_CONTEXT_PROFILE_MASK):
|
284
276
|
*
|
285
|
-
* OpenGL attribute - type of GL context, one of the following constants,
|
277
|
+
* @return [Integer] index for OpenGL attribute - type of GL context, one of the following constants,
|
286
278
|
* defaults depends on platform
|
287
279
|
*
|
288
280
|
* * {CONTEXT_PROFILE_CORE}
|
@@ -292,58 +284,59 @@ void rubysdl2_init_gl(void)
|
|
292
284
|
* https://wiki.libsdl.org/SDL_GLprofile
|
293
285
|
*/
|
294
286
|
DEFINE_GL_ATTR_CONST(CONTEXT_PROFILE_MASK);
|
295
|
-
/* OpenGL attribute - OpenGL context sharing, default is 0 */
|
287
|
+
/* @return [Integer] index for OpenGL attribute - OpenGL context sharing, default is 0 */
|
296
288
|
DEFINE_GL_ATTR_CONST(SHARE_WITH_CURRENT_CONTEXT);
|
297
289
|
#if SDL_VERSION_ATLEAST(2,0,1)
|
298
|
-
/* OpenGL attribute - 1 for requesting sRGB capable visual, default to 0 */
|
290
|
+
/* @return [Integer] index for OpenGL attribute - 1 for requesting sRGB capable visual, default to 0 */
|
299
291
|
DEFINE_GL_ATTR_CONST(FRAMEBUFFER_SRGB_CAPABLE);
|
300
292
|
#endif
|
301
|
-
/* OpenGL attribute - not used (deprecated) */
|
293
|
+
/* @return [Integer] index for OpenGL attribute - not used (deprecated) */
|
302
294
|
DEFINE_GL_ATTR_CONST(CONTEXT_EGL);
|
303
295
|
|
304
296
|
/* define(`DEFINE_GL_CONTEXT_CONST',`rb_define_const(mGL, "CONTEXT_$1", INT2NUM(SDL_GL_CONTEXT_$1))') */
|
305
297
|
|
306
|
-
/*
|
307
|
-
*
|
308
|
-
*
|
309
|
-
*
|
298
|
+
/* @return [Integer]
|
299
|
+
* This flag maps to GLX_CONTEXT_DEBUG_BIT_ARB in
|
300
|
+
* the GLX_ARB_create_context extension for X11
|
301
|
+
* and WGL_CONTEXT_DEBUG_BIT_ARB in the WGL_ARB_create_context
|
302
|
+
* extension for Windows.
|
310
303
|
*/
|
311
304
|
DEFINE_GL_CONTEXT_CONST(DEBUG_FLAG);
|
312
|
-
/*
|
313
|
-
*
|
314
|
-
*
|
315
|
-
*
|
316
|
-
*
|
305
|
+
/* @return [Integer]
|
306
|
+
* This flag maps to GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB in the
|
307
|
+
* GLX_ARB_create_context extension for X11 and
|
308
|
+
* WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB in the WGL_ARB_create_context
|
309
|
+
* extension for Windows.
|
317
310
|
*/
|
318
311
|
DEFINE_GL_CONTEXT_CONST(FORWARD_COMPATIBLE_FLAG);
|
319
|
-
/*
|
320
|
-
*
|
321
|
-
*
|
322
|
-
*
|
323
|
-
*
|
312
|
+
/* @return [Integer]
|
313
|
+
* This flag maps to GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB in the
|
314
|
+
* GLX_ARB_create_context_robustness extension for X11 and
|
315
|
+
* WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB in the WGL_ARB_create_context_robustness
|
316
|
+
* extension for Windows.
|
324
317
|
*/
|
325
318
|
DEFINE_GL_CONTEXT_CONST(ROBUST_ACCESS_FLAG);
|
326
|
-
/*
|
327
|
-
*
|
328
|
-
*
|
329
|
-
*
|
330
|
-
*
|
319
|
+
/* @return [Integer]
|
320
|
+
* This flag maps to GLX_CONTEXT_RESET_ISOLATION_BIT_ARB in the
|
321
|
+
* GLX_ARB_robustness_isolation extension for X11 and
|
322
|
+
* WGL_CONTEXT_RESET_ISOLATION_BIT_ARB in the WGL_ARB_create_context_robustness
|
323
|
+
* extension for Windows.
|
331
324
|
*/
|
332
325
|
DEFINE_GL_CONTEXT_CONST(RESET_ISOLATION_FLAG);
|
333
326
|
|
334
|
-
/*
|
335
|
-
*
|
336
|
-
*
|
327
|
+
/* @return [Integer]
|
328
|
+
* OpenGL core profile - deprecated
|
329
|
+
* functions are disabled
|
337
330
|
*/
|
338
331
|
DEFINE_GL_CONTEXT_CONST(PROFILE_CORE);
|
339
|
-
/*
|
340
|
-
*
|
341
|
-
*
|
332
|
+
/* @return [Integer]
|
333
|
+
* OpenGL compatibility profile -
|
334
|
+
* deprecated functions are allowed
|
342
335
|
*/
|
343
336
|
DEFINE_GL_CONTEXT_CONST(PROFILE_COMPATIBILITY);
|
344
|
-
/*
|
345
|
-
*
|
346
|
-
*
|
337
|
+
/* @return [Integer]
|
338
|
+
* OpenGL ES profile - only a subset of the
|
339
|
+
* base OpenGL functionality is available
|
347
340
|
*/
|
348
341
|
DEFINE_GL_CONTEXT_CONST(PROFILE_ES);
|
349
342
|
|
data/hint.c
CHANGED
@@ -88,11 +88,11 @@ void rubysdl2_init_hints(void)
|
|
88
88
|
rb_define_singleton_method(mHints, "get", Hints_s_aref, 1);
|
89
89
|
rb_define_singleton_method(mHints, "[]=", Hints_s_aset, -1);
|
90
90
|
|
91
|
-
/* low priority, used fro default values */
|
91
|
+
/* @return [Integer] index for low priority, used fro default values */
|
92
92
|
rb_define_const(mHints, "DEFAULT", INT2NUM(SDL_HINT_DEFAULT));
|
93
|
-
/* medium priority, overrided by an environment variable */
|
93
|
+
/* @return [Integer] index for medium priority, overrided by an environment variable */
|
94
94
|
rb_define_const(mHints, "NORMAL", INT2NUM(SDL_HINT_NORMAL));
|
95
|
-
/* high priority, this priority overrides the value by environment variables */
|
95
|
+
/* @return [Integer] index for high priority, this priority overrides the value by environment variables */
|
96
96
|
rb_define_const(mHints, "OVERRIDE", INT2NUM(SDL_HINT_OVERRIDE));
|
97
97
|
|
98
98
|
sym_priority = ID2SYM(rb_intern("priority"));
|
data/joystick.c
CHANGED
@@ -99,6 +99,7 @@ static VALUE Joystick_s_open(VALUE self, VALUE device_index)
|
|
99
99
|
* interface.
|
100
100
|
*
|
101
101
|
* @param [Integer] index the joystick device index
|
102
|
+
* @return [Boolean]
|
102
103
|
* @see SDL2::GameController
|
103
104
|
*
|
104
105
|
*/
|
@@ -225,7 +226,7 @@ static VALUE Joystick_axis(VALUE self, VALUE which)
|
|
225
226
|
* Get the current state of a trackball on a joystick.
|
226
227
|
*
|
227
228
|
* @param [Integer] which an index of a trackball, started at index 0
|
228
|
-
* @return [
|
229
|
+
* @return [Array(Integer,Integer)] dx and dy
|
229
230
|
* @see #num_balls
|
230
231
|
*/
|
231
232
|
static VALUE Joystick_ball(VALUE self, VALUE which)
|
@@ -309,23 +310,23 @@ void rubysdl2_init_joystick(void)
|
|
309
310
|
mHat = rb_define_module_under(cJoystick, "Hat");
|
310
311
|
|
311
312
|
/* */
|
312
|
-
/* Center position. Equal to 0. */
|
313
|
+
/* @return [Integer] hat state\: Center position. Equal to 0. */
|
313
314
|
rb_define_const(mHat, "CENTERED", INT2NUM(SDL_HAT_CENTERED));
|
314
|
-
/* Up position. */
|
315
|
+
/* @return [Integer] hat state\: Up position. */
|
315
316
|
rb_define_const(mHat, "UP", INT2NUM(SDL_HAT_UP));
|
316
|
-
/* Right position. */
|
317
|
+
/* @return [Integer] hat state\: Right position. */
|
317
318
|
rb_define_const(mHat, "RIGHT", INT2NUM(SDL_HAT_RIGHT));
|
318
|
-
/* Down position. */
|
319
|
+
/* @return [Integer] hat state\: Down position. */
|
319
320
|
rb_define_const(mHat, "DOWN", INT2NUM(SDL_HAT_DOWN));
|
320
|
-
/* Left position. */
|
321
|
+
/* @return [Integer] hat state\: Left position. */
|
321
322
|
rb_define_const(mHat, "LEFT", INT2NUM(SDL_HAT_LEFT));
|
322
|
-
/* Right Up position. Equal to ({RIGHT} | {UP}) */
|
323
|
+
/* @return [Integer] hat state\: Right Up position. Equal to ({RIGHT} | {UP}) */
|
323
324
|
rb_define_const(mHat, "RIGHTUP", INT2NUM(SDL_HAT_RIGHTUP));
|
324
|
-
/* Right Down position. Equal to ({RIGHT} | {DOWN}) */
|
325
|
+
/* @return [Integer] hat state\: Right Down position. Equal to ({RIGHT} | {DOWN}) */
|
325
326
|
rb_define_const(mHat, "RIGHTDOWN", INT2NUM(SDL_HAT_RIGHTDOWN));
|
326
|
-
/* Left Up position. Equal to ({LEFT} | {UP}) */
|
327
|
+
/* @return [Integer] hat state\: Left Up position. Equal to ({LEFT} | {UP}) */
|
327
328
|
rb_define_const(mHat, "LEFTUP", INT2NUM(SDL_HAT_LEFTUP));
|
328
|
-
/* Left Down position. Equal to ({LEFT} | {DOWN}) */
|
329
|
+
/* @return [Integer] hat state\: Left Down position. Equal to ({LEFT} | {DOWN}) */
|
329
330
|
rb_define_const(mHat, "LEFTDOWN", INT2NUM(SDL_HAT_LEFTDOWN));
|
330
331
|
|
331
332
|
/* Device GUID
|
data/joystick.c.m4
CHANGED
@@ -99,6 +99,7 @@ static VALUE Joystick_s_open(VALUE self, VALUE device_index)
|
|
99
99
|
* interface.
|
100
100
|
*
|
101
101
|
* @param [Integer] index the joystick device index
|
102
|
+
* @return [Boolean]
|
102
103
|
* @see SDL2::GameController
|
103
104
|
*
|
104
105
|
*/
|
@@ -225,7 +226,7 @@ static VALUE Joystick_axis(VALUE self, VALUE which)
|
|
225
226
|
* Get the current state of a trackball on a joystick.
|
226
227
|
*
|
227
228
|
* @param [Integer] which an index of a trackball, started at index 0
|
228
|
-
* @return [
|
229
|
+
* @return [Array(Integer,Integer)] dx and dy
|
229
230
|
* @see #num_balls
|
230
231
|
*/
|
231
232
|
static VALUE Joystick_ball(VALUE self, VALUE which)
|
@@ -309,23 +310,23 @@ void rubysdl2_init_joystick(void)
|
|
309
310
|
mHat = rb_define_module_under(cJoystick, "Hat");
|
310
311
|
|
311
312
|
/* define(`DEFINE_JOY_HAT_CONST',`rb_define_const(mHat, "$1", INT2NUM(SDL_HAT_$1))') */
|
312
|
-
/* Center position. Equal to 0. */
|
313
|
+
/* @return [Integer] hat state\: Center position. Equal to 0. */
|
313
314
|
DEFINE_JOY_HAT_CONST(CENTERED);
|
314
|
-
/* Up position. */
|
315
|
+
/* @return [Integer] hat state\: Up position. */
|
315
316
|
DEFINE_JOY_HAT_CONST(UP);
|
316
|
-
/* Right position. */
|
317
|
+
/* @return [Integer] hat state\: Right position. */
|
317
318
|
DEFINE_JOY_HAT_CONST(RIGHT);
|
318
|
-
/* Down position. */
|
319
|
+
/* @return [Integer] hat state\: Down position. */
|
319
320
|
DEFINE_JOY_HAT_CONST(DOWN);
|
320
|
-
/* Left position. */
|
321
|
+
/* @return [Integer] hat state\: Left position. */
|
321
322
|
DEFINE_JOY_HAT_CONST(LEFT);
|
322
|
-
/* Right Up position. Equal to ({RIGHT} | {UP}) */
|
323
|
+
/* @return [Integer] hat state\: Right Up position. Equal to ({RIGHT} | {UP}) */
|
323
324
|
DEFINE_JOY_HAT_CONST(RIGHTUP);
|
324
|
-
/* Right Down position. Equal to ({RIGHT} | {DOWN}) */
|
325
|
+
/* @return [Integer] hat state\: Right Down position. Equal to ({RIGHT} | {DOWN}) */
|
325
326
|
DEFINE_JOY_HAT_CONST(RIGHTDOWN);
|
326
|
-
/* Left Up position. Equal to ({LEFT} | {UP}) */
|
327
|
+
/* @return [Integer] hat state\: Left Up position. Equal to ({LEFT} | {UP}) */
|
327
328
|
DEFINE_JOY_HAT_CONST(LEFTUP);
|
328
|
-
/* Left Down position. Equal to ({LEFT} | {DOWN}) */
|
329
|
+
/* @return [Integer] hat state\: Left Down position. Equal to ({LEFT} | {DOWN}) */
|
329
330
|
DEFINE_JOY_HAT_CONST(LEFTDOWN);
|
330
331
|
|
331
332
|
/* Device GUID
|
data/key.c
CHANGED
@@ -65,6 +65,8 @@ static VALUE Key_s_keycode_from_scancode(VALUE self, VALUE scancode)
|
|
65
65
|
* @overload pressed?(code)
|
66
66
|
* @param [Integer] code scancode
|
67
67
|
*
|
68
|
+
* @return [Boolean] true if pressed
|
69
|
+
*
|
68
70
|
* Get whether the key of the given scancode is pressed or not.
|
69
71
|
*/
|
70
72
|
static VALUE Key_s_pressed_p(VALUE self, VALUE code)
|
@@ -159,7 +161,7 @@ static VALUE Mod_s_state(VALUE self)
|
|
159
161
|
* Set the current key modifier state
|
160
162
|
*
|
161
163
|
* @note This does not change the keyboard state, only the key modifier flags.
|
162
|
-
* @return [
|
164
|
+
* @return [void]
|
163
165
|
* @see .state
|
164
166
|
*/
|
165
167
|
static VALUE Mod_s_set_state(VALUE self, VALUE keymod)
|
@@ -220,7 +222,7 @@ static VALUE TextInput_s_stop(VALUE self)
|
|
220
222
|
* Set the rectanlgle used to type Unicode text inputs.
|
221
223
|
*
|
222
224
|
* @param rect [SDL2::Rect] the rectangle to receive text
|
223
|
-
* @return [
|
225
|
+
* @return [void]
|
224
226
|
*/
|
225
227
|
static VALUE TextInput_s_set_rect(VALUE self, VALUE rect)
|
226
228
|
{
|
@@ -1265,38 +1267,38 @@ void rubysdl2_init_key(void)
|
|
1265
1267
|
/* @return [Integer] keycode for "SLEEP" key */
|
1266
1268
|
rb_define_const(mKey, "SLEEP", INT2NUM(SDLK_SLEEP));
|
1267
1269
|
|
1268
|
-
/* 0 (no modifier is applicable) */
|
1270
|
+
/* @return [Integer] 0 (no modifier is applicable) */
|
1269
1271
|
rb_define_const(mMod, "NONE", INT2NUM(KMOD_NONE));
|
1270
|
-
/* the modifier key bit mask for the left shift key */
|
1272
|
+
/* @return [Integer] the modifier key bit mask for the left shift key */
|
1271
1273
|
rb_define_const(mMod, "LSHIFT", INT2NUM(KMOD_LSHIFT));
|
1272
|
-
/* the modifier key bit mask for the right shift key */
|
1274
|
+
/* @return [Integer] the modifier key bit mask for the right shift key */
|
1273
1275
|
rb_define_const(mMod, "RSHIFT", INT2NUM(KMOD_RSHIFT));
|
1274
|
-
/* the modifier key bit mask for the left control key */
|
1276
|
+
/* @return [Integer] the modifier key bit mask for the left control key */
|
1275
1277
|
rb_define_const(mMod, "LCTRL", INT2NUM(KMOD_LCTRL));
|
1276
|
-
/* the modifier key bit mask for the right control key */
|
1278
|
+
/* @return [Integer] the modifier key bit mask for the right control key */
|
1277
1279
|
rb_define_const(mMod, "RCTRL", INT2NUM(KMOD_RCTRL));
|
1278
|
-
/* the modifier key bit mask for the left alt key */
|
1280
|
+
/* @return [Integer] the modifier key bit mask for the left alt key */
|
1279
1281
|
rb_define_const(mMod, "LALT", INT2NUM(KMOD_LALT));
|
1280
|
-
/* the modifier key bit mask for the right alt key */
|
1282
|
+
/* @return [Integer] the modifier key bit mask for the right alt key */
|
1281
1283
|
rb_define_const(mMod, "RALT", INT2NUM(KMOD_RALT));
|
1282
|
-
/* the modifier key bit mask for the left GUI key (often the window key) */
|
1284
|
+
/* @return [Integer] the modifier key bit mask for the left GUI key (often the window key) */
|
1283
1285
|
rb_define_const(mMod, "LGUI", INT2NUM(KMOD_LGUI));
|
1284
|
-
/* the modifier key bit mask for the right GUI key (often the window key) */
|
1286
|
+
/* @return [Integer] the modifier key bit mask for the right GUI key (often the window key) */
|
1285
1287
|
rb_define_const(mMod, "RGUI", INT2NUM(KMOD_RGUI));
|
1286
|
-
/* the modifier key bit mask for the numlock key */
|
1288
|
+
/* @return [Integer] the modifier key bit mask for the numlock key */
|
1287
1289
|
rb_define_const(mMod, "NUM", INT2NUM(KMOD_NUM));
|
1288
|
-
/* the modifier key bit mask for the capslock key */
|
1290
|
+
/* @return [Integer] the modifier key bit mask for the capslock key */
|
1289
1291
|
rb_define_const(mMod, "CAPS", INT2NUM(KMOD_CAPS));
|
1290
|
-
/* the modifier key bit mask for the mode key (AltGr) */
|
1292
|
+
/* @return [Integer] the modifier key bit mask for the mode key (AltGr) */
|
1291
1293
|
rb_define_const(mMod, "MODE", INT2NUM(KMOD_MODE));
|
1292
|
-
/* the modifier key bit mask for the left and right control key */
|
1294
|
+
/* @return [Integer] the modifier key bit mask for the left and right control key */
|
1293
1295
|
rb_define_const(mMod, "CTRL", INT2NUM(KMOD_CTRL));
|
1294
|
-
/* the modifier key bit mask for the left and right shift key */
|
1296
|
+
/* @return [Integer] the modifier key bit mask for the left and right shift key */
|
1295
1297
|
rb_define_const(mMod, "SHIFT", INT2NUM(KMOD_SHIFT));
|
1296
|
-
/* the modifier key bit mask for the left and right alt key */
|
1298
|
+
/* @return [Integer] the modifier key bit mask for the left and right alt key */
|
1297
1299
|
rb_define_const(mMod, "ALT", INT2NUM(KMOD_ALT));
|
1298
|
-
/* the modifier key bit mask for the left and right GUI key */
|
1300
|
+
/* @return [Integer] the modifier key bit mask for the left and right GUI key */
|
1299
1301
|
rb_define_const(mMod, "GUI", INT2NUM(KMOD_GUI));
|
1300
|
-
/* reserved for future use */
|
1302
|
+
/* @return [Integer] reserved bit mask for future use */
|
1301
1303
|
rb_define_const(mMod, "RESERVED", INT2NUM(KMOD_RESERVED));
|
1302
1304
|
}
|
data/key.c.m4
CHANGED
@@ -65,6 +65,8 @@ static VALUE Key_s_keycode_from_scancode(VALUE self, VALUE scancode)
|
|
65
65
|
* @overload pressed?(code)
|
66
66
|
* @param [Integer] code scancode
|
67
67
|
*
|
68
|
+
* @return [Boolean] true if pressed
|
69
|
+
*
|
68
70
|
* Get whether the key of the given scancode is pressed or not.
|
69
71
|
*/
|
70
72
|
static VALUE Key_s_pressed_p(VALUE self, VALUE code)
|
@@ -159,7 +161,7 @@ static VALUE Mod_s_state(VALUE self)
|
|
159
161
|
* Set the current key modifier state
|
160
162
|
*
|
161
163
|
* @note This does not change the keyboard state, only the key modifier flags.
|
162
|
-
* @return [
|
164
|
+
* @return [void]
|
163
165
|
* @see .state
|
164
166
|
*/
|
165
167
|
static VALUE Mod_s_set_state(VALUE self, VALUE keymod)
|
@@ -220,7 +222,7 @@ static VALUE TextInput_s_stop(VALUE self)
|
|
220
222
|
* Set the rectanlgle used to type Unicode text inputs.
|
221
223
|
*
|
222
224
|
* @param rect [SDL2::Rect] the rectangle to receive text
|
223
|
-
* @return [
|
225
|
+
* @return [void]
|
224
226
|
*/
|
225
227
|
static VALUE TextInput_s_set_rect(VALUE self, VALUE rect)
|
226
228
|
{
|
@@ -796,38 +798,38 @@ void rubysdl2_init_key(void)
|
|
796
798
|
DEFINE_KEYCODE(EJECT);
|
797
799
|
DEFINE_KEYCODE(SLEEP);
|
798
800
|
|
799
|
-
/* 0 (no modifier is applicable) */
|
801
|
+
/* @return [Integer] 0 (no modifier is applicable) */
|
800
802
|
DEFINE_KEYMOD(NONE);
|
801
|
-
/* the modifier key bit mask for the left shift key */
|
803
|
+
/* @return [Integer] the modifier key bit mask for the left shift key */
|
802
804
|
DEFINE_KEYMOD(LSHIFT);
|
803
|
-
/* the modifier key bit mask for the right shift key */
|
805
|
+
/* @return [Integer] the modifier key bit mask for the right shift key */
|
804
806
|
DEFINE_KEYMOD(RSHIFT);
|
805
|
-
/* the modifier key bit mask for the left control key */
|
807
|
+
/* @return [Integer] the modifier key bit mask for the left control key */
|
806
808
|
DEFINE_KEYMOD(LCTRL);
|
807
|
-
/* the modifier key bit mask for the right control key */
|
809
|
+
/* @return [Integer] the modifier key bit mask for the right control key */
|
808
810
|
DEFINE_KEYMOD(RCTRL);
|
809
|
-
/* the modifier key bit mask for the left alt key */
|
811
|
+
/* @return [Integer] the modifier key bit mask for the left alt key */
|
810
812
|
DEFINE_KEYMOD(LALT);
|
811
|
-
/* the modifier key bit mask for the right alt key */
|
813
|
+
/* @return [Integer] the modifier key bit mask for the right alt key */
|
812
814
|
DEFINE_KEYMOD(RALT);
|
813
|
-
/* the modifier key bit mask for the left GUI key (often the window key) */
|
815
|
+
/* @return [Integer] the modifier key bit mask for the left GUI key (often the window key) */
|
814
816
|
DEFINE_KEYMOD(LGUI);
|
815
|
-
/* the modifier key bit mask for the right GUI key (often the window key) */
|
817
|
+
/* @return [Integer] the modifier key bit mask for the right GUI key (often the window key) */
|
816
818
|
DEFINE_KEYMOD(RGUI);
|
817
|
-
/* the modifier key bit mask for the numlock key */
|
819
|
+
/* @return [Integer] the modifier key bit mask for the numlock key */
|
818
820
|
DEFINE_KEYMOD(NUM);
|
819
|
-
/* the modifier key bit mask for the capslock key */
|
821
|
+
/* @return [Integer] the modifier key bit mask for the capslock key */
|
820
822
|
DEFINE_KEYMOD(CAPS);
|
821
|
-
/* the modifier key bit mask for the mode key (AltGr) */
|
823
|
+
/* @return [Integer] the modifier key bit mask for the mode key (AltGr) */
|
822
824
|
DEFINE_KEYMOD(MODE);
|
823
|
-
/* the modifier key bit mask for the left and right control key */
|
825
|
+
/* @return [Integer] the modifier key bit mask for the left and right control key */
|
824
826
|
DEFINE_KEYMOD(CTRL);
|
825
|
-
/* the modifier key bit mask for the left and right shift key */
|
827
|
+
/* @return [Integer] the modifier key bit mask for the left and right shift key */
|
826
828
|
DEFINE_KEYMOD(SHIFT);
|
827
|
-
/* the modifier key bit mask for the left and right alt key */
|
829
|
+
/* @return [Integer] the modifier key bit mask for the left and right alt key */
|
828
830
|
DEFINE_KEYMOD(ALT);
|
829
|
-
/* the modifier key bit mask for the left and right GUI key */
|
831
|
+
/* @return [Integer] the modifier key bit mask for the left and right GUI key */
|
830
832
|
DEFINE_KEYMOD(GUI);
|
831
|
-
/* reserved for future use */
|
833
|
+
/* @return [Integer] reserved bit mask for future use */
|
832
834
|
DEFINE_KEYMOD(RESERVED);
|
833
835
|
}
|
data/lib/sdl2/version.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module SDL2
|
2
|
-
# Version string of Ruby/SDL2
|
3
|
-
VERSION = "0.3.
|
4
|
-
# Version of Ruby/SDL2, [major, minor, patch level]
|
2
|
+
# @return [String] Version string of Ruby/SDL2
|
3
|
+
VERSION = "0.3.6"
|
4
|
+
# @return [Array<Integer>] Version of Ruby/SDL2, [major, minor, patch level]
|
5
5
|
VERSION_NUMBER = VERSION.split(".").map(&:to_i)
|
6
6
|
end
|
data/main.c
CHANGED
@@ -145,11 +145,6 @@ static VALUE libsdl_revision(void)
|
|
145
145
|
return rb_usascii_str_new_cstr(SDL_GetRevision());
|
146
146
|
}
|
147
147
|
|
148
|
-
static VALUE libsdl_revision_number(void)
|
149
|
-
{
|
150
|
-
return INT2NUM(SDL_GetRevisionNumber());
|
151
|
-
}
|
152
|
-
|
153
148
|
/*
|
154
149
|
* Document-module: SDL2
|
155
150
|
*
|
@@ -183,39 +178,41 @@ void Init_sdl2_ext(void)
|
|
183
178
|
DEFINE_SDL_INIT_CONST(EVERYTHING);
|
184
179
|
DEFINE_SDL_INIT_CONST(NOPARACHUTE);
|
185
180
|
|
186
|
-
/* SDL's version string */
|
181
|
+
/* @return [String] SDL's version string */
|
187
182
|
rb_define_const(mSDL2, "LIBSDL_VERSION", libsdl_version());
|
188
|
-
/* SDL's version array of numbers */
|
183
|
+
/* @return [Array(Integer, Integer, Integer)] SDL's version array of numbers */
|
189
184
|
rb_define_const(mSDL2, "LIBSDL_VERSION_NUMBER", libsdl_version_number());
|
190
|
-
/* SDL's revision (from VCS) string */
|
185
|
+
/* @return [String] SDL's revision (from VCS) string */
|
191
186
|
rb_define_const(mSDL2, "LIBSDL_REVISION", libsdl_revision());
|
192
|
-
/*
|
193
|
-
|
187
|
+
/* @return [Integer] always 0
|
188
|
+
* @deprecated
|
189
|
+
*/
|
190
|
+
rb_define_const(mSDL2, "LIBSDL_REVISION_NUMBER", INT2NUM(0));
|
194
191
|
|
195
192
|
#ifdef HAVE_SDL_IMAGE_H
|
196
193
|
{
|
197
194
|
const SDL_version* version = IMG_Linked_Version();
|
198
|
-
/* SDL_image's version string, only available if SDL_image is linked */
|
195
|
+
/* @return [String] SDL_image's version string, only available if SDL_image is linked */
|
199
196
|
rb_define_const(mSDL2, "LIBSDL_IMAGE_VERSION", SDL_version_to_String(version));
|
200
|
-
/* SDL_image's version array of numbers */
|
197
|
+
/* @return [Array(Integer, Integer, Integer)] SDL_image's version array of numbers */
|
201
198
|
rb_define_const(mSDL2, "LIBSDL_IMAGE_VERSION_NUMBER", SDL_version_to_Array(version));
|
202
199
|
}
|
203
200
|
#endif
|
204
201
|
#ifdef HAVE_SDL_TTF_H
|
205
202
|
{
|
206
203
|
const SDL_version* version = TTF_Linked_Version();
|
207
|
-
/* SDL_ttf's version string, only available if SDL_ttf is linked */
|
204
|
+
/* @return [String] SDL_ttf's version string, only available if SDL_ttf is linked */
|
208
205
|
rb_define_const(mSDL2, "LIBSDL_TTF_VERSION", SDL_version_to_String(version));
|
209
|
-
/* SDL_ttf's version array of numbers */
|
206
|
+
/* @return [Array(Integer, Integer, Integer)] SDL_ttf's version array of numbers */
|
210
207
|
rb_define_const(mSDL2, "LIBSDL_TTF_VERSION_NUMBER", SDL_version_to_Array(version));
|
211
208
|
}
|
212
209
|
#endif
|
213
210
|
#ifdef HAVE_SDL_MIXER_H
|
214
211
|
{
|
215
212
|
const SDL_version* version = Mix_Linked_Version();
|
216
|
-
/* SDL_mixer's version string , only available if SDL_mixer is linked */
|
213
|
+
/* @return [Integer] SDL_mixer's version string , only available if SDL_mixer is linked */
|
217
214
|
rb_define_const(mSDL2, "LIBSDL_MIXER_VERSION", SDL_version_to_String(version));
|
218
|
-
/* SDL_mixer's version array of numbers */
|
215
|
+
/* @return [Array(Integer, Integer, Integer)] SDL_mixer's version array of numbers */
|
219
216
|
rb_define_const(mSDL2, "LIBSDL_MIXER_VERSION_NUMBER", SDL_version_to_Array(version));
|
220
217
|
}
|
221
218
|
#endif
|
data/messagebox.c
CHANGED
@@ -70,7 +70,7 @@ static void set_color_scheme(VALUE colors, VALUE sym, SDL_MessageBoxColor* color
|
|
70
70
|
}
|
71
71
|
|
72
72
|
/*
|
73
|
-
* @overload show(
|
73
|
+
* @overload show(flags:, window: nil, title:, message:, buttons:, color_scheme: nil)
|
74
74
|
* Create a model message box.
|
75
75
|
*
|
76
76
|
* You specify one of the following constants as flag
|
@@ -134,7 +134,7 @@ static void set_color_scheme(VALUE colors, VALUE sym, SDL_MessageBoxColor* color
|
|
134
134
|
* @param [String] title the title text
|
135
135
|
* @param [String] message the message text
|
136
136
|
* @param [Array<Hash<Symbol => Object>>] buttons array of buttons
|
137
|
-
* @param [Hash<Symbol=>
|
137
|
+
* @param [Hash<Symbol=>Array(Integer,Integer,Integer)>, nil] color_scheme
|
138
138
|
* color scheme, or nil for the default color scheme
|
139
139
|
* @return [Integer] pressed button id
|
140
140
|
*
|
@@ -205,16 +205,16 @@ void rubysdl2_init_messagebox(void)
|
|
205
205
|
rb_define_singleton_method(mMessageBox, "show_simple_box",
|
206
206
|
MessageBox_s_show_simple_box, 4);
|
207
207
|
rb_define_singleton_method(mMessageBox, "show", MessageBox_s_show, 1);
|
208
|
-
/*
|
208
|
+
/* @return [Integer] the flag whcih means that the message box shows an error message */
|
209
209
|
rb_define_const(mMessageBox, "ERROR", INT2NUM(SDL_MESSAGEBOX_ERROR));
|
210
|
-
/*
|
210
|
+
/* @return [Integer] the flag whcih means that the message box shows a warning message */
|
211
211
|
rb_define_const(mMessageBox, "WARNING", INT2NUM(SDL_MESSAGEBOX_WARNING));
|
212
|
-
/*
|
212
|
+
/* @return [Integer] the flag whcih means that the message box shows an informational message */
|
213
213
|
rb_define_const(mMessageBox, "INFORMATION", INT2NUM(SDL_MESSAGEBOX_INFORMATION));
|
214
|
-
/*
|
214
|
+
/* @return [Integer] the flag whcih represents the button is selected when return key is pressed */
|
215
215
|
rb_define_const(mMessageBox, "BUTTON_RETURNKEY_DEFAULT",
|
216
216
|
INT2NUM(SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT));
|
217
|
-
/*
|
217
|
+
/* @return [Integer] the flag whcih represents the button is selected when escape key is pressed */
|
218
218
|
rb_define_const(mMessageBox, "BUTTON_ESCAPEKEY_DEFAULT",
|
219
219
|
INT2NUM(SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT));
|
220
220
|
|