Index: trunk/src/gl/gl_context.cc
===================================================================
--- trunk/src/gl/gl_context.cc	(revision 498)
+++ trunk/src/gl/gl_context.cc	(revision 499)
@@ -428,4 +428,31 @@
 			glTexImage2D( gl_type, 0, static_cast<GLint>( nv::image_format_to_internal_enum(format.format) ), size.x, size.y, 0, nv::image_format_to_enum(format.format), nv::datatype_to_gl_enum(format.type), data );
 	}
+}
+
+void* nv::gl_context::map_buffer( buffer b, buffer_access ba, size_t offset, size_t length )
+{
+	const gl_buffer_info* info = static_cast<const gl_buffer_info*>( m_device->get_buffer_info( b ) );
+	unsigned int glenum = buffer_type_to_enum( info->type );
+	glBindBuffer( glenum, info->glid );
+	void* result = glMapBufferRange( glenum, GLintptr( offset ), GLsizeiptr( length ), buffer_access_to_bitfield( ba ) );
+	if ( result == nullptr )
+	{
+		while ( GLenum err = glGetError() )
+		switch ( err )
+		{
+		case GL_INVALID_VALUE     : NV_LOG_ERROR( "map_buffer failed : GL_INVALID_VALUE" ) break;
+		case GL_INVALID_OPERATION : NV_LOG_ERROR( "map_buffer failed : GL_INVALID_OPERATION " ) break;
+		case GL_OUT_OF_MEMORY     : NV_LOG_ERROR( "map_buffer failed : GL_OUT_OF_MEMORY " ) break;
+		default:
+			break;
+		}
+	}
+	return result;
+}
+
+void nv::gl_context::unmap_buffer( buffer b )
+{
+	const gl_buffer_info* info = static_cast<const gl_buffer_info*>( m_device->get_buffer_info( b ) );
+	glUnmapBuffer( buffer_type_to_enum( info->type ) );
 }
 
Index: trunk/src/gl/gl_enum.cc
===================================================================
--- trunk/src/gl/gl_enum.cc	(revision 498)
+++ trunk/src/gl/gl_enum.cc	(revision 499)
@@ -287,5 +287,4 @@
 }
 
-
 unsigned int nv::output_slot_to_enum( output_slot slot )
 {
@@ -307,4 +306,13 @@
 }
 
+
+unsigned int nv::buffer_access_to_bitfield( buffer_access type )
+{
+	switch ( type )
+	{
+	case WRITE_UNSYNCHRONIZED     : return GL_MAP_WRITE_BIT | GL_MAP_UNSYNCHRONIZED_BIT;
+	default: return 0; // TODO: throw!
+	}
+}
 
 unsigned int nv::datatype_to_gl_enum( datatype type )
