Index: trunk/src/gl/gl_enum.cc
===================================================================
--- trunk/src/gl/gl_enum.cc	(revision 42)
+++ trunk/src/gl/gl_enum.cc	(revision 43)
@@ -134,4 +134,52 @@
 }
 
+unsigned int nv::texture_format_to_enum( texture2d::format format )
+{
+	switch( format )
+	{
+	case texture2d::RGB  : return GL_RGB;
+	case texture2d::RGBA : return GL_RGBA;
+	default : return 0; // TODO: throw!
+	}
+}
+
+unsigned int nv::texture_datatype_to_enum( texture2d::datatype datatype )
+{
+	switch( datatype )
+	{
+	case texture2d::UINT   : return GL_UNSIGNED_INT;
+	case texture2d::UBYTE  : return GL_UNSIGNED_BYTE;
+	case texture2d::FLOAT  : return GL_FLOAT;
+	default : return 0; // TODO: throw!
+	}
+}
+
+unsigned int nv::texture_filter_to_enum( texture2d_sampler::filter filter )
+{
+	switch( filter )
+	{
+	case texture2d_sampler::LINEAR                 : return GL_LINEAR;
+	case texture2d_sampler::NEAREST                : return GL_NEAREST;
+	case texture2d_sampler::NEAREST_MIPMAP_NEAREST : return GL_NEAREST_MIPMAP_NEAREST;
+	case texture2d_sampler::LINEAR_MIPMAP_NEAREST  : return GL_LINEAR_MIPMAP_NEAREST;
+	case texture2d_sampler::NEAREST_MIPMAP_LINEAR  : return GL_NEAREST_MIPMAP_LINEAR;
+	case texture2d_sampler::LINEAR_MIPMAP_LINEAR   : return GL_LINEAR_MIPMAP_LINEAR;
+	default : return 0; // TODO: throw!
+	}
+}
+
+unsigned int nv::texture_wrap_to_enum( texture2d_sampler::wrap wrap )
+{
+	switch( wrap )
+	{
+	case texture2d_sampler::CLAMP_TO_EDGE   : return GL_CLAMP_TO_EDGE;
+	case texture2d_sampler::CLAMP_TO_BORDER : return GL_CLAMP_TO_BORDER;
+	case texture2d_sampler::MIRRORED_REPEAT : return GL_MIRRORED_REPEAT;
+	case texture2d_sampler::REPEAT          : return GL_REPEAT;
+	default : return 0; // TODO: throw!
+	}
+}
+
+
 unsigned int nv::type_to_gl_enum( type type )
 {
Index: trunk/src/gl/gl_texture2d.cc
===================================================================
--- trunk/src/gl/gl_texture2d.cc	(revision 43)
+++ trunk/src/gl/gl_texture2d.cc	(revision 43)
@@ -0,0 +1,51 @@
+// Copyright (C) 2012-2013 Kornel Kisielewicz
+// This file is part of NV Libraries.
+// For conditions of distribution and use, see copyright notice in nv.hh
+
+#include "nv/gl/gl_texture2d.hh"
+
+#include "nv/gl/gl_enum.hh"
+#include "nv/lib/gl.hh"
+
+using namespace nv;
+
+nv::gl_texture2d::gl_texture2d( ivec2 size, format aformat, datatype adatatype, texture2d_sampler sampler, void* data /*= nullptr */ )
+	: texture2d( size, aformat, adatatype, sampler ), m_name()
+{
+	glBindTexture( GL_TEXTURE_2D, m_name.get_value() );
+
+	glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, nv::texture_filter_to_enum( m_sampler.filter_min ) );
+	glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, nv::texture_filter_to_enum( m_sampler.filter_max ) );
+	glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, nv::texture_wrap_to_enum( m_sampler.wrap_s) );
+	glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, nv::texture_wrap_to_enum( m_sampler.wrap_t) );
+
+	glBindTexture( GL_TEXTURE_2D, 0 );
+
+	if (data)
+	{
+		assign(data);
+	}
+}
+
+void nv::gl_texture2d::assign( void* data )
+{
+	glBindTexture( GL_TEXTURE_2D, m_name.get_value() );
+	glTexImage2D( GL_TEXTURE_2D, 0, nv::texture_format_to_enum(m_format), m_size.x, m_size.y, 0, nv::texture_format_to_enum(m_format), nv::texture_datatype_to_enum(m_datatype), data );
+	glBindTexture( GL_TEXTURE_2D, 0 );
+}
+
+void nv::gl_texture2d::bind( int slot )
+{
+	glActiveTexture( GL_TEXTURE0 + 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();
+}
