Changeset 535 for trunk


Ignore:
Timestamp:
01/12/17 19:15:29 (8 years ago)
Author:
epyon
Message:
  • unified pixel_format instead of image_format
Location:
trunk
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/nv/gl/gl_context.hh

    r534 r535  
    4242                virtual void release( vertex_array va );
    4343                virtual void release( framebuffer f );
    44                 virtual image_data* dump_image( image_format f, image_data* reuse );
     44                virtual image_data* dump_image( pixel_format f, image_data* reuse );
    4545                virtual const framebuffer_info* get_framebuffer_info( framebuffer f ) const;
    4646
    4747                using context::create_texture;
    48                 virtual texture create_texture( texture_type type, ivec2 size, image_format aformat, sampler asampler, const void* data = nullptr );
    49                 virtual texture create_texture( texture_type type, ivec3 size, image_format aformat, sampler asampler, const void* data = nullptr );
     48                virtual texture create_texture( texture_type type, ivec2 size, pixel_format aformat, sampler asampler, const void* data = nullptr );
     49                virtual texture create_texture( texture_type type, ivec3 size, pixel_format aformat, sampler asampler, const void* data = nullptr );
    5050
    5151                virtual buffer create_buffer( buffer_type type, buffer_hint hint, uint32 size, const void* source = nullptr );
  • trunk/nv/image/png_loader.hh

    r486 r535  
    2020        public:
    2121                png_loader();
    22                 virtual bool get_info( stream&, image_format& format, ivec2& size );
     22                virtual bool get_info( stream&, pixel_format& format, ivec2& size );
    2323                virtual bool test( stream& );
    2424                virtual image_data* load( stream& );
    25                 virtual image_data* load( stream&, image_format format );
     25                virtual image_data* load( stream&, pixel_format format );
    2626        };
    2727
  • trunk/nv/interface/context.hh

    r534 r535  
    160160                virtual void release( buffer b ) { m_device->release( b ); }
    161161
    162                 virtual image_data* dump_image( image_format f, image_data* reuse ) = 0;
    163 
    164                 virtual texture create_texture( texture_type type, ivec2 size, image_format aformat, sampler asampler, const void* data = nullptr ) = 0;
    165                 virtual texture create_texture( texture_type type, ivec3 size, image_format aformat, sampler asampler, const void* data = nullptr ) = 0;
     162                virtual image_data* dump_image( pixel_format f, image_data* reuse ) = 0;
     163
     164
     165                virtual texture create_texture( texture_type type, ivec2 size, pixel_format aformat, sampler asampler, const void* data = nullptr ) = 0;
     166                virtual texture create_texture( texture_type type, ivec3 size, pixel_format aformat, sampler asampler, const void* data = nullptr ) = 0;
    166167                virtual texture create_texture( texture_type type, pixel_format format ) { return m_device->create_texture( type, format ); }
    167168                // TODO: remove?
    168                 texture create_texture( ivec2 size, image_format aformat, sampler asampler, const void* data = nullptr )
     169                texture create_texture( ivec2 size, pixel_format aformat, sampler asampler, const void* data = nullptr )
    169170                {
    170171                        return create_texture( TEXTURE_2D, size, aformat, asampler, data );
  • trunk/nv/interface/device.hh

    r515 r535  
    173173                texture_type type;
    174174                ivec3        size;
    175                 image_format format;
     175                pixel_format format;
    176176                sampler      tsampler;
    177177        };
  • trunk/nv/interface/image_data.hh

    r534 r535  
    2020namespace nv
    2121{
    22         enum pixel_format
     22
     23        enum pixel_format : uint8
    2324        {
    24                 RGB,
    25                 RGBA,
     25                RGB8,
     26                RGBA8,
     27                BGR8,
     28                BGRA8,
     29                R8,
     30                RGB16F,
     31                RGBA16F,
    2632                RGB32F,
    2733                RGBA32F,
    28                 RGB16F,
    29                 RGBA16F,
    30                 BGR,
    31                 BGRA,
    32                 RED,
    3334                R16F,
    3435                R32F,
     
    4849                RGBA32I,
    4950                RGBA32UI,
     51                PIXEL_FORMAT_COUNT,
    5052        };
    51        
    52         struct image_format
     53
     54        struct pixel_format_info
    5355        {
    54                 pixel_format format;
    55                 datatype     type;
     56                datatype type;
     57                uint32   elements;
     58        };
    5659
    57                 image_format( pixel_format f = RGB, datatype d = UBYTE )
    58                         : format( f ), type( d )  {}
    59         };
     60        inline const pixel_format_info& get_pixel_format_info( pixel_format dt )
     61        {
     62                static pixel_format_info info[PIXEL_FORMAT_COUNT] = {
     63                        { UBYTE, 3 }, // RGB8,
     64                        { UBYTE, 4 }, // RGBA8,
     65                        { UBYTE, 3 }, // BGR8 
     66                        { UBYTE, 4 }, // BGRA8,
     67                        { UBYTE, 1 }, // R8,
     68                        { FLOAT, 3 }, // RGB16F,
     69                        { FLOAT, 4 }, // RGBA16F, // HALF-FLOAT
     70                        { FLOAT, 3 }, // RGB32F,
     71                        { FLOAT, 4 }, // RGBA32F,
     72                        { FLOAT, 1 }, // R16F  // HALF-FLOAT
     73                        { FLOAT, 1 }, // R32F,
     74                        { USHORT,1 }, // DEPTH16,
     75                        { UINT,  1 }, // DEPTH24,
     76                        { UINT,  1 }, // DEPTH32,
     77                        { BYTE,  1 }, // R8I,
     78                        { UBYTE, 1 }, // R8UI,
     79                        { SHORT, 1 }, // R16I,
     80                        { USHORT,1 }, // R16UI,
     81                        { INT,   1 }, // R32I,
     82                        { UINT,  1 }, // R32UI,
     83                        { BYTE,  4 }, // RGBA8I,
     84                        { UBYTE, 4 }, // RGBA8UI,
     85                        { SHORT, 4 }, // RGBA16I,
     86                        { USHORT,4 }, // RGBA16UI,
     87                        { INT,   4 }, // RGBA32I,
     88                        { UINT,  4 }, // RGBA32UI,
     89                };
     90                return info[dt];
     91        }
    6092
    6193        class image_data
    6294        {
    6395        public:
    64                 image_data( image_format format, ivec2 size, const uint8 * data )
     96                image_data( pixel_format format, ivec2 size, const uint8 * data )
    6597                        : m_format( format ), m_size( size ), m_data( nullptr )
    6698                {
     
    68100                        initialize( data );
    69101                }
    70                 image_data( image_format format, ivec2 size )
     102                image_data( pixel_format format, ivec2 size )
    71103                        : m_format( format ), m_size( size ), m_data( nullptr )
    72104                {
     
    81113                const uint8 * get_data()    const { return m_data; }
    82114                const ivec2 get_size() const { return m_size; }
    83                 // TODO : better depth check (template?)
    84                 uint32 get_depth() const { return m_format.format == RGB || m_format.format == BGR ? 3 : ( m_format.format == RED || m_format.format == R32F || m_format.format == R16F ? 1 : 4 ); }
    85                 image_format get_format() const { return m_format; }
     115                uint32 get_depth() const
     116                {
     117                        return get_pixel_format_info( m_format ).elements;
     118                }
     119                datatype get_type() const
     120                {
     121                        return get_pixel_format_info( m_format ).type;
     122                }
     123                pixel_format get_format() const { return m_format; }
    86124                ~image_data() { if (m_data) delete[] m_data; }
    87125        private:
     
    94132                }
    95133
    96                 image_format m_format;
     134                pixel_format m_format;
    97135                ivec2  m_size;  //!< Defines the size of the image as a vector
    98136                uint8* m_data;  //!< Holder for data
  • trunk/nv/interface/image_loader.hh

    r487 r535  
    2424        {
    2525        public:
    26                 virtual bool get_info( stream&, image_format& format, ivec2& size ) = 0;
     26                virtual bool get_info( stream&, pixel_format& format, ivec2& size ) = 0;
    2727                virtual bool test( stream& ) = 0;
    2828                virtual image_data* load( stream& ) = 0;
    29                 virtual image_data* load( stream&, image_format format ) = 0;
     29                virtual image_data* load( stream&, pixel_format format ) = 0;
    3030                virtual ~image_loader() {}
    3131        };
  • trunk/nv/stl/math.hh

    r532 r535  
    136136        template < datatype EnumType > struct enum_to_type {};
    137137
    138         template <> struct enum_to_type< NONE >  { typedef void type; };
    139         template <> struct enum_to_type< INT >   { typedef int type; };
    140         template <> struct enum_to_type< UINT >  { typedef unsigned int type; };
    141         template <> struct enum_to_type< SHORT > { typedef short type; };
    142         template <> struct enum_to_type< USHORT >{ typedef unsigned short type; };
    143         template <> struct enum_to_type< BYTE >  { typedef char type; };
    144         template <> struct enum_to_type< UBYTE > { typedef unsigned char type; };
    145         template <> struct enum_to_type< FLOAT > { typedef f32 type; };
     138        template <> struct enum_to_type< NONE >   { typedef void type; };
     139        template <> struct enum_to_type< INT >    { typedef int type; };
     140        template <> struct enum_to_type< UINT >   { typedef unsigned int type; };
     141        template <> struct enum_to_type< SHORT >  { typedef short type; };
     142        template <> struct enum_to_type< USHORT > { typedef unsigned short type; };
     143        template <> struct enum_to_type< BYTE >   { typedef char type; };
     144        template <> struct enum_to_type< UBYTE >  { typedef unsigned char type; };
     145        template <> struct enum_to_type< FLOAT >  { typedef f32 type; };
    146146
    147147        template <> struct enum_to_type< FLOAT_VECTOR_2 > { typedef vec2 type; };
  • trunk/src/engine/material_manager.cc

    r517 r535  
    1919        uint8 data[2 * 2 * 4];
    2020        nv::raw_fill_n( data, 2 * 2 * 4, 0 );
    21         m_default = m_context->create_texture( ivec2(2,2), nv::image_format( nv::RGBA ), nv::sampler(), data );
     21        m_default = m_context->create_texture( ivec2(2,2), nv::RGBA8, nv::sampler(), data );
    2222}
    2323
  • trunk/src/engine/shadow.cc

    r508 r535  
    1212{
    1313        m_map_size = map_size;
    14         m_maps = context->create_texture( TEXTURE_2D_ARRAY, ivec3( map_size, map_size, count ), image_format( DEPTH24, UINT ), sampler( sampler::LINEAR, sampler::CLAMP_TO_EDGE ), nullptr );
     14        m_maps = context->create_texture( TEXTURE_2D_ARRAY, ivec3( map_size, map_size, count ), DEPTH24, sampler( sampler::LINEAR, sampler::CLAMP_TO_EDGE ), nullptr );
    1515        m_passes.resize( count );
    1616        for ( uint32 i = 0; i < count; ++i )
     
    3232void nv::shadow_data::initialize( context* context, uint32 count, uint32 map_size, const render_pass& pass_base, const render_pass& color_base )
    3333{
    34         m_color_maps = context->create_texture( TEXTURE_2D_ARRAY, ivec3( map_size, map_size, count ), image_format( RGBA16F, FLOAT ), sampler( sampler::LINEAR, sampler::CLAMP_TO_EDGE ), nullptr );
     34        m_color_maps = context->create_texture( TEXTURE_2D_ARRAY, ivec3( map_size, map_size, count ), RGBA16F, sampler( sampler::LINEAR, sampler::CLAMP_TO_EDGE ), nullptr );
    3535
    3636        initialize( context, count, map_size, pass_base );
  • trunk/src/gl/gl_context.cc

    r534 r535  
    126126}
    127127
    128 nv::image_data* nv::gl_context::dump_image( image_format f, image_data* reuse )
    129 {
    130         NV_ASSERT_ALWAYS( f.type   == nv::UBYTE, "Bad format passed to dump" );
    131         NV_ASSERT_ALWAYS( f.format == nv::RGB || f.format == nv::RGBA, "Bad format passed to dump" );
     128nv::image_data* nv::gl_context::dump_image( pixel_format format, image_data* reuse )
     129{
     130        NV_ASSERT_ALWAYS( format == nv::RGB8 || format == nv::RGBA8, "Bad format passed to dump" );
    132131        glPixelStorei( GL_PACK_ALIGNMENT, 1 );
    133132        image_data* result = reuse;
    134         if ( !result ) result = new image_data( f, ivec2( m_viewport.z, m_viewport.w ) );
    135         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() ) );
     133        datatype type = get_pixel_format_info( format ).type;
     134        if ( !result ) result = new image_data( format, ivec2( m_viewport.z, m_viewport.w ) );
     135        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() ) );
    136136        return result;
    137137}
     
    307307                NV_ASSERT_ALWAYS( binfo->type == TEXTURE_BUFFER && tinfo->type == TEXTURE_1D_BUFFER, "bad texture or buffer type!" );
    308308                bind( t, TEXTURE_0 );
    309                 glTexBuffer( GL_TEXTURE_BUFFER, image_format_to_internal_enum( tinfo->format.format ), binfo->glid );
     309                glTexBuffer( GL_TEXTURE_BUFFER, image_format_to_internal_enum( tinfo->format ), binfo->glid );
    310310        }
    311311}
     
    451451        if ( info )
    452452        {
    453                 image_format format  = info->format;
     453                pixel_format format  = info->format;
     454                datatype     type    = get_pixel_format_info( format ).type;
    454455                ivec3        size    = info->size;
    455456                unsigned     gl_type = texture_type_to_enum( info->type );
     
    457458                bind( t, texture_slot::TEXTURE_0 );
    458459                if ( info->type == TEXTURE_3D || info->type == TEXTURE_2D_ARRAY )
    459 //                      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 );
    460                         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 );
     460//                      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 );
     461                        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 );
    461462                else
    462 //                      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 );
    463                         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 );
     463//                      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 );
     464                        glTexSubImage2D( gl_type, 0, 0, 0, size.x, size.y, nv::image_format_to_enum( format ), nv::datatype_to_gl_enum( type ), data );
    464465        }
    465466}
     
    898899}
    899900
    900 nv::texture nv::gl_context::create_texture( texture_type type, ivec2 size, image_format aformat, sampler asampler, const void* data /*= nullptr */ )
    901 {
    902         texture result = create_texture( type, aformat.format );
     901nv::texture nv::gl_context::create_texture( texture_type type, ivec2 size, pixel_format aformat, sampler asampler, const void* data /*= nullptr */ )
     902{
     903        texture result = create_texture( type, aformat );
    903904        gl_texture_info* info = static_cast<gl_device*>( m_device )->get_full_texture_info( result );
    904905        bind( result, texture_slot::TEXTURE_0 );
    905906        unsigned glid = info->glid;
    906907        unsigned gl_type = texture_type_to_enum( type );
    907         GLenum gl_internal = GLenum( image_format_to_internal_enum( aformat.format ) );
    908         unsigned gl_enum = image_format_to_enum( aformat.format );
    909 
    910         bool is_depth = aformat.format == DEPTH16 || aformat.format == DEPTH24 || aformat.format == DEPTH32;
     908        GLenum gl_internal = GLenum( image_format_to_internal_enum( aformat ) );
     909        unsigned gl_enum = image_format_to_enum( aformat );
     910
     911        bool is_depth = aformat == DEPTH16 || aformat == DEPTH24 || aformat == DEPTH32;
    911912
    912913        // Detect if mipmapping was requested
     
    953954
    954955        if ( gl_type != GL_TEXTURE_2D_MULTISAMPLE )
    955                 glTexImage2D( gl_type, 0, gl_internal, size.x, size.y, 0, gl_enum, nv::datatype_to_gl_enum( aformat.type ), data );
     956                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 );
    956957        else
    957958                glTexImage2DMultisample( gl_type, 4, gl_internal, size.x, size.y, 1 );
     
    974975}
    975976
    976 nv::texture nv::gl_context::create_texture( texture_type type, ivec3 size, image_format aformat, sampler asampler, const void* data /*= nullptr */ )
    977 {
    978         texture result = create_texture( type, aformat.format );
     977nv::texture nv::gl_context::create_texture( texture_type type, ivec3 size, pixel_format aformat, sampler asampler, const void* data /*= nullptr */ )
     978{
     979        texture result = create_texture( type, aformat );
    979980        gl_texture_info* info = static_cast<gl_device*>( m_device )->get_full_texture_info( result );
    980981        bind( result, texture_slot::TEXTURE_0 );
     
    983984        unsigned gl_type = texture_type_to_enum( type );
    984985
    985         bool is_depth = aformat.format == DEPTH16 || aformat.format == DEPTH24 || aformat.format == DEPTH32;
     986        bool is_depth = aformat == DEPTH16 || aformat == DEPTH24 || aformat == DEPTH32;
    986987
    987988        if ( asampler.filter_max != sampler::NEAREST )
     
    10071008
    10081009        //glTexStorage3D( GL_TEXTURE_2D_ARRAY, mipLevelCount, GL_RGBA8, width, height, layerCount );
    1009         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 );
     1010        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 );
    10101011
    10111012        bind( texture(), texture_slot::TEXTURE_0 );
  • trunk/src/gl/gl_device.cc

    r534 r535  
    3636        }
    3737        // TODO: BGR vs RGB, single channel
    38         pixel_format pformat = RGBA;
     38        pixel_format pformat = RGBA8;
    3939        switch ( image->format->BytesPerPixel )
    4040        {
    41         case 4: pformat = RGBA; break;
    42         case 3: pformat = RGB; break;
    43         case 1: pformat = RED; break;
     41        case 4: pformat = RGBA8; break;
     42        case 3: pformat = RGB8; break;
     43        case 1: pformat = R8; break;
    4444        default: NV_ASSERT( false, "BytesPerPixel != 4,3 or 1!" );
    4545        }
    46         image_format format( pformat, UBYTE );
    47         image_data* data = new image_data( format, ivec2( image->w, image->h ), static_cast<nv::uint8*>( image->pixels ) );
     46        image_data* data = new image_data( pformat, ivec2( image->w, image->h ), static_cast<nv::uint8*>( image->pixels ) );
    4847        return data;
    4948}
     
    6261        // TODO: BGR vs RGB, single channel
    6362        NV_ASSERT( image->format->BytesPerPixel > 2, "bytes per pixel > 2!" );
    64         image_format format( image->format->BytesPerPixel == 3 ? RGB : RGBA, UBYTE );
     63        pixel_format format( image->format->BytesPerPixel == 3 ? RGB8 : RGBA8 );
    6564        image_data* idata = new image_data( format, ivec2( image->w, image->h ), static_cast<nv::uint8*>( image->pixels ) );
    6665        return idata;
  • trunk/src/gl/gl_enum.cc

    r506 r535  
    182182        switch( format )
    183183        {
    184         case RGB     : return GL_RGB;
    185         case RGBA    : return GL_RGBA;
     184        case RGB8    : return GL_RGB;
     185        case RGBA8   : return GL_RGBA;
     186        case R8      : return GL_RED;
    186187        case RGB32F  : return GL_RGB;
    187188        case RGBA32F : return GL_RGBA;
    188189        case RGB16F  : return GL_RGB;
    189190        case RGBA16F : return GL_RGBA;
    190         case BGR     : return GL_BGR;
    191         case BGRA    : return GL_BGRA;
    192         case RED     : return GL_RED;
     191        case BGR8    : return GL_BGR;
     192        case BGRA8   : return GL_BGRA;
    193193        case R16F    : return GL_RED;
    194194        case R32F    : return GL_RED;
     
    202202        case R32I    : return GL_RED_INTEGER;
    203203        case R32UI   : return GL_RED_INTEGER;
    204         case RGBA8I  : return GL_RGBA;
    205         case RGBA8UI : return GL_RGBA;
    206         case RGBA16I : return GL_RGBA;
    207         case RGBA16UI: return GL_RGBA;
    208         case RGBA32I : return GL_RGBA;
    209         case RGBA32UI: return GL_RGBA;
     204        case RGBA8I  : return GL_RGBA_INTEGER;
     205        case RGBA8UI : return GL_RGBA_INTEGER;
     206        case RGBA16I : return GL_RGBA_INTEGER;
     207        case RGBA16UI: return GL_RGBA_INTEGER;
     208        case RGBA32I : return GL_RGBA_INTEGER;
     209        case RGBA32UI: return GL_RGBA_INTEGER;
    210210        NV_RETURN_COVERED_DEFAULT( 0 );
    211211        }
     
    216216        switch( format )
    217217        {
    218         case RGB     : return GL_RGB8;
    219         case RGBA    : return GL_RGBA8;
     218        case RGB8    : return GL_RGB8;
     219        case RGBA8   : return GL_RGBA8;
     220        case R8      : return GL_R8;
    220221        case RGB32F  : return GL_RGB32F;
    221222        case RGBA32F : return GL_RGBA32F;
    222223        case RGB16F  : return GL_RGBA16F;
    223224        case RGBA16F : return GL_RGBA16F;
    224         case BGR     : return GL_RGB8;
    225         case BGRA    : return GL_RGBA8;
    226         case RED     : return GL_R8;
     225        case BGR8    : return GL_RGB8;
     226        case BGRA8   : return GL_RGBA8;
    227227        case R16F    : return GL_R16F;
    228228        case R32F    : return GL_R32F;
    229229        case DEPTH16 : return GL_DEPTH_COMPONENT16;
    230230        case DEPTH24 : return GL_DEPTH_COMPONENT24;
    231         case DEPTH32:  return GL_DEPTH_COMPONENT32;
     231        case DEPTH32 :  return GL_DEPTH_COMPONENT32;
    232232        case R8I     : return GL_R8I;
    233233        case R8UI    : return GL_R8UI;
  • trunk/src/gui/gui_gfx_renderer.cc

    r534 r535  
    166166
    167167        nv::sampler sampler( nv::sampler::LINEAR, nv::sampler::CLAMP_TO_EDGE );
    168         sr->tex = m_window->get_context()->create_texture( m_atlas.get_size(), image_format( nv::RGBA, nv::UBYTE ), sampler, nullptr );
     168        sr->tex = m_window->get_context()->create_texture( m_atlas.get_size(), nv::RGBA8, sampler, nullptr );
    169169
    170170        m_render_state.depth_test.enabled = false;
  • trunk/src/image/png_loader.cc

    r534 r535  
    10151015png_loader::png_loader() {}
    10161016
    1017 bool nv::png_loader::get_info( stream& str, image_format& format, ivec2& size )
     1017bool nv::png_loader::get_info( stream& str, pixel_format& format, ivec2& size )
    10181018{
    10191019        size_t pos = str.tell();
     
    10241024        {
    10251025                str.seek( (long)pos, origin::SET );
    1026                 format.type = UBYTE;
    10271026                switch ( comp )
    10281027                {
    10291028                case 0: return false;
    1030                 case 1: format.format = RED; break;
    1031                 case 3: format.format = RGB; break;
    1032                 case 4: format.format = RGBA; break;
     1029                case 1: format = R8; break;
     1030                case 3: format = RGB8; break;
     1031                case 4: format = RGBA8; break;
    10331032                default: return false;
    10341033                }
     
    10571056                // need to 'unget' all the characters in the IO buffer
    10581057                s.seek( -ctx.remaining(), origin::CUR );
    1059                 image_format format;
     1058                pixel_format format;
    10601059                ivec2 size;
    1061                 format.type = UBYTE;
    10621060                switch ( comp )
    10631061                {
    1064                 case 1: format.format = RED; break;
    1065                 case 3: format.format = RGB; break;
    1066                 case 4: format.format = RGBA; break;
     1062                case 1: format = R8; break;
     1063                case 3: format = RGB8; break;
     1064                case 4: format = RGBA8; break;
    10671065                default: return nullptr;
    10681066                }
     
    10731071}
    10741072
    1075 image_data* nv::png_loader::load( stream& s, image_format format )
    1076 {
    1077         NV_ASSERT( format.type == UBYTE, "!" );
     1073image_data* nv::png_loader::load( stream& s, pixel_format format )
     1074{
    10781075        int rcomp = 0;
    1079         switch ( format.format )
    1080         {
    1081         case RED: rcomp = 1; break;
    1082         case RGB: rcomp = 3; break;
    1083         case RGBA: rcomp = 4; break;
     1076        switch ( format )
     1077        {
     1078        case R8: rcomp = 1; break;
     1079        case RGB8: rcomp = 3; break;
     1080        case RGBA8: rcomp = 4; break;
    10841081        default: NV_ASSERT( false, "bad format requested!" ); return nullptr;
    10851082        }
     
    10911088        {
    10921089                s.seek( -ctx.remaining(), origin::CUR );
    1093                 image_format fmt;
     1090                pixel_format fmt;
    10941091                ivec2 sz;
    1095                 fmt.type = UBYTE;
    10961092                switch ( comp )
    10971093                {
    1098                 case 1: fmt.format = RED; break;
    1099                 case 3: fmt.format = RGB; break;
    1100                 case 4: fmt.format = RGBA; break;
     1094                case 1: fmt = R8; break;
     1095                case 3: fmt = RGB8; break;
     1096                case 4: fmt = RGBA8; break;
    11011097                default: NV_ASSERT( false, "UNKNOWN RESULT!" );
    11021098                }
Note: See TracChangeset for help on using the changeset viewer.