Index: /trunk/nv.lua
===================================================================
--- /trunk/nv.lua	(revision 320)
+++ /trunk/nv.lua	(revision 321)
@@ -112,5 +112,5 @@
 	includedirs { "." }
 	files { "nv/gui/**.hh",     "src/gui/**.cc" }
-	links { "nv-core", "nv-io", "nv-gfx" }
+	links { "nv-core", "nv-io", "nv-gfx", "nv-lua" }
 	targetname "nv-gui"
 
Index: /trunk/tests/cachebuf_test/cachebuf_test.lua
===================================================================
--- /trunk/tests/cachebuf_test/cachebuf_test.lua	(revision 320)
+++ /trunk/tests/cachebuf_test/cachebuf_test.lua	(revision 321)
@@ -3,5 +3,6 @@
 	files { "nv_cachebuf_test.cc" }
 	includedirs { "../../" }
-	targetname "nv_gui_test"
-	links { "nv" }
+	links { "nv-core", "nv-gl", "nv-gfx" }
+	targetdir "../../bin"
+	targetname "nv_cachebuf_test"
  
Index: /trunk/tests/cachebuf_test/nv_cachebuf_test.cc
===================================================================
--- /trunk/tests/cachebuf_test/nv_cachebuf_test.cc	(revision 320)
+++ /trunk/tests/cachebuf_test/nv_cachebuf_test.cc	(revision 321)
@@ -5,11 +5,6 @@
 #include <nv/core/logging.hh>
 #include <nv/core/logger.hh>
-#include <glm/glm.hpp>
-#include <glm/gtc/matrix_transform.hpp>
-#include <glm/gtc/type_ptr.hpp>
 #include <nv/core/string.hh>
-#include <cstdlib> // rand
-#include <ctime> // time
-
+#include <nv/core/random.hh>
 #include <nv/gfx/sliced_buffer.hh>
 
@@ -259,5 +254,5 @@
 		nv::buffer buffer = m_quad_cache->get_vertex_buffer();
 		#else
-		m_quad_cache = new gcache( m_context, nv::DYNAMIC_DRAW, 20, true );
+		m_quad_cache = new gcache( m_context, nv::VERTEX_BUFFER, nv::DYNAMIC_DRAW, 20 );
 		nv::buffer buffer = m_quad_cache->get_buffer();
 		#endif
@@ -286,11 +281,12 @@
 			m_context->set_index_buffer( m_va, m_quad_cache->get_index_buffer(), nv::USHORT, false );
 			nv::buffer buffer = m_quad_cache->get_vertex_buffer();
+			m_context->replace_vertex_buffer( m_va, buffer, nv::slot::POSITION, false );
 			#else
 			nv::buffer buffer = m_quad_cache->get_buffer();
+			m_context->replace_vertex_buffer( m_va, buffer, false );
 			#endif
 		}
 
 		m_window->get_context()->clear( m_clear_state );
-//		m_program->set_uniform( "tex", 0 );
 		#ifdef INDEXED_TEST
 		size_t draw_size = m_quad_cache->get_index_size();
@@ -330,6 +326,6 @@
 void application::spawn_window()
 {
-	glm::ivec2 a( std::rand() % 600, std::rand() % 400 );
-	glm::ivec2 b( std::rand() % 200, std::rand() % 200 );
+	glm::ivec2 a = nv::random::get().range( nv::ivec2(), nv::ivec2( 600, 400 ) );
+	glm::ivec2 b = nv::random::get().range( nv::ivec2(), nv::ivec2( 200, 200 ) );
 	NV_LOG( nv::LOG_INFO, "Spawn (" << a.x << "," << a.y << "x" << b.x << "," << b.y << ")" );
 	m_windows.emplace_back( m_quad_cache, a, a + b, glm::vec4( 0, 0, 1, 1 ) );
@@ -339,5 +335,5 @@
 {
 	if ( m_windows.size() == 0 ) return;
-	size_t index = rand() % m_windows.size();
+	size_t index = nv::random::get().urand( m_windows.size() );
 	m_windows.erase( m_windows.begin() + index );
 }
@@ -346,5 +342,5 @@
 {
 	if ( m_windows.size() == 0 ) return;
-	size_t index = rand() % m_windows.size();
+	size_t index = nv::random::get().urand( m_windows.size() );
 	m_windows[ index ].change_color( nv::vec4( (float)rand() / float(RAND_MAX), (float)rand() / float(RAND_MAX), (float)rand() / float(RAND_MAX), 1.0 ) );
 }
@@ -353,5 +349,5 @@
 {
 	if ( m_windows.size() == 0 ) return;
-	size_t index = rand() % m_windows.size();
+	size_t index = nv::random::get().urand( m_windows.size() );
 	NV_LOG( nv::LOG_INFO, "Simplify " << index );
 	m_windows[ index ].simplify_toggle();
@@ -372,5 +368,5 @@
 int main(int, char* [])
 {
-	std::srand((unsigned int) std::time(0) );
+	nv::random::get().randomize();
 	nv::logger log(nv::LOG_TRACE);
 	log.add_sink( new nv::log_file_sink("log.txt"), nv::LOG_TRACE );
Index: /trunk/tests/cachebuf_test/premake4.lua
===================================================================
--- /trunk/tests/cachebuf_test/premake4.lua	(revision 320)
+++ /trunk/tests/cachebuf_test/premake4.lua	(revision 321)
@@ -5,23 +5,15 @@
 	flags { "ExtraWarnings", "NoPCH" }
 
-	configuration "gmake"	
-		buildoptions "-std=c++11"
-
 	configuration "debug"
 		defines { "DEBUG" }
 		flags { "Symbols", "StaticRuntime" }
-		objdir (_ACTION.."/debug")
+		objdir ("../../".._ACTION.."/debug")
 
 	configuration "release"
 		defines { "NDEBUG" }
 		flags { "Optimize", "StaticRuntime" }
-		objdir (_ACTION.."/release")
+		objdir ("../../".._ACTION.."/release")
 
 	dofile("cachebuf_test.lua")
 	dofile("../../nv.lua")
 
-if _ACTION == "clean" then
-	for action in premake.action.each() do
-		os.rmdir(action.trigger)
-	end
-end
Index: /trunk/tests/gui_test/gui_test.lua
===================================================================
--- /trunk/tests/gui_test/gui_test.lua	(revision 320)
+++ /trunk/tests/gui_test/gui_test.lua	(revision 321)
@@ -4,4 +4,5 @@
 	includedirs { "../../" }
 	targetname "nv_gui_test"
-	links { "nv" }
+	links { "nv-core", "nv-gl", "nv-gui" }
+	targetdir "../../bin"	
  
Index: /trunk/tests/gui_test/nv_gui_test.cc
===================================================================
--- /trunk/tests/gui_test/nv_gui_test.cc	(revision 320)
+++ /trunk/tests/gui_test/nv_gui_test.cc	(revision 321)
@@ -4,6 +4,5 @@
 #include <nv/core/logging.hh>
 #include <nv/core/logger.hh>
-#include <cstdlib> // rand
-#include <ctime> // time
+#include <nv/core/random.hh>
 
 class application
@@ -84,6 +83,6 @@
 void application::spawn_window()
 {
-	glm::ivec2 a( std::rand() % 600, std::rand() % 400 );
-	glm::ivec2 b( std::rand() % 200 + 40, std::rand() % 200 + 40 );
+	nv::ivec2 a = nv::random::get().range( nv::ivec2(), nv::ivec2( 600, 400 ) );
+	nv::ivec2 b = nv::random::get().range( nv::ivec2( 40, 40 ), nv::ivec2( 240, 240 ) );
 	nv::gui::handle e = m_guienv->create_element( nv::rectangle(a).dim(b) );
 	m_guienv->set_class( e, "window" );
@@ -96,5 +95,5 @@
 {
 	if ( m_windows.size() == 0 ) return;
-	size_t index = rand() % m_windows.size();
+	size_t index = nv::random::get().urand( m_windows.size() );
 	m_guienv->destroy_element( m_windows[index] );
 	m_windows.erase( m_windows.begin() + index );
@@ -118,5 +117,5 @@
 int main(int, char* [])
 {
-	std::srand((unsigned int) std::time(0) );
+	nv::random::get().randomize();
 	nv::logger log(nv::LOG_TRACE);
 	log.add_sink( new nv::log_file_sink("log.txt"), nv::LOG_TRACE );
Index: /trunk/tests/gui_test/premake4.lua
===================================================================
--- /trunk/tests/gui_test/premake4.lua	(revision 320)
+++ /trunk/tests/gui_test/premake4.lua	(revision 321)
@@ -5,23 +5,14 @@
 	flags { "ExtraWarnings", "NoPCH" }
 
-	configuration "gmake"	
-		buildoptions "-std=c++11"
-
 	configuration "debug"
 		defines { "DEBUG" }
 		flags { "Symbols", "StaticRuntime" }
-		objdir (_ACTION.."/debug")
+		objdir ("../../".._ACTION.."/debug")
 
 	configuration "release"
 		defines { "NDEBUG" }
 		flags { "Optimize", "StaticRuntime" }
-		objdir (_ACTION.."/release")
+		objdir ("../../".._ACTION.."/release")
 
 	dofile("gui_test.lua")
 	dofile("../../nv.lua")
-
-if _ACTION == "clean" then
-	for action in premake.action.each() do
-		os.rmdir(action.trigger)
-	end
-end
Index: unk/tests/lualib_test/lualib_test.cc
===================================================================
--- /trunk/tests/lualib_test/lualib_test.cc	(revision 320)
+++ 	(revision )
@@ -1,78 +1,0 @@
-#include <nv/lib/lua.hh>
-#include <nv/lua/lua_state.hh>
-#include <nv/lua/lua_dispatch.hh>
-#include <nv/lua/lua_raw.hh>
-#include <nv/lua/lua_glm.hh>
-#include <nv/logger.hh>
-#include <nv/math.hh>
-#include <nv/object.hh>
-#include <string>
-#include <iostream>
-#include <functional>
-#include <nv/gui/gui_element.hh>
-
-void hello( const std::string& h )
-{
-	std::cout << h << " world from C++!" << std::endl;
-}
-
-
-int main(int, char* [])
-{
-	nv::logger log(nv::LOG_TRACE);
-	log.add_sink( new nv::log_file_sink("log.txt"), nv::LOG_TRACE );
-	log.add_sink( new nv::log_console_sink(), nv::LOG_TRACE );
-	
-	NV_LOG( nv::LOG_NOTICE, "Logging started" );
-
-	// create new Lua state
-	{
-		nv::lua::state state( true );
-		nv::lua::register_glm( state );
-		// run the Lua script
-		state.register_function<decltype(hello),&hello>( "hello" );
-		state.do_file( "init.lua" );
-		//std::cout << nv::function_traits<decltype(hello)>::arg_count << std::endl;
-
-		log.set_level( nv::LOG_INFO );
-		for (;;)
-		{
-			nv::lua::stack_guard guard( state );
-			int stack = guard.get_level();
-			std::string input;
-			std::cout << "LUA (" << stack << ") > ";
-			std::getline( std::cin, input );
-			if (input == "quit")
-			{
-				break;
-			}
-
-			if (input.find("=", 0) == std::string::npos && 
-				input.find("if", 0) == std::string::npos && 
-				input.find("return", 0) == std::string::npos)
-			{
-				input = "return " + input;
-			}
-
-			std::cout << "> " << input << std::endl;
-
-			bool result = state.do_string( input, "", nv::lua::ret_multi );
-			if ( !result )
-			{
-				continue;
-			}
-
-			if (lua_gettop( state ) > stack)
-			{
-				for ( int i = stack+1; i <= lua_gettop( state ); ++i )
-				{
-					std::cout << nlua_typecontent( state, i ) << std::endl;
-				}
-			}
-		}
-	}
-	NV_LOG( nv::LOG_NOTICE, "Logging stopped" );
-
-	return 0;
-}
-
Index: /trunk/tests/lualib_test/lualib_test.lua
===================================================================
--- /trunk/tests/lualib_test/lualib_test.lua	(revision 321)
+++ /trunk/tests/lualib_test/lualib_test.lua	(revision 321)
@@ -0,0 +1,8 @@
+project "nv_lualib_test"
+	kind "ConsoleApp"
+	files { "nv_lualib_test.cc" }
+	includedirs { "../../" }
+	targetname "nv_lualib_test"
+	links { "nv-core", "nv-lua" }
+	targetdir "../../bin"	
+ 
Index: /trunk/tests/lualib_test/nv_lualib_test.cc
===================================================================
--- /trunk/tests/lualib_test/nv_lualib_test.cc	(revision 321)
+++ /trunk/tests/lualib_test/nv_lualib_test.cc	(revision 321)
@@ -0,0 +1,76 @@
+#include <nv/lib/lua.hh>
+#include <nv/lua/lua_state.hh>
+#include <nv/lua/lua_dispatch.hh>
+#include <nv/lua/lua_raw.hh>
+#include <nv/lua/lua_glm.hh>
+#include <nv/core/logger.hh>
+#include <nv/core/math.hh>
+#include <nv/core/string.hh>
+#include <iostream>
+#include <functional>
+
+void hello( const std::string& h )
+{
+	std::cout << h << " world from C++!" << std::endl;
+}
+
+
+int main(int, char* [])
+{
+	nv::logger log(nv::LOG_TRACE);
+	log.add_sink( new nv::log_file_sink("log.txt"), nv::LOG_TRACE );
+	log.add_sink( new nv::log_console_sink(), nv::LOG_TRACE );
+	
+	NV_LOG( nv::LOG_NOTICE, "Logging started" );
+
+	// create new Lua state
+	{
+		nv::lua::state state( true );
+		nv::lua::register_glm( state );
+		// run the Lua script
+		state.register_function<decltype(&hello),&hello>( "hello" );
+		state.do_file( "init.lua" );
+		//std::cout << nv::function_traits<decltype(hello)>::arg_count << std::endl;
+
+		log.set_level( nv::LOG_INFO );
+		for (;;)
+		{
+			nv::lua::stack_guard guard( state );
+			int stack = guard.get_level();
+			std::string input;
+			std::cout << "LUA (" << stack << ") > ";
+			std::getline( std::cin, input );
+			if (input == "quit")
+			{
+				break;
+			}
+
+			if (input.find("=", 0) == std::string::npos && 
+				input.find("if", 0) == std::string::npos && 
+				input.find("return", 0) == std::string::npos)
+			{
+				input = "return " + input;
+			}
+
+			std::cout << "> " << input << std::endl;
+
+			bool result = state.do_string( input, "", nv::lua::ret_multi );
+			if ( !result )
+			{
+				continue;
+			}
+
+			if (lua_gettop( state ) > stack)
+			{
+				for ( int i = stack+1; i <= lua_gettop( state ); ++i )
+				{
+					std::cout << nlua_typecontent( state, i ) << std::endl;
+				}
+			}
+		}
+	}
+	NV_LOG( nv::LOG_NOTICE, "Logging stopped" );
+
+	return 0;
+}
+
Index: /trunk/tests/lualib_test/premake4.lua
===================================================================
--- /trunk/tests/lualib_test/premake4.lua	(revision 320)
+++ /trunk/tests/lualib_test/premake4.lua	(revision 321)
@@ -8,17 +8,11 @@
 		defines { "DEBUG" }
 		flags { "Symbols", "StaticRuntime" }
-		objdir (_ACTION.."/debug")
+		objdir ("../../".._ACTION.."/debug")
 
 	configuration "release"
 		defines { "NDEBUG" }
 		flags { "Optimize", "StaticRuntime" }
-		objdir (_ACTION.."/release")
+		objdir ("../../".._ACTION.."/release")
 
 	dofile("lualib_test.lua")
 	dofile("../../nv.lua")
-
-if _ACTION == "clean" then
-	for action in premake.action.each() do
-		os.rmdir(action.trigger)
-	end
-end
Index: unk/tests/lualib_test/rl.lua
===================================================================
--- /trunk/tests/lualib_test/rl.lua	(revision 320)
+++ 	(revision )
@@ -1,9 +1,0 @@
--- RL project definition
-project "rl"
-	kind "ConsoleApp"
-	files { "src/**.hh", "src/**.cc", "rl.cc" }
-	includedirs { "src", "../nv" }
-	targetname "rl"
-	defines { "_SCL_SECURE_NO_WARNINGS" }
-	links { "nv" }
- 
Index: /trunk/tests/md2_test/md2.frag
===================================================================
--- /trunk/tests/md2_test/md2.frag	(revision 321)
+++ /trunk/tests/md2_test/md2.frag	(revision 321)
@@ -0,0 +1,37 @@
+#version 120
+
+uniform sampler2D nv_t_diffuse;
+uniform vec4 light_diffuse;
+uniform vec4 light_specular;
+
+varying vec2 v_texcoord;
+varying vec3 v_normal;
+varying vec3 v_light_vector;
+varying vec3 v_view_vector;
+
+void main(void) {
+	vec3 diff_texel      = vec3( texture2D( nv_t_diffuse, v_texcoord ) );	
+
+	vec3 nnormal         = normalize( v_normal );
+	vec3 nlight_vector   = normalize( v_light_vector );
+	vec3 nreflect_vector = reflect( -nlight_vector, nnormal );
+
+	float specular_amount = 0.2;
+	float diffuse_amount  = 1.0 - specular_amount;
+
+	float dot_prod_specular = dot( nreflect_vector, normalize( v_view_vector ) );
+	float dot_prod_diffuse  = dot( nlight_vector, nnormal );
+
+	float diffuse_factor  = max( dot_prod_diffuse, 0.0 );
+	float specular_factor = pow( max( dot_prod_specular, 0.0 ), 16.0 ); // 100.0
+
+	float final_diffuse  = diffuse_amount * diffuse_factor * 0.5;
+	float final_specular = specular_amount * specular_factor;
+
+	vec3 diffuse_color   = light_diffuse.xyz  * final_diffuse * diff_texel;
+	vec3 specular_color  = light_specular.xyz * final_specular;
+	vec3 self_ilum_color = vec3 (0.0, 0.0, 0.0);
+	vec3 ambient_color   = vec3 (0.0, 0.0, 0.0);
+
+	gl_FragColor = vec4( max( self_ilum_color, diffuse_color + specular_color + ambient_color ), 1.0 );
+}
Index: /trunk/tests/md2_test/md2.vert
===================================================================
--- /trunk/tests/md2_test/md2.vert	(revision 321)
+++ /trunk/tests/md2_test/md2.vert	(revision 321)
@@ -0,0 +1,33 @@
+#version 120
+
+attribute vec2 nv_texcoord;
+attribute vec3 nv_position;
+attribute vec3 nv_normal;
+attribute vec3 nv_next_position;
+attribute vec3 nv_next_normal;
+
+varying vec3 v_normal;
+varying vec3 v_light_vector;
+varying vec3 v_view_vector;
+varying vec2 v_texcoord;
+
+uniform mat4 nv_m_mvp;
+uniform mat4 nv_m_model;
+uniform mat4 nv_m_model_inv;
+uniform vec3 nv_v_camera_position;
+uniform vec3 light_position;
+uniform float nv_interpolate;
+
+void main(void)
+{
+	vec4 position   = vec4( mix( nv_position, nv_next_position, nv_interpolate ), 1.0 );
+	v_normal        = normalize( mix( nv_normal, nv_next_normal, nv_interpolate ) );
+	v_texcoord      = nv_texcoord;
+	gl_Position     = nv_m_mvp * position;
+
+	vec3 camera_loc = vec3(nv_m_model_inv * vec4 (nv_v_camera_position, 1.0) );
+	vec3 light_loc  = vec3(nv_m_model_inv * vec4 (light_position, 1.0) );
+
+	v_view_vector  = normalize( nv_position - camera_loc  );
+	v_light_vector = normalize( nv_position - light_loc );
+}
Index: unk/tests/md2_test/md2_test.cc
===================================================================
--- /trunk/tests/md2_test/md2_test.cc	(revision 320)
+++ 	(revision )
@@ -1,175 +1,0 @@
-#include <nv/common.hh>
-#include <nv/gfx/keyframed_mesh.hh>
-#include <nv/interface/vertex_buffer.hh>
-#include <nv/gl/gl_device.hh>
-#include <nv/gfx/image.hh>
-#include <nv/interface/context.hh>
-#include <nv/interface/window.hh>
-#include <nv/interface/program.hh>
-#include <nv/interface/texture2d.hh>
-#include <nv/interface/mesh_loader.hh>
-#include <nv/io/c_file_system.hh>
-#include <nv/formats/md2_loader.hh>
-#include <nv/profiler.hh>
-#include <nv/logging.hh>
-#include <nv/logger.hh>
-#include <nv/math.hh>
-#include <nv/time.hh>
-#include <nv/string.hh>
-#include <glm/gtx/rotate_vector.hpp>
-
-class application
-{
-public:
-	application();
-	bool initialize();
-	bool run();
-	~application();
-protected:
-	nv::device*       m_device;
-	nv::window*       m_window;
-	nv::texture2d*    m_diffuse;
-	nv::program*      m_program;
-
-	nv::clear_state   m_clear_state;
-	nv::render_state  m_render_state;
-	nv::scene_state   m_scene_state;
-
-	nv::mesh_data*      m_mesh_data;
-	nv::keyframed_mesh* m_mesh;
-};
-
-application::application()
-{
-	NV_PROFILE( "app_construct" );
-	m_device = new nv::gl_device();
-	m_window = m_device->create_window( 800, 600, false );
-
-	nv::sampler sampler( nv::sampler::LINEAR, nv::sampler::REPEAT );
-	nv::image_data* data = m_device->create_image_data( "data/manc.png" );
-	m_diffuse  = m_device->create_texture2d( data->get_size(), nv::RGB, nv::UBYTE, sampler, (void*)data->get_data() );
-	delete data;
-
-	m_clear_state.buffers = nv::clear_state::COLOR_AND_DEPTH_BUFFER;
-	m_render_state.depth_test.enabled = true;
-	m_render_state.culling.enabled    = true;
-	m_render_state.blending.enabled   = false;
-	m_render_state.blending.src_rgb_factor   = nv::blending::SRC_ALPHA;
-	m_render_state.blending.dst_rgb_factor   = nv::blending::ONE_MINUS_SRC_ALPHA;
-	m_render_state.blending.src_alpha_factor = nv::blending::SRC_ALPHA;
-	m_render_state.blending.dst_alpha_factor = nv::blending::ONE_MINUS_SRC_ALPHA;
-}
-
-bool application::initialize()
-{
-	NV_PROFILE( "app_initialize" );
-	m_program = m_device->create_program( nv::slurp( "obj.vert" ), nv::slurp( "obj.frag" ) );
-
-	nv::md2_loader* loader;
-	{
-		NV_PROFILE("loader->load");
-		nv::c_file_system fs;
-		nv::stream* mesh_file = fs.open( "data/manc.md2" );
-		loader = new nv::md2_loader();
-		loader->load( *mesh_file );
-		m_mesh_data = loader->release_mesh_data();
-		delete mesh_file;
-		delete loader;
-	}
-
-	{
-		NV_PROFILE("create_mesh");
-		m_mesh      = new nv::keyframed_mesh_gpu( m_window->get_context(), m_mesh_data, nullptr, m_program );
-	}
-
-	return true;
-}
-
-bool application::run()
-{
-	nv::profiler::pointer()->log_report(); 
-	NV_PROFILE( "app_run" );
-	int keypress = 0;
-
-	nv::uint32 ticks   = m_device->get_ticks();
-	nv::uint32 last_ticks;
-	nv::fps_counter_class< nv::system_us_timer > fps_counter;
-
-	m_mesh->setup_animation( 0, m_mesh->get_max_frames(), 2, true );
-
-	while(!keypress) 
-	{
-		last_ticks = ticks;
-		ticks      = m_device->get_ticks();
-		nv::uint32 elapsed = ticks - last_ticks;
-		m_window->get_context()->clear( m_clear_state );
-		m_mesh->update( elapsed );
-		glm::vec3 eye = glm::rotate( glm::vec3( 100.0f, 25.0f, 0.0f ), (ticks / 20.f), glm::vec3( 0.0,1.0,0.0 ) );
-
-		m_scene_state.set_model( nv::mat4(1.0f) );
-		m_scene_state.get_camera().set_lookat(eye, glm::vec3(0.0f, 25.0f, 0.0f), glm::vec3(0.0, 1.0, 0.0));
-		m_scene_state.get_camera().set_perspective(60.0f, 1.0f*800.0f/600.0f, 0.1f, 1000.0f);
-
-		m_diffuse->bind( 0 );
-		m_program->set_opt_uniform( "light_position", glm::vec3(120.0, 120.0, 0) );
-		m_program->set_opt_uniform( "light_diffuse",  glm::vec4(1.0,1.0,1.0,1.0) );
-		m_program->set_opt_uniform( "light_specular", glm::vec4(1.0,1.0,1.0,1.0) );
-		m_mesh->update( m_program );
-		m_window->get_context()->draw( m_render_state, m_scene_state, m_program, m_mesh );
-		m_window->swap_buffers();
-
-		nv::io_event event;
-		while(m_window->poll_event(event)) 
-		{      
-			switch (event.type) 
-			{
-			case nv::EV_QUIT:
-				keypress = 1;
-				break;
-			case nv::EV_KEY:
-				if (event.key.pressed)
-				{
-					switch (event.key.code) 
-					{
-					case nv::KEY_ESCAPE : keypress = 1; break;
-					case nv::KEY_F1 : nv::profiler::pointer()->log_report(); break;
-					default: break;
-					}
-				}
-				break;
-			default: break;
-			}
-		}
-		fps_counter.tick();
-	}
-	return true;
-}
-
-application::~application()
-{
-	delete m_program;
-	delete m_mesh_data;
-	delete m_mesh;
-	delete m_diffuse;
-	delete m_window;
-	delete m_device;
-}
-
-
-int main(int, char* [])
-{
-	nv::logger log(nv::LOG_TRACE);
-	log.add_sink( new nv::log_file_sink("log.txt"), nv::LOG_TRACE );
-	log.add_sink( new nv::log_console_sink(), nv::LOG_TRACE );
-	
-	NV_LOG( nv::LOG_NOTICE, "Logging started" );
-	application app;
-	if ( app.initialize() )
-	{
-		app.run();
-	}
-	NV_LOG( nv::LOG_NOTICE, "Logging stopped" );
-
-	return 0;
-}
-
Index: /trunk/tests/md2_test/md2_test.lua
===================================================================
--- /trunk/tests/md2_test/md2_test.lua	(revision 320)
+++ /trunk/tests/md2_test/md2_test.lua	(revision 321)
@@ -1,8 +1,8 @@
--- md2 load test project definition
-project "md2_test"
+project "nv_md2_test"
 	kind "ConsoleApp"
-	files { "md2_test.cc" }
+	files { "nv_md2_test.cc" }
 	includedirs { "../../" }
-	targetname "md2_test"
-	links { "nv" }
- 
+	targetname "nv_md2_test"
+	links { "nv-core", "nv-gl", "nv-formats" }
+	targetdir "../../bin"	
+  
Index: /trunk/tests/md2_test/nv_md2_test.cc
===================================================================
--- /trunk/tests/md2_test/nv_md2_test.cc	(revision 321)
+++ /trunk/tests/md2_test/nv_md2_test.cc	(revision 321)
@@ -0,0 +1,176 @@
+#include <nv/gfx/keyframed_mesh.hh>
+#include <nv/gl/gl_device.hh>
+#include <nv/gfx/image.hh>
+#include <nv/interface/context.hh>
+#include <nv/interface/window.hh>
+#include <nv/interface/mesh_loader.hh>
+#include <nv/io/c_file_system.hh>
+#include <nv/formats/md2_loader.hh>
+#include <nv/core/profiler.hh>
+#include <nv/core/logging.hh>
+#include <nv/core/logger.hh>
+#include <nv/core/math.hh>
+#include <nv/core/time.hh>
+#include <nv/core/string.hh>
+#include <glm/gtx/rotate_vector.hpp>
+
+class application
+{
+public:
+	application();
+	bool initialize();
+	bool run();
+	~application();
+protected:
+	nv::device*  m_device;
+	nv::window*  m_window;
+	nv::context* m_context;
+	nv::texture  m_diffuse;
+	nv::program  m_program;
+
+	nv::clear_state   m_clear_state;
+	nv::render_state  m_render_state;
+	nv::scene_state   m_scene_state;
+
+	nv::mesh_data*       m_mesh_data;
+	nv::keyframed_mesh*  m_mesh;
+	nv::animation_entry* m_animation;
+};
+
+application::application()
+{
+	NV_PROFILE( "app_construct" );
+	m_device  = new nv::gl_device();
+	m_window  = m_device->create_window( 800, 600, false );
+	m_context = m_window->get_context();
+
+	nv::sampler sampler( nv::sampler::LINEAR, nv::sampler::REPEAT );
+	nv::image_data* data = m_device->create_image_data( "data/manc.png" );
+	m_diffuse  = m_device->create_texture( data, sampler );
+	delete data;
+
+	m_clear_state.buffers = nv::clear_state::COLOR_AND_DEPTH_BUFFER;
+	m_render_state.depth_test.enabled = true;
+	m_render_state.culling.enabled    = true;
+	m_render_state.blending.enabled   = false;
+	m_render_state.blending.src_rgb_factor   = nv::blending::SRC_ALPHA;
+	m_render_state.blending.dst_rgb_factor   = nv::blending::ONE_MINUS_SRC_ALPHA;
+	m_render_state.blending.src_alpha_factor = nv::blending::SRC_ALPHA;
+	m_render_state.blending.dst_alpha_factor = nv::blending::ONE_MINUS_SRC_ALPHA;
+}
+
+bool application::initialize()
+{
+	NV_PROFILE( "app_initialize" );
+	m_program = m_device->create_program( nv::slurp( "md2.vert" ), nv::slurp( "md2.frag" ) );
+
+	nv::md2_loader* loader;
+	{
+		NV_PROFILE("loader->load");
+		nv::c_file_system fs;
+		nv::stream* mesh_file = fs.open( "data/manc.md2" );
+		loader = new nv::md2_loader();
+		loader->load( *mesh_file );
+		m_mesh_data = loader->release_mesh_data();
+		delete mesh_file;
+		delete loader;
+	}
+
+	{
+		NV_PROFILE("create_mesh");
+		m_mesh      = new nv::keyframed_mesh_gpu( m_context, m_mesh_data, nullptr );
+	}
+
+	return true;
+}
+
+bool application::run()
+{
+	nv::profiler::pointer()->log_report(); 
+	NV_PROFILE( "app_run" );
+	int keypress = 0;
+
+	nv::uint32 ticks   = m_device->get_ticks();
+	nv::uint32 last_ticks;
+	nv::fps_counter_class< nv::system_us_timer > fps_counter;
+
+	m_animation = new nv::animation_entry( "", true, 5, 0.0f, m_mesh->get_max_frames()-1 );
+	m_mesh->run_animation( m_animation );
+
+	while(!keypress) 
+	{
+		last_ticks = ticks;
+		ticks      = m_device->get_ticks();
+		nv::uint32 elapsed = ticks - last_ticks;
+		m_context->clear( m_clear_state );
+		glm::vec3 eye = glm::rotate( glm::vec3( 100.0f, 25.0f, 0.0f ), (ticks / 20.f), glm::vec3( 0.0,1.0,0.0 ) );
+
+		m_scene_state.set_model( nv::mat4(1.0f) );
+		m_scene_state.get_camera().set_lookat(eye, glm::vec3(0.0f, 25.0f, 0.0f), glm::vec3(0.0, 1.0, 0.0));
+		m_scene_state.get_camera().set_perspective(60.0f, 1.0f*800.0f/600.0f, 0.1f, 1000.0f);
+
+		m_context->bind( m_diffuse, nv::TEX_DIFFUSE );
+		m_device->set_opt_uniform( m_program, "light_position", glm::vec3(120.0, 120.0, 0) );
+		m_device->set_opt_uniform( m_program, "light_diffuse",  glm::vec4(1.0,1.0,1.0,1.0) );
+		m_device->set_opt_uniform( m_program, "light_specular", glm::vec4(1.0,1.0,1.0,1.0) );
+		m_mesh->update_animation( m_animation, ticks );
+		m_mesh->update( m_program );
+		m_context->draw( nv::TRIANGLES, m_render_state, m_scene_state, m_program, m_mesh->get_vertex_array(), m_mesh->get_index_count() );
+		m_window->swap_buffers();
+
+		nv::io_event event;
+		while(m_window->poll_event(event)) 
+		{      
+			switch (event.type) 
+			{
+			case nv::EV_QUIT:
+				keypress = 1;
+				break;
+			case nv::EV_KEY:
+				if (event.key.pressed)
+				{
+					switch (event.key.code) 
+					{
+					case nv::KEY_ESCAPE : keypress = 1; break;
+					case nv::KEY_F1 : nv::profiler::pointer()->log_report(); break;
+					default: break;
+					}
+				}
+				break;
+			default: break;
+			}
+		}
+		fps_counter.tick();
+	}
+	return true;
+}
+
+application::~application()
+{
+	m_device->release( m_program );
+	delete m_mesh_data;
+	delete m_mesh;
+	delete m_animation;
+	m_device->release( m_diffuse );
+	delete m_window;
+	delete m_device;
+}
+
+
+int main(int, char* [])
+{
+	nv::logger log(nv::LOG_TRACE);
+	log.add_sink( new nv::log_file_sink("log.txt"), nv::LOG_TRACE );
+	log.add_sink( new nv::log_console_sink(), nv::LOG_TRACE );
+	
+	NV_LOG( nv::LOG_NOTICE, "Logging started" );
+	application app;
+	if ( app.initialize() )
+	{
+		app.run();
+	}
+	NV_LOG( nv::LOG_NOTICE, "Logging stopped" );
+
+	return 0;
+}
+
Index: unk/tests/md2_test/obj.frag
===================================================================
--- /trunk/tests/md2_test/obj.frag	(revision 320)
+++ 	(revision )
@@ -1,37 +1,0 @@
-#version 120
-
-uniform sampler2D nv_t_diffuse;
-uniform vec4 light_diffuse;
-uniform vec4 light_specular;
-
-varying vec2 v_texcoord;
-varying vec3 v_normal;
-varying vec3 v_light_vector;
-varying vec3 v_view_vector;
-
-void main(void) {
-	vec3 diff_texel      = vec3( texture2D( nv_t_diffuse, v_texcoord ) );	
-
-	vec3 nnormal         = normalize( v_normal );
-	vec3 nlight_vector   = normalize( v_light_vector );
-	vec3 nreflect_vector = reflect( -nlight_vector, nnormal );
-
-	float specular_amount = 0.2;
-	float diffuse_amount  = 1.0 - specular_amount;
-
-	float dot_prod_specular = dot( nreflect_vector, normalize( v_view_vector ) );
-	float dot_prod_diffuse  = dot( nlight_vector, nnormal );
-
-	float diffuse_factor  = max( dot_prod_diffuse, 0.0 );
-	float specular_factor = pow( max( dot_prod_specular, 0.0 ), 16.0 ); // 100.0
-
-	float final_diffuse  = diffuse_amount * diffuse_factor * 0.5;
-	float final_specular = specular_amount * specular_factor;
-
-	vec3 diffuse_color   = light_diffuse.xyz  * final_diffuse * diff_texel;
-	vec3 specular_color  = light_specular.xyz * final_specular;
-	vec3 self_ilum_color = vec3 (0.0, 0.0, 0.0);
-	vec3 ambient_color   = vec3 (0.0, 0.0, 0.0);
-
-	gl_FragColor = vec4( max( self_ilum_color, diffuse_color + specular_color + ambient_color ), 1.0 );
-}
Index: unk/tests/md2_test/obj.vert
===================================================================
--- /trunk/tests/md2_test/obj.vert	(revision 320)
+++ 	(revision )
@@ -1,33 +1,0 @@
-#version 120
-
-attribute vec2 nv_texcoord;
-attribute vec3 nv_position;
-attribute vec3 nv_normal;
-attribute vec3 nv_next_position;
-attribute vec3 nv_next_normal;
-
-varying vec3 v_normal;
-varying vec3 v_light_vector;
-varying vec3 v_view_vector;
-varying vec2 v_texcoord;
-
-uniform mat4 nv_m_mvp;
-uniform mat4 nv_m_model;
-uniform mat4 nv_m_model_inv;
-uniform vec3 nv_v_camera_position;
-uniform vec3 light_position;
-uniform float nv_interpolate;
-
-void main(void)
-{
-	vec4 position   = vec4( mix( nv_position, nv_next_position, nv_interpolate ), 1.0 );
-	v_normal        = normalize( mix( nv_normal, nv_next_normal, nv_interpolate ) );
-	v_texcoord      = nv_texcoord;
-	gl_Position     = nv_m_mvp * position;
-
-	vec3 camera_loc = vec3(nv_m_model_inv * vec4 (nv_v_camera_position, 1.0) );
-	vec3 light_loc  = vec3(nv_m_model_inv * vec4 (light_position, 1.0) );
-
-	v_view_vector  = normalize( nv_position - camera_loc  );
-	v_light_vector = normalize( nv_position - light_loc );
-}
Index: /trunk/tests/md2_test/premake4.lua
===================================================================
--- /trunk/tests/md2_test/premake4.lua	(revision 320)
+++ /trunk/tests/md2_test/premake4.lua	(revision 321)
@@ -8,17 +8,11 @@
 		defines { "DEBUG" }
 		flags { "Symbols", "StaticRuntime" }
-		objdir (_ACTION or "".."/debug")
+		objdir ("../../".._ACTION.."/debug")
 
 	configuration "release"
 		defines { "NDEBUG" }
 		flags { "Optimize", "StaticRuntime" }
-		objdir (_ACTION or "".."/release")
+		objdir ("../../".._ACTION.."/release")
 
 	dofile("md2_test.lua")
 	dofile("../../nv.lua")
-
-if _ACTION == "clean" then
-	for action in premake.action.each() do
-		os.rmdir(action.trigger)
-	end
-end
Index: /trunk/tests/md3_test/md3.frag
===================================================================
--- /trunk/tests/md3_test/md3.frag	(revision 321)
+++ /trunk/tests/md3_test/md3.frag	(revision 321)
@@ -0,0 +1,34 @@
+#version 120
+
+uniform sampler2D nv_t_diffuse;
+uniform vec4 light_diffuse;
+uniform vec4 light_specular;
+
+varying vec2 v_texcoord;
+varying vec3 v_normal;
+varying vec3 v_light_vector;
+varying vec3 v_view_vector;
+ 
+void main(void) {
+	vec3 nnormal         = normalize( v_normal );
+	vec3 nlight_vector   = normalize( v_light_vector );
+	vec3 nview_vector    = normalize( v_view_vector );
+	vec3 nreflect_vector = reflect( -nlight_vector, nnormal );
+
+	float specular_value = clamp( dot( nreflect_vector, nview_vector ), 0.0, 1.0 );
+	specular_value       = pow( specular_value, 6.0 );
+	float diffuse_value  = max( dot( nlight_vector, nnormal ), 0.0 );
+
+	vec3 diff_texel      = vec3( texture2D( nv_t_diffuse, v_texcoord ) );	
+	
+	float final_specular = specular_value * 0.2;
+	float final_diffuse  = diffuse_value * 0.5;
+	float final_ambient  = 0.3;
+
+	vec3 ambient_color   = final_ambient * diff_texel;
+	vec3 diffuse_color   = light_diffuse.xyz * final_diffuse * diff_texel;
+	vec3 specular_color  = light_specular.xyz * final_specular;
+
+	gl_FragColor = vec4( ambient_color + diffuse_color + specular_color, 1.0 );
+//	gl_FragColor = vec4( diff_texel, 1.0 );
+}
Index: /trunk/tests/md3_test/md3_cpu.vert
===================================================================
--- /trunk/tests/md3_test/md3_cpu.vert	(revision 321)
+++ /trunk/tests/md3_test/md3_cpu.vert	(revision 321)
@@ -0,0 +1,28 @@
+#version 120
+
+attribute vec2 nv_texcoord;
+attribute vec3 nv_position;
+attribute vec3 nv_normal;
+
+varying vec3 v_normal;
+varying vec3 v_light_vector;
+varying vec3 v_view_vector;
+varying vec2 v_texcoord;
+
+uniform mat4 nv_m_mvp;
+uniform mat4 nv_m_modelview;
+uniform mat4 nv_m_projection;
+uniform mat3 nv_m_normal;
+uniform vec3 light_position;
+
+void main(void) {
+	vec4 vertex     = vec4( nv_position, 1.0 );
+	v_normal        = normalize( nv_m_normal * nv_normal );
+
+	vec3 eye_pos    = vec3( nv_m_modelview * vertex );
+	v_light_vector  = vec3( normalize( light_position - eye_pos ) );
+	v_view_vector   = vec3( normalize( -eye_pos ) );
+
+	v_texcoord      = nv_texcoord;
+	gl_Position     = nv_m_mvp * vertex;
+}
Index: /trunk/tests/md3_test/md3_gpu.vert
===================================================================
--- /trunk/tests/md3_test/md3_gpu.vert	(revision 321)
+++ /trunk/tests/md3_test/md3_gpu.vert	(revision 321)
@@ -0,0 +1,31 @@
+#version 120
+
+attribute vec2 nv_texcoord;
+attribute vec3 nv_position;
+attribute vec3 nv_normal;
+attribute vec3 nv_next_position;
+attribute vec3 nv_next_normal;
+
+varying vec3 v_normal;
+varying vec3 v_light_vector;
+varying vec3 v_view_vector;
+varying vec2 v_texcoord;
+
+uniform mat4 nv_m_mvp;
+uniform mat4 nv_m_modelview;
+uniform mat4 nv_m_projection;
+uniform mat3 nv_m_normal;
+uniform float nv_interpolate;
+uniform vec3 light_position;
+
+void main(void) {
+	vec4 vertex     = vec4( mix( nv_position, nv_next_position, nv_interpolate ), 1.0 );
+	v_normal        = normalize( nv_m_normal * mix( nv_normal, nv_next_normal, nv_interpolate ) );
+	
+	vec3 eye_pos    = vec3( nv_m_modelview * vertex );
+	v_light_vector  = vec3( normalize( light_position - eye_pos ) );
+	v_view_vector   = vec3( normalize( -eye_pos ) );
+
+	v_texcoord      = nv_texcoord;
+	gl_Position     = nv_m_mvp * vertex;
+}
Index: unk/tests/md3_test/md3_test.cc
===================================================================
--- /trunk/tests/md3_test/md3_test.cc	(revision 320)
+++ 	(revision )
@@ -1,302 +1,0 @@
-#include <nv/core/common.hh>
-#include <iomanip>
-#include <nv/gfx/keyframed_mesh.hh>
-#include <nv/gl/gl_device.hh>
-#include <nv/gfx/image.hh>
-#include <nv/interface/context.hh>
-#include <nv/interface/window.hh>
-#include <nv/interface/mesh_loader.hh>
-#include <nv/io/c_file_system.hh>
-#include <nv/formats/md3_loader.hh>
-#include <nv/core/profiler.hh>
-#include <nv/core/logging.hh>
-#include <nv/core/logger.hh>
-#include <nv/core/math.hh>
-#include <nv/core/time.hh>
-#include <nv/core/string.hh>
-#include <glm/gtx/rotate_vector.hpp>
-#include <glm/gtc/matrix_access.hpp>
-#include <glm/gtx/matrix_interpolation.hpp>
-
-bool GPU_ANIMATION = true;
-
-class mesh_part
-{
-public:
-	mesh_part( const std::string& path, nv::window* window )
-	{
-		NV_PROFILE("mesh_construct");
-		nv::md3_loader* loader;
-		{
-			NV_PROFILE("loader->load");
-			nv::c_file_system fs;
-			nv::stream* mesh_file = fs.open( path.c_str() );
-			loader = new nv::md3_loader();
-			loader->load( *mesh_file );
-			delete mesh_file;
-		}
-
-		{
-			NV_PROFILE("create_mesh_data");
-			m_mesh_data = loader->release_mesh_data_pack();
-		}
-		delete loader;
-		m_entry = nullptr;
-		{
-			NV_PROFILE("create_mesh");
-			if ( GPU_ANIMATION )
-				m_mesh      = new nv::keyframed_mesh_gpu( window->get_context(), m_mesh_data->get_mesh(0), m_mesh_data->get_nodes() );
-			else
-				m_mesh      = new nv::keyframed_mesh_cpu( window->get_context(), m_mesh_data->get_mesh(0), m_mesh_data->get_nodes() );
-		}
-
-	}
-
-	nv::mat4 get_transform( nv::uint32 id )
-	{
-		return m_mesh->get_node_transform( id ).extract();
-	}
-
-	void setup_animation( nv::uint32 start, nv::uint32 stop, nv::uint32 fps, bool loop )
-	{
-		delete m_entry;
-		m_entry = new nv::animation_entry("test", loop, fps, (float)start, float(stop-1) );
-		m_mesh->run_animation( m_entry );
-	}
-
-	void update( nv::uint32 ms, nv::program program )
-	{
-		m_mesh->update_animation( m_entry, ms );
-		m_mesh->update( program );
-	}
-
-	nv::mesh_interface* get_mesh() const { return m_mesh; }
-
-	size_t get_max_frames()
-	{
-		return m_mesh->get_max_frames();
-	}
-
-	~mesh_part()
-	{
-		delete m_mesh_data;
-		delete m_mesh;
-	}
-
-private:
-	nv::mesh_data_pack*  m_mesh_data;
-	nv::keyframed_mesh*  m_mesh;
-	nv::animation_entry* m_entry;
-};
-
-class application
-{
-public:
-	application();
-	bool initialize();
-	bool run();
-	~application();
-protected:
-	nv::device*       m_device;
-	nv::context*      m_context;
-	nv::window*       m_window;
-	nv::texture       m_diffuse;
-	nv::texture       m_diffuse_weapon;
-
-	nv::clear_state   m_clear_state;
-	nv::render_state  m_render_state;
-	nv::scene_state   m_scene_state;
-
-	mesh_part* m_torso;
-	mesh_part* m_legs;
-	mesh_part* m_head;
-	mesh_part* m_weapon;
-	nv::program m_program;
-};
-
-application::application()
-{
-	NV_PROFILE( "app_construct" );
-	m_device  = new nv::gl_device();
-	m_window  = m_device->create_window( 800, 600, false );
-	m_context = m_window->get_context();
-
-	nv::sampler sampler( nv::sampler::LINEAR, nv::sampler::REPEAT );
-	nv::image_data* data = m_device->create_image_data( "data/doom.png" );
-	m_diffuse  = m_device->create_texture( data->get_size(), nv::image_format( nv::RGBA, nv::UBYTE ), sampler, (void*)data->get_data() );
-	delete data;
-	data = m_device->create_image_data( "data/rocketl.png" );
-	m_diffuse_weapon = m_device->create_texture( data->get_size(), nv::image_format( nv::RGBA, nv::UBYTE ), sampler, (void*)data->get_data() );
-	delete data;
-
-	m_clear_state.buffers = nv::clear_state::COLOR_AND_DEPTH_BUFFER;
-	m_render_state.depth_test.enabled = true;
-	m_render_state.culling.enabled    = true;
-	m_render_state.blending.enabled   = false;
-	m_render_state.blending.src_rgb_factor   = nv::blending::SRC_ALPHA;
-	m_render_state.blending.dst_rgb_factor   = nv::blending::ONE_MINUS_SRC_ALPHA;
-	m_render_state.blending.src_alpha_factor = nv::blending::SRC_ALPHA;
-	m_render_state.blending.dst_alpha_factor = nv::blending::ONE_MINUS_SRC_ALPHA;
-}
-
-bool application::initialize()
-{
-	NV_PROFILE( "app_initialize" );
-	m_program = m_device->create_program( 
-		nv::slurp( GPU_ANIMATION ? "obj_gpu.vert" : "obj_cpu.vert" ), 
-		nv::slurp( "obj.frag" ) 
-	);
-	m_torso   = new mesh_part( "data/upper.md3", m_window );
-	m_legs    = new mesh_part( "data/lower.md3", m_window );
-	m_head    = new mesh_part( "data/head.md3", m_window );
-	m_weapon  = new mesh_part( "data/rocketl.md3", m_window );
-	return true;
-}
-
-bool application::run()
-{
-	nv::profiler::pointer()->log_report(); 
-	NV_PROFILE( "app_run" );
-	int keypress = 0;
-
-	glm::vec3 move( 0, 0, 0 );
-
-	nv::uint32 ticks   = m_device->get_ticks();
-	nv::uint32 last_ticks;
-	nv::fps_counter_class< nv::system_us_timer > fps_counter;
-
-	m_legs->setup_animation( 0, m_legs->get_max_frames(), 20, true );
-	m_torso->setup_animation( 0, m_torso->get_max_frames(), 20, true );
-
-	bool common = true;
-	while(!keypress) 
-	{
-		last_ticks = ticks;
-		ticks      = m_device->get_ticks();
-		nv::uint32 elapsed = ticks - last_ticks;
-		m_torso->update( ticks, m_program );
-		m_legs->update( ticks, m_program );
-		{
-			NV_PROFILE( "clear" );
-			m_context->clear( m_clear_state );
-		}
-
-		glm::mat4 view;
-		glm::mat4 projection;
-		{
-			NV_PROFILE( "update_sh" );
-
-			glm::vec3 source( 80.0f, 0.0f, 0.0f );
-			glm::vec3 eye = glm::rotate( source, (ticks / 20.f), glm::vec3( 0.0,1.0,0.0 ) );
-
-			m_scene_state.get_camera().set_lookat(eye + move, glm::vec3(0.0f, 0.0f, 0.0f) + move, glm::vec3(0.0, 1.0, 0.0));
-			m_scene_state.get_camera().set_perspective(60.0f, 1.0f*800.0f/600.0f, 0.1f, 1000.0f);
-
-			m_context->bind( m_diffuse, nv::TEX_DIFFUSE );
-			m_device->set_uniform( m_program, "light_position", glm::vec3(120.0, 120.0, 0) );
-			m_device->set_uniform( m_program, "light_diffuse",  glm::vec4(1.0,1.0,1.0,1.0) );
-			m_device->set_uniform( m_program, "light_specular", glm::vec4(1.0,1.0,1.0,1.0) );
-		}
-
-		{
-			NV_PROFILE( "draw" );
-			glm::mat4 model      = glm::mat4(1.0f);
-
-			m_scene_state.set_model( model );
-			m_window->get_context()->draw( nv::TRIANGLES, m_render_state, m_scene_state, m_program, m_legs->get_mesh()->get_vertex_array(), m_legs->get_mesh()->get_index_count() );
-
-			//model = m_legs->get_transform( "tag_torso", last_legs_frame, legs_frame, legs_interpolate );
-			model = m_legs->get_transform( 0 );
-			m_scene_state.set_model( model );
-			m_window->get_context()->draw( nv::TRIANGLES, m_render_state, m_scene_state, m_program, m_torso->get_mesh()->get_vertex_array(), m_torso->get_mesh()->get_index_count() );
-
-			glm::mat4 head = model * m_torso->get_transform( 0 ); //, last_torso_frame, torso_frame, torso_interpolate );
-			m_scene_state.set_model( head );
-			m_window->get_context()->draw( nv::TRIANGLES, m_render_state, m_scene_state, m_program, m_head->get_mesh()->get_vertex_array(), m_head->get_mesh()->get_index_count() );
-
-			glm::mat4 weapon = model * m_torso->get_transform( 2 ); //, last_torso_frame, torso_frame, torso_interpolate );
-			m_scene_state.set_model( weapon );
-			m_context->bind( m_diffuse_weapon, nv::TEX_DIFFUSE );
-			m_context->draw( nv::TRIANGLES, m_render_state, m_scene_state, m_program, m_weapon->get_mesh()->get_vertex_array(), m_weapon->get_mesh()->get_index_count() );
-
-		}
-
-		{
-			NV_PROFILE( "swap" );
-			m_window->swap_buffers();
-		}
-
-		{
-			NV_PROFILE( "pollevent" );
-			nv::io_event event;
-			while(m_window->poll_event(event)) 
-			{      
-				switch (event.type) 
-				{
-				case nv::EV_QUIT:
-					keypress = 1;
-					break;
-				case nv::EV_KEY:
-					if (event.key.pressed)
-					{
-						switch (event.key.code) 
-						{
-						case nv::KEY_ESCAPE : keypress = 1; break;
-						case nv::KEY_1 : m_legs->setup_animation( 0, 89, 20, true ); m_torso->setup_animation( 0, 89, 20, true ); common = true; break;
-						case nv::KEY_2 : m_legs->setup_animation( 90, 8, 20, true ); if (common) m_torso->setup_animation( 151, 1, 20, true ); common = false; break;
-						case nv::KEY_3 : m_legs->setup_animation( 98, 12, 20, true ); if (common) m_torso->setup_animation( 151, 1, 20, true ); common = false; break;
-						case nv::KEY_4 : m_legs->setup_animation( 110, 9, 15, true ); if (common) m_torso->setup_animation( 151, 1, 20, true ); common = false; break;
-						case nv::KEY_5 : m_legs->setup_animation( 138, 10, 15, true ); if (common) m_torso->setup_animation( 151, 1, 20, true ); common = false; break;
-						case nv::KEY_6 : m_legs->setup_animation( 171, 9, 15, true ); if (common) m_torso->setup_animation( 151, 1, 20, true ); common = false; break;
-						case nv::KEY_Q : m_torso->setup_animation( 90, 40, 20, true ); if (common) m_legs->setup_animation( 171, 10, 15, true ); common = false; break;
-						case nv::KEY_W : m_torso->setup_animation( 130, 6, 15, true ); if (common) m_legs->setup_animation( 171, 10, 15, true ); common = false; break;
-						case nv::KEY_E : m_torso->setup_animation( 136, 6, 15, true ); if (common) m_legs->setup_animation( 171, 10, 15, true ); common = false; break;
-						case nv::KEY_R : m_torso->setup_animation( 142, 5, 20, true ); if (common) m_legs->setup_animation( 171, 10, 15, true ); common = false; break;
-						case nv::KEY_T : m_torso->setup_animation( 147, 4, 20, true ); if (common) m_legs->setup_animation( 171, 10, 15, true ); common = false; break;
-						case nv::KEY_Y : m_torso->setup_animation( 151, 1, 15, true ); if (common) m_legs->setup_animation( 171, 10, 15, true ); common = false; break;
-						case nv::KEY_U : m_torso->setup_animation( 152, 1, 15, true ); if (common) m_legs->setup_animation( 171, 10, 15, true ); common = false; break;
-						case nv::KEY_F1 : nv::profiler::pointer()->log_report(); break;
-						default: break;
-						}
-					}
-					break;
-				default: break;
-				}
-			}
-		}
-		fps_counter.tick();
-	}
-	return true;
-}
-
-application::~application()
-{
-	m_device->release( m_program );
-	delete m_torso;
-	delete m_legs;
-	delete m_head;
-	delete m_weapon;
-	m_device->release( m_diffuse );
-	m_device->release( m_diffuse_weapon );
-	delete m_window;
-	delete m_device;
-}
-
-
-int main(int, char* [])
-{
-	nv::logger log(nv::LOG_TRACE);
-	log.add_sink( new nv::log_file_sink("log.txt"), nv::LOG_TRACE );
-	log.add_sink( new nv::log_console_sink(), nv::LOG_TRACE );
-	
-	NV_LOG( nv::LOG_NOTICE, "Logging started" );
-	application app;
-	if ( app.initialize() )
-	{
-		app.run();
-	}
-	NV_LOG( nv::LOG_NOTICE, "Logging stopped" );
-
-	return 0;
-}
-
Index: /trunk/tests/md3_test/md3_test.lua
===================================================================
--- /trunk/tests/md3_test/md3_test.lua	(revision 321)
+++ /trunk/tests/md3_test/md3_test.lua	(revision 321)
@@ -0,0 +1,8 @@
+project "nv_md3_test"
+	kind "ConsoleApp"
+	files { "nv_md3_test.cc" }
+	includedirs { "../../" }
+	targetname "nv_md3_test"
+	links { "nv-core", "nv-gl", "nv-formats" }
+	targetdir "../../bin"	
+ 
Index: /trunk/tests/md3_test/nv_md3_test.cc
===================================================================
--- /trunk/tests/md3_test/nv_md3_test.cc	(revision 321)
+++ /trunk/tests/md3_test/nv_md3_test.cc	(revision 321)
@@ -0,0 +1,309 @@
+#include <nv/core/common.hh>
+#include <iomanip>
+#include <nv/gfx/keyframed_mesh.hh>
+#include <nv/gl/gl_device.hh>
+#include <nv/gfx/image.hh>
+#include <nv/interface/context.hh>
+#include <nv/interface/window.hh>
+#include <nv/interface/mesh_loader.hh>
+#include <nv/io/c_file_system.hh>
+#include <nv/formats/md3_loader.hh>
+#include <nv/core/profiler.hh>
+#include <nv/core/logging.hh>
+#include <nv/core/logger.hh>
+#include <nv/core/math.hh>
+#include <nv/core/time.hh>
+#include <nv/core/string.hh>
+#include <glm/gtx/rotate_vector.hpp>
+#include <glm/gtc/matrix_access.hpp>
+#include <glm/gtx/matrix_interpolation.hpp>
+
+bool GPU_ANIMATION = true;
+
+class mesh_part
+{
+public:
+	mesh_part( const std::string& path, nv::window* window )
+	{
+		NV_PROFILE("mesh_construct");
+		nv::md3_loader* loader;
+		{
+			NV_PROFILE("loader->load");
+			nv::c_file_system fs;
+			nv::stream* mesh_file = fs.open( path.c_str() );
+			loader = new nv::md3_loader();
+			loader->load( *mesh_file );
+			delete mesh_file;
+		}
+
+		{
+			NV_PROFILE("create_mesh_data");
+			m_mesh_data = loader->release_mesh_data_pack();
+		}
+		delete loader;
+		m_entry = nullptr;
+		{
+			NV_PROFILE("create_mesh");
+			if ( GPU_ANIMATION )
+				m_mesh      = new nv::keyframed_mesh_gpu( window->get_context(), m_mesh_data->get_mesh(0), m_mesh_data->get_nodes() );
+			else
+				m_mesh      = new nv::keyframed_mesh_cpu( window->get_context(), m_mesh_data->get_mesh(0), m_mesh_data->get_nodes() );
+		}
+
+	}
+
+	nv::mat4 get_transform( nv::uint32 id )
+	{
+		return m_mesh->get_node_transform( id ).extract();
+	}
+
+	void setup_animation( nv::uint32 start, nv::uint32 stop, nv::uint32 fps, bool loop )
+	{
+		delete m_entry;
+		m_entry = new nv::animation_entry("test", loop, fps, (float)start, float(stop-1) );
+		m_mesh->run_animation( m_entry );
+	}
+
+	void update( nv::uint32 ms )
+	{
+		m_mesh->update_animation( m_entry, ms );
+	}
+
+	void update( nv::program program )
+	{
+		m_mesh->update( program );
+	}
+
+	nv::mesh_interface* get_mesh() const { return m_mesh; }
+
+	size_t get_max_frames()
+	{
+		return m_mesh->get_max_frames();
+	}
+
+	~mesh_part()
+	{
+		delete m_mesh_data;
+		delete m_mesh;
+	}
+
+private:
+	nv::mesh_data_pack*  m_mesh_data;
+	nv::keyframed_mesh*  m_mesh;
+	nv::animation_entry* m_entry;
+};
+
+class application
+{
+public:
+	application();
+	bool initialize();
+	bool run();
+	~application();
+protected:
+	nv::device*       m_device;
+	nv::context*      m_context;
+	nv::window*       m_window;
+	nv::texture       m_diffuse;
+	nv::texture       m_diffuse_weapon;
+
+	nv::clear_state   m_clear_state;
+	nv::render_state  m_render_state;
+	nv::scene_state   m_scene_state;
+
+	mesh_part* m_torso;
+	mesh_part* m_legs;
+	mesh_part* m_head;
+	mesh_part* m_weapon;
+	nv::program m_program;
+};
+
+application::application()
+{
+	NV_PROFILE( "app_construct" );
+	m_device  = new nv::gl_device();
+	m_window  = m_device->create_window( 800, 600, false );
+	m_context = m_window->get_context();
+
+	nv::sampler sampler( nv::sampler::LINEAR, nv::sampler::REPEAT );
+	nv::image_data* data = m_device->create_image_data( "data/doom.png" );
+	m_diffuse  = m_device->create_texture( data->get_size(), nv::image_format( nv::RGBA, nv::UBYTE ), sampler, (void*)data->get_data() );
+	delete data;
+	data = m_device->create_image_data( "data/rocketl.png" );
+	m_diffuse_weapon = m_device->create_texture( data->get_size(), nv::image_format( nv::RGBA, nv::UBYTE ), sampler, (void*)data->get_data() );
+	delete data;
+
+	m_clear_state.buffers = nv::clear_state::COLOR_AND_DEPTH_BUFFER;
+	m_render_state.depth_test.enabled = true;
+	m_render_state.culling.enabled    = true;
+	m_render_state.blending.enabled   = false;
+	m_render_state.blending.src_rgb_factor   = nv::blending::SRC_ALPHA;
+	m_render_state.blending.dst_rgb_factor   = nv::blending::ONE_MINUS_SRC_ALPHA;
+	m_render_state.blending.src_alpha_factor = nv::blending::SRC_ALPHA;
+	m_render_state.blending.dst_alpha_factor = nv::blending::ONE_MINUS_SRC_ALPHA;
+}
+
+bool application::initialize()
+{
+	NV_PROFILE( "app_initialize" );
+	m_program = m_device->create_program( 
+		nv::slurp( GPU_ANIMATION ? "md3_gpu.vert" : "md3_cpu.vert" ), 
+		nv::slurp( "md3.frag" ) 
+	);
+	m_torso   = new mesh_part( "data/upper.md3", m_window );
+	m_legs    = new mesh_part( "data/lower.md3", m_window );
+	m_head    = new mesh_part( "data/head.md3", m_window );
+	m_weapon  = new mesh_part( "data/rocketl.md3", m_window );
+	return true;
+}
+
+bool application::run()
+{
+	nv::profiler::pointer()->log_report(); 
+	NV_PROFILE( "app_run" );
+	int keypress = 0;
+
+	glm::vec3 move( 0, 0, 0 );
+
+	nv::uint32 ticks   = m_device->get_ticks();
+	nv::uint32 last_ticks;
+	nv::fps_counter_class< nv::system_us_timer > fps_counter;
+
+	m_legs->setup_animation( 0, m_legs->get_max_frames(), 20, true );
+	m_torso->setup_animation( 0, m_torso->get_max_frames(), 20, true );
+
+	bool common = true;
+	while(!keypress) 
+	{
+		last_ticks = ticks;
+		ticks      = m_device->get_ticks();
+		m_torso->update( ticks );
+		m_legs->update( ticks );
+		{
+			NV_PROFILE( "clear" );
+			m_context->clear( m_clear_state );
+		}
+
+		glm::mat4 view;
+		glm::mat4 projection;
+		{
+			NV_PROFILE( "update_sh" );
+
+			glm::vec3 source( 80.0f, 0.0f, 0.0f );
+			glm::vec3 eye = glm::rotate( source, (ticks / 20.f), glm::vec3( 0.0,1.0,0.0 ) );
+
+			m_scene_state.get_camera().set_lookat(eye + move, glm::vec3(0.0f, 0.0f, 0.0f) + move, glm::vec3(0.0, 1.0, 0.0));
+			m_scene_state.get_camera().set_perspective(60.0f, 1.0f*800.0f/600.0f, 0.1f, 1000.0f);
+
+			m_context->bind( m_diffuse, nv::TEX_DIFFUSE );
+			m_device->set_uniform( m_program, "light_position", glm::vec3(120.0, 120.0, 0) );
+			m_device->set_uniform( m_program, "light_diffuse",  glm::vec4(1.0,1.0,1.0,1.0) );
+			m_device->set_uniform( m_program, "light_specular", glm::vec4(1.0,1.0,1.0,1.0) );
+		}
+
+		{
+			NV_PROFILE( "draw" );
+			glm::mat4 model      = glm::mat4(1.0f);
+
+			m_scene_state.set_model( model );
+			m_legs->update( m_program );
+			m_window->get_context()->draw( nv::TRIANGLES, m_render_state, m_scene_state, m_program, m_legs->get_mesh()->get_vertex_array(), m_legs->get_mesh()->get_index_count() );
+
+			//model = m_legs->get_transform( "tag_torso", last_legs_frame, legs_frame, legs_interpolate );
+			model = m_legs->get_transform( 0 );
+			m_scene_state.set_model( model );
+			m_torso->update( m_program );
+			m_window->get_context()->draw( nv::TRIANGLES, m_render_state, m_scene_state, m_program, m_torso->get_mesh()->get_vertex_array(), m_torso->get_mesh()->get_index_count() );
+
+			glm::mat4 head = model * m_torso->get_transform( 0 ); //, last_torso_frame, torso_frame, torso_interpolate );
+			m_scene_state.set_model( head );
+			m_head->update( m_program );
+			m_window->get_context()->draw( nv::TRIANGLES, m_render_state, m_scene_state, m_program, m_head->get_mesh()->get_vertex_array(), m_head->get_mesh()->get_index_count() );
+
+			glm::mat4 weapon = model * m_torso->get_transform( 2 ); //, last_torso_frame, torso_frame, torso_interpolate );
+			m_weapon->update( m_program );
+			m_scene_state.set_model( weapon );
+			m_context->bind( m_diffuse_weapon, nv::TEX_DIFFUSE );
+			m_context->draw( nv::TRIANGLES, m_render_state, m_scene_state, m_program, m_weapon->get_mesh()->get_vertex_array(), m_weapon->get_mesh()->get_index_count() );
+
+		}
+
+		{
+			NV_PROFILE( "swap" );
+			m_window->swap_buffers();
+		}
+
+		{
+			NV_PROFILE( "pollevent" );
+			nv::io_event event;
+			while(m_window->poll_event(event)) 
+			{      
+				switch (event.type) 
+				{
+				case nv::EV_QUIT:
+					keypress = 1;
+					break;
+				case nv::EV_KEY:
+					if (event.key.pressed)
+					{
+						switch (event.key.code) 
+						{
+						case nv::KEY_ESCAPE : keypress = 1; break;
+						case nv::KEY_1 : m_legs->setup_animation( 0, 89, 20, true ); m_torso->setup_animation( 0, 89, 20, true ); common = true; break;
+						case nv::KEY_2 : m_legs->setup_animation( 90, 8, 20, true ); if (common) m_torso->setup_animation( 151, 1, 20, true ); common = false; break;
+						case nv::KEY_3 : m_legs->setup_animation( 98, 12, 20, true ); if (common) m_torso->setup_animation( 151, 1, 20, true ); common = false; break;
+						case nv::KEY_4 : m_legs->setup_animation( 110, 9, 15, true ); if (common) m_torso->setup_animation( 151, 1, 20, true ); common = false; break;
+						case nv::KEY_5 : m_legs->setup_animation( 138, 10, 15, true ); if (common) m_torso->setup_animation( 151, 1, 20, true ); common = false; break;
+						case nv::KEY_6 : m_legs->setup_animation( 171, 9, 15, true ); if (common) m_torso->setup_animation( 151, 1, 20, true ); common = false; break;
+						case nv::KEY_Q : m_torso->setup_animation( 90, 40, 20, true ); if (common) m_legs->setup_animation( 171, 10, 15, true ); common = false; break;
+						case nv::KEY_W : m_torso->setup_animation( 130, 6, 15, true ); if (common) m_legs->setup_animation( 171, 10, 15, true ); common = false; break;
+						case nv::KEY_E : m_torso->setup_animation( 136, 6, 15, true ); if (common) m_legs->setup_animation( 171, 10, 15, true ); common = false; break;
+						case nv::KEY_R : m_torso->setup_animation( 142, 5, 20, true ); if (common) m_legs->setup_animation( 171, 10, 15, true ); common = false; break;
+						case nv::KEY_T : m_torso->setup_animation( 147, 4, 20, true ); if (common) m_legs->setup_animation( 171, 10, 15, true ); common = false; break;
+						case nv::KEY_Y : m_torso->setup_animation( 151, 1, 15, true ); if (common) m_legs->setup_animation( 171, 10, 15, true ); common = false; break;
+						case nv::KEY_U : m_torso->setup_animation( 152, 1, 15, true ); if (common) m_legs->setup_animation( 171, 10, 15, true ); common = false; break;
+						case nv::KEY_F1 : nv::profiler::pointer()->log_report(); break;
+						default: break;
+						}
+					}
+					break;
+				default: break;
+				}
+			}
+		}
+		fps_counter.tick();
+	}
+	return true;
+}
+
+application::~application()
+{
+	m_device->release( m_program );
+	delete m_torso;
+	delete m_legs;
+	delete m_head;
+	delete m_weapon;
+	m_device->release( m_diffuse );
+	m_device->release( m_diffuse_weapon );
+	delete m_window;
+	delete m_device;
+}
+
+
+int main(int, char* [])
+{
+	nv::logger log(nv::LOG_TRACE);
+	log.add_sink( new nv::log_file_sink("log.txt"), nv::LOG_TRACE );
+	log.add_sink( new nv::log_console_sink(), nv::LOG_TRACE );
+	
+	NV_LOG( nv::LOG_NOTICE, "Logging started" );
+	application app;
+	if ( app.initialize() )
+	{
+		app.run();
+	}
+	NV_LOG( nv::LOG_NOTICE, "Logging stopped" );
+
+	return 0;
+}
+
Index: /trunk/tests/md3_test/premake4.lua
===================================================================
--- /trunk/tests/md3_test/premake4.lua	(revision 321)
+++ /trunk/tests/md3_test/premake4.lua	(revision 321)
@@ -0,0 +1,18 @@
+solution "nv_md3_test"
+	configurations { "debug", "release" }
+
+  	language "C++"
+	flags { "ExtraWarnings", "NoPCH" }
+
+	configuration "debug"
+		defines { "DEBUG" }
+		flags { "Symbols", "StaticRuntime" }
+		objdir ("../../".._ACTION.."/debug")
+
+	configuration "release"
+		defines { "NDEBUG" }
+		flags { "Optimize", "StaticRuntime" }
+		objdir ("../../".._ACTION.."/release")
+
+	dofile("md3_test.lua")
+	dofile("../../nv.lua")
Index: /trunk/tests/md5_test/md5.frag
===================================================================
--- /trunk/tests/md5_test/md5.frag	(revision 321)
+++ /trunk/tests/md5_test/md5.frag	(revision 321)
@@ -0,0 +1,50 @@
+#version 120
+
+uniform sampler2D nv_t_diffuse;
+uniform sampler2D nv_t_specular;
+uniform sampler2D nv_t_normal;
+uniform vec4 light_diffuse;
+uniform vec4 light_specular;
+uniform mat4 nv_m_view_inv;
+
+varying vec2 v_texcoord;
+varying vec3 v_normal;
+varying vec3 v_light_vector;
+varying vec3 v_view_vector;
+varying vec4 v_position;
+varying mat3 v_m33_tangent;
+ 
+void main(void) {
+	vec2 texcoord         = v_texcoord;
+	//
+	vec4 encoded_normal   = texture2D( nv_t_normal, texcoord );
+	encoded_normal.y      = 1 - encoded_normal.y;
+	vec3 local_coords     = 2.0 * encoded_normal.rgb - vec3(1.0);
+	vec3 normal_direction = normalize(v_m33_tangent * local_coords);
+	vec3 view_direction   = normalize(vec3(nv_m_view_inv * vec4(0.0, 0.0, 0.0, 1.0) - v_position));
+	vec3 nnormal         = normal_direction;
+	//
+
+//	vec3 nnormal         = normalize( v_normal );
+	vec3 nlight_vector   = normalize( v_light_vector );
+	vec3 nview_vector    = normalize( v_view_vector );
+	vec3 nreflect_vector = reflect( -nlight_vector, nnormal );
+
+	float specular_value = clamp( dot( nreflect_vector, nview_vector ), 0.0, 1.0 );
+	specular_value       = pow( specular_value, 6.0 );
+	float diffuse_value  = max( dot( nlight_vector, nnormal ), 0.0 );
+
+	vec3 diff_texel      = vec3( texture2D( nv_t_diffuse, texcoord ) );	
+	vec4 spec_texel      = texture2D( nv_t_specular, texcoord );
+	
+	float specular_amount = spec_texel.x;
+	float diffuse_amount  = 1.0 - specular_amount;
+
+	float final_specular = specular_amount * specular_value;
+	float final_diffuse  = diffuse_amount  * diffuse_value;
+
+	vec3 diffuse_color   = light_diffuse.xyz  * final_diffuse * diff_texel;
+	vec3 specular_color  = light_specular.xyz * final_specular;
+
+	gl_FragColor = vec4( diffuse_color + specular_color, 1.0 );
+}
Index: /trunk/tests/md5_test/md5.vert
===================================================================
--- /trunk/tests/md5_test/md5.vert	(revision 321)
+++ /trunk/tests/md5_test/md5.vert	(revision 321)
@@ -0,0 +1,37 @@
+#version 120
+
+attribute vec2 nv_texcoord;
+attribute vec3 nv_position;
+attribute vec3 nv_normal;
+attribute vec3 nv_tangent;
+
+varying vec3 v_normal;
+varying vec3 v_light_vector;
+varying vec3 v_view_vector;
+varying vec4 v_position;
+varying vec2 v_texcoord;
+varying mat3 v_m33_tangent;
+
+uniform mat4 nv_m_model;
+uniform mat4 nv_m_modelview;
+uniform mat4 nv_m_projection;
+uniform mat3 nv_m_normal;
+uniform mat4 nv_m_mvp;
+uniform float nv_interpolate;
+uniform vec3 light_position;
+
+void main(void) {
+	vec4 vertex     = vec4( nv_position, 1.0 );
+	vec3 eye_pos    = vec3( nv_m_modelview * vertex );
+	v_normal        = normalize( nv_m_normal * nv_normal );
+	v_light_vector  = vec3( normalize( light_position - eye_pos ) );
+	v_view_vector   = vec3( normalize( -eye_pos ) );
+
+	v_m33_tangent[0] = normalize(nv_m_normal * nv_tangent);
+	v_m33_tangent[2] = v_normal;
+	v_m33_tangent[1] = normalize(cross(v_m33_tangent[2], v_m33_tangent[0]));
+
+	v_texcoord      = nv_texcoord;
+	v_position      = nv_m_model * vertex;
+	gl_Position     = nv_m_mvp * vertex;
+}
Index: unk/tests/md5_test/md5_test.cc
===================================================================
--- /trunk/tests/md5_test/md5_test.cc	(revision 320)
+++ 	(revision )
@@ -1,246 +1,0 @@
-#include <nv/common.hh>
-#include <iomanip>
-#include <nv/gfx/keyframed_mesh.hh>
-#include <nv/interface/vertex_buffer.hh>
-#include <nv/gl/gl_device.hh>
-#include <nv/gfx/image.hh>
-#include <nv/interface/context.hh>
-#include <nv/interface/window.hh>
-#include <nv/interface/program.hh>
-#include <nv/interface/texture2d.hh>
-#include <nv/interface/mesh_loader.hh>
-#include <nv/io/c_file_system.hh>
-#include <nv/formats/md5_loader.hh>
-#include <nv/profiler.hh>
-#include <nv/logging.hh>
-#include <nv/logger.hh>
-#include <nv/math.hh>
-#include <nv/time.hh>
-#include <nv/string.hh>
-#include <nv/gfx/skeletal_mesh.hh>
-#include <glm/gtx/rotate_vector.hpp>
-#include <glm/gtc/matrix_access.hpp>
-#include <glm/gtx/matrix_interpolation.hpp>
-
-class application
-{
-public:
-	application();
-	bool initialize();
-	bool run();
-	~application();
-protected:
-	void load_animation( const std::string& path );
-protected:
-
-
-	nv::device*       m_device;
-	nv::window*       m_window;
-	nv::texture2d*    m_diffuse;
-	nv::texture2d*    m_specular;
-	nv::texture2d*    m_normal;
-	nv::clear_state   m_clear_state;
-	nv::render_state  m_render_state;
-	nv::scene_state   m_scene_state;
-
-	nv::skeletal_mesh* m_mesh;
-	nv::program*       m_program;
-	nv::md5_mesh_data* m_mesh_data;
-	nv::md5_animation* m_animation;
-
-};
-
-application::application()
-{
-	NV_PROFILE( "app_construct" );
-	m_device = new nv::gl_device();
-	m_window = m_device->create_window( 800, 600, false );
-	m_animation = nullptr;
-
-	nv::sampler sampler( nv::sampler::LINEAR, nv::sampler::REPEAT );
-	nv::image_data* data = m_device->create_image_data( "data/qshambler_d.png" );
-	m_diffuse  = m_device->create_texture2d( data->get_size(), nv::RGBA, nv::UBYTE, sampler, (void*)data->get_data() );
-	delete data;
-	data = m_device->create_image_data( "data/qshambler_s.png" );
-	m_specular = m_device->create_texture2d( data->get_size(), nv::RGBA, nv::UBYTE, sampler, (void*)data->get_data() );
-	delete data;
-
-	data = m_device->create_image_data( "data/qshambler_local.png" );
-	m_normal = m_device->create_texture2d( data->get_size(), nv::RGBA, nv::UBYTE, sampler, (void*)data->get_data() );
-	delete data;
-
-	m_clear_state.buffers = nv::clear_state::COLOR_AND_DEPTH_BUFFER;
-	m_render_state.depth_test.enabled = true;
-	m_render_state.culling.enabled    = true;
-	m_render_state.culling.order      = nv::culling::CCW;
-	m_render_state.blending.enabled   = false;
-	m_render_state.blending.src_rgb_factor   = nv::blending::SRC_ALPHA;
-	m_render_state.blending.dst_rgb_factor   = nv::blending::ONE_MINUS_SRC_ALPHA;
-	m_render_state.blending.src_alpha_factor = nv::blending::SRC_ALPHA;
-	m_render_state.blending.dst_alpha_factor = nv::blending::ONE_MINUS_SRC_ALPHA;
-}
-
-bool application::initialize()
-{
-	NV_PROFILE( "app_initialize" );
-	m_program = m_device->create_program( nv::slurp( "md5.vert" ), nv::slurp( "md5.frag" ) );
-
-	nv::md5_loader* loader = nullptr;
-	{
-		NV_PROFILE("loader->load");
-		nv::c_file_system fs;
-		nv::stream* mesh_file = fs.open( "data/qshambler.md5mesh" );
-		loader = new nv::md5_loader();
-		loader->load( *mesh_file );
-		delete mesh_file;
-	}
-
-	{
-		NV_PROFILE("create_mesh");
-		m_mesh_data = (nv::md5_mesh_data*)loader->release_mesh_data();
-		m_mesh = new nv::skeletal_mesh( m_window->get_context(), m_mesh_data );
-		delete loader;
-	}
-
-	load_animation( "data/walk.md5anim" );
-	return true;
-}
-
-bool application::run()
-{
-	nv::profiler::pointer()->log_report(); 
-	NV_PROFILE( "app_run" );
-	int keypress = 0;
-
-	glm::vec3 move( 0, 50.f, 0 );
-
-	nv::uint32 ticks   = m_device->get_ticks();
-	nv::uint32 last_ticks;
-	nv::fps_counter_class< nv::system_us_timer > fps_counter;
-
-	//m_mesh->setup_animation( 0, m_mesh->get_max_frames(), 2, true );
-
-	while(!keypress) 
-	{
-		last_ticks = ticks;
-		ticks      = m_device->get_ticks();
-		nv::uint32 elapsed = ticks - last_ticks;
-		m_mesh->update( elapsed );
-		{
-			NV_PROFILE( "clear" );
-			m_window->get_context()->clear( m_clear_state );
-		}
-
-		{
-			NV_PROFILE( "update_sh" );
-
-			glm::vec3 source( 250.0f, 0.0f, 0.0f );
-			glm::vec3 eye = glm::rotate( source, (ticks / 20.f), glm::vec3( 0.0,1.0,0.0 ) );
-
-			m_scene_state.get_camera().set_lookat(eye + move, glm::vec3(0.0f, 0.0f, 0.0f) + move, glm::vec3(0.0, 1.0, 0.0));
-			m_scene_state.get_camera().set_perspective(60.0f, 1.0f*800.0f/600.0f, 0.1f, 1000.0f);
-
-			m_diffuse ->bind( 0 );
-			m_specular->bind( 1 );
-			m_normal  ->bind( 2 );
-			m_program->set_opt_uniform( "light_position", glm::vec3(180.0, 180.0, 0) );
-			m_program->set_opt_uniform( "light_diffuse",  glm::vec4(0.7,0.7,0.7,1.0) );
-			m_program->set_opt_uniform( "light_specular", glm::vec4(1.0,1.0,1.0,1.0) );
-		}
-
-		{
-			NV_PROFILE( "draw" );
-			m_scene_state.set_model(nv::mat4(
-				1.f,0.f,0.f,0.f,
-				0.f,0.f,1.f,0.f,
-				0.f,1.f,0.f,0.f,
-				0.f,0.f,0.f,1.f
-			) );
-
-			m_window->get_context()->draw( m_render_state, m_scene_state, m_program, m_mesh );
-		}
-
-		{
-			NV_PROFILE( "swap" );
-			m_window->swap_buffers();
-		}
-
-		{
-			NV_PROFILE( "pollevent" );
-			nv::io_event event;
-			while(m_window->poll_event(event)) 
-			{      
-				switch (event.type) 
-				{
-				case nv::EV_QUIT:
-					keypress = 1;
-					break;
-				case nv::EV_KEY:
-					if (event.key.pressed)
-					{
-						switch (event.key.code) 
-						{
-						case nv::KEY_ESCAPE : keypress = 1; break;
-						case nv::KEY_F1 : nv::profiler::pointer()->log_report(); break;
-						default: break;
-						}
-					}
-					break;
-				default: break;
-				}
-			}
-		}
-		fps_counter.tick();
-	}
-	return true;
-}
-
-void application::load_animation( const std::string& path )
-{
-	delete m_animation;
-	m_animation = nullptr;
-	NV_PROFILE("load_animation");
-	nv::c_file_system fs;
-	nv::stream* anim_file = fs.open( path.c_str() );
-
-	if ( anim_file != nullptr )
-	{
-		m_animation = new nv::md5_animation();
-		if ( !m_animation->load_animation(*anim_file) )
-		{
-			delete m_animation;
-			m_animation = nullptr;
-		}
-		m_mesh->setup_animation( m_animation );
-		delete anim_file;
-	}
-}
-
-
-application::~application()
-{
-	delete m_program;
-	delete m_mesh;
-	delete m_diffuse;
-	delete m_window;
-	delete m_device;
-}
-
-
-int main(int, char* [])
-{
-	nv::logger log(nv::LOG_TRACE);
-	log.add_sink( new nv::log_file_sink("log.txt"), nv::LOG_TRACE );
-	log.add_sink( new nv::log_console_sink(), nv::LOG_TRACE );
-	
-	NV_LOG( nv::LOG_NOTICE, "Logging started" );
-	application app;
-	if ( app.initialize() )
-	{
-		app.run();
-	}
-	NV_LOG( nv::LOG_NOTICE, "Logging stopped" );
-
-	return 0;
-}
-
Index: /trunk/tests/md5_test/md5_test.lua
===================================================================
--- /trunk/tests/md5_test/md5_test.lua	(revision 321)
+++ /trunk/tests/md5_test/md5_test.lua	(revision 321)
@@ -0,0 +1,8 @@
+project "nv_md5_test"
+	kind "ConsoleApp"
+	files { "nv_md5_test.cc" }
+	includedirs { "../../" }
+	targetname "nv_md5_test"
+	links { "nv-core", "nv-gl", "nv-formats" }
+	targetdir "../../bin"	
+ 
Index: /trunk/tests/md5_test/nv_md5_test.cc
===================================================================
--- /trunk/tests/md5_test/nv_md5_test.cc	(revision 321)
+++ /trunk/tests/md5_test/nv_md5_test.cc	(revision 321)
@@ -0,0 +1,240 @@
+#include <nv/core/common.hh>
+#include <iomanip>
+#include <nv/gfx/keyframed_mesh.hh>
+#include <nv/gl/gl_device.hh>
+#include <nv/gfx/image.hh>
+#include <nv/interface/context.hh>
+#include <nv/interface/window.hh>
+#include <nv/interface/mesh_loader.hh>
+#include <nv/io/c_file_system.hh>
+#include <nv/formats/md5_loader.hh>
+#include <nv/core/profiler.hh>
+#include <nv/core/logging.hh>
+#include <nv/core/logger.hh>
+#include <nv/core/math.hh>
+#include <nv/core/time.hh>
+#include <nv/core/string.hh>
+#include <nv/gfx/skeletal_mesh.hh>
+#include <glm/gtx/rotate_vector.hpp>
+#include <glm/gtc/matrix_access.hpp>
+#include <glm/gtx/matrix_interpolation.hpp>
+
+class application
+{
+public:
+	application();
+	bool initialize();
+	bool run();
+	~application();
+protected:
+	void load_animation( const std::string& path );
+protected:
+
+
+	nv::device*       m_device;
+	nv::window*       m_window;
+	nv::context*      m_context;
+	nv::texture       m_diffuse;
+	nv::texture       m_specular;
+	nv::texture       m_normal;
+	nv::clear_state   m_clear_state;
+	nv::render_state  m_render_state;
+	nv::scene_state   m_scene_state;
+
+	nv::skeletal_mesh* m_mesh;
+	nv::program        m_program;
+	nv::mesh_data*       m_mesh_data;
+	nv::animation_entry* m_animation;
+
+};
+
+application::application()
+{
+	NV_PROFILE( "app_construct" );
+	m_device  = new nv::gl_device();
+	m_window  = m_device->create_window( 800, 600, false );
+	m_context = m_window->get_context();
+	m_animation = nullptr;
+
+	nv::sampler sampler( nv::sampler::LINEAR, nv::sampler::REPEAT );
+	nv::image_data* data = m_device->create_image_data( "data/qshambler_d.png" );
+	m_diffuse  = m_device->create_texture( data, sampler );
+	delete data;
+	data = m_device->create_image_data( "data/qshambler_s.png" );
+	m_specular = m_device->create_texture( data, sampler );
+	delete data;
+
+	data = m_device->create_image_data( "data/qshambler_local.png" );
+	m_normal = m_device->create_texture( data, sampler );
+	delete data;
+
+	m_clear_state.buffers = nv::clear_state::COLOR_AND_DEPTH_BUFFER;
+	m_render_state.depth_test.enabled = true;
+	m_render_state.culling.enabled    = true;
+	m_render_state.culling.order      = nv::culling::CCW;
+	m_render_state.blending.enabled   = false;
+	m_render_state.blending.src_rgb_factor   = nv::blending::SRC_ALPHA;
+	m_render_state.blending.dst_rgb_factor   = nv::blending::ONE_MINUS_SRC_ALPHA;
+	m_render_state.blending.src_alpha_factor = nv::blending::SRC_ALPHA;
+	m_render_state.blending.dst_alpha_factor = nv::blending::ONE_MINUS_SRC_ALPHA;
+}
+
+bool application::initialize()
+{
+	NV_PROFILE( "app_initialize" );
+	m_program = m_device->create_program( nv::slurp( "md5.vert" ), nv::slurp( "md5.frag" ) );
+
+	nv::md5_loader* loader = nullptr;
+	{
+		NV_PROFILE("loader->load");
+		nv::c_file_system fs;
+		nv::stream* mesh_file = fs.open( "data/qshambler.md5mesh" );
+		loader = new nv::md5_loader();
+		loader->load( *mesh_file );
+		delete mesh_file;
+	}
+
+	{
+		NV_PROFILE("create_mesh");
+		m_mesh_data = loader->release_mesh_data();
+		m_mesh = new nv::skeletal_mesh_cpu( m_context, m_mesh_data, loader->release_mesh_nodes_data() );
+		delete loader;
+	}
+
+	load_animation( "data/walk.md5anim" );
+	return true;
+}
+
+bool application::run()
+{
+	nv::profiler::pointer()->log_report(); 
+	NV_PROFILE( "app_run" );
+	int keypress = 0;
+
+	glm::vec3 move( 0, 50.f, 0 );
+
+	nv::uint32 ticks   = m_device->get_ticks();
+	nv::uint32 last_ticks;
+	nv::fps_counter_class< nv::system_us_timer > fps_counter;
+
+	//m_mesh->setup_animation( 0, m_mesh->get_max_frames(), 2, true );
+
+	while(!keypress) 
+	{
+		last_ticks = ticks;
+		ticks      = m_device->get_ticks();
+		m_mesh->update_animation( m_animation, ticks );
+		m_context->clear( m_clear_state );
+
+		{
+			NV_PROFILE( "update_sh" );
+
+			glm::vec3 source( 250.0f, 0.0f, 0.0f );
+			glm::vec3 eye = glm::rotate( source, (ticks / 20.f), glm::vec3( 0.0,1.0,0.0 ) );
+
+			m_scene_state.get_camera().set_lookat(eye + move, glm::vec3(0.0f, 0.0f, 0.0f) + move, glm::vec3(0.0, 1.0, 0.0));
+			m_scene_state.get_camera().set_perspective(60.0f, 1.0f*800.0f/600.0f, 0.1f, 1000.0f);
+
+			m_context->bind( m_diffuse,  nv::TEX_DIFFUSE );
+			m_context->bind( m_specular, nv::TEX_SPECULAR );
+			m_context->bind( m_normal,   nv::TEX_NORMAL );
+			m_device->set_opt_uniform( m_program, "light_position", glm::vec3(180.0, 180.0, 0) );
+			m_device->set_opt_uniform( m_program, "light_diffuse",  glm::vec4(0.7,0.7,0.7,1.0) );
+			m_device->set_opt_uniform( m_program, "light_specular", glm::vec4(1.0,1.0,1.0,1.0) );
+		}
+
+		{
+			NV_PROFILE( "draw" );
+			m_scene_state.set_model(nv::mat4(
+				1.f,0.f,0.f,0.f,
+				0.f,0.f,1.f,0.f,
+				0.f,1.f,0.f,0.f,
+				0.f,0.f,0.f,1.f
+			) );
+
+			m_mesh->update( m_program );
+			m_context->draw( nv::TRIANGLES, m_render_state, m_scene_state, m_program, m_mesh->get_vertex_array(), m_mesh->get_index_count() );
+		}
+
+		{
+			NV_PROFILE( "swap" );
+			m_window->swap_buffers();
+		}
+
+		{
+			NV_PROFILE( "pollevent" );
+			nv::io_event event;
+			while(m_window->poll_event(event)) 
+			{      
+				switch (event.type) 
+				{
+				case nv::EV_QUIT:
+					keypress = 1;
+					break;
+				case nv::EV_KEY:
+					if (event.key.pressed)
+					{
+						switch (event.key.code) 
+						{
+						case nv::KEY_ESCAPE : keypress = 1; break;
+						case nv::KEY_F1 : nv::profiler::pointer()->log_report(); break;
+						default: break;
+						}
+					}
+					break;
+				default: break;
+				}
+			}
+		}
+		fps_counter.tick();
+	}
+	return true;
+}
+
+void application::load_animation( const std::string& path )
+{
+	delete m_animation;
+	m_animation = nullptr;
+	NV_PROFILE("load_animation");
+	nv::c_file_system fs;
+	nv::stream* anim_file = fs.open( path.c_str() );
+
+	if ( anim_file != nullptr )
+	{
+		nv::md5_loader* loader = new nv::md5_loader();
+		loader->load( *anim_file );
+		delete anim_file;
+		m_animation = new nv::skeletal_animation_entry_cpu( "", loader->release_mesh_nodes_data(), true );
+		m_mesh->run_animation( m_animation );
+		delete loader;
+	}
+}
+
+
+application::~application()
+{
+	m_device->release( m_program );
+	delete m_mesh;
+	m_device->release( m_diffuse );
+	delete m_window;
+	delete m_device;
+}
+
+
+int main(int, char* [])
+{
+	nv::logger log(nv::LOG_TRACE);
+	log.add_sink( new nv::log_file_sink("log.txt"), nv::LOG_TRACE );
+	log.add_sink( new nv::log_console_sink(), nv::LOG_TRACE );
+	
+	NV_LOG( nv::LOG_NOTICE, "Logging started" );
+	application app;
+	if ( app.initialize() )
+	{
+		app.run();
+	}
+	NV_LOG( nv::LOG_NOTICE, "Logging stopped" );
+
+	return 0;
+}
+
Index: /trunk/tests/md5_test/premake4.lua
===================================================================
--- /trunk/tests/md5_test/premake4.lua	(revision 321)
+++ /trunk/tests/md5_test/premake4.lua	(revision 321)
@@ -0,0 +1,18 @@
+solution "nv_md5_test"
+	configurations { "debug", "release" }
+
+  	language "C++"
+	flags { "ExtraWarnings", "NoPCH" }
+
+	configuration "debug"
+		defines { "DEBUG" }
+		flags { "Symbols", "StaticRuntime" }
+		objdir ("../../".._ACTION.."/debug")
+
+	configuration "release"
+		defines { "NDEBUG" }
+		flags { "Optimize", "StaticRuntime" }
+		objdir ("../../".._ACTION.."/release")
+
+	dofile("md5_test.lua")
+	dofile("../../nv.lua")
Index: /trunk/tests/objload_test/nv_objload_test.cc
===================================================================
--- /trunk/tests/objload_test/nv_objload_test.cc	(revision 321)
+++ /trunk/tests/objload_test/nv_objload_test.cc	(revision 321)
@@ -0,0 +1,157 @@
+#include <nv/gl/gl_device.hh>
+#include <nv/gfx/image.hh>
+#include <nv/interface/context.hh>
+#include <nv/interface/window.hh>
+#include <nv/interface/mesh_loader.hh>
+#include <nv/io/c_file_system.hh>
+#include <nv/formats/obj_loader.hh>
+#include <nv/core/logging.hh>
+#include <nv/core/logger.hh>
+#include <nv/core/math.hh>
+#include <nv/core/string.hh>
+
+class application
+{
+public:
+	application();
+	bool initialize();
+	bool run();
+	~application();
+protected:
+	nv::device*       m_device;
+	nv::context*      m_context;
+	nv::window*       m_window;
+	nv::texture       m_diffuse;
+	nv::texture       m_specular;
+	nv::scene_state   m_scene_state;
+	nv::clear_state   m_clear_state;
+	nv::render_state  m_render_state;
+
+	nv::vertex_array  m_va;
+	nv::program       m_program;
+	nv::mesh_data*    m_mesh;
+};
+
+application::application()
+{
+	m_device = new nv::gl_device();
+	m_window = m_device->create_window( 800, 600, false );
+	m_context = m_window->get_context();
+
+	nv::sampler sampler( nv::sampler::LINEAR, nv::sampler::REPEAT );
+
+	nv::image_data* image = m_device->create_image_data( "diffuse.png" );
+	m_diffuse  = m_device->create_texture( image, sampler );
+	delete image;
+
+	image      = m_device->create_image_data( "specular.png" );
+	m_specular = m_device->create_texture( image, sampler );
+	delete image;
+
+	m_clear_state.buffers = nv::clear_state::COLOR_AND_DEPTH_BUFFER;
+	m_render_state.depth_test.enabled = true;
+	m_render_state.culling.enabled    = true;
+	m_render_state.blending.enabled   = false;
+	m_render_state.blending.src_rgb_factor   = nv::blending::SRC_ALPHA;
+	m_render_state.blending.dst_rgb_factor   = nv::blending::ONE_MINUS_SRC_ALPHA;
+	m_render_state.blending.src_alpha_factor = nv::blending::SRC_ALPHA;
+	m_render_state.blending.dst_alpha_factor = nv::blending::ONE_MINUS_SRC_ALPHA;
+}
+
+bool application::initialize()
+{
+	nv::c_file_system fs;
+	nv::stream* mesh_file = fs.open( "mesh.obj" );
+
+	nv::obj_loader* loader = new nv::obj_loader();
+	loader->load( *mesh_file );
+	m_mesh = loader->release_mesh_data();
+	delete mesh_file;
+	delete loader;
+
+	m_program = m_device->create_program( nv::slurp( "obj.vert" ), nv::slurp( "obj.frag" ) );
+	m_va = m_context->create_vertex_array( m_mesh, nv::STATIC_DRAW );
+
+	return true;
+}
+
+bool application::run()
+{
+	int keypress = 0;
+
+	glm::vec3 move( 0, 0, 0 );
+
+	while(!keypress) 
+	{
+		m_window->get_context()->clear( m_clear_state );
+		m_scene_state.set_model( glm::mat4() );
+		m_scene_state.get_camera().set_perspective(60.0f, 1.0f*800.0f/600.0f, 0.1f, 1000.0f);
+		m_scene_state.get_camera().set_lookat(glm::vec3(6.0f, 8.0f, 6.0f) + move, glm::vec3(0.0f, 4.0f, 0.0f) + move, glm::vec3(0.0, 1.0, 0.0));
+
+		m_context->bind( m_diffuse, nv::TEX_DIFFUSE );
+		m_context->bind( m_specular, nv::TEX_SPECULAR );
+		m_device->set_uniform( m_program, "light_position", glm::vec3(12.0, 12.0, 0) );
+		m_device->set_uniform( m_program, "light_diffuse",  glm::vec4(0.7,0.7,0.7,1.0) );
+		m_device->set_uniform( m_program, "light_specular", glm::vec4(1.0,1.0,1.0,1.0) );
+		m_device->set_uniform( m_program, "custom_color_1", glm::vec3(1.0,0.0,0.0) );
+		m_device->set_uniform( m_program, "custom_color_2", glm::vec3(0.0,0.0,1.0) );
+		m_context->draw( nv::TRIANGLES, m_render_state, m_scene_state, m_program, m_va, m_mesh->get_count() );
+		m_window->swap_buffers();
+
+		nv::io_event event;
+		while(m_window->poll_event(event)) 
+		{      
+			switch (event.type) 
+			{
+			case nv::EV_QUIT:
+				keypress = 1;
+				break;
+			case nv::EV_KEY:
+				if (event.key.pressed)
+				{
+					switch (event.key.code) 
+					{
+					case nv::KEY_ESCAPE : keypress = 1; break;
+					case nv::KEY_LEFT   : move.x = move.x - 1.0f; break;
+					case nv::KEY_RIGHT  : move.x = move.x + 1.0f; break;
+					case nv::KEY_UP     : move.z = move.z - 1.0f; break;
+					case nv::KEY_DOWN   : move.z = move.z + 1.0f; break;
+					default: break;
+					}
+				}
+				break;
+			default: break;
+			}
+		}
+	}
+	return true;
+}
+
+application::~application()
+{
+	delete m_mesh;
+	m_device->release( m_program );
+	m_device->release( m_diffuse );
+	m_device->release( m_specular );
+	delete m_window;
+	delete m_device;
+}
+
+
+int main(int, char* [])
+{
+	nv::logger log(nv::LOG_TRACE);
+	log.add_sink( new nv::log_file_sink("log.txt"), nv::LOG_TRACE );
+	log.add_sink( new nv::log_console_sink(), nv::LOG_TRACE );
+	
+	NV_LOG( nv::LOG_NOTICE, "Logging started" );
+	application app;
+	if ( app.initialize() )
+	{
+		app.run();
+	}
+	NV_LOG( nv::LOG_NOTICE, "Logging stopped" );
+
+	return 0;
+}
+
Index: /trunk/tests/objload_test/obj.frag
===================================================================
--- /trunk/tests/objload_test/obj.frag	(revision 320)
+++ /trunk/tests/objload_test/obj.frag	(revision 321)
@@ -1,6 +1,6 @@
 #version 120
 
-uniform sampler2D diffuse;
-uniform sampler2D specular;
+uniform sampler2D nv_diffuse;
+uniform sampler2D nv_specular;
 uniform vec4 light_diffuse;
 uniform vec4 light_specular;
@@ -23,6 +23,6 @@
 	float diffuse_value  = max( dot( nlight_vector, nnormal ), 0.0 );
 
-	vec3 diff_texel      = vec3( texture2D( diffuse, v_texcoord ) );	
-	vec4 spec_texel      = texture2D( specular, v_texcoord );
+	vec3 diff_texel      = vec3( texture2D( nv_diffuse, v_texcoord ) );	
+	vec4 spec_texel      = texture2D( nv_specular, v_texcoord );
 	
 	float specular_amount = spec_texel.x;
Index: /trunk/tests/objload_test/obj.vert
===================================================================
--- /trunk/tests/objload_test/obj.vert	(revision 320)
+++ /trunk/tests/objload_test/obj.vert	(revision 321)
@@ -10,5 +10,5 @@
 varying vec2 v_texcoord;
 
-uniform mat4 matrix_mvp;
+uniform mat4 nv_m_mvp;
 uniform mat4 nv_m_modelview;
 uniform mat4 nv_m_projection;
@@ -24,4 +24,4 @@
 
 	v_texcoord      = nv_texcoord;
-	gl_Position     = matrix_mvp * vertex;
+	gl_Position     = nv_m_mvp * vertex;
 }
Index: unk/tests/objload_test/objload_test.cc
===================================================================
--- /trunk/tests/objload_test/objload_test.cc	(revision 320)
+++ 	(revision )
@@ -1,174 +1,0 @@
-#include <nv/interface/vertex_buffer.hh>
-#include <nv/gl/gl_device.hh>
-#include <nv/gfx/image.hh>
-#include <nv/interface/context.hh>
-#include <nv/interface/window.hh>
-#include <nv/interface/program.hh>
-#include <nv/interface/texture2d.hh>
-#include <nv/interface/mesh_loader.hh>
-#include <nv/io/c_file_system.hh>
-#include <nv/formats/obj_loader.hh>
-#include <nv/logging.hh>
-#include <nv/logger.hh>
-#include <nv/math.hh>
-#include <nv/string.hh>
-
-class application
-{
-public:
-	application();
-	bool initialize();
-	bool run();
-	~application();
-protected:
-	nv::device*       m_device;
-	nv::window*       m_window;
-	nv::texture2d*    m_diffuse;
-	nv::texture2d*    m_specular;
-	nv::clear_state   m_clear_state;
-	nv::render_state  m_render_state;
-
-	nv::vertex_array* m_va;
-	nv::program*      m_program;
-	nv::mesh_data*    m_mesh;
-};
-
-application::application()
-{
-	m_device = new nv::gl_device();
-	m_window = m_device->create_window( 800, 600, false );
-	nv::sampler sampler( nv::sampler::LINEAR, nv::sampler::REPEAT );
-	
-	nv::image_data* sprites = m_device->create_image_data( "diffuse.png" );
-	m_diffuse  = m_device->create_texture2d( sprites->get_size(), nv::RGBA, nv::UBYTE, sampler, (void*)sprites->get_data() );
-	delete sprites;
-
-	sprites    = m_device->create_image_data( "specular.png" );
-	m_specular = m_device->create_texture2d( sprites->get_size(), nv::RGBA, nv::UBYTE, sampler, (void*)sprites->get_data() );
-	delete sprites;
-
-	m_clear_state.buffers = nv::clear_state::COLOR_AND_DEPTH_BUFFER;
-	m_render_state.depth_test.enabled = true;
-	m_render_state.culling.enabled    = true;
-	m_render_state.blending.enabled   = false;
-	m_render_state.blending.src_rgb_factor   = nv::blending::SRC_ALPHA;
-	m_render_state.blending.dst_rgb_factor   = nv::blending::ONE_MINUS_SRC_ALPHA;
-	m_render_state.blending.src_alpha_factor = nv::blending::SRC_ALPHA;
-	m_render_state.blending.dst_alpha_factor = nv::blending::ONE_MINUS_SRC_ALPHA;
-}
-
-bool application::initialize()
-{
-	nv::c_file_system fs;
-	nv::stream* mesh_file = fs.open( "mesh.obj" );
-
-// 		nv::mesh_loader* loader = new nv::obj_loader();
-// 		loader->load( *mesh_file );
-// 		nv::mesh_data_old* mesh = loader->release_mesh_data();
-// 		m_count = loader->get_size();
-// 		delete mesh_file;
-// 		delete loader;
-
-	nv::obj_loader* loader = new nv::obj_loader();
-	loader->load( *mesh_file );
-	m_mesh = loader->release_mesh_data();
-	delete mesh_file;
-	delete loader;
-
-	m_program = m_device->create_program( nv::slurp( "obj.vert" ), nv::slurp( "obj.frag" ) );
-
-//	nv::vertex_buffer* vb = nullptr;
-	m_va = m_device->create_vertex_array( m_mesh, nv::STATIC_DRAW );
-
-	return true;
-}
-
-bool application::run()
-{
-	int keypress = 0;
-
-	glm::vec3 move( 0, 0, 0 );
-
-	while(!keypress) 
-	{
-		m_window->get_context()->clear( m_clear_state );
-
-		glm::mat4 model = glm::translate(glm::mat4(1.0f), glm::vec3(0.0f, 0.0f, 0.0f));
-		glm::mat4 view  = glm::lookAt(glm::vec3(6.0f, 8.0f, 6.0f) + move, glm::vec3(0.0f, 4.0f, 0.0f) + move, glm::vec3(0.0, 1.0, 0.0));
-		glm::mat4 projection = glm::perspective(60.0f, 1.0f*800.0f/600.0f, 0.1f, 1000.0f);
-		glm::mat4 mv         = view * model;
-		glm::mat3 normal_matrix = glm::transpose(glm::inverse(glm::mat3(mv)));
-
-		m_diffuse->bind( 0 );
-		m_specular->bind( 1 );
-		m_program->set_opt_uniform( "nv_m_modelview", mv );
-		m_program->set_opt_uniform( "nv_m_projection", projection );
-		m_program->set_opt_uniform( "nv_m_normal", normal_matrix );
-		m_program->set_uniform( "matrix_mvp", projection * mv );
-		m_program->set_uniform( "light_position", glm::vec3(12.0, 12.0, 0) );
-		m_program->set_uniform( "light_diffuse",  glm::vec4(0.7,0.7,0.7,1.0) );
-		m_program->set_uniform( "light_specular", glm::vec4(1.0,1.0,1.0,1.0) );
-		m_program->set_uniform( "custom_color_1", glm::vec3(1.0,0.0,0.0) );
-		m_program->set_uniform( "custom_color_2", glm::vec3(0.0,0.0,1.0) );
-		m_program->set_uniform( "diffuse", 0 );
-		m_program->set_uniform( "specular", 1 );
-		m_window->get_context()->draw( nv::TRIANGLES, m_render_state, m_program, m_va, m_mesh->get_count() );
-		m_window->swap_buffers();
-
-		nv::io_event event;
-		while(m_window->poll_event(event)) 
-		{      
-			switch (event.type) 
-			{
-			case nv::EV_QUIT:
-				keypress = 1;
-				break;
-			case nv::EV_KEY:
-				if (event.key.pressed)
-				{
-					switch (event.key.code) 
-					{
-					case nv::KEY_ESCAPE : keypress = 1; break;
-					case nv::KEY_LEFT   : move.x = move.x - 1.0f; break;
-					case nv::KEY_RIGHT  : move.x = move.x + 1.0f; break;
-					case nv::KEY_UP     : move.z = move.z - 1.0f; break;
-					case nv::KEY_DOWN   : move.z = move.z + 1.0f; break;
-					default: break;
-					}
-				}
-				break;
-			default: break;
-			}
-		}
-	}
-	return true;
-}
-
-application::~application()
-{
-	delete m_mesh;
-	delete m_program;
-	delete m_diffuse;
-	delete m_specular;
-	delete m_window;
-	delete m_device;
-}
-
-
-int main(int, char* [])
-{
-	nv::logger log(nv::LOG_TRACE);
-	log.add_sink( new nv::log_file_sink("log.txt"), nv::LOG_TRACE );
-	log.add_sink( new nv::log_console_sink(), nv::LOG_TRACE );
-	
-	NV_LOG( nv::LOG_NOTICE, "Logging started" );
-	application app;
-	if ( app.initialize() )
-	{
-		app.run();
-	}
-	NV_LOG( nv::LOG_NOTICE, "Logging stopped" );
-
-	return 0;
-}
-
Index: /trunk/tests/objload_test/objload_test.lua
===================================================================
--- /trunk/tests/objload_test/objload_test.lua	(revision 320)
+++ /trunk/tests/objload_test/objload_test.lua	(revision 321)
@@ -1,8 +1,7 @@
--- obj load test project definition
-project "objload_test"
+project "nv_objload_test"
 	kind "ConsoleApp"
-	files { "objload_test.cc" }
+	files { "nv_objload_test.cc" }
 	includedirs { "../../" }
-	targetname "objload_test"
-	links { "nv" }
- 
+	targetname "nv_objload_test"
+	links { "nv-core", "nv-gl", "nv-gfx", "nv-formats" }
+	targetdir "../../bin"	 
Index: /trunk/tests/objload_test/premake4.lua
===================================================================
--- /trunk/tests/objload_test/premake4.lua	(revision 320)
+++ /trunk/tests/objload_test/premake4.lua	(revision 321)
@@ -8,17 +8,11 @@
 		defines { "DEBUG" }
 		flags { "Symbols", "StaticRuntime" }
-		objdir (_ACTION or "".."/debug")
+		objdir ("../../".._ACTION.."/debug")
 
 	configuration "release"
 		defines { "NDEBUG" }
 		flags { "Optimize", "StaticRuntime" }
-		objdir (_ACTION or "".."/release")
+		objdir ("../../".._ACTION.."/release")
 
 	dofile("objload_test.lua")
 	dofile("../../nv.lua")
-
-if _ACTION == "clean" then
-	for action in premake.action.each() do
-		os.rmdir(action.trigger)
-	end
-end
Index: /trunk/tests/render_test/nv_render_test.cc
===================================================================
--- /trunk/tests/render_test/nv_render_test.cc	(revision 321)
+++ /trunk/tests/render_test/nv_render_test.cc	(revision 321)
@@ -0,0 +1,261 @@
+#include <nv/gl/gl_device.hh>
+#include <nv/gfx/image.hh>
+#include <nv/interface/context.hh>
+#include <nv/interface/window.hh>
+#include <nv/core/logging.hh>
+#include <nv/core/logger.hh>
+#include <nv/core/math.hh>
+#include <nv/core/string.hh>
+
+const nv::uint16 size_x  = 16;
+const nv::uint16 size_y  = 16;
+const nv::uint16 size_xy = size_x * size_y;
+
+static nv::uint8 height[size_xy] = 
+{
+	4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,
+	4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,
+	4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,
+	4,  4,  4,  6,  6,  6,  6,  6,  6,  6,  4,  4,  4,  4,  4,  4,
+	4,  4,  4,  6,  6,  6,  6,  6,  6,  6,  4,  4,  4,  4,  4,  4,
+	4,  4,  4,  6,  6,  6,  6,  6,  6,  6,  4,  4,  4,  4,  4,  4,
+	4,  4,  4,  5,  5,  5,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,
+	4,  4,  4,  5,  5,  5,  4,  2,  2,  2,  2,  2,  2,  4,  4,  4,
+	4,  4,  4,  5,  5,  5,  4,  2,  2,  2,  2,  2,  2,  4,  4,  4,
+	4,  4,  4,  4,  4,  4,  4,  2,  2,  2,  2,  2,  2,  4,  4,  4,
+	4,  4,  4,  4,  4,  4,  4,  2,  2,  2,  2,  2,  2,  4,  4,  4,
+	4,  4,  4,  4,  4,  4,  4,  2,  2,  2,  2,  2,  2,  4,  4,  4,
+	4,  4,  4,  4,  4,  4,  4,  2,  2,  2,  4,  4,  4,  4,  4,  4,
+	4,  4,  4,  4,  4,  4,  4,  2,  2,  2,  4,  4,  4,  4,  4,  4,
+	4,  4,  4,  4,  4,  4,  4,  2,  2,  2,  4,  4,  4,  4,  4,  4,
+	4,  4,  4,  4,  4,  4,  4,  2,  2,  2,  4,  4,  4,  4,  4,  4,
+};
+
+static nv::uint8 map[size_xy] = 
+{
+	2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,
+	2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,
+	2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,
+	2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,
+	2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,
+	2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,
+	2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,
+	2,  2,  2,  2,  2,  2,  2,  6,  6,  6,  6,  6,  6,  2,  2,  2,
+	3,  2,  2,  2,  2,  2,  2,  6,  6,  6,  6,  6,  6,  2,  2,  2,
+	2,  2,  2,  2,  2,  2,  2,  6,  6,  6,  6,  6,  6,  2,  2,  2,
+	2,  2,  2,  2,  2,  2,  2,  6,  6,  6,  6,  6,  6,  2,  2,  2,
+	2,  2,  2,  2,  2,  2,  2,  6,  6,  6,  6,  6,  6,  2,  2,  2,
+	2,  2,  2,  2,  2,  2,  2,  6,  6,  6,  2,  2,  2,  2,  2,  2,
+	2,  2,  2,  2,  2,  2,  2,  6,  6,  6,  2,  2,  2,  2,  2,  2,
+	2,  2,  2,  2,  2,  2,  2,  6,  6,  6,  2,  2,  2,  2,  2,  2,
+	2,  2,  2,  2,  2,  2,  2,  6,  6,  6,  2,  2,  2,  2,  2,  2,
+};
+
+class application
+{
+public:
+	application();
+	bool initialize();
+	bool run();
+	~application();
+protected:
+	nv::device*  m_device;
+	nv::context* m_context;
+	nv::window*  m_window;
+	nv::texture  m_texture;
+
+	nv::clear_state  m_clear_state;
+	nv::render_state m_render_state;
+	nv::scene_state  m_scene_state;
+
+	nv::program m_char_program;
+	nv::program m_box_program;
+	nv::vertex_array m_char_va;
+	nv::vertex_array m_box_va;
+	unsigned int m_count;
+};
+
+struct vtx
+{
+	nv::i8vec3 position;
+	nv::i8vec3 color;
+
+	vtx( const nv::i8vec3& a_position, const nv::i8vec3& a_color )
+		: position( a_position ), color( a_color ) {}
+};
+
+application::application()
+{
+	m_device  = new nv::gl_device();
+	m_window  = m_device->create_window( 800, 600, false );
+	m_context = m_window->get_context();
+	
+	nv::image_data* sprites = m_device->create_image_data( "spritesheet.png" );
+	nv::sampler sampler( nv::sampler::NEAREST, nv::sampler::REPEAT );
+	m_texture = m_device->create_texture( sprites, sampler );
+	delete sprites;
+
+	m_clear_state.buffers = nv::clear_state::COLOR_AND_DEPTH_BUFFER;
+	m_render_state.depth_test.enabled = true;
+	m_render_state.blending.enabled   = true;
+	m_render_state.blending.src_rgb_factor   = nv::blending::SRC_ALPHA;
+	m_render_state.blending.dst_rgb_factor   = nv::blending::ONE_MINUS_SRC_ALPHA;
+	m_render_state.blending.src_alpha_factor = nv::blending::SRC_ALPHA;
+	m_render_state.blending.dst_alpha_factor = nv::blending::ONE_MINUS_SRC_ALPHA;
+}
+
+bool application::initialize()
+{
+	{ // CHARACTER
+		std::vector< vtx > v;
+		int m = 16;	int x = 0; int y = 0; int h = 0;
+		nv::i8vec3 mt( m, 1, 0 );
+		v.emplace_back( nv::i8vec3( x,   h, y ), mt );  
+		v.emplace_back( nv::i8vec3( x,   h, y+1 ), mt );
+		v.emplace_back( nv::i8vec3( x+1, h, y+1 ), mt );
+		v.emplace_back( nv::i8vec3( x+1, h, y+1 ), mt );
+		v.emplace_back( nv::i8vec3( x+1, h, y ), mt );  
+		v.emplace_back( nv::i8vec3( x,   h, y ), mt );  
+		m_char_program = m_device->create_program( nv::slurp( "char.vert" ), nv::slurp( "char.frag" ) );
+		m_char_va      = m_context->create_vertex_array( v, nv::STATIC_DRAW );
+	}
+
+	{ // WORLD
+		std::vector< vtx > v;
+		nv::i8vec3 mt;
+		for (int i = 0; i < size_x * size_y; ++i )
+		{
+			int x = i % size_x;
+			int y = i / size_x;
+
+			mt = nv::i8vec3( map[i], 2, 0 );
+			v.emplace_back( nv::i8vec3( x,   height[i], y   ), mt );
+			v.emplace_back( nv::i8vec3( x,   height[i], y+1 ), mt );
+			v.emplace_back( nv::i8vec3( x+1, height[i], y+1 ), mt );
+			v.emplace_back( nv::i8vec3( x+1, height[i], y+1 ), mt );
+			v.emplace_back( nv::i8vec3( x+1, height[i], y ), mt );
+			v.emplace_back( nv::i8vec3( x,   height[i], y ), mt );
+
+			if (i > 0 && height[i-1] != height[i])
+			{
+				short dir   = height[i-1] > height[i] ? -1 : 1;
+				nv::uint8 m = 1;
+				for ( int h = height[i-1]; h != height[i]; h = h + dir )
+				{
+					m_count += 6;
+					mt = nv::i8vec3( m, -dir, 0 );
+					v.emplace_back( nv::i8vec3( x, h,     y ), mt );
+					v.emplace_back( nv::i8vec3( x, h,     y+1 ), mt );
+					v.emplace_back( nv::i8vec3( x, h+dir, y+1 ), mt );
+					v.emplace_back( nv::i8vec3( x, h+dir, y+1 ), mt );
+					v.emplace_back( nv::i8vec3( x, h+dir, y ), mt );
+					v.emplace_back( nv::i8vec3( x, h,     y ), mt );
+				}
+			}
+
+			if (i >= size_x && height[i-size_x] != height[i])
+			{
+				short dir   = height[i-size_x] > height[i] ? -1 : 1;
+				nv::uint8 m = 1;
+				for ( int h = height[i-size_x]; h != height[i]; h = h + dir )
+				{
+					mt = nv::i8vec3( m, -3*dir, 0 );
+					v.emplace_back( nv::i8vec3( x,   h,     y ), mt );
+					v.emplace_back( nv::i8vec3( x,   h+dir, y ), mt );
+					v.emplace_back( nv::i8vec3( x+1, h+dir, y ), mt );
+
+					v.emplace_back( nv::i8vec3( x+1, h+dir, y ), mt );
+					v.emplace_back( nv::i8vec3( x+1, h,     y ), mt );
+					v.emplace_back( nv::i8vec3( x,   h,     y ), mt );
+				}
+			}
+
+		}
+
+		m_count       = v.size();
+		m_box_program = m_device->create_program( nv::slurp( "box.vert" ), nv::slurp( "box.frag" ) );
+		m_box_va      = m_context->create_vertex_array( v, nv::STATIC_DRAW );
+	}
+
+	return true;
+}
+
+bool application::run()
+{
+	int keypress = 0;
+
+	glm::vec3 move( 0, 0, 0 );
+	m_scene_state.get_camera().set_perspective(25.0f, 1.0f*800.0f/600.0f, 0.1f, 100.0f);
+
+	while(!keypress) 
+	{
+		m_scene_state.set_model( glm::translate(glm::mat4(1.0f), glm::vec3(-8.5, 0.0, -8.0)) );
+		m_scene_state.get_camera().set_lookat(glm::vec3(0.0, 20.0, 5.0) + move, glm::vec3(0.0, 4.0, 0.0) + move, glm::vec3(0.0, 1.0, 0.0));
+
+		m_context->clear( m_clear_state );
+		m_context->bind( m_texture, nv::TEXTURE_0 );
+		m_device->set_uniform( m_box_program, "light", glm::vec3(8.5, 4.5, 6.5) + move );
+		m_context->draw( nv::TRIANGLES, m_render_state, m_scene_state, m_box_program, m_box_va, m_count );
+
+		m_device->set_uniform( m_char_program, "pos", move + glm::vec3( 8, 4.1, 6 ) );
+		m_context->draw( nv::TRIANGLES, m_render_state, m_scene_state, m_char_program, m_char_va, 6 );
+		m_window->swap_buffers();
+
+		nv::io_event event;
+		while(m_window->poll_event(event)) 
+		{      
+			switch (event.type) 
+			{
+			case nv::EV_QUIT:
+				keypress = 1;
+				break;
+			case nv::EV_KEY:
+				if (event.key.pressed)
+				{
+					switch (event.key.code) 
+					{
+					case nv::KEY_ESCAPE : keypress = 1; break;
+					case nv::KEY_LEFT   : move.x = move.x - 1.0f; break;
+					case nv::KEY_RIGHT  : move.x = move.x + 1.0f; break;
+					case nv::KEY_UP     : move.z = move.z - 1.0f; break;
+					case nv::KEY_DOWN   : move.z = move.z + 1.0f; break;
+					default: break;
+					}
+				}
+				break;
+			default: break;
+			}
+		}
+	}
+	return true;
+}
+
+application::~application()
+{
+	m_device->release( m_char_program );
+	m_device->release( m_box_program );
+	m_context->release( m_char_va );
+	m_context->release( m_box_va );
+	m_device->release( m_texture );
+	delete m_window;
+	delete m_device;
+}
+
+
+int main(int, char* [])
+{
+	nv::logger log(nv::LOG_TRACE);
+	log.add_sink( new nv::log_file_sink("log.txt"), nv::LOG_TRACE );
+	log.add_sink( new nv::log_console_sink(), nv::LOG_TRACE );
+	
+	NV_LOG( nv::LOG_NOTICE, "Logging started" );
+	application app;
+	if ( app.initialize() )
+	{
+		app.run();
+	}
+	NV_LOG( nv::LOG_NOTICE, "Logging stopped" );
+
+	return 0;
+}
+
Index: /trunk/tests/render_test/premake4.lua
===================================================================
--- /trunk/tests/render_test/premake4.lua	(revision 320)
+++ /trunk/tests/render_test/premake4.lua	(revision 321)
@@ -8,17 +8,11 @@
 		defines { "DEBUG" }
 		flags { "Symbols", "StaticRuntime" }
-		objdir (_ACTION or "".."/debug")
+		objdir ("../../".._ACTION.."/debug")
 
 	configuration "release"
 		defines { "NDEBUG" }
 		flags { "Optimize", "StaticRuntime" }
-		objdir (_ACTION or "".."/release")
+		objdir ("../../".._ACTION.."/release")
 
 	dofile("render_test.lua")
 	dofile("../../nv.lua")
-
-if _ACTION == "clean" then
-	for action in premake.action.each() do
-		os.rmdir(action.trigger)
-	end
-end
Index: /trunk/tests/render_test/render_test.lua
===================================================================
--- /trunk/tests/render_test/render_test.lua	(revision 320)
+++ /trunk/tests/render_test/render_test.lua	(revision 321)
@@ -1,8 +1,8 @@
--- RL project definition
-project "rl"
+project "nv_render_test"
 	kind "ConsoleApp"
-	files { "rl.cc" }
+	files { "nv_render_test.cc" }
 	includedirs { "../../" }
-	targetname "rl"
-	links { "nv" }
+	targetname "nv_render_test"
+	links { "nv-core", "nv-gl" }
+	targetdir "../../bin"	
  
Index: unk/tests/render_test/rl.cc
===================================================================
--- /trunk/tests/render_test/rl.cc	(revision 320)
+++ 	(revision )
@@ -1,262 +1,0 @@
-#include <nv/interface/vertex_buffer.hh>
-#include <nv/gl/gl_device.hh>
-#include <nv/gfx/image.hh>
-#include <nv/interface/context.hh>
-#include <nv/interface/window.hh>
-#include <nv/interface/program.hh>
-#include <nv/interface/texture2d.hh>
-#include <nv/logging.hh>
-#include <nv/logger.hh>
-#include <nv/math.hh>
-#include <nv/string.hh>
-
-const nv::uint16 size_x  = 16;
-const nv::uint16 size_y  = 16;
-const nv::uint16 size_xy = size_x * size_y;
-
-static nv::uint8 height[size_xy] = 
-{
-	4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,
-	4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,
-	4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,
-	4,  4,  4,  6,  6,  6,  6,  6,  6,  6,  4,  4,  4,  4,  4,  4,
-	4,  4,  4,  6,  6,  6,  6,  6,  6,  6,  4,  4,  4,  4,  4,  4,
-	4,  4,  4,  6,  6,  6,  6,  6,  6,  6,  4,  4,  4,  4,  4,  4,
-	4,  4,  4,  5,  5,  5,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,
-	4,  4,  4,  5,  5,  5,  4,  2,  2,  2,  2,  2,  2,  4,  4,  4,
-	4,  4,  4,  5,  5,  5,  4,  2,  2,  2,  2,  2,  2,  4,  4,  4,
-	4,  4,  4,  4,  4,  4,  4,  2,  2,  2,  2,  2,  2,  4,  4,  4,
-	4,  4,  4,  4,  4,  4,  4,  2,  2,  2,  2,  2,  2,  4,  4,  4,
-	4,  4,  4,  4,  4,  4,  4,  2,  2,  2,  2,  2,  2,  4,  4,  4,
-	4,  4,  4,  4,  4,  4,  4,  2,  2,  2,  4,  4,  4,  4,  4,  4,
-	4,  4,  4,  4,  4,  4,  4,  2,  2,  2,  4,  4,  4,  4,  4,  4,
-	4,  4,  4,  4,  4,  4,  4,  2,  2,  2,  4,  4,  4,  4,  4,  4,
-	4,  4,  4,  4,  4,  4,  4,  2,  2,  2,  4,  4,  4,  4,  4,  4,
-};
-
-static nv::uint8 map[size_xy] = 
-{
-	2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,
-	2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,
-	2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,
-	2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,
-	2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,
-	2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,
-	2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,
-	2,  2,  2,  2,  2,  2,  2,  6,  6,  6,  6,  6,  6,  2,  2,  2,
-	3,  2,  2,  2,  2,  2,  2,  6,  6,  6,  6,  6,  6,  2,  2,  2,
-	2,  2,  2,  2,  2,  2,  2,  6,  6,  6,  6,  6,  6,  2,  2,  2,
-	2,  2,  2,  2,  2,  2,  2,  6,  6,  6,  6,  6,  6,  2,  2,  2,
-	2,  2,  2,  2,  2,  2,  2,  6,  6,  6,  6,  6,  6,  2,  2,  2,
-	2,  2,  2,  2,  2,  2,  2,  6,  6,  6,  2,  2,  2,  2,  2,  2,
-	2,  2,  2,  2,  2,  2,  2,  6,  6,  6,  2,  2,  2,  2,  2,  2,
-	2,  2,  2,  2,  2,  2,  2,  6,  6,  6,  2,  2,  2,  2,  2,  2,
-	2,  2,  2,  2,  2,  2,  2,  6,  6,  6,  2,  2,  2,  2,  2,  2,
-};
-
-class application
-{
-public:
-	application();
-	bool initialize();
-	bool run();
-	~application();
-protected:
-	nv::device* m_device;
-	nv::window* m_window;
-	nv::texture2d* m_texture;
-
-	nv::clear_state  m_clear_state;
-	nv::render_state m_render_state;
-	nv::scene_state  m_scene_state;
-
-	nv::program* m_char_program;
-	nv::program* m_box_program;
-	nv::vertex_array* m_char_va;
-	nv::vertex_array* m_box_va;
-	unsigned int m_count;
-};
-
-struct vtx
-{
-	nv::i8vec3 position;
-	nv::i8vec3 color;
-
-	vtx( const nv::i8vec3& a_position, const nv::i8vec3& a_color )
-		: position( a_position ), color( a_color ) {}
-};
-
-application::application()
-{
-	m_device = new nv::gl_device();
-	m_window = m_device->create_window( 800, 600, false );
-	
-	nv::image_data* sprites = m_device->create_image_data( "spritesheet.png" );
-	nv::sampler sampler( nv::sampler::NEAREST, nv::sampler::REPEAT );
-	m_texture = m_device->create_texture2d( sprites->get_size(), nv::RGBA, nv::UBYTE, sampler, (void*)sprites->get_data() );
-	delete sprites;
-
-	m_clear_state.buffers = nv::clear_state::COLOR_AND_DEPTH_BUFFER;
-	m_render_state.depth_test.enabled = true;
-	m_render_state.blending.enabled   = true;
-	m_render_state.blending.src_rgb_factor   = nv::blending::SRC_ALPHA;
-	m_render_state.blending.dst_rgb_factor   = nv::blending::ONE_MINUS_SRC_ALPHA;
-	m_render_state.blending.src_alpha_factor = nv::blending::SRC_ALPHA;
-	m_render_state.blending.dst_alpha_factor = nv::blending::ONE_MINUS_SRC_ALPHA;
-}
-
-bool application::initialize()
-{
-	{ // CHARACTER
-		std::vector< vtx > v;
-		int m = 16;	int x = 0; int y = 0; int h = 0;
-		nv::i8vec3 mt( m, 1, 0 );
-		v.emplace_back( nv::i8vec3( x,   h, y ), mt );  
-		v.emplace_back( nv::i8vec3( x,   h, y+1 ), mt );
-		v.emplace_back( nv::i8vec3( x+1, h, y+1 ), mt );
-		v.emplace_back( nv::i8vec3( x+1, h, y+1 ), mt );
-		v.emplace_back( nv::i8vec3( x+1, h, y ), mt );  
-		v.emplace_back( nv::i8vec3( x,   h, y ), mt );  
-		m_char_program = m_device->create_program( nv::slurp( "char.vert" ), nv::slurp( "char.frag" ) );
-		m_char_va      = m_device->create_vertex_array( v, nv::STATIC_DRAW );
-	}
-
-	{ // WORLD
-		std::vector< vtx > v;
-		nv::i8vec3 mt;
-		for (int i = 0; i < size_x * size_y; ++i )
-		{
-			int x = i % size_x;
-			int y = i / size_x;
-
-			mt = nv::i8vec3( map[i], 2, 0 );
-			v.emplace_back( nv::i8vec3( x,   height[i], y   ), mt );
-			v.emplace_back( nv::i8vec3( x,   height[i], y+1 ), mt );
-			v.emplace_back( nv::i8vec3( x+1, height[i], y+1 ), mt );
-			v.emplace_back( nv::i8vec3( x+1, height[i], y+1 ), mt );
-			v.emplace_back( nv::i8vec3( x+1, height[i], y ), mt );
-			v.emplace_back( nv::i8vec3( x,   height[i], y ), mt );
-
-			if (i > 0 && height[i-1] != height[i])
-			{
-				short dir   = height[i-1] > height[i] ? -1 : 1;
-				nv::uint8 m = 1;
-				for ( int h = height[i-1]; h != height[i]; h = h + dir )
-				{
-					m_count += 6;
-					mt = nv::i8vec3( m, -dir, 0 );
-					v.emplace_back( nv::i8vec3( x, h,     y ), mt );
-					v.emplace_back( nv::i8vec3( x, h,     y+1 ), mt );
-					v.emplace_back( nv::i8vec3( x, h+dir, y+1 ), mt );
-					v.emplace_back( nv::i8vec3( x, h+dir, y+1 ), mt );
-					v.emplace_back( nv::i8vec3( x, h+dir, y ), mt );
-					v.emplace_back( nv::i8vec3( x, h,     y ), mt );
-				}
-			}
-
-			if (i >= size_x && height[i-size_x] != height[i])
-			{
-				short dir   = height[i-size_x] > height[i] ? -1 : 1;
-				nv::uint8 m = 1;
-				for ( int h = height[i-size_x]; h != height[i]; h = h + dir )
-				{
-					mt = nv::i8vec3( m, -3*dir, 0 );
-					v.emplace_back( nv::i8vec3( x,   h,     y ), mt );
-					v.emplace_back( nv::i8vec3( x,   h+dir, y ), mt );
-					v.emplace_back( nv::i8vec3( x+1, h+dir, y ), mt );
-
-					v.emplace_back( nv::i8vec3( x+1, h+dir, y ), mt );
-					v.emplace_back( nv::i8vec3( x+1, h,     y ), mt );
-					v.emplace_back( nv::i8vec3( x,   h,     y ), mt );
-				}
-			}
-
-		}
-
-		m_count       = v.size();
-		m_box_program = m_device->create_program( nv::slurp( "box.vert" ), nv::slurp( "box.frag" ) );
-		m_box_va      = m_device->create_vertex_array( v, nv::STATIC_DRAW );
-	}
-
-	return true;
-}
-
-bool application::run()
-{
-	int keypress = 0;
-
-	glm::vec3 move( 0, 0, 0 );
-	m_scene_state.get_camera().set_perspective(25.0f, 1.0f*800.0f/600.0f, 0.1f, 100.0f);
-
-	while(!keypress) 
-	{
-		m_scene_state.set_model( glm::translate(glm::mat4(1.0f), glm::vec3(-8.5, 0.0, -8.0)) );
-		m_scene_state.get_camera().set_lookat(glm::vec3(0.0, 20.0, 5.0) + move, glm::vec3(0.0, 4.0, 0.0) + move, glm::vec3(0.0, 1.0, 0.0));
-
-		m_window->get_context()->clear( m_clear_state );
-		m_texture->bind( 0 );
-		m_box_program->set_uniform( "light", glm::vec3(8.5, 4.5, 6.5) + move );
-		m_window->get_context()->draw( nv::TRIANGLES, m_render_state, m_scene_state, m_box_program, m_box_va, m_count );
-
-		m_char_program->set_uniform( "pos", move + glm::vec3( 8, 4.1, 6 ) );
-		m_window->get_context()->draw( nv::TRIANGLES, m_render_state, m_scene_state, m_char_program, m_char_va, 6 );
-		m_window->swap_buffers();
-
-		nv::io_event event;
-		while(m_window->poll_event(event)) 
-		{      
-			switch (event.type) 
-			{
-			case nv::EV_QUIT:
-				keypress = 1;
-				break;
-			case nv::EV_KEY:
-				if (event.key.pressed)
-				{
-					switch (event.key.code) 
-					{
-					case nv::KEY_ESCAPE : keypress = 1; break;
-					case nv::KEY_LEFT   : move.x = move.x - 1.0f; break;
-					case nv::KEY_RIGHT  : move.x = move.x + 1.0f; break;
-					case nv::KEY_UP     : move.z = move.z - 1.0f; break;
-					case nv::KEY_DOWN   : move.z = move.z + 1.0f; break;
-					default: break;
-					}
-				}
-				break;
-			default: break;
-			}
-		}
-	}
-	return true;
-}
-
-application::~application()
-{
-	delete m_char_program;
-	delete m_box_program;
-	delete m_char_va;
-	delete m_box_va;
-	delete m_texture;
-	delete m_window;
-	delete m_device;
-}
-
-
-int main(int, char* [])
-{
-	nv::logger log(nv::LOG_TRACE);
-	log.add_sink( new nv::log_file_sink("log.txt"), nv::LOG_TRACE );
-	log.add_sink( new nv::log_console_sink(), nv::LOG_TRACE );
-	
-	NV_LOG( nv::LOG_NOTICE, "Logging started" );
-	application app;
-	if ( app.initialize() )
-	{
-		app.run();
-	}
-	NV_LOG( nv::LOG_NOTICE, "Logging stopped" );
-
-	return 0;
-}
-
