Index: trunk/src/gl/gl_device.cc
===================================================================
--- trunk/src/gl/gl_device.cc	(revision 461)
+++ trunk/src/gl/gl_device.cc	(revision 463)
@@ -17,5 +17,5 @@
 gl_device::gl_device()
 {
-	m_shader_header.append( "#version 120\n" );
+	m_shader_header.append( "#version 120\n#extension GL_EXT_texture_array : require\n" );
 	for ( auto& i : get_uniform_factory() ) 
 		m_shader_header.append( "uniform "+datatype_to_glsl_type( i.second->get_datatype() )+" "+ i.first +";\n" );
@@ -95,6 +95,10 @@
 nv::texture nv::gl_device::create_texture( texture_type type, ivec2 size, image_format aformat, sampler asampler, const void* data /*= nullptr */ )
 {
+	NV_ASSERT_ALWAYS( type != TEXTURE_3D && type != TEXTURE_2D_ARRAY, "2D texture type expected!" );
 	unsigned glid = 0;
 	unsigned gl_type = texture_type_to_enum( type );
+
+	bool is_depth = aformat.format == DEPTH16 || aformat.format == DEPTH24 || aformat.format == DEPTH32;
+
 	glGenTextures( 1, &glid );
 
@@ -117,4 +121,29 @@
 	glTexParameteri( gl_type, GL_TEXTURE_WRAP_S, GLint( nv::sampler_wrap_to_enum( asampler.wrap_s) ) );
 	glTexParameteri( gl_type, GL_TEXTURE_WRAP_T, GLint( nv::sampler_wrap_to_enum( asampler.wrap_t) ) );
+
+	if ( is_depth )
+	{
+#define GL_TEXTURE_DEPTH_SIZE 0x884A
+#define GL_DEPTH_TEXTURE_MODE 0x884B
+#define GL_TEXTURE_COMPARE_MODE 0x884C
+#define GL_TEXTURE_COMPARE_FUNC 0x884D
+#define GL_COMPARE_R_TO_TEXTURE 0x884E
+
+#define GL_INTENSITY 0x8049
+#define GL_LUMINANCE 0x1909
+// 		glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE );
+// 		glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL );
+// 		glTexParameteri( GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE, GL_LUMINANCE );
+//    		glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, 0 );
+//    		glTexParameteri( GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE, GL_INTENSITY );
+	}
+
+// #define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE
+// #define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF
+// 
+// 	float aniso = 0.0f;
+// 	glGetFloatv( GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &aniso );
+// 	NV_LOG_INFO( "Anisotropy at ", aniso, " (", int( aniso ), " ) " );
+// 	glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, aniso );
 
 	glTexImage2D( gl_type, 0, GLint( nv::image_format_to_internal_enum(aformat.format) ), size.x, size.y, 0, nv::image_format_to_enum(aformat.format), nv::datatype_to_gl_enum(aformat.type), data );
@@ -127,8 +156,45 @@
 	info->format   = aformat;
 	info->tsampler = asampler;
-	info->size     = size;
+	info->size     = ivec3( size.x, size.y, 1 );
 	info->glid     = glid;
 	return result;
 }
+
+nv::texture nv::gl_device::create_texture( texture_type type, ivec3 size, image_format aformat, sampler asampler, const void* data /*= nullptr */ )
+{
+	NV_ASSERT_ALWAYS( type == TEXTURE_3D || type == TEXTURE_2D_ARRAY, "3D texture type expected!" );
+	unsigned glid = 0;
+	unsigned gl_type = texture_type_to_enum( type );
+
+	bool is_depth = aformat.format == DEPTH16 || aformat.format == DEPTH24 || aformat.format == DEPTH32;
+
+	glGenTextures( 1, &glid );
+	glBindTexture( gl_type, glid );
+
+	if ( asampler.filter_max != sampler::NEAREST )
+	{
+		asampler.filter_max = sampler::LINEAR;
+	}
+
+	glTexParameteri( gl_type, GL_TEXTURE_MIN_FILTER, GLint( nv::sampler_filter_to_enum( asampler.filter_min ) ) );
+	glTexParameteri( gl_type, GL_TEXTURE_MAG_FILTER, GLint( nv::sampler_filter_to_enum( asampler.filter_max ) ) );
+	glTexParameteri( gl_type, GL_TEXTURE_WRAP_S, GLint( nv::sampler_wrap_to_enum( asampler.wrap_s ) ) );
+	glTexParameteri( gl_type, GL_TEXTURE_WRAP_T, GLint( nv::sampler_wrap_to_enum( asampler.wrap_t ) ) );
+
+	//glTexStorage3D( GL_TEXTURE_2D_ARRAY, mipLevelCount, GL_RGBA8, width, height, layerCount );
+	glTexImage3D( gl_type, 0, GLint( nv::image_format_to_internal_enum( aformat.format ) ), size.x, size.y, size.z, 0, nv::image_format_to_enum( aformat.format ), nv::datatype_to_gl_enum( aformat.type ), data );
+	glBindTexture( gl_type, 0 );
+
+	texture result = m_textures.create();
+	gl_texture_info* info = m_textures.get( result );
+	info->type = type;
+	info->format = aformat;
+	info->tsampler = asampler;
+	info->size = size;
+	info->glid = glid;
+	return result;
+}
+
+
 
 void nv::gl_device::release( texture t )
