Integrated submission from Boris Bralo:
Supported added for precompiled mip maps stored in osg::Image, and read by osg::Texture. Updates to TerraPage loader for support of compressed texture images and precompiled mip maps.
This commit is contained in:
@@ -36,15 +36,22 @@ Image::Image(const Image& image,const CopyOp& copyop):
|
||||
_dataType(image._dataType),
|
||||
_packing(image._packing),
|
||||
_data(0L),
|
||||
_mipmapData(image._mipmapData),
|
||||
_modifiedTag(image._modifiedTag)
|
||||
{
|
||||
if (image._data)
|
||||
{
|
||||
unsigned int size = computeRowWidthInBytes(_s,_pixelFormat,_dataType,_packing)*_t*_r;
|
||||
int num_components =
|
||||
_pixelFormat == GL_LUMINANCE ? 1 :
|
||||
_pixelFormat == GL_LUMINANCE_ALPHA ? 2 :
|
||||
_pixelFormat == GL_RGB ? 3 :
|
||||
_pixelFormat == GL_RGBA ? 4 : 4;
|
||||
|
||||
_data = (unsigned char*) osgMalloc(size);
|
||||
int size = _s*_t*_r*num_components;
|
||||
_data = (unsigned char*) malloc(size);
|
||||
memcpy(_data,image._data,size);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Image::~Image()
|
||||
@@ -190,6 +197,8 @@ void Image::createImage(int s,int t,int r,
|
||||
GLenum format,GLenum type,
|
||||
int packing)
|
||||
{
|
||||
_mipmapData.clear();
|
||||
|
||||
unsigned int previousTotalSize = computeRowWidthInBytes(_s,_pixelFormat,_dataType,_packing)*_t*_r;
|
||||
|
||||
unsigned int newTotalSize = computeRowWidthInBytes(s,format,type,packing)*t*r;
|
||||
@@ -235,6 +244,7 @@ void Image::setImage(int s,int t,int r,
|
||||
int packing)
|
||||
{
|
||||
if (_data) ::free(_data);
|
||||
_mipmapData.clear();
|
||||
|
||||
_s = s;
|
||||
_t = t;
|
||||
|
||||
Reference in New Issue
Block a user