Index: /trunk/nv/gfx/keyframed_mesh.hh
===================================================================
--- /trunk/nv/gfx/keyframed_mesh.hh	(revision 298)
+++ /trunk/nv/gfx/keyframed_mesh.hh	(revision 299)
@@ -19,5 +19,5 @@
 	{
 	public:
-		keyframed_mesh( device* a_device, const mesh_data* a_data, const mesh_nodes_data* a_tag_map );
+		keyframed_mesh( const mesh_data* a_data, const mesh_nodes_data* a_tag_map );
 		virtual size_t get_index_count() const { return m_index_count; }
 		virtual void run_animation( animation_entry* a_anim );
@@ -67,5 +67,5 @@
 	{
 	public:
-		keyframed_mesh_gpu( device* a_device, const mesh_data* a_data, const mesh_nodes_data* a_tag_map );
+		keyframed_mesh_gpu( context* a_context, const mesh_data* a_data, const mesh_nodes_data* a_tag_map );
 		void update( uint32 ms );
 		virtual void update( program* a_program );
@@ -82,8 +82,10 @@
 	{
 	public:
-		keyframed_mesh_cpu( device* a_device, const mesh_data* a_data, const mesh_nodes_data* a_tag_map );
+		keyframed_mesh_cpu( context* a_context, const mesh_data* a_data, const mesh_nodes_data* a_tag_map );
 		void update( uint32 ms );
 		~keyframed_mesh_cpu();
 	private:
+		context* m_context;
+
 		uint8*         m_data;
 		vertex_buffer* m_vb;
Index: /trunk/nv/gfx/skeletal_mesh.hh
===================================================================
--- /trunk/nv/gfx/skeletal_mesh.hh	(revision 298)
+++ /trunk/nv/gfx/skeletal_mesh.hh	(revision 299)
@@ -41,9 +41,10 @@
 	{
 	public:
-		skeletal_mesh_cpu( device* a_device, const mesh_data* a_mesh_data, const mesh_nodes_data* bones );
+		skeletal_mesh_cpu( context* a_context, const mesh_data* a_mesh_data, const mesh_nodes_data* bones );
 		virtual size_t get_index_count() const { return m_indices; }
 		virtual void update_animation( animation_entry* a_anim, uint32 a_anim_time );
 		virtual ~skeletal_mesh_cpu();
 	protected:
+		context*                     m_context;
 		uint32                       m_indices;
 		dynamic_array< md5_vtx_pnt > m_pntdata;
@@ -91,5 +92,5 @@
 	{
 	public:
-		skeletal_mesh_gpu( device* a_device, const mesh_data* a_mesh, const mesh_nodes_data* a_bone_data );
+		skeletal_mesh_gpu( context* a_context, const mesh_data* a_mesh, const mesh_nodes_data* a_bone_data );
 		virtual size_t get_index_count() const { return m_index_count; }
 		virtual void update( program* a_program );
Index: /trunk/nv/gfx/sliced_buffer.hh
===================================================================
--- /trunk/nv/gfx/sliced_buffer.hh	(revision 298)
+++ /trunk/nv/gfx/sliced_buffer.hh	(revision 299)
@@ -93,6 +93,6 @@
 		static const size_t value_type_size = sizeof(T);
 
-		sliced_buffer( device* dev, buffer_hint hint, size_t initial_size, bool is_vertex = true ) 
-			: m_device( dev )
+		sliced_buffer( context* ctx, buffer_hint hint, size_t initial_size, bool is_vertex = true ) 
+			: m_context( ctx )
 			, m_buffer( nullptr )
 			, m_hint( hint )
@@ -166,9 +166,10 @@
 			if ( m_max > 0 )
 			{
-				m_buffer->bind();
 				size_t offset = m_min * value_type_size;
 				size_t size   = (m_max-m_min) * value_type_size;
-				m_buffer->update( m_data.data() + m_min, offset, size );
-				m_buffer->unbind();
+				if ( m_is_vertex )
+					m_context->update( (vertex_buffer*)m_buffer, m_data.data() + m_min, offset, size );
+				else
+					m_context->update( (index_buffer*)m_buffer, m_data.data() + m_min, offset, size );
 			}
 			m_full_update = false;
@@ -202,10 +203,10 @@
 			delete m_buffer;
 			if ( m_is_vertex )
-				m_buffer = m_device->create_vertex_buffer( m_hint, size * value_type_size, nullptr );
+				m_buffer = m_context->get_device()->create_vertex_buffer( m_hint, size * value_type_size, nullptr );
 			else
-				m_buffer = m_device->create_index_buffer( m_hint, size * value_type_size, nullptr );
+				m_buffer = m_context->get_device()->create_index_buffer( m_hint, size * value_type_size, nullptr );
 		}
 	private:
-		device*     m_device;
+		context*    m_context;
 		buffer*     m_buffer;
 		buffer_hint m_hint;
Index: /trunk/nv/gl/gl_context.hh
===================================================================
--- /trunk/nv/gl/gl_context.hh	(revision 298)
+++ /trunk/nv/gl/gl_context.hh	(revision 299)
@@ -23,4 +23,18 @@
 	public:
 		~gl_context();
+		virtual void bind( texture2d* texture, texture_slot slot );
+		virtual void bind( program* p );
+		virtual void bind( vertex_buffer* b );
+		virtual void bind( index_buffer* b );
+		virtual void bind( vertex_array* va );
+		virtual void unbind( program* p );
+		virtual void unbind( index_buffer* b );
+		virtual void unbind( vertex_buffer* b );
+		virtual void unbind( vertex_array* va );
+
+		virtual void update( texture2d* texture, void* data );
+		virtual void update( index_buffer* b, const void* data, size_t offset, size_t size );
+		virtual void update( vertex_buffer* b, const void* data, size_t offset, size_t size );
+
 		virtual void clear( const clear_state& cs );
 		// temporary
Index: /trunk/nv/gl/gl_program.hh
===================================================================
--- /trunk/nv/gl/gl_program.hh	(revision 298)
+++ /trunk/nv/gl/gl_program.hh	(revision 299)
@@ -44,9 +44,9 @@
 	{
 	public:
+		friend class gl_context;
+
 		gl_program( const string& vertex_program, const string& fragment_program );
 		bool compile( const string& vertex_program, const string& fragment_program );
 
-		virtual void bind();
-		virtual void unbind();
 		virtual bool is_valid() const;
 
Index: /trunk/nv/gl/gl_texture2d.hh
===================================================================
--- /trunk/nv/gl/gl_texture2d.hh	(revision 298)
+++ /trunk/nv/gl/gl_texture2d.hh	(revision 299)
@@ -22,9 +22,7 @@
 	{
 	public:
+		friend class gl_context;
+
 		gl_texture2d( ivec2 size, pixel_format aformat, datatype adatatype, sampler asampler, void* data = nullptr );
-		virtual void assign( void* data );
-		virtual void bind( size_t slot = 0 );
-		virtual void unbind();
-		virtual bool is_valid() const;
 	protected:
 		gl_texture_name m_name;
Index: /trunk/nv/gl/gl_vertex_buffer.hh
===================================================================
--- /trunk/nv/gl/gl_vertex_buffer.hh	(revision 298)
+++ /trunk/nv/gl/gl_vertex_buffer.hh	(revision 299)
@@ -22,9 +22,7 @@
 	{
 	public:
+		friend class gl_context;
+
 		gl_vertex_buffer( buffer_hint hint, size_t size, const void* data = nullptr );
-		virtual void update( const void* data, size_t offset, size_t size );
-		virtual void bind();
-		virtual void unbind();
-		virtual bool is_valid() const;
 	private:
 		gl_buffer_name m_name;
@@ -34,19 +32,9 @@
 	{
 	public:
+		friend class gl_context;
+
 		gl_index_buffer( buffer_hint hint, size_t size, const void* data = nullptr );
-		virtual void update( const void* data, size_t offset, size_t size );
-		virtual void bind();
-		virtual void unbind();
-		virtual bool is_valid() const;
 	private:
 		gl_buffer_name m_name;
-	};
-
-	class gl_vertex_array : public vertex_array
-	{
-	public:
-		gl_vertex_array();
-		virtual void bind();
-		virtual void unbind();
 	};
 
Index: /trunk/nv/gui/gui_renderer.hh
===================================================================
--- /trunk/nv/gui/gui_renderer.hh	(revision 298)
+++ /trunk/nv/gui/gui_renderer.hh	(revision 299)
@@ -59,4 +59,5 @@
 			typedef std::vector< vec4 >                       image_vector;
 
+			context*      m_context;
 			window*       m_window;
 			style         m_style; 
Index: /trunk/nv/interface/context.hh
===================================================================
--- /trunk/nv/interface/context.hh	(revision 298)
+++ /trunk/nv/interface/context.hh	(revision 299)
@@ -49,4 +49,5 @@
 
 	class device;
+	class texture2d;
 	class context
 	{
@@ -58,4 +59,17 @@
 			m_device = a_device; 
 		}
+		virtual void bind( texture2d*, texture_slot ) = 0;
+		virtual void bind( vertex_buffer* ) = 0;
+		virtual void bind( index_buffer* ) = 0;
+		virtual void bind( program* ) = 0;
+		virtual void bind( vertex_array* ) = 0;
+		virtual void unbind( vertex_buffer* ) = 0;
+		virtual void unbind( index_buffer* ) = 0;
+		virtual void unbind( program* ) = 0;
+		virtual void unbind( vertex_array* ) = 0;
+		virtual void update( texture2d*, void* ) = 0;
+		virtual void update( index_buffer*, const void*, size_t /*offset*/, size_t /*size*/ ) = 0;
+		virtual void update( vertex_buffer*, const void*, size_t /*offset*/, size_t /*size*/ ) = 0;
+
 		virtual void clear( const clear_state& cs ) = 0;
 		// temporary
Index: /trunk/nv/interface/program.hh
===================================================================
--- /trunk/nv/interface/program.hh	(revision 298)
+++ /trunk/nv/interface/program.hh	(revision 299)
@@ -64,6 +64,4 @@
 	{
 	public:
-		virtual void bind() = 0;
-		virtual void unbind() = 0;
 		virtual bool is_valid() const = 0;
 		
Index: /trunk/nv/interface/texture2d.hh
===================================================================
--- /trunk/nv/interface/texture2d.hh	(revision 298)
+++ /trunk/nv/interface/texture2d.hh	(revision 299)
@@ -53,11 +53,8 @@
 	class texture2d
 	{
-	public:
+	protected:
 		texture2d( ivec2 size, pixel_format aformat, datatype adatatype, sampler asampler ) : 
 			m_size( size ), m_format( aformat, adatatype ), m_sampler( asampler ) {}
-		virtual void assign( void* data ) = 0;
-		virtual void bind( size_t slot = 0 ) = 0;
-		virtual void unbind() = 0;
-		virtual bool is_valid() const = 0;
+	public:
 		const ivec2& get_size() const { return m_size; }
 		int get_width() const { return m_size.x; }
Index: /trunk/nv/interface/vertex_buffer.hh
===================================================================
--- /trunk/nv/interface/vertex_buffer.hh	(revision 298)
+++ /trunk/nv/interface/vertex_buffer.hh	(revision 299)
@@ -34,8 +34,4 @@
 	public:
 		buffer( buffer_hint hint, size_t size ) { m_size = size; m_hint = hint; }
-		virtual void update( const void* data, size_t offset, size_t size ) = 0;
-		virtual void bind() = 0;
-		virtual void unbind() = 0;
-		virtual bool is_valid() const = 0;
 		size_t get_size() const { return m_size; }
 		buffer_hint get_hint() const { return m_hint; }
@@ -94,4 +90,7 @@
 	{
 	public:
+		friend class context;
+		friend class gl_context; // TODO: HACK, remove
+
 		vertex_array() : m_map(), m_index( nullptr ), m_index_owner( false ), m_index_type(USHORT) {}
 		void add_vertex_buffer( int location, vertex_buffer* buffer, datatype datatype, size_t components, size_t offset = 0, size_t stride = 0, bool owner = true ) 
@@ -162,6 +161,4 @@
 		bool has_index_buffer() const { return m_index != nullptr; }
 		datatype get_index_buffer_type() const { return m_index_type; }
-		virtual void bind() = 0;
-		virtual void unbind() = 0;
 		virtual ~vertex_array() { 
 			for ( vertex_buffer_attribute_map::iterator i = m_map.begin(); 	i != m_map.end(); ++i ) 
Index: /trunk/src/gfx/keyframed_mesh.cc
===================================================================
--- /trunk/src/gfx/keyframed_mesh.cc	(revision 298)
+++ /trunk/src/gfx/keyframed_mesh.cc	(revision 299)
@@ -15,5 +15,5 @@
 using namespace nv;
 
-nv::keyframed_mesh::keyframed_mesh( device* a_device, const mesh_data* a_data, const mesh_nodes_data* a_tag_map )
+nv::keyframed_mesh::keyframed_mesh( const mesh_data* a_data, const mesh_nodes_data* a_tag_map )
 	: animated_mesh()
 	, m_mesh_data( a_data )
@@ -24,6 +24,4 @@
 	, m_active( false )
 {
-	m_va = a_device->create_vertex_array();
-
 	m_index_count  = m_mesh_data->get_index_channel()->count;
 	m_vertex_count = m_mesh_data->get_channel<vertex_t>()->count;
@@ -123,6 +121,6 @@
 }
 
-nv::keyframed_mesh_gpu::keyframed_mesh_gpu( device* a_device, const mesh_data* a_data, const mesh_nodes_data* a_tag_map )
-	: keyframed_mesh( a_device, a_data, a_tag_map )
+nv::keyframed_mesh_gpu::keyframed_mesh_gpu( context* a_context, const mesh_data* a_data, const mesh_nodes_data* a_tag_map )
+	: keyframed_mesh( a_data, a_tag_map )
 	, m_loc_next_position( -1 )
 	, m_loc_next_normal( -1 )
@@ -131,5 +129,5 @@
 	, m_gpu_next_frame( 0xFFFFFFFF )
 {
-	m_va = a_device->create_vertex_array( a_data, STATIC_DRAW );
+	m_va = a_context->get_device()->create_vertex_array( a_data, STATIC_DRAW );
 }
 
@@ -177,14 +175,16 @@
 }
 
-nv::keyframed_mesh_cpu::keyframed_mesh_cpu( device* a_device, const mesh_data* a_data, const mesh_nodes_data* a_tag_map )
-	: keyframed_mesh( a_device, a_data, a_tag_map )
-{
-	m_vb = a_device->create_vertex_buffer( nv::STATIC_DRAW, m_vertex_count * m_vsize, (void*)m_vchannel->data );
+nv::keyframed_mesh_cpu::keyframed_mesh_cpu( context* a_context, const mesh_data* a_data, const mesh_nodes_data* a_tag_map )
+	: keyframed_mesh( a_data, a_tag_map )
+	, m_context( a_context )
+{
+	m_va = m_context->get_device()->create_vertex_array();
+	m_vb = m_context->get_device()->create_vertex_buffer( nv::STATIC_DRAW, m_vertex_count * m_vsize, (void*)m_vchannel->data );
 	m_va->add_vertex_buffers( m_vb, m_vchannel );
 
-	nv::vertex_buffer* vb = a_device->create_vertex_buffer( nv::STATIC_DRAW, m_vertex_count * sizeof( nv::vec2 ), (void*)m_mesh_data->get_channel<vertex_t>()->data );
+	nv::vertex_buffer* vb = m_context->get_device()->create_vertex_buffer( nv::STATIC_DRAW, m_vertex_count * sizeof( nv::vec2 ), (void*)m_mesh_data->get_channel<vertex_t>()->data );
 	m_va->add_vertex_buffers( vb, m_mesh_data->get_channel<vertex_t>() );
 
-	nv::index_buffer* ib = a_device->create_index_buffer( nv::STATIC_DRAW, m_mesh_data->get_index_channel()->size(), (void*)m_mesh_data->get_index_channel()->data );
+	nv::index_buffer* ib = m_context->get_device()->create_index_buffer( nv::STATIC_DRAW, m_mesh_data->get_index_channel()->size(), (void*)m_mesh_data->get_index_channel()->data );
 	m_va->set_index_buffer( ib, m_mesh_data->get_index_channel()->desc.slots[0].etype, true );
 
@@ -224,7 +224,5 @@
 	}
 
-	m_vb->bind();
-	m_vb->update( m_data, 0, m_vertex_count * m_vsize );
-	m_vb->unbind();
+	m_context->update( m_vb, m_data, 0, m_vertex_count * m_vsize );
 }
 
Index: /trunk/src/gfx/skeletal_mesh.cc
===================================================================
--- /trunk/src/gfx/skeletal_mesh.cc	(revision 298)
+++ /trunk/src/gfx/skeletal_mesh.cc	(revision 299)
@@ -11,6 +11,7 @@
 
 
-nv::skeletal_mesh_cpu::skeletal_mesh_cpu( device* a_device, const mesh_data* a_mesh_data, const mesh_nodes_data* bones )
+nv::skeletal_mesh_cpu::skeletal_mesh_cpu( context* a_context, const mesh_data* a_mesh_data, const mesh_nodes_data* bones )
 	: skeletal_mesh()
+	, m_context( a_context )
 	, m_data( a_mesh_data )
 {
@@ -26,5 +27,5 @@
 	m_vtx_data  = a_mesh_data->get_channel_data<md5_vtx_pntiw>();
 	m_indices   = a_mesh_data->get_count();
-	m_va        = a_device->create_vertex_array( a_mesh_data, nv::STREAM_DRAW );
+	m_va        = a_context->get_device()->create_vertex_array( a_mesh_data, nv::STREAM_DRAW );
 }
 
@@ -63,7 +64,5 @@
 
 		vertex_buffer* vb = m_va->find_buffer( nv::slot::POSITION );
-		vb->bind();
-		vb->update( m_pntdata.data(), 0, m_pntdata.raw_size() );
-		vb->unbind();
+		m_context->update( vb, m_pntdata.data(), 0, m_pntdata.raw_size() );
 	}
 }
@@ -200,8 +199,8 @@
 }
 
-nv::skeletal_mesh_gpu::skeletal_mesh_gpu( device* a_device, const mesh_data* a_mesh, const mesh_nodes_data* a_bone_data )
+nv::skeletal_mesh_gpu::skeletal_mesh_gpu( context* a_context, const mesh_data* a_mesh, const mesh_nodes_data* a_bone_data )
 	: skeletal_mesh(), m_bone_data( a_bone_data ), m_transform( nullptr )
 {
-	m_va          = a_device->create_vertex_array( a_mesh, nv::STATIC_DRAW );
+	m_va          = a_context->get_device()->create_vertex_array( a_mesh, nv::STATIC_DRAW );
 	m_index_count = a_mesh->get_count();
 	if ( m_bone_data )
Index: /trunk/src/gl/gl_context.cc
===================================================================
--- /trunk/src/gl/gl_context.cc	(revision 298)
+++ /trunk/src/gl/gl_context.cc	(revision 299)
@@ -8,6 +8,111 @@
 #include "nv/lib/gl.hh"
 #include "nv/lib/sdl.hh"
+#include "nv/gl/gl_texture2d.hh"
+#include "nv/gl/gl_program.hh"
+#include "nv/gl/gl_vertex_buffer.hh"
 
 using namespace nv;
+
+void gl_context::bind( texture2d* texture, texture_slot slot )
+{
+	GLuint id = static_cast< gl_texture2d* >( texture )->m_name.get_value();
+	glActiveTexture( GL_TEXTURE0 + static_cast< GLenum >( slot ) );
+	glBindTexture( GL_TEXTURE_2D, id );
+}
+
+void nv::gl_context::bind( program* p )
+{
+	gl_program* glp = static_cast< gl_program* >( p );
+	glUseProgram( glp->m_name.get_value() );
+	glp->update_uniforms();
+}
+
+void nv::gl_context::bind( vertex_buffer* b )
+{
+	GLuint id = static_cast< gl_vertex_buffer* >( b )->m_name.get_value();
+	glBindBuffer( GL_ARRAY_BUFFER, id );
+}
+
+void nv::gl_context::bind( index_buffer* b )
+{
+	GLuint id = static_cast< gl_index_buffer* >( b )->m_name.get_value();
+	glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, id );
+}
+
+void nv::gl_context::bind( vertex_array* va )
+{
+	for ( vertex_buffer_attribute_map::iterator i = va->m_map.begin(); 	i != va->m_map.end(); ++i ) 
+	{
+		uint32 location             = static_cast<uint32>( i->first );
+		vertex_buffer_attribute* va = i->second;
+		vertex_buffer*           vb = va->get_buffer();
+		glEnableVertexAttribArray( location );
+		bind( vb );
+		glVertexAttribPointer( 
+			location, 
+			static_cast<GLint>( va->get_components() ), 
+			nv::datatype_to_gl_enum( va->get_datatype() ),
+			GL_FALSE,
+			static_cast<GLsizei>( va->get_stride() ),
+			(void*)va->get_offset()
+			);
+		unbind( vb );
+	}
+
+	if ( va->m_index )
+	{
+		bind( va->m_index );
+	}
+}
+
+void nv::gl_context::unbind( program* )
+{
+	glUseProgram( 0 );
+}
+
+void nv::gl_context::unbind( vertex_buffer* )
+{
+	glBindBuffer( GL_ARRAY_BUFFER, 0 );
+}
+
+void nv::gl_context::unbind( index_buffer* )
+{
+	glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, 0 );
+}
+
+void nv::gl_context::unbind( vertex_array* va )
+{
+	if ( va->m_index )
+	{
+		unbind( va->m_index );
+	}
+
+	for ( vertex_buffer_attribute_map::iterator i = va->m_map.begin(); 	i != va->m_map.end(); ++i ) 
+	{
+		glDisableVertexAttribArray( static_cast<uint32>( i->first ) );
+	}
+}
+
+void gl_context::update( texture2d* texture, void* data )
+{
+	GLuint id = static_cast< gl_texture2d* >( texture )->m_name.get_value();
+	image_format format = texture->get_format();
+	ivec2        size   = texture->get_size();
+
+	glBindTexture( GL_TEXTURE_2D, id );
+	glTexImage2D( GL_TEXTURE_2D, 0, (GLint)nv::image_format_to_enum(format.format), size.x, size.y, 0, nv::image_format_to_enum(format.format), nv::datatype_to_gl_enum(format.type), data );
+}
+
+void gl_context::update( vertex_buffer* b, const void* data, size_t offset, size_t size )
+{
+	bind( b );
+	glBufferSubData( GL_ARRAY_BUFFER, (GLintptr)offset, (GLsizeiptr)size, data );
+}
+
+void gl_context::update( index_buffer* b, const void* data, size_t offset, size_t size )
+{
+	bind( b );
+	glBufferSubData( GL_ELEMENT_ARRAY_BUFFER, (GLintptr)offset, (GLsizeiptr)size, data );
+}
 
 void gl_context::clear( const clear_state& cs )
@@ -372,5 +477,4 @@
 }
 
-
 void gl_context::draw( primitive prim, const render_state& rs, program* p, vertex_array* va, size_t count )
 {
@@ -378,6 +482,6 @@
 	if ( count > 0 )
 	{
-		p->bind();
-		va->bind();
+		bind( p );
+		bind( va );
 		if ( va->has_index_buffer() )
 		{
@@ -388,6 +492,6 @@
 			glDrawArrays( primitive_to_enum(prim), 0, static_cast<GLsizei>( count ) );
 		}
-		va->unbind();
-		p->unbind();
+		unbind( va );
+		//unbind( p );
 	}
 }
Index: /trunk/src/gl/gl_device.cc
===================================================================
--- /trunk/src/gl/gl_device.cc	(revision 298)
+++ /trunk/src/gl/gl_device.cc	(revision 299)
@@ -67,5 +67,5 @@
 vertex_array* gl_device::create_vertex_array()
 {
-	return new gl_vertex_array();
+	return new vertex_array();
 }
 
Index: /trunk/src/gl/gl_program.cc
===================================================================
--- /trunk/src/gl/gl_program.cc	(revision 298)
+++ /trunk/src/gl/gl_program.cc	(revision 299)
@@ -125,15 +125,4 @@
 	load_uniforms();
 	return true;
-}
-
-void gl_program::bind()
-{
-	glUseProgram( m_name.get_value() );
-	update_uniforms();
-}
-
-void gl_program::unbind()
-{
-	glUseProgram( 0 );
 }
 
Index: /trunk/src/gl/gl_texture2d.cc
===================================================================
--- /trunk/src/gl/gl_texture2d.cc	(revision 298)
+++ /trunk/src/gl/gl_texture2d.cc	(revision 299)
@@ -31,28 +31,8 @@
 	if (data)
 	{
-		assign(data);
+		glBindTexture( GL_TEXTURE_2D, m_name.get_value() );
+		glTexImage2D( GL_TEXTURE_2D, 0, (GLint)nv::image_format_to_enum(m_format.format), m_size.x, m_size.y, 0, nv::image_format_to_enum(m_format.format), nv::datatype_to_gl_enum(m_format.type), data );
+		glBindTexture( GL_TEXTURE_2D, 0 );
 	}
 }
 
-void nv::gl_texture2d::assign( void* data )
-{
-	glBindTexture( GL_TEXTURE_2D, m_name.get_value() );
-	glTexImage2D( GL_TEXTURE_2D, 0, (GLint)nv::image_format_to_enum(m_format.format), m_size.x, m_size.y, 0, nv::image_format_to_enum(m_format.format), nv::datatype_to_gl_enum(m_format.type), data );
-	glBindTexture( GL_TEXTURE_2D, 0 );
-}
-
-void nv::gl_texture2d::bind( size_t slot )
-{
-	glActiveTexture( GL_TEXTURE0 + static_cast< GLenum >( slot ) );
-	glBindTexture( GL_TEXTURE_2D, m_name.get_value() );
-}
-
-void nv::gl_texture2d::unbind()
-{
-	glBindTexture( GL_TEXTURE_2D, 0 );
-}
-
-bool nv::gl_texture2d::is_valid() const
-{
-	return m_name.is_valid();
-}
Index: /trunk/src/gl/gl_vertex_buffer.cc
===================================================================
--- /trunk/src/gl/gl_vertex_buffer.cc	(revision 298)
+++ /trunk/src/gl/gl_vertex_buffer.cc	(revision 299)
@@ -13,29 +13,7 @@
 	: vertex_buffer( hint, size ), m_name()
 {
-	bind();
+	glBindBuffer( GL_ARRAY_BUFFER, m_name.get_value() );
 	glBufferData( GL_ARRAY_BUFFER, (GLsizeiptr)m_size, data, buffer_hint_to_enum( m_hint ) );
-	unbind();
-}
-
-void gl_vertex_buffer::update( const void* data, size_t offset, size_t size )
-{
-	// IMPORTANT - THIS DOES NOT BIND, SHOULD IT?
-	glBufferSubData( GL_ARRAY_BUFFER, (GLintptr)offset, (GLsizeiptr)size, data );
-}
-
-
-void gl_vertex_buffer::bind()
-{
-	glBindBuffer( GL_ARRAY_BUFFER, m_name.get_value() );
-}
-
-void gl_vertex_buffer::unbind()
-{
 	glBindBuffer( GL_ARRAY_BUFFER, 0 );
-}
-
-bool gl_vertex_buffer::is_valid() const
-{
-	return m_name.is_valid();
 }
 
@@ -43,70 +21,7 @@
 	: index_buffer( hint, size ), m_name()
 {
-	bind();
+	glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, m_name.get_value() );
 	glBufferData( GL_ELEMENT_ARRAY_BUFFER, (GLsizeiptr)m_size, data, buffer_hint_to_enum( m_hint ) );
-	unbind();
-}
-
-void gl_index_buffer::update( const void* data, size_t offset, size_t size )
-{
-	glBufferSubData( GL_ELEMENT_ARRAY_BUFFER, (GLintptr)offset, (GLsizeiptr)size, data );
-}
-
-void gl_index_buffer::bind()
-{
-	glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, m_name.get_value() );
-}
-
-void gl_index_buffer::unbind()
-{
 	glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, 0 );
 }
 
-bool gl_index_buffer::is_valid() const
-{
-	return m_name.is_valid();
-}
-
-gl_vertex_array::gl_vertex_array()
-{
-
-}
-
-void gl_vertex_array::bind()
-{
-	for ( vertex_buffer_attribute_map::iterator i = m_map.begin(); 	i != m_map.end(); ++i ) 
-	{
-		uint32 location             = static_cast<uint32>( i->first );
-		vertex_buffer_attribute* va = i->second;
-		vertex_buffer*           vb = va->get_buffer();
-		glEnableVertexAttribArray( location );
-		vb->bind();
-		glVertexAttribPointer( 
-			location, 
-			static_cast<GLint>( va->get_components() ), 
-			nv::datatype_to_gl_enum( va->get_datatype() ),
-			GL_FALSE,
-			static_cast<GLsizei>( va->get_stride() ),
-			(void*)va->get_offset()
-			);
-		vb->unbind();
-	}
-
-	if ( m_index )
-	{
-		m_index->bind();
-	}
-}
-
-void gl_vertex_array::unbind()
-{
-	if ( m_index )
-	{
-		m_index->unbind();
-	}
-
-	for ( vertex_buffer_attribute_map::iterator i = m_map.begin(); 	i != m_map.end(); ++i ) 
-	{
-		glDisableVertexAttribArray( static_cast<uint32>( i->first ) );
-	}
-}
Index: /trunk/src/gui/gui_renderer.cc
===================================================================
--- /trunk/src/gui/gui_renderer.cc	(revision 298)
+++ /trunk/src/gui/gui_renderer.cc	(revision 299)
@@ -65,6 +65,6 @@
 {
 public:
-	screen_render_data( device* dev, size_t initial_size )
-		: buffer( dev, nv::DYNAMIC_DRAW, initial_size ), varray( nullptr ), shader(nullptr), texture(nullptr) 
+	screen_render_data( context* ctx, size_t initial_size )
+		: buffer( ctx, nv::DYNAMIC_DRAW, initial_size ), varray( nullptr ), shader(nullptr), texture(nullptr) 
 	{
 
@@ -98,4 +98,5 @@
 	, m_reupload( true )
 {
+	m_context = w->get_context();
 	m_area.dim( dimension( w->get_width(), w->get_height() ) );
 	region white = m_atlas.get_region( ivec2(3,3) );
@@ -107,5 +108,5 @@
 	delete[] wfill;
 
-	screen_render_data* sr = new screen_render_data( w->get_device(), 1024 );
+	screen_render_data* sr = new screen_render_data( w->get_context(), 1024 );
 	m_render_data = sr;
 	// ** EXTREMELY TEMPORARY!
@@ -261,5 +262,5 @@
 	if ( m_reupload )
 	{
-		sr->texture->assign( (void*)m_atlas.get_data() );
+		m_context->update( sr->texture, (void*)m_atlas.get_data() );
 		m_reupload = false;
 	}
@@ -272,6 +273,6 @@
 		sr->varray->update_vertex_buffer( nv::slot::COLOR,    vb, false );
 	}
-	sr->texture->bind( nv::TEX_DIFFUSE );
-	m_window->get_context()->draw( TRIANGLES, m_render_state, m_scene_state, sr->shader, sr->varray, sr->buffer.get_size() * 6 );
+	m_context->bind( sr->texture, TEX_DIFFUSE );
+	m_context->draw( TRIANGLES, m_render_state, m_scene_state, sr->shader, sr->varray, sr->buffer.get_size() * 6 );
 }
 
