Index: trunk/nv/lib/gl.hh
===================================================================
--- trunk/nv/lib/gl.hh	(revision 5)
+++ trunk/nv/lib/gl.hh	(revision 5)
@@ -0,0 +1,685 @@
+// Copyright (C) 2012-2013 ChaosForge / Kornel Kisielewicz
+// http://chaosforge.org/
+//
+// This file is part of NV Libraries.
+// For conditions of distribution and use, see copyright notice in nv.hh
+
+#ifndef NV_LIB_GL_HH
+#define NV_LIB_GL_HH
+
+//#define NV_SDL_GL
+#define NV_GL_DYNAMIC
+//#define NV_GL_SHARED
+
+#if NV_PLATFORM == NV_WINDOWS
+#	define NV_GL_PATH "opengl32.dll"
+#elif NV_PLATFORM == NV_APPLE
+#	define NV_GL_PATH "/System/Library/Frameworks/OpenGL.framework/Libraries/libGL.dylib"
+#else
+#	define NV_GL_PATH "libGL.so"
+#endif
+
+#include <stdint.h>
+
+extern "C" {
+
+#if NV_PLATFORM == NV_WINDOWS 
+#	define NV_GL_APIENTRY __stdcall
+#else
+#	define NV_GL_APIENTRY 
+#endif
+
+#if defined(NV_GL_SHARED) && (NV_PLATFORM == NV_WINDOWS)
+#	define NV_GL_API __declspec(dllimport)
+#else
+#	define NV_GL_API extern
+#endif
+
+#if defined(NV_GL_DYNAMIC)
+#	define NV_GL_FUN( rtype, fname, fparams ) NV_GL_API rtype ( NV_GL_APIENTRY *fname) fparams
+#else
+#	define NV_GL_FUN( rtype, fname, fparams ) NV_GL_API rtype NV_GL_APIENTRY fname fparams
+#endif
+
+typedef unsigned int GLenum;
+typedef unsigned int GLbitfield;
+typedef unsigned int GLuint;
+typedef int GLint;
+typedef int GLsizei;
+typedef unsigned char GLboolean;
+typedef signed char GLbyte;
+typedef short GLshort;
+typedef unsigned char GLubyte;
+typedef unsigned short GLushort;
+typedef unsigned long GLulong;
+typedef float GLfloat;
+typedef float GLclampf;
+typedef double GLdouble;
+typedef double GLclampd;
+typedef void GLvoid;
+typedef char GLchar;
+typedef ptrdiff_t GLintptr;
+typedef ptrdiff_t GLsizeiptr;
+
+
+/* OpenGL 1.1 non-deprecated defines */
+#define GL_DEPTH_BUFFER_BIT 0x00000100
+#define GL_STENCIL_BUFFER_BIT 0x00000400
+#define GL_COLOR_BUFFER_BIT 0x00004000
+#define GL_FALSE 0
+#define GL_TRUE 1
+#define GL_POINTS 0x0000
+#define GL_LINES 0x0001
+#define GL_LINE_LOOP 0x0002
+#define GL_LINE_STRIP 0x0003
+#define GL_TRIANGLES 0x0004
+#define GL_TRIANGLE_STRIP 0x0005
+#define GL_TRIANGLE_FAN 0x0006
+#define GL_NEVER 0x0200
+#define GL_LESS 0x0201
+#define GL_LEQUAL 0x0203
+#define GL_GREATER 0x0204
+#define GL_NOTEQUAL 0x0205
+#define GL_GEQUAL 0x0206
+#define GL_ALWAYS 0x0207
+#define GL_ONE 1
+#define GL_SRC_COLOR 0x0300
+#define GL_ONE_MINUS_SRC_COLOR 0x0301
+#define GL_SRC_ALPHA 0x0302
+#define GL_ONE_MINUS_SRC_ALPHA 0x0303
+#define GL_DST_ALPHA 0x0304
+#define GL_ONE_MINUS_DST_ALPHA 0x0305
+#define GL_DST_COLOR 0x0306
+#define GL_ONE_MINUS_DST_COLOR 0x0307
+#define GL_SRC_ALPHA_SATURATE 0x0308
+#define GL_FRONT_LEFT 0x0400
+#define GL_FRONT_RIGHT 0x0401
+#define GL_BACK_LEFT 0x0402
+#define GL_BACK_RIGHT 0x0403
+#define GL_FRONT 0x0404
+#define GL_BACK 0x0405
+#define GL_LEFT 0x0406
+#define GL_RIGHT 0x0407
+#define GL_FRONT_AND_BACK 0x0408
+#define GL_INVALID_ENUM 0x0500
+#define GL_INVALID_VALUE 0x0501
+#define GL_INVALID_OPERATION 0x0502
+#define GL_OUT_OF_MEMORY 0x0505
+#define GL_POINT_SIZE 0x0B11
+#define GL_POINT_SIZE_RANGE 0x0B12
+#define GL_POINT_SIZE_GRANULARITY 0x0B13
+#define GL_LINE_SMOOTH 0x0B20
+#define GL_LINE_WIDTH 0x0B21
+#define GL_LINE_WIDTH_RANGE 0x0B22
+#define GL_LINE_WIDTH_GRANULARITY 0x0B23
+#define GL_POLYGON_SMOOTH 0x0B41
+#define GL_CULL_FACE 0x0B44
+#define GL_CULL_FACE_MODE 0x0B45
+#define GL_FRONT_FACE 0x0B46
+#define GL_DEPTH_TEST 0x0B71
+#define GL_DEPTH_WRITEMASK 0x0B72
+#define GL_DEPTH_CLEAR_VALUE 0x0B73
+#define GL_DEPTH_FUNC 0x0B74
+#define GL_STENCIL_TEST 0x0B90
+#define GL_STENCIL_CLEAR_VALUE 0x0B91
+#define GL_STENCIL_FUNC 0x0B92
+#define GL_STENCIL_VALUE_MASK 0x0B93
+#define GL_STENCIL_FAIL 0x0B94
+#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95
+#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96
+#define GL_STENCIL_REF 0x0B97
+#define GL_STENCIL_WRITEMASK 0x0B98
+#define GL_DITHER 0x0BD0
+#define GL_BLEND_DST 0x0BE0
+#define GL_BLEND_SRC 0x0BE1
+#define GL_BLEND 0x0BE2
+#define GL_LOGIC_OP_MODE 0x0BF0
+#define GL_COLOR_LOGIC_OP 0x0BF2
+#define GL_DRAW_BUFFER 0x0C01
+#define GL_READ_BUFFER 0x0C02
+#define GL_COLOR_CLEAR_VALUE 0x0C22
+#define GL_COLOR_WRITEMASK 0x0C23
+#define GL_DOUBLEBUFFER 0x0C32
+#define GL_STEREO 0x0C33
+#define GL_LINE_SMOOTH_HINT 0x0C52
+#define GL_POLYGON_SMOOTH_HINT 0x0C53
+#define GL_UNPACK_SWAP_BYTES 0x0CF0
+#define GL_UNPACK_LSB_FIRST 0x0CF1
+#define GL_UNPACK_ROW_LENGTH 0x0CF2
+#define GL_UNPACK_SKIP_ROWS 0x0CF3
+#define GL_UNPACK_SKIP_PIXELS 0x0CF4
+#define GL_UNPACK_ALIGNMENT 0x0CF5
+#define GL_PACK_SWAP_BYTES 0x0D00
+#define GL_PACK_LSB_FIRST 0x0D01
+#define GL_PACK_ROW_LENGTH 0x0D02
+#define GL_PACK_SKIP_ROWS 0x0D03
+#define GL_PACK_SKIP_PIXELS 0x0D04
+#define GL_PACK_ALIGNMENT 0x0D05
+#define GL_MAX_TEXTURE_SIZE 0x0D33
+#define GL_MAX_VIEWPORT_DIMS 0x0D3A
+#define GL_SUBPIXEL_BITS 0x0D50
+#define GL_POLYGON_OFFSET_UNITS 0x2A00
+#define GL_POLYGON_OFFSET_POINT 0x2A01
+#define GL_POLYGON_OFFSET_LINE 0x2A02
+#define GL_POLYGON_OFFSET_FILL 0x8037
+#define GL_POLYGON_OFFSET_FACTOR 0x8038
+#define GL_TEXTURE_BINDING_1D 0x8068
+#define GL_TEXTURE_BINDING_2D 0x8069
+#define GL_TEXTURE_WIDTH 0x1000
+#define GL_TEXTURE_HEIGHT 0x1001
+#define GL_TEXTURE_INTERNAL_FORMAT 0x1003
+#define GL_TEXTURE_BORDER_COLOR 0x1004
+#define GL_TEXTURE_RED_SIZE 0x805C
+#define GL_TEXTURE_GREEN_SIZE 0x805D
+#define GL_TEXTURE_BLUE_SIZE 0x805E
+#define GL_TEXTURE_ALPHA_SIZE 0x805F
+#define GL_DONT_CARE 0x1100
+#define GL_FASTEST 0x1101
+#define GL_NICEST 0x1102
+#define GL_BYTE 0x1400
+#define GL_UNSIGNED_BYTE 0x1401
+#define GL_SHORT 0x1402
+#define GL_UNSIGNED_SHORT 0x1403
+#define GL_INT 0x1404
+#define GL_UNSIGNED_INT 0x1405
+#define GL_FLOAT 0x1406
+#define GL_CLEAR 0x1500
+#define GL_AND 0x1501
+#define GL_AND_REVERSE 0x1502
+#define GL_COPY 0x1503
+#define GL_AND_INVERTED 0x1504
+#define GL_NOOP 0x1505
+#define GL_XOR 0x1506
+#define GL_OR 0x1507
+#define GL_NOR 0x1508
+#define GL_EQUIV 0x1509
+#define GL_INVERT 0x150A
+#define GL_OR_REVERSE 0x150B
+#define GL_COPY_INVERTED 0x150C
+#define GL_OR_INVERTED 0x150D
+#define GL_NAND 0x150E
+#define GL_SET 0x150F
+#define GL_TEXTURE 0x1702
+#define GL_COLOR 0x1800
+#define GL_DEPTH 0x1801
+#define GL_STENCIL 0x1802
+#define GL_STENCIL_INDEX 0x1901
+#define GL_DEPTH_COMPONENT 0x1902
+#define GL_RED 0x1903
+#define GL_GREEN 0x1904
+#define GL_BLUE 0x1905
+#define GL_ALPHA 0x1906
+#define GL_RGB 0x1907
+#define GL_RGBA 0x1908
+#define GL_POINT 0x1B00
+#define GL_LINE 0x1B01
+#define GL_FILL 0x1B02
+#define GL_KEEP 0x1E00
+#define GL_REPLACE 0x1E01
+#define GL_INCR 0x1E02
+#define GL_DECR 0x1E03
+#define GL_VENDOR 0x1F00
+#define GL_RENDERER 0x1F01
+#define GL_VERSION 0x1F02
+#define GL_EXTENSIONS 0x1F03
+#define GL_NEAREST 0x2600
+#define GL_LINEAR 0x2601
+#define GL_NEAREST_MIPMAP_NEAREST 0x2700
+#define GL_LINEAR_MIPMAP_NEAREST 0x2701
+#define GL_NEAREST_MIPMAP_LINEAR 0x2702
+#define GL_LINEAR_MIPMAP_LINEAR 0x2703
+#define GL_TEXTURE_MAG_FILTER 0x2800
+#define GL_TEXTURE_MIN_FILTER 0x2801
+#define GL_TEXTURE_WRAP_S 0x2802
+#define GL_TEXTURE_WRAP_T 0x2803
+#define GL_PROXY_TEXTURE_1D 0x8063
+#define GL_PROXY_TEXTURE_2D 0x8064
+#define GL_REPEAT 0x2901
+#define GL_R3_G3_B2 0x2A10
+#define GL_RGB4 0x804F
+#define GL_RGB5 0x8050
+#define GL_RGB8 0x8051
+#define GL_RGB10 0x8052
+#define GL_RGB12 0x8053
+#define GL_RGB16 0x8054
+#define GL_RGBA2 0x8055
+#define GL_RGBA4 0x8056
+#define GL_RGB5_A1 0x8057
+#define GL_RGBA8 0x8058
+#define GL_RGB10_A2 0x8059
+#define GL_RGBA12 0x805A
+#define GL_RGBA16 0x805B
+
+/* OpenGL 1.2 non-deprecated defines */
+#define GL_UNSIGNED_BYTE_3_3_2 0x8032
+#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033
+#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034
+#define GL_UNSIGNED_INT_8_8_8_8 0x8035
+#define GL_UNSIGNED_INT_10_10_10_2 0x8036
+#define GL_TEXTURE_BINDING_3D 0x806A
+#define GL_PACK_SKIP_IMAGES 0x806B
+#define GL_PACK_IMAGE_HEIGHT 0x806C
+#define GL_UNPACK_SKIP_IMAGES 0x806D
+#define GL_UNPACK_IMAGE_HEIGHT 0x806E
+#define GL_PROXY_TEXTURE_3D 0x8070
+#define GL_TEXTURE_DEPTH 0x8071
+#define GL_TEXTURE_WRAP_R 0x8072
+#define GL_MAX_3D_TEXTURE_SIZE 0x8073
+#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362
+#define GL_UNSIGNED_SHORT_5_6_5 0x8363
+#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364
+#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365
+#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366
+#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367
+#define GL_BGR 0x80E0
+#define GL_MAX_ELEMENTS_VERTICES 0x80E8
+#define GL_MAX_ELEMENTS_INDICES 0x80E9
+#define GL_CLAMP_TO_EDGE 0x812F
+#define GL_TEXTURE_MIN_LOD 0x813A
+#define GL_TEXTURE_MAX_LOD 0x813B
+#define GL_TEXTURE_BASE_LEVEL 0x813C
+#define GL_TEXTURE_MAX_LEVEL 0x813D
+#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12
+#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13
+#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22
+#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23
+#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E
+
+/* OpenGL 1.3 non-deprecated defines */
+#define GL_TEXTURE0 0x84C0
+#define GL_TEXTURE1 0x84C1
+#define GL_TEXTURE2 0x84C2
+#define GL_TEXTURE3 0x84C3
+#define GL_TEXTURE4 0x84C4
+#define GL_TEXTURE5 0x84C5
+#define GL_TEXTURE6 0x84C6
+#define GL_TEXTURE7 0x84C7
+#define GL_TEXTURE8 0x84C8
+#define GL_TEXTURE9 0x84C9
+#define GL_TEXTURE10 0x84CA
+#define GL_TEXTURE11 0x84CB
+#define GL_TEXTURE12 0x84CC
+#define GL_TEXTURE13 0x84CD
+#define GL_TEXTURE14 0x84CE
+#define GL_TEXTURE15 0x84CF
+#define GL_TEXTURE16 0x84D0
+#define GL_TEXTURE17 0x84D1
+#define GL_TEXTURE18 0x84D2
+#define GL_TEXTURE19 0x84D3
+#define GL_TEXTURE20 0x84D4
+#define GL_TEXTURE21 0x84D5
+#define GL_TEXTURE22 0x84D6
+#define GL_TEXTURE23 0x84D7
+#define GL_TEXTURE24 0x84D8
+#define GL_TEXTURE25 0x84D9
+#define GL_TEXTURE26 0x84DA
+#define GL_TEXTURE27 0x84DB
+#define GL_TEXTURE28 0x84DC
+#define GL_TEXTURE29 0x84DD
+#define GL_TEXTURE30 0x84DE
+#define GL_TEXTURE31 0x84DF
+#define GL_ACTIVE_TEXTURE 0x84E0
+#define GL_MULTISAMPLE 0x809D
+#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E
+#define GL_SAMPLE_ALPHA_TO_ONE 0x809F
+#define GL_SAMPLE_COVERAGE 0x80A0
+#define GL_SAMPLE_BUFFERS 0x80A8
+#define GL_SAMPLE_COVERAGE_VALUE 0x80AA
+#define GL_SAMPLE_COVERAGE_INVERT 0x80AB
+#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A
+#define GL_PROXY_TEXTURE_CUBE_MAP 0x851B
+#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C
+#define GL_COMPRESSED_RGB 0x84ED
+#define GL_COMPRESSED_RGBA 0x84EE
+#define GL_TEXTURE_COMPRESSION_HINT 0x84EF
+#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0
+#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2
+#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3
+#define GL_CLAMP_TO_BORDER 0x812D
+
+/* OpenGL 1.4 non-deprecated defines */
+#define GL_BLEND_DST_RGB 0x80C8
+#define GL_BLEND_SRC_RGB 0x80C9
+#define GL_BLEND_DST_ALPHA 0x80CA
+#define GL_BLEND_SRC_ALPHA 0x80CB
+#define GL_POINT_FADE_THRESHOLD_SIZE 0x8128
+#define GL_DEPTH_COMPONENT16 0x81A5
+#define GL_DEPTH_COMPONENT24 0x81A6
+#define GL_DEPTH_COMPONENT32 0x81A7
+#define GL_MIRRORED_REPEAT 0x8370
+#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD
+#define GL_TEXTURE_LOD_BIAS 0x8501
+#define GL_INCR_WRAP 0x8507
+#define GL_DECR_WRAP 0x8508
+#define GL_TEXTURE_DEPTH_SIZE 0x884A
+#define GL_TEXTURE_COMPARE_MODE 0x884C
+#define GL_TEXTURE_COMPARE_FUNC 0x884D
+
+/* OpenGL 1.5 non-deprecated defines */
+#define GL_BUFFER_SIZE 0x8764
+#define GL_BUFFER_USAGE 0x8765
+#define GL_QUERY_COUNTER_BITS 0x8864
+#define GL_CURRENT_QUERY 0x8865
+#define GL_QUERY_RESULT 0x8866
+#define GL_QUERY_RESULT_AVAILABLE 0x8867
+#define GL_ARRAY_BUFFER 0x8892
+#define GL_ELEMENT_ARRAY_BUFFER 0x8893
+#define GL_ARRAY_BUFFER_BINDING 0x8894
+#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895
+#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F
+#define GL_READ_ONLY 0x88B8
+#define GL_BUFFER_ACCESS 0x88BB
+#define GL_BUFFER_MAPPED 0x88BC
+#define GL_BUFFER_MAP_POINTER 0x88BD
+#define GL_STREAM_DRAW 0x88E0
+#define GL_STREAM_READ 0x88E1
+#define GL_STREAM_COPY 0x88E2
+#define GL_STATIC_DRAW 0x88E4
+#define GL_STATIC_READ 0x88E5
+#define GL_STATIC_COPY 0x88E6
+#define GL_DYNAMIC_DRAW 0x88E8
+#define GL_DYNAMIC_READ 0x88E9
+#define GL_DYNAMIC_COPY 0x88EA
+#define GL_SAMPLES_PASSED 0x8914
+
+/* OpenGL 2.0 non-deprecated defines */
+#define GL_BLEND_EQUATION_RGB 0x8009
+#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622
+#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623
+#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624
+#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625
+#define GL_CURRENT_VERTEX_ATTRIB 0x8626
+#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642
+#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645
+#define GL_STENCIL_BACK_FUNC 0x8800
+#define GL_STENCIL_BACK_FAIL 0x8801
+#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802
+#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803
+#define GL_MAX_DRAW_BUFFERS 0x8824
+#define GL_DRAW_BUFFER0 0x8825
+#define GL_DRAW_BUFFER1 0x8826
+#define GL_DRAW_BUFFER2 0x8827
+#define GL_DRAW_BUFFER3 0x8828
+#define GL_DRAW_BUFFER4 0x8829
+#define GL_DRAW_BUFFER5 0x882A
+#define GL_DRAW_BUFFER6 0x882B
+#define GL_DRAW_BUFFER7 0x882C
+#define GL_DRAW_BUFFER8 0x882D
+#define GL_DRAW_BUFFER9 0x882E
+#define GL_DRAW_BUFFER10 0x882F
+#define GL_DRAW_BUFFER11 0x8830
+#define GL_DRAW_BUFFER12 0x8831
+#define GL_DRAW_BUFFER13 0x8832
+#define GL_DRAW_BUFFER14 0x8833
+#define GL_DRAW_BUFFER15 0x8834
+#define GL_BLEND_EQUATION_ALPHA 0x883D
+#define GL_MAX_VERTEX_ATTRIBS 0x8869
+#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A
+#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872
+#define GL_FRAGMENT_SHADER 0x8B30
+#define GL_VERTEX_SHADER 0x8B31
+#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49
+#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A
+#define GL_MAX_VARYING_FLOATS 0x8B4B
+#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C
+#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D
+#define GL_SHADER_TYPE 0x8B4F
+#define GL_FLOAT_VEC2 0x8B50
+#define GL_FLOAT_VEC3 0x8B51
+#define GL_FLOAT_VEC4 0x8B52
+#define GL_INT_VEC2 0x8B53
+#define GL_INT_VEC3 0x8B54
+#define GL_INT_VEC4 0x8B55
+#define GL_BOOL 0x8B56
+#define GL_BOOL_VEC2 0x8B57
+#define GL_BOOL_VEC3 0x8B58
+#define GL_BOOL_VEC4 0x8B59
+#define GL_FLOAT_MAT2 0x8B5A
+#define GL_FLOAT_MAT3 0x8B5B
+#define GL_FLOAT_MAT4 0x8B5C
+#define GL_SAMPLER_1D 0x8B5D
+#define GL_SAMPLER_2D 0x8B5E
+#define GL_SAMPLER_3D 0x8B5F
+#define GL_SAMPLER_CUBE 0x8B60
+#define GL_SAMPLER_1D_SHADOW 0x8B61
+#define GL_SAMPLER_2D_SHADOW 0x8B62
+#define GL_DELETE_STATUS 0x8B80
+#define GL_COMPILE_STATUS 0x8B81
+#define GL_LINK_STATUS 0x8B82
+#define GL_VALIDATE_STATUS 0x8B83
+#define GL_INFO_LOG_LENGTH 0x8B84
+#define GL_ATTACHED_SHADERS 0x8B85
+#define GL_ACTIVE_UNIFORMS 0x8B86
+#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87
+#define GL_SHADER_SOURCE_LENGTH 0x8B88
+#define GL_ACTIVE_ATTRIBUTES 0x8B89
+#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A
+#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B
+#define GL_SHADING_LANGUAGE_VERSION 0x8B8C
+#define GL_CURRENT_PROGRAM 0x8B8D
+#define GL_POINT_SPRITE_COORD_ORIGIN 0x8CA0
+#define GL_LOWER_LEFT 0x8CA1
+#define GL_UPPER_LEFT 0x8CA2
+#define GL_STENCIL_BACK_REF 0x8CA3
+#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4
+#define GL_STENCIL_BACK_WRITEMASK 0x8CA5
+
+/* OpenGL 2.1 non-deprecated defines */
+#define GL_PIXEL_PACK_BUFFER 0x88EB
+#define GL_PIXEL_UNPACK_BUFFER 0x88EC
+#define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED
+#define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF
+#define GL_FLOAT_MAT2x3 0x8B65
+#define GL_FLOAT_MAT2x4 0x8B66
+#define GL_FLOAT_MAT3x2 0x8B67
+#define GL_FLOAT_MAT3x4 0x8B68
+#define GL_FLOAT_MAT4x2 0x8B69
+#define GL_FLOAT_MAT4x3 0x8B6A
+#define GL_SRGB 0x8C40
+#define GL_SRGB8 0x8C41
+#define GL_SRGB_ALPHA 0x8C42
+#define GL_SRGB8_ALPHA8 0x8C43
+#define GL_COMPRESSED_SRGB 0x8C48
+#define GL_COMPRESSED_SRGB_ALPHA 0x8C49
+
+/* OpenGL 1.1 non-deprecated functions */
+NV_GL_FUN( void , glCullFace , ( GLenum ) );
+NV_GL_FUN( void , glFrontFace , ( GLenum ) );
+NV_GL_FUN( void , glHint , ( GLenum, GLenum ) );
+NV_GL_FUN( void , glLineWidth , ( GLfloat ) );
+NV_GL_FUN( void , glPointSize , ( GLfloat ) );
+NV_GL_FUN( void , glPolygonMode , ( GLenum, GLenum ) );
+NV_GL_FUN( void , glScissor , ( GLint , GLint , GLsizei , GLsizei ) );
+NV_GL_FUN( void , glTexParameterf , ( GLenum , GLenum , GLfloat ) );
+NV_GL_FUN( void , glTexParameterfv , ( GLenum , GLenum , const GLint *) );
+NV_GL_FUN( void , glTexParameteri , ( GLenum , GLenum , GLfloat ) );
+NV_GL_FUN( void , glTexParameteriv , ( GLenum , GLenum , const GLint *) );
+NV_GL_FUN( void , glTexImage1D , ( GLenum , GLint , GLint , GLsizei , GLint , GLenum , GLenum , const GLvoid *) );
+NV_GL_FUN( void , glTexImage2D , ( GLenum , GLint , GLint , GLsizei , GLsizei , GLint , GLenum , GLenum , const GLvoid *) );
+NV_GL_FUN( void , glDrawBuffer , ( GLenum ) );
+NV_GL_FUN( void , glClear , ( GLbitfield ) );
+NV_GL_FUN( void , glClearColor , ( GLfloat , GLfloat , GLfloat , GLfloat ) );
+NV_GL_FUN( void , glClearStencil , ( GLint ) );
+NV_GL_FUN( void , glClearDepth , ( GLdouble ) );
+NV_GL_FUN( void , glStencilMask , ( GLuint ) );
+NV_GL_FUN( void , glColorMask , ( GLboolean , GLboolean , GLboolean , GLboolean ) );
+NV_GL_FUN( void , glDepthMask , ( GLboolean ) );
+NV_GL_FUN( void , glDisable , ( GLenum ) );
+NV_GL_FUN( void , glEnable , ( GLenum ) );
+NV_GL_FUN( void , glFinish , ( void ) );
+NV_GL_FUN( void , glFlush , ( void ) );
+NV_GL_FUN( void , glBlendFunc , ( GLenum, GLenum ) );
+NV_GL_FUN( void , glLogicOp , ( GLenum ) );
+NV_GL_FUN( void , glStencilFunc , ( GLenum , GLint , GLuint ) );
+NV_GL_FUN( void , glStencilOp , ( GLenum , GLenum , GLenum ) );
+NV_GL_FUN( void , glDepthFunc , ( GLenum ) );
+NV_GL_FUN( void , glPixelStoref , ( GLenum , GLfloat ) );
+NV_GL_FUN( void , glPixelStorei , ( GLenum , GLint ) );
+NV_GL_FUN( void , glReadBuffer , ( GLenum ) );
+NV_GL_FUN( void , glReadPixels , ( GLint , GLint , GLsizei , GLsizei , GLenum , GLenum , GLvoid *) );
+NV_GL_FUN( void , glGetBooleanv , ( GLenum , GLboolean *) );
+NV_GL_FUN( void , glGetDoublev , ( GLenum , GLdouble *) );
+NV_GL_FUN( GLenum , glGetError , ( void ) );
+NV_GL_FUN( void , glGetFloatv , ( GLenum , GLfloat *) );
+NV_GL_FUN( void , glGetIntegerv , ( GLenum , GLint *) );
+NV_GL_FUN( const GLubyte * , glGetString , ( GLenum ) );
+NV_GL_FUN( void , glGetTexImage , ( GLenum , GLint , GLenum , GLenum , GLvoid *) );
+NV_GL_FUN( void , glGetTexParameterfv , ( GLenum , GLenum , GLfloat *) );
+NV_GL_FUN( void , glGetTexParameteriv , ( GLenum , GLenum , GLint *) );
+NV_GL_FUN( void , glGetTexLevelParameterfv , ( GLenum , GLint , GLenum , GLfloat *) );
+NV_GL_FUN( void , glGetTexLevelParameteriv , ( GLenum , GLint , GLenum , GLint *) );
+NV_GL_FUN( GLboolean , glIsEnabled , ( GLenum ) );
+NV_GL_FUN( void , glDepthRange , ( GLdouble , GLdouble ) );
+NV_GL_FUN( void , glViewport , ( GLint , GLint , GLsizei , GLsizei ) );
+NV_GL_FUN( void , glDrawArrays , ( GLenum , GLint , GLsizei ) );
+NV_GL_FUN( void , glDrawElements , ( GLenum , GLsizei , GLenum , const GLvoid *) );
+NV_GL_FUN( void , glGetPointerv , ( GLenum , GLvoid* *) );
+NV_GL_FUN( void , glPolygonOffset , ( GLfloat , GLfloat ) );
+NV_GL_FUN( void , glCopyTexImage1D , ( GLenum , GLint , GLenum , GLint , GLint , GLsizei , GLint ) );
+NV_GL_FUN( void , glCopyTexImage2D , ( GLenum , GLint , GLenum , GLint , GLint , GLsizei , GLsizei , GLint ) );
+NV_GL_FUN( void , glCopyTexSubImage1D , ( GLenum , GLint , GLint , GLint , GLint , GLsizei ) );
+NV_GL_FUN( void , glCopyTexSubImage2D , ( GLenum , GLint , GLint , GLint , GLint , GLint , GLsizei , GLsizei ) );
+NV_GL_FUN( void , glTexSubImage1D , ( GLenum , GLint , GLint , GLsizei , GLenum , GLenum , const GLvoid *) );
+NV_GL_FUN( void , glTexSubImage2D , ( GLenum , GLint , GLint , GLsizei , GLenum , GLenum , const GLvoid *) );
+NV_GL_FUN( void , glBindTexture , ( GLenum , GLint , GLint , GLsizei , GLenum , GLenum , const GLvoid *) );
+NV_GL_FUN( void , glDeleteTextures , ( GLsizei , const GLuint *) );
+NV_GL_FUN( void , glGenTextures , ( GLsizei , GLuint *) );
+NV_GL_FUN( GLboolean , glIsTexture , ( GLuint ) );
+NV_GL_FUN( void , glIndexub , ( GLubyte ) );
+NV_GL_FUN( void , glIndexubv , ( const GLubyte *) );
+
+/* OpenGL 1.2 non-deprecated functions */
+NV_GL_FUN( void , glBlendColor , ( GLfloat , GLfloat , GLfloat , GLfloat ) );
+NV_GL_FUN( void , glBlendEquation , ( GLenum ) );
+NV_GL_FUN( void , glDrawRangeElements , ( GLenum , GLuint , GLuint , GLsizei , GLenum , const GLvoid *) );
+NV_GL_FUN( void , glTexSubImage3D , ( GLenum , GLint , GLint , GLint , GLint , GLsizei , GLsizei , GLsizei , GLenum , GLenum , const GLvoid *) );
+NV_GL_FUN( void , glCopyTexSubImage3D , ( GLenum , GLint , GLint , GLint , GLint , GLint , GLint , GLsizei , GLsizei ) );
+
+/* OpenGL 1.3 non-deprecated functions */
+NV_GL_FUN( void , glActiveTexture , ( GLenum ) );
+NV_GL_FUN( void , glSampleCoverage , ( GLfloat , GLboolean ) );
+NV_GL_FUN( void , glCompressedTexImage3D , ( GLenum , GLint , GLenum , GLsizei , GLsizei , GLsizei , GLint , GLsizei , const GLvoid *) );
+NV_GL_FUN( void , glCompressedTexImage2D , ( GLenum , GLint , GLenum , GLsizei , GLsizei , GLint , GLsizei , const GLvoid *) );
+NV_GL_FUN( void , glCompressedTexImage1D , ( GLenum , GLint , GLenum , GLsizei , GLint , GLsizei , const GLvoid *) );
+NV_GL_FUN( void , glCompressedTexSubImage3D , ( GLenum , GLint , GLint , GLint , GLint , GLsizei , GLsizei , GLsizei , GLenum , GLsizei , const GLvoid *) );
+NV_GL_FUN( void , glCompressedTexSubImage2D , ( GLenum , GLint , GLint , GLint , GLsizei , GLsizei , GLenum , GLsizei , const GLvoid *) );
+NV_GL_FUN( void , glCompressedTexSubImage1D , ( GLenum , GLint , GLint , GLsizei , GLenum , GLsizei , const GLvoid *) );
+NV_GL_FUN( void , glGetCompressedTexImage , ( GLenum , GLint , GLvoid *) );
+
+/* OpenGL 1.4 non-deprecated functions */
+NV_GL_FUN( void , glBlendFuncSeparate , ( GLenum , GLenum , GLenum , GLenum ) );
+NV_GL_FUN( void , glMultiDrawArrays , ( GLenum , const GLint *, const GLsizei *, GLsizei ) );
+NV_GL_FUN( void , glMultiDrawElements , ( GLenum , const GLsizei *, GLenum , const GLvoid* const *, GLsizei ) );
+NV_GL_FUN( void , glPointParameterf , ( GLenum , GLfloat ) );
+NV_GL_FUN( void , glPointParameterfv , ( GLenum , const GLfloat *) );
+NV_GL_FUN( void , glPointParameteri , ( GLenum , GLint ) );
+NV_GL_FUN( void , glPointParameteriv , ( GLenum , const GLint *) );
+
+/* OpenGL 1.5 non-deprecated functions */
+NV_GL_FUN( void , glGenQueries , ( GLsizei , GLuint *) );
+NV_GL_FUN( void , glDeleteQueries , ( GLsizei , const GLuint *) );
+NV_GL_FUN( GLboolean , glIsQuery , ( GLuint ) );
+NV_GL_FUN( void , glBeginQuery , ( GLenum , GLuint ) );
+NV_GL_FUN( void , glEndQuery , ( GLenum ) );
+NV_GL_FUN( void , glGetQueryiv , ( GLenum , GLenum , GLint *) );
+NV_GL_FUN( void , glGetQueryObjectiv , ( GLuint , GLenum , GLint *) );
+NV_GL_FUN( void , glGetQueryObjectuiv , ( GLuint , GLenum , GLuint *) );
+NV_GL_FUN( void , glBindBuffer , ( GLenum , GLuint ) );
+NV_GL_FUN( void , glDeleteBuffers , ( GLsizei , const GLuint *) );
+NV_GL_FUN( void , glGenBuffers , ( GLsizei , GLuint *) );
+NV_GL_FUN( GLboolean , glIsBuffer , ( GLuint ) );
+NV_GL_FUN( void , glBufferData , ( GLenum , GLsizeiptr , const GLvoid *, GLenum ) );
+NV_GL_FUN( void , glBufferSubData , ( GLenum , GLintptr , GLsizeiptr , const GLvoid *) );
+NV_GL_FUN( void , glGetBufferSubData , ( GLenum , GLintptr , GLsizeiptr , GLvoid *) );
+NV_GL_FUN( GLvoid* , glMapBuffer , ( GLenum , GLenum ) );
+NV_GL_FUN( GLboolean , glUnmapBuffer , ( GLenum ) );
+NV_GL_FUN( void , glGetBufferParameteriv , ( GLenum , GLenum , GLint *) );
+NV_GL_FUN( void , glGetBufferPointerv , ( GLenum , GLenum , GLvoid* *) );
+
+/* OpenGL 2.0 non-deprecated functions */
+NV_GL_FUN( void , glBlendEquationSeparate , ( GLenum , GLenum ) );
+NV_GL_FUN( void , glDrawBuffers , ( GLsizei , const GLenum *) );
+NV_GL_FUN( void , glStencilOpSeparate , ( GLenum , GLenum , GLenum , GLenum ) );
+NV_GL_FUN( void , glStencilFuncSeparate , ( GLenum , GLenum , GLint , GLuint ) );
+NV_GL_FUN( void , glStencilMaskSeparate , ( GLenum , GLuint ) );
+NV_GL_FUN( void , glAttachShader , ( GLuint , GLuint ) );
+NV_GL_FUN( void , glBindAttribLocation , ( GLuint , GLuint , const GLchar *) );
+NV_GL_FUN( void , glCompileShader , ( GLuint ) );
+NV_GL_FUN( GLuint , glCreateProgram , ( void ) );
+NV_GL_FUN( GLuint , glCreateShader , ( GLenum ) );
+NV_GL_FUN( void , glDeleteProgram , ( GLuint ) );
+NV_GL_FUN( void , glDeleteShader , ( GLuint ) );
+NV_GL_FUN( void , glDetachShader , ( GLuint, GLuint ) );
+NV_GL_FUN( void , glDisableVertexAttribArray , ( GLuint ) );
+NV_GL_FUN( void , glEnableVertexAttribArray , ( GLuint ) );
+NV_GL_FUN( void , glGetActiveAttrib , ( GLuint , GLuint , GLsizei , GLsizei *, GLint *, GLenum *, GLchar *) );
+NV_GL_FUN( void , glGetActiveUniform , ( GLuint , GLuint , GLsizei , GLsizei *, GLint *, GLenum *, GLchar *) );
+NV_GL_FUN( void , glGetAttachedShaders , ( GLuint , GLsizei , GLsizei *, GLuint *) );
+NV_GL_FUN( GLint , glGetAttribLocation , ( GLuint , const GLchar *) );
+NV_GL_FUN( void , glGetProgramiv , ( GLuint , GLenum , GLint *) );
+NV_GL_FUN( void , glGetProgramInfoLog , ( GLuint , GLsizei , GLsizei *, GLchar *) );
+NV_GL_FUN( void , glGetShaderiv , ( GLuint , GLenum , GLint *) );
+NV_GL_FUN( void , glGetShaderInfoLog , ( GLuint , GLsizei , GLsizei *, GLchar *) );
+NV_GL_FUN( void , glGetShaderSource , ( GLuint , GLsizei , GLsizei *, GLchar *) );
+NV_GL_FUN( GLint , glGetUniformLocation , ( GLuint , const GLchar *) );
+NV_GL_FUN( void , glGetUniformfv , ( GLuint , GLint , GLfloat *) );
+NV_GL_FUN( void , glGetUniformiv , ( GLuint , GLint , GLint *) );
+NV_GL_FUN( void , glGetVertexAttribdv , ( GLuint , GLenum , GLdouble *) );
+NV_GL_FUN( void , glGetVertexAttribfv , ( GLuint , GLenum , GLfloat *) );
+NV_GL_FUN( void , glGetVertexAttribiv , ( GLuint , GLenum , GLint *) );
+NV_GL_FUN( void , glGetVertexAttribPointerv , ( GLuint , GLenum , GLvoid* *) );
+NV_GL_FUN( GLboolean , glIsProgram , ( GLuint ) );
+NV_GL_FUN( GLboolean , glIsShader , ( GLuint ) );
+NV_GL_FUN( void , glLinkProgram , ( GLuint ) );
+NV_GL_FUN( void , glShaderSource , ( GLuint , GLsizei , const GLchar* const *, const GLint *) );
+NV_GL_FUN( void , glUseProgram , ( GLuint ) );
+NV_GL_FUN( void , glUniform1f , ( GLint , GLfloat ) );
+NV_GL_FUN( void , glUniform2f , ( GLint , GLfloat , GLfloat ) );
+NV_GL_FUN( void , glUniform3f , ( GLint , GLfloat , GLfloat , GLfloat ) );
+NV_GL_FUN( void , glUniform4f , ( GLint , GLfloat , GLfloat , GLfloat , GLfloat ) );
+NV_GL_FUN( void , glUniform1i , ( GLint , GLint ) );
+NV_GL_FUN( void , glUniform2i , ( GLint , GLint , GLint ) );
+NV_GL_FUN( void , glUniform3i , ( GLint , GLint , GLint , GLint ) );
+NV_GL_FUN( void , glUniform4i , ( GLint , GLint , GLint , GLint , GLint ) );
+NV_GL_FUN( void , glUniform1fv , ( GLint , GLsizei , const GLfloat *) );
+NV_GL_FUN( void , glUniform2fv , ( GLint , GLsizei , const GLfloat *) );
+NV_GL_FUN( void , glUniform3fv , ( GLint , GLsizei , const GLfloat *) );
+NV_GL_FUN( void , glUniform4fv , ( GLint , GLsizei , const GLfloat *) );
+NV_GL_FUN( void , glUniform1iv , ( GLint , GLsizei , const GLint *) );
+NV_GL_FUN( void , glUniform2iv , ( GLint , GLsizei , const GLint *) );
+NV_GL_FUN( void , glUniform3iv , ( GLint , GLsizei , const GLint *) );
+NV_GL_FUN( void , glUniform4iv , ( GLint , GLsizei , const GLint *) );
+NV_GL_FUN( void , glUniformMatrix2fv , ( GLint , GLsizei , GLboolean , const GLfloat *) );
+NV_GL_FUN( void , glUniformMatrix3fv , ( GLint , GLsizei , GLboolean , const GLfloat *) );
+NV_GL_FUN( void , glUniformMatrix4fv , ( GLint , GLsizei , GLboolean , const GLfloat *) );
+NV_GL_FUN( void , glValidateProgram , ( GLuint ) );
+NV_GL_FUN( void , glVertexAttribPointer , ( GLuint , GLint , GLenum , GLboolean , GLsizei , const GLvoid *) );
+
+/* OpenGL 2.1 non-deprecated functions */
+NV_GL_FUN( void , glUniformMatrix2x3fv , ( GLint , GLsizei , GLboolean , const GLfloat *) );
+NV_GL_FUN( void , glUniformMatrix3x2fv , ( GLint , GLsizei , GLboolean , const GLfloat *) );
+NV_GL_FUN( void , glUniformMatrix2x4fv , ( GLint , GLsizei , GLboolean , const GLfloat *) );
+NV_GL_FUN( void , glUniformMatrix4x2fv , ( GLint , GLsizei , GLboolean , const GLfloat *) );
+NV_GL_FUN( void , glUniformMatrix3x4fv , ( GLint , GLsizei , GLboolean , const GLfloat *) );
+NV_GL_FUN( void , glUniformMatrix4x3fv , ( GLint , GLsizei , GLboolean , const GLfloat *) );
+
+#undef NV_GL_FUN
+
+}
+
+namespace nv {
+/* Dynamic load support */
+#	if defined( NV_GL_DYNAMIC )
+		bool load_gl_library( const char* path = NV_GL_PATH );
+#	else
+		inline bool load_gl_library( const char* path = "" ) { return true; }
+#	endif
+}
+
+#endif // NV_LIB_GL_HH
Index: trunk/nv/lib/lua.hh
===================================================================
--- trunk/nv/lib/lua.hh	(revision 5)
+++ trunk/nv/lib/lua.hh	(revision 5)
@@ -0,0 +1,456 @@
+// Copyright (C) 2012-2013 ChaosForge / Kornel Kisielewicz
+// http://chaosforge.org/
+//
+// This file is part of NV Libraries.
+// For conditions of distribution and use, see copyright notice in nv.hh
+
+#ifndef NV_LIB_LUA_HH
+#define NV_LIB_LUA_HH
+
+// Portions of the official Lua 5.2 headers were used, copyright follows:
+
+/******************************************************************************
+* Copyright (C) 1994-2012 Lua.org, PUC-Rio.
+*
+* 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.
+******************************************************************************/
+
+#define NV_LUA_DYNAMIC
+//#define NV_LUA_SHARED
+
+#if NV_PLATFORM == NV_WINDOWS
+#	define NV_LUA_PATH "lua52.dll"
+#elif NV_PLATFORM == NV_APPLE
+#	define NV_LUA_PATH "lua5.2.dylib"
+#else
+#	define NV_LUA_PATH "lua5.2.so"
+#endif
+
+#include <limits.h>
+#include <stdarg.h>
+#include <stddef.h>
+#include <stdio.h>
+
+extern "C" {
+
+#if defined(NV_LUA_SHARED) && (NV_PLATFORM == NV_WINDOWS)
+#	define NV_LUA_API __declspec(dllimport)
+#else
+#	define NV_LUA_API extern
+#endif
+
+#if defined(NV_LUA_DYNAMIC)
+#	define NV_LUA_FUN( rtype, fname, fparams ) NV_LUA_API rtype (*fname) fparams
+#else
+#	define NV_LUA_FUN( rtype, fname, fparams ) NV_LUA_API rtype fname fparams
+#endif
+
+/* luaconf.h definitions (only the ones needed in the headers) */
+#define LUA_NUMBER   double
+#define LUA_INTEGER  ptrdiff_t
+#define LUA_UNSIGNED unsigned int
+
+#define LUAI_MAXSTACK		1000000
+#define LUAI_FIRSTPSEUDOIDX	(-LUAI_MAXSTACK - 1000)
+#define LUA_IDSIZE 60
+
+/* lua.h */
+#define LUA_VERSION_MAJOR	"5"
+#define LUA_VERSION_MINOR	"2"
+#define LUA_VERSION_NUM		502
+#define LUA_VERSION_RELEASE	"1"
+
+#define LUA_VERSION	"Lua " LUA_VERSION_MAJOR "." LUA_VERSION_MINOR
+#define LUA_RELEASE	LUA_VERSION "." LUA_VERSION_RELEASE
+#define LUA_COPYRIGHT	LUA_RELEASE "  Copyright (C) 1994-2012 Lua.org, PUC-Rio"
+#define LUA_AUTHORS	"R. Ierusalimschy, L. H. de Figueiredo, W. Celes"
+
+#define LUA_SIGNATURE	"\033Lua"
+#define LUA_MULTRET	(-1)
+#define LUA_NOREF       (-2)
+#define LUA_REFNIL      (-1)
+
+#define LUA_REGISTRYINDEX	LUAI_FIRSTPSEUDOIDX
+#define lua_upvalueindex(i)	(LUA_REGISTRYINDEX - (i))
+
+#define LUAL_BUFFERSIZE		BUFSIZ
+
+
+/* Types */
+typedef struct lua_State lua_State;
+typedef struct lua_Debug lua_Debug; 
+typedef int (*lua_CFunction) (lua_State *L);
+typedef const char * (*lua_Reader) (lua_State *L, void *ud, size_t *sz);
+typedef int (*lua_Writer) (lua_State *L, const void* p, size_t sz, void* ud);
+typedef void * (*lua_Alloc) (void *ud, void *ptr, size_t osize, size_t nsize);
+typedef void (*lua_Hook) (lua_State *L, lua_Debug *ar);
+
+struct lua_Debug {
+  int event;
+  const char *name;	/* (n) */
+  const char *namewhat;	/* (n) 'global', 'local', 'field', 'method' */
+  const char *what;	/* (S) 'Lua', 'C', 'main', 'tail' */
+  const char *source;	/* (S) */
+  int currentline;	/* (l) */
+  int linedefined;	/* (S) */
+  int lastlinedefined;	/* (S) */
+  unsigned char nups;	/* (u) number of upvalues */
+  unsigned char nparams;/* (u) number of parameters */
+  char isvararg;        /* (u) */
+  char istailcall;	/* (t) */
+  char short_src[LUA_IDSIZE]; /* (S) */
+  struct CallInfo *i_ci;  /* active function */
+};
+
+/* Aux lib structs */
+typedef struct luaL_Reg {
+  const char *name;
+  lua_CFunction func;
+} luaL_Reg;
+
+typedef struct luaL_Buffer {
+  char *b;  /* buffer address */
+  size_t size;  /* buffer size */
+  size_t n;  /* number of characters in buffer */
+  lua_State *L;
+  char initb[LUAL_BUFFERSIZE];  /* initial buffer */
+} luaL_Buffer;
+
+typedef struct luaL_Stream {
+  FILE *f;  /* stream (NULL for incompletely created streams) */
+  lua_CFunction closef;  /* to close stream (NULL for closed streams) */
+} luaL_Stream;
+
+typedef LUA_NUMBER lua_Number;
+typedef LUA_INTEGER lua_Integer;
+typedef LUA_UNSIGNED lua_Unsigned;
+
+/* Thread return codes */
+#define LUA_OK		0
+#define LUA_YIELD	1
+#define LUA_ERRRUN	2
+#define LUA_ERRSYNTAX	3
+#define LUA_ERRMEM	4
+#define LUA_ERRGCMM	5
+#define LUA_ERRERR	6
+#define LUA_ERRFILE 7
+
+
+/* Type codes */
+#define LUA_TNONE			(-1)
+#define LUA_TNIL			0
+#define LUA_TBOOLEAN		1
+#define LUA_TLIGHTUSERDATA	2
+#define LUA_TNUMBER			3
+#define LUA_TSTRING			4
+#define LUA_TTABLE			5
+#define LUA_TFUNCTION		6
+#define LUA_TUSERDATA		7
+#define LUA_TTHREAD			8
+
+#define LUA_NUMTAGS			9
+#define LUA_MINSTACK		20
+
+/* Pre-defined registers */
+#define LUA_RIDX_MAINTHREAD	1
+#define LUA_RIDX_GLOBALS	2
+#define LUA_RIDX_LAST		LUA_RIDX_GLOBALS
+
+/* OP codes */
+#define LUA_OPADD	0
+#define LUA_OPSUB	1
+#define LUA_OPMUL	2
+#define LUA_OPDIV	3
+#define LUA_OPMOD	4
+#define LUA_OPPOW	5
+#define LUA_OPUNM	6
+
+/* Compare codes */
+#define LUA_OPEQ	0
+#define LUA_OPLT	1
+#define LUA_OPLE	2
+
+/* Event codes */
+#define LUA_GCSTOP			0
+#define LUA_GCRESTART		1
+#define LUA_GCCOLLECT		2
+#define LUA_GCCOUNT			3
+#define LUA_GCCOUNTB		4
+#define LUA_GCSTEP			5
+#define LUA_GCSETPAUSE		6
+#define LUA_GCSETSTEPMUL	7
+#define LUA_GCSETMAJORINC	8
+#define LUA_GCISRUNNING		9
+#define LUA_GCGEN			10
+#define LUA_GCINC			11
+
+/* Debug event codes */
+#define LUA_HOOKCALL	0
+#define LUA_HOOKRET	1
+#define LUA_HOOKLINE	2
+#define LUA_HOOKCOUNT	3
+#define LUA_HOOKTAILCALL 4
+
+/* Debug event masks */
+#define LUA_MASKCALL	(1 << LUA_HOOKCALL)
+#define LUA_MASKRET	(1 << LUA_HOOKRET)
+#define LUA_MASKLINE	(1 << LUA_HOOKLINE)
+#define LUA_MASKCOUNT	(1 << LUA_HOOKCOUNT)
+
+/* lualib.h defines */
+#define LUA_COLIBNAME	"coroutine"
+#define LUA_TABLIBNAME	"table"
+#define LUA_IOLIBNAME	"io"
+#define LUA_OSLIBNAME	"os"
+#define LUA_STRLIBNAME	"string"
+#define LUA_BITLIBNAME	"bit32"
+#define LUA_MATHLIBNAME	"math"
+#define LUA_DBLIBNAME	"debug"
+#define LUA_LOADLIBNAME	"package"
+
+/* State manipulation */
+NV_LUA_FUN( lua_State *,(lua_newstate),(lua_Alloc f, void *ud) );
+NV_LUA_FUN( void       ,(lua_close),(lua_State *L) );
+NV_LUA_FUN( lua_State *,(lua_newthread),(lua_State *L) );
+NV_LUA_FUN( lua_CFunction,(lua_atpanic),(lua_State *L, lua_CFunction panicf) );
+NV_LUA_FUN( const lua_Number *,(lua_version),(lua_State *L) );
+
+/* Basic stack manipulation */
+NV_LUA_FUN( int  ,(lua_absindex),(lua_State *L, int idx) );
+NV_LUA_FUN( int  ,(lua_gettop),(lua_State *L) );
+NV_LUA_FUN( void ,(lua_settop),(lua_State *L, int idx) );
+NV_LUA_FUN( void ,(lua_pushvalue),(lua_State *L, int idx) );
+NV_LUA_FUN( void ,(lua_remove),(lua_State *L, int idx) );
+NV_LUA_FUN( void ,(lua_insert),(lua_State *L, int idx) );
+NV_LUA_FUN( void ,(lua_replace),(lua_State *L, int idx) );
+NV_LUA_FUN( void ,(lua_copy),(lua_State *L, int fromidx, int toidx) );
+NV_LUA_FUN( int  ,(lua_checkstack),(lua_State *L, int sz) );
+NV_LUA_FUN( void ,(lua_xmove),(lua_State *from, lua_State *to, int n) );
+
+/* Access functions (stack -> C) */
+NV_LUA_FUN( int            ,(lua_isnumber),(lua_State *L, int idx) );
+NV_LUA_FUN( int            ,(lua_isstring),(lua_State *L, int idx) );
+NV_LUA_FUN( int            ,(lua_iscfunction),(lua_State *L, int idx) );
+NV_LUA_FUN( int            ,(lua_isuserdata),(lua_State *L, int idx) );
+NV_LUA_FUN( int            ,(lua_type),(lua_State *L, int idx) );
+NV_LUA_FUN( const char*    ,(lua_typename),(lua_State *L, int tp) );
+
+NV_LUA_FUN( lua_Number     ,(lua_tonumberx),(lua_State *L, int idx, int *isnum) );
+NV_LUA_FUN( lua_Integer    ,(lua_tointegerx),(lua_State *L, int idx, int *isnum) );
+NV_LUA_FUN( lua_Unsigned   ,(lua_tounsignedx),(lua_State *L, int idx, int *isnum) );
+NV_LUA_FUN( int            ,(lua_toboolean),(lua_State *L, int idx) );
+NV_LUA_FUN( const char*    ,(lua_tolstring),(lua_State *L, int idx, size_t *len) );
+NV_LUA_FUN( size_t         ,(lua_rawlen),(lua_State *L, int idx) );
+NV_LUA_FUN( lua_CFunction  ,(lua_tocfunction),(lua_State *L, int idx) );
+NV_LUA_FUN( void*          ,(lua_touserdata),(lua_State *L, int idx) );
+NV_LUA_FUN( lua_State*     ,(lua_tothread),(lua_State *L, int idx) );
+NV_LUA_FUN( const void*    ,(lua_topointer),(lua_State *L, int idx) );
+
+/* Comparison and arithmetic functions */
+NV_LUA_FUN( void ,(lua_arith),(lua_State *L, int op) );
+NV_LUA_FUN( int  ,(lua_rawequal),(lua_State *L, int idx1, int idx2) );
+NV_LUA_FUN( int  ,(lua_compare),(lua_State *L, int idx1, int idx2, int op) );
+
+/* Push functions (C -> stack) */
+NV_LUA_FUN( void        ,(lua_pushnil),(lua_State *L) );
+NV_LUA_FUN( void        ,(lua_pushnumber),(lua_State *L, lua_Number n) );
+NV_LUA_FUN( void        ,(lua_pushinteger),(lua_State *L, lua_Integer n) );
+NV_LUA_FUN( void        ,(lua_pushunsigned),(lua_State *L, lua_Unsigned n) );
+NV_LUA_FUN( const char* ,(lua_pushlstring),(lua_State *L, const char *s, size_t l) );
+NV_LUA_FUN( const char* ,(lua_pushstring),(lua_State *L, const char *s) );
+NV_LUA_FUN( const char* ,(lua_pushvfstring),(lua_State *L, const char *fmt,
+                                                      va_list argp) );
+NV_LUA_FUN( const char *,(lua_pushfstring),(lua_State *L, const char *fmt, ...) );
+NV_LUA_FUN( void ,(lua_pushcclosure),(lua_State *L, lua_CFunction fn, int n) );
+NV_LUA_FUN( void ,(lua_pushboolean),(lua_State *L, int b) );
+NV_LUA_FUN( void ,(lua_pushlightuserdata),(lua_State *L, void *p) );
+NV_LUA_FUN( int  ,(lua_pushthread),(lua_State *L) );
+
+/* Get functions (Lua -> stack) */
+NV_LUA_FUN( void ,(lua_getglobal),(lua_State *L, const char *var) );
+NV_LUA_FUN( void ,(lua_gettable),(lua_State *L, int idx) );
+NV_LUA_FUN( void ,(lua_getfield),(lua_State *L, int idx, const char *k) );
+NV_LUA_FUN( void ,(lua_rawget),(lua_State *L, int idx) );
+NV_LUA_FUN( void ,(lua_rawgeti),(lua_State *L, int idx, int n) );
+NV_LUA_FUN( void ,(lua_rawgetp),(lua_State *L, int idx, const void *p) );
+NV_LUA_FUN( void ,(lua_createtable),(lua_State *L, int narr, int nrec) );
+NV_LUA_FUN( void*,(lua_newuserdata),(lua_State *L, size_t sz) );
+NV_LUA_FUN( int  ,(lua_getmetatable),(lua_State *L, int objindex) );
+NV_LUA_FUN( void ,(lua_getuservalue),(lua_State *L, int idx) );
+
+/* Set functions (stack -> Lua) */
+NV_LUA_FUN( void ,(lua_setglobal),(lua_State *L, const char *var) );
+NV_LUA_FUN( void ,(lua_settable),(lua_State *L, int idx) );
+NV_LUA_FUN( void ,(lua_setfield),(lua_State *L, int idx, const char *k) );
+NV_LUA_FUN( void ,(lua_rawset),(lua_State *L, int idx) );
+NV_LUA_FUN( void ,(lua_rawseti),(lua_State *L, int idx, int n) );
+NV_LUA_FUN( void ,(lua_rawsetp),(lua_State *L, int idx, const void *p) );
+NV_LUA_FUN( int  ,(lua_setmetatable),(lua_State *L, int objindex) );
+NV_LUA_FUN( void ,(lua_setuservalue),(lua_State *L, int idx) );
+
+/* 'load' and 'call' functions (load and run Lua code) */
+NV_LUA_FUN( void ,(lua_callk),(lua_State *L, int nargs, int nresults, int ctx, lua_CFunction k) );
+NV_LUA_FUN( int  ,(lua_getctx),(lua_State *L, int *ctx) );
+NV_LUA_FUN( int  ,(lua_pcallk),(lua_State *L, int nargs, int nresults, int errfunc, int ctx, lua_CFunction k) );
+NV_LUA_FUN( int  ,(lua_load),(lua_State *L, lua_Reader reader, void *dt, const char *chunkname, const char *mode) );
+NV_LUA_FUN( int  ,(lua_dump),(lua_State *L, lua_Writer writer, void *data) );
+
+/* Coroutine functions */
+NV_LUA_FUN( int ,(lua_yieldk),(lua_State *L, int nresults, int ctx, lua_CFunction k) );
+NV_LUA_FUN( int ,(lua_resume),(lua_State *L, lua_State *from, int narg) );
+NV_LUA_FUN( int ,(lua_status),(lua_State *L) );
+
+/* Garbage-collection function and options */
+NV_LUA_FUN( int,(lua_gc),(lua_State *L, int what, int data) );
+
+/* Miscellaneous functions */
+NV_LUA_FUN( int  ,(lua_error),(lua_State *L) );
+NV_LUA_FUN( int  ,(lua_next),(lua_State *L, int idx) );
+NV_LUA_FUN( void ,(lua_concat),(lua_State *L, int n) );
+NV_LUA_FUN( void ,(lua_len)   ,(lua_State *L, int idx) );
+NV_LUA_FUN( lua_Alloc,(lua_getallocf),(lua_State *L, void **ud) );
+NV_LUA_FUN( void     ,(lua_setallocf),(lua_State *L, lua_Alloc f, void *ud) );
+
+/* Debug API */
+NV_LUA_FUN( int,(lua_getstack),(lua_State *L, int level, lua_Debug *ar) );
+NV_LUA_FUN( int,(lua_getinfo),(lua_State *L, const char *what, lua_Debug *ar) );
+NV_LUA_FUN( const char *,(lua_getlocal),(lua_State *L, const lua_Debug *ar, int n) );
+NV_LUA_FUN( const char *,(lua_setlocal),(lua_State *L, const lua_Debug *ar, int n) );
+NV_LUA_FUN( const char *,(lua_getupvalue),(lua_State *L, int funcindex, int n) );
+NV_LUA_FUN( const char *,(lua_setupvalue),(lua_State *L, int funcindex, int n) );
+NV_LUA_FUN( void *,(lua_upvalueid),(lua_State *L, int fidx, int n) );
+NV_LUA_FUN( void  ,(lua_upvaluejoin),(lua_State *L, int fidx1, int n1, int fidx2, int n2) );
+NV_LUA_FUN( int,(lua_sethook),(lua_State *L, lua_Hook func, int mask, int count) );
+NV_LUA_FUN( lua_Hook,(lua_gethook),(lua_State *L) );
+NV_LUA_FUN( int,(lua_gethookmask),(lua_State *L) );
+NV_LUA_FUN( int,(lua_gethookcount),(lua_State *L) );
+
+/* lualib API */
+NV_LUA_FUN( int,(luaopen_base),(lua_State *L) );
+NV_LUA_FUN( int,(luaopen_coroutine),(lua_State *L) );
+NV_LUA_FUN( int,(luaopen_table),(lua_State *L) );
+NV_LUA_FUN( int,(luaopen_io),(lua_State *L) );
+NV_LUA_FUN( int,(luaopen_os),(lua_State *L) );
+NV_LUA_FUN( int,(luaopen_string),(lua_State *L) );
+NV_LUA_FUN( int,(luaopen_bit32),(lua_State *L) );
+NV_LUA_FUN( int,(luaopen_math),(lua_State *L) );
+NV_LUA_FUN( int,(luaopen_debug),(lua_State *L) );
+NV_LUA_FUN( int,(luaopen_package),(lua_State *L) );
+NV_LUA_FUN( int,(luaL_openlibs),(lua_State *L) );
+
+/* lauxlib API */
+NV_LUA_FUN( void  ,(luaL_checkversion_),(lua_State *L, lua_Number ver) );
+NV_LUA_FUN( int ,(luaL_getmetafield),(lua_State *L, int obj, const char *e) );
+NV_LUA_FUN( int ,(luaL_callmeta),(lua_State *L, int obj, const char *e) );
+NV_LUA_FUN( const char *,(luaL_tolstring),(lua_State *L, int idx, size_t *len) );
+NV_LUA_FUN( int ,(luaL_argerror),(lua_State *L, int numarg, const char *extramsg) );
+NV_LUA_FUN( const char *,(luaL_checklstring),(lua_State *L, int numArg, size_t *l) );
+NV_LUA_FUN( const char *,(luaL_optlstring),(lua_State *L, int numArg, const char *def, size_t *l) );
+NV_LUA_FUN( lua_Number ,(luaL_checknumber),(lua_State *L, int numArg) );
+NV_LUA_FUN( lua_Number ,(luaL_optnumber),(lua_State *L, int nArg, lua_Number def) );
+NV_LUA_FUN( lua_Integer ,(luaL_checkinteger),(lua_State *L, int numArg) );
+NV_LUA_FUN( lua_Integer ,(luaL_optinteger),(lua_State *L, int nArg, lua_Integer def) );
+NV_LUA_FUN( lua_Unsigned ,(luaL_checkunsigned),(lua_State *L, int numArg) );
+NV_LUA_FUN( lua_Unsigned ,(luaL_optunsigned),(lua_State *L, int numArg, lua_Unsigned def) );
+NV_LUA_FUN( void ,(luaL_checkstack),(lua_State *L, int sz, const char *msg) );
+NV_LUA_FUN( void ,(luaL_checktype),(lua_State *L, int narg, int t) );
+NV_LUA_FUN( void ,(luaL_checkany),(lua_State *L, int narg) );
+NV_LUA_FUN( int   ,(luaL_newmetatable),(lua_State *L, const char *tname) );
+NV_LUA_FUN( void  ,(luaL_setmetatable),(lua_State *L, const char *tname) );
+NV_LUA_FUN( void *,(luaL_testudata),(lua_State *L, int ud, const char *tname) );
+NV_LUA_FUN( void *,(luaL_checkudata),(lua_State *L, int ud, const char *tname) );
+NV_LUA_FUN( void ,(luaL_where),(lua_State *L, int lvl) );
+NV_LUA_FUN( int ,(luaL_error),(lua_State *L, const char *fmt, ...) );
+NV_LUA_FUN( int ,(luaL_checkoption),(lua_State *L, int narg, const char *def, const char *const lst[]) );
+NV_LUA_FUN( int ,(luaL_fileresult),(lua_State *L, int stat, const char *fname) );
+NV_LUA_FUN( int ,(luaL_execresult),(lua_State *L, int stat) );
+
+NV_LUA_FUN( int ,(luaL_ref),(lua_State *L, int t) );
+NV_LUA_FUN( void ,(luaL_unref),(lua_State *L, int t, int ref) );
+NV_LUA_FUN( int ,(luaL_loadfilex),(lua_State *L, const char *filename, const char *mode) );
+NV_LUA_FUN( int ,(luaL_loadbufferx),(lua_State *L, const char *buff, size_t sz, const char *name, const char *mode) );
+NV_LUA_FUN( int ,(luaL_loadstring),(lua_State *L, const char *s) );
+NV_LUA_FUN( lua_State *,(luaL_newstate), (void) );
+NV_LUA_FUN( int ,(luaL_len),(lua_State *L, int idx) );
+NV_LUA_FUN( const char *,(luaL_gsub),(lua_State *L, const char *s, const char *p, const char *r) );
+NV_LUA_FUN( void ,(luaL_setfuncs),(lua_State *L, const luaL_Reg *l, int nup) );
+NV_LUA_FUN( int ,(luaL_getsubtable),(lua_State *L, int idx, const char *fname) );
+NV_LUA_FUN( void ,(luaL_traceback),(lua_State *L, lua_State *L1, const char *msg, int level) );
+NV_LUA_FUN( void ,(luaL_requiref),(lua_State *L, const char *modname, lua_CFunction openf, int glb) );
+
+#undef NV_LUA_FUN
+
+/* Macros */
+#define lua_call(L,n,r)		lua_callk(L, (n), (r), 0, NULL)
+#define lua_pcall(L,n,r,f)	lua_pcallk(L, (n), (r), (f), 0, NULL)
+#define lua_yield(L,n)		lua_yieldk(L, (n), 0, NULL)
+#define lua_tonumber(L,i)	lua_tonumberx(L,i,NULL)
+#define lua_tointeger(L,i)	lua_tointegerx(L,i,NULL)
+#define lua_tounsigned(L,i)	lua_tounsignedx(L,i,NULL)
+#define lua_pop(L,n)		lua_settop(L, -(n)-1)
+#define lua_newtable(L)		lua_createtable(L, 0, 0)
+#define lua_register(L,n,f) (lua_pushcfunction(L, (f)), lua_setglobal(L, (n)))
+#define lua_pushcfunction(L,f)	lua_pushcclosure(L, (f), 0)
+#define lua_isfunction(L,n)	(lua_type(L, (n)) == LUA_TFUNCTION)
+#define lua_istable(L,n)	(lua_type(L, (n)) == LUA_TTABLE)
+#define lua_islightuserdata(L,n)	(lua_type(L, (n)) == LUA_TLIGHTUSERDATA)
+#define lua_isnil(L,n)		(lua_type(L, (n)) == LUA_TNIL)
+#define lua_isboolean(L,n)	(lua_type(L, (n)) == LUA_TBOOLEAN)
+#define lua_isthread(L,n)	(lua_type(L, (n)) == LUA_TTHREAD)
+#define lua_isnone(L,n)		(lua_type(L, (n)) == LUA_TNONE)
+#define lua_isnoneornil(L, n)	(lua_type(L, (n)) <= 0)
+#define lua_pushliteral(L, s)	lua_pushlstring(L, "" s, (sizeof(s)/sizeof(char))-1)
+#define lua_pushglobaltable(L)  lua_rawgeti(L, LUA_REGISTRYINDEX, LUA_RIDX_GLOBALS)
+#define lua_tostring(L,i)	lua_tolstring(L, (i), NULL)
+
+/* Aux lib macros */
+#define luaL_checkversion(L)	luaL_checkversion_(L, LUA_VERSION_NUM)
+#define luaL_loadfile(L,f)	luaL_loadfilex(L,f,NULL)
+#define luaL_newlibtable(L,l)	lua_createtable(L, 0, sizeof(l)/sizeof((l)[0]) - 1)
+#define luaL_newlib(L,l)	(luaL_newlibtable(L,l), luaL_setfuncs(L,l,0))
+#define luaL_argcheck(L, cond,numarg,extramsg)	((void)((cond) || luaL_argerror(L, (numarg), (extramsg))))
+#define luaL_checkstring(L,n)	(luaL_checklstring(L, (n), NULL))
+#define luaL_optstring(L,n,d)	(luaL_optlstring(L, (n), (d), NULL))
+#define luaL_checkint(L,n)	((int)luaL_checkinteger(L, (n)))
+#define luaL_optint(L,n,d)	((int)luaL_optinteger(L, (n), (d)))
+#define luaL_checklong(L,n)	((long)luaL_checkinteger(L, (n)))
+#define luaL_optlong(L,n,d)	((long)luaL_optinteger(L, (n), (d)))
+#define luaL_typename(L,i)	lua_typename(L, lua_type(L,(i)))
+#define luaL_dofile(L, fn) (luaL_loadfile(L, fn) || lua_pcall(L, 0, LUA_MULTRET, 0))
+#define luaL_dostring(L, s) (luaL_loadstring(L, s) || lua_pcall(L, 0, LUA_MULTRET, 0))
+#define luaL_getmetatable(L,n)	(lua_getfield(L, LUA_REGISTRYINDEX, (n)))
+#define luaL_opt(L,f,n,d)	(lua_isnoneornil(L,(n)) ? (d) : f(L,(n)))
+#define luaL_loadbuffer(L,s,sz,n)	luaL_loadbufferx(L,s,sz,n,NULL)
+#define luaL_addchar(B,c)  ((void)((B)->n < (B)->size || luaL_prepbuffsize((B), 1)), ((B)->b[(B)->n++] = (c)))
+#define luaL_addsize(B,s)	((B)->n += (s))
+#define luaL_prepbuffer(B)	luaL_prepbuffsize(B, LUAL_BUFFERSIZE)
+
+}
+
+namespace nv {
+/* Dynamic load support */
+#	if defined( NV_LUA_DYNAMIC )
+		bool load_lua_library( const char* path = NV_LUA_PATH );
+#	else
+		inline bool load_lua_library( const char* path = "" ) { return true; }
+#	endif
+}
+
+#endif // NV_LIB_LUA_HH
Index: trunk/nv/lib/sdl12.hh
===================================================================
--- trunk/nv/lib/sdl12.hh	(revision 5)
+++ trunk/nv/lib/sdl12.hh	(revision 5)
@@ -0,0 +1,1051 @@
+// Copyright (C) 2012-2013 ChaosForge / Kornel Kisielewicz
+// http://chaosforge.org/
+//
+// This file is part of NV Libraries.
+// For conditions of distribution and use, see copyright notice in nv.hh
+
+#ifndef NV_LIB_SDL_HH
+#define NV_LIB_SDL_HH
+
+#define NV_SDL_DYNAMIC
+//#define NV_SDL_SHARED
+
+#if NV_PLATFORM == NV_WINDOWS
+#	define NV_SDL_PATH "SDL.dll"
+#elif NV_PLATFORM == NV_APPLE
+#	define NV_SDL_PATH "SDL.framework/SDL"
+#else
+#	define NV_SDL_PATH "libSDL-1.2.so.0"
+#endif
+
+#include <stdint.h>
+#include <stdio.h>
+
+extern "C" {
+
+#if NV_PLATFORM == NV_WINDOWS 
+#	define NV_SDL_APIENTRY __cdecl
+#else
+#	define NV_SDL_APIENTRY 
+#endif
+
+#if defined(NV_SDL_SHARED) && (NV_PLATFORM == NV_WINDOWS)
+#	define NV_SDL_API __declspec(dllimport)
+#else
+#	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 */
+typedef enum {
+	SDL_FALSE = 0,
+	SDL_TRUE  = 1
+} SDL_bool;
+
+typedef int8_t		Sint8;
+typedef uint8_t		Uint8;
+typedef int16_t		Sint16;
+typedef uint16_t	Uint16;
+typedef int32_t		Sint32;
+typedef uint32_t	Uint32;
+typedef int64_t		Sint64;
+typedef uint64_t	Uint64;
+
+static_assert(sizeof(Uint8) == 1, "Uint8 has wrong size!" );
+static_assert(sizeof(Sint8) == 1, "Sint8 has wrong size!");
+static_assert(sizeof(Uint16) == 2, "Uint16 has wrong size!");
+static_assert(sizeof(Sint16) == 2, "Sint16 has wrong size!");
+static_assert(sizeof(Uint32) == 4, "Uint32 has wrong size!");
+static_assert(sizeof(Sint32) == 4, "Sint32 has wrong size!");
+static_assert(sizeof(Uint64) == 8, "Uint64 has wrong size!");
+static_assert(sizeof(Sint64) == 8, "Sint64 has wrong size!");
+
+#define RW_SEEK_SET	0
+#define RW_SEEK_CUR	1
+#define RW_SEEK_END	2
+
+/* SDL.h defines */
+
+#define	SDL_INIT_TIMER		0x00000001
+#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 
+
+/* SDL_error.h defines */
+typedef enum {
+	SDL_ENOMEM,
+	SDL_EFREAD,
+	SDL_EFWRITE,
+	SDL_EFSEEK,
+	SDL_UNSUPPORTED,
+	SDL_LASTERROR
+} SDL_errorcode;
+
+/* 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);
+
+	Uint32 type;
+	union {
+#if NV_PLATFORM == NV_WINDOWS 
+	    struct {
+		int   append;
+		void *h;
+		struct {
+		    void *data;
+		    int size;
+		    int left;
+		} buffer;
+	    } win32io;
+#endif
+	    struct {
+		int autoclose;
+	 	FILE *fp;
+	    } stdio;
+	    struct {
+		Uint8 *base;
+	 	Uint8 *here;
+		Uint8 *stop;
+	    } mem;
+	    struct {
+		void *data1;
+	    } unknown;
+	} hidden;
+
+} SDL_RWops;
+
+/* SDL_video.h defines */
+#define SDL_ALPHA_OPAQUE 255
+#define SDL_ALPHA_TRANSPARENT 0
+
+typedef struct SDL_Rect {
+	Sint16 x, y;
+	Uint16 w, h;
+} SDL_Rect;
+
+typedef struct SDL_Color {
+	Uint8 r;
+	Uint8 g;
+	Uint8 b;
+	Uint8 unused;
+} SDL_Color;
+#define SDL_Colour SDL_Color
+
+typedef struct SDL_Palette {
+	int       ncolors;
+	SDL_Color *colors;
+} SDL_Palette;
+
+typedef struct SDL_PixelFormat {
+	SDL_Palette *palette;
+	Uint8  BitsPerPixel;
+	Uint8  BytesPerPixel;
+	Uint8  Rloss;
+	Uint8  Gloss;
+	Uint8  Bloss;
+	Uint8  Aloss;
+	Uint8  Rshift;
+	Uint8  Gshift;
+	Uint8  Bshift;
+	Uint8  Ashift;
+	Uint32 Rmask;
+	Uint32 Gmask;
+	Uint32 Bmask;
+	Uint32 Amask;
+
+	Uint32 colorkey;
+	Uint8  alpha;
+} SDL_PixelFormat;
+
+typedef struct SDL_Surface {
+	Uint32 flags;
+	SDL_PixelFormat *format;
+	int w, h;
+	Uint16 pitch;
+	void *pixels;
+	int offset;	
+	struct private_hwdata *hwdata;
+	SDL_Rect clip_rect;
+	Uint32 unused1;
+	Uint32 locked;
+	struct SDL_BlitMap *map;
+	unsigned int format_version;
+	int refcount;
+} SDL_Surface;
+
+#define SDL_SWSURFACE	0x00000000	
+#define SDL_HWSURFACE	0x00000001	
+#define SDL_ASYNCBLIT	0x00000004	
+#define SDL_ANYFORMAT	0x10000000	
+#define SDL_HWPALETTE	0x20000000	
+#define SDL_DOUBLEBUF	0x40000000	
+#define SDL_FULLSCREEN	0x80000000	
+#define SDL_OPENGL      0x00000002  
+#define SDL_OPENGLBLIT	0x0000000A	
+#define SDL_RESIZABLE	0x00000010	
+#define SDL_NOFRAME	0x00000020	
+#define SDL_HWACCEL	0x00000100	
+#define SDL_SRCCOLORKEY	0x00001000	
+#define SDL_RLEACCELOK	0x00002000	
+#define SDL_RLEACCEL	0x00004000	
+#define SDL_SRCALPHA	0x00010000	
+#define SDL_PREALLOC	0x01000000	
+
+#define SDL_MUSTLOCK(surface)	\
+  (surface->offset ||		\
+  ((surface->flags & (SDL_HWSURFACE|SDL_ASYNCBLIT|SDL_RLEACCEL)) != 0))
+
+typedef int (*SDL_blit)(struct SDL_Surface *src, SDL_Rect *srcrect, struct SDL_Surface *dst, SDL_Rect *dstrect);
+
+typedef struct SDL_VideoInfo {
+	Uint32 hw_available :1;
+	Uint32 wm_available :1;
+	Uint32 UnusedBits1  :6;
+	Uint32 UnusedBits2  :1;
+	Uint32 blit_hw      :1;
+	Uint32 blit_hw_CC   :1;
+	Uint32 blit_hw_A    :1;
+	Uint32 blit_sw      :1;
+	Uint32 blit_sw_CC   :1;
+	Uint32 blit_sw_A    :1;
+	Uint32 blit_fill    :1;
+	Uint32 UnusedBits3  :16;
+	Uint32 video_mem;
+	SDL_PixelFormat *vfmt;
+	int    current_w;
+	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 {
+    SDL_GL_RED_SIZE,
+    SDL_GL_GREEN_SIZE,
+    SDL_GL_BLUE_SIZE,
+    SDL_GL_ALPHA_SIZE,
+    SDL_GL_BUFFER_SIZE,
+    SDL_GL_DOUBLEBUFFER,
+    SDL_GL_DEPTH_SIZE,
+    SDL_GL_STENCIL_SIZE,
+    SDL_GL_ACCUM_RED_SIZE,
+    SDL_GL_ACCUM_GREEN_SIZE,
+    SDL_GL_ACCUM_BLUE_SIZE,
+    SDL_GL_ACCUM_ALPHA_SIZE,
+    SDL_GL_STEREO,
+    SDL_GL_MULTISAMPLEBUFFERS,
+    SDL_GL_MULTISAMPLESAMPLES,
+    SDL_GL_ACCELERATED_VISUAL,
+    SDL_GL_SWAP_CONTROL
+} SDL_GLattr;
+
+#define SDL_LOGPAL 0x01
+#define SDL_PHYSPAL 0x02
+
+typedef enum {
+	SDL_GRAB_QUERY = -1,
+	SDL_GRAB_OFF = 0,
+	SDL_GRAB_ON = 1,
+	SDL_GRAB_FULLSCREEN	/**< Used internally */
+} SDL_GrabMode;
+
+/* SDL_audio.h defines */
+typedef struct SDL_AudioSpec {
+	int freq;
+	Uint16 format;
+	Uint8  channels;
+	Uint8  silence;
+	Uint16 samples;
+	Uint16 padding;
+	Uint32 size;
+	void (SDLCALL *callback)(void *userdata, Uint8 *stream, int len);
+	void  *userdata;
+} SDL_AudioSpec;
+
+#define AUDIO_U8	0x0008
+#define AUDIO_S8	0x8008
+#define AUDIO_U16LSB	0x0010	
+#define AUDIO_S16LSB	0x8010	
+#define AUDIO_U16MSB	0x1010	
+#define AUDIO_S16MSB	0x9010
+#define AUDIO_U16	AUDIO_U16LSB
+#define AUDIO_S16	AUDIO_S16LSB
+
+/* NOTE : assuming LSB! */
+#define AUDIO_U16SYS	AUDIO_U16LSB
+#define AUDIO_S16SYS	AUDIO_S16LSB
+
+typedef struct SDL_AudioCVT {
+	int needed;
+	Uint16 src_format;
+	Uint16 dst_format;
+	double rate_incr;
+	Uint8 *buf;		
+	int    len;		
+	int    len_cvt;	
+	int    len_mult;
+	double len_ratio;
+	void (SDLCALL *filters[10])(struct SDL_AudioCVT *cvt, Uint16 format);
+	int filter_index;
+} SDL_AudioCVT; 
+	
+typedef enum {
+	SDL_AUDIO_STOPPED = 0,
+	SDL_AUDIO_PLAYING,
+	SDL_AUDIO_PAUSED
+} SDL_audiostatus;
+
+#define SDL_MIX_MAXVOLUME 128
+
+/* SDL_active.h defines */
+#define SDL_APPMOUSEFOCUS	0x01
+#define SDL_APPINPUTFOCUS	0x02
+#define SDL_APPACTIVE		0x04
+
+/* SDL_keyboard.h defines */
+typedef enum {
+	SDLK_UNKNOWN		= 0,
+	SDLK_FIRST		= 0,
+	SDLK_BACKSPACE		= 8,
+	SDLK_TAB		= 9,
+	SDLK_CLEAR		= 12,
+	SDLK_RETURN		= 13,
+	SDLK_PAUSE		= 19,
+	SDLK_ESCAPE		= 27,
+	SDLK_SPACE		= 32,
+	SDLK_EXCLAIM		= 33,
+	SDLK_QUOTEDBL		= 34,
+	SDLK_HASH		= 35,
+	SDLK_DOLLAR		= 36,
+	SDLK_AMPERSAND		= 38,
+	SDLK_QUOTE		= 39,
+	SDLK_LEFTPAREN		= 40,
+	SDLK_RIGHTPAREN		= 41,
+	SDLK_ASTERISK		= 42,
+	SDLK_PLUS		= 43,
+	SDLK_COMMA		= 44,
+	SDLK_MINUS		= 45,
+	SDLK_PERIOD		= 46,
+	SDLK_SLASH		= 47,
+	SDLK_0			= 48,
+	SDLK_1			= 49,
+	SDLK_2			= 50,
+	SDLK_3			= 51,
+	SDLK_4			= 52,
+	SDLK_5			= 53,
+	SDLK_6			= 54,
+	SDLK_7			= 55,
+	SDLK_8			= 56,
+	SDLK_9			= 57,
+	SDLK_COLON		= 58,
+	SDLK_SEMICOLON		= 59,
+	SDLK_LESS		= 60,
+	SDLK_EQUALS		= 61,
+	SDLK_GREATER		= 62,
+	SDLK_QUESTION		= 63,
+	SDLK_AT			= 64,
+	SDLK_LEFTBRACKET	= 91,
+	SDLK_BACKSLASH		= 92,
+	SDLK_RIGHTBRACKET	= 93,
+	SDLK_CARET		= 94,
+	SDLK_UNDERSCORE		= 95,
+	SDLK_BACKQUOTE		= 96,
+	SDLK_a			= 97,
+	SDLK_b			= 98,
+	SDLK_c			= 99,
+	SDLK_d			= 100,
+	SDLK_e			= 101,
+	SDLK_f			= 102,
+	SDLK_g			= 103,
+	SDLK_h			= 104,
+	SDLK_i			= 105,
+	SDLK_j			= 106,
+	SDLK_k			= 107,
+	SDLK_l			= 108,
+	SDLK_m			= 109,
+	SDLK_n			= 110,
+	SDLK_o			= 111,
+	SDLK_p			= 112,
+	SDLK_q			= 113,
+	SDLK_r			= 114,
+	SDLK_s			= 115,
+	SDLK_t			= 116,
+	SDLK_u			= 117,
+	SDLK_v			= 118,
+	SDLK_w			= 119,
+	SDLK_x			= 120,
+	SDLK_y			= 121,
+	SDLK_z			= 122,
+	SDLK_DELETE		= 127,
+	SDLK_WORLD_0		= 160,
+	SDLK_WORLD_1		= 161,
+	SDLK_WORLD_2		= 162,
+	SDLK_WORLD_3		= 163,
+	SDLK_WORLD_4		= 164,
+	SDLK_WORLD_5		= 165,
+	SDLK_WORLD_6		= 166,
+	SDLK_WORLD_7		= 167,
+	SDLK_WORLD_8		= 168,
+	SDLK_WORLD_9		= 169,
+	SDLK_WORLD_10		= 170,
+	SDLK_WORLD_11		= 171,
+	SDLK_WORLD_12		= 172,
+	SDLK_WORLD_13		= 173,
+	SDLK_WORLD_14		= 174,
+	SDLK_WORLD_15		= 175,
+	SDLK_WORLD_16		= 176,
+	SDLK_WORLD_17		= 177,
+	SDLK_WORLD_18		= 178,
+	SDLK_WORLD_19		= 179,
+	SDLK_WORLD_20		= 180,
+	SDLK_WORLD_21		= 181,
+	SDLK_WORLD_22		= 182,
+	SDLK_WORLD_23		= 183,
+	SDLK_WORLD_24		= 184,
+	SDLK_WORLD_25		= 185,
+	SDLK_WORLD_26		= 186,
+	SDLK_WORLD_27		= 187,
+	SDLK_WORLD_28		= 188,
+	SDLK_WORLD_29		= 189,
+	SDLK_WORLD_30		= 190,
+	SDLK_WORLD_31		= 191,
+	SDLK_WORLD_32		= 192,
+	SDLK_WORLD_33		= 193,
+	SDLK_WORLD_34		= 194,
+	SDLK_WORLD_35		= 195,
+	SDLK_WORLD_36		= 196,
+	SDLK_WORLD_37		= 197,
+	SDLK_WORLD_38		= 198,
+	SDLK_WORLD_39		= 199,
+	SDLK_WORLD_40		= 200,
+	SDLK_WORLD_41		= 201,
+	SDLK_WORLD_42		= 202,
+	SDLK_WORLD_43		= 203,
+	SDLK_WORLD_44		= 204,
+	SDLK_WORLD_45		= 205,
+	SDLK_WORLD_46		= 206,
+	SDLK_WORLD_47		= 207,
+	SDLK_WORLD_48		= 208,
+	SDLK_WORLD_49		= 209,
+	SDLK_WORLD_50		= 210,
+	SDLK_WORLD_51		= 211,
+	SDLK_WORLD_52		= 212,
+	SDLK_WORLD_53		= 213,
+	SDLK_WORLD_54		= 214,
+	SDLK_WORLD_55		= 215,
+	SDLK_WORLD_56		= 216,
+	SDLK_WORLD_57		= 217,
+	SDLK_WORLD_58		= 218,
+	SDLK_WORLD_59		= 219,
+	SDLK_WORLD_60		= 220,
+	SDLK_WORLD_61		= 221,
+	SDLK_WORLD_62		= 222,
+	SDLK_WORLD_63		= 223,
+	SDLK_WORLD_64		= 224,
+	SDLK_WORLD_65		= 225,
+	SDLK_WORLD_66		= 226,
+	SDLK_WORLD_67		= 227,
+	SDLK_WORLD_68		= 228,
+	SDLK_WORLD_69		= 229,
+	SDLK_WORLD_70		= 230,
+	SDLK_WORLD_71		= 231,
+	SDLK_WORLD_72		= 232,
+	SDLK_WORLD_73		= 233,
+	SDLK_WORLD_74		= 234,
+	SDLK_WORLD_75		= 235,
+	SDLK_WORLD_76		= 236,
+	SDLK_WORLD_77		= 237,
+	SDLK_WORLD_78		= 238,
+	SDLK_WORLD_79		= 239,
+	SDLK_WORLD_80		= 240,
+	SDLK_WORLD_81		= 241,
+	SDLK_WORLD_82		= 242,
+	SDLK_WORLD_83		= 243,
+	SDLK_WORLD_84		= 244,
+	SDLK_WORLD_85		= 245,
+	SDLK_WORLD_86		= 246,
+	SDLK_WORLD_87		= 247,
+	SDLK_WORLD_88		= 248,
+	SDLK_WORLD_89		= 249,
+	SDLK_WORLD_90		= 250,
+	SDLK_WORLD_91		= 251,
+	SDLK_WORLD_92		= 252,
+	SDLK_WORLD_93		= 253,
+	SDLK_WORLD_94		= 254,
+	SDLK_WORLD_95		= 255,
+	SDLK_KP0		= 256,
+	SDLK_KP1		= 257,
+	SDLK_KP2		= 258,
+	SDLK_KP3		= 259,
+	SDLK_KP4		= 260,
+	SDLK_KP5		= 261,
+	SDLK_KP6		= 262,
+	SDLK_KP7		= 263,
+	SDLK_KP8		= 264,
+	SDLK_KP9		= 265,
+	SDLK_KP_PERIOD		= 266,
+	SDLK_KP_DIVIDE		= 267,
+	SDLK_KP_MULTIPLY	= 268,
+	SDLK_KP_MINUS		= 269,
+	SDLK_KP_PLUS		= 270,
+	SDLK_KP_ENTER		= 271,
+	SDLK_KP_EQUALS		= 272,
+	SDLK_UP			= 273,
+	SDLK_DOWN		= 274,
+	SDLK_RIGHT		= 275,
+	SDLK_LEFT		= 276,
+	SDLK_INSERT		= 277,
+	SDLK_HOME		= 278,
+	SDLK_END		= 279,
+	SDLK_PAGEUP		= 280,
+	SDLK_PAGEDOWN		= 281,
+	SDLK_F1			= 282,
+	SDLK_F2			= 283,
+	SDLK_F3			= 284,
+	SDLK_F4			= 285,
+	SDLK_F5			= 286,
+	SDLK_F6			= 287,
+	SDLK_F7			= 288,
+	SDLK_F8			= 289,
+	SDLK_F9			= 290,
+	SDLK_F10		= 291,
+	SDLK_F11		= 292,
+	SDLK_F12		= 293,
+	SDLK_F13		= 294,
+	SDLK_F14		= 295,
+	SDLK_F15		= 296,
+	SDLK_NUMLOCK		= 300,
+	SDLK_CAPSLOCK		= 301,
+	SDLK_SCROLLOCK		= 302,
+	SDLK_RSHIFT		= 303,
+	SDLK_LSHIFT		= 304,
+	SDLK_RCTRL		= 305,
+	SDLK_LCTRL		= 306,
+	SDLK_RALT		= 307,
+	SDLK_LALT		= 308,
+	SDLK_RMETA		= 309,
+	SDLK_LMETA		= 310,
+	SDLK_LSUPER		= 311,
+	SDLK_RSUPER		= 312,
+	SDLK_MODE		= 313,
+	SDLK_COMPOSE		= 314,
+	SDLK_HELP		= 315,
+	SDLK_PRINT		= 316,
+	SDLK_SYSREQ		= 317,
+	SDLK_BREAK		= 318,
+	SDLK_MENU		= 319,
+	SDLK_POWER		= 320,
+	SDLK_EURO		= 321,
+	SDLK_UNDO		= 322,
+	SDLK_LAST
+} SDLKey;
+
+typedef enum {
+	KMOD_NONE  = 0x0000,
+	KMOD_LSHIFT= 0x0001,
+	KMOD_RSHIFT= 0x0002,
+	KMOD_LCTRL = 0x0040,
+	KMOD_RCTRL = 0x0080,
+	KMOD_LALT  = 0x0100,
+	KMOD_RALT  = 0x0200,
+	KMOD_LMETA = 0x0400,
+	KMOD_RMETA = 0x0800,
+	KMOD_NUM   = 0x1000,
+	KMOD_CAPS  = 0x2000,
+	KMOD_MODE  = 0x4000,
+	KMOD_RESERVED = 0x8000
+} SDLMod;
+
+#define KMOD_CTRL	(KMOD_LCTRL|KMOD_RCTRL)
+#define KMOD_SHIFT	(KMOD_LSHIFT|KMOD_RSHIFT)
+#define KMOD_ALT	(KMOD_LALT|KMOD_RALT)
+#define KMOD_META	(KMOD_LMETA|KMOD_RMETA)
+
+#define SDL_DEFAULT_REPEAT_DELAY	500
+#define SDL_DEFAULT_REPEAT_INTERVAL	30
+
+typedef struct SDL_keysym {
+	Uint8 scancode;
+	SDLKey sym;
+	SDLMod mod;
+	Uint16 unicode;
+} SDL_keysym;
+
+#define SDL_ALL_HOTKEYS		0xFFFFFFFF
+
+/* SDL_mouse.h defines */
+typedef struct WMcursor WMcursor;
+typedef struct SDL_Cursor {
+	SDL_Rect area;	
+	Sint16 hot_x, hot_y;
+	Uint8 *data;
+	Uint8 *mask;
+	Uint8 *save[2];	
+	WMcursor *wm_cursor;
+} SDL_Cursor;
+ 
+#define SDL_BUTTON(X)		(1 << ((X)-1))
+#define SDL_BUTTON_LEFT		1
+#define SDL_BUTTON_MIDDLE	2
+#define SDL_BUTTON_RIGHT	3
+#define SDL_BUTTON_WHEELUP	4
+#define SDL_BUTTON_WHEELDOWN	5
+#define SDL_BUTTON_X1		6
+#define SDL_BUTTON_X2		7
+#define SDL_BUTTON_LMASK	SDL_BUTTON(SDL_BUTTON_LEFT)
+#define SDL_BUTTON_MMASK	SDL_BUTTON(SDL_BUTTON_MIDDLE)
+#define SDL_BUTTON_RMASK	SDL_BUTTON(SDL_BUTTON_RIGHT)
+#define SDL_BUTTON_X1MASK	SDL_BUTTON(SDL_BUTTON_X1)
+#define SDL_BUTTON_X2MASK	SDL_BUTTON(SDL_BUTTON_X2) 
+
+/* SDL_joystick.h defines */
+struct _SDL_Joystick;
+typedef struct _SDL_Joystick SDL_Joystick; 
+
+#define SDL_HAT_CENTERED	0x00
+#define SDL_HAT_UP		0x01
+#define SDL_HAT_RIGHT		0x02
+#define SDL_HAT_DOWN		0x04
+#define SDL_HAT_LEFT		0x08
+#define SDL_HAT_RIGHTUP		(SDL_HAT_RIGHT|SDL_HAT_UP)
+#define SDL_HAT_RIGHTDOWN	(SDL_HAT_RIGHT|SDL_HAT_DOWN)
+#define SDL_HAT_LEFTUP		(SDL_HAT_LEFT|SDL_HAT_UP)
+#define SDL_HAT_LEFTDOWN	(SDL_HAT_LEFT|SDL_HAT_DOWN)
+
+/* SDL_event.h defines */
+#define SDL_RELEASED	0
+#define SDL_PRESSED	1
+
+typedef enum {
+       SDL_NOEVENT = 0,
+       SDL_ACTIVEEVENT,
+       SDL_KEYDOWN,
+       SDL_KEYUP,
+       SDL_MOUSEMOTION,
+       SDL_MOUSEBUTTONDOWN,
+       SDL_MOUSEBUTTONUP,
+       SDL_JOYAXISMOTION,
+       SDL_JOYBALLMOTION,
+       SDL_JOYHATMOTION,
+       SDL_JOYBUTTONDOWN,
+       SDL_JOYBUTTONUP,
+       SDL_QUIT,
+       SDL_SYSWMEVENT,
+       SDL_EVENT_RESERVEDA,
+       SDL_EVENT_RESERVEDB,
+       SDL_VIDEORESIZE,
+       SDL_VIDEOEXPOSE,
+       SDL_EVENT_RESERVED2,
+       SDL_EVENT_RESERVED3,
+       SDL_EVENT_RESERVED4,
+       SDL_EVENT_RESERVED5,
+       SDL_EVENT_RESERVED6,
+       SDL_EVENT_RESERVED7,
+       SDL_USEREVENT = 24,
+       SDL_NUMEVENTS = 32
+} SDL_EventType;
+
+#define SDL_EVENTMASK(X)	(1<<(X))
+typedef enum {
+	SDL_ACTIVEEVENTMASK	= SDL_EVENTMASK(SDL_ACTIVEEVENT),
+	SDL_KEYDOWNMASK		= SDL_EVENTMASK(SDL_KEYDOWN),
+	SDL_KEYUPMASK		= SDL_EVENTMASK(SDL_KEYUP),
+	SDL_KEYEVENTMASK	= SDL_EVENTMASK(SDL_KEYDOWN)|
+	                          SDL_EVENTMASK(SDL_KEYUP),
+	SDL_MOUSEMOTIONMASK	= SDL_EVENTMASK(SDL_MOUSEMOTION),
+	SDL_MOUSEBUTTONDOWNMASK	= SDL_EVENTMASK(SDL_MOUSEBUTTONDOWN),
+	SDL_MOUSEBUTTONUPMASK	= SDL_EVENTMASK(SDL_MOUSEBUTTONUP),
+	SDL_MOUSEEVENTMASK	= SDL_EVENTMASK(SDL_MOUSEMOTION)|
+	                          SDL_EVENTMASK(SDL_MOUSEBUTTONDOWN)|
+	                          SDL_EVENTMASK(SDL_MOUSEBUTTONUP),
+	SDL_JOYAXISMOTIONMASK	= SDL_EVENTMASK(SDL_JOYAXISMOTION),
+	SDL_JOYBALLMOTIONMASK	= SDL_EVENTMASK(SDL_JOYBALLMOTION),
+	SDL_JOYHATMOTIONMASK	= SDL_EVENTMASK(SDL_JOYHATMOTION),
+	SDL_JOYBUTTONDOWNMASK	= SDL_EVENTMASK(SDL_JOYBUTTONDOWN),
+	SDL_JOYBUTTONUPMASK	= SDL_EVENTMASK(SDL_JOYBUTTONUP),
+	SDL_JOYEVENTMASK	= SDL_EVENTMASK(SDL_JOYAXISMOTION)|
+	                          SDL_EVENTMASK(SDL_JOYBALLMOTION)|
+	                          SDL_EVENTMASK(SDL_JOYHATMOTION)|
+	                          SDL_EVENTMASK(SDL_JOYBUTTONDOWN)|
+	                          SDL_EVENTMASK(SDL_JOYBUTTONUP),
+	SDL_VIDEORESIZEMASK	= SDL_EVENTMASK(SDL_VIDEORESIZE),
+	SDL_VIDEOEXPOSEMASK	= SDL_EVENTMASK(SDL_VIDEOEXPOSE),
+	SDL_QUITMASK		= SDL_EVENTMASK(SDL_QUIT),
+	SDL_SYSWMEVENTMASK	= SDL_EVENTMASK(SDL_SYSWMEVENT)
+} SDL_EventMask ;
+#define SDL_ALLEVENTS		0xFFFFFFFF
+
+typedef struct SDL_ActiveEvent {
+	Uint8 type;
+	Uint8 gain;
+	Uint8 state;
+} SDL_ActiveEvent;
+
+typedef struct SDL_KeyboardEvent {
+	Uint8 type;	
+	Uint8 which;
+	Uint8 state;
+	SDL_keysym keysym;
+} SDL_KeyboardEvent;
+
+typedef struct SDL_MouseMotionEvent {
+	Uint8 type;
+	Uint8 which;
+	Uint8 state;
+	Uint16 x, y;
+	Sint16 xrel;
+	Sint16 yrel;
+} SDL_MouseMotionEvent;
+
+typedef struct SDL_MouseButtonEvent {
+	Uint8 type;
+	Uint8 which;
+	Uint8 button;
+	Uint8 state;
+	Uint16 x, y;
+} SDL_MouseButtonEvent;
+
+typedef struct SDL_JoyAxisEvent {
+	Uint8 type;
+	Uint8 which;
+	Uint8 axis;
+	Sint16 value;
+} SDL_JoyAxisEvent;
+
+typedef struct SDL_JoyBallEvent {
+	Uint8 type;
+	Uint8 which;
+	Uint8 ball;
+	Sint16 xrel;
+	Sint16 yrel;
+} SDL_JoyBallEvent;
+
+typedef struct SDL_JoyHatEvent {
+	Uint8 type;
+	Uint8 which;
+	Uint8 hat;
+	Uint8 value;
+} SDL_JoyHatEvent;
+
+typedef struct SDL_JoyButtonEvent {
+	Uint8 type;
+	Uint8 which;
+	Uint8 button;
+	Uint8 state;
+} SDL_JoyButtonEvent;
+
+typedef struct SDL_ResizeEvent {
+	Uint8 type;
+	int w;
+	int h;
+} SDL_ResizeEvent;
+
+typedef struct SDL_ExposeEvent {
+	Uint8 type;
+} SDL_ExposeEvent;
+
+typedef struct SDL_QuitEvent {
+	Uint8 type;
+} SDL_QuitEvent;
+
+typedef struct SDL_UserEvent {
+	Uint8 type;
+	int code;
+	void *data1;
+	void *data2;
+} SDL_UserEvent;
+
+struct SDL_SysWMmsg;
+typedef struct SDL_SysWMmsg SDL_SysWMmsg;
+typedef struct SDL_SysWMEvent {
+	Uint8 type;
+	SDL_SysWMmsg *msg;
+} SDL_SysWMEvent;
+
+typedef union SDL_Event {
+	Uint8 type;
+	SDL_ActiveEvent active;
+	SDL_KeyboardEvent key;
+	SDL_MouseMotionEvent motion;
+	SDL_MouseButtonEvent button;
+	SDL_JoyAxisEvent jaxis;
+	SDL_JoyBallEvent jball;
+	SDL_JoyHatEvent jhat;
+	SDL_JoyButtonEvent jbutton;
+	SDL_ResizeEvent resize;
+	SDL_ExposeEvent expose;
+	SDL_QuitEvent quit;
+	SDL_UserEvent user;
+	SDL_SysWMEvent syswm;
+} SDL_Event;
+
+typedef enum {
+	SDL_ADDEVENT,
+	SDL_PEEKEVENT,
+	SDL_GETEVENT
+} SDL_eventaction;
+
+typedef int (SDLCALL *SDL_EventFilter)(const SDL_Event *event);
+
+#define SDL_QUERY	-1
+#define SDL_IGNORE	 0
+#define SDL_DISABLE	 0
+#define SDL_ENABLE	 1
+
+/* SDL_timer.h defines */
+#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 struct _SDL_TimerID *SDL_TimerID;
+
+/* SDL_version.h defines */
+#define SDL_MAJOR_VERSION	1
+#define SDL_MINOR_VERSION	2
+#define SDL_PATCHLEVEL		15 
+
+typedef struct SDL_version {
+	Uint8 major;
+	Uint8 minor;
+	Uint8 patch;
+} 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 type, int state) );
+
+#define SDL_RWseek(ctx, offset, whence)	(ctx)->seek(ctx, offset, whence)
+#define SDL_RWtell(ctx)			(ctx)->seek(ctx, 0, RW_SEEK_CUR)
+#define SDL_RWread(ctx, ptr, size, n)	(ctx)->read(ctx, ptr, size, n)
+#define SDL_RWwrite(ctx, ptr, size, n)	(ctx)->write(ctx, ptr, size, n)
+#define SDL_RWclose(ctx)		(ctx)->close(ctx)
+#define SDL_BlitSurface SDL_UpperBlit
+#define SDL_VERSION(X)							\
+{									\
+	(X)->major = SDL_MAJOR_VERSION;					\
+	(X)->minor = SDL_MINOR_VERSION;					\
+	(X)->patch = SDL_PATCHLEVEL;					\
+}
+#define SDL_VERSIONNUM(X, Y, Z)						\
+	((X)*1000 + (Y)*100 + (Z))
+#define SDL_COMPILEDVERSION \
+	SDL_VERSIONNUM(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL)
+#define SDL_VERSION_ATLEAST(X, Y, Z) \
+	(SDL_COMPILEDVERSION >= SDL_VERSIONNUM(X, Y, Z))
+ 
+}
+
+namespace nv {
+/* Dynamic load support */
+#	if defined( NV_SDL_DYNAMIC )
+		bool load_sdl_library( const char* path = NV_SDL_PATH );
+#	else
+		inline bool load_sdl_library( const char* path = "" ) { return true; }
+#	endif
+}
+
+#endif // NV_LIB_SDL_HH
Index: trunk/nv/lib/sdl_image.hh
===================================================================
--- trunk/nv/lib/sdl_image.hh	(revision 5)
+++ trunk/nv/lib/sdl_image.hh	(revision 5)
@@ -0,0 +1,71 @@
+// Copyright (C) 2012-2013 ChaosForge / Kornel Kisielewicz
+// http://chaosforge.org/
+//
+// This file is part of NV Libraries.
+// For conditions of distribution and use, see copyright notice in nv.hh
+
+#ifndef NV_LIB_SDL_IMAGE_HH
+#define NV_LIB_SDL_IMAGE_HH
+
+#include <nv/lib/sdl12.hh>
+
+#if NV_PLATFORM == NV_WINDOWS
+#	define NV_SDL_IMAGE_PATH "SDL_image.dll"
+#elif NV_PLATFORM == NV_APPLE
+#	define NV_SDL_IMAGE_PATH "SDL_image.framework/SDL_image"
+#else
+#	define NV_SDL_IMAGE_PATH "libSDL_image-1.2.so.0"
+#endif
+
+extern "C" {
+
+/** SDL_image defines */
+#define SDL_IMAGE_MAJOR_VERSION	1
+#define SDL_IMAGE_MINOR_VERSION	2
+#define SDL_IMAGE_PATCHLEVEL	11
+#define SDL_IMAGE_VERSION(X)						\
+{									\
+	(X)->major = SDL_IMAGE_MAJOR_VERSION;				\
+	(X)->minor = SDL_IMAGE_MINOR_VERSION;				\
+	(X)->patch = SDL_IMAGE_PATCHLEVEL;				\
+}
+typedef enum
+{
+    IMG_INIT_JPG = 0x00000001,
+    IMG_INIT_PNG = 0x00000002,
+    IMG_INIT_TIF = 0x00000004,
+} 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 *type) );
+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) );
+}
+
+namespace nv {
+/* Dynamic load support */
+#	if defined( NV_SDL_DYNAMIC )
+		bool load_sdl_image_library( const char* path = NV_SDL_IMAGE_PATH );
+#	else
+		inline bool load_sdl_image_library( const char* path = "" ) { return true; }
+#	endif
+}
+
+#endif // NV_LIB_SDL_IMAGE_HH
Index: trunk/src/lib/gl.cc
===================================================================
--- trunk/src/lib/gl.cc	(revision 5)
+++ trunk/src/lib/gl.cc	(revision 5)
@@ -0,0 +1,406 @@
+// Copyright (C) 2012-2013 ChaosForge / Kornel Kisielewicz
+// http://chaosforge.org/
+//
+// This file is part of NV Libraries.
+// For conditions of distribution and use, see copyright notice in nv.hh
+
+#include "nv/lib/gl.hh"
+
+#if defined( NV_GL_DYNAMIC )
+
+#include "nv/library.hh"
+
+#if defined( NV_SDL_GL )
+#	include "nv/lib/sdl12.hh"
+#endif
+
+/* OpenGL 1.1 non-deprecated functions */
+void (NV_GL_APIENTRY *glCullFace) ( GLenum ) = nullptr;
+void (NV_GL_APIENTRY *glFrontFace) ( GLenum ) = nullptr;
+void (NV_GL_APIENTRY *glHint) ( GLenum, GLenum ) = nullptr;
+void (NV_GL_APIENTRY *glLineWidth) ( GLfloat ) = nullptr;
+void (NV_GL_APIENTRY *glPointSize) ( GLfloat ) = nullptr;
+void (NV_GL_APIENTRY *glPolygonMode) ( GLenum, GLenum ) = nullptr;
+void (NV_GL_APIENTRY *glScissor) ( GLint , GLint , GLsizei , GLsizei ) = nullptr;
+void (NV_GL_APIENTRY *glTexParameterf) ( GLenum , GLenum , GLfloat ) = nullptr;
+void (NV_GL_APIENTRY *glTexParameterfv) ( GLenum , GLenum , const GLint *) = nullptr;
+void (NV_GL_APIENTRY *glTexParameteri) ( GLenum , GLenum , GLfloat ) = nullptr;
+void (NV_GL_APIENTRY *glTexParameteriv) ( GLenum , GLenum , const GLint *) = nullptr;
+void (NV_GL_APIENTRY *glTexImage1D) ( GLenum , GLint , GLint , GLsizei , GLint , GLenum , GLenum , const GLvoid *) = nullptr;
+void (NV_GL_APIENTRY *glTexImage2D) ( GLenum , GLint , GLint , GLsizei , GLsizei , GLint , GLenum , GLenum , const GLvoid *) = nullptr;
+void (NV_GL_APIENTRY *glDrawBuffer) ( GLenum ) = nullptr;
+void (NV_GL_APIENTRY *glClear) ( GLbitfield ) = nullptr;
+void (NV_GL_APIENTRY *glClearColor) ( GLfloat , GLfloat , GLfloat , GLfloat ) = nullptr;
+void (NV_GL_APIENTRY *glClearStencil) ( GLint ) = nullptr;
+void (NV_GL_APIENTRY *glClearDepth) ( GLdouble ) = nullptr;
+void (NV_GL_APIENTRY *glStencilMask) ( GLuint ) = nullptr;
+void (NV_GL_APIENTRY *glColorMask) ( GLboolean , GLboolean , GLboolean , GLboolean ) = nullptr;
+void (NV_GL_APIENTRY *glDepthMask) ( GLboolean ) = nullptr;
+void (NV_GL_APIENTRY *glDisable) ( GLenum ) = nullptr;
+void (NV_GL_APIENTRY *glEnable) ( GLenum ) = nullptr;
+void (NV_GL_APIENTRY *glFinish) ( void ) = nullptr;
+void (NV_GL_APIENTRY *glFlush) ( void ) = nullptr;
+void (NV_GL_APIENTRY *glBlendFunc) ( GLenum, GLenum ) = nullptr;
+void (NV_GL_APIENTRY *glLogicOp) ( GLenum ) = nullptr;
+void (NV_GL_APIENTRY *glStencilFunc) ( GLenum , GLint , GLuint ) = nullptr;
+void (NV_GL_APIENTRY *glStencilOp) ( GLenum , GLenum , GLenum ) = nullptr;
+void (NV_GL_APIENTRY *glDepthFunc) ( GLenum ) = nullptr;
+void (NV_GL_APIENTRY *glPixelStoref) ( GLenum , GLfloat ) = nullptr;
+void (NV_GL_APIENTRY *glPixelStorei) ( GLenum , GLint ) = nullptr;
+void (NV_GL_APIENTRY *glReadBuffer) ( GLenum ) = nullptr;
+void (NV_GL_APIENTRY *glReadPixels) ( GLint , GLint , GLsizei , GLsizei , GLenum , GLenum , GLvoid *) = nullptr;
+void (NV_GL_APIENTRY *glGetBooleanv) ( GLenum , GLboolean *) = nullptr;
+void (NV_GL_APIENTRY *glGetDoublev) ( GLenum , GLdouble *) = nullptr;
+GLenum (NV_GL_APIENTRY *glGetError) ( void ) = nullptr;
+void (NV_GL_APIENTRY *glGetFloatv) ( GLenum , GLfloat *) = nullptr;
+void (NV_GL_APIENTRY *glGetIntegerv) ( GLenum , GLint *) = nullptr;
+const GLubyte * (NV_GL_APIENTRY *glGetString) ( GLenum ) = nullptr;
+void (NV_GL_APIENTRY *glGetTexImage) ( GLenum , GLint , GLenum , GLenum , GLvoid *) = nullptr;
+void (NV_GL_APIENTRY *glGetTexParameterfv) ( GLenum , GLenum , GLfloat *) = nullptr;
+void (NV_GL_APIENTRY *glGetTexParameteriv) ( GLenum , GLenum , GLint *) = nullptr;
+void (NV_GL_APIENTRY *glGetTexLevelParameterfv) ( GLenum , GLint , GLenum , GLfloat *) = nullptr;
+void (NV_GL_APIENTRY *glGetTexLevelParameteriv) ( GLenum , GLint , GLenum , GLint *) = nullptr;
+GLboolean (NV_GL_APIENTRY *glIsEnabled) ( GLenum ) = nullptr;
+void (NV_GL_APIENTRY *glDepthRange) ( GLdouble , GLdouble ) = nullptr;
+void (NV_GL_APIENTRY *glViewport) ( GLint , GLint , GLsizei , GLsizei ) = nullptr;
+void (NV_GL_APIENTRY *glDrawArrays) ( GLenum , GLint , GLsizei ) = nullptr;
+void (NV_GL_APIENTRY *glDrawElements) ( GLenum , GLsizei , GLenum , const GLvoid *) = nullptr;
+void (NV_GL_APIENTRY *glGetPointerv) ( GLenum , GLvoid* *) = nullptr;
+void (NV_GL_APIENTRY *glPolygonOffset) ( GLfloat , GLfloat ) = nullptr;
+void (NV_GL_APIENTRY *glCopyTexImage1D) ( GLenum , GLint , GLenum , GLint , GLint , GLsizei , GLint ) = nullptr;
+void (NV_GL_APIENTRY *glCopyTexImage2D) ( GLenum , GLint , GLenum , GLint , GLint , GLsizei , GLsizei , GLint ) = nullptr;
+void (NV_GL_APIENTRY *glCopyTexSubImage1D) ( GLenum , GLint , GLint , GLint , GLint , GLsizei ) = nullptr;
+void (NV_GL_APIENTRY *glCopyTexSubImage2D) ( GLenum , GLint , GLint , GLint , GLint , GLint , GLsizei , GLsizei ) = nullptr;
+void (NV_GL_APIENTRY *glTexSubImage1D) ( GLenum , GLint , GLint , GLsizei , GLenum , GLenum , const GLvoid *) = nullptr;
+void (NV_GL_APIENTRY *glTexSubImage2D) ( GLenum , GLint , GLint , GLsizei , GLenum , GLenum , const GLvoid *) = nullptr;
+void (NV_GL_APIENTRY *glBindTexture) ( GLenum , GLint , GLint , GLsizei , GLenum , GLenum , const GLvoid *) = nullptr;
+void (NV_GL_APIENTRY *glDeleteTextures) ( GLsizei , const GLuint *) = nullptr;
+void (NV_GL_APIENTRY *glGenTextures) ( GLsizei , GLuint *) = nullptr;
+GLboolean (NV_GL_APIENTRY *glIsTexture) ( GLuint ) = nullptr;
+void (NV_GL_APIENTRY *glIndexub) ( GLubyte ) = nullptr;
+void (NV_GL_APIENTRY *glIndexubv) ( const GLubyte *) = nullptr;
+
+/* OpenGL 1.2 non-deprecated functions */
+void (NV_GL_APIENTRY *glBlendColor) ( GLfloat , GLfloat , GLfloat , GLfloat ) = nullptr;
+void (NV_GL_APIENTRY *glBlendEquation) ( GLenum ) = nullptr;
+void (NV_GL_APIENTRY *glDrawRangeElements) ( GLenum , GLuint , GLuint , GLsizei , GLenum , const GLvoid *) = nullptr;
+void (NV_GL_APIENTRY *glTexSubImage3D) ( GLenum , GLint , GLint , GLint , GLint , GLsizei , GLsizei , GLsizei , GLenum , GLenum , const GLvoid *) = nullptr;
+void (NV_GL_APIENTRY *glCopyTexSubImage3D) ( GLenum , GLint , GLint , GLint , GLint , GLint , GLint , GLsizei , GLsizei ) = nullptr;
+
+/* OpenGL 1.3 non-deprecated functions */
+void (NV_GL_APIENTRY *glActiveTexture) ( GLenum ) = nullptr;
+void (NV_GL_APIENTRY *glSampleCoverage) ( GLfloat , GLboolean ) = nullptr;
+void (NV_GL_APIENTRY *glCompressedTexImage3D) ( GLenum , GLint , GLenum , GLsizei , GLsizei , GLsizei , GLint , GLsizei , const GLvoid *) = nullptr;
+void (NV_GL_APIENTRY *glCompressedTexImage2D) ( GLenum , GLint , GLenum , GLsizei , GLsizei , GLint , GLsizei , const GLvoid *) = nullptr;
+void (NV_GL_APIENTRY *glCompressedTexImage1D) ( GLenum , GLint , GLenum , GLsizei , GLint , GLsizei , const GLvoid *) = nullptr;
+void (NV_GL_APIENTRY *glCompressedTexSubImage3D) ( GLenum , GLint , GLint , GLint , GLint , GLsizei , GLsizei , GLsizei , GLenum , GLsizei , const GLvoid *) = nullptr;
+void (NV_GL_APIENTRY *glCompressedTexSubImage2D) ( GLenum , GLint , GLint , GLint , GLsizei , GLsizei , GLenum , GLsizei , const GLvoid *) = nullptr;
+void (NV_GL_APIENTRY *glCompressedTexSubImage1D) ( GLenum , GLint , GLint , GLsizei , GLenum , GLsizei , const GLvoid *) = nullptr;
+void (NV_GL_APIENTRY *glGetCompressedTexImage) ( GLenum , GLint , GLvoid *) = nullptr;
+
+/* OpenGL 1.4 non-deprecated functions */
+void (NV_GL_APIENTRY *glBlendFuncSeparate) ( GLenum , GLenum , GLenum , GLenum ) = nullptr;
+void (NV_GL_APIENTRY *glMultiDrawArrays) ( GLenum , const GLint *, const GLsizei *, GLsizei ) = nullptr;
+void (NV_GL_APIENTRY *glMultiDrawElements) ( GLenum , const GLsizei *, GLenum , const GLvoid* const *, GLsizei ) = nullptr;
+void (NV_GL_APIENTRY *glPointParameterf) ( GLenum , GLfloat ) = nullptr;
+void (NV_GL_APIENTRY *glPointParameterfv) ( GLenum , const GLfloat *) = nullptr;
+void (NV_GL_APIENTRY *glPointParameteri) ( GLenum , GLint ) = nullptr;
+void (NV_GL_APIENTRY *glPointParameteriv) ( GLenum , const GLint *) = nullptr;
+
+/* OpenGL 1.5 non-deprecated functions */
+void (NV_GL_APIENTRY *glGenQueries) ( GLsizei , GLuint *) = nullptr;
+void (NV_GL_APIENTRY *glDeleteQueries) ( GLsizei , const GLuint *) = nullptr;
+GLboolean (NV_GL_APIENTRY *glIsQuery) ( GLuint ) = nullptr;
+void (NV_GL_APIENTRY *glBeginQuery) ( GLenum , GLuint ) = nullptr;
+void (NV_GL_APIENTRY *glEndQuery) ( GLenum ) = nullptr;
+void (NV_GL_APIENTRY *glGetQueryiv) ( GLenum , GLenum , GLint *) = nullptr;
+void (NV_GL_APIENTRY *glGetQueryObjectiv) ( GLuint , GLenum , GLint *) = nullptr;
+void (NV_GL_APIENTRY *glGetQueryObjectuiv) ( GLuint , GLenum , GLuint *) = nullptr;
+void (NV_GL_APIENTRY *glBindBuffer) ( GLenum , GLuint ) = nullptr;
+void (NV_GL_APIENTRY *glDeleteBuffers) ( GLsizei , const GLuint *) = nullptr;
+void (NV_GL_APIENTRY *glGenBuffers) ( GLsizei , GLuint *) = nullptr;
+GLboolean (NV_GL_APIENTRY *glIsBuffer) ( GLuint ) = nullptr;
+void (NV_GL_APIENTRY *glBufferData) ( GLenum , GLsizeiptr , const GLvoid *, GLenum ) = nullptr;
+void (NV_GL_APIENTRY *glBufferSubData) ( GLenum , GLintptr , GLsizeiptr , const GLvoid *) = nullptr;
+void (NV_GL_APIENTRY *glGetBufferSubData) ( GLenum , GLintptr , GLsizeiptr , GLvoid *) = nullptr;
+GLvoid* (NV_GL_APIENTRY *glMapBuffer) ( GLenum , GLenum ) = nullptr;
+GLboolean (NV_GL_APIENTRY *glUnmapBuffer) ( GLenum ) = nullptr;
+void (NV_GL_APIENTRY *glGetBufferParameteriv) ( GLenum , GLenum , GLint *) = nullptr;
+void (NV_GL_APIENTRY *glGetBufferPointerv) ( GLenum , GLenum , GLvoid* *) = nullptr;
+
+/* OpenGL 2.0 non-deprecated functions */
+void (NV_GL_APIENTRY *glBlendEquationSeparate) ( GLenum , GLenum ) = nullptr;
+void (NV_GL_APIENTRY *glDrawBuffers) ( GLsizei , const GLenum *) = nullptr;
+void (NV_GL_APIENTRY *glStencilOpSeparate) ( GLenum , GLenum , GLenum , GLenum ) = nullptr;
+void (NV_GL_APIENTRY *glStencilFuncSeparate) ( GLenum , GLenum , GLint , GLuint ) = nullptr;
+void (NV_GL_APIENTRY *glStencilMaskSeparate) ( GLenum , GLuint ) = nullptr;
+void (NV_GL_APIENTRY *glAttachShader) ( GLuint , GLuint ) = nullptr;
+void (NV_GL_APIENTRY *glBindAttribLocation) ( GLuint , GLuint , const GLchar *) = nullptr;
+void (NV_GL_APIENTRY *glCompileShader) ( GLuint ) = nullptr;
+GLuint (NV_GL_APIENTRY *glCreateProgram) ( void ) = nullptr;
+GLuint (NV_GL_APIENTRY *glCreateShader) ( GLenum ) = nullptr;
+void (NV_GL_APIENTRY *glDeleteProgram) ( GLuint ) = nullptr;
+void (NV_GL_APIENTRY *glDeleteShader) ( GLuint ) = nullptr;
+void (NV_GL_APIENTRY *glDetachShader) ( GLuint, GLuint ) = nullptr;
+void (NV_GL_APIENTRY *glDisableVertexAttribArray) ( GLuint ) = nullptr;
+void (NV_GL_APIENTRY *glEnableVertexAttribArray) ( GLuint ) = nullptr;
+void (NV_GL_APIENTRY *glGetActiveAttrib) ( GLuint , GLuint , GLsizei , GLsizei *, GLint *, GLenum *, GLchar *) = nullptr;
+void (NV_GL_APIENTRY *glGetActiveUniform) ( GLuint , GLuint , GLsizei , GLsizei *, GLint *, GLenum *, GLchar *) = nullptr;
+void (NV_GL_APIENTRY *glGetAttachedShaders) ( GLuint , GLsizei , GLsizei *, GLuint *) = nullptr;
+GLint (NV_GL_APIENTRY *glGetAttribLocation) ( GLuint , const GLchar *) = nullptr;
+void (NV_GL_APIENTRY *glGetProgramiv) ( GLuint , GLenum , GLint *) = nullptr;
+void (NV_GL_APIENTRY *glGetProgramInfoLog) ( GLuint , GLsizei , GLsizei *, GLchar *) = nullptr;
+void (NV_GL_APIENTRY *glGetShaderiv) ( GLuint , GLenum , GLint *) = nullptr;
+void (NV_GL_APIENTRY *glGetShaderInfoLog) ( GLuint , GLsizei , GLsizei *, GLchar *) = nullptr;
+void (NV_GL_APIENTRY *glGetShaderSource) ( GLuint , GLsizei , GLsizei *, GLchar *) = nullptr;
+GLint (NV_GL_APIENTRY *glGetUniformLocation) ( GLuint , const GLchar *) = nullptr;
+void (NV_GL_APIENTRY *glGetUniformfv) ( GLuint , GLint , GLfloat *) = nullptr;
+void (NV_GL_APIENTRY *glGetUniformiv) ( GLuint , GLint , GLint *) = nullptr;
+void (NV_GL_APIENTRY *glGetVertexAttribdv) ( GLuint , GLenum , GLdouble *) = nullptr;
+void (NV_GL_APIENTRY *glGetVertexAttribfv) ( GLuint , GLenum , GLfloat *) = nullptr;
+void (NV_GL_APIENTRY *glGetVertexAttribiv) ( GLuint , GLenum , GLint *) = nullptr;
+void (NV_GL_APIENTRY *glGetVertexAttribPointerv) ( GLuint , GLenum , GLvoid* *) = nullptr;
+GLboolean (NV_GL_APIENTRY *glIsProgram) ( GLuint ) = nullptr;
+GLboolean (NV_GL_APIENTRY *glIsShader) ( GLuint ) = nullptr;
+void (NV_GL_APIENTRY *glLinkProgram) ( GLuint ) = nullptr;
+void (NV_GL_APIENTRY *glShaderSource) ( GLuint , GLsizei , const GLchar* const *, const GLint *) = nullptr;
+void (NV_GL_APIENTRY *glUseProgram) ( GLuint ) = nullptr;
+void (NV_GL_APIENTRY *glUniform1f) ( GLint , GLfloat ) = nullptr;
+void (NV_GL_APIENTRY *glUniform2f) ( GLint , GLfloat , GLfloat ) = nullptr;
+void (NV_GL_APIENTRY *glUniform3f) ( GLint , GLfloat , GLfloat , GLfloat ) = nullptr;
+void (NV_GL_APIENTRY *glUniform4f) ( GLint , GLfloat , GLfloat , GLfloat , GLfloat ) = nullptr;
+void (NV_GL_APIENTRY *glUniform1i) ( GLint , GLint ) = nullptr;
+void (NV_GL_APIENTRY *glUniform2i) ( GLint , GLint , GLint ) = nullptr;
+void (NV_GL_APIENTRY *glUniform3i) ( GLint , GLint , GLint , GLint ) = nullptr;
+void (NV_GL_APIENTRY *glUniform4i) ( GLint , GLint , GLint , GLint , GLint ) = nullptr;
+void (NV_GL_APIENTRY *glUniform1fv) ( GLint , GLsizei , const GLfloat *) = nullptr;
+void (NV_GL_APIENTRY *glUniform2fv) ( GLint , GLsizei , const GLfloat *) = nullptr;
+void (NV_GL_APIENTRY *glUniform3fv) ( GLint , GLsizei , const GLfloat *) = nullptr;
+void (NV_GL_APIENTRY *glUniform4fv) ( GLint , GLsizei , const GLfloat *) = nullptr;
+void (NV_GL_APIENTRY *glUniform1iv) ( GLint , GLsizei , const GLint *) = nullptr;
+void (NV_GL_APIENTRY *glUniform2iv) ( GLint , GLsizei , const GLint *) = nullptr;
+void (NV_GL_APIENTRY *glUniform3iv) ( GLint , GLsizei , const GLint *) = nullptr;
+void (NV_GL_APIENTRY *glUniform4iv) ( GLint , GLsizei , const GLint *) = nullptr;
+void (NV_GL_APIENTRY *glUniformMatrix2fv) ( GLint , GLsizei , GLboolean , const GLfloat *) = nullptr;
+void (NV_GL_APIENTRY *glUniformMatrix3fv) ( GLint , GLsizei , GLboolean , const GLfloat *) = nullptr;
+void (NV_GL_APIENTRY *glUniformMatrix4fv) ( GLint , GLsizei , GLboolean , const GLfloat *) = nullptr;
+void (NV_GL_APIENTRY *glValidateProgram) ( GLuint ) = nullptr;
+void (NV_GL_APIENTRY *glVertexAttribPointer) ( GLuint , GLint , GLenum , GLboolean , GLsizei , const GLvoid *) = nullptr;
+
+/* OpenGL 2.1 non-deprecated functions */
+void (NV_GL_APIENTRY *glUniformMatrix2x3fv) ( GLint , GLsizei , GLboolean , const GLfloat *) = nullptr;
+void (NV_GL_APIENTRY *glUniformMatrix3x2fv) ( GLint , GLsizei , GLboolean , const GLfloat *) = nullptr;
+void (NV_GL_APIENTRY *glUniformMatrix2x4fv) ( GLint , GLsizei , GLboolean , const GLfloat *) = nullptr;
+void (NV_GL_APIENTRY *glUniformMatrix4x2fv) ( GLint , GLsizei , GLboolean , const GLfloat *) = nullptr;
+void (NV_GL_APIENTRY *glUniformMatrix3x4fv) ( GLint , GLsizei , GLboolean , const GLfloat *) = nullptr;
+void (NV_GL_APIENTRY *glUniformMatrix4x3fv) ( GLint , GLsizei , GLboolean , const GLfloat *) = nullptr;
+
+bool nv::load_gl_library( const char* path )
+{
+#if defined( NV_SDL_GL )
+#		define NV_GL_LOAD( symbol ) *(void **) (&symbol) = SDL_GL_GetProcAddress(#symbol);
+#		define NV_GL_LOAD_EXT( symbol ) *(void **) (&symbol) = SDL_GL_GetProcAddress(#symbol);
+#else
+	static nv::library gl_library( path );
+	void * (NV_GL_APIENTRY *ext_loader) (const char* proc) = nullptr;
+#	if NV_PLATFORM == NV_WINDOWS 
+#		define NV_GL_LOAD( symbol ) *(void **) (&symbol) = gl_library.get(#symbol);
+		*(void **) (&ext_loader) = gl_library.get("wglGetProcAddress");
+#		define NV_GL_LOAD_EXT( symbol ) *(void **) (&symbol) = ext_loader(#symbol);
+#	elif NV_PLATFORM == NV_LINUX
+#		define NV_GL_LOAD( symbol ) *(void **) (&symbol) = gl_library.get(#symbol);
+		*(void **) (&ext_loader) = gl_library.get("glXGetProcAddress");
+#		define NV_GL_LOAD_EXT( symbol ) *(void **) (&symbol) = ext_loader(#symbol);
+#	else
+#		define NV_GL_LOAD( symbol ) *(void **) (&symbol) = gl_library.get(#symbol);
+#		define NV_GL_LOAD_EXT( symbol ) *(void **) (&symbol) = gl_library.get(#symbol);
+#	endif
+#endif
+
+/* OpenGL 1.1 non-deprecated functions */
+	NV_GL_LOAD( glCullFace );
+	NV_GL_LOAD( glFrontFace );
+	NV_GL_LOAD( glHint );
+	NV_GL_LOAD( glLineWidth );
+	NV_GL_LOAD( glPointSize );
+	NV_GL_LOAD( glPolygonMode );
+	NV_GL_LOAD( glScissor );
+	NV_GL_LOAD( glTexParameterf );
+	NV_GL_LOAD( glTexParameterfv );
+	NV_GL_LOAD( glTexParameteri );
+	NV_GL_LOAD( glTexParameteriv );
+	NV_GL_LOAD( glTexImage1D );
+	NV_GL_LOAD( glTexImage2D );
+	NV_GL_LOAD( glDrawBuffer );
+	NV_GL_LOAD( glClear );
+	NV_GL_LOAD( glClearColor );
+	NV_GL_LOAD( glClearStencil );
+	NV_GL_LOAD( glClearDepth );
+	NV_GL_LOAD( glStencilMask );
+	NV_GL_LOAD( glColorMask );
+	NV_GL_LOAD( glDepthMask );
+	NV_GL_LOAD( glDisable );
+	NV_GL_LOAD( glEnable );
+	NV_GL_LOAD( glFinish );
+	NV_GL_LOAD( glFlush );
+	NV_GL_LOAD( glBlendFunc );
+	NV_GL_LOAD( glLogicOp );
+	NV_GL_LOAD( glStencilFunc );
+	NV_GL_LOAD( glStencilOp );
+	NV_GL_LOAD( glDepthFunc );
+	NV_GL_LOAD( glPixelStoref );
+	NV_GL_LOAD( glPixelStorei );
+	NV_GL_LOAD( glReadBuffer );
+	NV_GL_LOAD( glReadPixels );
+	NV_GL_LOAD( glGetBooleanv );
+	NV_GL_LOAD( glGetDoublev );
+	NV_GL_LOAD( glGetError );
+	NV_GL_LOAD( glGetFloatv );
+	NV_GL_LOAD( glGetIntegerv );
+	NV_GL_LOAD( glGetString );
+	NV_GL_LOAD( glGetTexImage );
+	NV_GL_LOAD( glGetTexParameterfv );
+	NV_GL_LOAD( glGetTexParameteriv );
+	NV_GL_LOAD( glGetTexLevelParameterfv );
+	NV_GL_LOAD( glGetTexLevelParameteriv );
+	NV_GL_LOAD( glIsEnabled );
+	NV_GL_LOAD( glDepthRange );
+	NV_GL_LOAD( glViewport );
+	NV_GL_LOAD( glDrawArrays );
+	NV_GL_LOAD( glDrawElements );
+	NV_GL_LOAD( glGetPointerv );
+	NV_GL_LOAD( glPolygonOffset );
+	NV_GL_LOAD( glCopyTexImage1D );
+	NV_GL_LOAD( glCopyTexImage2D );
+	NV_GL_LOAD( glCopyTexSubImage1D );
+	NV_GL_LOAD( glCopyTexSubImage2D );
+	NV_GL_LOAD( glTexSubImage1D );
+	NV_GL_LOAD( glTexSubImage2D );
+	NV_GL_LOAD( glBindTexture );
+	NV_GL_LOAD( glDeleteTextures );
+	NV_GL_LOAD( glGenTextures );
+	NV_GL_LOAD( glIsTexture );
+	NV_GL_LOAD( glIndexub );
+	NV_GL_LOAD( glIndexubv );
+
+/* OpenGL 1.2 non-deprecated functions */
+	NV_GL_LOAD_EXT( glBlendColor );
+	NV_GL_LOAD_EXT( glBlendEquation );
+	NV_GL_LOAD_EXT( glDrawRangeElements );
+	NV_GL_LOAD_EXT( glTexSubImage3D );
+	NV_GL_LOAD_EXT( glCopyTexSubImage3D );
+
+/* OpenGL 1.3 non-deprecated functions */
+	NV_GL_LOAD_EXT( glActiveTexture );
+	NV_GL_LOAD_EXT( glSampleCoverage );
+	NV_GL_LOAD_EXT( glCompressedTexImage3D );
+	NV_GL_LOAD_EXT( glCompressedTexImage2D );
+	NV_GL_LOAD_EXT( glCompressedTexImage1D );
+	NV_GL_LOAD_EXT( glCompressedTexSubImage3D );
+	NV_GL_LOAD_EXT( glCompressedTexSubImage2D );
+	NV_GL_LOAD_EXT( glCompressedTexSubImage1D );
+	NV_GL_LOAD_EXT( glGetCompressedTexImage );
+
+/* OpenGL 1.4 non-deprecated functions */
+	NV_GL_LOAD_EXT( glBlendFuncSeparate );
+	NV_GL_LOAD_EXT( glMultiDrawArrays );
+	NV_GL_LOAD_EXT( glMultiDrawElements );
+	NV_GL_LOAD_EXT( glPointParameterf );
+	NV_GL_LOAD_EXT( glPointParameterfv );
+	NV_GL_LOAD_EXT( glPointParameteri );
+	NV_GL_LOAD_EXT( glPointParameteriv );
+
+/* OpenGL 1.5 non-deprecated functions */
+	NV_GL_LOAD_EXT( glGenQueries );
+	NV_GL_LOAD_EXT( glDeleteQueries );
+	NV_GL_LOAD_EXT( glIsQuery );
+	NV_GL_LOAD_EXT( glBeginQuery );
+	NV_GL_LOAD_EXT( glEndQuery );
+	NV_GL_LOAD_EXT( glGetQueryiv );
+	NV_GL_LOAD_EXT( glGetQueryObjectiv );
+	NV_GL_LOAD_EXT( glGetQueryObjectuiv );
+	NV_GL_LOAD_EXT( glBindBuffer );
+	NV_GL_LOAD_EXT( glDeleteBuffers );
+	NV_GL_LOAD_EXT( glGenBuffers );
+	NV_GL_LOAD_EXT( glIsBuffer );
+	NV_GL_LOAD_EXT( glBufferData );
+	NV_GL_LOAD_EXT( glBufferSubData );
+	NV_GL_LOAD_EXT( glGetBufferSubData );
+	NV_GL_LOAD_EXT( glMapBuffer );
+	NV_GL_LOAD_EXT( glUnmapBuffer );
+	NV_GL_LOAD_EXT( glGetBufferParameteriv );
+	NV_GL_LOAD_EXT( glGetBufferPointerv );
+
+/* OpenGL 2.0 non-deprecated functions */
+	NV_GL_LOAD_EXT( glBlendEquationSeparate );
+	NV_GL_LOAD_EXT( glDrawBuffers );
+	NV_GL_LOAD_EXT( glStencilOpSeparate );
+	NV_GL_LOAD_EXT( glStencilFuncSeparate );
+	NV_GL_LOAD_EXT( glStencilMaskSeparate );
+	NV_GL_LOAD_EXT( glAttachShader );
+	NV_GL_LOAD_EXT( glBindAttribLocation );
+	NV_GL_LOAD_EXT( glCompileShader );
+	NV_GL_LOAD_EXT( glCreateProgram );
+	NV_GL_LOAD_EXT( glCreateShader );
+	NV_GL_LOAD_EXT( glDeleteProgram );
+	NV_GL_LOAD_EXT( glDeleteShader );
+	NV_GL_LOAD_EXT( glDetachShader );
+	NV_GL_LOAD_EXT( glDisableVertexAttribArray );
+	NV_GL_LOAD_EXT( glEnableVertexAttribArray );
+	NV_GL_LOAD_EXT( glGetActiveAttrib );
+	NV_GL_LOAD_EXT( glGetActiveUniform );
+	NV_GL_LOAD_EXT( glGetAttachedShaders );
+	NV_GL_LOAD_EXT( glGetAttribLocation );
+	NV_GL_LOAD_EXT( glGetProgramiv );
+	NV_GL_LOAD_EXT( glGetProgramInfoLog );
+	NV_GL_LOAD_EXT( glGetShaderiv );
+	NV_GL_LOAD_EXT( glGetShaderInfoLog );
+	NV_GL_LOAD_EXT( glGetShaderSource );
+	NV_GL_LOAD_EXT( glGetUniformLocation );
+	NV_GL_LOAD_EXT( glGetUniformfv );
+	NV_GL_LOAD_EXT( glGetUniformiv );
+	NV_GL_LOAD_EXT( glGetVertexAttribdv );
+	NV_GL_LOAD_EXT( glGetVertexAttribfv );
+	NV_GL_LOAD_EXT( glGetVertexAttribiv );
+	NV_GL_LOAD_EXT( glGetVertexAttribPointerv );
+	NV_GL_LOAD_EXT( glIsProgram );
+	NV_GL_LOAD_EXT( glIsShader );
+	NV_GL_LOAD_EXT( glLinkProgram );
+	NV_GL_LOAD_EXT( glShaderSource );
+	NV_GL_LOAD_EXT( glUseProgram );
+	NV_GL_LOAD_EXT( glUniform1f );
+	NV_GL_LOAD_EXT( glUniform2f );
+	NV_GL_LOAD_EXT( glUniform3f );
+	NV_GL_LOAD_EXT( glUniform4f );
+	NV_GL_LOAD_EXT( glUniform1i );
+	NV_GL_LOAD_EXT( glUniform2i );
+	NV_GL_LOAD_EXT( glUniform3i );
+	NV_GL_LOAD_EXT( glUniform4i );
+	NV_GL_LOAD_EXT( glUniform1fv );
+	NV_GL_LOAD_EXT( glUniform2fv );
+	NV_GL_LOAD_EXT( glUniform3fv );
+	NV_GL_LOAD_EXT( glUniform4fv );
+	NV_GL_LOAD_EXT( glUniform1iv );
+	NV_GL_LOAD_EXT( glUniform2iv );
+	NV_GL_LOAD_EXT( glUniform3iv );
+	NV_GL_LOAD_EXT( glUniform4iv );
+	NV_GL_LOAD_EXT( glUniformMatrix2fv );
+	NV_GL_LOAD_EXT( glUniformMatrix3fv );
+	NV_GL_LOAD_EXT( glUniformMatrix4fv );
+	NV_GL_LOAD_EXT( glValidateProgram );
+	NV_GL_LOAD_EXT( glVertexAttribPointer );
+
+/* OpenGL 2.1 non-deprecated functions */
+	NV_GL_LOAD_EXT( glUniformMatrix2x3fv );
+	NV_GL_LOAD_EXT( glUniformMatrix3x2fv );
+	NV_GL_LOAD_EXT( glUniformMatrix2x4fv );
+	NV_GL_LOAD_EXT( glUniformMatrix4x2fv );
+	NV_GL_LOAD_EXT( glUniformMatrix3x4fv );
+	NV_GL_LOAD_EXT( glUniformMatrix4x3fv );
+
+#	undef NV_GL_LOAD
+#	undef NV_GL_LOAD_EXT
+	return true;
+}
+
+#endif
Index: trunk/src/lib/lua.cc
===================================================================
--- trunk/src/lib/lua.cc	(revision 5)
+++ trunk/src/lib/lua.cc	(revision 5)
@@ -0,0 +1,362 @@
+// Copyright (C) 2012-2013 ChaosForge / Kornel Kisielewicz
+// http://chaosforge.org/
+//
+// This file is part of NV Libraries.
+// For conditions of distribution and use, see copyright notice in nv.hh
+
+#include "nv/lib/lua.hh"
+
+#if defined( NV_LUA_DYNAMIC )
+
+#include "nv/library.hh"
+
+/* State manipulation */
+lua_State *        (*lua_newstate) (lua_Alloc f, void *ud) = nullptr;
+void               (*lua_close) (lua_State *L) = nullptr;
+lua_State *        (*lua_newthread) (lua_State *L) = nullptr;
+lua_CFunction      (*lua_atpanic) (lua_State *L, lua_CFunction panicf) = nullptr;
+const lua_Number * (*lua_version) (lua_State *L) = nullptr;
+
+/* Basic stack manipulation */
+int   (*lua_absindex) (lua_State *L, int idx) = nullptr;
+int   (*lua_gettop) (lua_State *L) = nullptr;
+void  (*lua_settop) (lua_State *L, int idx) = nullptr;
+void  (*lua_pushvalue) (lua_State *L, int idx) = nullptr;
+void  (*lua_remove) (lua_State *L, int idx) = nullptr;
+void  (*lua_insert) (lua_State *L, int idx) = nullptr;
+void  (*lua_replace) (lua_State *L, int idx) = nullptr;
+void  (*lua_copy) (lua_State *L, int fromidx, int toidx) = nullptr;
+int   (*lua_checkstack) (lua_State *L, int sz) = nullptr;
+void  (*lua_xmove) (lua_State *from, lua_State *to, int n) = nullptr;
+
+/* Access functions (stack -> C) */
+int             (*lua_isnumber) (lua_State *L, int idx) = nullptr;
+int             (*lua_isstring) (lua_State *L, int idx) = nullptr;
+int             (*lua_iscfunction) (lua_State *L, int idx) = nullptr;
+int             (*lua_isuserdata) (lua_State *L, int idx) = nullptr;
+int             (*lua_type) (lua_State *L, int idx) = nullptr;
+const char*     (*lua_typename) (lua_State *L, int tp) = nullptr;
+
+lua_Number      (*lua_tonumberx) (lua_State *L, int idx, int *isnum) = nullptr;
+lua_Integer     (*lua_tointegerx) (lua_State *L, int idx, int *isnum) = nullptr;
+lua_Unsigned    (*lua_tounsignedx) (lua_State *L, int idx, int *isnum) = nullptr;
+int             (*lua_toboolean) (lua_State *L, int idx) = nullptr;
+const char*     (*lua_tolstring) (lua_State *L, int idx, size_t *len) = nullptr;
+size_t          (*lua_rawlen) (lua_State *L, int idx) = nullptr;
+lua_CFunction   (*lua_tocfunction) (lua_State *L, int idx) = nullptr;
+void*           (*lua_touserdata) (lua_State *L, int idx) = nullptr;
+lua_State*      (*lua_tothread) (lua_State *L, int idx) = nullptr;
+const void*     (*lua_topointer) (lua_State *L, int idx) = nullptr;
+
+/* Comparison and arithmetic functions */
+void  (*lua_arith) (lua_State *L, int op) = nullptr;
+int   (*lua_rawequal) (lua_State *L, int idx1, int idx2) = nullptr;
+int   (*lua_compare) (lua_State *L, int idx1, int idx2, int op) = nullptr;
+
+/* Push functions (C -> stack) */
+void         (*lua_pushnil) (lua_State *L) = nullptr;
+void         (*lua_pushnumber) (lua_State *L, lua_Number n) = nullptr;
+void         (*lua_pushinteger) (lua_State *L, lua_Integer n) = nullptr;
+void         (*lua_pushunsigned) (lua_State *L, lua_Unsigned n) = nullptr;
+const char*  (*lua_pushlstring) (lua_State *L, const char *s, size_t l) = nullptr;
+const char*  (*lua_pushstring) (lua_State *L, const char *s) = nullptr;
+const char*  (*lua_pushvfstring) (lua_State *L, const char *fmt,
+                                                      va_list argp) = nullptr;
+const char * (*lua_pushfstring) (lua_State *L, const char *fmt, ...) = nullptr;
+void  (*lua_pushcclosure) (lua_State *L, lua_CFunction fn, int n) = nullptr;
+void  (*lua_pushboolean) (lua_State *L, int b) = nullptr;
+void  (*lua_pushlightuserdata) (lua_State *L, void *p) = nullptr;
+int   (*lua_pushthread) (lua_State *L) = nullptr;
+
+/* Get functions (Lua -> stack) */
+void  (*lua_getglobal) (lua_State *L, const char *var) = nullptr;
+void  (*lua_gettable) (lua_State *L, int idx) = nullptr;
+void  (*lua_getfield) (lua_State *L, int idx, const char *k) = nullptr;
+void  (*lua_rawget) (lua_State *L, int idx) = nullptr;
+void  (*lua_rawgeti) (lua_State *L, int idx, int n) = nullptr;
+void  (*lua_rawgetp) (lua_State *L, int idx, const void *p) = nullptr;
+void  (*lua_createtable) (lua_State *L, int narr, int nrec) = nullptr;
+void* (*lua_newuserdata) (lua_State *L, size_t sz) = nullptr;
+int   (*lua_getmetatable) (lua_State *L, int objindex) = nullptr;
+void  (*lua_getuservalue) (lua_State *L, int idx) = nullptr;
+
+/* Set functions (stack -> Lua) */
+void  (*lua_setglobal) (lua_State *L, const char *var) = nullptr;
+void  (*lua_settable) (lua_State *L, int idx) = nullptr;
+void  (*lua_setfield) (lua_State *L, int idx, const char *k) = nullptr;
+void  (*lua_rawset) (lua_State *L, int idx) = nullptr;
+void  (*lua_rawseti) (lua_State *L, int idx, int n) = nullptr;
+void  (*lua_rawsetp) (lua_State *L, int idx, const void *p) = nullptr;
+int   (*lua_setmetatable) (lua_State *L, int objindex) = nullptr;
+void  (*lua_setuservalue) (lua_State *L, int idx) = nullptr;
+
+/* 'load' and 'call' functions (load and run Lua code) */
+void  (*lua_callk) (lua_State *L, int nargs, int nresults, int ctx, lua_CFunction k) = nullptr;
+int   (*lua_getctx) (lua_State *L, int *ctx) = nullptr;
+int   (*lua_pcallk) (lua_State *L, int nargs, int nresults, int errfunc, int ctx, lua_CFunction k) = nullptr;
+int   (*lua_load) (lua_State *L, lua_Reader reader, void *dt, const char *chunkname, const char *mode) = nullptr;
+int   (*lua_dump) (lua_State *L, lua_Writer writer, void *data) = nullptr;
+
+/* Coroutine functions */
+int  (*lua_yieldk) (lua_State *L, int nresults, int ctx, lua_CFunction k) = nullptr;
+int  (*lua_resume) (lua_State *L, lua_State *from, int narg) = nullptr;
+int  (*lua_status) (lua_State *L) = nullptr;
+
+/* Garbage-collection function and options */
+int (*lua_gc) (lua_State *L, int what, int data) = nullptr;
+
+/* Miscellaneous functions */
+int   (*lua_error) (lua_State *L) = nullptr;
+int   (*lua_next) (lua_State *L, int idx) = nullptr;
+void  (*lua_concat) (lua_State *L, int n) = nullptr;
+void  (*lua_len)    (lua_State *L, int idx) = nullptr;
+lua_Alloc (*lua_getallocf) (lua_State *L, void **ud) = nullptr;
+void      (*lua_setallocf) (lua_State *L, lua_Alloc f, void *ud) = nullptr;
+
+/* Debug API */
+int (*lua_getstack) (lua_State *L, int level, lua_Debug *ar) = nullptr;
+int (*lua_getinfo) (lua_State *L, const char *what, lua_Debug *ar) = nullptr;
+const char * (*lua_getlocal) (lua_State *L, const lua_Debug *ar, int n) = nullptr;
+const char * (*lua_setlocal) (lua_State *L, const lua_Debug *ar, int n) = nullptr;
+const char * (*lua_getupvalue) (lua_State *L, int funcindex, int n) = nullptr;
+const char * (*lua_setupvalue) (lua_State *L, int funcindex, int n) = nullptr;
+void * (*lua_upvalueid) (lua_State *L, int fidx, int n) = nullptr;
+void   (*lua_upvaluejoin) (lua_State *L, int fidx1, int n1, int fidx2, int n2) = nullptr;
+int (*lua_sethook) (lua_State *L, lua_Hook func, int mask, int count) = nullptr;
+lua_Hook (*lua_gethook) (lua_State *L) = nullptr;
+int (*lua_gethookmask) (lua_State *L) = nullptr;
+int (*lua_gethookcount) (lua_State *L) = nullptr;
+
+/* lualib API */
+int (*luaopen_base) (lua_State *L) = nullptr;
+int (*luaopen_coroutine) (lua_State *L) = nullptr;
+int (*luaopen_table) (lua_State *L) = nullptr;
+int (*luaopen_io) (lua_State *L) = nullptr;
+int (*luaopen_os) (lua_State *L) = nullptr;
+int (*luaopen_string) (lua_State *L) = nullptr;
+int (*luaopen_bit32) (lua_State *L) = nullptr;
+int (*luaopen_math) (lua_State *L) = nullptr;
+int (*luaopen_debug) (lua_State *L) = nullptr;
+int (*luaopen_package) (lua_State *L) = nullptr;
+int (*luaL_openlibs) (lua_State *L) = nullptr;
+
+/* lauxlib API */
+void   (*luaL_checkversion_) (lua_State *L, lua_Number ver) = nullptr;
+int  (*luaL_getmetafield) (lua_State *L, int obj, const char *e) = nullptr;
+int  (*luaL_callmeta) (lua_State *L, int obj, const char *e) = nullptr;
+const char * (*luaL_tolstring) (lua_State *L, int idx, size_t *len) = nullptr;
+int  (*luaL_argerror) (lua_State *L, int numarg, const char *extramsg) = nullptr;
+const char * (*luaL_checklstring) (lua_State *L, int numArg, size_t *l) = nullptr;
+const char * (*luaL_optlstring) (lua_State *L, int numArg, const char *def, size_t *l) = nullptr;
+lua_Number  (*luaL_checknumber) (lua_State *L, int numArg) = nullptr;
+lua_Number  (*luaL_optnumber) (lua_State *L, int nArg, lua_Number def) = nullptr;
+lua_Integer  (*luaL_checkinteger) (lua_State *L, int numArg) = nullptr;
+lua_Integer  (*luaL_optinteger) (lua_State *L, int nArg, lua_Integer def) = nullptr;
+lua_Unsigned  (*luaL_checkunsigned) (lua_State *L, int numArg) = nullptr;
+lua_Unsigned  (*luaL_optunsigned) (lua_State *L, int numArg, lua_Unsigned def) = nullptr;
+void  (*luaL_checkstack) (lua_State *L, int sz, const char *msg) = nullptr;
+void  (*luaL_checktype) (lua_State *L, int narg, int t) = nullptr;
+void  (*luaL_checkany) (lua_State *L, int narg) = nullptr;
+int    (*luaL_newmetatable) (lua_State *L, const char *tname) = nullptr;
+void   (*luaL_setmetatable) (lua_State *L, const char *tname) = nullptr;
+void * (*luaL_testudata) (lua_State *L, int ud, const char *tname) = nullptr;
+void * (*luaL_checkudata) (lua_State *L, int ud, const char *tname) = nullptr;
+void  (*luaL_where) (lua_State *L, int lvl) = nullptr;
+int  (*luaL_error) (lua_State *L, const char *fmt, ...) = nullptr;
+int  (*luaL_checkoption) (lua_State *L, int narg, const char *def, const char *const lst[]) = nullptr;
+int  (*luaL_fileresult) (lua_State *L, int stat, const char *fname) = nullptr;
+int  (*luaL_execresult) (lua_State *L, int stat) = nullptr;
+
+int  (*luaL_ref) (lua_State *L, int t) = nullptr;
+void  (*luaL_unref) (lua_State *L, int t, int ref) = nullptr;
+int  (*luaL_loadfilex) (lua_State *L, const char *filename, const char *mode) = nullptr;
+int  (*luaL_loadbufferx) (lua_State *L, const char *buff, size_t sz, const char *name, const char *mode) = nullptr;
+int  (*luaL_loadstring) (lua_State *L, const char *s) = nullptr;
+lua_State * (*luaL_newstate)  (void) = nullptr;
+int  (*luaL_len) (lua_State *L, int idx) = nullptr;
+const char * (*luaL_gsub) (lua_State *L, const char *s, const char *p, const char *r) = nullptr;
+void  (*luaL_setfuncs) (lua_State *L, const luaL_Reg *l, int nup) = nullptr;
+int  (*luaL_getsubtable) (lua_State *L, int idx, const char *fname) = nullptr;
+void  (*luaL_traceback) (lua_State *L, lua_State *L1, const char *msg, int level) = nullptr;
+void  (*luaL_requiref) (lua_State *L, const char *modname, lua_CFunction openf, int glb) = nullptr;
+
+bool nv::load_lua_library( const char* path )
+{
+#	define NV_LUA_LOAD( symbol ) *(void **) (&symbol) = lua_library.get(#symbol);
+
+	static nv::library lua_library( path );
+
+/* State manipulation */
+	NV_LUA_LOAD(lua_newstate);
+	NV_LUA_LOAD(lua_close);
+	NV_LUA_LOAD(lua_newthread);
+	NV_LUA_LOAD(lua_atpanic);
+	NV_LUA_LOAD(lua_version);
+
+/* Basic stack manipulation */
+	NV_LUA_LOAD(lua_absindex);
+	NV_LUA_LOAD(lua_gettop);
+	NV_LUA_LOAD(lua_settop);
+	NV_LUA_LOAD(lua_pushvalue);
+	NV_LUA_LOAD(lua_remove);
+	NV_LUA_LOAD(lua_insert);
+	NV_LUA_LOAD(lua_replace);
+	NV_LUA_LOAD(lua_copy);
+	NV_LUA_LOAD(lua_checkstack);
+	NV_LUA_LOAD(lua_xmove);
+
+/* Access functions (stack -> C) */
+	NV_LUA_LOAD(lua_isnumber);
+	NV_LUA_LOAD(lua_isstring);
+	NV_LUA_LOAD(lua_iscfunction);
+	NV_LUA_LOAD(lua_isuserdata);
+	NV_LUA_LOAD(lua_type);
+	NV_LUA_LOAD(lua_typename);
+
+	NV_LUA_LOAD(lua_tonumberx);
+	NV_LUA_LOAD(lua_tointegerx);
+	NV_LUA_LOAD(lua_tounsignedx);
+	NV_LUA_LOAD(lua_toboolean);
+	NV_LUA_LOAD(lua_tolstring);
+	NV_LUA_LOAD(lua_rawlen);
+	NV_LUA_LOAD(lua_tocfunction);
+	NV_LUA_LOAD(lua_touserdata);
+	NV_LUA_LOAD(lua_tothread);
+	NV_LUA_LOAD(lua_topointer);
+
+/* Comparison and arithmetic functions */
+	NV_LUA_LOAD(lua_arith);
+	NV_LUA_LOAD(lua_rawequal);
+	NV_LUA_LOAD(lua_compare);
+
+/* Push functions (C -> stack) */
+	NV_LUA_LOAD(lua_pushnil);
+	NV_LUA_LOAD(lua_pushnumber);
+	NV_LUA_LOAD(lua_pushinteger);
+	NV_LUA_LOAD(lua_pushunsigned);
+	NV_LUA_LOAD(lua_pushlstring);
+	NV_LUA_LOAD(lua_pushstring);
+	NV_LUA_LOAD(lua_pushvfstring);
+	NV_LUA_LOAD(lua_pushfstring);
+	NV_LUA_LOAD(lua_pushcclosure);
+	NV_LUA_LOAD(lua_pushboolean);
+	NV_LUA_LOAD(lua_pushlightuserdata);
+	NV_LUA_LOAD(lua_pushthread);
+
+/* Get functions (Lua -> stack) */
+	NV_LUA_LOAD(lua_getglobal);
+	NV_LUA_LOAD(lua_gettable);
+	NV_LUA_LOAD(lua_getfield);
+	NV_LUA_LOAD(lua_rawget);
+	NV_LUA_LOAD(lua_rawgeti);
+	NV_LUA_LOAD(lua_rawgetp);
+	NV_LUA_LOAD(lua_createtable);
+	NV_LUA_LOAD(lua_newuserdata);
+	NV_LUA_LOAD(lua_getmetatable);
+	NV_LUA_LOAD(lua_getuservalue);
+
+/* Set functions (stack -> Lua) */
+	NV_LUA_LOAD(lua_setglobal);
+	NV_LUA_LOAD(lua_settable);
+	NV_LUA_LOAD(lua_setfield);
+	NV_LUA_LOAD(lua_rawset);
+	NV_LUA_LOAD(lua_rawseti);
+	NV_LUA_LOAD(lua_rawsetp);
+	NV_LUA_LOAD(lua_setmetatable);
+	NV_LUA_LOAD(lua_setuservalue);
+
+/* 'load' and 'call' functions (load and run Lua code) */
+	NV_LUA_LOAD(lua_callk);
+	NV_LUA_LOAD(lua_getctx);
+	NV_LUA_LOAD(lua_pcallk);
+	NV_LUA_LOAD(lua_load);
+	NV_LUA_LOAD(lua_dump);
+
+/* Coroutine functions */
+	NV_LUA_LOAD(lua_yieldk);
+	NV_LUA_LOAD(lua_resume);
+	NV_LUA_LOAD(lua_status);
+
+/* Garbage-collection function and options */
+	NV_LUA_LOAD(lua_gc);
+
+/* Miscellaneous functions */
+	NV_LUA_LOAD(lua_error);
+	NV_LUA_LOAD(lua_next);
+	NV_LUA_LOAD(lua_concat);
+	NV_LUA_LOAD(lua_len);
+	NV_LUA_LOAD(lua_getallocf);
+	NV_LUA_LOAD(lua_setallocf);
+
+/* Debug API */
+	NV_LUA_LOAD(lua_getstack);
+	NV_LUA_LOAD(lua_getinfo);
+	NV_LUA_LOAD(lua_getlocal);
+	NV_LUA_LOAD(lua_setlocal);
+	NV_LUA_LOAD(lua_getupvalue);
+	NV_LUA_LOAD(lua_setupvalue);
+	NV_LUA_LOAD(lua_upvalueid);
+	NV_LUA_LOAD(lua_upvaluejoin);
+	NV_LUA_LOAD(lua_sethook);
+	NV_LUA_LOAD(lua_gethook);
+	NV_LUA_LOAD(lua_gethookmask);
+	NV_LUA_LOAD(lua_gethookcount);
+
+/* lualib API */
+	NV_LUA_LOAD(luaopen_base);
+	NV_LUA_LOAD(luaopen_coroutine);
+	NV_LUA_LOAD(luaopen_table);
+	NV_LUA_LOAD(luaopen_io);
+	NV_LUA_LOAD(luaopen_os);
+	NV_LUA_LOAD(luaopen_string);
+	NV_LUA_LOAD(luaopen_bit32);
+	NV_LUA_LOAD(luaopen_math);
+	NV_LUA_LOAD(luaopen_debug);
+	NV_LUA_LOAD(luaopen_package);
+	NV_LUA_LOAD(luaL_openlibs);
+
+/* lauxlib API */
+	NV_LUA_LOAD(luaL_checkversion_);
+	NV_LUA_LOAD(luaL_getmetafield);
+	NV_LUA_LOAD(luaL_callmeta);
+	NV_LUA_LOAD(luaL_tolstring);
+	NV_LUA_LOAD(luaL_argerror);
+	NV_LUA_LOAD(luaL_checklstring);
+	NV_LUA_LOAD(luaL_optlstring);
+	NV_LUA_LOAD(luaL_checknumber);
+	NV_LUA_LOAD(luaL_optnumber);
+	NV_LUA_LOAD(luaL_checkinteger);
+	NV_LUA_LOAD(luaL_optinteger);
+	NV_LUA_LOAD(luaL_checkunsigned);
+	NV_LUA_LOAD(luaL_optunsigned);
+	NV_LUA_LOAD(luaL_checkstack);
+	NV_LUA_LOAD(luaL_checktype);
+	NV_LUA_LOAD(luaL_checkany);
+	NV_LUA_LOAD(luaL_newmetatable);
+	NV_LUA_LOAD(luaL_setmetatable);
+	NV_LUA_LOAD(luaL_testudata);
+	NV_LUA_LOAD(luaL_checkudata);
+	NV_LUA_LOAD(luaL_where);
+	NV_LUA_LOAD(luaL_error);
+	NV_LUA_LOAD(luaL_checkoption);
+	NV_LUA_LOAD(luaL_fileresult);
+	NV_LUA_LOAD(luaL_execresult);
+
+	NV_LUA_LOAD(luaL_ref);
+	NV_LUA_LOAD(luaL_unref);
+	NV_LUA_LOAD(luaL_loadfilex);
+	NV_LUA_LOAD(luaL_loadbufferx);
+	NV_LUA_LOAD(luaL_loadstring);
+	NV_LUA_LOAD(luaL_newstate);
+	NV_LUA_LOAD(luaL_len);
+	NV_LUA_LOAD(luaL_gsub);
+	NV_LUA_LOAD(luaL_setfuncs);
+	NV_LUA_LOAD(luaL_getsubtable);
+	NV_LUA_LOAD(luaL_traceback);
+	NV_LUA_LOAD(luaL_requiref);
+
+#	undef NV_LUA_LOAD
+	return true;
+}
+
+#endif
Index: trunk/src/lib/sdl12.cc
===================================================================
--- trunk/src/lib/sdl12.cc	(revision 5)
+++ trunk/src/lib/sdl12.cc	(revision 5)
@@ -0,0 +1,375 @@
+// Copyright (C) 2012-2013 ChaosForge / Kornel Kisielewicz
+// http://chaosforge.org/
+//
+// This file is part of NV Libraries.
+// For conditions of distribution and use, see copyright notice in nv.hh
+
+#include "nv/lib/sdl12.hh"
+
+#if defined( NV_SDL_DYNAMIC )
+
+#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; 
+
+bool nv::load_sdl_library( const char* path )
+{
+#	define NV_SDL_LOAD( symbol ) *(void **) (&symbol) = sdl_library.get(#symbol);
+	static nv::library sdl_library( 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
+	return true;
+}
+#endif
Index: trunk/src/lib/sdl_image.cc
===================================================================
--- trunk/src/lib/sdl_image.cc	(revision 5)
+++ trunk/src/lib/sdl_image.cc	(revision 5)
@@ -0,0 +1,66 @@
+// Copyright (C) 2012-2013 ChaosForge / Kornel Kisielewicz
+// http://chaosforge.org/
+//
+// This file is part of NV Libraries.
+// For conditions of distribution and use, see copyright notice in nv.hh
+
+#include "nv/lib/sdl_image.hh"
+
+#if defined( NV_SDL_DYNAMIC )
+
+#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;
+
+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( 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 );
+
+#	undef NV_SDL_IMAGE_LOAD
+	return true;
+}
+#endif
