parrotcode: Parrot extension for SDL bindings | |
Contents | Libraries |
SDL - Parrot extension for SDL bindings
None.
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 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:
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.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.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:
An array of SDL_Rect structs. Use this for such things as passing multiple rects to a surface update function, for example. Note that you'll have to update the element at index 1 with the proper count of the number of rects in the array.
If this confuses you,
see SDL::Surface::update_rects()
and imagine how I felt when I wrote it!
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-2007 The Perl Foundation.
|