Ignore:
Timestamp:
02/04/15 16:37:00 (10 years ago)
Author:
epyon
Message:
  • massive untracked updates
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/gl/gl_device.cc

    r331 r350  
    4949        image_data* data = new image_data( format, glm::ivec2( image->w, image->h ), (nv::uint8*)image->pixels );
    5050        return data;
     51}
     52
     53// this is a temporary function that will be removed once we find a way to
     54// pass binary file data around
     55image_data* gl_device::create_image_data( const uint8* data, uint32 size )
     56{
     57        load_sdl_image_library();
     58        SDL_Surface* image = IMG_LoadTyped_RW( SDL_RWFromMem( (void*)data, size ), 1, "tga" );
     59        if ( !image )
     60        {
     61                NV_LOG( LOG_ERROR, "Image binary data cannot be loaded found!" );
     62                return nullptr;
     63        }
     64        // TODO: BGR vs RGB, single channel
     65        assert( image->format->BytesPerPixel > 2 );
     66        image_format format( image->format->BytesPerPixel == 3 ? RGB : RGBA, UBYTE );
     67        image_data* idata = new image_data( format, glm::ivec2( image->w, image->h ), ( nv::uint8* )image->pixels );
     68        return idata;
    5169}
    5270
Note: See TracChangeset for help on using the changeset viewer.