Index: trunk/src/gl/gl_context.cc
===================================================================
--- trunk/src/gl/gl_context.cc	(revision 534)
+++ trunk/src/gl/gl_context.cc	(revision 535)
@@ -126,12 +126,12 @@
 }
 
-nv::image_data* nv::gl_context::dump_image( image_format f, image_data* reuse )
-{
-	NV_ASSERT_ALWAYS( f.type   == nv::UBYTE, "Bad format passed to dump" );
-	NV_ASSERT_ALWAYS( f.format == nv::RGB || f.format == nv::RGBA, "Bad format passed to dump" );
+nv::image_data* nv::gl_context::dump_image( pixel_format format, image_data* reuse )
+{
+	NV_ASSERT_ALWAYS( format == nv::RGB8 || format == nv::RGBA8, "Bad format passed to dump" );
 	glPixelStorei( GL_PACK_ALIGNMENT, 1 );
 	image_data* result = reuse;
-	if ( !result ) result = new image_data( f, ivec2( m_viewport.z, m_viewport.w ) );
-	glReadPixels( 0, 0, m_viewport.z, m_viewport.w, f.format == nv::RGB ? GL_RGB : GL_RGBA, datatype_to_gl_enum( f.type ), const_cast< uint8* >( result->get_data() ) );
+	datatype type = get_pixel_format_info( format ).type;
+	if ( !result ) result = new image_data( format, ivec2( m_viewport.z, m_viewport.w ) );
+	glReadPixels( 0, 0, m_viewport.z, m_viewport.w, format == nv::RGB8 ? GL_RGB : GL_RGBA, datatype_to_gl_enum( type ), const_cast< uint8* >( result->get_data() ) );
 	return result;
 }
@@ -307,5 +307,5 @@
 		NV_ASSERT_ALWAYS( binfo->type == TEXTURE_BUFFER && tinfo->type == TEXTURE_1D_BUFFER, "bad texture or buffer type!" );
 		bind( t, TEXTURE_0 );
-		glTexBuffer( GL_TEXTURE_BUFFER, image_format_to_internal_enum( tinfo->format.format ), binfo->glid );
+		glTexBuffer( GL_TEXTURE_BUFFER, image_format_to_internal_enum( tinfo->format ), binfo->glid );
 	}
 }
@@ -451,5 +451,6 @@
 	if ( info )
 	{
-		image_format format  = info->format;
+		pixel_format format  = info->format;
+		datatype     type    = get_pixel_format_info( format ).type;
 		ivec3        size    = info->size;
 		unsigned     gl_type = texture_type_to_enum( info->type );
@@ -457,9 +458,9 @@
 		bind( t, texture_slot::TEXTURE_0 );
 		if ( info->type == TEXTURE_3D || info->type == TEXTURE_2D_ARRAY )
-//			glTexImage3D( gl_type, 0, static_cast<GLint>( nv::image_format_to_internal_enum( format.format ) ), size.x, size.y, size.z, 0, nv::image_format_to_enum( format.format ), nv::datatype_to_gl_enum( format.type ), data );
-			glTexSubImage3D( gl_type, 0, 0, 0, 0, size.x, size.y, size.z, nv::image_format_to_enum( format.format ), nv::datatype_to_gl_enum( format.type ), data );
+//			glTexImage3D( gl_type, 0, static_cast<GLint>( nv::image_format_to_internal_enum( format ) ), size.x, size.y, size.z, 0, nv::image_format_to_enum( format ), nv::datatype_to_gl_enum( type ), data );
+			glTexSubImage3D( gl_type, 0, 0, 0, 0, size.x, size.y, size.z, nv::image_format_to_enum( format ), nv::datatype_to_gl_enum( type ), data );
 		else
-//			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 );
-			glTexSubImage2D( gl_type, 0, 0, 0, size.x, size.y, nv::image_format_to_enum( format.format ), nv::datatype_to_gl_enum( format.type ), data );
+//			glTexImage2D( gl_type, 0, static_cast<GLint>( nv::image_format_to_internal_enum(format) ), size.x, size.y, 0, nv::image_format_to_enum(format), nv::datatype_to_gl_enum(type), data );
+			glTexSubImage2D( gl_type, 0, 0, 0, size.x, size.y, nv::image_format_to_enum( format ), nv::datatype_to_gl_enum( type ), data );
 	}
 }
@@ -898,15 +899,15 @@
 }
 
-nv::texture nv::gl_context::create_texture( texture_type type, ivec2 size, image_format aformat, sampler asampler, const void* data /*= nullptr */ )
-{
-	texture result = create_texture( type, aformat.format );
+nv::texture nv::gl_context::create_texture( texture_type type, ivec2 size, pixel_format aformat, sampler asampler, const void* data /*= nullptr */ )
+{
+	texture result = create_texture( type, aformat );
 	gl_texture_info* info = static_cast<gl_device*>( m_device )->get_full_texture_info( result );
 	bind( result, texture_slot::TEXTURE_0 );
 	unsigned glid = info->glid;
 	unsigned gl_type = texture_type_to_enum( type );
-	GLenum gl_internal = GLenum( image_format_to_internal_enum( aformat.format ) );
-	unsigned gl_enum = image_format_to_enum( aformat.format );
-
-	bool is_depth = aformat.format == DEPTH16 || aformat.format == DEPTH24 || aformat.format == DEPTH32;
+	GLenum gl_internal = GLenum( image_format_to_internal_enum( aformat ) );
+	unsigned gl_enum = image_format_to_enum( aformat );
+
+	bool is_depth = aformat == DEPTH16 || aformat == DEPTH24 || aformat == DEPTH32;
 
 	// Detect if mipmapping was requested
@@ -953,5 +954,5 @@
 
 	if ( gl_type != GL_TEXTURE_2D_MULTISAMPLE )
-		glTexImage2D( gl_type, 0, gl_internal, size.x, size.y, 0, gl_enum, nv::datatype_to_gl_enum( aformat.type ), data );
+		glTexImage2D( gl_type, 0, gl_internal, size.x, size.y, 0, gl_enum, nv::datatype_to_gl_enum( get_pixel_format_info( aformat ).type ), data );
 	else
 		glTexImage2DMultisample( gl_type, 4, gl_internal, size.x, size.y, 1 );
@@ -974,7 +975,7 @@
 }
 
-nv::texture nv::gl_context::create_texture( texture_type type, ivec3 size, image_format aformat, sampler asampler, const void* data /*= nullptr */ )
-{
-	texture result = create_texture( type, aformat.format );
+nv::texture nv::gl_context::create_texture( texture_type type, ivec3 size, pixel_format aformat, sampler asampler, const void* data /*= nullptr */ )
+{
+	texture result = create_texture( type, aformat );
 	gl_texture_info* info = static_cast<gl_device*>( m_device )->get_full_texture_info( result );
 	bind( result, texture_slot::TEXTURE_0 );
@@ -983,5 +984,5 @@
 	unsigned gl_type = texture_type_to_enum( type );
 
-	bool is_depth = aformat.format == DEPTH16 || aformat.format == DEPTH24 || aformat.format == DEPTH32;
+	bool is_depth = aformat == DEPTH16 || aformat == DEPTH24 || aformat == DEPTH32;
 
 	if ( asampler.filter_max != sampler::NEAREST )
@@ -1007,5 +1008,5 @@
 
 	//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 );
+	glTexImage3D( gl_type, 0, GLint( nv::image_format_to_internal_enum( aformat ) ), size.x, size.y, size.z, 0, nv::image_format_to_enum( aformat ), nv::datatype_to_gl_enum( get_pixel_format_info( aformat ).type ), data );
 
 	bind( texture(), texture_slot::TEXTURE_0 );
