Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
1,414 additions
and
381 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,27 @@ | ||
{ | ||
"name" : "SDL", | ||
"version" : "*", | ||
"version" : "0.1.0", | ||
"description" : "A Perl 6 wrapper around SDL 1.2", | ||
"depends" : [ "Inline" ], | ||
"depends" : [ ], | ||
"provides" : { | ||
"SDL" : "lib/lib/SDL.pm6", | ||
"SDL::Version" : "lib/lib/SDL/Version.pm6", | ||
"SDL::CStructs" : "lib/lib/SDL/CStructs.pm6", | ||
"SDL::PixelFormat" : "lib/lib/SDL/PixelFormat.pm6", | ||
"SDL::Palette" : "lib/lib/SDL/Palette.pm6", | ||
"SDL::SFont" : "lib/lib/SDL/SFont.pm6", | ||
"SDL::Video" : "lib/lib/SDL/Video.pm6", | ||
"SDL::Surface" : "lib/lib/SDL/Surface.pm6", | ||
"SDL::App" : "lib/lib/SDL/App.pm6", | ||
"SDL::Rect" : "lib/lib/SDL/Rect.pm6", | ||
"SDL::SDL_video" : "lib/lib/SDL/SDL_video.pm", | ||
"SDL::Mixer" : "lib/lib/SDL/Mixer.pm6", | ||
"SDL::Mixer::Samples" : "lib/lib/SDL/Mixer/Samples.pm6", | ||
"SDL::Mixer::Effects" : "lib/lib/SDL/Mixer/Effects.pm6", | ||
"SDL::Mixer::Channels" : "lib/lib/SDL/Mixer/Channels.pm6", | ||
"SDL::Event" : "lib/lib/SDL/Event.pm6", | ||
"SDL::Controller" : "lib/lib/SDL/Controller.pm6", | ||
"SDL::Color" : "lib/lib/SDL/Color.pm" | ||
}, | ||
"source-url" : "git://github.com/PerlGameDev/SDL6.git" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,188 @@ | ||
|
||
# Ideally this file could be autogenerated. | ||
|
||
class SDL_version is repr('CStruct') { # typedef struct { | ||
has uint8 $.major; # Uint8 major; | ||
has uint8 $.minor; # Uint8 minor; | ||
has uint8 $.patch; # Uint8 patch; | ||
} # } SDL_version; | ||
|
||
# From: SDL_video.h | ||
|
||
class SDL_Rect is repr('CStruct') { # typedef struct SDL_Rect { | ||
has int16 $.x; has int16 $.y; # Sint16 x, y; | ||
has uint16 $.w; has uint16 $.h; # Uint16 w, h; | ||
} # } SDL_Rect; | ||
|
||
typedef struct SDL_Color { | ||
Uint8 r; | ||
Uint8 g; | ||
Uint8 b; | ||
Uint8 unused; | ||
} SDL_Color; | ||
#define SDL_Colour SDL_Color | ||
|
||
typedef struct SDL_Palette { | ||
int ncolors; | ||
SDL_Color *colors; | ||
} SDL_Palette; | ||
/*@}*/ | ||
|
||
/** Everything in the pixel format structure is read-only */ | ||
typedef struct SDL_PixelFormat { | ||
SDL_Palette *palette; | ||
Uint8 BitsPerPixel; | ||
Uint8 BytesPerPixel; | ||
Uint8 Rloss; | ||
Uint8 Gloss; | ||
Uint8 Bloss; | ||
Uint8 Aloss; | ||
Uint8 Rshift; | ||
Uint8 Gshift; | ||
Uint8 Bshift; | ||
Uint8 Ashift; | ||
Uint32 Rmask; | ||
Uint32 Gmask; | ||
Uint32 Bmask; | ||
Uint32 Amask; | ||
|
||
/** RGB color key information */ | ||
Uint32 colorkey; | ||
/** Alpha value information (per-surface alpha) */ | ||
Uint8 alpha; | ||
} SDL_PixelFormat; | ||
|
||
/** This structure should be treated as read-only, except for 'pixels', | ||
* which, if not NULL, contains the raw pixel data for the surface. | ||
*/ | ||
typedef struct SDL_Surface { | ||
Uint32 flags; /**< Read-only */ | ||
SDL_PixelFormat *format; /**< Read-only */ | ||
int w, h; /**< Read-only */ | ||
Uint16 pitch; /**< Read-only */ | ||
void *pixels; /**< Read-write */ | ||
int offset; /**< Private */ | ||
|
||
/** Hardware-specific surface info */ | ||
struct private_hwdata *hwdata; | ||
|
||
/** clipping information */ | ||
SDL_Rect clip_rect; /**< Read-only */ | ||
Uint32 unused1; /**< for binary compatibility */ | ||
|
||
/** Allow recursive locks */ | ||
Uint32 locked; /**< Private */ | ||
|
||
/** info for fast blit mapping to other surfaces */ | ||
struct SDL_BlitMap *map; /**< Private */ | ||
|
||
/** format version, bumped at every change to invalidate blit maps */ | ||
unsigned int format_version; /**< Private */ | ||
|
||
/** Reference count -- used when freeing surface */ | ||
int refcount; /**< Read-mostly */ | ||
} SDL_Surface; | ||
|
||
/** @name SDL_Surface Flags | ||
* These are the currently supported flags for the SDL_surface | ||
*/ | ||
/*@{*/ | ||
|
||
/** Available for SDL_CreateRGBSurface() or SDL_SetVideoMode() */ | ||
/*@{*/ | ||
#define SDL_SWSURFACE 0x00000000 /**< Surface is in system memory */ | ||
#define SDL_HWSURFACE 0x00000001 /**< Surface is in video memory */ | ||
#define SDL_ASYNCBLIT 0x00000004 /**< Use asynchronous blits if possible */ | ||
/*@}*/ | ||
|
||
/** Available for SDL_SetVideoMode() */ | ||
/*@{*/ | ||
#define SDL_ANYFORMAT 0x10000000 /**< Allow any video depth/pixel-format */ | ||
#define SDL_HWPALETTE 0x20000000 /**< Surface has exclusive palette */ | ||
#define SDL_DOUBLEBUF 0x40000000 /**< Set up double-buffered video mode */ | ||
#define SDL_FULLSCREEN 0x80000000 /**< Surface is a full screen display */ | ||
#define SDL_OPENGL 0x00000002 /**< Create an OpenGL rendering context */ | ||
#define SDL_OPENGLBLIT 0x0000000A /**< Create an OpenGL rendering context and use it for blitting */ | ||
#define SDL_RESIZABLE 0x00000010 /**< This video mode may be resized */ | ||
#define SDL_NOFRAME 0x00000020 /**< No window caption or edge frame */ | ||
/*@}*/ | ||
|
||
/** Used internally (read-only) */ | ||
/*@{*/ | ||
#define SDL_HWACCEL 0x00000100 /**< Blit uses hardware acceleration */ | ||
#define SDL_SRCCOLORKEY 0x00001000 /**< Blit uses a source color key */ | ||
#define SDL_RLEACCELOK 0x00002000 /**< Private flag */ | ||
#define SDL_RLEACCEL 0x00004000 /**< Surface is RLE encoded */ | ||
#define SDL_SRCALPHA 0x00010000 /**< Blit uses source alpha blending */ | ||
#define SDL_PREALLOC 0x01000000 /**< Surface uses preallocated memory */ | ||
/*@}*/ | ||
|
||
/*@}*/ | ||
|
||
/** Evaluates to true if the surface needs to be locked before access */ | ||
#define SDL_MUSTLOCK(surface) \ | ||
(surface->offset || \ | ||
((surface->flags & (SDL_HWSURFACE|SDL_ASYNCBLIT|SDL_RLEACCEL)) != 0)) | ||
|
||
/** typedef for private surface blitting functions */ | ||
typedef int (*SDL_blit)(struct SDL_Surface *src, SDL_Rect *srcrect, | ||
struct SDL_Surface *dst, SDL_Rect *dstrect); | ||
|
||
|
||
/** Useful for determining the video hardware capabilities */ | ||
typedef struct SDL_VideoInfo { | ||
Uint32 hw_available :1; /**< Flag: Can you create hardware surfaces? */ | ||
Uint32 wm_available :1; /**< Flag: Can you talk to a window manager? */ | ||
Uint32 UnusedBits1 :6; | ||
Uint32 UnusedBits2 :1; | ||
Uint32 blit_hw :1; /**< Flag: Accelerated blits HW --> HW */ | ||
Uint32 blit_hw_CC :1; /**< Flag: Accelerated blits with Colorkey */ | ||
Uint32 blit_hw_A :1; /**< Flag: Accelerated blits with Alpha */ | ||
Uint32 blit_sw :1; /**< Flag: Accelerated blits SW --> HW */ | ||
Uint32 blit_sw_CC :1; /**< Flag: Accelerated blits with Colorkey */ | ||
Uint32 blit_sw_A :1; /**< Flag: Accelerated blits with Alpha */ | ||
Uint32 blit_fill :1; /**< Flag: Accelerated color fill */ | ||
Uint32 UnusedBits3 :16; | ||
Uint32 video_mem; /**< The total amount of video memory (in K) */ | ||
SDL_PixelFormat *vfmt; /**< Value: The format of the video surface */ | ||
int current_w; /**< Value: The current video mode width */ | ||
int current_h; /**< Value: The current video mode height */ | ||
} SDL_VideoInfo; | ||
|
||
|
||
/** @name Overlay Formats | ||
* The most common video overlay formats. | ||
* For an explanation of these pixel formats, see: | ||
* http://www.webartz.com/fourcc/indexyuv.htm | ||
* | ||
* For information on the relationship between color spaces, see: | ||
* http://www.neuro.sfc.keio.ac.jp/~aly/polygon/info/color-space-faq.html | ||
*/ | ||
/*@{*/ | ||
#define SDL_YV12_OVERLAY 0x32315659 /**< Planar mode: Y + V + U (3 planes) */ | ||
#define SDL_IYUV_OVERLAY 0x56555949 /**< Planar mode: Y + U + V (3 planes) */ | ||
#define SDL_YUY2_OVERLAY 0x32595559 /**< Packed mode: Y0+U0+Y1+V0 (1 plane) */ | ||
#define SDL_UYVY_OVERLAY 0x59565955 /**< Packed mode: U0+Y0+V0+Y1 (1 plane) */ | ||
#define SDL_YVYU_OVERLAY 0x55595659 /**< Packed mode: Y0+V0+Y1+U0 (1 plane) */ | ||
/*@}*/ | ||
|
||
/** The YUV hardware video overlay */ | ||
typedef struct SDL_Overlay { | ||
Uint32 format; /**< Read-only */ | ||
int w, h; /**< Read-only */ | ||
int planes; /**< Read-only */ | ||
Uint16 *pitches; /**< Read-only */ | ||
Uint8 **pixels; /**< Read-write */ | ||
|
||
/** @name Hardware-specific surface info */ | ||
/*@{*/ | ||
struct private_yuvhwfuncs *hwfuncs; | ||
struct private_yuvhwdata *hwdata; | ||
/*@{*/ | ||
|
||
/** @name Special flags */ | ||
/*@{*/ | ||
Uint32 hw_overlay :1; /**< Flag: This overlay hardware accelerated? */ | ||
Uint32 UnusedBits :31; | ||
/*@}*/ | ||
} SDL_Overlay; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
|
||
class SDL::Color is repr('CStruct'); | ||
|
||
#~ has uint8 $.r; | ||
#~ has uint8 $.g; | ||
#~ has uint8 $.b; | ||
#~ has uint8 $.unused; | ||
has int8 $.r; | ||
has int8 $.g; | ||
has int8 $.b; | ||
has int8 $.unused; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
|
||
module SDL::Controller; | ||
unit module SDL::Controller; | ||
|
||
use NativeCall; | ||
#use SDL; # I cant do that? | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
|
||
module SDL::Event; | ||
unit module SDL::Event; | ||
|
||
use NativeCall; # for CArray type | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
|
||
module SDL::Mixer; | ||
unit module SDL::Mixer; | ||
|
||
use NativeCall; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
module SDL::Mixer::Channels; | ||
unit module SDL::Mixer::Channels; | ||
|
||
use NativeCall; | ||
|
||
# native calls to libSDL_mixer | ||
# Note: 'is symbol' will be called 'is named' in future | ||
our sub volume( int, int ) returns Int is native('libSDL_mixer') is symbol('Mix_Volume') { * } | ||
our sub allocate( int ) returns Int is native('libSDL_mixer') is symbol('Mix_AllocateChannels') { * } | ||
our sub finished( Code &callback(int) ) returns Int is native('libSDL_mixer') is symbol('Mix_ChannelFinished') { * } | ||
our sub _play( int, OpaquePointer, int, int ) returns Int is native('libSDL_mixer') is symbol('Mix_PlayChannelTimed') { * } | ||
our sub halt( int ) returns Int is native('libSDL_mixer') is symbol('Mix_HaltChannel') { * } | ||
our sub playing( int ) returns Int is native('libSDL_mixer') is symbol('Mix_Playing') { * } | ||
our sub paused( int) returns Int is native('libSDL_mixer') is symbol('Mix_Paused') { * } | ||
our sub fading( int ) returns Int is native('libSDL_mixer') is symbol('Mix_FadingChannel') { * } | ||
our sub volume( int32, int32 ) returns int32 is native('libSDL_mixer') is symbol('Mix_Volume') { * } | ||
our sub allocate( int32 ) returns int32 is native('libSDL_mixer') is symbol('Mix_AllocateChannels') { * } | ||
our sub finished( &callback (int32) ) returns int32 is native('libSDL_mixer') is symbol('Mix_ChannelFinished') { * } | ||
our sub _play( int32, Pointer, int32, int32 ) returns int32 is native('libSDL_mixer') is symbol('Mix_PlayChannelTimed') { * } | ||
our sub halt( int32 ) returns int32 is native('libSDL_mixer') is symbol('Mix_HaltChannel') { * } | ||
our sub playing( int32 ) returns int32 is native('libSDL_mixer') is symbol('Mix_Playing') { * } | ||
our sub paused( int32 ) returns int32 is native('libSDL_mixer') is symbol('Mix_Paused') { * } | ||
our sub fading( int32 ) returns int32 is native('libSDL_mixer') is symbol('Mix_FadingChannel') { * } | ||
|
||
# wrappers (for example to support optional parameters) | ||
# Note: dont use typed parameters here | ||
our sub play( $channel, $sample, $loops, $time = -1 ) returns Int { _play( $channel, $sample, $loops, $time ) } | ||
our sub play( $channel, $sample, $loops, $time = -1 ) returns int32 { _play( $channel, $sample, $loops, $time ) } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
|
||
module SDL::Mixer::Effects; | ||
unit module SDL::Mixer::Effects; | ||
|
||
use NativeCall; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
|
||
module SDL::Mixer::Samples; | ||
unit module SDL::Mixer::Samples; | ||
|
||
use NativeCall; | ||
|
||
our sub load_WAV( Str $file ) returns OpaquePointer { | ||
my $rw = rw_from_file( $file, 'rb' ); | ||
return load_WAV_RW( $rw, 1 ); | ||
our sub load_WAV( Str $file ) returns Pointer { | ||
my $rw = rw_from_file( $file, 'rb' ); | ||
return load_WAV_RW( $rw, 1 ); | ||
} | ||
our sub load_WAV_RW( OpaquePointer, int ) returns OpaquePointer is native('libSDL_mixer') is symbol('Mix_LoadWAV_RW') { * } | ||
our sub rw_from_file( Str, Str ) returns OpaquePointer is native('libSDL') is symbol('SDL_RWFromFile') { * } | ||
our sub load_WAV_RW( Pointer, int32 ) returns Pointer is native('libSDL_mixer') is symbol('Mix_LoadWAV_RW') { * } | ||
our sub rw_from_file( Str, Str ) returns Pointer is native('libSDL') is symbol('SDL_RWFromFile') { * } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
class SDL::Palette is repr('CStruct'); | ||
|
||
use NativeCall; | ||
use SDL::Color; | ||
|
||
has int32 $.ncolors; | ||
has CArray[SDL::Color] $.colors; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
|
||
class SDL::PixelFormat is repr('CStruct'); | ||
|
||
use SDL::Palette; | ||
|
||
has SDL::Palette $.palette; | ||
#~ has uint8 $.BitsPerPixel; | ||
#~ has uint8 $.BytesPerPixel; | ||
#~ has uint8 $.Rloss; | ||
#~ has uint8 $.Gloss; | ||
#~ has uint8 $.Bloss; | ||
#~ has uint8 $.Aloss; | ||
#~ has uint8 $.Rshift; | ||
#~ has uint8 $.Gshift; | ||
#~ has uint8 $.Bshift; | ||
#~ has uint8 $.Ashift;has uint8 $.BitsPerPixel; | ||
has int8 $.BytesPerPixel; | ||
has int8 $.Rloss; | ||
has int8 $.Gloss; | ||
has int8 $.Bloss; | ||
has int8 $.Aloss; | ||
has int8 $.Rshift; | ||
has int8 $.Gshift; | ||
has int8 $.Bshift; | ||
has int8 $.Ashift; | ||
#~ has uint32 $.Rmask; | ||
#~ has uint32 $.Gmask; | ||
#~ has uint32 $.Bmask; | ||
#~ has uint32 $.Amask; | ||
#~ has uint32 $.colorkey; | ||
has int32 $.Rmask; | ||
has int32 $.Gmask; | ||
has int32 $.Bmask; | ||
has int32 $.Amask; | ||
has int32 $.colorkey; | ||
#~ has uint8 $.alpha; | ||
has int8 $.alpha; |
Oops, something went wrong.