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

Legend:

Unmodified
Added
Removed
  • 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 );
Note: See TracChangeset for help on using the changeset viewer.