Index: /trunk/nv/lib/detail/sdl_functions.inc
===================================================================
--- /trunk/nv/lib/detail/sdl_functions.inc	(revision 168)
+++ /trunk/nv/lib/detail/sdl_functions.inc	(revision 168)
@@ -0,0 +1,171 @@
+/* SDL.h functions */
+NV_SDL_FUN( int, SDL_Init, (Uint32 flags) );
+NV_SDL_FUN( int, SDL_InitSubSystem, (Uint32 flags) );
+NV_SDL_FUN( void, SDL_QuitSubSystem, (Uint32 flags) );
+NV_SDL_FUN( Uint32, SDL_WasInit, (Uint32 flags) );
+NV_SDL_FUN( void, SDL_Quit, (void) );
+
+/* SDL_rwops.h functions */
+NV_SDL_FUN( SDL_RWops *, SDL_RWFromFile, (const char *file, const char *mode) );
+NV_SDL_FUN( SDL_RWops *, SDL_RWFromFP, (FILE *fp, int autoclose) );
+NV_SDL_FUN( SDL_RWops *, SDL_RWFromMem, (void *mem, int size) );
+NV_SDL_FUN( SDL_RWops *, SDL_RWFromConstMem, (const void *mem, int size) );
+NV_SDL_FUN( SDL_RWops *, SDL_AllocRW, (void) );
+NV_SDL_FUN( void, SDL_FreeRW, (SDL_RWops *area) );
+NV_SDL_FUN( Uint16, SDL_ReadLE16, (SDL_RWops *src) );
+NV_SDL_FUN( Uint16, SDL_ReadBE16, (SDL_RWops *src) );
+NV_SDL_FUN( Uint32, SDL_ReadLE32, (SDL_RWops *src) );
+NV_SDL_FUN( Uint32, SDL_ReadBE32, (SDL_RWops *src) );
+NV_SDL_FUN( Uint64, SDL_ReadLE64, (SDL_RWops *src) );
+NV_SDL_FUN( Uint64, SDL_ReadBE64, (SDL_RWops *src) );
+NV_SDL_FUN( int, SDL_WriteLE16, (SDL_RWops *dst, Uint16 value) );
+NV_SDL_FUN( int, SDL_WriteBE16, (SDL_RWops *dst, Uint16 value) );
+NV_SDL_FUN( int, SDL_WriteLE32, (SDL_RWops *dst, Uint32 value) );
+NV_SDL_FUN( int, SDL_WriteBE32, (SDL_RWops *dst, Uint32 value) );
+NV_SDL_FUN( int, SDL_WriteLE64, (SDL_RWops *dst, Uint64 value) );
+NV_SDL_FUN( int, SDL_WriteBE64, (SDL_RWops *dst, Uint64 value) );
+
+/* SDL_video.h defines */
+NV_SDL_FUN( int, SDL_VideoInit, (const char *driver_name, Uint32 flags) );
+NV_SDL_FUN( void, SDL_VideoQuit, (void) );
+NV_SDL_FUN( char *, SDL_VideoDriverName, (char *namebuf, int maxlen) );
+NV_SDL_FUN( SDL_Surface *, SDL_GetVideoSurface, (void) );
+NV_SDL_FUN( const SDL_VideoInfo *, SDL_GetVideoInfo, (void) );
+NV_SDL_FUN( int, SDL_VideoModeOK, (int width, int height, int bpp, Uint32 flags) );
+NV_SDL_FUN( SDL_Rect **, SDL_ListModes, (SDL_PixelFormat *format, Uint32 flags) );
+NV_SDL_FUN( SDL_Surface *, SDL_SetVideoMode, (int width, int height, int bpp, Uint32 flags) );
+NV_SDL_FUN( void, SDL_UpdateRects, (SDL_Surface *screen, int numrects, SDL_Rect *rects) );
+NV_SDL_FUN( void, SDL_UpdateRect, (SDL_Surface *screen, Sint32 x, Sint32 y, Uint32 w, Uint32 h) );
+NV_SDL_FUN( int, SDL_Flip, (SDL_Surface *screen) );
+NV_SDL_FUN( int, SDL_SetGamma, (float red, float green, float blue) );
+NV_SDL_FUN( int, SDL_SetGammaRamp, (const Uint16 *red, const Uint16 *green, const Uint16 *blue) );
+NV_SDL_FUN( int, SDL_GetGammaRamp, (Uint16 *red, Uint16 *green, Uint16 *blue) );
+NV_SDL_FUN( int, SDL_SetColors, (SDL_Surface *surface, SDL_Color *colors, int firstcolor, int ncolors) );
+NV_SDL_FUN( int, SDL_SetPalette, (SDL_Surface *surface, int flags, SDL_Color *colors, int firstcolor, int ncolors) );
+NV_SDL_FUN( Uint32, SDL_MapRGB, (const SDL_PixelFormat * const format, const Uint8 r, const Uint8 g, const Uint8 b) );
+NV_SDL_FUN( Uint32, SDL_MapRGBA, (const SDL_PixelFormat * const format, const Uint8 r, const Uint8 g, const Uint8 b, const Uint8 a) );
+NV_SDL_FUN( void, SDL_GetRGB, (Uint32 pixel, const SDL_PixelFormat * const fmt, Uint8 *r, Uint8 *g, Uint8 *b) );
+NV_SDL_FUN( void, SDL_GetRGBA, (Uint32 pixel,	const SDL_PixelFormat * const fmt, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a) );
+NV_SDL_FUN( SDL_Surface *, SDL_CreateRGBSurface, (Uint32 flags, int width, int height, int depth, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask) );
+NV_SDL_FUN( SDL_Surface *, SDL_CreateRGBSurfaceFrom, (void *pixels, int width, int height, int depth, int pitch, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask) );
+NV_SDL_FUN( void, SDL_FreeSurface, (SDL_Surface *surface) );
+NV_SDL_FUN( int, SDL_LockSurface, (SDL_Surface *surface) );
+NV_SDL_FUN( void, SDL_UnlockSurface, (SDL_Surface *surface) );
+NV_SDL_FUN( SDL_Surface *, SDL_LoadBMP_RW, (SDL_RWops *src, int freesrc) );
+NV_SDL_FUN( int, SDL_SaveBMP_RW, (SDL_Surface *surface, SDL_RWops *dst, int freedst) );
+NV_SDL_FUN( int, SDL_SetColorKey, (SDL_Surface *surface, Uint32 flag, Uint32 key) );
+NV_SDL_FUN( int, SDL_SetAlpha, (SDL_Surface *surface, Uint32 flag, Uint8 alpha) );
+NV_SDL_FUN( SDL_bool, SDL_SetClipRect, (SDL_Surface *surface, const SDL_Rect *rect) );
+NV_SDL_FUN( void, SDL_GetClipRect, (SDL_Surface *surface, SDL_Rect *rect) );
+NV_SDL_FUN( SDL_Surface *, SDL_ConvertSurface, (SDL_Surface *src, SDL_PixelFormat *fmt, Uint32 flags) );
+NV_SDL_FUN( int, SDL_UpperBlit, (SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect) );
+NV_SDL_FUN( int, SDL_LowerBlit, (SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect) );
+NV_SDL_FUN( int, SDL_FillRect, (SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color) );
+NV_SDL_FUN( SDL_Surface *, SDL_DisplayFormat, (SDL_Surface *surface) );
+NV_SDL_FUN( SDL_Surface *, SDL_DisplayFormatAlpha, (SDL_Surface *surface) );
+NV_SDL_FUN( int, SDL_GL_LoadLibrary, (const char *path) );
+NV_SDL_FUN( void *, SDL_GL_GetProcAddress, (const char* proc) );
+NV_SDL_FUN( int, SDL_GL_SetAttribute, (SDL_GLattr attr, int value) );
+NV_SDL_FUN( int, SDL_GL_GetAttribute, (SDL_GLattr attr, int* value) );
+NV_SDL_FUN( void, SDL_GL_SwapBuffers, (void) );
+NV_SDL_FUN( void, SDL_GL_UpdateRects, (int numrects, SDL_Rect* rects) );
+NV_SDL_FUN( void, SDL_GL_Lock, (void) );
+NV_SDL_FUN( void, SDL_GL_Unlock, (void) );
+NV_SDL_FUN( void, SDL_WM_SetCaption, (const char *title, const char *icon) );
+NV_SDL_FUN( void, SDL_WM_GetCaption, (char **title, char **icon) );
+NV_SDL_FUN( void, SDL_WM_SetIcon, (SDL_Surface *icon, Uint8 *mask) );
+NV_SDL_FUN( int, SDL_WM_IconifyWindow, (void) );
+NV_SDL_FUN( int, SDL_WM_ToggleFullScreen, (SDL_Surface *surface) );
+NV_SDL_FUN( SDL_GrabMode, SDL_WM_GrabInput, (SDL_GrabMode mode) ); 
+
+/* SDL_audio.h functions */
+NV_SDL_FUN( int, SDL_AudioInit, (const char *driver_name) );
+NV_SDL_FUN( void, SDL_AudioQuit, (void) ); 
+NV_SDL_FUN( char *, SDL_AudioDriverName, (char *namebuf, int maxlen) );
+NV_SDL_FUN( int, SDL_OpenAudio, (SDL_AudioSpec *desired, SDL_AudioSpec *obtained) );
+NV_SDL_FUN( SDL_audiostatus, SDL_GetAudioStatus, (void) );
+NV_SDL_FUN( void, SDL_PauseAudio, (int pause_on) );
+NV_SDL_FUN( SDL_AudioSpec *, SDL_LoadWAV_RW, (SDL_RWops *src, int freesrc, SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len) );
+NV_SDL_FUN( void, SDL_FreeWAV, (Uint8 *audio_buf) );
+NV_SDL_FUN( int, SDL_BuildAudioCVT, (SDL_AudioCVT *cvt, Uint16 src_format, Uint8 src_channels, int src_rate, Uint16 dst_format, Uint8 dst_channels, int dst_rate) );
+NV_SDL_FUN( int, SDL_ConvertAudio, (SDL_AudioCVT *cvt) );
+NV_SDL_FUN( void, SDL_MixAudio, (Uint8 *dst, const Uint8 *src, Uint32 len, int volume) );
+NV_SDL_FUN( void, SDL_LockAudio, (void) );
+NV_SDL_FUN( void, SDL_UnlockAudio, (void) );
+NV_SDL_FUN( void, SDL_CloseAudio, (void) );  
+
+/* SDL_cpuinfo.h functions */
+NV_SDL_FUN( SDL_bool, SDL_HasRDTSC, (void) );
+NV_SDL_FUN( SDL_bool, SDL_HasMMX, (void) );
+NV_SDL_FUN( SDL_bool, SDL_HasMMXExt, (void) );
+NV_SDL_FUN( SDL_bool, SDL_Has3DNow, (void) );
+NV_SDL_FUN( SDL_bool, SDL_Has3DNowExt, (void) );
+NV_SDL_FUN( SDL_bool, SDL_HasSSE, (void) );
+NV_SDL_FUN( SDL_bool, SDL_HasSSE2, (void) );
+NV_SDL_FUN( SDL_bool, SDL_HasAltiVec, (void) ); 
+
+/* SDL_error.h functions */
+NV_SDL_FUN( void, SDL_SetError, (const char *fmt, ...) );
+NV_SDL_FUN( char *, SDL_GetError, (void) );
+NV_SDL_FUN( void, SDL_ClearError, (void) );
+NV_SDL_FUN( void, SDL_Error, (SDL_errorcode code) );
+
+/* SDL_active.h functions */
+NV_SDL_FUN( Uint8, SDL_GetAppState, (void) );
+
+/* SDL_keyboard.h functions */
+NV_SDL_FUN( int, SDL_EnableUNICODE, (int enable) );
+NV_SDL_FUN( int, SDL_EnableKeyRepeat, (int delay, int interval) );
+NV_SDL_FUN( void, SDL_GetKeyRepeat, (int *delay, int *interval) );
+NV_SDL_FUN( Uint8 *, SDL_GetKeyState, (int *numkeys) );
+NV_SDL_FUN( SDLMod, SDL_GetModState, (void) );
+NV_SDL_FUN( void, SDL_SetModState, (SDLMod modstate) );
+NV_SDL_FUN( char *, SDL_GetKeyName, (SDLKey key) );
+ 
+/* SDL_mouse.h functions */
+NV_SDL_FUN( Uint8, SDL_GetMouseState, (int *x, int *y) );
+NV_SDL_FUN( Uint8, SDL_GetRelativeMouseState, (int *x, int *y) );
+NV_SDL_FUN( void, SDL_WarpMouse, (Uint16 x, Uint16 y) );
+NV_SDL_FUN( SDL_Cursor *, SDL_CreateCursor, (Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y) );
+NV_SDL_FUN( void, SDL_SetCursor, (SDL_Cursor *cursor) );
+NV_SDL_FUN( SDL_Cursor *, SDL_GetCursor, (void) );
+NV_SDL_FUN( void, SDL_FreeCursor, (SDL_Cursor *cursor) );
+NV_SDL_FUN( int, SDL_ShowCursor, (int toggle) );
+
+/* SDL_joystick.h functions */
+NV_SDL_FUN( int, SDL_NumJoysticks, (void) );
+NV_SDL_FUN( const char *, SDL_JoystickName, (int device_index) );
+NV_SDL_FUN( SDL_Joystick *, SDL_JoystickOpen, (int device_index) );
+NV_SDL_FUN( int, SDL_JoystickOpened, (int device_index) );
+NV_SDL_FUN( int, SDL_JoystickIndex, (SDL_Joystick *joystick) );
+NV_SDL_FUN( int, SDL_JoystickNumAxes, (SDL_Joystick *joystick) );
+NV_SDL_FUN( int, SDL_JoystickNumBalls, (SDL_Joystick *joystick) );
+NV_SDL_FUN( int, SDL_JoystickNumHats, (SDL_Joystick *joystick) );
+NV_SDL_FUN( int, SDL_JoystickNumButtons, (SDL_Joystick *joystick) );
+NV_SDL_FUN( void, SDL_JoystickUpdate, (void) );
+NV_SDL_FUN( int, SDL_JoystickEventState, (int state) );
+NV_SDL_FUN( Sint16, SDL_JoystickGetAxis, (SDL_Joystick *joystick, int axis) );
+NV_SDL_FUN( Uint8, SDL_JoystickGetHat, (SDL_Joystick *joystick, int hat) );
+NV_SDL_FUN( int, SDL_JoystickGetBall, (SDL_Joystick *joystick, int ball, int *dx, int *dy) );
+NV_SDL_FUN( Uint8, SDL_JoystickGetButton, (SDL_Joystick *joystick, int button) );
+NV_SDL_FUN( void, SDL_JoystickClose, (SDL_Joystick *joystick) );
+
+/* SDL_timer.h functions */
+NV_SDL_FUN( Uint32, SDL_GetTicks, (void) );
+NV_SDL_FUN( void, SDL_Delay, (Uint32 ms) );
+NV_SDL_FUN( int, SDL_SetTimer, (Uint32 interval, SDL_TimerCallback callback) );
+NV_SDL_FUN( SDL_TimerID, SDL_AddTimer, (Uint32 interval, SDL_NewTimerCallback callback, void *param) );
+NV_SDL_FUN( SDL_bool, SDL_RemoveTimer, (SDL_TimerID t) );
+
+/* SDL_version.h functions */
+NV_SDL_FUN( const SDL_version *, SDL_Linked_Version, (void) ); 
+
+/* SDL_event.h functions */
+NV_SDL_FUN( void, SDL_PumpEvents, (void) );
+NV_SDL_FUN( int, SDL_PeepEvents, (SDL_Event *events, int numevents, SDL_eventaction action, Uint32 mask) );
+NV_SDL_FUN( int, SDL_PollEvent, (SDL_Event *event) );
+NV_SDL_FUN( int, SDL_WaitEvent, (SDL_Event *event) );
+NV_SDL_FUN( int, SDL_PushEvent, (SDL_Event *event) );
+NV_SDL_FUN( void, SDL_SetEventFilter, (SDL_EventFilter filter) );
+NV_SDL_FUN( SDL_EventFilter, SDL_GetEventFilter, (void) );
+NV_SDL_FUN( Uint8, SDL_EventState, (Uint8 etype, int state) );
Index: /trunk/nv/lib/detail/sdl_image_functions.inc
===================================================================
--- /trunk/nv/lib/detail/sdl_image_functions.inc	(revision 168)
+++ /trunk/nv/lib/detail/sdl_image_functions.inc	(revision 168)
@@ -0,0 +1,21 @@
+NV_SDL_FUN( const SDL_version *, IMG_Linked_Version, (void) );
+NV_SDL_FUN( int, IMG_Init, (int flags) );
+NV_SDL_FUN( void, IMG_Quit, (void) );
+NV_SDL_FUN( SDL_Surface *, IMG_LoadTyped_RW, (SDL_RWops *src, int freesrc, char *etype) );
+NV_SDL_FUN( SDL_Surface *, IMG_Load, (const char *file) );
+NV_SDL_FUN( SDL_Surface *, IMG_Load_RW, (SDL_RWops *src, int freesrc) );
+NV_SDL_FUN( int, IMG_isICO, (SDL_RWops *src) );
+NV_SDL_FUN( int, IMG_isCUR, (SDL_RWops *src) );
+NV_SDL_FUN( int, IMG_isBMP, (SDL_RWops *src) );
+NV_SDL_FUN( int, IMG_isGIF, (SDL_RWops *src) );
+NV_SDL_FUN( int, IMG_isJPG, (SDL_RWops *src) );
+NV_SDL_FUN( int, IMG_isPNG, (SDL_RWops *src) );
+NV_SDL_FUN( int, IMG_isTIF, (SDL_RWops *src) );
+NV_SDL_FUN( SDL_Surface *, IMG_LoadICO_RW, (SDL_RWops *src) );
+NV_SDL_FUN( SDL_Surface *, IMG_LoadCUR_RW, (SDL_RWops *src) );
+NV_SDL_FUN( SDL_Surface *, IMG_LoadBMP_RW, (SDL_RWops *src) );
+NV_SDL_FUN( SDL_Surface *, IMG_LoadGIF_RW, (SDL_RWops *src) );
+NV_SDL_FUN( SDL_Surface *, IMG_LoadJPG_RW, (SDL_RWops *src) );
+NV_SDL_FUN( SDL_Surface *, IMG_LoadPNG_RW, (SDL_RWops *src) );
+NV_SDL_FUN( SDL_Surface *, IMG_LoadTGA_RW, (SDL_RWops *src) );
+NV_SDL_FUN( SDL_Surface *, IMG_LoadTIF_RW, (SDL_RWops *src) );
Index: /trunk/nv/lib/sdl12.hh
===================================================================
--- /trunk/nv/lib/sdl12.hh	(revision 167)
+++ /trunk/nv/lib/sdl12.hh	(revision 168)
@@ -13,10 +13,31 @@
 //#define NV_SDL_SHARED
 
+#define NV_SDL_C      0
+#define NV_SDL_12     1
+#define NV_SDL_20     2
+
+#if !defined(NV_SDL_VERSION)
+#	define NV_SDL_VERSION     NV_SDL_12
+#endif
+
 #if NV_PLATFORM == NV_WINDOWS
-#	define NV_SDL_PATH "SDL.dll"
+#	define NV_SDL_PATH_12 "SDL.dll"
+#	define NV_SDL_PATH_20 "SDL2.dll"
 #elif NV_PLATFORM == NV_APPLE
-#	define NV_SDL_PATH "SDL.framework/SDL"
+#	define NV_SDL_PATH_12 "SDL.framework/SDL"
+#	define NV_SDL_PATH_20 "SDL2.framework/SDL"
 #else
-#	define NV_SDL_PATH "libSDL-1.2.so.0"
+#	define NV_SDL_PATH_12 "libSDL-1.2.so.0"
+#	define NV_SDL_PATH_20 "libSDL-1.2.so.0"
+#endif
+
+#if NV_SDL_VERSION == NV_SDL_12
+#	define NV_SDL_PATH NV_SDL_PATH_12
+#elif NV_SDL_VERSION == NV_SDL_20 
+#	define NV_SDL_PATH NV_SDL_PATH_20
+#elif NV_SDL_VERSION == NV_SDL_C
+#	define NV_SDL_PATH nullptr
+#else
+#	error "Unrecognized NV_SDL_VERSION!"
 #endif
 
@@ -37,14 +58,4 @@
 #	define NV_SDL_API extern
 #endif
-
-#if defined(NV_SDL_DYNAMIC)
-#	define NV_SDL_FUN( rtype, fname, fparams ) NV_SDL_API rtype (NV_SDL_APIENTRY *fname) fparams
-#else
-#	define NV_SDL_FUN( rtype, fname, fparams ) NV_SDL_API rtype NV_SDL_APIENTRY fname fparams
-#endif
-
-/** REMOVE THIS */
-#define DECLSPEC NV_SDL_API
-#define SDLCALL
 
 /* SDL_stdinc.h types */
@@ -81,10 +92,19 @@
 #define SDL_INIT_AUDIO		0x00000010
 #define SDL_INIT_VIDEO		0x00000020
-#define SDL_INIT_CDROM		0x00000100
 #define SDL_INIT_JOYSTICK	0x00000200
-#define SDL_INIT_NOPARACHUTE	0x00100000
-#define SDL_INIT_EVENTTHREAD	0x01000000
-#define SDL_INIT_EVERYTHING	0x0000FFFF 
-
+#if NV_SDL_VERSION == NV_SDL_20
+#define SDL_INIT_NOPARACHUTE    0x00100000
+#define SDL_INIT_EVENTTHREAD    0x01000000
+#define SDL_INIT_EVERYTHING     0x0000FFFF 
+#else
+#define SDL_INIT_HAPTIC         0x00001000
+#define SDL_INIT_GAMECONTROLLER 0x00002000 
+#define SDL_INIT_EVENTS         0x00004000
+#define SDL_INIT_NOPARACHUTE    0x00100000
+#define SDL_INIT_EVERYTHING ( \
+	SDL_INIT_TIMER | SDL_INIT_AUDIO | SDL_INIT_VIDEO | SDL_INIT_EVENTS | \
+	SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC | SDL_INIT_GAMECONTROLLER \
+	) 
+#endif
 /* SDL_error.h defines */
 typedef enum {
@@ -97,10 +117,26 @@
 } SDL_errorcode;
 
+#if NV_SDL_VERSION == NV_SDL_20
+#define SDL_RWOPS_UNKNOWN   0
+#define SDL_RWOPS_WINFILE   1
+#define SDL_RWOPS_STDFILE   2
+#define SDL_RWOPS_JNIFILE   3
+#define SDL_RWOPS_MEMORY    4
+#define SDL_RWOPS_MEMORY_RO 5
+#endif
+
 /* SDL_rwops.h defines */
 typedef struct SDL_RWops {
-	int (SDLCALL *seek)(struct SDL_RWops *context, int offset, int whence);
-	int (SDLCALL *read)(struct SDL_RWops *context, void *ptr, int size, int maxnum);
-	int (SDLCALL *write)(struct SDL_RWops *context, const void *ptr, int size, int num);
-	int (SDLCALL *close)(struct SDL_RWops *context);
+#if NV_SDL_VERSION == NV_SDL_20
+	Sint64 (NV_SDL_APIENTRY *size)(struct SDL_RWops *context);
+	Sint64 (NV_SDL_APIENTRY *seek)(struct SDL_RWops *context, Sint64 offset, int whence);
+	size_t (NV_SDL_APIENTRY *read)(struct SDL_RWops *context, void *ptr, size_t size, size_t maxnum);
+	size_t (NV_SDL_APIENTRY *write)(struct SDL_RWops *context, const void *ptr, size_t size, size_t num);
+#else
+	int (NV_SDL_APIENTRY *seek)(struct SDL_RWops *context, int offset, int whence);
+	int (NV_SDL_APIENTRY *read)(struct SDL_RWops *context, void *ptr, int size, int maxnum);
+	int (NV_SDL_APIENTRY *write)(struct SDL_RWops *context, const void *ptr, int size, int num);
+#endif
+	int (NV_SDL_APIENTRY *close)(struct SDL_RWops *context);
 
 	Uint32 type;
@@ -128,4 +164,5 @@
 	    struct {
 		void *data1;
+		void *data2;
 	    } unknown;
 	} hidden;
@@ -137,8 +174,21 @@
 #define SDL_ALPHA_TRANSPARENT 0
 
+#if NV_SDL_VERSION == NV_SDL_20
+typedef struct
+{
+	int x;
+	int y;
+} SDL_Point;
+
+typedef struct SDL_Rect {
+	int x, y;
+	int w, h;
+} SDL_Rect;
+#else
 typedef struct SDL_Rect {
 	Sint16 x, y;
 	Uint16 w, h;
 } SDL_Rect;
+#endif
 
 typedef struct SDL_Color {
@@ -146,13 +196,44 @@
 	Uint8 g;
 	Uint8 b;
+#if NV_SDL_VERSION == NV_SDL_20
 	Uint8 unused;
+#else
+	Uint8 a;
+#endif
 } SDL_Color;
-#define SDL_Colour SDL_Color
 
 typedef struct SDL_Palette {
 	int       ncolors;
 	SDL_Color *colors;
+#if NV_SDL_VERSION == NV_SDL_20
+	Uint32    version;
+	int       refcount;
+#endif
+
 } SDL_Palette;
 
+#if NV_SDL_VERSION == NV_SDL_20
+typedef struct SDL_PixelFormat {
+	Uint32 format;
+	SDL_Palette *palette;
+	Uint8  BitsPerPixel;
+	Uint8  BytesPerPixel;
+	Uint8  padding[2];
+	Uint32 Rmask;
+	Uint32 Gmask;
+	Uint32 Bmask;
+	Uint32 Amask;
+	Uint8 Rloss;
+	Uint8 Gloss;
+	Uint8 Bloss;
+	Uint8 Aloss;
+	Uint8 Rshift;
+	Uint8 Gshift;
+	Uint8 Bshift;
+	Uint8 Ashift;
+	int refcount;
+	struct SDL_PixelFormat *next; 
+} SDL_PixelFormat;
+#else
 typedef struct SDL_PixelFormat {
 	SDL_Palette *palette;
@@ -175,4 +256,16 @@
 	Uint8  alpha;
 } SDL_PixelFormat;
+#endif
+
+#if NV_SDL_VERSION == NV_SDL_20
+typedef struct
+{
+	Uint32 format; 
+	int w;
+	int h;
+	int refresh_rate;
+	void *driverdata;
+} SDL_DisplayMode;
+#endif
 
 typedef struct SDL_Surface {
@@ -234,22 +327,4 @@
 	int    current_h;
 } SDL_VideoInfo;
-
-#define SDL_YV12_OVERLAY  0x32315659
-#define SDL_IYUV_OVERLAY  0x56555949
-#define SDL_YUY2_OVERLAY  0x32595559
-#define SDL_UYVY_OVERLAY  0x59565955
-#define SDL_YVYU_OVERLAY  0x55595659
-
-typedef struct SDL_Overlay {
-	Uint32 format;
-	int w, h;
-	int planes;
-	Uint16 *pitches;
-	Uint8 **pixels;
-	struct private_yuvhwfuncs *hwfuncs;
-	struct private_yuvhwdata *hwdata;
-	Uint32 hw_overlay :1;
-	Uint32 UnusedBits :31;
-} SDL_Overlay;
 
 typedef enum {
@@ -292,5 +367,5 @@
 	Uint16 padding;
 	Uint32 size;
-	void (SDLCALL *callback)(void *userdata, Uint8 *stream, int len);
+	void (NV_SDL_APIENTRY *callback)(void *userdata, Uint8 *stream, int len);
 	void  *userdata;
 } SDL_AudioSpec;
@@ -319,5 +394,5 @@
 	int    len_mult;
 	double len_ratio;
-	void (SDLCALL *filters[10])(struct SDL_AudioCVT *cvt, Uint16 format);
+	void (NV_SDL_APIENTRY *filters[10])(struct SDL_AudioCVT *cvt, Uint16 format);
 	int filter_index;
 } SDL_AudioCVT; 
@@ -819,5 +894,5 @@
 } SDL_eventaction;
 
-typedef int (SDLCALL *SDL_EventFilter)(const SDL_Event *event);
+typedef int (NV_SDL_APIENTRY *SDL_EventFilter)(const SDL_Event *event);
 
 #define SDL_QUERY	-1
@@ -829,6 +904,6 @@
 #define SDL_TIMESLICE		10
 #define TIMER_RESOLUTION	10
-typedef Uint32 (SDLCALL *SDL_TimerCallback)(Uint32 interval);
-typedef Uint32 (SDLCALL *SDL_NewTimerCallback)(Uint32 interval, void *param);
+typedef Uint32 (NV_SDL_APIENTRY *SDL_TimerCallback)(Uint32 interval);
+typedef Uint32 (NV_SDL_APIENTRY *SDL_NewTimerCallback)(Uint32 interval, void *param);
 typedef struct _SDL_TimerID *SDL_TimerID;
 
@@ -844,180 +919,11 @@
 } SDL_version;
 
-/* SDL.h functions */
-NV_SDL_FUN( int, SDL_Init, (Uint32 flags) );
-NV_SDL_FUN( int, SDL_InitSubSystem, (Uint32 flags) );
-NV_SDL_FUN( void, SDL_QuitSubSystem, (Uint32 flags) );
-NV_SDL_FUN( Uint32, SDL_WasInit, (Uint32 flags) );
-NV_SDL_FUN( void, SDL_Quit, (void) );
-
-/* SDL_rwops.h functions */
-NV_SDL_FUN( SDL_RWops *, SDL_RWFromFile, (const char *file, const char *mode) );
-NV_SDL_FUN( SDL_RWops *, SDL_RWFromFP, (FILE *fp, int autoclose) );
-NV_SDL_FUN( SDL_RWops *, SDL_RWFromMem, (void *mem, int size) );
-NV_SDL_FUN( SDL_RWops *, SDL_RWFromConstMem, (const void *mem, int size) );
-NV_SDL_FUN( SDL_RWops *, SDL_AllocRW, (void) );
-NV_SDL_FUN( void, SDL_FreeRW, (SDL_RWops *area) );
-NV_SDL_FUN( Uint16, SDL_ReadLE16, (SDL_RWops *src) );
-NV_SDL_FUN( Uint16, SDL_ReadBE16, (SDL_RWops *src) );
-NV_SDL_FUN( Uint32, SDL_ReadLE32, (SDL_RWops *src) );
-NV_SDL_FUN( Uint32, SDL_ReadBE32, (SDL_RWops *src) );
-NV_SDL_FUN( Uint64, SDL_ReadLE64, (SDL_RWops *src) );
-NV_SDL_FUN( Uint64, SDL_ReadBE64, (SDL_RWops *src) );
-NV_SDL_FUN( int, SDL_WriteLE16, (SDL_RWops *dst, Uint16 value) );
-NV_SDL_FUN( int, SDL_WriteBE16, (SDL_RWops *dst, Uint16 value) );
-NV_SDL_FUN( int, SDL_WriteLE32, (SDL_RWops *dst, Uint32 value) );
-NV_SDL_FUN( int, SDL_WriteBE32, (SDL_RWops *dst, Uint32 value) );
-NV_SDL_FUN( int, SDL_WriteLE64, (SDL_RWops *dst, Uint64 value) );
-NV_SDL_FUN( int, SDL_WriteBE64, (SDL_RWops *dst, Uint64 value) );
-
-/* SDL_video.h defines */
-NV_SDL_FUN( int, SDL_VideoInit, (const char *driver_name, Uint32 flags) );
-NV_SDL_FUN( void, SDL_VideoQuit, (void) );
-NV_SDL_FUN( char *, SDL_VideoDriverName, (char *namebuf, int maxlen) );
-NV_SDL_FUN( SDL_Surface *, SDL_GetVideoSurface, (void) );
-NV_SDL_FUN( const SDL_VideoInfo *, SDL_GetVideoInfo, (void) );
-NV_SDL_FUN( int, SDL_VideoModeOK, (int width, int height, int bpp, Uint32 flags) );
-NV_SDL_FUN( SDL_Rect **, SDL_ListModes, (SDL_PixelFormat *format, Uint32 flags) );
-NV_SDL_FUN( SDL_Surface *, SDL_SetVideoMode, (int width, int height, int bpp, Uint32 flags) );
-NV_SDL_FUN( void, SDL_UpdateRects, (SDL_Surface *screen, int numrects, SDL_Rect *rects) );
-NV_SDL_FUN( void, SDL_UpdateRect, (SDL_Surface *screen, Sint32 x, Sint32 y, Uint32 w, Uint32 h) );
-NV_SDL_FUN( int, SDL_Flip, (SDL_Surface *screen) );
-NV_SDL_FUN( int, SDL_SetGamma, (float red, float green, float blue) );
-NV_SDL_FUN( int, SDL_SetGammaRamp, (const Uint16 *red, const Uint16 *green, const Uint16 *blue) );
-NV_SDL_FUN( int, SDL_GetGammaRamp, (Uint16 *red, Uint16 *green, Uint16 *blue) );
-NV_SDL_FUN( int, SDL_SetColors, (SDL_Surface *surface, SDL_Color *colors, int firstcolor, int ncolors) );
-NV_SDL_FUN( int, SDL_SetPalette, (SDL_Surface *surface, int flags, SDL_Color *colors, int firstcolor, int ncolors) );
-NV_SDL_FUN( Uint32, SDL_MapRGB, (const SDL_PixelFormat * const format, const Uint8 r, const Uint8 g, const Uint8 b) );
-NV_SDL_FUN( Uint32, SDL_MapRGBA, (const SDL_PixelFormat * const format, const Uint8 r, const Uint8 g, const Uint8 b, const Uint8 a) );
-NV_SDL_FUN( void, SDL_GetRGB, (Uint32 pixel, const SDL_PixelFormat * const fmt, Uint8 *r, Uint8 *g, Uint8 *b) );
-NV_SDL_FUN( void, SDL_GetRGBA, (Uint32 pixel,	const SDL_PixelFormat * const fmt, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a) );
-NV_SDL_FUN( SDL_Surface *, SDL_CreateRGBSurface, (Uint32 flags, int width, int height, int depth, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask) );
-NV_SDL_FUN( SDL_Surface *, SDL_CreateRGBSurfaceFrom, (void *pixels, int width, int height, int depth, int pitch, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask) );
-NV_SDL_FUN( void, SDL_FreeSurface, (SDL_Surface *surface) );
-NV_SDL_FUN( int, SDL_LockSurface, (SDL_Surface *surface) );
-NV_SDL_FUN( void, SDL_UnlockSurface, (SDL_Surface *surface) );
-NV_SDL_FUN( SDL_Surface *, SDL_LoadBMP_RW, (SDL_RWops *src, int freesrc) );
-NV_SDL_FUN( int, SDL_SaveBMP_RW, (SDL_Surface *surface, SDL_RWops *dst, int freedst) );
-NV_SDL_FUN( int, SDL_SetColorKey, (SDL_Surface *surface, Uint32 flag, Uint32 key) );
-NV_SDL_FUN( int, SDL_SetAlpha, (SDL_Surface *surface, Uint32 flag, Uint8 alpha) );
-NV_SDL_FUN( SDL_bool, SDL_SetClipRect, (SDL_Surface *surface, const SDL_Rect *rect) );
-NV_SDL_FUN( void, SDL_GetClipRect, (SDL_Surface *surface, SDL_Rect *rect) );
-NV_SDL_FUN( SDL_Surface *, SDL_ConvertSurface, (SDL_Surface *src, SDL_PixelFormat *fmt, Uint32 flags) );
-NV_SDL_FUN( int, SDL_UpperBlit, (SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect) );
-NV_SDL_FUN( int, SDL_LowerBlit, (SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect) );
-NV_SDL_FUN( int, SDL_FillRect, (SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color) );
-NV_SDL_FUN( SDL_Surface *, SDL_DisplayFormat, (SDL_Surface *surface) );
-NV_SDL_FUN( SDL_Surface *, SDL_DisplayFormatAlpha, (SDL_Surface *surface) );
-NV_SDL_FUN( SDL_Overlay *, SDL_CreateYUVOverlay, (int width, int height, Uint32 format, SDL_Surface *display) );
-NV_SDL_FUN( int, SDL_LockYUVOverlay, (SDL_Overlay *overlay) );
-NV_SDL_FUN( void, SDL_UnlockYUVOverlay, (SDL_Overlay *overlay) );
-NV_SDL_FUN( int, SDL_DisplayYUVOverlay, (SDL_Overlay *overlay, SDL_Rect *dstrect) );
-NV_SDL_FUN( void, SDL_FreeYUVOverlay, (SDL_Overlay *overlay) );
-NV_SDL_FUN( int, SDL_GL_LoadLibrary, (const char *path) );
-NV_SDL_FUN( void *, SDL_GL_GetProcAddress, (const char* proc) );
-NV_SDL_FUN( int, SDL_GL_SetAttribute, (SDL_GLattr attr, int value) );
-NV_SDL_FUN( int, SDL_GL_GetAttribute, (SDL_GLattr attr, int* value) );
-NV_SDL_FUN( void, SDL_GL_SwapBuffers, (void) );
-NV_SDL_FUN( void, SDL_GL_UpdateRects, (int numrects, SDL_Rect* rects) );
-NV_SDL_FUN( void, SDL_GL_Lock, (void) );
-NV_SDL_FUN( void, SDL_GL_Unlock, (void) );
-NV_SDL_FUN( void, SDL_WM_SetCaption, (const char *title, const char *icon) );
-NV_SDL_FUN( void, SDL_WM_GetCaption, (char **title, char **icon) );
-NV_SDL_FUN( void, SDL_WM_SetIcon, (SDL_Surface *icon, Uint8 *mask) );
-NV_SDL_FUN( int, SDL_WM_IconifyWindow, (void) );
-NV_SDL_FUN( int, SDL_WM_ToggleFullScreen, (SDL_Surface *surface) );
-NV_SDL_FUN( SDL_GrabMode, SDL_WM_GrabInput, (SDL_GrabMode mode) ); 
-
-/* SDL_audio.h functions */
-NV_SDL_FUN( int, SDL_AudioInit, (const char *driver_name) );
-NV_SDL_FUN( void, SDL_AudioQuit, (void) ); 
-NV_SDL_FUN( char *, SDL_AudioDriverName, (char *namebuf, int maxlen) );
-NV_SDL_FUN( int, SDL_OpenAudio, (SDL_AudioSpec *desired, SDL_AudioSpec *obtained) );
-NV_SDL_FUN( SDL_audiostatus, SDL_GetAudioStatus, (void) );
-NV_SDL_FUN( void, SDL_PauseAudio, (int pause_on) );
-NV_SDL_FUN( SDL_AudioSpec *, SDL_LoadWAV_RW, (SDL_RWops *src, int freesrc, SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len) );
-NV_SDL_FUN( void, SDL_FreeWAV, (Uint8 *audio_buf) );
-NV_SDL_FUN( int, SDL_BuildAudioCVT, (SDL_AudioCVT *cvt, Uint16 src_format, Uint8 src_channels, int src_rate, Uint16 dst_format, Uint8 dst_channels, int dst_rate) );
-NV_SDL_FUN( int, SDL_ConvertAudio, (SDL_AudioCVT *cvt) );
-NV_SDL_FUN( void, SDL_MixAudio, (Uint8 *dst, const Uint8 *src, Uint32 len, int volume) );
-NV_SDL_FUN( void, SDL_LockAudio, (void) );
-NV_SDL_FUN( void, SDL_UnlockAudio, (void) );
-NV_SDL_FUN( void, SDL_CloseAudio, (void) );  
-
-/* SDL_cpuinfo.h functions */
-NV_SDL_FUN( SDL_bool, SDL_HasRDTSC, (void) );
-NV_SDL_FUN( SDL_bool, SDL_HasMMX, (void) );
-NV_SDL_FUN( SDL_bool, SDL_HasMMXExt, (void) );
-NV_SDL_FUN( SDL_bool, SDL_Has3DNow, (void) );
-NV_SDL_FUN( SDL_bool, SDL_Has3DNowExt, (void) );
-NV_SDL_FUN( SDL_bool, SDL_HasSSE, (void) );
-NV_SDL_FUN( SDL_bool, SDL_HasSSE2, (void) );
-NV_SDL_FUN( SDL_bool, SDL_HasAltiVec, (void) ); 
-
-/* SDL_error.h functions */
-NV_SDL_FUN( void, SDL_SetError, (const char *fmt, ...) );
-NV_SDL_FUN( char *, SDL_GetError, (void) );
-NV_SDL_FUN( void, SDL_ClearError, (void) );
-NV_SDL_FUN( void, SDL_Error, (SDL_errorcode code) );
-
-/* SDL_active.h functions */
-NV_SDL_FUN( Uint8, SDL_GetAppState, (void) );
-
-/* SDL_keyboard.h functions */
-NV_SDL_FUN( int, SDL_EnableUNICODE, (int enable) );
-NV_SDL_FUN( int, SDL_EnableKeyRepeat, (int delay, int interval) );
-NV_SDL_FUN( void, SDL_GetKeyRepeat, (int *delay, int *interval) );
-NV_SDL_FUN( Uint8 *, SDL_GetKeyState, (int *numkeys) );
-NV_SDL_FUN( SDLMod, SDL_GetModState, (void) );
-NV_SDL_FUN( void, SDL_SetModState, (SDLMod modstate) );
-NV_SDL_FUN( char *, SDL_GetKeyName, (SDLKey key) );
- 
-/* SDL_mouse.h functions */
-NV_SDL_FUN( Uint8, SDL_GetMouseState, (int *x, int *y) );
-NV_SDL_FUN( Uint8, SDL_GetRelativeMouseState, (int *x, int *y) );
-NV_SDL_FUN( void, SDL_WarpMouse, (Uint16 x, Uint16 y) );
-NV_SDL_FUN( SDL_Cursor *, SDL_CreateCursor, (Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y) );
-NV_SDL_FUN( void, SDL_SetCursor, (SDL_Cursor *cursor) );
-NV_SDL_FUN( SDL_Cursor *, SDL_GetCursor, (void) );
-NV_SDL_FUN( void, SDL_FreeCursor, (SDL_Cursor *cursor) );
-NV_SDL_FUN( int, SDL_ShowCursor, (int toggle) );
-
-/* SDL_joystick.h functions */
-NV_SDL_FUN( int, SDL_NumJoysticks, (void) );
-NV_SDL_FUN( const char *, SDL_JoystickName, (int device_index) );
-NV_SDL_FUN( SDL_Joystick *, SDL_JoystickOpen, (int device_index) );
-NV_SDL_FUN( int, SDL_JoystickOpened, (int device_index) );
-NV_SDL_FUN( int, SDL_JoystickIndex, (SDL_Joystick *joystick) );
-NV_SDL_FUN( int, SDL_JoystickNumAxes, (SDL_Joystick *joystick) );
-NV_SDL_FUN( int, SDL_JoystickNumBalls, (SDL_Joystick *joystick) );
-NV_SDL_FUN( int, SDL_JoystickNumHats, (SDL_Joystick *joystick) );
-NV_SDL_FUN( int, SDL_JoystickNumButtons, (SDL_Joystick *joystick) );
-NV_SDL_FUN( void, SDL_JoystickUpdate, (void) );
-NV_SDL_FUN( int, SDL_JoystickEventState, (int state) );
-NV_SDL_FUN( Sint16, SDL_JoystickGetAxis, (SDL_Joystick *joystick, int axis) );
-NV_SDL_FUN( Uint8, SDL_JoystickGetHat, (SDL_Joystick *joystick, int hat) );
-NV_SDL_FUN( int, SDL_JoystickGetBall, (SDL_Joystick *joystick, int ball, int *dx, int *dy) );
-NV_SDL_FUN( Uint8, SDL_JoystickGetButton, (SDL_Joystick *joystick, int button) );
-NV_SDL_FUN( void, SDL_JoystickClose, (SDL_Joystick *joystick) );
-
-/* SDL_timer.h functions */
-NV_SDL_FUN( Uint32, SDL_GetTicks, (void) );
-NV_SDL_FUN( void, SDL_Delay, (Uint32 ms) );
-NV_SDL_FUN( int, SDL_SetTimer, (Uint32 interval, SDL_TimerCallback callback) );
-NV_SDL_FUN( SDL_TimerID, SDL_AddTimer, (Uint32 interval, SDL_NewTimerCallback callback, void *param) );
-NV_SDL_FUN( SDL_bool, SDL_RemoveTimer, (SDL_TimerID t) );
-
-/* SDL_version.h functions */
-NV_SDL_FUN( const SDL_version *, SDL_Linked_Version, (void) ); 
-
-/* SDL_event.h functions */
-NV_SDL_FUN( void, SDL_PumpEvents, (void) );
-NV_SDL_FUN( int, SDL_PeepEvents, (SDL_Event *events, int numevents, SDL_eventaction action, Uint32 mask) );
-NV_SDL_FUN( int, SDL_PollEvent, (SDL_Event *event) );
-NV_SDL_FUN( int, SDL_WaitEvent, (SDL_Event *event) );
-NV_SDL_FUN( int, SDL_PushEvent, (SDL_Event *event) );
-NV_SDL_FUN( void, SDL_SetEventFilter, (SDL_EventFilter filter) );
-NV_SDL_FUN( SDL_EventFilter, SDL_GetEventFilter, (void) );
-NV_SDL_FUN( Uint8, SDL_EventState, (Uint8 etype, int state) );
+#if defined(NV_SDL_DYNAMIC)
+#	define NV_SDL_FUN( rtype, fname, fparams ) NV_SDL_API rtype (NV_SDL_APIENTRY *fname) fparams
+#else
+#	define NV_SDL_FUN( rtype, fname, fparams ) NV_SDL_API rtype NV_SDL_APIENTRY fname fparams
+#endif
+#include <nv/lib/detail/sdl_functions.inc>
+#undef NV_SDL_FUN
 
 #define SDL_RWseek(ctx, offset, whence)	(ctx)->seek(ctx, offset, whence)
Index: /trunk/nv/lib/sdl_image.hh
===================================================================
--- /trunk/nv/lib/sdl_image.hh	(revision 167)
+++ /trunk/nv/lib/sdl_image.hh	(revision 168)
@@ -38,25 +38,12 @@
 } IMG_InitFlags;
 
-NV_SDL_FUN( const SDL_version *, IMG_Linked_Version, (void) );
-NV_SDL_FUN( int, IMG_Init, (int flags) );
-NV_SDL_FUN( void, IMG_Quit, (void) );
-NV_SDL_FUN( SDL_Surface *, IMG_LoadTyped_RW, (SDL_RWops *src, int freesrc, char *etype) );
-NV_SDL_FUN( SDL_Surface *, IMG_Load, (const char *file) );
-NV_SDL_FUN( SDL_Surface *, IMG_Load_RW, (SDL_RWops *src, int freesrc) );
-NV_SDL_FUN( int, IMG_isICO, (SDL_RWops *src) );
-NV_SDL_FUN( int, IMG_isCUR, (SDL_RWops *src) );
-NV_SDL_FUN( int, IMG_isBMP, (SDL_RWops *src) );
-NV_SDL_FUN( int, IMG_isGIF, (SDL_RWops *src) );
-NV_SDL_FUN( int, IMG_isJPG, (SDL_RWops *src) );
-NV_SDL_FUN( int, IMG_isPNG, (SDL_RWops *src) );
-NV_SDL_FUN( int, IMG_isTIF, (SDL_RWops *src) );
-NV_SDL_FUN( SDL_Surface *, IMG_LoadICO_RW, (SDL_RWops *src) );
-NV_SDL_FUN( SDL_Surface *, IMG_LoadCUR_RW, (SDL_RWops *src) );
-NV_SDL_FUN( SDL_Surface *, IMG_LoadBMP_RW, (SDL_RWops *src) );
-NV_SDL_FUN( SDL_Surface *, IMG_LoadGIF_RW, (SDL_RWops *src) );
-NV_SDL_FUN( SDL_Surface *, IMG_LoadJPG_RW, (SDL_RWops *src) );
-NV_SDL_FUN( SDL_Surface *, IMG_LoadPNG_RW, (SDL_RWops *src) );
-NV_SDL_FUN( SDL_Surface *, IMG_LoadTGA_RW, (SDL_RWops *src) );
-NV_SDL_FUN( SDL_Surface *, IMG_LoadTIF_RW, (SDL_RWops *src) );
+#if defined(NV_SDL_DYNAMIC)
+#	define NV_SDL_FUN( rtype, fname, fparams ) NV_SDL_API rtype (NV_SDL_APIENTRY *fname) fparams
+#else
+#	define NV_SDL_FUN( rtype, fname, fparams ) NV_SDL_API rtype NV_SDL_APIENTRY fname fparams
+#endif
+#include <nv/lib/detail/sdl_image_functions.inc>
+#undef NV_SDL_FUN
+
 }
 
Index: /trunk/src/lib/sdl12.cc
===================================================================
--- /trunk/src/lib/sdl12.cc	(revision 167)
+++ /trunk/src/lib/sdl12.cc	(revision 168)
@@ -11,366 +11,16 @@
 #include "nv/library.hh"
 
-/* SDL.h functions */
-int (NV_SDL_APIENTRY *SDL_Init) (Uint32 flags) = nullptr;
-int (NV_SDL_APIENTRY *SDL_InitSubSystem) (Uint32 flags) = nullptr;
-void (NV_SDL_APIENTRY *SDL_QuitSubSystem) (Uint32 flags) = nullptr;
-Uint32 (NV_SDL_APIENTRY *SDL_WasInit) (Uint32 flags) = nullptr;
-void (NV_SDL_APIENTRY *SDL_Quit) (void) = nullptr;
-
-/* SDL_rwops.h functions */
-SDL_RWops * (NV_SDL_APIENTRY *SDL_RWFromFile) (const char *file, const char *mode) = nullptr;
-SDL_RWops * (NV_SDL_APIENTRY *SDL_RWFromFP) (FILE *fp, int autoclose) = nullptr;
-SDL_RWops * (NV_SDL_APIENTRY *SDL_RWFromMem) (void *mem, int size) = nullptr;
-SDL_RWops * (NV_SDL_APIENTRY *SDL_RWFromConstMem) (const void *mem, int size) = nullptr;
-SDL_RWops * (NV_SDL_APIENTRY *SDL_AllocRW) (void) = nullptr;
-void (NV_SDL_APIENTRY *SDL_FreeRW) (SDL_RWops *area) = nullptr;
-Uint16 (NV_SDL_APIENTRY *SDL_ReadLE16) (SDL_RWops *src) = nullptr;
-Uint16 (NV_SDL_APIENTRY *SDL_ReadBE16) (SDL_RWops *src) = nullptr;
-Uint32 (NV_SDL_APIENTRY *SDL_ReadLE32) (SDL_RWops *src) = nullptr;
-Uint32 (NV_SDL_APIENTRY *SDL_ReadBE32) (SDL_RWops *src) = nullptr;
-Uint64 (NV_SDL_APIENTRY *SDL_ReadLE64) (SDL_RWops *src) = nullptr;
-Uint64 (NV_SDL_APIENTRY *SDL_ReadBE64) (SDL_RWops *src) = nullptr;
-int (NV_SDL_APIENTRY *SDL_WriteLE16) (SDL_RWops *dst, Uint16 value) = nullptr;
-int (NV_SDL_APIENTRY *SDL_WriteBE16) (SDL_RWops *dst, Uint16 value) = nullptr;
-int (NV_SDL_APIENTRY *SDL_WriteLE32) (SDL_RWops *dst, Uint32 value) = nullptr;
-int (NV_SDL_APIENTRY *SDL_WriteBE32) (SDL_RWops *dst, Uint32 value) = nullptr;
-int (NV_SDL_APIENTRY *SDL_WriteLE64) (SDL_RWops *dst, Uint64 value) = nullptr;
-int (NV_SDL_APIENTRY *SDL_WriteBE64) (SDL_RWops *dst, Uint64 value) = nullptr;
-
-/* SDL_video.h defines */
-int (NV_SDL_APIENTRY *SDL_VideoInit) (const char *driver_name, Uint32 flags) = nullptr;
-void (NV_SDL_APIENTRY *SDL_VideoQuit) (void) = nullptr;
-char * (NV_SDL_APIENTRY *SDL_VideoDriverName) (char *namebuf, int maxlen) = nullptr;
-SDL_Surface * (NV_SDL_APIENTRY *SDL_GetVideoSurface) (void) = nullptr;
-const SDL_VideoInfo * (NV_SDL_APIENTRY *SDL_GetVideoInfo) (void) = nullptr;
-int (NV_SDL_APIENTRY *SDL_VideoModeOK) (int width, int height, int bpp, Uint32 flags) = nullptr;
-SDL_Rect ** (NV_SDL_APIENTRY *SDL_ListModes) (SDL_PixelFormat *format, Uint32 flags) = nullptr;
-SDL_Surface * (NV_SDL_APIENTRY *SDL_SetVideoMode) (int width, int height, int bpp, Uint32 flags) = nullptr;
-void (NV_SDL_APIENTRY *SDL_UpdateRects) (SDL_Surface *screen, int numrects, SDL_Rect *rects) = nullptr;
-void (NV_SDL_APIENTRY *SDL_UpdateRect) (SDL_Surface *screen, Sint32 x, Sint32 y, Uint32 w, Uint32 h) = nullptr;
-int (NV_SDL_APIENTRY *SDL_Flip) (SDL_Surface *screen) = nullptr;
-int (NV_SDL_APIENTRY *SDL_SetGamma) (float red, float green, float blue) = nullptr;
-int (NV_SDL_APIENTRY *SDL_SetGammaRamp) (const Uint16 *red, const Uint16 *green, const Uint16 *blue) = nullptr;
-int (NV_SDL_APIENTRY *SDL_GetGammaRamp) (Uint16 *red, Uint16 *green, Uint16 *blue) = nullptr;
-int (NV_SDL_APIENTRY *SDL_SetColors) (SDL_Surface *surface, SDL_Color *colors, int firstcolor, int ncolors) = nullptr;
-int (NV_SDL_APIENTRY *SDL_SetPalette) (SDL_Surface *surface, int flags, SDL_Color *colors, int firstcolor, int ncolors) = nullptr;
-Uint32 (NV_SDL_APIENTRY *SDL_MapRGB) (const SDL_PixelFormat * const format, const Uint8 r, const Uint8 g, const Uint8 b) = nullptr;
-Uint32 (NV_SDL_APIENTRY *SDL_MapRGBA) (const SDL_PixelFormat * const format, const Uint8 r, const Uint8 g, const Uint8 b, const Uint8 a) = nullptr;
-void (NV_SDL_APIENTRY *SDL_GetRGB) (Uint32 pixel, const SDL_PixelFormat * const fmt, Uint8 *r, Uint8 *g, Uint8 *b) = nullptr;
-void (NV_SDL_APIENTRY *SDL_GetRGBA) (Uint32 pixel,	const SDL_PixelFormat * const fmt, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a) = nullptr;
-SDL_Surface * (NV_SDL_APIENTRY *SDL_CreateRGBSurface) (Uint32 flags, int width, int height, int depth, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask) = nullptr;
-SDL_Surface * (NV_SDL_APIENTRY *SDL_CreateRGBSurfaceFrom) (void *pixels, int width, int height, int depth, int pitch, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask) = nullptr;
-void (NV_SDL_APIENTRY *SDL_FreeSurface) (SDL_Surface *surface) = nullptr;
-int (NV_SDL_APIENTRY *SDL_LockSurface) (SDL_Surface *surface) = nullptr;
-void (NV_SDL_APIENTRY *SDL_UnlockSurface) (SDL_Surface *surface) = nullptr;
-SDL_Surface * (NV_SDL_APIENTRY *SDL_LoadBMP_RW) (SDL_RWops *src, int freesrc) = nullptr;
-int (NV_SDL_APIENTRY *SDL_SaveBMP_RW) (SDL_Surface *surface, SDL_RWops *dst, int freedst) = nullptr;
-int (NV_SDL_APIENTRY *SDL_SetColorKey) (SDL_Surface *surface, Uint32 flag, Uint32 key) = nullptr;
-int (NV_SDL_APIENTRY *SDL_SetAlpha) (SDL_Surface *surface, Uint32 flag, Uint8 alpha) = nullptr;
-SDL_bool (NV_SDL_APIENTRY *SDL_SetClipRect) (SDL_Surface *surface, const SDL_Rect *rect) = nullptr;
-void (NV_SDL_APIENTRY *SDL_GetClipRect) (SDL_Surface *surface, SDL_Rect *rect) = nullptr;
-SDL_Surface * (NV_SDL_APIENTRY *SDL_ConvertSurface) (SDL_Surface *src, SDL_PixelFormat *fmt, Uint32 flags) = nullptr;
-int (NV_SDL_APIENTRY *SDL_UpperBlit) (SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect) = nullptr;
-int (NV_SDL_APIENTRY *SDL_LowerBlit) (SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect) = nullptr;
-int (NV_SDL_APIENTRY *SDL_FillRect) (SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color) = nullptr;
-SDL_Surface * (NV_SDL_APIENTRY *SDL_DisplayFormat) (SDL_Surface *surface) = nullptr;
-SDL_Surface * (NV_SDL_APIENTRY *SDL_DisplayFormatAlpha) (SDL_Surface *surface) = nullptr;
-SDL_Overlay * (NV_SDL_APIENTRY *SDL_CreateYUVOverlay) (int width, int height, Uint32 format, SDL_Surface *display) = nullptr;
-int (NV_SDL_APIENTRY *SDL_LockYUVOverlay) (SDL_Overlay *overlay) = nullptr;
-void (NV_SDL_APIENTRY *SDL_UnlockYUVOverlay) (SDL_Overlay *overlay) = nullptr;
-int (NV_SDL_APIENTRY *SDL_DisplayYUVOverlay) (SDL_Overlay *overlay, SDL_Rect *dstrect) = nullptr;
-void (NV_SDL_APIENTRY *SDL_FreeYUVOverlay) (SDL_Overlay *overlay) = nullptr;
-int (NV_SDL_APIENTRY *SDL_GL_LoadLibrary) (const char *path) = nullptr;
-void * (NV_SDL_APIENTRY *SDL_GL_GetProcAddress) (const char* proc) = nullptr;
-int (NV_SDL_APIENTRY *SDL_GL_SetAttribute) (SDL_GLattr attr, int value) = nullptr;
-int (NV_SDL_APIENTRY *SDL_GL_GetAttribute) (SDL_GLattr attr, int* value) = nullptr;
-void (NV_SDL_APIENTRY *SDL_GL_SwapBuffers) (void) = nullptr;
-void (NV_SDL_APIENTRY *SDL_GL_UpdateRects) (int numrects, SDL_Rect* rects) = nullptr;
-void (NV_SDL_APIENTRY *SDL_GL_Lock) (void) = nullptr;
-void (NV_SDL_APIENTRY *SDL_GL_Unlock) (void) = nullptr;
-void (NV_SDL_APIENTRY *SDL_WM_SetCaption) (const char *title, const char *icon) = nullptr;
-void (NV_SDL_APIENTRY *SDL_WM_GetCaption) (char **title, char **icon) = nullptr;
-void (NV_SDL_APIENTRY *SDL_WM_SetIcon) (SDL_Surface *icon, Uint8 *mask) = nullptr;
-int (NV_SDL_APIENTRY *SDL_WM_IconifyWindow) (void) = nullptr;
-int (NV_SDL_APIENTRY *SDL_WM_ToggleFullScreen) (SDL_Surface *surface) = nullptr;
-SDL_GrabMode (NV_SDL_APIENTRY *SDL_WM_GrabInput) (SDL_GrabMode mode) = nullptr; 
-
-/* SDL_audio.h functions */
-int (NV_SDL_APIENTRY *SDL_AudioInit) (const char *driver_name) = nullptr;
-void (NV_SDL_APIENTRY *SDL_AudioQuit) (void) = nullptr; 
-char * (NV_SDL_APIENTRY *SDL_AudioDriverName) (char *namebuf, int maxlen) = nullptr;
-int (NV_SDL_APIENTRY *SDL_OpenAudio) (SDL_AudioSpec *desired, SDL_AudioSpec *obtained) = nullptr;
-SDL_audiostatus (NV_SDL_APIENTRY *SDL_GetAudioStatus) (void) = nullptr;
-void (NV_SDL_APIENTRY *SDL_PauseAudio) (int pause_on) = nullptr;
-SDL_AudioSpec * (NV_SDL_APIENTRY *SDL_LoadWAV_RW) (SDL_RWops *src, int freesrc, SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len) = nullptr;
-void (NV_SDL_APIENTRY *SDL_FreeWAV) (Uint8 *audio_buf) = nullptr;
-int (NV_SDL_APIENTRY *SDL_BuildAudioCVT) (SDL_AudioCVT *cvt, Uint16 src_format, Uint8 src_channels, int src_rate, Uint16 dst_format, Uint8 dst_channels, int dst_rate) = nullptr;
-int (NV_SDL_APIENTRY *SDL_ConvertAudio) (SDL_AudioCVT *cvt) = nullptr;
-void (NV_SDL_APIENTRY *SDL_MixAudio) (Uint8 *dst, const Uint8 *src, Uint32 len, int volume) = nullptr;
-void (NV_SDL_APIENTRY *SDL_LockAudio) (void) = nullptr;
-void (NV_SDL_APIENTRY *SDL_UnlockAudio) (void) = nullptr;
-void (NV_SDL_APIENTRY *SDL_CloseAudio) (void) = nullptr;  
-
-/* SDL_cpuinfo.h functions */
-SDL_bool (NV_SDL_APIENTRY *SDL_HasRDTSC) (void) = nullptr;
-SDL_bool (NV_SDL_APIENTRY *SDL_HasMMX) (void) = nullptr;
-SDL_bool (NV_SDL_APIENTRY *SDL_HasMMXExt) (void) = nullptr;
-SDL_bool (NV_SDL_APIENTRY *SDL_Has3DNow) (void) = nullptr;
-SDL_bool (NV_SDL_APIENTRY *SDL_Has3DNowExt) (void) = nullptr;
-SDL_bool (NV_SDL_APIENTRY *SDL_HasSSE) (void) = nullptr;
-SDL_bool (NV_SDL_APIENTRY *SDL_HasSSE2) (void) = nullptr;
-SDL_bool (NV_SDL_APIENTRY *SDL_HasAltiVec) (void) = nullptr; 
-
-/* SDL_error.h functions */
-void (NV_SDL_APIENTRY *SDL_SetError) (const char *fmt, ...) = nullptr;
-char * (NV_SDL_APIENTRY *SDL_GetError) (void) = nullptr;
-void (NV_SDL_APIENTRY *SDL_ClearError) (void) = nullptr;
-void (NV_SDL_APIENTRY *SDL_Error) (SDL_errorcode code) = nullptr;
-
-/* SDL_active.h functions */
-Uint8 (NV_SDL_APIENTRY *SDL_GetAppState) (void) = nullptr;
-
-/* SDL_keyboard.h functions */
-int (NV_SDL_APIENTRY *SDL_EnableUNICODE) (int enable) = nullptr;
-int (NV_SDL_APIENTRY *SDL_EnableKeyRepeat) (int delay, int interval) = nullptr;
-void (NV_SDL_APIENTRY *SDL_GetKeyRepeat) (int *delay, int *interval) = nullptr;
-Uint8 * (NV_SDL_APIENTRY *SDL_GetKeyState) (int *numkeys) = nullptr;
-SDLMod (NV_SDL_APIENTRY *SDL_GetModState) (void) = nullptr;
-void (NV_SDL_APIENTRY *SDL_SetModState) (SDLMod modstate) = nullptr;
-char * (NV_SDL_APIENTRY *SDL_GetKeyName) (SDLKey key) = nullptr;
- 
-/* SDL_mouse.h functions */
-Uint8 (NV_SDL_APIENTRY *SDL_GetMouseState) (int *x, int *y) = nullptr;
-Uint8 (NV_SDL_APIENTRY *SDL_GetRelativeMouseState) (int *x, int *y) = nullptr;
-void (NV_SDL_APIENTRY *SDL_WarpMouse) (Uint16 x, Uint16 y) = nullptr;
-SDL_Cursor * (NV_SDL_APIENTRY *SDL_CreateCursor) (Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y) = nullptr;
-void (NV_SDL_APIENTRY *SDL_SetCursor) (SDL_Cursor *cursor) = nullptr;
-SDL_Cursor * (NV_SDL_APIENTRY *SDL_GetCursor) (void) = nullptr;
-void (NV_SDL_APIENTRY *SDL_FreeCursor) (SDL_Cursor *cursor) = nullptr;
-int (NV_SDL_APIENTRY *SDL_ShowCursor) (int toggle) = nullptr;
-
-/* SDL_joystick.h functions */
-int (NV_SDL_APIENTRY *SDL_NumJoysticks) (void) = nullptr;
-const char * (NV_SDL_APIENTRY *SDL_JoystickName) (int device_index) = nullptr;
-SDL_Joystick * (NV_SDL_APIENTRY *SDL_JoystickOpen) (int device_index) = nullptr;
-int (NV_SDL_APIENTRY *SDL_JoystickOpened) (int device_index) = nullptr;
-int (NV_SDL_APIENTRY *SDL_JoystickIndex) (SDL_Joystick *joystick) = nullptr;
-int (NV_SDL_APIENTRY *SDL_JoystickNumAxes) (SDL_Joystick *joystick) = nullptr;
-int (NV_SDL_APIENTRY *SDL_JoystickNumBalls) (SDL_Joystick *joystick) = nullptr;
-int (NV_SDL_APIENTRY *SDL_JoystickNumHats) (SDL_Joystick *joystick) = nullptr;
-int (NV_SDL_APIENTRY *SDL_JoystickNumButtons) (SDL_Joystick *joystick) = nullptr;
-void (NV_SDL_APIENTRY *SDL_JoystickUpdate) (void) = nullptr;
-int (NV_SDL_APIENTRY *SDL_JoystickEventState) (int state) = nullptr;
-Sint16 (NV_SDL_APIENTRY *SDL_JoystickGetAxis) (SDL_Joystick *joystick, int axis) = nullptr;
-Uint8 (NV_SDL_APIENTRY *SDL_JoystickGetHat) (SDL_Joystick *joystick, int hat) = nullptr;
-int (NV_SDL_APIENTRY *SDL_JoystickGetBall) (SDL_Joystick *joystick, int ball, int *dx, int *dy) = nullptr;
-Uint8 (NV_SDL_APIENTRY *SDL_JoystickGetButton) (SDL_Joystick *joystick, int button) = nullptr;
-void (NV_SDL_APIENTRY *SDL_JoystickClose) (SDL_Joystick *joystick) = nullptr;
-
-/* SDL_event.h functions */
-void (NV_SDL_APIENTRY *SDL_PumpEvents) (void) = nullptr;
-int (NV_SDL_APIENTRY *SDL_PeepEvents) (SDL_Event *events, int numevents, SDL_eventaction action, Uint32 mask)  = nullptr;
-int (NV_SDL_APIENTRY *SDL_PollEvent) (SDL_Event *event) = nullptr;
-int (NV_SDL_APIENTRY *SDL_WaitEvent) (SDL_Event *event) = nullptr;
-int (NV_SDL_APIENTRY *SDL_PushEvent) (SDL_Event *event) = nullptr;
-void (NV_SDL_APIENTRY *SDL_SetEventFilter) (SDL_EventFilter filter) = nullptr;
-SDL_EventFilter (NV_SDL_APIENTRY *SDL_GetEventFilter) (void) = nullptr;
-Uint8 (NV_SDL_APIENTRY *SDL_EventState) (Uint8 type, int state) = nullptr;
-
-/* SDL_timer.h functions */
-Uint32 (NV_SDL_APIENTRY *SDL_GetTicks) (void) = nullptr;
-void (NV_SDL_APIENTRY *SDL_Delay) (Uint32 ms) = nullptr;
-int (NV_SDL_APIENTRY *SDL_SetTimer) (Uint32 interval, SDL_TimerCallback callback) = nullptr;
-SDL_TimerID (NV_SDL_APIENTRY *SDL_AddTimer) (Uint32 interval, SDL_NewTimerCallback callback, void *param) = nullptr;
-SDL_bool (NV_SDL_APIENTRY *SDL_RemoveTimer) (SDL_TimerID t) = nullptr;
-
-/* SDL_version.h functions */
-const SDL_version * (NV_SDL_APIENTRY *SDL_Linked_Version) (void) = nullptr; 
+#define NV_SDL_FUN( rtype, fname, fparams ) rtype (NV_SDL_APIENTRY *fname) fparams = nullptr;
+#include <nv/lib/detail/sdl_functions.inc>
+#undef NV_SDL_FUN
 
 bool nv::load_sdl_library( const char* path )
 {
-#	define NV_SDL_LOAD( symbol ) *(void **) (&symbol) = sdl_library.get(#symbol);
 	static nv::library sdl_library;
 	if ( sdl_library.is_open() ) return true;
 	sdl_library.open( path );
-
-/* SDL.h functions */
-	NV_SDL_LOAD( SDL_Init );
-	NV_SDL_LOAD( SDL_InitSubSystem );
-	NV_SDL_LOAD( SDL_QuitSubSystem );
-	NV_SDL_LOAD( SDL_WasInit );
-	NV_SDL_LOAD( SDL_Quit );
-
-/* SDL_rwops.h functions */
-	NV_SDL_LOAD( SDL_RWFromFile );
-	NV_SDL_LOAD( SDL_RWFromFP );
-	NV_SDL_LOAD( SDL_RWFromMem );
-	NV_SDL_LOAD( SDL_RWFromConstMem );
-	NV_SDL_LOAD( SDL_AllocRW );
-	NV_SDL_LOAD( SDL_FreeRW );
-	NV_SDL_LOAD( SDL_ReadLE16 );
-	NV_SDL_LOAD( SDL_ReadBE16 );
-	NV_SDL_LOAD( SDL_ReadLE32 );
-	NV_SDL_LOAD( SDL_ReadBE32 );
-	NV_SDL_LOAD( SDL_ReadLE64 );
-	NV_SDL_LOAD( SDL_ReadBE64 );
-	NV_SDL_LOAD( SDL_WriteLE16 );
-	NV_SDL_LOAD( SDL_WriteBE16 );
-	NV_SDL_LOAD( SDL_WriteLE32 );
-	NV_SDL_LOAD( SDL_WriteBE32 );
-	NV_SDL_LOAD( SDL_WriteLE64 );
-	NV_SDL_LOAD( SDL_WriteBE64 );
-
-/* SDL_video.h defines */
-	NV_SDL_LOAD( SDL_VideoInit );
-	NV_SDL_LOAD( SDL_VideoQuit );
-	NV_SDL_LOAD( SDL_VideoDriverName );
-	NV_SDL_LOAD( SDL_GetVideoSurface );
-	NV_SDL_LOAD( SDL_GetVideoInfo );
-	NV_SDL_LOAD( SDL_VideoModeOK );
-	NV_SDL_LOAD( SDL_ListModes );
-	NV_SDL_LOAD( SDL_SetVideoMode );
-	NV_SDL_LOAD( SDL_UpdateRects );
-	NV_SDL_LOAD( SDL_UpdateRect );
-	NV_SDL_LOAD( SDL_Flip );
-	NV_SDL_LOAD( SDL_SetGamma );
-	NV_SDL_LOAD( SDL_SetGammaRamp );
-	NV_SDL_LOAD( SDL_GetGammaRamp );
-	NV_SDL_LOAD( SDL_SetColors );
-	NV_SDL_LOAD( SDL_SetPalette );
-	NV_SDL_LOAD( SDL_MapRGB );
-	NV_SDL_LOAD( SDL_MapRGBA );
-	NV_SDL_LOAD( SDL_GetRGB );
-	NV_SDL_LOAD( SDL_GetRGBA );
-	NV_SDL_LOAD( SDL_CreateRGBSurface );
-	NV_SDL_LOAD( SDL_CreateRGBSurfaceFrom );
-	NV_SDL_LOAD( SDL_FreeSurface );
-	NV_SDL_LOAD( SDL_LockSurface );
-	NV_SDL_LOAD( SDL_UnlockSurface );
-	NV_SDL_LOAD( SDL_LoadBMP_RW );
-	NV_SDL_LOAD( SDL_SaveBMP_RW );
-	NV_SDL_LOAD( SDL_SetColorKey );
-	NV_SDL_LOAD( SDL_SetAlpha );
-	NV_SDL_LOAD( SDL_SetClipRect );
-	NV_SDL_LOAD( SDL_GetClipRect );
-	NV_SDL_LOAD( SDL_ConvertSurface );
-	NV_SDL_LOAD( SDL_UpperBlit );
-	NV_SDL_LOAD( SDL_LowerBlit );
-	NV_SDL_LOAD( SDL_FillRect );
-	NV_SDL_LOAD( SDL_DisplayFormat );
-	NV_SDL_LOAD( SDL_DisplayFormatAlpha );
-	NV_SDL_LOAD( SDL_CreateYUVOverlay );
-	NV_SDL_LOAD( SDL_LockYUVOverlay );
-	NV_SDL_LOAD( SDL_UnlockYUVOverlay );
-	NV_SDL_LOAD( SDL_DisplayYUVOverlay );
-	NV_SDL_LOAD( SDL_FreeYUVOverlay );
-	NV_SDL_LOAD( SDL_GL_LoadLibrary );
-	NV_SDL_LOAD( SDL_GL_GetProcAddress );
-	NV_SDL_LOAD( SDL_GL_SetAttribute );
-	NV_SDL_LOAD( SDL_GL_GetAttribute );
-	NV_SDL_LOAD( SDL_GL_SwapBuffers );
-	NV_SDL_LOAD( SDL_GL_UpdateRects );
-	NV_SDL_LOAD( SDL_GL_Lock );
-	NV_SDL_LOAD( SDL_GL_Unlock );
-	NV_SDL_LOAD( SDL_WM_SetCaption );
-	NV_SDL_LOAD( SDL_WM_GetCaption );
-	NV_SDL_LOAD( SDL_WM_SetIcon );
-	NV_SDL_LOAD( SDL_WM_IconifyWindow );
-	NV_SDL_LOAD( SDL_WM_ToggleFullScreen );
-	NV_SDL_LOAD( SDL_WM_GrabInput ); 
-
-/* SDL_audio.h functions */
-	NV_SDL_LOAD( SDL_AudioInit );
-	NV_SDL_LOAD( SDL_AudioQuit ); 
-	NV_SDL_LOAD( SDL_AudioDriverName );
-	NV_SDL_LOAD( SDL_OpenAudio );
-	NV_SDL_LOAD( SDL_GetAudioStatus );
-	NV_SDL_LOAD( SDL_PauseAudio );
-	NV_SDL_LOAD( SDL_LoadWAV_RW );
-	NV_SDL_LOAD( SDL_FreeWAV );
-	NV_SDL_LOAD( SDL_BuildAudioCVT );
-	NV_SDL_LOAD( SDL_ConvertAudio );
-	NV_SDL_LOAD( SDL_MixAudio );
-	NV_SDL_LOAD( SDL_LockAudio );
-	NV_SDL_LOAD( SDL_UnlockAudio );
-	NV_SDL_LOAD( SDL_CloseAudio );  
-
-/* SDL_cpuinfo.h functions */
-	NV_SDL_LOAD( SDL_HasRDTSC );
-	NV_SDL_LOAD( SDL_HasMMX );
-	NV_SDL_LOAD( SDL_HasMMXExt );
-	NV_SDL_LOAD( SDL_Has3DNow );
-	NV_SDL_LOAD( SDL_Has3DNowExt );
-	NV_SDL_LOAD( SDL_HasSSE );
-	NV_SDL_LOAD( SDL_HasSSE2 );
-	NV_SDL_LOAD( SDL_HasAltiVec ); 
-
-/* SDL_error.h functions */
-	NV_SDL_LOAD( SDL_SetError );
-	NV_SDL_LOAD( SDL_GetError );
-	NV_SDL_LOAD( SDL_ClearError );
-	NV_SDL_LOAD( SDL_Error );
-
-/* SDL_active.h functions */
-	NV_SDL_LOAD( SDL_GetAppState );
-
-/* SDL_keyboard.h functions */
-	NV_SDL_LOAD( SDL_EnableUNICODE );
-	NV_SDL_LOAD( SDL_EnableKeyRepeat );
-	NV_SDL_LOAD( SDL_GetKeyRepeat );
-	NV_SDL_LOAD( SDL_GetKeyState );
-	NV_SDL_LOAD( SDL_GetModState );
-	NV_SDL_LOAD( SDL_SetModState );
-	NV_SDL_LOAD( SDL_GetKeyName );
- 
-/* SDL_mouse.h functions */
-	NV_SDL_LOAD( SDL_GetMouseState );
-	NV_SDL_LOAD( SDL_GetRelativeMouseState );
-	NV_SDL_LOAD( SDL_WarpMouse );
-	NV_SDL_LOAD( SDL_CreateCursor );
-	NV_SDL_LOAD( SDL_SetCursor );
-	NV_SDL_LOAD( SDL_GetCursor );
-	NV_SDL_LOAD( SDL_FreeCursor );
-	NV_SDL_LOAD( SDL_ShowCursor );
-
-/* SDL_joystick.h functions */
-	NV_SDL_LOAD( SDL_NumJoysticks );
-	NV_SDL_LOAD( SDL_JoystickName );
-	NV_SDL_LOAD( SDL_JoystickOpen );
-	NV_SDL_LOAD( SDL_JoystickOpened );
-	NV_SDL_LOAD( SDL_JoystickIndex );
-	NV_SDL_LOAD( SDL_JoystickNumAxes );
-	NV_SDL_LOAD( SDL_JoystickNumBalls );
-	NV_SDL_LOAD( SDL_JoystickNumHats );
-	NV_SDL_LOAD( SDL_JoystickNumButtons );
-	NV_SDL_LOAD( SDL_JoystickUpdate );
-	NV_SDL_LOAD( SDL_JoystickEventState );
-	NV_SDL_LOAD( SDL_JoystickGetAxis );
-	NV_SDL_LOAD( SDL_JoystickGetHat );
-	NV_SDL_LOAD( SDL_JoystickGetBall );
-	NV_SDL_LOAD( SDL_JoystickGetButton );
-	NV_SDL_LOAD( SDL_JoystickClose );
-
-/* SDL_timer.h functions */
-	NV_SDL_LOAD( SDL_GetTicks );
-	NV_SDL_LOAD( SDL_Delay );
-	NV_SDL_LOAD( SDL_SetTimer );
-	NV_SDL_LOAD( SDL_AddTimer );
-	NV_SDL_LOAD( SDL_RemoveTimer );
-
-/* SDL_version.h functions */
-	NV_SDL_LOAD( SDL_Linked_Version ); 
-
-/* SDL_event.h functions */
-	NV_SDL_LOAD( SDL_PumpEvents );
-	NV_SDL_LOAD( SDL_PeepEvents );
-	NV_SDL_LOAD( SDL_PollEvent );
-	NV_SDL_LOAD( SDL_WaitEvent );
-	NV_SDL_LOAD( SDL_PushEvent );
-	NV_SDL_LOAD( SDL_SetEventFilter );
-	NV_SDL_LOAD( SDL_GetEventFilter );
-	NV_SDL_LOAD( SDL_EventState );
-
-#	undef NV_SDL_LOAD
+#	define NV_SDL_FUN( rtype, fname, fparams ) *(void **) (&fname) = sdl_library.get(#fname);
+#	include <nv/lib/detail/sdl_functions.inc>
+#	undef NV_SDL_FUN
 	return true;
 }
Index: /trunk/src/lib/sdl_image.cc
===================================================================
--- /trunk/src/lib/sdl_image.cc	(revision 167)
+++ /trunk/src/lib/sdl_image.cc	(revision 168)
@@ -11,57 +11,18 @@
 #include "nv/library.hh"
 
-/* SDL_image.h functions */
-const SDL_version * (NV_SDL_APIENTRY *IMG_Linked_Version) (void) = nullptr;
-int (NV_SDL_APIENTRY *IMG_Init) (int flags) = nullptr;
-void (NV_SDL_APIENTRY *IMG_Quit) (void) = nullptr;
-SDL_Surface * (NV_SDL_APIENTRY *IMG_LoadTyped_RW) (SDL_RWops *src, int freesrc, char *type) = nullptr;
-SDL_Surface * (NV_SDL_APIENTRY *IMG_Load) (const char *file) = nullptr;
-SDL_Surface * (NV_SDL_APIENTRY *IMG_Load_RW) (SDL_RWops *src, int freesrc) = nullptr;
-int (NV_SDL_APIENTRY *IMG_isICO) (SDL_RWops *src) = nullptr;
-int (NV_SDL_APIENTRY *IMG_isCUR) (SDL_RWops *src) = nullptr;
-int (NV_SDL_APIENTRY *IMG_isBMP) (SDL_RWops *src) = nullptr;
-int (NV_SDL_APIENTRY *IMG_isGIF) (SDL_RWops *src) = nullptr;
-int (NV_SDL_APIENTRY *IMG_isJPG) (SDL_RWops *src) = nullptr;
-int (NV_SDL_APIENTRY *IMG_isPNG) (SDL_RWops *src) = nullptr;
-int (NV_SDL_APIENTRY *IMG_isTIF) (SDL_RWops *src) = nullptr;
-SDL_Surface * (NV_SDL_APIENTRY *IMG_LoadICO_RW) (SDL_RWops *src) = nullptr;
-SDL_Surface * (NV_SDL_APIENTRY *IMG_LoadCUR_RW) (SDL_RWops *src) = nullptr;
-SDL_Surface * (NV_SDL_APIENTRY *IMG_LoadBMP_RW) (SDL_RWops *src) = nullptr;
-SDL_Surface * (NV_SDL_APIENTRY *IMG_LoadGIF_RW) (SDL_RWops *src) = nullptr;
-SDL_Surface * (NV_SDL_APIENTRY *IMG_LoadJPG_RW) (SDL_RWops *src) = nullptr;
-SDL_Surface * (NV_SDL_APIENTRY *IMG_LoadPNG_RW) (SDL_RWops *src) = nullptr;
-SDL_Surface * (NV_SDL_APIENTRY *IMG_LoadTGA_RW) (SDL_RWops *src) = nullptr;
-SDL_Surface * (NV_SDL_APIENTRY *IMG_LoadTIF_RW) (SDL_RWops *src) = nullptr;
+#define NV_SDL_FUN( rtype, fname, fparams ) rtype (NV_SDL_APIENTRY *fname) fparams = nullptr;
+#include <nv/lib/detail/sdl_image_functions.inc>
+#undef NV_SDL_FUN
 
 bool nv::load_sdl_image_library( const char* path )
 {
-#	define NV_SDL_IMAGE_LOAD( symbol ) *(void **) (&symbol) = sdl_image_library.get(#symbol);
 	static nv::library sdl_image_library;
 	if ( sdl_image_library.is_open() ) return true;
 	sdl_image_library.open( path );
 
-	NV_SDL_IMAGE_LOAD( IMG_Linked_Version );
-	NV_SDL_IMAGE_LOAD( IMG_Init );
-	NV_SDL_IMAGE_LOAD( IMG_Quit );
-	NV_SDL_IMAGE_LOAD( IMG_LoadTyped_RW );
-	NV_SDL_IMAGE_LOAD( IMG_Load );
-	NV_SDL_IMAGE_LOAD( IMG_Load_RW );
-	NV_SDL_IMAGE_LOAD( IMG_isICO );
-	NV_SDL_IMAGE_LOAD( IMG_isCUR );
-	NV_SDL_IMAGE_LOAD( IMG_isBMP );
-	NV_SDL_IMAGE_LOAD( IMG_isGIF );
-	NV_SDL_IMAGE_LOAD( IMG_isJPG );
-	NV_SDL_IMAGE_LOAD( IMG_isPNG );
-	NV_SDL_IMAGE_LOAD( IMG_isTIF );
-	NV_SDL_IMAGE_LOAD( IMG_LoadICO_RW );
-	NV_SDL_IMAGE_LOAD( IMG_LoadCUR_RW );
-	NV_SDL_IMAGE_LOAD( IMG_LoadBMP_RW );
-	NV_SDL_IMAGE_LOAD( IMG_LoadGIF_RW );
-	NV_SDL_IMAGE_LOAD( IMG_LoadJPG_RW );
-	NV_SDL_IMAGE_LOAD( IMG_LoadPNG_RW );
-	NV_SDL_IMAGE_LOAD( IMG_LoadTGA_RW );
-	NV_SDL_IMAGE_LOAD( IMG_LoadTIF_RW );
+#	define NV_SDL_FUN( rtype, fname, fparams ) *(void **) (&fname) = sdl_image_library.get(#fname);
+#	include <nv/lib/detail/sdl_image_functions.inc>
+#	undef NV_SDL_FUN
 
-#	undef NV_SDL_IMAGE_LOAD
 	return true;
 }
