SDL - Parrot extension for SDL bindings



You probably shouldn't use this library directly, unless you're writing your own wrappers around the SDL NCI code or if you're calling the NCI functions directly.

In that case, I'm perfectly happy saying "Hey buddy, you're on your own!"


This is the library that contains all of the actual NCI bindings and Parrot data structure definitions to work with SDL from Parrot. Normal people, run away to SDL::App right now instead. This is pretty low-level stuff and you shouldn't have to use it or even know that it's here if you want to work with SDL from Parrot.

On the other hand, if you want to use these functions directly, write your own wrappers, or add wrappers that aren't already here, you should know how it works.

The SDL Namespace ^

The SDL namespace holds only a few functions right now, initializers for various libraries. These load the PASM code that actually creates the SDL NCI bindings and initialize all of the SDL-specific data structures needed to access structs passed to and returned from SDL calls. There's no need to load sound components if you don't have sound installed, for example.

Each struct layout has its own function that creates and stores the appropriate data structure. The order of calling really matters here, as some structs contain other structs.

When you load this file with load_bytecode, it initializes the SDL_video subsystem. You'll have to use the appropriate IMC modules or initialize the other subsystems manually.

The subsystem initalizers include:


Initialize the video subsystem. You shouldn't ever need to call this directly. In fact, don't count on it sticking around. It may not. Then again, it might.


Initialize the SDL_image subsystem. If you don't have the appropriate library installed, this won't work very well. You'll probably want to use the SDL::Image library anyway, which calls this for you.


Initialize the SDL_ttf subsystem. If you don't have the appropriate library installed, this won't work very well. You'll probably want to use the SDL::Font library anyway, which calls this for you.

The SDL::NCI Namespace ^

Besides all of the actual NCI subs, there's one additional subroutine in the SDL::NCI namespace.

fetch_layout() takes one argument, a string containing the name of the SDL_* data structure layout PMC to return. You can then assign the layout to an UnManagedStruct or ManagedStruct PMC to assign to and read from various struct members.

Note that the name of the layout has the leading SDL_ prefix removed; to fetch the layout for an SDL_Rect struct, ask for Rect.

This currently doesn't do much if you request an unknown layout. Suggestions welcome.

In addition to the various SDL data structures, this makes the following other layouts available:


Written and maintained by chromatic, <chromatic at wgz dot org>. Please send patches, feedback, and suggestions to the Perl 6 Internals mailing list.


Copyright (c) 2004, The Perl Foundation.