Index: trunk/tests/md2_test/nv_md2_test.cc
===================================================================
--- trunk/tests/md2_test/md2_test.cc	(revision 239)
+++ trunk/tests/md2_test/nv_md2_test.cc	(revision 321)
@@ -1,20 +1,16 @@
-#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 <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>
 
@@ -27,8 +23,9 @@
 	~application();
 protected:
-	nv::device*       m_device;
-	nv::window*       m_window;
-	nv::texture2d*    m_diffuse;
-	nv::program*      m_program;
+	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;
@@ -36,6 +33,7 @@
 	nv::scene_state   m_scene_state;
 
-	nv::mesh_data*      m_mesh_data;
-	nv::keyframed_mesh* m_mesh;
+	nv::mesh_data*       m_mesh_data;
+	nv::keyframed_mesh*  m_mesh;
+	nv::animation_entry* m_animation;
 };
 
@@ -43,10 +41,11 @@
 {
 	NV_PROFILE( "app_construct" );
-	m_device = new nv::gl_device();
-	m_window = m_device->create_window( 800, 600, false );
+	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_texture2d( data->get_size(), nv::RGB, nv::UBYTE, sampler, (void*)data->get_data() );
+	m_diffuse  = m_device->create_texture( data, sampler );
 	delete data;
 
@@ -64,5 +63,5 @@
 {
 	NV_PROFILE( "app_initialize" );
-	m_program = m_device->create_program( nv::slurp( "obj.vert" ), nv::slurp( "obj.frag" ) );
+	m_program = m_device->create_program( nv::slurp( "md2.vert" ), nv::slurp( "md2.frag" ) );
 
 	nv::md2_loader* loader;
@@ -80,5 +79,5 @@
 	{
 		NV_PROFILE("create_mesh");
-		m_mesh      = new nv::keyframed_mesh_gpu( m_window->get_context(), m_mesh_data, nullptr, m_program );
+		m_mesh      = new nv::keyframed_mesh_gpu( m_context, m_mesh_data, nullptr );
 	}
 
@@ -96,5 +95,6 @@
 	nv::fps_counter_class< nv::system_us_timer > fps_counter;
 
-	m_mesh->setup_animation( 0, m_mesh->get_max_frames(), 2, true );
+	m_animation = new nv::animation_entry( "", true, 5, 0.0f, m_mesh->get_max_frames()-1 );
+	m_mesh->run_animation( m_animation );
 
 	while(!keypress) 
@@ -103,6 +103,5 @@
 		ticks      = m_device->get_ticks();
 		nv::uint32 elapsed = ticks - last_ticks;
-		m_window->get_context()->clear( m_clear_state );
-		m_mesh->update( elapsed );
+		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 ) );
 
@@ -111,10 +110,11 @@
 		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_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_window->get_context()->draw( m_render_state, m_scene_state, m_program, m_mesh );
+		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();
 
@@ -148,8 +148,9 @@
 application::~application()
 {
-	delete m_program;
+	m_device->release( m_program );
 	delete m_mesh_data;
 	delete m_mesh;
-	delete m_diffuse;
+	delete m_animation;
+	m_device->release( m_diffuse );
 	delete m_window;
 	delete m_device;
