From 5d51058513094e044bae4c396a482d8514c00b0c Mon Sep 17 00:00:00 2001 From: Juerg Billeter Date: Fri, 21 Mar 2008 19:15:02 +0000 Subject: [PATCH] add SDL bindings, patch by Levi Bard, fixes bug 522940 2008-03-21 Juerg Billeter * vapi/Makefile.am, vapi/sdl-gfx.vapi, vapi/sdl-image.vapi, vapi/sdl-mixer.vapi, vapi/sdl-ttf.vapi, vapi/sdl.vapi: add SDL bindings, patch by Levi Bard, fixes bug 522940 svn path=/trunk/; revision=1147 --- ChangeLog | 6 + vapi/Makefile.am | 5 + vapi/sdl-gfx.vapi | 428 ++++++++++++++++++++ vapi/sdl-image.vapi | 87 ++++ vapi/sdl-mixer.vapi | 220 ++++++++++ vapi/sdl-ttf.vapi | 114 ++++++ vapi/sdl.vapi | 1123 +++++++++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 1983 insertions(+) create mode 100644 vapi/sdl-gfx.vapi create mode 100644 vapi/sdl-image.vapi create mode 100644 vapi/sdl-mixer.vapi create mode 100644 vapi/sdl-ttf.vapi create mode 100644 vapi/sdl.vapi diff --git a/ChangeLog b/ChangeLog index 776430a..f92435f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2008-03-21 Jürg Billeter + * vapi/Makefile.am, vapi/sdl-gfx.vapi, vapi/sdl-image.vapi, + vapi/sdl-mixer.vapi, vapi/sdl-ttf.vapi, vapi/sdl.vapi: add SDL + bindings, patch by Levi Bard, fixes bug 522940 + +2008-03-21 Jürg Billeter + * vala/valasemanticanalyzer.vala: report error when trying to declare private construct properties, patch by Daniel Silverstone, fixes bug 522685 diff --git a/vapi/Makefile.am b/vapi/Makefile.am index 406ce37..575b1e1 100644 --- a/vapi/Makefile.am +++ b/vapi/Makefile.am @@ -104,6 +104,11 @@ dist_vapi_DATA = \ pangocairo.vapi \ poppler-glib.deps \ poppler-glib.vapi \ + sdl.vapi \ + sdl-gfx.vapi \ + sdl-image.vapi \ + sdl-mixer.vapi \ + sdl-ttf.vapi \ sqlite3.vapi \ taglib_c.vapi \ vala-1.0.vapi \ diff --git a/vapi/sdl-gfx.vapi b/vapi/sdl-gfx.vapi new file mode 100644 index 0000000..b73c56c --- /dev/null +++ b/vapi/sdl-gfx.vapi @@ -0,0 +1,428 @@ +using GLib; +using SDL; + +namespace SDLGraphics { + [CCode (cheader_filename="SDL_gfxPrimitives.h")] + public class Pixel { + [CCode (cname="pixelColor")] + public static int color(Surface dst, int16 x, int16 y, uint32 color); + + [CCode (cname="pixelRGBA")] + public static int rgba(Surface dst, int16 x, int16 y, + uchar r, uchar g, uchar b, uchar a); + }// Pixel + + [CCode (cheader_filename="SDL_gfxPrimitives.h")] + public class Line { + [CCode (cname="hlineColor")] + public static int color_h(Surface dst, int16 x1, int16 x2, + int16 y, uint32 color); + + [CCode (cname="hlineRGBA")] + public static int rgba_h(Surface dst, int16 x1, int16 x2, + int16 y, uchar r, uchar g, uchar b, uchar a); + + [CCode (cname="vlineColor")] + public static int color_v(Surface dst, int16 x, int16 y1, + int16 y2, uint32 color); + + [CCode (cname="vlineRGBA")] + public static int rgba_v(Surface dst, int16 x, int16 y1, + int16 y2, uchar r, uchar g, uchar b, uchar a); + + [CCode (cname="lineColor")] + public static int color(Surface dst, int16 x1, int16 y1, + int16 x2, int16 y2, uint32 color); + + [CCode (cname="lineRGBA")] + public static int rgba(Surface dst, int16 x1, int16 y1, + int16 x2, int16 y2, uchar r, uchar g, uchar b, uchar a); + + [CCode (cname="aalineColor")] + public static int color_aa(Surface dst, int16 x1, int16 y1, + int16 x2, int16 y2, uint32 color); + + [CCode (cname="aalineRGBA")] + public static int rgba_aa(Surface dst, int16 x1, int16 y1, + int16 x2, int16 y2, uchar r, uchar g, uchar b, uchar a); + }// Line + + [CCode (cheader_filename="SDL_gfxPrimitives.h")] + public class Rectangle { + [CCode (cname="rectangleColor")] + public static int outline_color(Surface dst, int16 x1, int16 y1, + int16 x2, int16 y2, uint32 color); + + [CCode (cname="rectangleRGBA")] + public static int outline_rgba(Surface dst, int16 x1, int16 y1, + int16 x2, int16 y2, uchar r, uchar g, uchar b, uchar a); + + [CCode (cname="boxColor")] + public static int fill_color(Surface dst, int16 x1, int16 y1, + int16 x2, int16 y2, uint32 color); + + [CCode (cname="boxRGBA")] + public static int fill_rgba(Surface dst, int16 x1, int16 y1, + int16 x2, int16 y2, uchar r, uchar g, uchar b, uchar a); + }// Rectangle + + [CCode (cheader_filename="SDL_gfxPrimitives.h")] + public class Circle { + [CCode (cname="circleColor")] + public static int outline_color(Surface dst, int16 x, int16 y, + int16 radius, uint32 color); + + [CCode (cname="circleRGBA")] + public static int outline_rgba(Surface dst, int16 x, int16 y, int16 radius, + uchar r, uchar g, uchar b, uchar a); + + [CCode (cname="aacircleColor")] + public static int outline_color_aa(Surface dst, int16 x, int16 y, + int16 radius, uint32 color); + + [CCode (cname="aacircleRGBA")] + public static int outline_rgba_aa(Surface dst, int16 x, int16 y, int16 radius, + uchar r, uchar g, uchar b, uchar a); + + [CCode (cname="filledCircleColor")] + public static int fill_color(Surface dst, int16 x, int16 y, + int16 radius, uint32 color); + + [CCode (cname="filledCircleRGBA")] + public static int fill_rgba(Surface dst, int16 x, int16 y, int16 radius, + uchar r, uchar g, uchar b, uchar a); + }// Circle + + [CCode (cheader_filename="SDL_gfxPrimitives.h")] + public class Ellipse { + [CCode (cname="ellipseColor")] + public static int outline_color(Surface dst, int16 xc, int16 yc, + int16 rx, int16 ry, uint32 color); + + [CCode (cname="ellipseRGBA")] + public static int outline_rgba(Surface dst, int16 xc, int16 yc, + int16 rx, int16 ry, uchar r, uchar g, uchar b, uchar a); + + [CCode (cname="aaellipseColor")] + public static int outline_color_aa(Surface dst, int16 xc, int16 yc, + int16 rx, int16 ry, uint32 color); + + [CCode (cname="aaellipseRGBA")] + public static int outline_rgba_aa(Surface dst, int16 xc, int16 yc, + int16 rx, int16 ry, uchar r, uchar g, uchar b, uchar a); + + [CCode (cname="filledEllipseColor")] + public static int fill_color(Surface dst, int16 xc, int16 yc, + int16 rx, int16 ry, uint32 color); + + [CCode (cname="filledEllipseRGBA")] + public static int fill_rgba(Surface dst, int16 xc, int16 yc, + int16 rx, int16 ry, uchar r, uchar g, uchar b, uchar a); + }// Ellipse + + [CCode (cheader_filename="SDL_gfxPrimitives.h")] + public class Arc { + [CCode (cname="pieColor")] + public static int outline_color(Surface dst, int16 x, int16 y, int16 radius, + int16 start, int16 end, uint32 color); + + [CCode (cname="pieRGBA")] + public static int outline_rgba(Surface dst, int16 x, int16 y, int16 radius, + int16 start, int16 end, uchar r, uchar g, uchar b, uchar a); + + [CCode (cname="filledPieColor")] + public static int fill_color(Surface dst, int16 x, int16 y, int16 radius, + int16 start, int16 end, uint32 color); + + [CCode (cname="filledPieRGBA")] + public static int fill_rgba(Surface dst, int16 x, int16 y, int16 radius, + int16 start, int16 end, uchar r, uchar g, uchar b, uchar a); + }// Arc + + [CCode (cheader_filename="SDL_gfxPrimitives.h")] + public class Trigon { + [CCode (cname="trigonColor")] + public static int outline_color(Surface dst, int16 x1, int16 y1, + int16 x2, int16 y2, int16 x3, int16 y3, uint32 color); + + [CCode (cname="trigonRGBA")] + public static int outline_rgba(Surface dst, int16 x1, int16 y1, + int16 x2, int16 y2, int16 x3, int16 y3, + uchar r, uchar g, uchar b, uchar a); + + [CCode (cname="aatrigonColor")] + public static int outline_color_aa(Surface dst, int16 x1, int16 y1, + int16 x2, int16 y2, int16 x3, int16 y3, uint32 color); + + [CCode (cname="aatrigonRGBA")] + public static int outline_rgba_aa(Surface dst, int16 x1, int16 y1, + int16 x2, int16 y2, int16 x3, int16 y3, + uchar r, uchar g, uchar b, uchar a); + + [CCode (cname="filledTrigonColor")] + public static int fill_color(Surface dst, int16 x1, int16 y1, + int16 x2, int16 y2, int16 x3, int16 y3, uint32 color); + + [CCode (cname="filledTrigonRGBA")] + public static int fill_rgba(Surface dst, int16 x1, int16 y1, + int16 x2, int16 y2, int16 x3, int16 y3, + uchar r, uchar g, uchar b, uchar a); + }// Trigon + + [CCode (cheader_filename="SDL_gfxPrimitives.h")] + public class Polygon { + [CCode (cname="polygonColor")] + [NoArrayLength] + public static int outline_color(Surface dst, int16[] vx, int16[] vy, + int n, uint32 color); + + [CCode (cname="polygonRGBA")] + [NoArrayLength] + public static int outline_rgba(Surface dst, int16[] vx, int16[] vy, + int n, uchar r, uchar g, uchar b, uchar a); + + [CCode (cname="aapolygonColor")] + [NoArrayLength] + public static int outline_color_aa(Surface dst, int16[] vx, int16[] vy, + int n, uint32 color); + + [CCode (cname="aapolygonRGBA")] + [NoArrayLength] + public static int outline_rgba_aa(Surface dst, int16[] vx, int16[] vy, + int n, uchar r, uchar g, uchar b, uchar a); + + [CCode (cname="filledPolygonColor")] + [NoArrayLength] + public static int fill_color(Surface dst, int16[] vx, int16[] vy, + int n, uint32 color); + + [CCode (cname="filledPolygonRGBA")] + [NoArrayLength] + public static int fill_rgba(Surface dst, int16[] vx, int16[] vy, + int n, uchar r, uchar g, uchar b, uchar a); + }// Polygon + + [CCode (cheader_filename="SDL_gfxPrimitives.h")] + public class BezierCurve { + [CCode (cname="bezierColor")] + [NoArrayLength] + public static int color(Surface dst, int16[] vx, int16[] vy, + int vertices, int steps, uint32 color); + + [CCode (cname="bezierRGBA")] + [NoArrayLength] + public static int rgba(Surface dst, int16[] vx, int16[] vy, + int vertices, int steps, uchar r, uchar g, uchar b, uchar a); + }// BezierCurve + + [CCode (cheader_filename="SDL_gfxPrimitives.h")] + public class Text { + [CCode (cname="stringColor")] + public static int color(Surface dst, int16 x, int16 y, string s, uint32 color); + + [CCode (cname="stringRGBA")] + public static int rgba(Surface dst, int16 x, int16 y, string s, + uchar r, uchar g, uchar b, uchar a); + + [CCode (cname="gfxPrimitivesSetFont")] + public static int set_font(pointer fontdata, int cw, int ch); + }// Text + + [CCode (cheader_filename="SDL_rotozoom.h")] + public class RotoZoom { + [CCode (cname="rotozoomSurface")] + public static Surface rotozoom(Surface src, double degrees, + double zoom, int smooth); + + [CCode (cname="rotozoomSurfaceXY")] + public static Surface rotozoom_xy(Surface src, double degrees, + double zoomx, double zoomy, int smooth); + + [CCode (cname="rotozoomSurfaceSize")] + public static void rotozoom_size(int width, int height, double degrees, + double zoom, ref int dstwidth, ref int dstheight); + + [CCode (cname="rotozoomSurfaceSizeXY")] + public static void rotozoom_size_xy(int width, int height, double degrees, + double zoomx, double zoomy, ref int dstwidth, ref int dstheight); + + [CCode (cname="zoomSurface")] + public static Surface zoom(Surface src, double zoomx, + double zoomy, int smooth); + + [CCode (cname="zoomSurfaceSize")] + public static void zoom_size(int width, int height, double zoomx, + double zoomy, ref int dstwidth, ref int dstheight); + }// RotoZoom + + [CCode (cheader_filename="SDL_framerate.h", cname="FPSmanager", free_function="g_free")] + public class FramerateManager { + [CCode (cname="SDL_initFramerate")] + public void init(); + + [CCode (cname="SDL_setFramerate")] + public int set_rate(int rate); + + [CCode (cname="SDL_getFramerate")] + public int get_rate(); + + [CCode (cname="SDL_framerateDelay")] + public void run(); + }// FramerateManager + + [CCode (cheader_filename="SDL_imageFilter.h")] + public class Filter { + [CCode (cname="SDL_imageFilterMMXdetect")] + public static int have_mmx(); + + [CCode (cname="SDL_imageFilterMMXon")] + public static void enable_mmx(); + + [CCode (cname="SDL_imageFilterMMXoff")] + public static void disable_mmx(); + + [CCode (cname="SDL_imageFilterAdd")] + [NoArrayLength] + public static int add(uchar[] src1, uchar[] src2, uchar[] dst, int length); + + [CCode (cname="SDL_imageFilterMean")] + [NoArrayLength] + public static int mean(uchar[] src1, uchar[] src2, uchar[] dst, int length); + + [CCode (cname="SDL_imageFilterSub")] + [NoArrayLength] + public static int subtract(uchar[] src1, uchar[] src2, uchar[] dst, int length); + + [CCode (cname="SDL_imageFilterAbsDiff")] + [NoArrayLength] + public static int absolute_difference(uchar[] src1, uchar[] src2, uchar[] dst, int length); + + [CCode (cname="SDL_imageFilterMult")] + [NoArrayLength] + public static int multiply(uchar[] src1, uchar[] src2, uchar[] dst, int length); + + [CCode (cname="SDL_imageFilterMultNor")] + [NoArrayLength] + public static int multiply_normalized(uchar[] src1, uchar[] src2, uchar[] dst, int length); + + [CCode (cname="SDL_imageFilterMultDivby2")] + [NoArrayLength] + public static int multiply_half(uchar[] src1, uchar[] src2, uchar[] dst, int length); + + [CCode (cname="SDL_imageFilterMultDivby4")] + [NoArrayLength] + public static int multiply_quarter(uchar[] src1, uchar[] src2, uchar[] dst, int length); + + [CCode (cname="SDL_imageFilterBitAnd")] + [NoArrayLength] + public static int and(uchar[] src1, uchar[] src2, uchar[] dst, int length); + + [CCode (cname="SDL_imageFilterBitOr")] + [NoArrayLength] + public static int or(uchar[] src1, uchar[] src2, uchar[] dst, int length); + + [CCode (cname="SDL_imageFilterDiv")] + [NoArrayLength] + public static int divide(uchar[] src1, uchar[] src2, uchar[] dst, int length); + + [CCode (cname="SDL_imageFilterBitNegation")] + [NoArrayLength] + public static int negate(uchar[] src1, uchar[] dst, int length); + + [CCode (cname="SDL_imageFilterAddByte")] + [NoArrayLength] + public static int add_uchar(uchar[] src1, uchar[] dst, int length, uchar addend); + + [CCode (cname="SDL_imageFilterAddUint")] + [NoArrayLength] + public static int add_uint(uchar[] src1, uchar[] dst, int length, uint addend); + + [CCode (cname="SDL_imageFilterAddByteToHalf")] + [NoArrayLength] + public static int halve_add_uchar(uchar[] src1, uchar[] dst, int length, uchar addend); + + [CCode (cname="SDL_imageFilterSubByte")] + [NoArrayLength] + public static int subtract_uchar(uchar[] src1, uchar[] dst, int length, uchar subtrahend); + + [CCode (cname="SDL_imageFilterSubUint")] + [NoArrayLength] + public static int subtract_uint(uchar[] src1, uchar[] dst, int length, uint subtrahend); + + [CCode (cname="SDL_imageFilterShiftRight")] + [NoArrayLength] + public static int shift_right_uchar(uchar[] src1, uchar[] dst, int length, uchar shiftcount); + + [CCode (cname="SDL_imageFilterShiftRightUint")] + [NoArrayLength] + public static int shift_right_uint(uchar[] src1, uchar[] dst, int length, uint shiftcount); + + [CCode (cname="SDL_imageFilterMultByByte")] + [NoArrayLength] + public static int multiply_uchar(uchar[] src1, uchar[] dst, int length, uchar multiplicand); + + [CCode (cname="SDL_imageFilterShiftRightAndMultByByte")] + [NoArrayLength] + public static int shift_right_multiply_uchar(uchar[] src1, uchar[] dst, int length, uchar shiftcount, uchar multiplicand); + + [CCode (cname="SDL_imageFilterShiftLeftByte")] + [NoArrayLength] + public static int shift_left_uchar(uchar[] src1, uchar[] dst, int length, uchar shiftcount); + + [CCode (cname="SDL_imageFilterShiftLeftUint")] + [NoArrayLength] + public static int shift_left_uint(uchar[] src1, uchar[] dst, int length, uint shiftcount); + + [CCode (cname="SDL_imageFilterBinarizeUsingThreshold")] + [NoArrayLength] + public static int binarize(uchar[] src1, uchar[] dst, int length, uchar threshold); + + [CCode (cname="SDL_imageFilterClipToRange")] + [NoArrayLength] + public static int clip(uchar[] src1, uchar[] dst, int length, uchar min, uchar max); + + [CCode (cname="SDL_imageFilterNormalize")] + [NoArrayLength] + public static int normalize(uchar[] src1, uchar[] dst, int length, int cmin, int cmax, int nmin, int nmax); + + [CCode (cname="SDL_imageFilterConvolveKernel3x3Divide")] + [NoArrayLength] + public static int convolve_3x3_divide(uchar[] src1, uchar[] dst, int rows, int columns, int16[] kernel, uchar divisor); + + [CCode (cname="SDL_imageFilterConvolveKernel5x5Divide")] + [NoArrayLength] + public static int convolve_5x5_divide(uchar[] src1, uchar[] dst, int rows, int columns, int16[] kernel, uchar divisor); + + [CCode (cname="SDL_imageFilterConvolveKernel7x7Divide")] + [NoArrayLength] + public static int convolve_7x7_divide(uchar[] src1, uchar[] dst, int rows, int columns, int16[] kernel, uchar divisor); + + [CCode (cname="SDL_imageFilterConvolveKernel9x9Divide")] + [NoArrayLength] + public static int convolve_9x9_divide(uchar[] src1, uchar[] dst, int rows, int columns, int16[] kernel, uchar divisor); + + [CCode (cname="SDL_imageFilterConvolveKernel3x3ShiftRight")] + [NoArrayLength] + public static int convolve_3x3_shift(uchar[] src1, uchar[] dst, int rows, int columns, int16[] kernel, uchar shiftcount); + + [CCode (cname="SDL_imageFilterConvolveKernel5x5ShiftRight")] + [NoArrayLength] + public static int convolve_5x5_shift(uchar[] src1, uchar[] dst, int rows, int columns, int16[] kernel, uchar shiftcount); + + [CCode (cname="SDL_imageFilterConvolveKernel7x7ShiftRight")] + [NoArrayLength] + public static int convolve_7x7_shift(uchar[] src1, uchar[] dst, int rows, int columns, int16[] kernel, uchar shiftcount); + + [CCode (cname="SDL_imageFilterConvolveKernel9x9ShiftRight")] + [NoArrayLength] + public static int convolve_9x9_shift(uchar[] src1, uchar[] dst, int rows, int columns, int16[] kernel, uchar shiftcount); + + [CCode (cname="SDL_imageFilterSobelX")] + [NoArrayLength] + public static int sobel(uchar[] src1, uchar[] dst, int rows, int columns); + + [CCode (cname="SDL_imageFilterSobelXShiftRight")] + [NoArrayLength] + public static int sobel_shift(uchar[] src1, uchar[] dst, int rows, int columns, uchar shiftcount); + }// Filter +}// SDLGraphics diff --git a/vapi/sdl-image.vapi b/vapi/sdl-image.vapi new file mode 100644 index 0000000..d5b46ba --- /dev/null +++ b/vapi/sdl-image.vapi @@ -0,0 +1,87 @@ +using GLib; +using SDL; + +[CCode (cheader_filename="SDL_image.h")] +namespace SDLImage { + [CCode (cname="IMG_Linked_Version")] + public static weak Version linked(); + + [CCode (cname="IMG_LoadTyped_RW")] + public static Surface load_rw_typed(RWops src, int freesrc=0, string type); + + [CCode (cname="IMG_Load_RW")] + public static Surface load_rw(RWops src, int freesrc=0); + + [CCode (cname="IMG_Load")] + public static Surface load(string file); + + [CCode (cname="IMG_isBMP")] + public static int is_bmp(RWops src); + + [CCode (cname="IMG_isGIF")] + public static int is_gif(RWops src); + + [CCode (cname="IMG_isJPG")] + public static int is_jpg(RWops src); + + [CCode (cname="IMG_isLBM")] + public static int is_lbm(RWops src); + + [CCode (cname="IMG_isPCX")] + public static int is_pcx(RWops src); + + [CCode (cname="IMG_isPNG")] + public static int is_png(RWops src); + + [CCode (cname="IMG_isPNM")] + public static int is_pnm(RWops src); + + [CCode (cname="IMG_isTIF")] + public static int is_tif(RWops src); + + [CCode (cname="IMG_isXCF")] + public static int is_xcf(RWops src); + + [CCode (cname="IMG_isXPM")] + public static int is_xpm(RWops src); + + [CCode (cname="IMG_isXV")] + public static int is_xv(RWops src); + + + [CCode (cname="IMG_LoadBMP_RW")] + public static Surface load_bmp(RWops src); + + [CCode (cname="IMG_LoadGIF_RW")] + public static Surface load_gif(RWops src); + + [CCode (cname="IMG_LoadJPG_RW")] + public static Surface load_jpg(RWops src); + + [CCode (cname="IMG_LoadLBM_RW")] + public static Surface load_lbm(RWops src); + + [CCode (cname="IMG_LoadPCX_RW")] + public static Surface load_pcx(RWops src); + + [CCode (cname="IMG_LoadPNG_RW")] + public static Surface load_png(RWops src); + + [CCode (cname="IMG_LoadPNM_RW")] + public static Surface load_pnm(RWops src); + + [CCode (cname="IMG_LoadTIF_RW")] + public static Surface load_tif(RWops src); + + [CCode (cname="IMG_LoadXCF_RW")] + public static Surface load_xcf(RWops src); + + [CCode (cname="IMG_LoadXPM_RW")] + public static Surface load_xpm(RWops src); + + [CCode (cname="IMG_ReadXPMFromArray")] + public static Surface read_xpm(pointer xpmdata); + + [CCode (cname="IMG_LoadXV_RW")] + public static Surface load_xv(RWops src); +}// SDLImage diff --git a/vapi/sdl-mixer.vapi b/vapi/sdl-mixer.vapi new file mode 100644 index 0000000..0f17bcc --- /dev/null +++ b/vapi/sdl-mixer.vapi @@ -0,0 +1,220 @@ +using GLib; +using SDL; + +[CCode (cheader_filename="SDL_mixer.h")] +namespace SDLMixer { + [CCode (cname="Mix_Linked_Version")] + public static weak Version linked(); + + [CCode (cname="Mix_OpenAudio")] + public static int open(int frequency, uint16 format, int channels, int chunksize); + + [CCode (cname="Mix_CloseAudio")] + public static void close(); + + [CCode (cname="Mix_QuerySpec")] + public static int query(ref int frequency, ref uint16 format, ref int channels); + + [CCode (cname="Mix_SetPostMix")] + public static void set_post_mixer(MixFunction f, pointer arg); + + [CCode (cname="Mix_SetSynchroValue")] + public static int set_synchro_value(int value); + + [CCode (cname="Mix_GetSynchroValue")] + public static int get_synchro_value(); + + public delegate void MixFunction(pointer udata, uchar[] stream); + public delegate void MusicFinishedCallback(); + public delegate void ChannelFinishedCallback(int channel); + public delegate void EffectCallback(int chan, pointer stream, int len, pointer udata); + public delegate void EffectDoneCallback(int chan, pointer udata); + + [CCode (cprefix="MIX_")] + public enum FadeStatus { + NO_FADING, FADING_OUT, FADING_IN + }// FadeStatus + + [CCode (cprefix="MUS_")] + public enum MusicType { + NONE, CMD, WAV, MOD, MID, OGG, MP3, MP3_MAD + }// MusicType + + [CCode (cname="Mix_Chunk", free_function="Mix_FreeChunk")] + public class Chunk { + [CCode (cname="Mix_LoadWAV_RW")] + public Chunk.WAV(RWops src, int freesrc=0); + + [CCode (cname="Mix_QuickLoad_WAV")] + [NoArrayLength] + public Chunk.QuickWAV(uchar[] mem); + + [CCode (cname="Mix_QuickLoad_RAW")] + public Chunk.QuickRAW(uchar[] mem); + + [CCode (cname="Mix_VolumeChunk")] + public int volume(int num); + }// Chunk + + [CCode (cname="Mix_Music", free_function="Mix_FreeMusic")] + public class Music { + [CCode (cname="Mix_GetMusicHookData")] + public static pointer get_hook_data(); + + [CCode (cname="Mix_HookMusic")] + public static void hook_mixer(MixFunction f, pointer arg); + + [CCode (cname="Mix_HookMusicFinished")] + public static void hook_finished(MusicFinishedCallback cb); + + [CCode (cname="Mix_FadeOutMusic")] + public static int fade_out(int ms); + + [CCode (cname="Mix_FadingMusic")] + public static FadeStatus is_fading(); + + [CCode (cname="Mix_VolumeMusic")] + public static int volume(int num); + + [CCode (cname="Mix_HaltMusic")] + public static int halt(); + + [CCode (cname="Mix_PauseMusic")] + public static void pause(); + + [CCode (cname="Mix_ResumeMusic")] + public static void resume(); + + [CCode (cname="Mix_RewindMusic")] + public static void rewind(); + + [CCode (cname="Mix_PausedMusic")] + public static int is_paused(); + + [CCode (cname="Mix_SetMusicPosition")] + public static int position(double position); + + [CCode (cname="Mix_PlayingMusic")] + public static int is_playing(); + + [CCode (cname="Mix_SetMusicCMD")] + public static int set_play_command(string command); + + [CCode (cname="Mix_LoadMUS")] + public Music(string file); + + [CCode (cname="Mix_LoadMUS_RW")] + public Music.RW(RWops rw); + + [CCode (cname="Mix_GetMusicType")] + public MusicType type(); + + [CCode (cname="Mix_PlayMusic")] + public int play(int loops); + + [CCode (cname="Mix_FadeInMusicPos")] + public int fade_in(int loops, int ms, double position=0.0); + }// Music + + public class Effect { + [CCode (cname="Mix_RegisterEffect")] + public static int register(int chan, EffectCallback f, + EffectDoneCallback d, pointer arg); + + [CCode (cname="Mix_UnregisterEffect")] + public static int unregister(int chan, EffectCallback f); + + [CCode (cname="Mix_UnregisterAllEffects")] + public static int unregister_all(int channel); + }// Effect + + [CCode (cname="int")] + [SimpleType] + public struct Channel: int { + [CCode (cname="Mix_AllocateChannels")] + public static int allocate(int num_channels); + + [CCode (cname="Mix_ReserveChannels")] + public static int reserve(int num_channels); + + [CCode (cname="Mix_ChannelFinished")] + public static void hook_finished(ChannelFinishedCallback cb); + + [CCode (cname="Mix_SetPanning")] + public int pan(uchar left, uchar right); + + [CCode (cname="Mix_SetPosition")] + public int position(int16 degrees, uchar distance); + + [CCode (cname="Mix_SetDistance")] + public int distance(uchar distance); + + [CCode (cname="Mix_SetReverseStereo")] + public int reverse_stereo(int flip); + + [CCode (cname="Mix_PlayChannelTimed")] + public int play(Chunk chunk, int loops, int ticks=-1); + + [CCode (cname="Mix_FadeInChannelTimed")] + public int fade_in(Chunk chunk, int loops, int ms, int ticks=-1); + + [CCode (cname="Mix_FadeOutChannelTimed")] + public int fade_out(int ms); + + [CCode (cname="Mix_FadingChannel")] + public FadeStatus is_fading(); + + [CCode (cname="Mix_Volume")] + public int volume(int num); + + [CCode (cname="Mix_HaltChannel")] + public int halt(); + + [CCode (cname="Mix_ExpireChannel")] + public int expire(int ticks); + + [CCode (cname="Mix_Pause")] + public void pause(); + + [CCode (cname="Mix_Paused")] + public int is_paused(); + + [CCode (cname="Mix_Resume")] + public void resume(); + + [CCode (cname="Mix_Playing")] + public int is_playing(); + + [CCode (cname="Mix_GetChunk")] + public Chunk get_chunk(); + }// Channel + + [CCode (cname="int")] + [SimpleType] + public struct ChannelGroup: int { + [CCode (cname="Mix_GroupChannel")] + public static int add(int channel, int group); + + [CCode (cname="Mix_GroupChannels")] + public static int add_range(int from_channel, int to_channel, int group); + + [CCode (cname="Mix_GroupAvailable")] + public int first_available(); + + [CCode (cname="Mix_GroupCount")] + public int count(); + + [CCode (cname="Mix_GroupOldest")] + public int oldest(); + + [CCode (cname="Mix_GroupNewer")] + public int newest(); + + [CCode (cname="Mix_HaltGroup")] + public int halt(); + + [CCode (cname="Mix_FadeOutGroup")] + public int fade_out(int ms); + }// ChannelGroup + +}// SDLMixer diff --git a/vapi/sdl-ttf.vapi b/vapi/sdl-ttf.vapi new file mode 100644 index 0000000..fb6019a --- /dev/null +++ b/vapi/sdl-ttf.vapi @@ -0,0 +1,114 @@ +using GLib; +using SDL; + +[CCode (cheader_filename="SDL_ttf.h")] +namespace SDLTTF { + [CCode (cname="TTF_Linked_Version")] + public static weak Version linked(); + + [CCode (cname="TTF_ByteSwappedUNICODE")] + public static void byteswap_unicode(int swapped); + + [CCode (cname="TTF_Init")] + public static int init(); + + [CCode (cname="TTF_WasInit")] + public static int get_initialized(); + + [CCode (cname="TTF_Quit")] + public static void quit(); + + [CCode (cprefix="TTF_STYLE_")] + public enum FontStyle { + NORMAL, BOLD, ITALIC, UNDERLINE + }// FontStyle + + [CCode (cname="TTF_Font", free_function="TTF_CloseFont")] + public class Font { + [CCode (cname="TTF_OpenFont")] + public Font(string file, int ptsize); + + [CCode (cname="TTF_OpenFontIndex")] + public Font.index(string file, int ptsize, long index); + + [CCode (cname="TTF_OpenFontRW")] + public Font.RW(RWops src, int freesrc=0, int ptsize); + + [CCode (cname="TTF_OpenFontIndexRW")] + public Font.RWindex(RWops src, int freesrc=0, int ptsize, long index); + + [CCode (cname="TTF_GetFontStyle")] + public FontStyle get_style(); + + [CCode (cname="TTF_SetFontStyle")] + public FontStyle set_style(FontStyle style); + + [CCode (cname="TTF_FontHeight")] + public int height(); + + [CCode (cname="TTF_FontAscent")] + public int ascent(); + + [CCode (cname="TTF_FontDescent")] + public int descent(); + + [CCode (cname="TTF_FontLineSkip")] + public int lineskip(); + + [CCode (cname="TTF_FontFaces")] + public long faces(); + + [CCode (cname="TTF_FontFaceIsFixedWidth")] + public int is_fixed_width(); + + [CCode (cname="TTF_FontFaceFamilyName")] + public string family(); + + [CCode (cname="TTF_FontFaceStyleName")] + public string style(); + + [CCode (cname="TTF_GlyphMetrics")] + public int metrics(uint16 ch, ref int minx, ref int maxx, + ref int miny, ref int maxy, ref int advance); + + [CCode (cname="TTF_SizeText")] + public int size(string text, ref int w, ref int h); + + [CCode (cname="TTF_SizeUTF8")] + public int size_utf8(string text, ref int w, ref int h); + + [CCode (cname="TTF_SizeUNICODE")] + [NoArrayLength] + public int size_unicode(uint16[] text, ref int w, ref int h); + + [CCode (cname="TTF_RenderText_Solid")] + public Surface render(string text, Color fg); + + [CCode (cname="TTF_RenderUTF8_Solid")] + public Surface render_utf8(string text, Color fg); + + [CCode (cname="TTF_RenderUNICODE_Solid")] + [NoArrayLength] + public Surface render_unicode(uint16[] text, Color fg); + + [CCode (cname="TTF_RenderText_Shaded")] + public Surface render_shaded(string text, Color fg, Color bg); + + [CCode (cname="TTF_RenderUTF8_Shaded")] + public Surface render_shaded_utf8(string text, Color fg, Color bg); + + [CCode (cname="TTF_RenderUNICODE_Shaded")] + [NoArrayLength] + public Surface render_shaded_unicode(uint16[] text, Color fg, Color bg); + + [CCode (cname="TTF_RenderText_Blended")] + public Surface render_blended(string text, Color fg); + + [CCode (cname="TTF_RenderUTF8_Blended")] + public Surface render_blended_utf8(string text, Color fg); + + [CCode (cname="TTF_RenderUNICODE_Blended")] + [NoArrayLength] + public Surface render_blended_unicode(uint16[] text, Color fg); + }// Font +}// SDLTTF diff --git a/vapi/sdl.vapi b/vapi/sdl.vapi new file mode 100644 index 0000000..36c4aaa --- /dev/null +++ b/vapi/sdl.vapi @@ -0,0 +1,1123 @@ +using GLib; + +[CCode (cprefix="SDL_", cheader_filename="SDL.h")] +namespace SDL { + /// + /// Initialization + /// + [CCode (cprefix="SDL_INIT_")] + public enum InitFlag { + TIMER, AUDIO, VIDEO, CDROM, JOYSTICK, + NOPARACHUTE, EVENTTHREAD, EVERYTHING + }// InitFlag + + [CCode (cname="SDL_Init")] + public static int init(uint32 flags); + + [CCode (cname="SDL_InitSubSystem")] + public static int init_subsystem(uint32 flags); + + [CCode (cname="SDL_WasInit")] + public static uint32 get_initialized(uint32 flags); + + [CCode (cname="SDL_Quit")] + public static void quit(); + + [CCode (cname="SDL_QuitSubSystem")] + public static void quit_subsystem(uint32 flags); + + [CCode (type_id="SDL_version", cheader_filename="SDL_version.h", cname="SDL_version")] + public class Version { + public uchar major; + public uchar minor; + public uchar patch; + + [CCode (cheader_filename="SDL_version.h", cname="SDL_Linked_Version")] + public static weak Version linked(); + }// Version + + + /// + /// Error + /// + [CCode (cprefix="SDL_")] + public enum Error { + ENOMEM, EFREAD, EFWRITE, EFSEEK, + UNSUPPORTED, LASTERROR + }// Error + + [CCode (cname="SDL_SetError")] + public static void set_error(string format, ...); + + [CCode (cname="SDL_GetError")] + public static weak string get_error(); + + [CCode (cname="SDL_ClearError")] + public static void clear_error(); + + [CCode (cname="SDL_Error")] + public static void error(Error code); + + + /// + /// Video + /// + [CCode (cprefix="SDL_ALPHA_")] + public enum Opacity { + OPAQUE, TRANSPARENT + }// Opacity + + public class Video { + [CCode (cname="SDL_VideoDriverName")] + public static weak string driver_name(string namebuf, int maxlen); + + [CCode (cname="SDL_SetGamma")] + public static int set_gamma(float red, float green, float blue); + + [CCode (cname="SDL_SetGammaRamp")] + [NoArrayLength] + public static int set_gamma_ramp(weak uint16[] red, weak uint16[] green, weak uint16[] blue); + + [CCode (cname="SDL_GetGammaRamp")] + [NoArrayLength] + public static int get_gamma_ramp(ref uint16[] red, ref uint16[] green, ref uint16[] blue); + + [CCode (cname="SDL_ListModes")] + [NoArrayLength] + public static pointer list_modes(PixelFormat format, uint32 flags); + }// Video + + [CCode (cprefix="SDL_")] + public enum SurfaceFlag { + SWSURFACE, HWSURFACE, ASYNCBLIT, ANYFORMAT, HWPALETTE, DOUBLEBUF, + FULLSCREEN, OPENGL, OPENGLBLIT, RESIZABLE, NOFRAME, HWACCEL, + SRCCOLORKEY, RLEACCEL, SRCALPHA + }// SurfaceFlag + + [CCode (cname="SDL_Surface", free_function="SDL_FreeSurface", copy_function="SDL_DisplayFormat")] + public class Surface { + public uint32 flags; + public PixelFormat format; + public int w; + public int h; + public uint16 pitch; + public pointer pixels; + public int ref_count; + + [CCode (cname="SDL_CreateRGBSurface")] + public Surface.RGB(uint32 flags, int width, int height, int depth, + uint32 rmask, uint32 gmask, uint32 bmask, uint32 amask); + + [CCode (cname="SDL_CreateRGBSurfaceFrom")] + public Surface.from_RGB(pointer pixels, int width, int height, int depth, + int pitch, uint32 rmask, uint32 gmask, uint32 bmask, uint32 amask); + + [CCode (cname="SDL_LoadBMP_RW")] + public static Surface.load(RWops src, int freesrc=0); + + // Instance methods + [CCode (cname="SDL_UpdateRects")] + [NoArrayLength] + public void update_rects(int numrects, Rect[] rects); + + [CCode (cname="SDL_UpdateRect")] + public void update_rect(int32 x, int32 y, uint32 w, uint32 h); + + [CCode (cname="SDL_Flip")] + public int flip(); + + [CCode (cname="SDL_SetColors")] + [NoArrayLength] + public int set_colors(Color[] colors, int firstcolor, int ncolors); + + [CCode (cname="SDL_SetPalette")] + [NoArrayLength] + public int set_palette(int flags, Color[] colors, int firstcolor, int ncolors); + + [CCode (cname="SDL_LockSurface")] + public int do_lock(); + + [CCode (cname="SDL_UnlockSurface")] + public void unlock(); + + [CCode (cname="SDL_SaveBMP_RW")] + public int save(RWops dst, int freedst=0); + + [CCode (cname="SDL_SetColorKey")] + public int set_colorkey(uint32 flag, uint32 key); + + [CCode (cname="SDL_SetAlpha")] + public int set_alpha(uint32 flag, uchar alpha); + + [CCode (cname="SDL_SetClipRect")] + public bool set_cliprect(Rect rect); + + [CCode (cname="SDL_GetClipRect")] + public void get_cliprect(Rect rect); + + [CCode (cname="SDL_ConvertSurface")] + public Surface convert(PixelFormat fmt, uint32 flags); + + [CCode (cname="SDL_UpperBlit")] + public int blit(Rect srcrect, Surface dst, Rect dstrect); + + [CCode (cname="SDL_FillRect")] + public int fill(Rect dst, uint32 color); + }// Surface + + [CCode (cname="SDL_Surface")] + public class Screen: Surface { + [CCode (cname="SDL_GetVideoSurface")] + public static weak Screen instance(); + + [CCode (cname="SDL_SetVideoMode")] + public static weak Screen set_video_mode(int width, int height, int bpp, uint32 flags); + + [CCode (cname="SDL_VideoModeOK")] + public static int check_video_mode(int width, int height, int bpp, uint32 flags); + }// Screen + + [CCode (cname="SDL_PixelFormat")] + public class PixelFormat { + public Palette palette; + public uchar BitsPerPixel; + public uchar BytesPerPixel; + public uchar Rloss; + public uchar Gloss; + public uchar Bloss; + public uchar Aloss; + public uchar Rshift; + public uchar Gshift; + public uchar Bshift; + public uchar Ashift; + public uchar Rmask; + public uchar Gmask; + public uchar Bmask; + public uchar Amask; + + public uint32 colorkey; + public uchar alpha; + + [CCode (cname="SDL_MapRGB")] + public uint32 map_rgb(uchar r, uchar g, uchar b); + + [CCode (cname="SDL_MapRGBA")] + public uint32 map_rgba(uchar r, uchar g, uchar b, uchar a); + + [CCode (cname="SDL_GetRGB")] + public static void get_rgb(uint32 pixel, weak PixelFormat fmt, ref uchar r, ref uchar g, ref uchar b); + + [CCode (cname="SDL_GetRGBA")] + public static void get_rgba(uint32 pixel, weak PixelFormat fmt, ref uchar r, ref uchar g, ref uchar b, ref uchar a); + }// PixelFormat + + [CCode (cname="SDL_Rect")] + public struct Rect { + public int16 x; + public int16 y; + public uint16 w; + public uint16 h; + }// Rect + + [CCode (cname="SDL_Color")] + [SimpleType] + public struct Color { + public uchar r; + public uchar g; + public uchar b; + public uchar unused; + }// Color + + [CCode (cprefix="SDL_")] + public enum PaletteFlags { + LOGPAL, PHYSPAL + }// PaletteFlags + + [CCode (cname="SDL_Palette")] + public class Palette { + public int ncolors; + + [NoArrayLength] + public Color[] colors; + }// Palette + + [CCode (cname="SDL_VideoInfo")] + public class VideoInfo { + public uint32 hw_available ; + public uint32 wm_available ; + public uint32 UnusedBits1 ; + public uint32 UnusedBits2 ; + public uint32 blit_hw ; + public uint32 bliw_hw_CC ; + public uint32 blit_hw_A ; + public uint32 blit_sw ; + public uint32 blit_sw_CC ; + public uint32 blit_sw_A ; + public uint32 blit_fill ; + public uint32 UnusedBits3 ; + + public uint32 video_mem; + public PixelFormat vfmt; + public int current_w; + public int current_h; + + [CCode (cname="SDL_GetVideoInfo")] + public static weak VideoInfo get(); + }// VideoInfo + + [CCode (cprefix="SDL_")] + public enum OverlayFormat { + YV12_OVERLAY, IYUV_OVERLAY, YUY2_OVERLAY, + UYVY_OVERLAY, YVYU_OVERLAY + }// OverlayFormat + + [CCode (cname="SDL_Overlay", free_function="SDL_FreeYUVOverlay")] + public class Overlay { + public uint32 format; + public int w; + public int h; + public int planes; + uint16[] pitches; + pointer pixels; + + uint32 hw_overlay; + uint32 UnusedBits; + + [CCode (cname="SDL_CreateYUVOverlay")] + public Overlay(int width, int height, OverlayFormat format, Surface display); + + [CCode (cname="SDL_LockYUVOverlay")] + public int do_lock(); + + [CCode (cname="SDL_UnlockYUVOverlay")] + public void unlock(); + + [CCode (cname="SDL_DisplayYUVOverlay")] + public void display(Rect dst); + }// Overlay + + + /// + /// RWops + /// + [CCode (cname="SDL_RWops", free_function="SDL_FreeRW")] + public class RWops { + [CCode (cname="SDL_RWFromFile")] + public RWops.from_file(string file, string mode); + + [CCode (cname="SDL_RWFromMem")] + public RWops.from_mem(pointer mem, int size); + }// RWops + + + /// + /// OpenGL + /// + [CCode (cprefix="SDL_GL_")] + public enum GLattr { + RED_SIZE, GREEN_SIZE, BLUE_SIZE, ALPHA_SIZE, + BUFFER_SIZE, DOUBLEBUFFER, DEPTH_SIZE, STENCIL_SIZE, + ACCUM_RED_SIZE, ACCUM_GREEN_SIZE, ACCUM_BLUE_SIZE, + ACCUM_ALPHA_SIZE, STEREO, MULTISAMPLEBUFFERS, + MULTISAMPLESAMPLES, ACCELERATED_VISUAL, SWAP_CONTROL + }// GLattr + + [CCode (cprefix="SDL_GL_", cheader_filename="SDL.h")] + public class GL { + [CCode (cname="SDL_GL_LoadLibrary")] + public static int load_library(string path); + + [CCode (cname="SDL_GL_GetProcAddress")] + public static pointer get_proc_address(string proc); + + [CCode (cname="SDL_GL_SetAttribute")] + public static int set_attribute(GLattr attr, int val); + + [CCode (cname="SDL_GL_GetAttribute")] + public static int get_attribute(GLattr attr, ref int val); + + [CCode (cname="SDL_GL_SwapBuffers")] + public static void swap_buffers(); + }// GL + + + /// + /// Window manager + /// + [CCode (cprefix="SDL_GRAB_")] + public enum GrabMode { + QUERY, OFF, ON + }// GrabMode + + [CCode (cprefix="SDL_WM_", cheader_filename="SDL.h")] + public class WindowManager { + [CCode (cname="SDL_WM_SetCaption")] + public static void set_caption(string title, string icon); + + [CCode (cname="SDL_WM_GetCaption")] + public static void get_caption(ref string title, ref string icon); + + [CCode (cname="SDL_WM_SetIcon")] + [NoArrayLength] + public static void set_icon(Surface icon, uchar[] mask); + + [CCode (cname="SDL_WM_IconifyWindow")] + public static int iconify(); + + [CCode (cname="SDL_WM_ToggleFullScreen")] + public static int toggle_fullscreen(Surface surface); + + [CCode (cname="SDL_WM_GrabInput")] + public static GrabMode grab_input(GrabMode mode); + }// WindowManager + + + /// + /// Events + /// + [CCode (cprefix="SDL_")] + public enum EventType { + NOEVENT, ACTIVEEVENT, KEYDOWN, KEYUP, MOUSEMOTION, + MOUSEBUTTONDOWN, MOUSEBUTTONUP, JOYAXISMOTION, + JOYBALLMOTION, JOYHATMOTION, JOYBUTTONDOWN, JOYBUTTONUP, + QUIT, SYSWMEVENT, VIDEORESIZE, VIDEOEXPOSE, USEREVENT, + NUMEVENTS + }// EventType + + [CCode (cprefix="SDL_")] + public enum EventMask { + ACTIVEEVENTMASK, KEYDOWNMASK, KEYUPMASK, KEYEVENTMASK, + MOUSEMOTIONMASK, MOUSEBUTTONDOWNMASK, MOUSEBUTTONUPMASK, + MOUSEEVENTMASK, JOYAXISMOTIONMASK, JOYBALLMOTIONMASK, + JOYHATMOTIONMASK, JOYBUTTONDOWNMASK, JOYBUTTONUPMASK, + JOYEVENTMASK, VIDEORESIZEMASK, VIDEOEXPOSEMASK, QUITMASK, + SYSWMEVENTMASK + }// EventMask + + [CCode (cname="SDL_MouseButtonEvent", type_id = "G_TYPE_POINTER", marshaller_type_name = "POINTER")] + public struct MouseButtonEvent { + public uchar type; + public uchar which; + public uchar button; + public uchar state; + public uint16 x; + public uint16 y; + }// MouseButtonEvent + + [CCode (cname="SDL_ActiveEvent", type_id = "G_TYPE_POINTER", marshaller_type_name = "POINTER")] + public struct ActiveEvent { + public uchar type; + public uchar gain; + public uchar state; + }// ActiveEvent + + [CCode (cname="SDL_KeyboardEvent", type_id = "G_TYPE_POINTER", marshaller_type_name = "POINTER")] + public struct KeyboardEvent { + public uchar type; + public uchar which; + public uchar state; + public Key keysym; + }// KeyboardEvent + + [CCode (cname="SDL_MouseMotionEvent", type_id = "G_TYPE_POINTER", marshaller_type_name = "POINTER")] + public struct MouseMotionEvent { + public uchar type; + public uchar which; + public uchar state; + public uint16 x; + public uint16 y; + public int16 xrel; + public int16 yrel; + }// MouseMotionEvent + + [CCode (cname="SDL_JoyAxisEvent", type_id = "G_TYPE_POINTER", marshaller_type_name = "POINTER")] + public struct JoyAxisEvent { + public uchar type; + public uchar which; + public uchar axis; + public uint16 @value; + }// JoyAxisEvent + + [CCode (cname="SDL_JoyBallEvent", type_id = "G_TYPE_POINTER", marshaller_type_name = "POINTER")] + public struct JoyBallEvent { + public uchar type; + public uchar which; + public uchar ball; + public int16 xrel; + public int16 yrel; + }// JoyBallEvent + + [CCode (cname="SDL_JoyHatEvent", type_id = "G_TYPE_POINTER", marshaller_type_name = "POINTER")] + public struct JoyHatEvent { + public uchar type; + public uchar which; + public uchar hat; + public uchar @value; + }// JoyHatEvent + + [CCode (cname="SDL_JoyButtonEvent", type_id = "G_TYPE_POINTER", marshaller_type_name = "POINTER")] + public struct JoyButtonEvent { + public uchar type; + public uchar which; + public uchar button; + public uchar state; + }// JoyButtonEvent + + [CCode (cname="SDL_ResizeEvent", type_id = "G_TYPE_POINTER", marshaller_type_name = "POINTER")] + public struct ResizeEvent { + public uchar type; + public int w; + public int h; + }// ResizeEvent + + [CCode (cname="SDL_ExposeEvent", type_id = "G_TYPE_POINTER", marshaller_type_name = "POINTER")] + public struct ExposeEvent { + public uchar type; + }// ExposeEvent + + [CCode (cname="SDL_QuitEvent", type_id = "G_TYPE_POINTER", marshaller_type_name = "POINTER")] + public struct QuitEvent { + public uchar type; + }// QuitEvent + + [CCode (cname="SDL_UserEvent", type_id = "G_TYPE_POINTER", marshaller_type_name = "POINTER")] + public struct UserEvent { + public uchar type; + public int code; + public pointer data1; + public pointer data2; + }// UserEvent + + [CCode (cname="SDL_SysWMEvent", type_id = "G_TYPE_POINTER", marshaller_type_name = "POINTER")] + public struct SysWMEvent { + public uchar type; + public SysWMmsg msg; + }// WMEvent + + [CCode (cname="SDL_SysWMmsg", cheader="SDL_syswm.h")] + public class SysWMmsg { + }// SysWMmsg + + [CCode (cname="SDL_Event", type_id = "G_TYPE_POINTER", marshaller_type_name = "POINTER")] + public struct Event { + public uchar type; + public ActiveEvent active; + public KeyboardEvent key; + public MouseMotionEvent motion; + public MouseButtonEvent button; + public JoyAxisEvent jaxis; + public JoyBallEvent jball; + public JoyHatEvent jhat; + public JoyButtonEvent jbutton; + public ResizeEvent resize; + public ExposeEvent expose; + public QuitEvent quit; + public UserEvent user; + public SysWMEvent syswm; + + [CCode (cname="SDL_PumpEvents")] + public static void pump(); + + [CCode (cname="SDL_PeepEvents")] + [NoArrayLength] + public static void peep(weak Event[] events, int numevents, + EventAction action, EventMask mask); + + [CCode (cname="SDL_PollEvent")] + public static int poll(Event ev); + + [CCode (cname="SDL_WaitEvent")] + public static int wait(Event ev); + + [CCode (cname="SDL_PushEvent")] + public static int push(Event ev); + + [CCode (cname="SDL_EventState")] + public static uchar state(uchar type, EventState state); + }// Event + + [CCode (cprefix="SDL_")] + public enum EventAction { + ADDEVENT, PEEKEVENT, GETEVENT + }// EventAction + + [CCode (cprefix="SDL_")] + public enum EventState { + QUERY, IGNORE, DISABLE, ENABLE + }// EventState + + + /// + /// Input + /// + [CCode (cprefix="SDL_")] + public enum ButtonState { + RELEASED, PRESSED + }// ButtonState + + [CCode (cname="SDL_keysym", type_id = "G_TYPE_POINTER", marshaller_type_name = "POINTER")] + public struct Key { + public uchar scancode; + public KeySymbol sym; + public KeyModifier mod; + public uint16 unicode; + + [CCode (cname="SDL_EnableUNICODE")] + public static int enable_unicode(int enable); + + [CCode (cname="SDL_EnableKeyRepeat")] + public static int set_repeat(int delay, int interval); + + [CCode (cname="SDL_GetKeyRepeat")] + public static void get_repeat(ref int delay, ref int interval); + + [CCode (cname="SDL_GetKeyState")] + public static weak uchar[] get_keys(ref int numkeys); + + [CCode (cname="SDL_GetModState")] + public static KeyModifier get_modifiers(); + + [CCode (cname="SDL_SetModState")] + public static void set_modifiers(KeyModifier modstate); + + [CCode (cname="SDL_GetKeyName")] + public static string get_name(KeySymbol key); + }// Key + + [CCode (cprefix="SDLK_", cheader_filename="SDL_keysym.h")] + public enum KeySymbol { + UNKNOWN, + FIRST, + BACKSPACE, + TAB, + CLEAR, + RETURN, + PAUSE, + ESCAPE, + SPACE, + EXCLAIM, + QUOTEDBL, + HASH, + DOLLAR, + AMPERSAND, + QUOTE, + LEFTPAREN, + RIGHTPAREN, + ASTERISK, + PLUS, + COMMA, + MINUS, + PERIOD, + SLASH, + ZERO = 48, + ONE = 49, + TWO = 50, + THREE = 51, + FOUR = 52, + FIVE = 53, + SIX = 54, + SEVEN = 55, + EIGHT = 56, + NINE = 57, + COLON, + SEMICOLON, + LESS, + EQUALS, + GREATER, + QUESTION, + AT, + /* + Skip uppercase letters + */ + LEFTBRACKET, + BACKSLASH, + RIGHTBRACKET, + CARET, + UNDERSCORE, + BACKQUOTE, + a, + b, + c, + d, + e, + f, + g, + h, + i, + j, + k, + l, + m, + n, + o, + p, + q, + r, + s, + t, + u, + v, + w, + x, + y, + z, + DELETE, + /* End of ASCII mapped keysyms */ + + /* International keyboard syms */ + WORLD_0, /* 0xA0 */ + WORLD_1, + WORLD_2, + WORLD_3, + WORLD_4, + WORLD_5, + WORLD_6, + WORLD_7, + WORLD_8, + WORLD_9, + WORLD_10, + WORLD_11, + WORLD_12, + WORLD_13, + WORLD_14, + WORLD_15, + WORLD_16, + WORLD_17, + WORLD_18, + WORLD_19, + WORLD_20, + WORLD_21, + WORLD_22, + WORLD_23, + WORLD_24, + WORLD_25, + WORLD_26, + WORLD_27, + WORLD_28, + WORLD_29, + WORLD_30, + WORLD_31, + WORLD_32, + WORLD_33, + WORLD_34, + WORLD_35, + WORLD_36, + WORLD_37, + WORLD_38, + WORLD_39, + WORLD_40, + WORLD_41, + WORLD_42, + WORLD_43, + WORLD_44, + WORLD_45, + WORLD_46, + WORLD_47, + WORLD_48, + WORLD_49, + WORLD_50, + WORLD_51, + WORLD_52, + WORLD_53, + WORLD_54, + WORLD_55, + WORLD_56, + WORLD_57, + WORLD_58, + WORLD_59, + WORLD_60, + WORLD_61, + WORLD_62, + WORLD_63, + WORLD_64, + WORLD_65, + WORLD_66, + WORLD_67, + WORLD_68, + WORLD_69, + WORLD_70, + WORLD_71, + WORLD_72, + WORLD_73, + WORLD_74, + WORLD_75, + WORLD_76, + WORLD_77, + WORLD_78, + WORLD_79, + WORLD_80, + WORLD_81, + WORLD_82, + WORLD_83, + WORLD_84, + WORLD_85, + WORLD_86, + WORLD_87, + WORLD_88, + WORLD_89, + WORLD_90, + WORLD_91, + WORLD_92, + WORLD_93, + WORLD_94, + WORLD_95, /* 0xFF */ + + /* Numeric keypad */ + KP0, + KP1, + KP2, + KP3, + KP4, + KP5, + KP6, + KP7, + KP8, + KP9, + KP_PERIOD, + KP_DIVIDE, + KP_MULTIPLY, + KP_MINUS, + KP_PLUS, + KP_ENTER, + KP_EQUALS, + + /* Arrows + Home/End pad */ + UP, + DOWN, + RIGHT, + LEFT, + INSERT, + HOME, + END, + PAGEUP, + PAGEDOWN, + + /* Function keys */ + F1, + F2, + F3, + F4, + F5, + F6, + F7, + F8, + F9, + F10, + F11, + F12, + F13, + F14, + F15, + + /* Key state modifier keys */ + NUMLOCK, + CAPSLOCK, + SCROLLOCK, + RSHIFT, + LSHIFT, + RCTRL, + LCTRL, + RALT, + LALT, + RMETA, + LMETA, + LSUPER, /* Left "Windows" key */ + RSUPER, /* Right "Windows" key */ + MODE, /* "Alt Gr" key */ + COMPOSE, /* Multi-key compose key */ + + /* Miscellaneous function keys */ + HELP, + PRINT, + SYSREQ, + BREAK, + MENU, + POWER, /* Power Macintosh power key */ + EURO, /* Some european keyboards */ + UNDO, /* Atari keyboard has Undo */ + + /* Add any other keys here */ + + LAST + }// KeySymbol + + [CCode (cprefix="KMOD_", cheader_filename="SDL_keysym.h")] + enum KeyModifier { + NONE, + LSHIFT, + RSHIFT, + LCTRL, + RCTRL, + LALT, + RALT, + LMETA, + RMETA, + NUM, + CAPS, + MODE, + RESERVED, + CTRL, + SHIFT, + ALT, + META + }// KeyModifier + + [CCode (cprefix="SDL_BUTTON_")] + public enum MouseButton { + LEFT, MIDDLE, RIGHT, WHEELUP, WHEELDOWN + }// Buttons + + [CCode (cname="SDL_Cursor", free_function="SDL_FreeCursor")] + public class Cursor { + public Rect area; + public int16 hot_x; + public int16 hot_y; + public pointer data; + public pointer mask; + public pointer save; + + [CCode (cname="SDL_GetMouseState")] + public static uchar get_state(ref int x, ref int y); + + [CCode (cname="SDL_GetRelativeMouseState")] + public static uchar get_relative_state(ref int x, ref int y); + + [CCode (cname="SDL_WarpMouse")] + public static void warp(uint16 x, uint16 y); + + [CCode (cname="SDL_CreateCursor")] + public Cursor(pointer data, pointer mask, int w, int h, + int hot_x, int hot_y); + + [CCode (cname="SDL_GetCursor")] + public static Cursor get(); + + [CCode (cname="SDL_SetCursor")] + public static void set(Cursor cursor); + + [CCode (cname="SDL_ShowCursor")] + public static int show(int toggle); + }// Cursor + + [CCode (cprefix="SDL_HAT_")] + public enum HatValue { + CENTERED, UP, RIGHT, DOWN, LEFT, + RIGHTUP, RIGHTDOWN, LEFTUP, LEFTDOWN + }// HatValue + + [CCode (cname="SDL_Joystick", free_function="SDL_JoystickClose")] + public class Joystick { + [CCode (cname="SDL_JoystickName")] + public static weak string get_name(int device_index); + + [CCode (cname="SDL_JoystickOpened")] + public static int is_open(int device_index); + + [CCode (cname="SDL_JoystickUpdate")] + public static void update_all(); + + [CCode (cname="SDL_JoystickEventState")] + public static int event_state(EventState state); + + [CCode (cname="SDL_NumJoysticks")] + public static int count(); + + [CCode (cname="SDL_JoystickOpen")] + public Joystick(int device_index); + + [CCode (cname="SDL_JoystickIndex")] + public int index(); + + [CCode (cname="SDL_JoystickNumAxes")] + public int num_axes(); + + [CCode (cname="SDL_JoystickNumBalls")] + public int num_balls(); + + [CCode (cname="SDL_JoystickNumHats")] + public int num_hats(); + + [CCode (cname="SDL_JoystickNumButtons")] + public int num_buttons(); + + [CCode (cname="SDL_JoystickGetAxis")] + public int16 get_axis(int axis); + + [CCode (cname="SDL_JoystickGetHat")] + public HatValue get_hat(int hat); + + [CCode (cname="SDL_JoystickGetBall")] + public HatValue get_ball(int ball, ref int dx, ref int dy); + + [CCode (cname="SDL_JoystickGetButton")] + public ButtonState get_button(int button); + }// Joystick + + + /// + /// Audio + /// + [CCode (cprefix="AUDIO_")] + public enum AudioFormat { + U8, S8, U16LSB, S16LSB, U16MSB, S16MSB, U16, S16, + U16SYS, S16SYS + }// AudioFormat + + [CCode (cprefix="SDL_AUDIO_")] + public enum AudioStatus { + STOPPED, PLAYING, PAUSED + }// AudioStatus + + [CCode (cname="SDL_AudioSpec")] + public class AudioSpec { + public int freq; + public AudioFormat format; + public uchar channels; + public uchar silence; + public uint16 samples; + public uint16 padding; + public uint32 size; + + public pointer userdata; + }// AudioSpec + + [CCode (cname="SDL_AudioCVT")] + public class AudioConverter { + public int needed; + public AudioFormat src_format; + public AudioFormat dst_format; + public double rate_incr; + + [NoArrayLength] + public uchar[] buf; + public int len; + public int len_cvt; + public int len_mult; + public double len_ratio; + public int filter_index; + + [CCode (cname="SDL_BuildAudioCVT")] + public static int build(AudioConverter cvt, AudioFormat src_format, + uchar src_channels, int src_rate, AudioFormat dst_format, + uchar dst_channels, int dst_rate); + + [CCode (cname="SDL_ConvertAudio")] + public int convert(); + }// AudioConverter + + public class Audio { + [CCode (cname="SDL_AudioDriverName")] + public static weak string driver_name(string namebuf, int maxlen); + + [CCode (cname="SDL_OpenAudio")] + public static int open(AudioSpec desired, AudioSpec obtained); + + [CCode (cname="SDL_GetAudioStatus")] + public static AudioStatus status(); + + [CCode (cname="SDL_PauseAudio")] + public static void pause(int pause_on); + + [CCode (cname="SDL_LoadWAV_RW")] + public static AudioSpec load(RWops src, int freesrc=0, AudioSpec spec, ref pointer audio_buf, ref uint32 audio_len); + + [CCode (cname="SDL_FreeWAV")] + public static void free(pointer audio_buf); + + [CCode (cname="SDL_MixAudio")] + public static void mix(uchar[] dst, uchar[] src, uint32 len, int volume); + + [CCode (cname="SDL_LockAudio")] + public static void do_lock(); + + [CCode (cname="SDL_UnlockAudio")] + public static void unlock(); + + [CCode (cname="SDL_CloseAudio")] + public static void close(); + }// Audio + + + /// + /// Threading + /// + public delegate int ThreadFunc(pointer data); + + [CCode (cname="SDL_Thread", free_function="SDL_WaitThread")] + public class Thread { + [CCode (cname="SDL_ThreadID")] + public static uint32 id(); + + [CCode (cname="SDL_CreateThread")] + public Thread(ThreadFunc f, pointer data); + }// Thread + + [CCode (cname="SDL_mutex", free_function="SDL_DestroyMutex")] + public class Mutex { + [CCode (cname="SDL_CreateMutex")] + public Mutex(); + + [CCode (cname="SDL_mutexP")] + public int do_lock(); + + [CCode (cname="SDL_mutexV")] + public int unlock(); + }// Mutex + + [CCode (cname="SDL_sem", free_function="SDL_DestroySemaphore")] + public class Semaphore { + [CCode (cname="SDL_CreateSemaphore")] + public Semaphore(uint32 initial_value); + + [CCode (cname="SDL_SemWait")] + public int wait(); + + [CCode (cname="SDL_SemTryWait")] + public int try_wait(); + + [CCode (cname="SDL_SemWaitTimeout")] + public int wait_timeout(uint32 ms); + + [CCode (cname="SDL_SemPost")] + public int post(); + + [CCode (cname="SDL_SemValue")] + public uint32 count(); + }// Semaphore + + [CCode (cname="SDL_cond", free_function="SDL_DestroyCond")] + public class Condition { + [CCode (cname="SDL_CreateCond")] + public Condition(); + + [CCode (cname="SDL_CondSignal")] + public int @signal(); + + [CCode (cname="SDL_CondBroadcast")] + public int broadcast(); + + [CCode (cname="SDL_CondWait")] + public int wait(Mutex mut); + + [CCode (cname="SDL_CondWaitTimeout")] + public int wait_timeout(Mutex mut, uint32 ms); + }// Condition + + + /// + /// Timers + /// + public delegate uint32 TimerCallback(uint32 interval, pointer param); + + [CCode (cname="struct _SDL_TimerID", free_function="SDL_RemoveTimer")] + public class Timer { + [CCode (cname="SDL_GetTicks")] + public static uint32 get_ticks(); + + [CCode (cname="SDL_Delay")] + public static void delay(uint32 ms); + + [CCode (cname="SDL_AddTimer")] + public Timer(uint32 interval, TimerCallback callback, pointer param); + }// Timer +}// SDL -- 2.7.4