├── .gitignore ├── META6.json ├── README.md ├── lib ├── SDL.pm6 └── SDL │ ├── Constants.pm6 │ ├── Functions.pm6 │ └── Structures.pm6 ├── share ├── sample.wav └── silence.wav └── t ├── core.t ├── mixer-channels.t └── rect.t /.gitignore: -------------------------------------------------------------------------------- 1 | lib/.precomp/ 2 | -------------------------------------------------------------------------------- /META6.json: -------------------------------------------------------------------------------- 1 | { 2 | "perl" : "6.*", 3 | "name" : "SDL", 4 | "version" : "0.2.0", 5 | "description" : "A Perl 6 wrapper around SDL 1.2", 6 | "depends" : [ ], 7 | "provides" : { 8 | "SDL" : "lib/SDL.pm6", 9 | "SDL::Constants" : "lib/SDL/Constants.pm6", 10 | "SDL::Functions" : "lib/SDL/Functions.pm6", 11 | "SDL::Structures" : "lib/SDL/Structures.pm6" 12 | }, 13 | "source-url" : "git://github.com/PerlGameDev/SDL6.git" 14 | } 15 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | This module provides access to the Simple DirectMedia Layer (www.libsdl.org) to Perl6. 2 | 3 | It makes use of NativeCall, so a C compiler is not needed in order to install this module. 4 | 5 | ## Dependencies 6 | 7 | - libSDL, libSDL-mixer, libSDL-image 8 | 9 | To aid NativeCall locating the libaries you should just do: 10 | ```bash 11 | sudo apt install libsdl1.2-dev libsdl-mixer1.2-dev libsdl-image1.2-dev 12 | ``` 13 | -------------------------------------------------------------------------------- /lib/SDL.pm6: -------------------------------------------------------------------------------- 1 | use v6; 2 | use SDL::Constants; 3 | use SDL::Structures; 4 | use SDL::Functions; 5 | 6 | sub EXPORT { %( 7 | SDL::Constants::EXPORT::DEFAULT::, 8 | SDL::Structures::EXPORT::DEFAULT::, 9 | SDL::Functions::EXPORT::DEFAULT::, 10 | ) } 11 | -------------------------------------------------------------------------------- /lib/SDL/Constants.pm6: -------------------------------------------------------------------------------- 1 | unit module SDL::Constants; 2 | 3 | enum SDL::Constants::Init is export ( 4 | SDL_INIT_TIMER => 0x00000001, 5 | SDL_INIT_AUDIO => 0x00000010, 6 | SDL_INIT_VIDEO => 0x00000020, 7 | SDL_INIT_CDROM => 0x00000100, 8 | SDL_INIT_JOYSTICK => 0x00000200, 9 | SDL_INIT_NOPARACHUTE => 0x00100000, 10 | SDL_INIT_EVENTTHREAD => 0x01000000, 11 | SDL_INIT_EVERYTHING => 0x0000FFFF, 12 | ); # SDL/init 13 | 14 | enum SDL::Constants::Defaults is export ( 15 | SDL_LIL_ENDIAN => 1234, 16 | SDL_BIG_ENDIAN => 4321, 17 | #~ SDL_BYTEORDER => $Config{byteorder} 18 | ); # SDL/defaults 19 | 20 | enum SDL::Constants::AudioFormat is export ( 21 | AUDIO_U8 => 0x0008, 22 | AUDIO_S8 => 0x8008, 23 | AUDIO_U16LSB => 0x0010, 24 | AUDIO_S16LSB => 0x8010, 25 | AUDIO_U16MSB => 0x1010, 26 | AUDIO_S16MSB => 0x9010, 27 | AUDIO_U16 => 0x0010, 28 | AUDIO_S16 => 0x8010, 29 | #~ AUDIO_U16SYS => ( $Config{byteorder} == 1234 ? 0x0010 : 0x1010 ), 30 | #~ AUDIO_S16SYS => ( $Config{byteorder} == 1234 ? 0x8010 : 0x9010 ), 31 | ); # SDL::Audio/format 32 | 33 | enum SDL::Constants::AudioStatus is export ( 34 | SDL_AUDIO_STOPPED => 0, 35 | SDL_AUDIO_PLAYING => 1, 36 | SDL_AUDIO_PAUSED => 2, 37 | ); # SDL::Audio/status 38 | 39 | enum SDL::Constants::CDROMDefaults is export ( 40 | CD_FPS => 75, 41 | SDL_MAX_TRACKS => 99, 42 | ); # SDL::CDROM/defaults 43 | 44 | enum SDL::Constants::CDROMStatus is export ( 45 | CD_TRAYEMPTY => 0, 46 | CD_STOPPED => 1, 47 | CD_PLAYING => 2, 48 | CD_PAUSED => 3, 49 | CD_ERROR => -1, 50 | ); # SDL::CDROM/status 51 | 52 | enum SDL::Constants::CDROMTrackType is export ( 53 | SDL_AUDIO_TRACK => 0, 54 | SDL_DATA_TRACK => 4, 55 | ); # SDL::CDROM/track_type 56 | 57 | enum SDL::Constants::EventType is export ( 58 | SDL_ACTIVEEVENT => 1, 59 | SDL_KEYDOWN => 2, 60 | SDL_KEYUP => 3, 61 | SDL_MOUSEMOTION => 4, 62 | SDL_MOUSEBUTTONDOWN => 5, 63 | SDL_MOUSEBUTTONUP => 6, 64 | SDL_JOYAXISMOTION => 7, 65 | SDL_JOYBALLMOTION => 8, 66 | SDL_JOYHATMOTION => 9, 67 | SDL_JOYBUTTONDOWN => 10, 68 | SDL_JOYBUTTONUP => 11, 69 | SDL_QUIT => 12, 70 | SDL_SYSWMEVENT => 13, 71 | SDL_VIDEORESIZE => 16, 72 | SDL_VIDEOEXPOSE => 17, 73 | SDL_USEREVENT => 24, 74 | SDL_NUMEVENTS => 32, 75 | ); # SDL::Event/type 76 | 77 | sub SDL_EVENTMASK($e) { return 1 +< $e; } 78 | 79 | enum SDL::Constants::EventMask is export ( 80 | SDL_ACTIVEEVENTMASK => SDL_EVENTMASK(SDL_ACTIVEEVENT), 81 | SDL_KEYDOWNMASK => SDL_EVENTMASK(SDL_KEYDOWN), 82 | SDL_KEYUPMASK => SDL_EVENTMASK(SDL_KEYUP), 83 | SDL_KEYEVENTMASK => SDL_EVENTMASK(SDL_KEYDOWN) 84 | +| SDL_EVENTMASK(SDL_KEYUP), 85 | SDL_MOUSEMOTIONMASK => SDL_EVENTMASK(SDL_MOUSEMOTION), 86 | SDL_MOUSEBUTTONDOWNMASK => SDL_EVENTMASK(SDL_MOUSEBUTTONDOWN), 87 | SDL_MOUSEBUTTONUPMASK => SDL_EVENTMASK(SDL_MOUSEBUTTONUP), 88 | SDL_MOUSEEVENTMASK => SDL_EVENTMASK(SDL_MOUSEMOTION) 89 | +| SDL_EVENTMASK(SDL_MOUSEBUTTONDOWN) 90 | +| SDL_EVENTMASK(SDL_MOUSEBUTTONUP), 91 | SDL_JOYAXISMOTIONMASK => SDL_EVENTMASK(SDL_JOYAXISMOTION), 92 | SDL_JOYBALLMOTIONMASK => SDL_EVENTMASK(SDL_JOYBALLMOTION), 93 | SDL_JOYHATMOTIONMASK => SDL_EVENTMASK(SDL_JOYHATMOTION), 94 | SDL_JOYBUTTONDOWNMASK => SDL_EVENTMASK(SDL_JOYBUTTONDOWN), 95 | SDL_JOYBUTTONUPMASK => SDL_EVENTMASK(SDL_JOYBUTTONUP), 96 | SDL_JOYEVENTMASK => SDL_EVENTMASK(SDL_JOYAXISMOTION) 97 | +| SDL_EVENTMASK(SDL_JOYBALLMOTION) 98 | +| SDL_EVENTMASK(SDL_JOYHATMOTION) 99 | +| SDL_EVENTMASK(SDL_JOYBUTTONDOWN) 100 | +| SDL_EVENTMASK(SDL_JOYBUTTONUP), 101 | SDL_VIDEORESIZEMASK => SDL_EVENTMASK(SDL_VIDEORESIZE), 102 | SDL_VIDEOEXPOSEMASK => SDL_EVENTMASK(SDL_VIDEOEXPOSE), 103 | SDL_QUITMASK => SDL_EVENTMASK(SDL_QUIT), 104 | SDL_SYSWMEVENTMASK => SDL_EVENTMASK(SDL_SYSWMEVENT), 105 | SDL_ALLEVENTS => 0xFFFFFFFF, 106 | ); 107 | 108 | enum SDL::Constants::EventAction is export ( 109 | SDL_ADDEVENT => 0, 110 | SDL_PEEKEVENT => 1, 111 | SDL_GETEVENT => 2, 112 | ); # SDL::Events/action 113 | 114 | enum SDL::Constants::EventState is export ( 115 | SDL_QUERY => -1, 116 | SDL_IGNORE => 0, 117 | SDL_DISABLE => 0, 118 | SDL_ENABLE => 1, 119 | SDL_RELEASED => 0, 120 | SDL_PRESSED => 1, 121 | ); # SDL::Events/state 122 | 123 | enum SDL::Constants::EventHat is export ( 124 | SDL_HAT_CENTERED => 0x00, 125 | SDL_HAT_UP => 0x01, 126 | SDL_HAT_RIGHT => 0x02, 127 | SDL_HAT_DOWN => 0x04, 128 | SDL_HAT_LEFT => 0x08, 129 | SDL_HAT_RIGHTUP => 0x02 +| 0x01, 130 | SDL_HAT_RIGHTDOWN => 0x02 +| 0x04, 131 | SDL_HAT_LEFTUP => 0x08 +| 0x01, 132 | SDL_HAT_LEFTDOWN => 0x08 +| 0x04, 133 | ); # SDL::Events/hat 134 | 135 | enum SDL::Constants::EventApp is export ( 136 | SDL_APPMOUSEFOCUS => 0x01, 137 | SDL_APPINPUTFOCUS => 0x02, 138 | SDL_APPACTIVE => 0x04, 139 | ); # SDL::Events/app 140 | 141 | sub SDL_BUTTON($b) { return (1 +< ($b - 1)); } 142 | 143 | enum SDL::Constants::EventButton is export ( 144 | SDL_BUTTON_LEFT => 1, 145 | SDL_BUTTON_MIDDLE => 2, 146 | SDL_BUTTON_RIGHT => 3, 147 | SDL_BUTTON_WHEELUP => 4, 148 | SDL_BUTTON_WHEELDOWN => 5, 149 | SDL_BUTTON_X1 => 6, 150 | SDL_BUTTON_X2 => 7, 151 | SDL_BUTTON_LMASK => SDL_BUTTON(1), 152 | SDL_BUTTON_MMASK => SDL_BUTTON(2), 153 | SDL_BUTTON_RMASK => SDL_BUTTON(3), 154 | SDL_BUTTON_X1MASK => SDL_BUTTON(6), 155 | SDL_BUTTON_X2MASK => SDL_BUTTON(7), 156 | ); # SDL::Events/button 157 | 158 | enum SDL::Constants::EventKeysym is export ( 159 | SDLK_UNKNOWN => 0, 160 | SDLK_FIRST => 0, 161 | SDLK_BACKSPACE => 8, 162 | SDLK_TAB => 9, 163 | SDLK_CLEAR => 12, 164 | SDLK_RETURN => 13, 165 | SDLK_PAUSE => 19, 166 | SDLK_ESCAPE => 27, 167 | SDLK_SPACE => 32, 168 | SDLK_EXCLAIM => 33, 169 | SDLK_QUOTEDBL => 34, 170 | SDLK_HASH => 35, 171 | SDLK_DOLLAR => 36, 172 | SDLK_AMPERSAND => 38, 173 | SDLK_QUOTE => 39, 174 | SDLK_LEFTPAREN => 40, 175 | SDLK_RIGHTPAREN => 41, 176 | SDLK_ASTERISK => 42, 177 | SDLK_PLUS => 43, 178 | SDLK_COMMA => 44, 179 | SDLK_MINUS => 45, 180 | SDLK_PERIOD => 46, 181 | SDLK_SLASH => 47, 182 | SDLK_0 => 48, 183 | SDLK_1 => 49, 184 | SDLK_2 => 50, 185 | SDLK_3 => 51, 186 | SDLK_4 => 52, 187 | SDLK_5 => 53, 188 | SDLK_6 => 54, 189 | SDLK_7 => 55, 190 | SDLK_8 => 56, 191 | SDLK_9 => 57, 192 | SDLK_COLON => 58, 193 | SDLK_SEMICOLON => 59, 194 | SDLK_LESS => 60, 195 | SDLK_EQUALS => 61, 196 | SDLK_GREATER => 62, 197 | SDLK_QUESTION => 63, 198 | SDLK_AT => 64, 199 | SDLK_LEFTBRACKET => 91, 200 | SDLK_BACKSLASH => 92, 201 | SDLK_RIGHTBRACKET => 93, 202 | SDLK_CARET => 94, 203 | SDLK_UNDERSCORE => 95, 204 | SDLK_BACKQUOTE => 96, 205 | SDLK_a => 97, 206 | SDLK_b => 98, 207 | SDLK_c => 99, 208 | SDLK_d => 100, 209 | SDLK_e => 101, 210 | SDLK_f => 102, 211 | SDLK_g => 103, 212 | SDLK_h => 104, 213 | SDLK_i => 105, 214 | SDLK_j => 106, 215 | SDLK_k => 107, 216 | SDLK_l => 108, 217 | SDLK_m => 109, 218 | SDLK_n => 110, 219 | SDLK_o => 111, 220 | SDLK_p => 112, 221 | SDLK_q => 113, 222 | SDLK_r => 114, 223 | SDLK_s => 115, 224 | SDLK_t => 116, 225 | SDLK_u => 117, 226 | SDLK_v => 118, 227 | SDLK_w => 119, 228 | SDLK_x => 120, 229 | SDLK_y => 121, 230 | SDLK_z => 122, 231 | SDLK_DELETE => 127, 232 | SDLK_WORLD_0 => 160, 233 | SDLK_WORLD_1 => 161, 234 | SDLK_WORLD_2 => 162, 235 | SDLK_WORLD_3 => 163, 236 | SDLK_WORLD_4 => 164, 237 | SDLK_WORLD_5 => 165, 238 | SDLK_WORLD_6 => 166, 239 | SDLK_WORLD_7 => 167, 240 | SDLK_WORLD_8 => 168, 241 | SDLK_WORLD_9 => 169, 242 | SDLK_WORLD_10 => 170, 243 | SDLK_WORLD_11 => 171, 244 | SDLK_WORLD_12 => 172, 245 | SDLK_WORLD_13 => 173, 246 | SDLK_WORLD_14 => 174, 247 | SDLK_WORLD_15 => 175, 248 | SDLK_WORLD_16 => 176, 249 | SDLK_WORLD_17 => 177, 250 | SDLK_WORLD_18 => 178, 251 | SDLK_WORLD_19 => 179, 252 | SDLK_WORLD_20 => 180, 253 | SDLK_WORLD_21 => 181, 254 | SDLK_WORLD_22 => 182, 255 | SDLK_WORLD_23 => 183, 256 | SDLK_WORLD_24 => 184, 257 | SDLK_WORLD_25 => 185, 258 | SDLK_WORLD_26 => 186, 259 | SDLK_WORLD_27 => 187, 260 | SDLK_WORLD_28 => 188, 261 | SDLK_WORLD_29 => 189, 262 | SDLK_WORLD_30 => 190, 263 | SDLK_WORLD_31 => 191, 264 | SDLK_WORLD_32 => 192, 265 | SDLK_WORLD_33 => 193, 266 | SDLK_WORLD_34 => 194, 267 | SDLK_WORLD_35 => 195, 268 | SDLK_WORLD_36 => 196, 269 | SDLK_WORLD_37 => 197, 270 | SDLK_WORLD_38 => 198, 271 | SDLK_WORLD_39 => 199, 272 | SDLK_WORLD_40 => 200, 273 | SDLK_WORLD_41 => 201, 274 | SDLK_WORLD_42 => 202, 275 | SDLK_WORLD_43 => 203, 276 | SDLK_WORLD_44 => 204, 277 | SDLK_WORLD_45 => 205, 278 | SDLK_WORLD_46 => 206, 279 | SDLK_WORLD_47 => 207, 280 | SDLK_WORLD_48 => 208, 281 | SDLK_WORLD_49 => 209, 282 | SDLK_WORLD_50 => 210, 283 | SDLK_WORLD_51 => 211, 284 | SDLK_WORLD_52 => 212, 285 | SDLK_WORLD_53 => 213, 286 | SDLK_WORLD_54 => 214, 287 | SDLK_WORLD_55 => 215, 288 | SDLK_WORLD_56 => 216, 289 | SDLK_WORLD_57 => 217, 290 | SDLK_WORLD_58 => 218, 291 | SDLK_WORLD_59 => 219, 292 | SDLK_WORLD_60 => 220, 293 | SDLK_WORLD_61 => 221, 294 | SDLK_WORLD_62 => 222, 295 | SDLK_WORLD_63 => 223, 296 | SDLK_WORLD_64 => 224, 297 | SDLK_WORLD_65 => 225, 298 | SDLK_WORLD_66 => 226, 299 | SDLK_WORLD_67 => 227, 300 | SDLK_WORLD_68 => 228, 301 | SDLK_WORLD_69 => 229, 302 | SDLK_WORLD_70 => 230, 303 | SDLK_WORLD_71 => 231, 304 | SDLK_WORLD_72 => 232, 305 | SDLK_WORLD_73 => 233, 306 | SDLK_WORLD_74 => 234, 307 | SDLK_WORLD_75 => 235, 308 | SDLK_WORLD_76 => 236, 309 | SDLK_WORLD_77 => 237, 310 | SDLK_WORLD_78 => 238, 311 | SDLK_WORLD_79 => 239, 312 | SDLK_WORLD_80 => 240, 313 | SDLK_WORLD_81 => 241, 314 | SDLK_WORLD_82 => 242, 315 | SDLK_WORLD_83 => 243, 316 | SDLK_WORLD_84 => 244, 317 | SDLK_WORLD_85 => 245, 318 | SDLK_WORLD_86 => 246, 319 | SDLK_WORLD_87 => 247, 320 | SDLK_WORLD_88 => 248, 321 | SDLK_WORLD_89 => 249, 322 | SDLK_WORLD_90 => 250, 323 | SDLK_WORLD_91 => 251, 324 | SDLK_WORLD_92 => 252, 325 | SDLK_WORLD_93 => 253, 326 | SDLK_WORLD_94 => 254, 327 | SDLK_WORLD_95 => 255, 328 | SDLK_KP0 => 256, 329 | SDLK_KP1 => 257, 330 | SDLK_KP2 => 258, 331 | SDLK_KP3 => 259, 332 | SDLK_KP4 => 260, 333 | SDLK_KP5 => 261, 334 | SDLK_KP6 => 262, 335 | SDLK_KP7 => 263, 336 | SDLK_KP8 => 264, 337 | SDLK_KP9 => 265, 338 | SDLK_KP_PERIOD => 266, 339 | SDLK_KP_DIVIDE => 267, 340 | SDLK_KP_MULTIPLY => 268, 341 | SDLK_KP_MINUS => 269, 342 | SDLK_KP_PLUS => 270, 343 | SDLK_KP_ENTER => 271, 344 | SDLK_KP_EQUALS => 272, 345 | SDLK_UP => 273, 346 | SDLK_DOWN => 274, 347 | SDLK_RIGHT => 275, 348 | SDLK_LEFT => 276, 349 | SDLK_INSERT => 277, 350 | SDLK_HOME => 278, 351 | SDLK_END => 279, 352 | SDLK_PAGEUP => 280, 353 | SDLK_PAGEDOWN => 281, 354 | SDLK_F1 => 282, 355 | SDLK_F2 => 283, 356 | SDLK_F3 => 284, 357 | SDLK_F4 => 285, 358 | SDLK_F5 => 286, 359 | SDLK_F6 => 287, 360 | SDLK_F7 => 288, 361 | SDLK_F8 => 289, 362 | SDLK_F9 => 290, 363 | SDLK_F10 => 291, 364 | SDLK_F11 => 292, 365 | SDLK_F12 => 293, 366 | SDLK_F13 => 294, 367 | SDLK_F14 => 295, 368 | SDLK_F15 => 296, 369 | SDLK_NUMLOCK => 300, 370 | SDLK_CAPSLOCK => 301, 371 | SDLK_SCROLLOCK => 302, 372 | SDLK_RSHIFT => 303, 373 | SDLK_LSHIFT => 304, 374 | SDLK_RCTRL => 305, 375 | SDLK_LCTRL => 306, 376 | SDLK_RALT => 307, 377 | SDLK_LALT => 308, 378 | SDLK_RMETA => 309, 379 | SDLK_LMETA => 310, 380 | SDLK_LSUPER => 311, 381 | SDLK_RSUPER => 312, 382 | SDLK_MODE => 313, 383 | SDLK_COMPOSE => 314, 384 | SDLK_HELP => 315, 385 | SDLK_PRINT => 316, 386 | SDLK_SYSREQ => 317, 387 | SDLK_BREAK => 318, 388 | SDLK_MENU => 319, 389 | SDLK_POWER => 320, 390 | SDLK_EURO => 321, 391 | SDLK_UNDO => 322, 392 | ); # SDL::Events/keysym 393 | 394 | enum SDL::Constants::EventKeymod is export ( 395 | KMOD_NONE => 0x0000, 396 | KMOD_LSHIFT => 0x0001, 397 | KMOD_RSHIFT => 0x0002, 398 | KMOD_LCTRL => 0x0040, 399 | KMOD_RCTRL => 0x0080, 400 | KMOD_LALT => 0x0100, 401 | KMOD_RALT => 0x0200, 402 | KMOD_LMETA => 0x0400, 403 | KMOD_RMETA => 0x0800, 404 | KMOD_NUM => 0x1000, 405 | KMOD_CAPS => 0x2000, 406 | KMOD_MODE => 0x4000, 407 | KMOD_RESERVED => 0x8000, 408 | KMOD_CTRL => 0x0040 +| 0x0080, 409 | KMOD_SHIFT => 0x0001 +| 0x0002, 410 | KMOD_ALT => 0x0100 +| 0x0200, 411 | KMOD_META => 0x0400 +| 0x0800, 412 | ); # SDL::Events/keymod 413 | 414 | enum SDL::Constants::GFXSmoothing is export ( 415 | SMOOTHING_OFF => 0, 416 | SMOOTHING_ON => 1, 417 | ); # SDL::GFX/smoothing 418 | 419 | enum SDL::Constants::ImageInit is export ( 420 | IMG_INIT_JPG => 0x00000001, 421 | IMG_INIT_PNG => 0x00000002, 422 | IMG_INIT_TIF => 0x00000004, 423 | ); # SDL::Image 424 | 425 | enum SDL::Constants::MixerInit is export ( 426 | MIX_INIT_FLAC => 0x00000001, 427 | MIX_INIT_MOD => 0x00000002, 428 | MIX_INIT_MP3 => 0x00000004, 429 | MIX_INIT_OGG => 0x00000008, 430 | ); # SDL::Mixer/init 431 | 432 | enum SDL::Constants::MixerDefaults is export ( 433 | MIX_CHANNELS => 8, 434 | MIX_DEFAULT_FORMAT => 32784, 435 | MIX_DEFAULT_FREQUENCY => 22050, 436 | MIX_DEFAULT_CHANNELS => 2, 437 | MIX_MAX_VOLUME => 128, 438 | MIX_CHANNEL_POST => -2, 439 | ); # SDL::Mixer/defaults 440 | 441 | enum SDL::Constants::MixerFading is export ( 442 | MIX_NO_FADING => 0, 443 | MIX_FADING_OUT => 1, 444 | MIX_FADING_IN => 2, 445 | ); # SDL::Mixer/fading 446 | 447 | enum SDL::Constants::MixerType is export ( 448 | MUS_NONE => 0, 449 | MUS_CMD => 1, 450 | MUS_WAV => 2, 451 | MUS_MOD => 3, 452 | MUS_MID => 4, 453 | MUS_OGG => 5, 454 | MUS_MP3 => 6, 455 | MUS_MP3_MAD => 7, 456 | MUS_MP3_FLAC => 8, 457 | ); # SDL::Mixer/type 458 | 459 | enum SDL::Constants::Net is export ( 460 | INADDR_ANY => 0x00000000, 461 | INADDR_NONE => 0xFFFFFFFF, 462 | INADDR_BROADCAST => 0xFFFFFFFF, 463 | SDLNET_MAX_UDPCHANNELS => 32, 464 | SDLNET_MAX_UDPADDRESSES => 4, 465 | ); # SDL::Net 466 | 467 | enum SDL::Constants::PangoDirection is export ( 468 | SDLPANGO_DIRECTION_LTR => 0, 469 | SDLPANGO_DIRECTION_RTL => 1, 470 | SDLPANGO_DIRECTION_WEAK_LTR => 2, 471 | SDLPANGO_DIRECTION_WEAK_RTL => 3, 472 | SDLPANGO_DIRECTION_NEUTRAL => 4, 473 | ); # SDL::Pango/direction 474 | 475 | enum SDL::Constants::PangoAlign is export ( 476 | SDLPANGO_ALIGN_LEFT => 0, 477 | SDLPANGO_ALIGN_CENTER => 1, 478 | SDLPANGO_ALIGN_RIGHT => 2, 479 | ); # SDL::Pango/align 480 | 481 | enum SDL::Constants::RWOps is export ( 482 | RW_SEEK_SET => 0, 483 | RW_SEEK_CUR => 1, 484 | RW_SEEK_END => 2, 485 | ); # SDL::RWOps/defaults 486 | 487 | enum SDL::Constants::TTF is export ( 488 | TTF_HINTING_NORMAL => 0, 489 | TTF_HINTING_LIGHT => 1, 490 | TTF_HINTING_MONO => 2, 491 | TTF_HINTING_NONE => 3, 492 | TTF_STYLE_NORMAL => 0, 493 | TTF_STYLE_BOLD => 1, 494 | TTF_STYLE_ITALIC => 2, 495 | TTF_STYLE_UNDERLINE => 4, 496 | TTF_STYLE_STRIKETHROUGH => 8, 497 | ); # SDL::TTF 498 | 499 | enum SDL::Constants::Video is export ( 500 | SDL_ALPHA_OPAQUE => 255, 501 | SDL_ALPHA_TRANSPARENT => 0, 502 | 503 | SDL_SWSURFACE => 0x00000000, # for SDL::Surface->new() and set_video_mode() 504 | SDL_HWSURFACE => 0x00000001, # for SDL::Surface->new() and set_video_mode() 505 | SDL_ASYNCBLIT => 0x00000004, # for SDL::Surface->new() and set_video_mode() 506 | SDL_ANYFORMAT => 0x10000000, # set_video_mode() 507 | SDL_HWPALETTE => 0x20000000, # set_video_mode() 508 | SDL_DOUBLEBUF => 0x40000000, # set_video_mode() 509 | SDL_FULLSCREEN => 0x80000000, # set_video_mode() 510 | SDL_OPENGL => 0x00000002, # set_video_mode() 511 | SDL_OPENGLBLIT => 0x0000000A, # set_video_mode() 512 | SDL_RESIZABLE => 0x00000010, # set_video_mode() 513 | SDL_NOFRAME => 0x00000020, # set_video_mode() 514 | SDL_HWACCEL => 0x00000100, # set_video_mode() 515 | SDL_SRCCOLORKEY => 0x00001000, # set_video_mode() 516 | SDL_RLEACCELOK => 0x00002000, # set_video_mode() 517 | SDL_RLEACCEL => 0x00004000, # set_video_mode() 518 | SDL_SRCALPHA => 0x00010000, # set_video_mode() 519 | SDL_PREALLOC => 0x01000000, # set_video_mode() 520 | 521 | SDL_YV12_OVERLAY => 0x32315659, # Planar mode: Y + V + U (3 planes) 522 | SDL_IYUV_OVERLAY => 0x56555949, # Planar mode: Y + U + V (3 planes) 523 | SDL_YUY2_OVERLAY => 0x32595559, # Packed mode: Y0+U0+Y1+V0 (1 plane) 524 | SDL_UYVY_OVERLAY => 0x59565955, # Packed mode: U0+Y0+V0+Y1 (1 plane) 525 | SDL_YVYU_OVERLAY => 0x55595659, # Packed mode: Y0+V0+Y1+U0 (1 plane) 526 | 527 | SDL_LOGPAL => 0x01, # for set_palette() 528 | SDL_PHYSPAL => 0x02, # for set_palette() 529 | 530 | SDL_GRAB_QUERY => -1, # SDL_GrabMode 531 | SDL_GRAB_OFF => 0, # SDL_GrabMode 532 | SDL_GRAB_ON => 1, # SDL_GrabMode 533 | SDL_GRAB_FULLSCREEN => 2, # SDL_GrabMode, used internally 534 | ); # SDL::Video/... 535 | 536 | enum SDL::Constants::VideoGL is export ( 537 | SDL_GL_RED_SIZE => 0, 538 | SDL_GL_GREEN_SIZE => 1, 539 | SDL_GL_BLUE_SIZE => 2, 540 | SDL_GL_ALPHA_SIZE => 3, 541 | SDL_GL_BUFFER_SIZE => 4, 542 | SDL_GL_DOUBLEBUFFER => 5, 543 | SDL_GL_DEPTH_SIZE => 6, 544 | SDL_GL_STENCIL_SIZE => 7, 545 | SDL_GL_ACCUM_RED_SIZE => 8, 546 | SDL_GL_ACCUM_GREEN_SIZE => 9, 547 | SDL_GL_ACCUM_BLUE_SIZE => 10, 548 | SDL_GL_ACCUM_ALPHA_SIZE => 11, 549 | SDL_GL_STEREO => 12, 550 | SDL_GL_MULTISAMPLEBUFFERS => 13, 551 | SDL_GL_MULTISAMPLESAMPLES => 14, 552 | SDL_GL_ACCELERATED_VISUAL => 15, 553 | SDL_GL_SWAP_CONTROL => 16, 554 | ); # SDL::Video/gl 555 | -------------------------------------------------------------------------------- /lib/SDL/Functions.pm6: -------------------------------------------------------------------------------- 1 | unit module SDL::Functions; 2 | 3 | use NativeCall; 4 | use SDL::Structures; 5 | 6 | # general 7 | sub SDL_Init(int32) returns int32 is native is export { * } 8 | sub SDL_InitSubSystem(int32) returns int32 is native is export { * } 9 | sub SDL_QuitSubSystem(int32) is native is export { * } 10 | sub SDL_WasInit(int32) returns int32 is native is export { * } 11 | sub SDL_GetError() returns Str is native is export { * } 12 | sub SDL_Linked_Version() returns SDL_version is native is export { * } 13 | sub SDL_RWFromFile(Str, Str) returns Pointer is native is export { * } 14 | sub SDL_RWFromConstMem( Pointer, int32 ) returns Pointer is native is export { * } 15 | 16 | # Video 17 | #| SDL_GetVideoSurface -- returns a pointer to the current display surface 18 | #| SDL_GetVideoInfo -- returns a pointer to information about the video hardware 19 | sub SDL_GetVideoInfo() returns SDL_VideoInfo is native { * } 20 | #| SDL_VideoDriverName -- Obtain the name of the video driver 21 | #| SDL_ListModes -- Returns a pointer to an array of available screen dimensions for the given format and video flags 22 | #| SDL_VideoModeOK -- Check to see if a particular video mode is supported. 23 | #| SDL_SetVideoMode -- Set up a video mode with the specified width, height and bits-per-pixel. 24 | sub SDL_SetVideoMode(int32, int32, int32, int32) returns SDL_Surface is native is export { * } 25 | #| SDL_UpdateRect -- Makes sure the given area is updated on the given screen. 26 | sub SDL_UpdateRect(SDL_Surface, int32, int32, int32, int32) is native is export { * } 27 | #| SDL_UpdateRects -- Makes sure the given list of rectangles is updated on the given screen. 28 | #| SDL_Flip -- Swaps screen buffers 29 | sub SDL_Flip(SDL_Surface) returns int32 is native is export { * } 30 | #| SDL_SetColors -- Sets a portion of the colormap for the given 8-bit surface. 31 | #| SDL_SetPalette -- Sets the colors in the palette of an 8-bit surface. 32 | #| SDL_SetGamma -- Sets the color gamma function for the display 33 | #| SDL_GetGammaRamp -- Gets the color gamma lookup tables for the display 34 | #| SDL_SetGammaRamp -- Sets the color gamma lookup tables for the display 35 | #| SDL_MapRGB -- Map a RGB color value to a pixel format. 36 | sub SDL_MapRGB(SDL_PixelFormat, uint8, uint8, uint8) returns uint32 is native is export { * } 37 | #| SDL_MapRGBA -- Map a RGBA color value to a pixel format. 38 | #| SDL_GetRGB -- Get RGB values from a pixel in the specified pixel format. 39 | #| SDL_GetRGBA -- Get RGBA values from a pixel in the specified pixel format. 40 | #| SDL_CreateRGBSurface -- Create an empty SDL_Surface 41 | sub SDL_CreateRGBSurface(uint32 $flags, int32 $width, int32 $height, int32 $depth, uint32 $Rmask, uint32 $Gmask, uint32 $Bmask, uint32 $Amask) returns SDL_Surface is native is export { * } 42 | #| SDL_CreateRGBSurfaceFrom -- Create an SDL_Surface from pixel data 43 | #| SDL_FreeSurface -- Frees (deletes) a SDL_Surface 44 | #| SDL_LockSurface -- Lock a surface for directly access. 45 | #| SDL_UnlockSurface -- Unlocks a previously locked surface. 46 | #| SDL_LoadBMP -- Load a Windows BMP file into an SDL_Surface. 47 | #| SDL_SaveBMP -- Save an SDL_Surface as a Windows BMP file. 48 | #| SDL_SetColorKey -- Sets the color key (transparent pixel) in a blittable surface and RLE acceleration. 49 | #| SDL_SetAlpha -- Adjust the alpha properties of a surface 50 | sub SDL_SetAlpha(SDL_Surface, uint32 $flag, uint8 $alpha) returns int32 is native is export { * } 51 | #| SDL_SetClipRect -- Sets the clipping rectangle for a surface. 52 | #| SDL_GetClipRect -- Gets the clipping rectangle for a surface. 53 | sub SDL_GetClipRect( Pointer, CArray[int32] ) is native is export { * } 54 | #| SDL_ConvertSurface -- Converts a surface to the same format as another surface. 55 | sub SDL_ConvertSurface(SDL_Surface, SDL_PixelFormat, uint32 $flags) returns SDL_Surface is native is export { * } 56 | #| SDL_BlitSurface -- This performs a fast blit from the source surface to the destination surface. 57 | sub SDL_BlitSurface(SDL_Surface, SDL_Rect, SDL_Surface, SDL_Rect) returns int32 is native is export is symbol { * } 58 | #| SDL_FillRect -- This function performs a fast fill of the given rectangle with some color 59 | sub SDL_FillRect(SDL_Surface, SDL_Rect, int32) returns int32 is native is export { * } 60 | #| SDL_DisplayFormat -- Convert a surface to the display format 61 | #| SDL_DisplayFormatAlpha -- Convert a surface to the display format 62 | #| SDL_WarpMouse -- Set the position of the mouse cursor. 63 | #| SDL_CreateCursor -- Creates a new mouse cursor. 64 | #| SDL_FreeCursor -- Frees a cursor created with SDL_CreateCursor. 65 | #| SDL_SetCursor -- Set the currently active mouse cursor. 66 | #| SDL_GetCursor -- Get the currently active mouse cursor. 67 | #| SDL_ShowCursor -- Toggle whether or not the cursor is shown on the screen. 68 | #| SDL_GL_LoadLibrary -- Specify an OpenGL library 69 | #| SDL_GL_GetProcAddress -- Get the address of a GL function 70 | #| SDL_GL_GetAttribute -- Get the value of a special SDL/OpenGL attribute 71 | #| SDL_GL_SetAttribute -- Set a special SDL/OpenGL attribute 72 | #| SDL_GL_SwapBuffers -- Swap OpenGL framebuffers/Update Display 73 | #| SDL_CreateYUVOverlay -- Create a YUV video overlay 74 | #| SDL_LockYUVOverlay -- Lock an overlay 75 | #| SDL_UnlockYUVOverlay -- Unlock an overlay 76 | #| SDL_DisplayYUVOverlay -- Blit the overlay to the display 77 | #| SDL_FreeYUVOverlay -- Free a YUV video overlay 78 | 79 | #| SDL_GLattr -- SDL GL Attributes 80 | #| SDL_Rect -- Defines a rectangular area 81 | #| SDL_Color -- Format independent color description 82 | #| SDL_Palette -- Color palette for 8-bit pixel formats 83 | #| SDL_PixelFormat -- Stores surface format information 84 | #| SDL_Surface -- Graphical Surface Structure 85 | #| SDL_VideoInfo -- Video Target information 86 | #| SDL_Overlay -- YUV video overlay 87 | 88 | # Window Management 89 | #| SDL_WM_SetCaption -- Sets the window tile and icon name. 90 | #| SDL_WM_GetCaption -- Gets the window title and icon name. 91 | #| SDL_WM_SetIcon -- Sets the icon for the display window. 92 | #| SDL_WM_IconifyWindow -- Iconify/Minimise the window 93 | #| SDL_WM_ToggleFullScreen -- Toggles fullscreen mode 94 | #| SDL_WM_GrabInput -- Grabs mouse and keyboard input. 95 | 96 | # Events 97 | #| SDL_PumpEvents -- Pumps the event loop, gathering events from the input devices. 98 | sub SDL_PumpEvents() returns int32 is native is export { * } 99 | #| SDL_PeepEvents -- Checks the event queue for messages and optionally returns them. 100 | #| SDL_PollEvent -- Polls for currently pending events. 101 | sub SDL_PollEvent(SDL_Event is rw) returns int32 is native is export { * } 102 | #| SDL_WaitEvent -- Waits indefinitely for the next available event. 103 | #| SDL_PushEvent -- Pushes an event onto the event queue 104 | #| SDL_SetEventFilter -- Sets up a filter to process all events before they are posted to the event queue. 105 | #| SDL_GetEventFilter -- Retrieves a pointer to he event filter 106 | #| SDL_EventState -- This function allows you to set the state of processing certain events. 107 | #| SDL_GetKeyState -- Get a snapshot of the current keyboard state 108 | #| SDL_GetModState -- Get the state of modifier keys. 109 | #| SDL_SetModState -- Set the current key modifier state 110 | #| SDL_GetKeyName -- Get the name of an SDL virtual keysym 111 | #| SDL_EnableUNICODE -- Enable UNICODE translation 112 | #| SDL_EnableKeyRepeat -- Set keyboard repeat rate. 113 | #| SDL_GetMouseState -- Retrieve the current state of the mouse 114 | sub SDL_GetMouseState(int32 $x is rw, int32 $y is rw) returns uint8 is native is export { * } 115 | 116 | #| SDL_GetRelativeMouseState -- Retrieve the current state of the mouse 117 | #| SDL_GetAppState -- Get the state of the application 118 | #| SDL_JoystickEventState -- Enable/disable joystick event polling 119 | 120 | # Joystick 121 | #~ SDL_NumJoysticks -- Count available joysticks. 122 | #~ SDL_JoystickName -- Get joystick name. 123 | #~ SDL_JoystickOpen -- Opens a joystick for use. 124 | #~ SDL_JoystickOpened -- Determine if a joystick has been opened 125 | #~ SDL_JoystickIndex -- Get the index of an SDL_Joystick. 126 | #~ SDL_JoystickNumAxes -- Get the number of joystick axes 127 | #~ SDL_JoystickNumBalls -- Get the number of joystick trackballs 128 | #~ SDL_JoystickNumHats -- Get the number of joystick hats 129 | #~ SDL_JoystickNumButtons -- Get the number of joysitck buttons 130 | #~ SDL_JoystickUpdate -- Updates the state of all joysticks 131 | #~ SDL_JoystickGetAxis -- Get the current state of an axis 132 | #~ SDL_JoystickGetHat -- Get the current state of a joystick hat 133 | #~ SDL_JoystickGetButton -- Get the current state of a given button on a given joystick 134 | #~ SDL_JoystickGetBall -- Get relative trackball motion 135 | #~ SDL_JoystickClose -- Closes a previously opened joystick 136 | 137 | # Audio 138 | #~ SDL_AudioSpec -- Audio Specification Structure 139 | #~ SDL_OpenAudio -- Opens the audio device with the desired parameters. 140 | #~ SDL_PauseAudio -- Pauses and unpauses the audio callback processing 141 | #~ SDL_GetAudioStatus -- Get the current audio state 142 | #~ SDL_LoadWAV -- Load a WAVE file 143 | #~ SDL_FreeWAV -- Frees previously opened WAV data 144 | #~ SDL_AudioCVT -- Audio Conversion Structure 145 | #~ SDL_BuildAudioCVT -- Initializes a SDL_AudioCVT structure for conversion 146 | #~ SDL_ConvertAudio -- Convert audio data to a desired audio format. 147 | #~ SDL_MixAudio -- Mix audio data 148 | #~ SDL_LockAudio -- Lock out the callback function 149 | #~ SDL_UnlockAudio -- Unlock the callback function 150 | #~ SDL_CloseAudio -- Shuts down audio processing and closes the audio device. 151 | 152 | # CDROM 153 | #~ SDL_CDNumDrives -- Returns the number of CD-ROM drives on the system. 154 | #~ SDL_CDName -- Returns a human-readable, system-dependent identifier for the CD-ROM. 155 | #~ SDL_CDOpen -- Opens a CD-ROM drive for access. 156 | #~ SDL_CDStatus -- Returns the current status of the given drive. 157 | #~ SDL_CDPlay -- Play a CD 158 | #~ SDL_CDPlayTracks -- Play the given CD track(s) 159 | #~ SDL_CDPause -- Pauses a CDROM 160 | #~ SDL_CDResume -- Resumes a CDROM 161 | #~ SDL_CDStop -- Stops a CDROM 162 | #~ SDL_CDEject -- Ejects a CDROM 163 | #~ SDL_CDClose -- Closes a SDL_CD handle 164 | #~ SDL_CD -- CDROM Drive Information 165 | #~ SDL_CDtrack -- CD Track Information Structure 166 | 167 | # Multi-threaded 168 | #~ SDL_CreateThread -- Creates a new thread of execution that shares its parent's properties. 169 | #~ SDL_ThreadID -- Get the 32-bit thread identifier for the current thread. 170 | #~ SDL_GetThreadID -- Get the SDL thread ID of a SDL_Thread 171 | #~ SDL_WaitThread -- Wait for a thread to finish. 172 | #~ SDL_KillThread -- Gracelessly terminates the thread. 173 | #~ SDL_CreateMutex -- Create a mutex 174 | #~ SDL_DestroyMutex -- Destroy a mutex 175 | #~ SDL_mutexP -- Lock a mutex 176 | #~ SDL_mutexV -- Unlock a mutex 177 | #~ SDL_CreateSemaphore -- Creates a new semaphore and assigns an initial value to it. 178 | #~ SDL_DestroySemaphore -- Destroys a semaphore that was created by SDL_CreateSemaphore. 179 | #~ SDL_SemWait -- Lock a semaphore and suspend the thread if the semaphore value is zero. 180 | #~ SDL_SemTryWait -- Attempt to lock a semaphore but don't suspend the thread. 181 | #~ SDL_SemWaitTimeout -- Lock a semaphore, but only wait up to a specified maximum time. 182 | #~ SDL_SemPost -- Unlock a semaphore. 183 | #~ SDL_SemValue -- Return the current value of a semaphore. 184 | #~ SDL_CreateCond -- Create a condition variable 185 | #~ SDL_DestroyCond -- Destroy a condition variable 186 | #~ SDL_CondSignal -- Restart a thread wait on a condition variable 187 | #~ SDL_CondBroadcast -- Restart all threads waiting on a condition variable 188 | #~ SDL_CondWait -- Wait on a condition variable 189 | #~ SDL_CondWaitTimeout -- Wait on a condition variable, with timeout 190 | 191 | # Timer 192 | #| SDL_GetTicks -- Get the number of milliseconds since the SDL library initialization. 193 | sub SDL_GetTicks() returns int32 is native is export { * } 194 | #| SDL_Delay -- Wait a specified number of milliseconds before returning. 195 | sub SDL_Delay(int32) is native is export { * } 196 | #| SDL_AddTimer -- Add a timer which will call a callback after the specified number of milliseconds has elapsed. 197 | #| SDL_RemoveTimer -- Remove a timer which was added with SDL_AddTimer. 198 | #| SDL_SetTimer -- Set a callback to run after the specified number of milliseconds has elapsed. 199 | 200 | # Image 201 | sub IMG_Init(int32) returns int32 is native is export { * } 202 | sub IMG_Load(Str) returns SDL_Surface is native is export { * } 203 | sub IMG_Load_RW(Pointer, int32) returns SDL_Surface is native is export { * } 204 | sub IMG_isBMP(Pointer) returns int32 is native is export { * } 205 | sub IMG_isCUR(Pointer) returns int32 is native is export { * } 206 | sub IMG_isICO(Pointer) returns int32 is native is export { * } 207 | sub IMG_isGIF(Pointer) returns int32 is native is export { * } 208 | sub IMG_isJPG(Pointer) returns int32 is native is export { * } 209 | sub IMG_isLBM(Pointer) returns int32 is native is export { * } 210 | sub IMG_isPCX(Pointer) returns int32 is native is export { * } 211 | sub IMG_isPNG(Pointer) returns int32 is native is export { * } 212 | sub IMG_isPNM(Pointer) returns int32 is native is export { * } 213 | sub IMG_isTIF(Pointer) returns int32 is native is export { * } 214 | sub IMG_isXCF(Pointer) returns int32 is native is export { * } 215 | sub IMG_isXPM(Pointer) returns int32 is native is export { * } 216 | sub IMG_isXV(Pointer) returns int32 is native is export { * } 217 | 218 | # Mixer General 219 | sub Mix_Linked_Version() returns SDL_version is native is export { * } 220 | #~ 4.1.2 Mix_Init Initialize SDL_mixer 221 | #~ 4.1.3 Mix_Quit Cleanup SDL_mixer 222 | sub Mix_OpenAudio(int32, int32, int32, int32) returns int32 is native is export { * } 223 | sub Mix_CloseAudio() returns int32 is native is export { * } 224 | #~ 4.1.6 Mix_SetError Set the current error string 225 | #~ 4.1.7 Mix_GetError Get the current error string 226 | #~ 4.1.8 Mix_QuerySpec Get output format 227 | 228 | # Mixer Samples 229 | #~ 4.2.1 Mix_GetNumChunkDecoders Number of sample format types that can be decoded 230 | #~ 4.2.2 Mix_GetChunkDecoder Name of enumerated sample format type decoder 231 | sub Mix_LoadWAV_RW(Pointer, int32) returns Mix_Chunk is native is export { * } 232 | sub Mix_LoadWAV(Str $file) returns Mix_Chunk is export { 233 | Mix_LoadWAV_RW(SDL_RWFromFile($file, "rb"), 1); 234 | } 235 | #~ 4.2.5 Mix_QuickLoad_WAV From memory, in output format already 236 | #~ 4.2.6 Mix_QuickLoad_RAW From memory, in output format already 237 | #~ 4.2.7 Mix_VolumeChunk Set mix volume 238 | #~ 4.2.8 Mix_FreeChunk Free sample 239 | 240 | # Mixer Channels 241 | sub Mix_AllocateChannels(int32) returns int32 is native is export { * } 242 | sub Mix_Volume(int32, int32) returns int32 is native is export { * } 243 | #~ 4.3.3 Mix_PlayChannel Play loop 244 | sub Mix_PlayChannelTimed(int32, Mix_Chunk, int32, int32) returns int32 is native is export { * } 245 | sub Mix_FadeInChannelTimed(int32, Mix_Chunk, int32, int32, int32) returns int32 is native is export { * } 246 | sub Mix_FadeInChannel(int32 $channel, Mix_Chunk $chunk, int32 $loops, int32 $ms) returns int32 is export { 247 | Mix_FadeInChannelTimed($channel, $chunk, $loops, $ms, -1); 248 | } 249 | sub Mix_Pause(int32) is native is export { * } 250 | sub Mix_Resume(int32) is native is export { * } 251 | sub Mix_HaltChannel(int32) returns int32 is native is export { * } 252 | sub Mix_ExpireChannel(int32, int32) returns int32 is native is export { * } 253 | sub Mix_FadeOutChannel(int32, int32) returns int32 is native is export { * } 254 | sub Mix_ChannelFinished(&callback (int32)) returns int32 is native is export { * } 255 | sub Mix_Playing(int32) returns int32 is native is export { * } 256 | sub Mix_Paused(int32) returns int32 is native is export { * } 257 | sub Mix_FadingChannel(int32) returns int32 is native is export { * } 258 | sub Mix_GetChunk(int32) returns Mix_Chunk is native is export { * } 259 | 260 | # Mixer Groups 261 | #~ 4.4.1 Mix_ReserveChannels Prevent channels from being used in default group 262 | #~ 4.4.2 Mix_GroupChannel Add/remove channel to/from group 263 | #~ 4.4.3 Mix_GroupChannels Add/remove segment of channels to/from group 264 | #~ 4.4.4 Mix_GroupCount Get number of channels in group 265 | #~ 4.4.5 Mix_GroupAvailable Get first inactive channel in group 266 | #~ 4.4.6 Mix_GroupOldest Get oldest busy channel in group 267 | #~ 4.4.7 Mix_GroupNewer Get youngest busy channel in group 268 | #~ 4.4.8 Mix_FadeOutGroup Fade out a group over time 269 | #~ 4.4.9 Mix_HaltGroup Stop a group 270 | 271 | # Mixer Music 272 | #~ 4.5.1 Mix_GetNumMusicDecoders Number of music format types that can be decoded 273 | #~ 4.5.2 Mix_GetMusicDecoder Name of enumerated music format type decoder 274 | #~ 4.5.3 Mix_LoadMUS Load a music file into a Mix_Music 275 | #~ 4.5.4 Mix_FreeMusic Free a Mix_Music 276 | #~ 4.5.5 Mix_PlayMusic Play music, with looping 277 | #~ 4.5.6 Mix_FadeInMusic Play music, with looping, and fade in 278 | #~ 4.5.7 Mix_FadeInMusicPos Play music from a start point, with looping, and fade in 279 | #~ 4.5.8 Mix_HookMusic Hook for a custom music player 280 | #~ 4.5.9 Mix_VolumeMusic Set music volume 281 | #~ 4.5.10 Mix_PauseMusic Pause music 282 | #~ 4.5.11 Mix_ResumeMusic Resume paused music 283 | #~ 4.5.12 Mix_RewindMusic Rewind music to beginning 284 | #~ 4.5.13 Mix_SetMusicPosition Set position of playback in stream 285 | #~ 4.5.14 Mix_SetMusicCMD Use external program for music playback 286 | #~ 4.5.15 Mix_HaltMusic Stop music playback 287 | #~ 4.5.16 Mix_FadeOutMusic Stop music, with fade out 288 | #~ 4.5.17 Mix_HookMusicFinished Set a callback for when music stops 289 | #~ 4.5.18 Mix_GetMusicType Get the music encoding type 290 | #~ 4.5.19 Mix_PlayingMusic Test whether music is playing 291 | #~ 4.5.20 Mix_PausedMusic Test whether music is paused 292 | #~ 4.5.21 Mix_FadingMusic Get status of current music fade activity 293 | #~ 4.5.22 Mix_GetMusicHookData Retrieve the Mix_HookMusic arg 294 | 295 | # Mixer Effects 296 | #~ 4.6.1 Mix_RegisterEffect Hook a processor to a channel 297 | #~ 4.6.2 Mix_UnregisterEffect Unhook a processor from a channel 298 | #~ 4.6.3 Mix_UnregisterAllEffects Unhook all processors from a channel 299 | #~ 4.6.4 Mix_SetPostMix Hook in a postmix processor 300 | #~ 4.6.5 Mix_SetPanning Stereo panning 301 | #~ 4.6.6 Mix_SetDistance Distance attenuation (volume) 302 | #~ 4.6.7 Mix_SetPosition Panning(angular) and distance 303 | #~ 4.6.8 Mix_SetReverseStereo Swap stereo left and right 304 | -------------------------------------------------------------------------------- /lib/SDL/Structures.pm6: -------------------------------------------------------------------------------- 1 | unit module SDL::Structures; 2 | 3 | use NativeCall; 4 | # Ideally this file could be autogenerated. 5 | 6 | class SDL_version is repr is export { # typedef struct { 7 | has uint8 $.major; # Uint8 major; 8 | has uint8 $.minor; # Uint8 minor; 9 | has uint8 $.patch; # Uint8 patch; 10 | } # } SDL_version; 11 | 12 | # From: SDL_video.h 13 | 14 | class SDL_Rect is repr is export { # typedef struct SDL_Rect { 15 | has int16 $.x; has int16 $.y; # Sint16 x, y; 16 | has uint16 $.w; has uint16 $.h; # Uint16 w, h; 17 | # } SDL_Rect; 18 | method new($x = 0, $y = 0, $w = 0, $h = 0) { 19 | self.bless(:$x, :$y, :$w, :$h); 20 | } 21 | } 22 | 23 | class SDL_Color is repr is export { # typedef struct SDL_Color { 24 | has uint8 $.r; # Uint8 r; 25 | has uint8 $.g; # Uint8 g; 26 | has uint8 $.b; # Uint8 b; 27 | has uint8 $.unused; # Uint8 unused; 28 | } # } SDL_Color; 29 | constant SDL_Colour = SDL_Color; #define SDL_Colour SDL_Color 30 | 31 | class SDL_Palette is repr is export { # typedef struct SDL_Palette { 32 | has int32 $.ncolors; # int ncolors; 33 | has Pointer[SDL_Color] $.colors; # SDL_Color *colors; 34 | } # } SDL_Palette; 35 | 36 | #~ /** Everything in the pixel format structure is read-only */ 37 | class SDL_PixelFormat is repr is export { # typedef struct SDL_PixelFormat { 38 | has SDL_Palette $.palette; # SDL_Palette *palette; 39 | has uint8 $.BitsPerPixel; # Uint8 BitsPerPixel; 40 | has uint8 $.BytesPerPixel; # Uint8 BytesPerPixel; 41 | has uint8 $.Rloss; # Uint8 Rloss; 42 | has uint8 $.Gloss; # Uint8 Gloss; 43 | has uint8 $.Bloss; # Uint8 Bloss; 44 | has uint8 $.Aloss; # Uint8 Aloss; 45 | has uint8 $.Rshift; # Uint8 Rshift; 46 | has uint8 $.Gshift; # Uint8 Gshift; 47 | has uint8 $.Bshift; # Uint8 Bshift; 48 | has uint8 $.Ashift; # Uint8 Ashift; 49 | has uint32 $.Rmask; # Uint32 Rmask; 50 | has uint32 $.Gmask; # Uint32 Gmask; 51 | has uint32 $.Bmask; # Uint32 Bmask; 52 | has uint32 $.Amask; # Uint32 Amask; 53 | # /** RGB color key information */ 54 | has uint32 $.colorkey; # Uint32 colorkey; 55 | # /** Alpha value information (per-surface alpha) */ 56 | has uint8 $.alpha; # Uint8 alpha; 57 | } # } SDL_PixelFormat; 58 | 59 | #| This structure should be treated as read-only, except for 'pixels', 60 | #| which, if not NULL, contains the raw pixel data for the surface. 61 | class SDL_Surface is repr is export { # typedef struct SDL_Surface { 62 | has uint32 $.flags; # Uint32 flags; /**< Read-only */ 63 | has SDL_PixelFormat $.format; # SDL_PixelFormat *format; /**< Read-only */ 64 | has int32 $.w; has int32 $.h; # int w, h; /**< Read-only */ 65 | has uint16 $.pitch; # Uint16 pitch; /**< Read-only */ 66 | has Pointer $.pixels; # void *pixels; /**< Read-write */ 67 | has int32 $.offset; # int offset; /**< Private */ 68 | # /** Hardware-specific surface info */ 69 | has Pointer $.hwdata; # struct private_hwdata *hwdata; 70 | # /** clipping information */ 71 | HAS SDL_Rect $.clip_rect; # SDL_Rect clip_rect; /**< Read-only */ 72 | has uint32 $.unused1; # Uint32 unused1; /**< for binary compatibility */ 73 | # /** Allow recursive locks */ 74 | has uint32 $.locked; # Uint32 locked; /**< Private */ 75 | # /** info for fast blit mapping to other surfaces */ 76 | has Pointer $.map; # struct SDL_BlitMap *map; /**< Private */ 77 | # /** format version, bumped at every change to invalidate blit maps */ 78 | has uint32 $.format_version; # unsigned int format_version; /**< Private */ 79 | # /** Reference count -- used when freeing surface */ 80 | has int32 $.refcount; # int refcount; /**< Read-mostly */ 81 | } # } SDL_Surface; 82 | 83 | #| Useful for determining the video hardware capabilities 84 | class SDL_VideoInfo is repr is export { # typedef struct SDL_VideoInfo { 85 | has uint32 $.hw_available; # Uint32 hw_available :1; /**< Flag: Can you create hardware surfaces? */ 86 | has uint32 $.wm_available; # Uint32 wm_available :1; /**< Flag: Can you talk to a window manager? */ 87 | has uint32 $.UnusedBits1; # Uint32 UnusedBits1 :6; 88 | has uint32 $.UnusedBits2; # Uint32 UnusedBits2 :1; 89 | has uint32 $.blit_hw; # Uint32 blit_hw :1; /**< Flag: Accelerated blits HW --> HW */ 90 | has uint32 $.blit_hw_CC; # Uint32 blit_hw_CC :1; /**< Flag: Accelerated blits with Colorkey */ 91 | has uint32 $.blit_hw_A; # Uint32 blit_hw_A :1; /**< Flag: Accelerated blits with Alpha */ 92 | has uint32 $.blit_sw; # Uint32 blit_sw :1; /**< Flag: Accelerated blits SW --> HW */ 93 | has uint32 $.blit_sw_CC; # Uint32 blit_sw_CC :1; /**< Flag: Accelerated blits with Colorkey */ 94 | has uint32 $.blit_sw_A; # Uint32 blit_sw_A :1; /**< Flag: Accelerated blits with Alpha */ 95 | has uint32 $.blit_fill; # Uint32 blit_fill :1; /**< Flag: Accelerated color fill */ 96 | has uint32 $.UnusedBits3; # Uint32 UnusedBits3 :16; 97 | has uint32 $.video_mem; # Uint32 video_mem; /**< The total amount of video memory (in K) */ 98 | has SDL_PixelFormat $.vfmt; # SDL_PixelFormat *vfmt; /**< Value: The format of the video surface */ 99 | has int32 $.current_w; # int current_w; /**< Value: The current video mode width */ 100 | has int32 $.current_h; # int current_h; /**< Value: The current video mode height */ 101 | } # } SDL_VideoInfo; 102 | 103 | #~ /** The YUV hardware video overlay */ 104 | #~ typedef struct SDL_Overlay { 105 | #~ Uint32 format; /**< Read-only */ 106 | #~ int w, h; /**< Read-only */ 107 | #~ int planes; /**< Read-only */ 108 | #~ Uint16 *pitches; /**< Read-only */ 109 | #~ Uint8 **pixels; /**< Read-write */ 110 | 111 | #~ /** @name Hardware-specific surface info */ 112 | #~ /*@{*/ 113 | #~ struct private_yuvhwfuncs *hwfuncs; 114 | #~ struct private_yuvhwdata *hwdata; 115 | #~ /*@{*/ 116 | 117 | #~ /** @name Special flags */ 118 | #~ /*@{*/ 119 | #~ Uint32 hw_overlay :1; /**< Flag: This overlay hardware accelerated? */ 120 | #~ Uint32 UnusedBits :31; 121 | #~ /*@}*/ 122 | #~ } SDL_Overlay; 123 | 124 | class SDL_ActiveEvent is repr is export { 125 | has uint8 $.type; 126 | has uint8 $.gain; 127 | has uint8 $.state; 128 | } 129 | 130 | class SDL_keysym is repr is export { 131 | has uint8 $.scancode; 132 | has uint32 $.sym; # SDLKey 133 | has uint32 $.mod; # SDLMod 134 | has uint16 $.unicode; 135 | } 136 | 137 | class SDL_KeyboardEvent is repr is export { 138 | has uint8 $.type; 139 | has uint8 $.state; 140 | HAS SDL_keysym $.keysym; 141 | } 142 | 143 | class SDL_MouseMotionEvent is repr is export { 144 | has uint8 $.type; 145 | has uint8 $.state; 146 | has uint16 $.x; 147 | has uint16 $.y; 148 | has int16 $.xrel; 149 | has int16 $.yrel; 150 | } 151 | 152 | class SDL_MouseButtonEvent is repr is export { 153 | has uint8 $.type; 154 | has uint8 $.button; 155 | has uint8 $.state; 156 | has uint16 $.x; 157 | has uint16 $.y; 158 | } 159 | 160 | class SDL_JoyAxisEvent is repr is export { 161 | has uint8 $.type; 162 | has uint8 $.which; 163 | has uint8 $.axis; 164 | has int16 $.value; 165 | } 166 | 167 | class SDL_JoyBallEvent is repr is export { 168 | has uint8 $.type; 169 | has uint8 $.which; 170 | has uint8 $.ball; 171 | has int16 $.xrel; 172 | has int16 $.yrel; 173 | } 174 | 175 | class SDL_JoyHatEvent is repr is export { 176 | has uint8 $.type; 177 | has uint8 $.which; 178 | has uint8 $.hat; 179 | has uint8 $.value; 180 | } 181 | 182 | class SDL_JoyButtonEvent is repr is export { 183 | has uint8 $.type; 184 | has uint8 $.which; 185 | has uint8 $.button; 186 | has uint8 $.state; 187 | } 188 | 189 | class SDL_QuitEvent is repr is export { 190 | has uint8 $.type; 191 | } 192 | 193 | class SDL_SysWMEvent is repr is export { 194 | has uint8 $.type; 195 | has Pointer $.msg; # SDL_SysWMmsg 196 | } 197 | 198 | class SDL_ResizeEvent is repr is export { 199 | has uint8 $.type; 200 | has int32 $.w; 201 | has int32 $.h; 202 | } 203 | 204 | class SDL_ExposeEvent is repr is export { 205 | has uint8 $.type; 206 | } 207 | 208 | class SDL_UserEvent is repr is export { 209 | has uint8 $.type; 210 | has int32 $.code; 211 | has Pointer $.data1; 212 | has Pointer $.data2; 213 | } 214 | 215 | class SDL_Event is repr is export { 216 | has uint8 $.type; 217 | HAS SDL_ActiveEvent $.active; 218 | HAS SDL_KeyboardEvent $.key; 219 | HAS SDL_MouseMotionEvent $.motion; 220 | HAS SDL_MouseButtonEvent $.button; 221 | HAS SDL_JoyAxisEvent $.jaxis; 222 | HAS SDL_JoyBallEvent $.jball; 223 | HAS SDL_JoyHatEvent $.jhat; 224 | HAS SDL_JoyButtonEvent $.jbutton; 225 | HAS SDL_ResizeEvent $.resize; 226 | HAS SDL_ExposeEvent $.expose; 227 | HAS SDL_QuitEvent $.quit; 228 | HAS SDL_UserEvent $.user; 229 | HAS SDL_SysWMEvent $.syswm; 230 | } 231 | 232 | class Mix_Chunk is repr is export { 233 | has int32 $.allocated; 234 | has Pointer $.abuf; 235 | has uint32 $.alen; 236 | has uint8 $.volume; # Per-sample volume, 0-128 237 | } 238 | 239 | -------------------------------------------------------------------------------- /share/sample.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PerlGameDev/SDL6/dbbd8fdca02d179231385508b4ea79760f14d6d4/share/sample.wav -------------------------------------------------------------------------------- /share/silence.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PerlGameDev/SDL6/dbbd8fdca02d179231385508b4ea79760f14d6d4/share/silence.wav -------------------------------------------------------------------------------- /t/core.t: -------------------------------------------------------------------------------- 1 | use SDL; 2 | use Test; 3 | 4 | plan 11; 5 | 6 | SDL_Linked_Version() andthen diag sprintf 'SDL_Linked_Version v%d.%d.%d', .major, .minor, .patch; 7 | 8 | is SDL_Init(1), 0, "SDL_Init"; 9 | is SDL_WasInit(0), 1, "SDL_WasInit"; 10 | is SDL_InitSubSystem(255), 0, "SDL_InitSubSystem"; 11 | ok SDL_WasInit(0) > 1, "SDL_WasInit"; 12 | SDL_QuitSubSystem(254); pass "SDL_QuitSubSystem"; 13 | is SDL_WasInit(0), 1, "SDL_WasInit"; 14 | 15 | SDL_Delay(200); 16 | ok SDL_GetTicks() >= 200, "SDL_GetTicks"; 17 | 18 | my $version = SDL_Linked_Version(); 19 | isa-ok $version, SDL_version, "SDL_Linked_Version"; 20 | is $version.major, 1, "SDL_Linked_Version.major"; 21 | is $version.minor, 2, "SDL_Linked_Version.minor"; 22 | ok 4 <= $version.patch <= 15, "SDL_Linked_Version.patch"; 23 | -------------------------------------------------------------------------------- /t/mixer-channels.t: -------------------------------------------------------------------------------- 1 | use SDL; 2 | use NativeCall; 3 | use Test; 4 | 5 | plan 39; 6 | 7 | Mix_Linked_Version() andthen diag sprintf 'Mix_Linked_Version v%d.%d.%d', .major, .minor, .patch; 8 | 9 | # Setting up audio. You will hear nothing unless SDL_RELEASE_TESTING is set. 10 | my $delay = 50; 11 | my $audio_test_file = 'share/silence.wav'; 12 | my $volume = 1; 13 | 14 | if %*ENV { 15 | $delay = 300; 16 | $audio_test_file = 'share/sample.wav'; 17 | $volume = 20; 18 | } 19 | 20 | # Try to init audio. If it fails its not our fault, maybe the machine has no sound card. 21 | if 0 != SDL_Init(16) { 22 | skip-rest( 'Failed to initialize audio with reason: "' ~ SDL_GetError() ~ '"' ); 23 | exit; 24 | } 25 | 26 | # Basically the same 27 | if 0 != Mix_OpenAudio(44100, 36880, 2, 4096) { 28 | skip-rest( 'Failed to open audio: "' ~ SDL_GetError() ~ '"' ); 29 | exit; 30 | } 31 | 32 | # Hooray! So far... 33 | pass 'Mix_OpenAudio ran'; 34 | 35 | # We request 4 channels, but we will actually just need one. 36 | is Mix_AllocateChannels(4), 4, 'Mix_AllocateChannels allocated 4 channels'; 37 | 38 | # Changing the volume. 39 | is Mix_Volume(-1, 10), 128, 'Mix_Volume set to 10, previously was 128'; 40 | is Mix_Volume(-1, $volume), 10, "Mix_Volume set to $volume, previously was 10"; 41 | 42 | # Loading audio file. 43 | my $sample_chunk = Mix_LoadWAV($audio_test_file); 44 | ok $sample_chunk ~~ Mix_Chunk, "Mix_LoadWAV loaded audio sample $audio_test_file"; 45 | 46 | # Play that audio file. 47 | my $playing_channel = Mix_PlayChannelTimed(-1, $sample_chunk, -1, -1); 48 | ok $playing_channel >= 0, 'Mix_PlayChannelTimed plays audio sample'; 49 | SDL_Delay($delay); 50 | 51 | # Request the current states. 52 | is Mix_Playing($playing_channel), 1, "Mix_Playing channel $playing_channel is playing"; 53 | is Mix_Paused($playing_channel), 0, "Mix_Paused channel $playing_channel is not paused"; 54 | is Mix_FadingChannel($playing_channel), 0, "Mix_FadingChannel channel $playing_channel is not fading"; 55 | 56 | # Preparing first callback test. NativeCall++, it's pretty easy to do. 57 | my $callback_finished = 0; 58 | sub callback_finished(int32 $channel) { 59 | pass "Mix_ChannelFinished called callback type: &callback for channel $channel"; 60 | $callback_finished++; 61 | } 62 | Mix_ChannelFinished(&callback_finished); 63 | pass 'Mix_ChannelFinished registered callback type: &callback'; 64 | 65 | # Stopping the music, the callback should be called then. 66 | is Mix_HaltChannel($playing_channel), 0, "Mix_HaltChannel stopped channel $playing_channel"; 67 | is $callback_finished, 1, "Mix_ChannelFinished callback was called once"; 68 | 69 | # Checking states again. 70 | is Mix_Playing($playing_channel), 0, "Mix_Playing channel $playing_channel is not playing"; 71 | is Mix_Paused($playing_channel), 0, "Mix_Paused channel $playing_channel is not paused"; 72 | is Mix_FadingChannel($playing_channel), 0, "Mix_FadingChannel channel $playing_channel is not fading"; 73 | 74 | # Playing and stopping again, the callback should get called again. 75 | $playing_channel = Mix_PlayChannelTimed(-1, $sample_chunk, -1, -1); 76 | SDL_Delay($delay); 77 | is Mix_HaltChannel( $playing_channel ), 0, "Mix_HaltChannel stopped channel $playing_channel"; 78 | is $callback_finished, 2, "Mix_ChannelFinished callback was called twice"; 79 | 80 | # Unregistering callback and checking that it doesn't get called. 81 | Mix_ChannelFinished(Code); 82 | pass 'Mix_ChannelFinished unregistered callback type: &callback'; 83 | $playing_channel = Mix_PlayChannelTimed(-1, $sample_chunk, -1, -1); 84 | SDL_Delay($delay); 85 | is Mix_HaltChannel($playing_channel), 0, "Mix_HaltChannel stopped channel $playing_channel"; 86 | is $callback_finished, 2, "Mix_ChannelFinished callback still was called twice"; 87 | 88 | $playing_channel = Mix_PlayChannelTimed(-1, $sample_chunk, -1, -1); 89 | SDL_Delay($delay); 90 | 91 | is MixerFading(Mix_FadingChannel($playing_channel)), MIX_NO_FADING, "Mix_FadingChannel channel $playing_channel is not fading"; 92 | is Mix_Playing($playing_channel), 1, "Mix_Playing channel $playing_channel is playing"; 93 | is Mix_Paused($playing_channel), 0, "Mix_Paused channel $playing_channel is not paused"; 94 | 95 | my $fading_channels = Mix_FadeOutChannel($playing_channel, $delay); 96 | ok $fading_channels > 0, "Mix_FadeOutChannel $delay ms for $fading_channels channel(s)"; 97 | is MixerFading(Mix_FadingChannel($playing_channel)), MIX_FADING_OUT, "Mix_FadingChannel channel $playing_channel is fading out"; 98 | 99 | SDL_Delay($delay); 100 | 101 | $playing_channel = Mix_FadeInChannel(-1, $sample_chunk, 0, $delay); 102 | 103 | isnt $playing_channel, -1,"Mix_FadeInChannel $delay ms for channel $playing_channel"; 104 | is MixerFading(Mix_FadingChannel($playing_channel)), MIX_FADING_IN, "Mix_FadingChannel channel $playing_channel is fading in"; 105 | SDL_Delay($delay); 106 | 107 | Mix_Pause(-1); 108 | pass 'Mix_Pause ran'; 109 | is Mix_Paused($playing_channel), 1, "Mix_Paused channel $playing_channel is paused"; 110 | SDL_Delay(($delay / 4).Int); 111 | 112 | Mix_Resume(-1); 113 | pass 'Mix_Resume ran'; 114 | 115 | SDL_Delay($delay); 116 | 117 | is Mix_HaltChannel($playing_channel), 0, "Mix_HaltChannel stop channel $playing_channel"; 118 | is Mix_Playing($playing_channel), 0, "Mix_Playing channel $playing_channel is not playing"; 119 | 120 | SDL_Delay($delay); 121 | 122 | $playing_channel = Mix_PlayChannelTimed(-1, $sample_chunk, 0, $delay); 123 | 124 | isnt $playing_channel, -1, "Mix_PlayChannelTimed play $delay ms for channel $playing_channel"; 125 | SDL_Delay(($delay / 4).Int); 126 | 127 | my $expire_channel = Mix_ExpireChannel($playing_channel, $delay); 128 | ok $expire_channel > 0, "Mix_ExpireChannel stops after $delay ms for $expire_channel channel(s)"; 129 | 130 | SDL_Delay($delay); 131 | 132 | $playing_channel = Mix_FadeInChannelTimed(-1, $sample_chunk, 0, $delay, $delay * 2); 133 | 134 | isnt $playing_channel, -1, "Mix_FadeInChannelTimed play {$delay * 2} ms after $delay ms fade in for channel $playing_channel"; 135 | 136 | isa-ok Mix_GetChunk($playing_channel), Mix_Chunk, 'Mix_GetChunk'; 137 | 138 | sleep(1); 139 | 140 | SDL_Delay($delay); 141 | Mix_CloseAudio(); 142 | pass 'Mix_CloseAudio ran'; 143 | -------------------------------------------------------------------------------- /t/rect.t: -------------------------------------------------------------------------------- 1 | use SDL; 2 | use Test; 3 | 4 | plan 9; 5 | 6 | SDL_Linked_Version() andthen diag sprintf 'v%d.%d.%d', .major, .minor, .patch; 7 | 8 | my $r1 = SDL_Rect.new(1, 2, 3, 4); 9 | my $r2 = SDL_Rect.new(4, 3, 2, 1); 10 | 11 | ok $r1 ~~ SDL_Rect, 'create a SDL::Rect object'; 12 | is $r1.x, 1, 'rect one attribute x'; 13 | is $r1.y, 2, 'rect one attribute y'; 14 | is $r1.w, 3, 'rect one attribute w'; 15 | is $r1.h, 4, 'rect one attribute h'; 16 | is $r2.x, 4, 'rect two attribute x'; 17 | is $r2.y, 3, 'rect two attribute y'; 18 | is $r2.w, 2, 'rect two attribute w'; 19 | is $r2.h, 1, 'rect two attribute h'; 20 | --------------------------------------------------------------------------------