ruby-sdl2 0.3.5 → 0.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +4 -1
- data/Gemfile +10 -0
- data/README.md +8 -3
- data/Rakefile +22 -2
- data/Steepfile +24 -0
- data/doc/DEVELOP.md +35 -0
- data/event.c +36 -32
- data/gamecontroller.c +31 -27
- data/gamecontroller.c.m4 +31 -27
- data/gl.c +63 -67
- data/gl.c.m4 +63 -67
- data/hint.c +3 -3
- data/joystick.c +16 -12
- data/joystick.c.m4 +16 -12
- data/key.c +21 -19
- data/key.c.m4 +21 -19
- data/lib/sdl2/version.rb +3 -3
- data/main.c +13 -16
- data/messagebox.c +7 -7
- data/mixer.c +54 -38
- data/mixer.c.m4 +54 -38
- data/mouse.c +3 -3
- data/rbs_collection.yaml +32 -0
- data/rubysdl2_internal.h +12 -1
- data/sample/test_read_pixels.rb +41 -0
- data/ttf.c +20 -17
- data/ttf.c.m4 +20 -17
- data/video.c +262 -143
- data/video.c.m4 +199 -112
- metadata +8 -6
data/gl.c
CHANGED
|
@@ -12,8 +12,6 @@ typedef struct GLContext {
|
|
|
12
12
|
SDL_GLContext context;
|
|
13
13
|
} GLContext;
|
|
14
14
|
|
|
15
|
-
DEFINE_WRAPPER(SDL_GLContext, GLContext, context, cGLContext, "SDL2::GL::Context");
|
|
16
|
-
|
|
17
15
|
static void GLContext_free(GLContext* c)
|
|
18
16
|
{
|
|
19
17
|
if (c->context)
|
|
@@ -21,11 +19,16 @@ static void GLContext_free(GLContext* c)
|
|
|
21
19
|
free(c);
|
|
22
20
|
}
|
|
23
21
|
|
|
22
|
+
DEFINE_DATA_TYPE(GLContext, GLContext_free);
|
|
23
|
+
|
|
24
|
+
DEFINE_WRAPPER(SDL_GLContext, GLContext, context, cGLContext, "SDL2::GL::Context");
|
|
25
|
+
|
|
24
26
|
static VALUE GLContext_new(SDL_GLContext context)
|
|
25
27
|
{
|
|
26
|
-
GLContext* c
|
|
28
|
+
GLContext* c;
|
|
29
|
+
VALUE obj = TypedData_Make_Struct(cGLContext, GLContext, &GLContext_data_type, c);
|
|
27
30
|
c->context = context;
|
|
28
|
-
return
|
|
31
|
+
return obj;
|
|
29
32
|
}
|
|
30
33
|
|
|
31
34
|
/*
|
|
@@ -115,8 +118,7 @@ static VALUE GLContext_make_current(VALUE self, VALUE window)
|
|
|
115
118
|
/*
|
|
116
119
|
* Get the current OpenGL context.
|
|
117
120
|
*
|
|
118
|
-
* @return [SDL2::GL::Context] the
|
|
119
|
-
* @return [nil] if there is no current context
|
|
121
|
+
* @return [SDL2::GL::Context,nil] the current context, nil if there is no current context
|
|
120
122
|
*
|
|
121
123
|
* @see #make_current
|
|
122
124
|
*/
|
|
@@ -130,6 +132,7 @@ static VALUE GLContext_s_current(VALUE self)
|
|
|
130
132
|
* Return true if the current context supports **extension**
|
|
131
133
|
*
|
|
132
134
|
* @param extension [String] the name of an extension
|
|
135
|
+
* @return [Boolean]
|
|
133
136
|
* @example
|
|
134
137
|
* SDL2::GL.extension_supported?("GL_EXT_framebuffer_blit")
|
|
135
138
|
*/
|
|
@@ -190,7 +193,7 @@ static VALUE GL_s_get_attribute(VALUE self, VALUE attr)
|
|
|
190
193
|
*
|
|
191
194
|
* @param attr [Integer] the OpenGL attribute to set
|
|
192
195
|
* @param value [Integer] the desired value for the attribute
|
|
193
|
-
* @return [
|
|
196
|
+
* @return [void]
|
|
194
197
|
*/
|
|
195
198
|
static VALUE GL_s_set_attribute(VALUE self, VALUE attr, VALUE value)
|
|
196
199
|
{
|
|
@@ -217,56 +220,48 @@ void rubysdl2_init_gl(void)
|
|
|
217
220
|
rb_define_module_function(mGL, "set_attribute", GL_s_set_attribute, 2);
|
|
218
221
|
|
|
219
222
|
/* */
|
|
220
|
-
/* OpenGL attribute - minimal bits of red channel in color buffer, default is 3 */
|
|
223
|
+
/* @return [Integer] index for OpenGL attribute - minimal bits of red channel in color buffer, default is 3 */
|
|
221
224
|
rb_define_const(mGL, "RED_SIZE", INT2NUM(SDL_GL_RED_SIZE));
|
|
222
|
-
/* OpenGL attribute - minimal bits of green channel in color buffer, default is 3 */
|
|
225
|
+
/* @return [Integer] index for OpenGL attribute - minimal bits of green channel in color buffer, default is 3 */
|
|
223
226
|
rb_define_const(mGL, "GREEN_SIZE", INT2NUM(SDL_GL_GREEN_SIZE));
|
|
224
|
-
/* OpenGL attribute - minimal bits of blue channel in color buffer, default is 2 */
|
|
227
|
+
/* @return [Integer] index for OpenGL attribute - minimal bits of blue channel in color buffer, default is 2 */
|
|
225
228
|
rb_define_const(mGL, "BLUE_SIZE", INT2NUM(SDL_GL_BLUE_SIZE));
|
|
226
|
-
/* OpenGL attribute - minimal bits of alpha channel in color buffer, default is 0 */
|
|
229
|
+
/* @return [Integer] index for OpenGL attribute - minimal bits of alpha channel in color buffer, default is 0 */
|
|
227
230
|
rb_define_const(mGL, "ALPHA_SIZE", INT2NUM(SDL_GL_ALPHA_SIZE));
|
|
228
|
-
/* OpenGL attribute - minimal bits of framebufer, default is 0 */
|
|
231
|
+
/* @return [Integer] index for OpenGL attribute - minimal bits of framebufer, default is 0 */
|
|
229
232
|
rb_define_const(mGL, "BUFFER_SIZE", INT2NUM(SDL_GL_BUFFER_SIZE));
|
|
230
|
-
/* OpenGL attribute - whether the single buffer (0) or double buffer (1), default
|
|
231
|
-
is double buffer */
|
|
233
|
+
/* @return [Integer] index for OpenGL attribute - whether the single buffer (0) or double buffer (1), default is double buffer */
|
|
232
234
|
rb_define_const(mGL, "DOUBLEBUFFER", INT2NUM(SDL_GL_DOUBLEBUFFER));
|
|
233
|
-
/* OpenGL attribute - bits of depth buffer, default is 16 */
|
|
235
|
+
/* @return [Integer] index for OpenGL attribute - bits of depth buffer, default is 16 */
|
|
234
236
|
rb_define_const(mGL, "DEPTH_SIZE", INT2NUM(SDL_GL_DEPTH_SIZE));
|
|
235
|
-
/* OpenGL attribute - bits of stencil buffer, default is 0 */
|
|
237
|
+
/* @return [Integer] index for OpenGL attribute - bits of stencil buffer, default is 0 */
|
|
236
238
|
rb_define_const(mGL, "STENCIL_SIZE", INT2NUM(SDL_GL_STENCIL_SIZE));
|
|
237
|
-
/* OpenGL attribute - minimal bits of red channel in accumlation buffer,
|
|
238
|
-
default is 0 */
|
|
239
|
+
/* @return [Integer] index for OpenGL attribute - minimal bits of red channel in accumlation buffer, default is 0 */
|
|
239
240
|
rb_define_const(mGL, "ACCUM_RED_SIZE", INT2NUM(SDL_GL_ACCUM_RED_SIZE));
|
|
240
|
-
/* OpenGL attribute - minimal bits of green channel in accumlation buffer,
|
|
241
|
-
default is 0 */
|
|
241
|
+
/* @return [Integer] index for OpenGL attribute - minimal bits of green channel in accumlation buffer, default is 0 */
|
|
242
242
|
rb_define_const(mGL, "ACCUM_GREEN_SIZE", INT2NUM(SDL_GL_ACCUM_GREEN_SIZE));
|
|
243
|
-
/* OpenGL attribute - minimal bits of blue channel in accumlation buffer,
|
|
244
|
-
default is 0 */
|
|
243
|
+
/* @return [Integer] index for OpenGL attribute - minimal bits of blue channel in accumlation buffer, default is 0 */
|
|
245
244
|
rb_define_const(mGL, "ACCUM_BLUE_SIZE", INT2NUM(SDL_GL_ACCUM_BLUE_SIZE));
|
|
246
|
-
/* OpenGL attribute - minimal bits of alpha channel in accumlation buffer,
|
|
247
|
-
default is 0 */
|
|
245
|
+
/* @return [Integer] index for OpenGL attribute - minimal bits of alpha channel in accumlation buffer, default is 0 */
|
|
248
246
|
rb_define_const(mGL, "ACCUM_ALPHA_SIZE", INT2NUM(SDL_GL_ACCUM_ALPHA_SIZE));
|
|
249
|
-
/* OpenGL attribute - whether output is stereo (1) or not (0), default is 0 */
|
|
247
|
+
/* @return [Integer] index for OpenGL attribute - whether output is stereo (1) or not (0), default is 0 */
|
|
250
248
|
rb_define_const(mGL, "STEREO", INT2NUM(SDL_GL_STEREO));
|
|
251
|
-
/* OpenGL attribuite - the number of buffers used for multisampe anti-aliasing,
|
|
252
|
-
default is 0 */
|
|
249
|
+
/* @return [Integer] index for OpenGL attribuite - the number of buffers used for multisampe anti-aliasing, default is 0 */
|
|
253
250
|
rb_define_const(mGL, "MULTISAMPLEBUFFERS", INT2NUM(SDL_GL_MULTISAMPLEBUFFERS));
|
|
254
|
-
/* OpenGL attribute - the number of samples used around the current pixel
|
|
255
|
-
use for multisample anti-aliasing, default is 0 */
|
|
251
|
+
/* @return [Integer] index for OpenGL attribute - the number of samples used around the current pixel use for multisample anti-aliasing, default is 0 */
|
|
256
252
|
rb_define_const(mGL, "MULTISAMPLESAMPLES", INT2NUM(SDL_GL_MULTISAMPLESAMPLES));
|
|
257
|
-
/* OpenGL attribute - 1 for requiring hardware acceleration, 0 for software rendering,
|
|
258
|
-
default is allowing either */
|
|
253
|
+
/* @return [Integer] index for OpenGL attribute - 1 for requiring hardware acceleration, 0 for software rendering, default is allowing either */
|
|
259
254
|
rb_define_const(mGL, "ACCELERATED_VISUAL", INT2NUM(SDL_GL_ACCELERATED_VISUAL));
|
|
260
|
-
/* OpenGL attribute - not used (deprecated) */
|
|
255
|
+
/* @return [Integer] index for OpenGL attribute - not used (deprecated) */
|
|
261
256
|
rb_define_const(mGL, "RETAINED_BACKING", INT2NUM(SDL_GL_RETAINED_BACKING));
|
|
262
|
-
/* OpenGL attribute - OpenGL context major version */
|
|
257
|
+
/* @return [Integer] index for OpenGL attribute - OpenGL context major version */
|
|
263
258
|
rb_define_const(mGL, "CONTEXT_MAJOR_VERSION", INT2NUM(SDL_GL_CONTEXT_MAJOR_VERSION));
|
|
264
|
-
/* OpenGL attribute - OpenGL context minor version */
|
|
259
|
+
/* @return [Integer] index for OpenGL attribute - OpenGL context minor version */
|
|
265
260
|
rb_define_const(mGL, "CONTEXT_MINOR_VERSION", INT2NUM(SDL_GL_CONTEXT_MINOR_VERSION));
|
|
266
261
|
/*
|
|
267
262
|
* INT2NUM(SDL_GL_CONTEXT_FLAGS):
|
|
268
263
|
*
|
|
269
|
-
* OpenGL attribute - the bit combination of following constants, or 0.
|
|
264
|
+
* @return [Integer] index for OpenGL attribute - the bit combination of following constants, or 0.
|
|
270
265
|
* default is 0
|
|
271
266
|
*
|
|
272
267
|
* * {SDL2::GL::CONTEXT_DEBUG_FLAG}
|
|
@@ -282,7 +277,7 @@ void rubysdl2_init_gl(void)
|
|
|
282
277
|
rb_define_const(mGL, "CONTEXT_FLAGS", INT2NUM(SDL_GL_CONTEXT_FLAGS));
|
|
283
278
|
/* INT2NUM(SDL_GL_CONTEXT_PROFILE_MASK):
|
|
284
279
|
*
|
|
285
|
-
* OpenGL attribute - type of GL context, one of the following constants,
|
|
280
|
+
* @return [Integer] index for OpenGL attribute - type of GL context, one of the following constants,
|
|
286
281
|
* defaults depends on platform
|
|
287
282
|
*
|
|
288
283
|
* * {CONTEXT_PROFILE_CORE}
|
|
@@ -292,58 +287,59 @@ void rubysdl2_init_gl(void)
|
|
|
292
287
|
* https://wiki.libsdl.org/SDL_GLprofile
|
|
293
288
|
*/
|
|
294
289
|
rb_define_const(mGL, "CONTEXT_PROFILE_MASK", INT2NUM(SDL_GL_CONTEXT_PROFILE_MASK));
|
|
295
|
-
/* OpenGL attribute - OpenGL context sharing, default is 0 */
|
|
290
|
+
/* @return [Integer] index for OpenGL attribute - OpenGL context sharing, default is 0 */
|
|
296
291
|
rb_define_const(mGL, "SHARE_WITH_CURRENT_CONTEXT", INT2NUM(SDL_GL_SHARE_WITH_CURRENT_CONTEXT));
|
|
297
292
|
#if SDL_VERSION_ATLEAST(2,0,1)
|
|
298
|
-
/* OpenGL attribute - 1 for requesting sRGB capable visual, default to 0 */
|
|
293
|
+
/* @return [Integer] index for OpenGL attribute - 1 for requesting sRGB capable visual, default to 0 */
|
|
299
294
|
rb_define_const(mGL, "FRAMEBUFFER_SRGB_CAPABLE", INT2NUM(SDL_GL_FRAMEBUFFER_SRGB_CAPABLE));
|
|
300
295
|
#endif
|
|
301
|
-
/* OpenGL attribute - not used (deprecated) */
|
|
296
|
+
/* @return [Integer] index for OpenGL attribute - not used (deprecated) */
|
|
302
297
|
rb_define_const(mGL, "CONTEXT_EGL", INT2NUM(SDL_GL_CONTEXT_EGL));
|
|
303
298
|
|
|
304
299
|
/* */
|
|
305
300
|
|
|
306
|
-
/*
|
|
307
|
-
*
|
|
308
|
-
*
|
|
309
|
-
*
|
|
301
|
+
/* @return [Integer]
|
|
302
|
+
* This flag maps to GLX_CONTEXT_DEBUG_BIT_ARB in
|
|
303
|
+
* the GLX_ARB_create_context extension for X11
|
|
304
|
+
* and WGL_CONTEXT_DEBUG_BIT_ARB in the WGL_ARB_create_context
|
|
305
|
+
* extension for Windows.
|
|
310
306
|
*/
|
|
311
307
|
rb_define_const(mGL, "CONTEXT_DEBUG_FLAG", INT2NUM(SDL_GL_CONTEXT_DEBUG_FLAG));
|
|
312
|
-
/*
|
|
313
|
-
*
|
|
314
|
-
*
|
|
315
|
-
*
|
|
316
|
-
*
|
|
308
|
+
/* @return [Integer]
|
|
309
|
+
* This flag maps to GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB in the
|
|
310
|
+
* GLX_ARB_create_context extension for X11 and
|
|
311
|
+
* WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB in the WGL_ARB_create_context
|
|
312
|
+
* extension for Windows.
|
|
317
313
|
*/
|
|
318
314
|
rb_define_const(mGL, "CONTEXT_FORWARD_COMPATIBLE_FLAG", INT2NUM(SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG));
|
|
319
|
-
/*
|
|
320
|
-
*
|
|
321
|
-
*
|
|
322
|
-
*
|
|
323
|
-
*
|
|
315
|
+
/* @return [Integer]
|
|
316
|
+
* This flag maps to GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB in the
|
|
317
|
+
* GLX_ARB_create_context_robustness extension for X11 and
|
|
318
|
+
* WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB in the WGL_ARB_create_context_robustness
|
|
319
|
+
* extension for Windows.
|
|
324
320
|
*/
|
|
325
321
|
rb_define_const(mGL, "CONTEXT_ROBUST_ACCESS_FLAG", INT2NUM(SDL_GL_CONTEXT_ROBUST_ACCESS_FLAG));
|
|
326
|
-
/*
|
|
327
|
-
*
|
|
328
|
-
*
|
|
329
|
-
*
|
|
330
|
-
*
|
|
322
|
+
/* @return [Integer]
|
|
323
|
+
* This flag maps to GLX_CONTEXT_RESET_ISOLATION_BIT_ARB in the
|
|
324
|
+
* GLX_ARB_robustness_isolation extension for X11 and
|
|
325
|
+
* WGL_CONTEXT_RESET_ISOLATION_BIT_ARB in the WGL_ARB_create_context_robustness
|
|
326
|
+
* extension for Windows.
|
|
331
327
|
*/
|
|
332
328
|
rb_define_const(mGL, "CONTEXT_RESET_ISOLATION_FLAG", INT2NUM(SDL_GL_CONTEXT_RESET_ISOLATION_FLAG));
|
|
333
329
|
|
|
334
|
-
/*
|
|
335
|
-
*
|
|
336
|
-
*
|
|
330
|
+
/* @return [Integer]
|
|
331
|
+
* OpenGL core profile - deprecated
|
|
332
|
+
* functions are disabled
|
|
337
333
|
*/
|
|
338
334
|
rb_define_const(mGL, "CONTEXT_PROFILE_CORE", INT2NUM(SDL_GL_CONTEXT_PROFILE_CORE));
|
|
339
|
-
/*
|
|
340
|
-
*
|
|
341
|
-
*
|
|
335
|
+
/* @return [Integer]
|
|
336
|
+
* OpenGL compatibility profile -
|
|
337
|
+
* deprecated functions are allowed
|
|
342
338
|
*/
|
|
343
339
|
rb_define_const(mGL, "CONTEXT_PROFILE_COMPATIBILITY", INT2NUM(SDL_GL_CONTEXT_PROFILE_COMPATIBILITY));
|
|
344
|
-
/*
|
|
345
|
-
*
|
|
346
|
-
*
|
|
340
|
+
/* @return [Integer]
|
|
341
|
+
* OpenGL ES profile - only a subset of the
|
|
342
|
+
* base OpenGL functionality is available
|
|
347
343
|
*/
|
|
348
344
|
rb_define_const(mGL, "CONTEXT_PROFILE_ES", INT2NUM(SDL_GL_CONTEXT_PROFILE_ES));
|
|
349
345
|
|
data/gl.c.m4
CHANGED
|
@@ -12,8 +12,6 @@ typedef struct GLContext {
|
|
|
12
12
|
SDL_GLContext context;
|
|
13
13
|
} GLContext;
|
|
14
14
|
|
|
15
|
-
DEFINE_WRAPPER(SDL_GLContext, GLContext, context, cGLContext, "SDL2::GL::Context");
|
|
16
|
-
|
|
17
15
|
static void GLContext_free(GLContext* c)
|
|
18
16
|
{
|
|
19
17
|
if (c->context)
|
|
@@ -21,11 +19,16 @@ static void GLContext_free(GLContext* c)
|
|
|
21
19
|
free(c);
|
|
22
20
|
}
|
|
23
21
|
|
|
22
|
+
DEFINE_DATA_TYPE(GLContext, GLContext_free);
|
|
23
|
+
|
|
24
|
+
DEFINE_WRAPPER(SDL_GLContext, GLContext, context, cGLContext, "SDL2::GL::Context");
|
|
25
|
+
|
|
24
26
|
static VALUE GLContext_new(SDL_GLContext context)
|
|
25
27
|
{
|
|
26
|
-
GLContext* c
|
|
28
|
+
GLContext* c;
|
|
29
|
+
VALUE obj = TypedData_Make_Struct(cGLContext, GLContext, &GLContext_data_type, c);
|
|
27
30
|
c->context = context;
|
|
28
|
-
return
|
|
31
|
+
return obj;
|
|
29
32
|
}
|
|
30
33
|
|
|
31
34
|
/*
|
|
@@ -115,8 +118,7 @@ static VALUE GLContext_make_current(VALUE self, VALUE window)
|
|
|
115
118
|
/*
|
|
116
119
|
* Get the current OpenGL context.
|
|
117
120
|
*
|
|
118
|
-
* @return [SDL2::GL::Context] the
|
|
119
|
-
* @return [nil] if there is no current context
|
|
121
|
+
* @return [SDL2::GL::Context,nil] the current context, nil if there is no current context
|
|
120
122
|
*
|
|
121
123
|
* @see #make_current
|
|
122
124
|
*/
|
|
@@ -130,6 +132,7 @@ static VALUE GLContext_s_current(VALUE self)
|
|
|
130
132
|
* Return true if the current context supports **extension**
|
|
131
133
|
*
|
|
132
134
|
* @param extension [String] the name of an extension
|
|
135
|
+
* @return [Boolean]
|
|
133
136
|
* @example
|
|
134
137
|
* SDL2::GL.extension_supported?("GL_EXT_framebuffer_blit")
|
|
135
138
|
*/
|
|
@@ -190,7 +193,7 @@ static VALUE GL_s_get_attribute(VALUE self, VALUE attr)
|
|
|
190
193
|
*
|
|
191
194
|
* @param attr [Integer] the OpenGL attribute to set
|
|
192
195
|
* @param value [Integer] the desired value for the attribute
|
|
193
|
-
* @return [
|
|
196
|
+
* @return [void]
|
|
194
197
|
*/
|
|
195
198
|
static VALUE GL_s_set_attribute(VALUE self, VALUE attr, VALUE value)
|
|
196
199
|
{
|
|
@@ -217,56 +220,48 @@ void rubysdl2_init_gl(void)
|
|
|
217
220
|
rb_define_module_function(mGL, "set_attribute", GL_s_set_attribute, 2);
|
|
218
221
|
|
|
219
222
|
/* 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 */
|
|
223
|
+
/* @return [Integer] index for OpenGL attribute - minimal bits of red channel in color buffer, default is 3 */
|
|
221
224
|
DEFINE_GL_ATTR_CONST(RED_SIZE);
|
|
222
|
-
/* OpenGL attribute - minimal bits of green channel in color buffer, default is 3 */
|
|
225
|
+
/* @return [Integer] index for OpenGL attribute - minimal bits of green channel in color buffer, default is 3 */
|
|
223
226
|
DEFINE_GL_ATTR_CONST(GREEN_SIZE);
|
|
224
|
-
/* OpenGL attribute - minimal bits of blue channel in color buffer, default is 2 */
|
|
227
|
+
/* @return [Integer] index for OpenGL attribute - minimal bits of blue channel in color buffer, default is 2 */
|
|
225
228
|
DEFINE_GL_ATTR_CONST(BLUE_SIZE);
|
|
226
|
-
/* OpenGL attribute - minimal bits of alpha channel in color buffer, default is 0 */
|
|
229
|
+
/* @return [Integer] index for OpenGL attribute - minimal bits of alpha channel in color buffer, default is 0 */
|
|
227
230
|
DEFINE_GL_ATTR_CONST(ALPHA_SIZE);
|
|
228
|
-
/* OpenGL attribute - minimal bits of framebufer, default is 0 */
|
|
231
|
+
/* @return [Integer] index for OpenGL attribute - minimal bits of framebufer, default is 0 */
|
|
229
232
|
DEFINE_GL_ATTR_CONST(BUFFER_SIZE);
|
|
230
|
-
/* OpenGL attribute - whether the single buffer (0) or double buffer (1), default
|
|
231
|
-
is double buffer */
|
|
233
|
+
/* @return [Integer] index for OpenGL attribute - whether the single buffer (0) or double buffer (1), default is double buffer */
|
|
232
234
|
DEFINE_GL_ATTR_CONST(DOUBLEBUFFER);
|
|
233
|
-
/* OpenGL attribute - bits of depth buffer, default is 16 */
|
|
235
|
+
/* @return [Integer] index for OpenGL attribute - bits of depth buffer, default is 16 */
|
|
234
236
|
DEFINE_GL_ATTR_CONST(DEPTH_SIZE);
|
|
235
|
-
/* OpenGL attribute - bits of stencil buffer, default is 0 */
|
|
237
|
+
/* @return [Integer] index for OpenGL attribute - bits of stencil buffer, default is 0 */
|
|
236
238
|
DEFINE_GL_ATTR_CONST(STENCIL_SIZE);
|
|
237
|
-
/* OpenGL attribute - minimal bits of red channel in accumlation buffer,
|
|
238
|
-
default is 0 */
|
|
239
|
+
/* @return [Integer] index for OpenGL attribute - minimal bits of red channel in accumlation buffer, default is 0 */
|
|
239
240
|
DEFINE_GL_ATTR_CONST(ACCUM_RED_SIZE);
|
|
240
|
-
/* OpenGL attribute - minimal bits of green channel in accumlation buffer,
|
|
241
|
-
default is 0 */
|
|
241
|
+
/* @return [Integer] index for OpenGL attribute - minimal bits of green channel in accumlation buffer, default is 0 */
|
|
242
242
|
DEFINE_GL_ATTR_CONST(ACCUM_GREEN_SIZE);
|
|
243
|
-
/* OpenGL attribute - minimal bits of blue channel in accumlation buffer,
|
|
244
|
-
default is 0 */
|
|
243
|
+
/* @return [Integer] index for OpenGL attribute - minimal bits of blue channel in accumlation buffer, default is 0 */
|
|
245
244
|
DEFINE_GL_ATTR_CONST(ACCUM_BLUE_SIZE);
|
|
246
|
-
/* OpenGL attribute - minimal bits of alpha channel in accumlation buffer,
|
|
247
|
-
default is 0 */
|
|
245
|
+
/* @return [Integer] index for OpenGL attribute - minimal bits of alpha channel in accumlation buffer, default is 0 */
|
|
248
246
|
DEFINE_GL_ATTR_CONST(ACCUM_ALPHA_SIZE);
|
|
249
|
-
/* OpenGL attribute - whether output is stereo (1) or not (0), default is 0 */
|
|
247
|
+
/* @return [Integer] index for OpenGL attribute - whether output is stereo (1) or not (0), default is 0 */
|
|
250
248
|
DEFINE_GL_ATTR_CONST(STEREO);
|
|
251
|
-
/* OpenGL attribuite - the number of buffers used for multisampe anti-aliasing,
|
|
252
|
-
default is 0 */
|
|
249
|
+
/* @return [Integer] index for OpenGL attribuite - the number of buffers used for multisampe anti-aliasing, default is 0 */
|
|
253
250
|
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 */
|
|
251
|
+
/* @return [Integer] index for OpenGL attribute - the number of samples used around the current pixel use for multisample anti-aliasing, default is 0 */
|
|
256
252
|
DEFINE_GL_ATTR_CONST(MULTISAMPLESAMPLES);
|
|
257
|
-
/* OpenGL attribute - 1 for requiring hardware acceleration, 0 for software rendering,
|
|
258
|
-
default is allowing either */
|
|
253
|
+
/* @return [Integer] index for OpenGL attribute - 1 for requiring hardware acceleration, 0 for software rendering, default is allowing either */
|
|
259
254
|
DEFINE_GL_ATTR_CONST(ACCELERATED_VISUAL);
|
|
260
|
-
/* OpenGL attribute - not used (deprecated) */
|
|
255
|
+
/* @return [Integer] index for OpenGL attribute - not used (deprecated) */
|
|
261
256
|
DEFINE_GL_ATTR_CONST(RETAINED_BACKING);
|
|
262
|
-
/* OpenGL attribute - OpenGL context major version */
|
|
257
|
+
/* @return [Integer] index for OpenGL attribute - OpenGL context major version */
|
|
263
258
|
DEFINE_GL_ATTR_CONST(CONTEXT_MAJOR_VERSION);
|
|
264
|
-
/* OpenGL attribute - OpenGL context minor version */
|
|
259
|
+
/* @return [Integer] index for OpenGL attribute - OpenGL context minor version */
|
|
265
260
|
DEFINE_GL_ATTR_CONST(CONTEXT_MINOR_VERSION);
|
|
266
261
|
/*
|
|
267
262
|
* INT2NUM(SDL_GL_CONTEXT_FLAGS):
|
|
268
263
|
*
|
|
269
|
-
* OpenGL attribute - the bit combination of following constants, or 0.
|
|
264
|
+
* @return [Integer] index for OpenGL attribute - the bit combination of following constants, or 0.
|
|
270
265
|
* default is 0
|
|
271
266
|
*
|
|
272
267
|
* * {SDL2::GL::CONTEXT_DEBUG_FLAG}
|
|
@@ -282,7 +277,7 @@ void rubysdl2_init_gl(void)
|
|
|
282
277
|
DEFINE_GL_ATTR_CONST(CONTEXT_FLAGS);
|
|
283
278
|
/* INT2NUM(SDL_GL_CONTEXT_PROFILE_MASK):
|
|
284
279
|
*
|
|
285
|
-
* OpenGL attribute - type of GL context, one of the following constants,
|
|
280
|
+
* @return [Integer] index for OpenGL attribute - type of GL context, one of the following constants,
|
|
286
281
|
* defaults depends on platform
|
|
287
282
|
*
|
|
288
283
|
* * {CONTEXT_PROFILE_CORE}
|
|
@@ -292,58 +287,59 @@ void rubysdl2_init_gl(void)
|
|
|
292
287
|
* https://wiki.libsdl.org/SDL_GLprofile
|
|
293
288
|
*/
|
|
294
289
|
DEFINE_GL_ATTR_CONST(CONTEXT_PROFILE_MASK);
|
|
295
|
-
/* OpenGL attribute - OpenGL context sharing, default is 0 */
|
|
290
|
+
/* @return [Integer] index for OpenGL attribute - OpenGL context sharing, default is 0 */
|
|
296
291
|
DEFINE_GL_ATTR_CONST(SHARE_WITH_CURRENT_CONTEXT);
|
|
297
292
|
#if SDL_VERSION_ATLEAST(2,0,1)
|
|
298
|
-
/* OpenGL attribute - 1 for requesting sRGB capable visual, default to 0 */
|
|
293
|
+
/* @return [Integer] index for OpenGL attribute - 1 for requesting sRGB capable visual, default to 0 */
|
|
299
294
|
DEFINE_GL_ATTR_CONST(FRAMEBUFFER_SRGB_CAPABLE);
|
|
300
295
|
#endif
|
|
301
|
-
/* OpenGL attribute - not used (deprecated) */
|
|
296
|
+
/* @return [Integer] index for OpenGL attribute - not used (deprecated) */
|
|
302
297
|
DEFINE_GL_ATTR_CONST(CONTEXT_EGL);
|
|
303
298
|
|
|
304
299
|
/* define(`DEFINE_GL_CONTEXT_CONST',`rb_define_const(mGL, "CONTEXT_$1", INT2NUM(SDL_GL_CONTEXT_$1))') */
|
|
305
300
|
|
|
306
|
-
/*
|
|
307
|
-
*
|
|
308
|
-
*
|
|
309
|
-
*
|
|
301
|
+
/* @return [Integer]
|
|
302
|
+
* This flag maps to GLX_CONTEXT_DEBUG_BIT_ARB in
|
|
303
|
+
* the GLX_ARB_create_context extension for X11
|
|
304
|
+
* and WGL_CONTEXT_DEBUG_BIT_ARB in the WGL_ARB_create_context
|
|
305
|
+
* extension for Windows.
|
|
310
306
|
*/
|
|
311
307
|
DEFINE_GL_CONTEXT_CONST(DEBUG_FLAG);
|
|
312
|
-
/*
|
|
313
|
-
*
|
|
314
|
-
*
|
|
315
|
-
*
|
|
316
|
-
*
|
|
308
|
+
/* @return [Integer]
|
|
309
|
+
* This flag maps to GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB in the
|
|
310
|
+
* GLX_ARB_create_context extension for X11 and
|
|
311
|
+
* WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB in the WGL_ARB_create_context
|
|
312
|
+
* extension for Windows.
|
|
317
313
|
*/
|
|
318
314
|
DEFINE_GL_CONTEXT_CONST(FORWARD_COMPATIBLE_FLAG);
|
|
319
|
-
/*
|
|
320
|
-
*
|
|
321
|
-
*
|
|
322
|
-
*
|
|
323
|
-
*
|
|
315
|
+
/* @return [Integer]
|
|
316
|
+
* This flag maps to GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB in the
|
|
317
|
+
* GLX_ARB_create_context_robustness extension for X11 and
|
|
318
|
+
* WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB in the WGL_ARB_create_context_robustness
|
|
319
|
+
* extension for Windows.
|
|
324
320
|
*/
|
|
325
321
|
DEFINE_GL_CONTEXT_CONST(ROBUST_ACCESS_FLAG);
|
|
326
|
-
/*
|
|
327
|
-
*
|
|
328
|
-
*
|
|
329
|
-
*
|
|
330
|
-
*
|
|
322
|
+
/* @return [Integer]
|
|
323
|
+
* This flag maps to GLX_CONTEXT_RESET_ISOLATION_BIT_ARB in the
|
|
324
|
+
* GLX_ARB_robustness_isolation extension for X11 and
|
|
325
|
+
* WGL_CONTEXT_RESET_ISOLATION_BIT_ARB in the WGL_ARB_create_context_robustness
|
|
326
|
+
* extension for Windows.
|
|
331
327
|
*/
|
|
332
328
|
DEFINE_GL_CONTEXT_CONST(RESET_ISOLATION_FLAG);
|
|
333
329
|
|
|
334
|
-
/*
|
|
335
|
-
*
|
|
336
|
-
*
|
|
330
|
+
/* @return [Integer]
|
|
331
|
+
* OpenGL core profile - deprecated
|
|
332
|
+
* functions are disabled
|
|
337
333
|
*/
|
|
338
334
|
DEFINE_GL_CONTEXT_CONST(PROFILE_CORE);
|
|
339
|
-
/*
|
|
340
|
-
*
|
|
341
|
-
*
|
|
335
|
+
/* @return [Integer]
|
|
336
|
+
* OpenGL compatibility profile -
|
|
337
|
+
* deprecated functions are allowed
|
|
342
338
|
*/
|
|
343
339
|
DEFINE_GL_CONTEXT_CONST(PROFILE_COMPATIBILITY);
|
|
344
|
-
/*
|
|
345
|
-
*
|
|
346
|
-
*
|
|
340
|
+
/* @return [Integer]
|
|
341
|
+
* OpenGL ES profile - only a subset of the
|
|
342
|
+
* base OpenGL functionality is available
|
|
347
343
|
*/
|
|
348
344
|
DEFINE_GL_CONTEXT_CONST(PROFILE_ES);
|
|
349
345
|
|
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
|
@@ -18,11 +18,14 @@ static void Joystick_free(Joystick* j)
|
|
|
18
18
|
free(j);
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
DEFINE_DATA_TYPE(Joystick, Joystick_free);
|
|
22
|
+
|
|
21
23
|
static VALUE Joystick_new(SDL_Joystick* joystick)
|
|
22
24
|
{
|
|
23
|
-
Joystick* j
|
|
25
|
+
Joystick* j;
|
|
26
|
+
VALUE obj = TypedData_Make_Struct(cJoystick, Joystick, &Joystick_data_type, j);
|
|
24
27
|
j->joystick = joystick;
|
|
25
|
-
return
|
|
28
|
+
return obj;
|
|
26
29
|
}
|
|
27
30
|
|
|
28
31
|
DEFINE_WRAPPER(SDL_Joystick, Joystick, joystick, cJoystick, "SDL2::Joystick");
|
|
@@ -99,6 +102,7 @@ static VALUE Joystick_s_open(VALUE self, VALUE device_index)
|
|
|
99
102
|
* interface.
|
|
100
103
|
*
|
|
101
104
|
* @param [Integer] index the joystick device index
|
|
105
|
+
* @return [Boolean]
|
|
102
106
|
* @see SDL2::GameController
|
|
103
107
|
*
|
|
104
108
|
*/
|
|
@@ -225,7 +229,7 @@ static VALUE Joystick_axis(VALUE self, VALUE which)
|
|
|
225
229
|
* Get the current state of a trackball on a joystick.
|
|
226
230
|
*
|
|
227
231
|
* @param [Integer] which an index of a trackball, started at index 0
|
|
228
|
-
* @return [
|
|
232
|
+
* @return [Array(Integer,Integer)] dx and dy
|
|
229
233
|
* @see #num_balls
|
|
230
234
|
*/
|
|
231
235
|
static VALUE Joystick_ball(VALUE self, VALUE which)
|
|
@@ -309,23 +313,23 @@ void rubysdl2_init_joystick(void)
|
|
|
309
313
|
mHat = rb_define_module_under(cJoystick, "Hat");
|
|
310
314
|
|
|
311
315
|
/* */
|
|
312
|
-
/* Center position. Equal to 0. */
|
|
316
|
+
/* @return [Integer] hat state\: Center position. Equal to 0. */
|
|
313
317
|
rb_define_const(mHat, "CENTERED", INT2NUM(SDL_HAT_CENTERED));
|
|
314
|
-
/* Up position. */
|
|
318
|
+
/* @return [Integer] hat state\: Up position. */
|
|
315
319
|
rb_define_const(mHat, "UP", INT2NUM(SDL_HAT_UP));
|
|
316
|
-
/* Right position. */
|
|
320
|
+
/* @return [Integer] hat state\: Right position. */
|
|
317
321
|
rb_define_const(mHat, "RIGHT", INT2NUM(SDL_HAT_RIGHT));
|
|
318
|
-
/* Down position. */
|
|
322
|
+
/* @return [Integer] hat state\: Down position. */
|
|
319
323
|
rb_define_const(mHat, "DOWN", INT2NUM(SDL_HAT_DOWN));
|
|
320
|
-
/* Left position. */
|
|
324
|
+
/* @return [Integer] hat state\: Left position. */
|
|
321
325
|
rb_define_const(mHat, "LEFT", INT2NUM(SDL_HAT_LEFT));
|
|
322
|
-
/* Right Up position. Equal to ({RIGHT} | {UP}) */
|
|
326
|
+
/* @return [Integer] hat state\: Right Up position. Equal to ({RIGHT} | {UP}) */
|
|
323
327
|
rb_define_const(mHat, "RIGHTUP", INT2NUM(SDL_HAT_RIGHTUP));
|
|
324
|
-
/* Right Down position. Equal to ({RIGHT} | {DOWN}) */
|
|
328
|
+
/* @return [Integer] hat state\: Right Down position. Equal to ({RIGHT} | {DOWN}) */
|
|
325
329
|
rb_define_const(mHat, "RIGHTDOWN", INT2NUM(SDL_HAT_RIGHTDOWN));
|
|
326
|
-
/* Left Up position. Equal to ({LEFT} | {UP}) */
|
|
330
|
+
/* @return [Integer] hat state\: Left Up position. Equal to ({LEFT} | {UP}) */
|
|
327
331
|
rb_define_const(mHat, "LEFTUP", INT2NUM(SDL_HAT_LEFTUP));
|
|
328
|
-
/* Left Down position. Equal to ({LEFT} | {DOWN}) */
|
|
332
|
+
/* @return [Integer] hat state\: Left Down position. Equal to ({LEFT} | {DOWN}) */
|
|
329
333
|
rb_define_const(mHat, "LEFTDOWN", INT2NUM(SDL_HAT_LEFTDOWN));
|
|
330
334
|
|
|
331
335
|
/* Device GUID
|
data/joystick.c.m4
CHANGED
|
@@ -18,11 +18,14 @@ static void Joystick_free(Joystick* j)
|
|
|
18
18
|
free(j);
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
DEFINE_DATA_TYPE(Joystick, Joystick_free);
|
|
22
|
+
|
|
21
23
|
static VALUE Joystick_new(SDL_Joystick* joystick)
|
|
22
24
|
{
|
|
23
|
-
Joystick* j
|
|
25
|
+
Joystick* j;
|
|
26
|
+
VALUE obj = TypedData_Make_Struct(cJoystick, Joystick, &Joystick_data_type, j);
|
|
24
27
|
j->joystick = joystick;
|
|
25
|
-
return
|
|
28
|
+
return obj;
|
|
26
29
|
}
|
|
27
30
|
|
|
28
31
|
DEFINE_WRAPPER(SDL_Joystick, Joystick, joystick, cJoystick, "SDL2::Joystick");
|
|
@@ -99,6 +102,7 @@ static VALUE Joystick_s_open(VALUE self, VALUE device_index)
|
|
|
99
102
|
* interface.
|
|
100
103
|
*
|
|
101
104
|
* @param [Integer] index the joystick device index
|
|
105
|
+
* @return [Boolean]
|
|
102
106
|
* @see SDL2::GameController
|
|
103
107
|
*
|
|
104
108
|
*/
|
|
@@ -225,7 +229,7 @@ static VALUE Joystick_axis(VALUE self, VALUE which)
|
|
|
225
229
|
* Get the current state of a trackball on a joystick.
|
|
226
230
|
*
|
|
227
231
|
* @param [Integer] which an index of a trackball, started at index 0
|
|
228
|
-
* @return [
|
|
232
|
+
* @return [Array(Integer,Integer)] dx and dy
|
|
229
233
|
* @see #num_balls
|
|
230
234
|
*/
|
|
231
235
|
static VALUE Joystick_ball(VALUE self, VALUE which)
|
|
@@ -309,23 +313,23 @@ void rubysdl2_init_joystick(void)
|
|
|
309
313
|
mHat = rb_define_module_under(cJoystick, "Hat");
|
|
310
314
|
|
|
311
315
|
/* define(`DEFINE_JOY_HAT_CONST',`rb_define_const(mHat, "$1", INT2NUM(SDL_HAT_$1))') */
|
|
312
|
-
/* Center position. Equal to 0. */
|
|
316
|
+
/* @return [Integer] hat state\: Center position. Equal to 0. */
|
|
313
317
|
DEFINE_JOY_HAT_CONST(CENTERED);
|
|
314
|
-
/* Up position. */
|
|
318
|
+
/* @return [Integer] hat state\: Up position. */
|
|
315
319
|
DEFINE_JOY_HAT_CONST(UP);
|
|
316
|
-
/* Right position. */
|
|
320
|
+
/* @return [Integer] hat state\: Right position. */
|
|
317
321
|
DEFINE_JOY_HAT_CONST(RIGHT);
|
|
318
|
-
/* Down position. */
|
|
322
|
+
/* @return [Integer] hat state\: Down position. */
|
|
319
323
|
DEFINE_JOY_HAT_CONST(DOWN);
|
|
320
|
-
/* Left position. */
|
|
324
|
+
/* @return [Integer] hat state\: Left position. */
|
|
321
325
|
DEFINE_JOY_HAT_CONST(LEFT);
|
|
322
|
-
/* Right Up position. Equal to ({RIGHT} | {UP}) */
|
|
326
|
+
/* @return [Integer] hat state\: Right Up position. Equal to ({RIGHT} | {UP}) */
|
|
323
327
|
DEFINE_JOY_HAT_CONST(RIGHTUP);
|
|
324
|
-
/* Right Down position. Equal to ({RIGHT} | {DOWN}) */
|
|
328
|
+
/* @return [Integer] hat state\: Right Down position. Equal to ({RIGHT} | {DOWN}) */
|
|
325
329
|
DEFINE_JOY_HAT_CONST(RIGHTDOWN);
|
|
326
|
-
/* Left Up position. Equal to ({LEFT} | {UP}) */
|
|
330
|
+
/* @return [Integer] hat state\: Left Up position. Equal to ({LEFT} | {UP}) */
|
|
327
331
|
DEFINE_JOY_HAT_CONST(LEFTUP);
|
|
328
|
-
/* Left Down position. Equal to ({LEFT} | {DOWN}) */
|
|
332
|
+
/* @return [Integer] hat state\: Left Down position. Equal to ({LEFT} | {DOWN}) */
|
|
329
333
|
DEFINE_JOY_HAT_CONST(LEFTDOWN);
|
|
330
334
|
|
|
331
335
|
/* Device GUID
|