Permalink
Browse files

Rewrite all bindings, and expose libSDL's function/struct names

With this one will get all structures and functions that the C library offers
by doing `use SDL`. The sugar-coated classes will be in the SDLx namespace
only. But I've removed these for now, since the existing code was created
before NativeCall was able to unpack C Structures properly. So it was awkward
anyway and not much of a loss.
  • Loading branch information...
FROGGS committed Apr 25, 2018
1 parent 432bc30 commit dbbd8fdca02d179231385508b4ea79760f14d6d4
View
@@ -0,0 +1 @@
+lib/.precomp/
View
@@ -1,29 +1,14 @@
{
"perl" : "6.*",
"name" : "SDL",
- "version" : "0.1.0",
+ "version" : "0.2.0",
"description" : "A Perl 6 wrapper around SDL 1.2",
"depends" : [ ],
"provides" : {
- "SDL" : "lib/SDL.pm6",
- "SDL::Version" : "lib/SDL/Version.pm6",
- "SDL::CStructs" : "lib/SDL/CStructs.pm6",
- "SDL::PixelFormat" : "lib/SDL/PixelFormat.pm6",
- "SDL::Palette" : "lib/SDL/Palette.pm6",
- "SDL::SFont" : "lib/SDL/SFont.pm6",
- "SDL::Video" : "lib/SDL/Video.pm6",
- "SDL::Surface" : "lib/SDL/Surface.pm6",
- "SDL::Surfacish" : "lib/SDL/Surfacish.pm6",
- "SDL::App" : "lib/SDL/App.pm6",
- "SDL::Rect" : "lib/SDL/Rect.pm6",
- "SDL::SDL_video" : "lib/SDL/SDL_video.pm",
- "SDL::Mixer" : "lib/SDL/Mixer.pm6",
- "SDL::Mixer::Samples" : "lib/SDL/Mixer/Samples.pm6",
- "SDL::Mixer::Effects" : "lib/SDL/Mixer/Effects.pm6",
- "SDL::Mixer::Channels" : "lib/SDL/Mixer/Channels.pm6",
- "SDL::Event" : "lib/SDL/Event.pm6",
- "SDL::Controller" : "lib/SDL/Controller.pm6",
- "SDL::Color" : "lib/SDL/Color.pm"
+ "SDL" : "lib/SDL.pm6",
+ "SDL::Constants" : "lib/SDL/Constants.pm6",
+ "SDL::Functions" : "lib/SDL/Functions.pm6",
+ "SDL::Structures" : "lib/SDL/Structures.pm6"
},
"source-url" : "git://github.com/PerlGameDev/SDL6.git"
}
View
6 README
@@ -1,6 +0,0 @@
-This module provides access to the Simple DirectMedia Layer (www.libsdl.org) to Perl6. The hope is for this
-module to be implemented in pure Perl 6.
-
-## Dependencies
-
- - libSDL, libSDL-mixer
View
@@ -0,0 +1,12 @@
+This module provides access to the Simple DirectMedia Layer (www.libsdl.org) to Perl6.
+
+It makes use of NativeCall, so a C compiler is not needed in order to install this module.
+
+## Dependencies
+
+ - libSDL, libSDL-mixer, libSDL-image
+
+To aid NativeCall locating the libaries you should just do:
+```bash
+sudo apt install libsdl1.2-dev libsdl-mixer1.2-dev libsdl-image1.2-dev
+```
View

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -1,16 +0,0 @@
-unit module SDL::App;
-
-use NativeCall;
-use SDL::Controller;
-use SDL::Surface;
-use SDL::Surfacish;
-
-class SDL::App is SDL::Controller does SDL::Surfacish {
- method new( $w, $h, $bpp, $flags ) {
- self.bless: surface => SDL::Surface::_set_video_mode( $w, $h, $bpp, $flags )
- }
-
- method FALLBACK($name, |c) {
- $!surface."$name"(|c)
- }
-}
View
@@ -1,181 +0,0 @@
-
-use NativeCall;
-# 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;
-
-class SDL_Color is repr('CStruct') { # typedef struct SDL_Color {
- has uint8 $.r; # Uint8 r;
- has uint8 $.g; # Uint8 g;
- has uint8 $.b; # Uint8 b;
- has uint8 $.unused; # Uint8 unused;
-} # } SDL_Color;
-constant SDL_Colour = SDL_Color; #define SDL_Colour SDL_Color
-
-class SDL_Palette is repr('CStruct') { # typedef struct SDL_Palette {
- has int32 $.ncolors; # int ncolors;
- has Pointer[SDL_Color] $.colors; # SDL_Color *colors;
-} # } SDL_Palette;
-
-#~ /** Everything in the pixel format structure is read-only */
-class SDL_PixelFormat is repr('CStruct') { # typedef struct SDL_PixelFormat {
- has SDL_Palette $.palette; # SDL_Palette *palette;
- has uint8 $.BitsPerPixel; # Uint8 BitsPerPixel;
- has uint8 $.BytesPerPixel; # Uint8 BytesPerPixel;
- has uint8 $.Rloss; # Uint8 Rloss;
- has uint8 $.Gloss; # Uint8 Gloss;
- has uint8 $.Bloss; # Uint8 Bloss;
- has uint8 $.Aloss; # Uint8 Aloss;
- has uint8 $.Rshift; # Uint8 Rshift;
- has uint8 $.Gshift; # Uint8 Gshift;
- has uint8 $.Bshift; # Uint8 Bshift;
- has uint8 $.Ashift; # Uint8 Ashift;
- has uint32 $.Rmask; # Uint32 Rmask;
- has uint32 $.Gmask; # Uint32 Gmask;
- has uint32 $.Bmask; # Uint32 Bmask;
- has uint32 $.Amask; # Uint32 Amask;
- # /** RGB color key information */
- has uint32 $.colorkey; # Uint32 colorkey;
- # /** Alpha value information (per-surface alpha) */
- has uint8 $.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.
- #~ */
-class SDL_Surface is repr('CStruct') { # typedef struct SDL_Surface {
- has uint32 $.flags; # Uint32 flags; /**< Read-only */
- has SDL_PixelFormat $.format; # SDL_PixelFormat *format; /**< Read-only */
- has int32 $.w; has int32 $.h; # int w, h; /**< Read-only */
- has uint16 $.pitch; # Uint16 pitch; /**< Read-only */
- has Pointer $.pixels; # void *pixels; /**< Read-write */
- has int32 $.offset; # int offset; /**< Private */
- # /** Hardware-specific surface info */
- has Pointer $.hwdata; # struct private_hwdata *hwdata;
- # /** clipping information */
- HAS SDL_Rect $.clip_rect; # SDL_Rect clip_rect; /**< Read-only */
- has uint32 $.unused1; # Uint32 unused1; /**< for binary compatibility */
- # /** Allow recursive locks */
- has uint32 $.locked; # Uint32 locked; /**< Private */
- # /** info for fast blit mapping to other surfaces */
- has Pointer $.map; # struct SDL_BlitMap *map; /**< Private */
- # /** format version, bumped at every change to invalidate blit maps */
- has uint32 $.format_version; # unsigned int format_version; /**< Private */
- # /** Reference count -- used when freeing surface */
- has int32 $.refcount; # 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;
View
@@ -1,11 +0,0 @@
-
-unit 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;
Oops, something went wrong.

0 comments on commit dbbd8fd

Please sign in to comment.