2002-10-24 03:38:23 +00:00
|
|
|
#ifndef SM_SDL_UTILS
|
|
|
|
|
#define SM_SDL_UTILS 1
|
|
|
|
|
|
2003-02-14 06:29:40 +00:00
|
|
|
/* Hack to prevent X includes from messing with our namespace: */
|
|
|
|
|
#define Font X11___Font
|
|
|
|
|
#define Screen X11___Screen
|
2002-10-24 03:38:23 +00:00
|
|
|
#include "SDL.h"
|
2003-02-14 06:29:40 +00:00
|
|
|
#include "SDL_syswm.h" // for SDL_SysWMinfo
|
|
|
|
|
#undef Font
|
|
|
|
|
#undef Screen
|
2002-10-24 03:38:23 +00:00
|
|
|
|
2003-06-28 02:03:26 +00:00
|
|
|
Uint32 mySDL_Swap24(Uint32 x);
|
2004-03-08 07:28:07 +00:00
|
|
|
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
|
|
|
|
|
#define mySDL_SwapLE24(n) (n)
|
|
|
|
|
#define mySDL_SwapBE24(n) (mySDL_Swap24(n))
|
|
|
|
|
#else
|
|
|
|
|
#define mySDL_SwapLE24(n) (mySDL_Swap24(n))
|
|
|
|
|
#define mySDL_SwapBE24(n) (n)
|
|
|
|
|
#endif
|
2003-06-28 02:03:26 +00:00
|
|
|
|
2002-10-24 03:38:23 +00:00
|
|
|
Uint32 decodepixel(const Uint8 *p, int bpp);
|
|
|
|
|
void encodepixel(Uint8 *p, int bpp, Uint32 pixel);
|
|
|
|
|
|
|
|
|
|
void mySDL_GetRawRGBAV(Uint32 pixel, const SDL_Surface *src, Uint8 *v);
|
|
|
|
|
void mySDL_GetRawRGBAV(const Uint8 *p, const SDL_Surface *src, Uint8 *v);
|
2003-04-05 21:17:51 +00:00
|
|
|
void mySDL_GetRGBAV(Uint32 pixel, const SDL_Surface *src, Uint8 *v);
|
|
|
|
|
void mySDL_GetRGBAV(const Uint8 *p, const SDL_Surface *src, Uint8 *v);
|
2002-10-24 03:38:23 +00:00
|
|
|
|
|
|
|
|
Uint32 mySDL_SetRawRGBAV(const SDL_PixelFormat *fmt, const Uint8 *v);
|
|
|
|
|
void mySDL_SetRawRGBAV(Uint8 *p, const SDL_Surface *src, const Uint8 *v);
|
2003-04-05 21:17:51 +00:00
|
|
|
Uint32 mySDL_SetRGBAV(const SDL_PixelFormat *fmt, const Uint8 *v);
|
|
|
|
|
void mySDL_SetRGBAV(Uint8 *p, const SDL_Surface *src, const Uint8 *v);
|
2002-10-24 03:38:23 +00:00
|
|
|
|
|
|
|
|
void mySDL_GetBitsPerChannel(const SDL_PixelFormat *fmt, Uint32 bits[4]);
|
2003-06-04 20:08:51 +00:00
|
|
|
void mySDL_SetPalette(SDL_Surface *dst, SDL_Color *colors, int start, int cnt);
|
2004-02-25 03:36:20 +00:00
|
|
|
void CopySDLSurface( SDL_Surface *src, SDL_Surface *dest );
|
|
|
|
|
bool ConvertSDLSurface( SDL_Surface *src, SDL_Surface *&dst,
|
|
|
|
|
int width, int height, int bpp,
|
|
|
|
|
Uint32 R, Uint32 G, Uint32 B, Uint32 A );
|
2002-10-24 03:38:23 +00:00
|
|
|
void ConvertSDLSurface(SDL_Surface *&image,
|
|
|
|
|
int width, int height, int bpp,
|
|
|
|
|
Uint32 R, Uint32 G, Uint32 B, Uint32 A);
|
|
|
|
|
SDL_Surface *SDL_CreateRGBSurfaceSane
|
|
|
|
|
(Uint32 flags, int width, int height, int depth,
|
|
|
|
|
Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask);
|
|
|
|
|
|
2003-01-23 05:35:21 +00:00
|
|
|
void FixHiddenAlpha(SDL_Surface *img);
|
2003-01-23 04:45:45 +00:00
|
|
|
|
2003-04-12 19:00:56 +00:00
|
|
|
/* Check for an event; return true if one was waiting. */
|
|
|
|
|
bool SDL_GetEvent(SDL_Event &event, int mask);
|
|
|
|
|
|
2003-05-25 23:49:40 +00:00
|
|
|
/* Change the event state without dropping extra events. */
|
|
|
|
|
Uint8 mySDL_EventState(Uint8 type, int state);
|
|
|
|
|
|
2003-05-26 01:43:23 +00:00
|
|
|
void mySDL_GetAllEvents(vector<SDL_Event> &events);
|
|
|
|
|
void mySDL_PushEvents(vector<SDL_Event> &events);
|
|
|
|
|
|
2003-03-27 06:01:43 +00:00
|
|
|
/* The surface contains no transparent pixels and/or never uses its color
|
|
|
|
|
* key, so it doesn't need any alpha bits at all. */
|
|
|
|
|
#define TRAIT_NO_TRANSPARENCY 0x0001 /* 0alpha */
|
|
|
|
|
/* The surface contains only transparent values of 0 or 1; no translucency.
|
|
|
|
|
* It only needs one bit of alpha. */
|
|
|
|
|
#define TRAIT_BOOL_TRANSPARENCY 0x0002 /* 1alpha */
|
|
|
|
|
int FindSurfaceTraits(const SDL_Surface *img);
|
|
|
|
|
|
2003-05-25 21:58:34 +00:00
|
|
|
|
|
|
|
|
void mySDL_WM_SetIcon( CString sIconFile );
|
|
|
|
|
|
2003-06-04 20:08:51 +00:00
|
|
|
bool mySDL_SaveSurface( SDL_Surface *img, CString file );
|
|
|
|
|
SDL_Surface *mySDL_LoadSurface( CString file );
|
|
|
|
|
|
|
|
|
|
int mySDL_MapRGBExact(SDL_PixelFormat *fmt, Uint8 R, Uint8 G, Uint8 B);
|
|
|
|
|
|
|
|
|
|
void mySDL_BlitTransform( const SDL_Surface *src, SDL_Surface *dst,
|
|
|
|
|
const float fCoords[8] /* TL, BR, BL, TR */ );
|
2003-06-29 07:03:00 +00:00
|
|
|
void mySDL_BlitSurface(
|
|
|
|
|
SDL_Surface *src, SDL_Surface *dst, int width, int height, bool ckey);
|
2003-10-08 03:37:33 +00:00
|
|
|
|
|
|
|
|
/* Use the "unused1" field in surfaces to mark paletted surfaces that only use
|
|
|
|
|
* 16 palette values. */
|
|
|
|
|
enum { FOUR_BIT_PALETTE = 0x1 };
|
|
|
|
|
|
2003-10-08 01:46:00 +00:00
|
|
|
SDL_Surface *mySDL_Palettize( SDL_Surface *src_surf, int GrayBits, int AlphaBits );
|
2003-05-25 21:58:34 +00:00
|
|
|
|
2003-12-04 20:41:00 +00:00
|
|
|
SDL_Surface *SDL_LoadImage( const CString &sPath );
|
|
|
|
|
|
2003-12-12 10:03:23 +00:00
|
|
|
SDL_RWops *OpenRWops( const CString &sPath, bool Write=false );
|
|
|
|
|
SDL_RWops *OpenRWops( CString &sBuf );
|
2004-02-20 05:10:39 +00:00
|
|
|
SDL_Surface *mySDL_MakeDummySurface( int height, int width );
|
2003-12-12 10:03:23 +00:00
|
|
|
|
2004-04-09 21:52:50 +00:00
|
|
|
CString mySDL_GetError();
|
|
|
|
|
|
2002-10-24 03:38:23 +00:00
|
|
|
#endif
|
|
|
|
|
|