Commit e3319dde authored by Mario Daniel Ruiz Saavedra's avatar Mario Daniel Ruiz Saavedra 💬 Committed by Rico Tzschichholz
Browse files

vapi: Add SDL 2.x bindings

Fixes #1032
parent 2010ed9f
......@@ -253,6 +253,25 @@ dist_vapi_DATA = \
rest-0.7.vapi \
rest-extras-0.7.deps \
rest-extras-0.7.vapi \
sdl2-android.deps \
sdl2-android.vapi \
SDL2_gfx.deps \
SDL2_gfx.vapi \
SDL2_image.deps \
SDL2_image.vapi \
sdl2-ios.deps \
sdl2-ios.vapi \
SDL2_mixer.deps \
SDL2_mixer.vapi \
SDL2_net.deps \
SDL2_net.vapi \
SDL2_ttf.deps \
SDL2_ttf.vapi \
sdl2.vapi \
sdl2-windows.deps \
sdl2-windows.vapi \
sdl2-winrt.deps \
sdl2-winrt.vapi \
sqlite3.vapi \
taglib_c.vapi \
tiff.vapi \
......
This diff is collapsed.
/*
* The MIT License (MIT)
*
* Copyright (c) 2016-2020 SDL2 VAPI Authors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* Authors:
* Mario Daniel Ruiz Saavedra <desiderantes93@gmail.com>
* Gontzal Uriarte <txasatonga@gmail.com>
* Pedro H. Lara Campos <root@pedrohlc.com>
*/
[CCode (cheader_filename = "SDL2/SDL_image.h")]
namespace SDLImage {
//! Defines
[CCode (cname = "IMG_InitFlags", cprefix = "IMG_INIT_")]
public enum InitFlags {
JPG,
PNG,
TIF,
WEBP,
[CCode (cname = "IMG_INIT_JPG|IMG_INIT_PNG|IMG_INIT_TIF|IMG_INIT_WEBP")]
ALL
}
//! General
[CCode (cname = "IMG_Linked_Version")]
public static unowned SDL.Version linked ();
[CCode (cname = "IMG_Init")]
public static int init (int flags);
[CCode (cname = "IMG_Quit")]
public static void quit ();
//! Loading
[CCode (cname = "IMG_Load")]
public static SDL.Video.Surface? load (string file);
[CCode (cname = "IMG_Load_RW")]
public static SDL.Video.Surface? load_rw (SDL.RWops src, bool freesrc = false);
[CCode (cname = "IMG_LoadTyped_RW")]
public static SDL.Video.Surface? load_rw_typed (SDL.RWops src, bool freesrc, string type);
[CCode (cname = "IMG_LoadTexture")]
public static SDL.Video.Texture? load_texture (SDL.Video.Renderer renderer, string file);
[CCode (cname = "IMG_LoadTexture_RW")]
public static SDL.Video.Texture? load_texture_rw (SDL.Video.Renderer renderer, SDL.RWops src, bool freesrc = false);
[CCode (cname = "IMG_LoadTextureTyped_RW")]
public static SDL.Video.Texture? load_texture_rw_typed (SDL.Video.Renderer renderer, SDL.RWops src, bool freesrc, string type);
[CCode (cname = "IMG_InvertAlpha")]
public static int invert_alpha (int on);
[CCode (cname = "IMG_LoadCUR_RW")]
public static SDL.Video.Surface? load_cur (SDL.RWops src);
[CCode (cname = "IMG_LoadICO_RW")]
public static SDL.Video.Surface? load_ico (SDL.RWops src);
[CCode (cname = "IMG_LoadBMP_RW")]
public static SDL.Video.Surface? load_bmp (SDL.RWops src);
[CCode (cname = "IMG_LoadPNM_RW")]
public static SDL.Video.Surface? load_pnm (SDL.RWops src);
[CCode (cname = "IMG_LoadXPM_RW")]
public static SDL.Video.Surface? load_xpm (SDL.RWops src);
[CCode (cname = "IMG_LoadXCF_RW")]
public static SDL.Video.Surface? load_xcf (SDL.RWops src);
[CCode (cname = "IMG_LoadPCX_RW")]
public static SDL.Video.Surface? load_pcx (SDL.RWops src);
[CCode (cname = "IMG_LoadGIF_RW")]
public static SDL.Video.Surface? load_gif (SDL.RWops src);
[CCode (cname = "IMG_LoadJPG_RW")]
public static SDL.Video.Surface? load_jpg (SDL.RWops src);
[CCode (cname = "IMG_LoadTIF_RW")]
public static SDL.Video.Surface? load_tif (SDL.RWops src);
[CCode (cname = "IMG_LoadPNG_RW")]
public static SDL.Video.Surface? load_png (SDL.RWops src);
[CCode (cname = "IMG_LoadTGA_RW")]
public static SDL.Video.Surface? load_tga (SDL.RWops src);
[CCode (cname = "IMG_LoadLBM_RW")]
public static SDL.Video.Surface? load_lbm (SDL.RWops src);
[CCode (cname = "IMG_LoadXV_RW")]
public static SDL.Video.Surface? load_xv (SDL.RWops src);
[CCode (cname = "IMG_LoadWEBP_RW")]
public static SDL.Video.Surface? load_webp (SDL.RWops src);
[CCode (cname = "IMG_ReadXPMFromArray")]
public static SDL.Video.Surface? read_xpm (string[] xpmdata);
//!Info
[CCode (cname = "IMG_isCUR")]
public static bool is_cur (SDL.RWops src);
[CCode (cname = "IMG_isICO")]
public static bool is_ico (SDL.RWops src);
[CCode (cname = "IMG_isBMP")]
public static bool is_bmp (SDL.RWops src);
[CCode (cname = "IMG_isPNM")]
public static bool is_pnm (SDL.RWops src);
[CCode (cname = "IMG_isXPM")]
public static bool is_xpm (SDL.RWops src);
[CCode (cname = "IMG_isXCF")]
public static bool is_xcf (SDL.RWops src);
[CCode (cname = "IMG_isPCX")]
public static bool is_pcx (SDL.RWops src);
[CCode (cname = "IMG_isGIF")]
public static bool is_gif (SDL.RWops src);
[CCode (cname = "IMG_isJPG")]
public static bool is_jpg (SDL.RWops src);
[CCode (cname = "IMG_isTIF")]
public static bool is_tif (SDL.RWops src);
[CCode (cname = "IMG_isPNG")]
public static bool is_png (SDL.RWops src);
[CCode (cname = "IMG_isLBM")]
public static bool is_lbm (SDL.RWops src);
[CCode (cname = "IMG_isXV")]
public static bool is_xv (SDL.RWops src);
[CCode (cname = "IMG_isWEBP")]
public static bool is_webp (SDL.RWops src);
} // SDLImage
/*
* The MIT License (MIT)
*
* Copyright (c) 2016-2020 SDL2 VAPI Authors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* Authors:
* Mario Daniel Ruiz Saavedra <desiderantes93@gmail.com>
* Gontzal Uriarte <txasatonga@gmail.com>
* Pedro H. Lara Campos <root@pedrohlc.com>
*/
[CCode (cheader_filename = "SDL2/SDL_mixer.h")]
namespace SDLMixer {
[CCode (cname = "Mix_Linked_Version")]
public static unowned SDL.Version linked ();
[CCode (cname = "Mix_OpenAudio")]
public static int open (int frequency, SDL.Audio.AudioFormat format, int channels, int chunksize);
[CCode (cname = "Mix_CloseAudio")]
public static void close ();
[CCode (cname = "Mix_QuerySpec")]
public static int query (out int frequency, out SDL.Audio.AudioFormat format, out int channels);
[CCode (cname = "Mix_SetPostMix")]
public static void set_post_mixer (MixFunction f);
[CCode (cname = "Mix_SetSynchroValue")]
public static int set_synchro_value (int value);
[CCode (cname = "Mix_GetSynchroValue")]
public static int get_synchro_value ();
[CCode (has_target = true, delegate_target_pos = 0)]
public delegate void MixFunction (uint8[] stream);
public delegate void MusicFinishedCallback ();
public delegate void ChannelFinishedCallback (int channel);
[CCode (has_target = true, delegate_target_pos = 2.1)]
public delegate void EffectCallback (int chan, void* stream, int len);
[CCode (has_target = true, delegate_target_pos = 0.1)]
public delegate void EffectDoneCallback (int chan);
[CCode (cname = "int", cprefix = "MIX_")]
public enum FadeStatus {
NO_FADING, FADING_OUT, FADING_IN
}// FadeStatus
[CCode (cname = "int", cprefix = "MUS_")]
public enum MusicType {
NONE, CMD, WAV, MOD, MID, OGG, MP3, MP3_MAD
}// MusicType
[CCode (cname = "Mix_Chunk", free_function = "Mix_FreeChunk")]
[Compact]
public class Chunk {
[CCode (cname = "Mix_LoadWAV_RW")]
public Chunk.WAV_RW (SDL.RWops src, int freesrc = 0);
[CCode (cname = "Mix_LoadWAV")]
public Chunk.WAV (string file);
[CCode (cname = "Mix_QuickLoad_WAV")]
public Chunk.QuickWAV ([CCode (array_length = false)] uint8[] mem);
[CCode (cname = "Mix_QuickLoad_RAW")]
public Chunk.QuickRAW (uint8[] mem);
[CCode (cname = "Mix_VolumeChunk")]
public int volume (int num);
}// Chunk
[CCode (cname = "Mix_Music", free_function = "Mix_FreeMusic")]
[Compact]
public class Music {
[CCode (cname = "Mix_GetMusicHookData")]
public static void* get_hook_data ();
[CCode (cname = "Mix_HookMusic")]
public static void hook_mixer (MixFunction? f);
[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 bool is_paused ();
[CCode (cname = "Mix_SetMusicPosition")]
public static int position (double position);
[CCode (cname = "Mix_PlayingMusic")]
public static bool 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 (SDL.RWops rw, bool freesrc);
[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
[Compact]
public class Effect {
[CCode (cname = "Mix_RegisterEffect")]
public static int register (int chan, EffectCallback f,
EffectDoneCallback? d);
[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 (uint8 left, uint8 right);
[CCode (cname = "Mix_SetPosition")]
public int position (int16 degrees, uint8 distance);
[CCode (cname = "Mix_SetDistance")]
public int distance (uint8 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 = "-1")]
public const SDLMixer.Channel DEFAULT_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
/*
* The MIT License (MIT)
*
* Copyright (c) 2016-2020 SDL2 VAPI Authors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* Authors:
* Mario Daniel Ruiz Saavedra <desiderantes93@gmail.com>
* Gontzal Uriarte <txasatonga@gmail.com>
* Pedro H. Lara Campos <root@pedrohlc.com>
*/
[CCode (cprefix = "SDLNet_", cheader_filename = "SDL2/SDL2_net.h")]
namespace SDLNet {
[CCode (cname = "SDLNet_Linked_Version")]
public static SDL.Version linked ();
[CCode (cname = "SDLNet_Init")]
public static int init ();
[CCode (cname = "SDLNet_Quit")]
public static void quit ();
[CCode (cname = "SDLNet_Write16")]
public static void write16 (uint16 value, void* area);
[CCode (cname = "SDLNet_Write32")]
public static void write32 (uint value, void* area);
[CCode (cname = "SDLNet_Read16")]
public static uint16 read16 (void* area);
[CCode (cname = "SDLNet_Read32")]
public static uint read32 (void* area);
[CCode (cname = "IPaddress", free_function = "g_free", has_type_id = false)]
public struct IPAddress {
public uint host;
public uint16 port;
[CCode (cname = "INADDR_ANY")]
public const uint ANY;
[CCode (cname = "INADDR_NONE")]
public const uint NONE;
[CCode (cname = "SDLNet_ResolveHost")]
public static int from_host (out IPAddress address, string? host, uint16 port);
[CCode (cname = "SDLNet_ResolveIP")]
public unowned string? lookup ();
}// IPAddress
[CCode (cname = "UDPpacket", free_function = "SDLNet_FreePacket")]
[Compact]
public class UDPPacket {
public int channel;
public uchar *data;
public int len;
public int maxlen;
public int status;
public IPAddress address;
[CCode (cname = "SDLNet_AllocPacket")]
public UDPPacket (int size);
[CCode (cname = "SDLNet_ResizePacket")]
public int resize (int newsize);
}// UDPPacket
[CCode (cname = "void")]
[Compact]
public class Socket {
public int ready;
}// Socket
[CCode (cname = "struct _TCPsocket", free_function = "SDLNet_TCP_Close")]
[Compact]
public class TCPSocket: Socket {
[CCode (cname = "SDLNet_TCP_Open")]
public TCPSocket (IPAddress ip);
[CCode (cname = "SDLNet_TCP_Accept")]
public TCPSocket? accept ();
[CCode (cname = "SDLNet_TCP_GetPeerAddress")]
public IPAddress? get_address ();
[CCode (cname = "SDLNet_TCP_Send")]
public int send (uchar[] data);
[CCode (cname = "SDLNet_TCP_Recv")]
public int receive (uchar[] data);
}// TCPSocket
[CCode (cname = "struct _UDPsocket", free_function = "SDLNet_UDP_Close")]
[Compact]
public class UDPSocket: Socket {
[CCode (cname = "SDLNet_UDP_Open")]
public UDPSocket (uint16 port);
[CCode (cname = "SDLNet_UDP_Bind")]
public int bind (int channel, IPAddress address);
[CCode (cname = "SDLNet_UDP_Unbind")]
public void unbind (int channel);
[CCode (cname = "SDLNet_UDP_GetPeerAddress")]
public IPAddress? get_address (int channel);
[CCode (cname = "SDLNet_UDP_Send")]
public int send (int channel, UDPPacket packet);
[CCode (cname = "SDLNet_UDP_Recv")]
public int receive (UDPPacket packet);
[CCode (cname = "SDLNet_UDP_SendV")]
public int send_many (UDPPacket[] packets);
[CCode (cname = "SDLNet_UDP_RecvV")]
public int receive_many ([CCode (array_length = false)] UDPPacket[] packets);
}// UDPSocket
[CCode (cname = "struct _SDLNet_SocketSet", free_function = "SDLNet_FreeSocketSet")]
[Compact]
public class SocketSet {
[CCode (cname = "SDLNet_AllocSocketSet")]
public SocketSet (int maxsockets);
[CCode (cname = "SDLNet_AddSocket")]
public int add (Socket socket);
[CCode (cname = "SDLNet_DelSocket")]
public int remove (Socket socket);
[CCode (cname = "SDLNet_CheckSockets")]
public int has_data (uint timeout);
[CCode (cname = "SDLNet_SocketReady ")]
public int is_ready ();
}// SocketSet
}// SDL
/*
* The MIT License (MIT)
*
* Copyright (c) 2016-2020 SDL2 VAPI Authors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* Authors:
* Mario Daniel Ruiz Saavedra <desiderantes93@gmail.com>
* Gontzal Uriarte <txasatonga@gmail.com>