Index: trunk/src/gl/gl_context.cc
===================================================================
--- trunk/src/gl/gl_context.cc	(revision 295)
+++ 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 295)
+++ 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 295)
+++ 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 295)
+++ 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 295)
+++ 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 ) );
-	}
-}
