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
