Added osg::Image::AllocationMode enum and associated set/get methods.
osg::Image::setImage has also been modified to require the AllocationMode mode to be passed to it so that it knows how to delete the data once the image goes out of scope. Port the image plugins across to specify the new AllocationMode, and converted them across to using new/delete in place of malloc/free.
This commit is contained in:
parent
7877c55770
commit
b32c8c65f3
15
examples/osgstereoimage/Makefile
Normal file
15
examples/osgstereoimage/Makefile
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
TOPDIR = ../..
|
||||||
|
include $(TOPDIR)/Make/makedefs
|
||||||
|
|
||||||
|
CXXFILES =\
|
||||||
|
osgstereoimage.cpp\
|
||||||
|
|
||||||
|
LIBS += -losgProducer -lProducer $(OSG_LIBS) -L/usr/local/lib $(FREETYPE_LIB) $(GLUT_LIB) $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS)
|
||||||
|
|
||||||
|
INSTFILES = \
|
||||||
|
$(CXXFILES)\
|
||||||
|
Makefile.inst=Makefile
|
||||||
|
|
||||||
|
EXEC = osgstereoimage
|
||||||
|
|
||||||
|
include $(TOPDIR)/Make/makerules
|
@ -64,6 +64,19 @@ class SG_EXPORT Image : public Object
|
|||||||
inline const std::string& getFileName() const { return _fileName; }
|
inline const std::string& getFileName() const { return _fileName; }
|
||||||
|
|
||||||
|
|
||||||
|
enum AllocationMode {
|
||||||
|
NO_DELETE,
|
||||||
|
USE_NEW_DELETE,
|
||||||
|
USE_MALLOC_FREE
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Set the method used for deleting data once it goes out of scope.*/
|
||||||
|
void setAllocationMode(AllocationMode mode) { _allocationMode = mode; }
|
||||||
|
|
||||||
|
/** Get the method used for deleting data once it goes out of scope.*/
|
||||||
|
AllocationMode setAllocationMode() const { return _allocationMode; }
|
||||||
|
|
||||||
|
|
||||||
/* allocated a pixel block of specified size and type.*/
|
/* allocated a pixel block of specified size and type.*/
|
||||||
void allocateImage(int s,int t,int r,
|
void allocateImage(int s,int t,int r,
|
||||||
GLenum format,GLenum type,
|
GLenum format,GLenum type,
|
||||||
@ -80,6 +93,7 @@ class SG_EXPORT Image : public Object
|
|||||||
GLint internalTextureformat,
|
GLint internalTextureformat,
|
||||||
GLenum format,GLenum type,
|
GLenum format,GLenum type,
|
||||||
unsigned char *data,
|
unsigned char *data,
|
||||||
|
AllocationMode mode,
|
||||||
int packing=1);
|
int packing=1);
|
||||||
|
|
||||||
/** readPixels from screen at specified position and size, using glReadPixels.
|
/** readPixels from screen at specified position and size, using glReadPixels.
|
||||||
@ -220,12 +234,19 @@ class SG_EXPORT Image : public Object
|
|||||||
Image& operator = (const Image&) { return *this; }
|
Image& operator = (const Image&) { return *this; }
|
||||||
|
|
||||||
std::string _fileName;
|
std::string _fileName;
|
||||||
|
|
||||||
int _s, _t, _r;
|
int _s, _t, _r;
|
||||||
GLint _internalTextureFormat;
|
GLint _internalTextureFormat;
|
||||||
GLenum _pixelFormat;
|
GLenum _pixelFormat;
|
||||||
GLenum _dataType;
|
GLenum _dataType;
|
||||||
unsigned int _packing;
|
unsigned int _packing;
|
||||||
|
|
||||||
|
AllocationMode _allocationMode;
|
||||||
unsigned char *_data;
|
unsigned char *_data;
|
||||||
|
|
||||||
|
void deallocateData();
|
||||||
|
|
||||||
|
void setData(unsigned char *data,AllocationMode allocationMode);
|
||||||
|
|
||||||
unsigned int _modifiedTag;
|
unsigned int _modifiedTag;
|
||||||
|
|
||||||
|
@ -34,7 +34,8 @@ Image::Image()
|
|||||||
_dataType = (unsigned int)0;
|
_dataType = (unsigned int)0;
|
||||||
_packing = 4;
|
_packing = 4;
|
||||||
|
|
||||||
_data = (unsigned char *)0L;
|
_allocationMode = USE_NEW_DELETE;
|
||||||
|
_data = (unsigned char *)0L;
|
||||||
|
|
||||||
_modifiedTag = 0;
|
_modifiedTag = 0;
|
||||||
}
|
}
|
||||||
@ -60,7 +61,7 @@ Image::Image(const Image& image,const CopyOp& copyop):
|
|||||||
_pixelFormat == GL_RGBA ? 4 : 4;
|
_pixelFormat == GL_RGBA ? 4 : 4;
|
||||||
|
|
||||||
int size = _s*_t*_r*num_components;
|
int size = _s*_t*_r*num_components;
|
||||||
_data = (unsigned char*) malloc(size);
|
setData(new unsigned char [size],USE_NEW_DELETE);
|
||||||
memcpy(_data,image._data,size);
|
memcpy(_data,image._data,size);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,15 +69,30 @@ Image::Image(const Image& image,const CopyOp& copyop):
|
|||||||
|
|
||||||
Image::~Image()
|
Image::~Image()
|
||||||
{
|
{
|
||||||
if (_data) ::free(_data);
|
deallocateData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Image::deallocateData()
|
||||||
|
{
|
||||||
|
if (_data) {
|
||||||
|
if (_allocationMode==USE_NEW_DELETE) delete [] _data;
|
||||||
|
else if (_allocationMode==USE_MALLOC_FREE) ::free(_data);
|
||||||
|
_data = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Image::setFileName(const std::string& fileName)
|
void Image::setFileName(const std::string& fileName)
|
||||||
{
|
{
|
||||||
_fileName = fileName;
|
_fileName = fileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Image::setData(unsigned char* data, AllocationMode mode)
|
||||||
|
{
|
||||||
|
deallocateData();
|
||||||
|
_data = data;
|
||||||
|
_allocationMode = mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Image::isPackedType(GLenum type)
|
bool Image::isPackedType(GLenum type)
|
||||||
{
|
{
|
||||||
@ -214,12 +230,10 @@ void Image::allocateImage(int s,int t,int r,
|
|||||||
|
|
||||||
if (newTotalSize!=previousTotalSize)
|
if (newTotalSize!=previousTotalSize)
|
||||||
{
|
{
|
||||||
if (_data) ::free(_data);
|
|
||||||
|
|
||||||
if (newTotalSize)
|
if (newTotalSize)
|
||||||
_data = (unsigned char *)malloc (newTotalSize);
|
setData(new unsigned char [newTotalSize],USE_NEW_DELETE);
|
||||||
else
|
else
|
||||||
_data = 0L;
|
deallocateData(); // and sets it to NULL.
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_data)
|
if (_data)
|
||||||
@ -251,9 +265,9 @@ void Image::setImage(int s,int t,int r,
|
|||||||
GLint internalTextureFormat,
|
GLint internalTextureFormat,
|
||||||
GLenum format,GLenum type,
|
GLenum format,GLenum type,
|
||||||
unsigned char *data,
|
unsigned char *data,
|
||||||
|
AllocationMode mode,
|
||||||
int packing)
|
int packing)
|
||||||
{
|
{
|
||||||
if (_data) ::free(_data);
|
|
||||||
_mipmapData.clear();
|
_mipmapData.clear();
|
||||||
|
|
||||||
_s = s;
|
_s = s;
|
||||||
@ -264,12 +278,10 @@ void Image::setImage(int s,int t,int r,
|
|||||||
_pixelFormat = format;
|
_pixelFormat = format;
|
||||||
_dataType = type;
|
_dataType = type;
|
||||||
|
|
||||||
_data = data;
|
setData(data,mode);
|
||||||
|
|
||||||
_packing = packing;
|
_packing = packing;
|
||||||
|
|
||||||
// test scaling...
|
|
||||||
// scaleImageTo(16,16,_r);
|
|
||||||
|
|
||||||
++_modifiedTag;
|
++_modifiedTag;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -306,7 +318,7 @@ void Image::scaleImage(int s,int t,int r)
|
|||||||
unsigned int newTotalSize = computeRowWidthInBytes(s,_pixelFormat,_dataType,_packing)*t;
|
unsigned int newTotalSize = computeRowWidthInBytes(s,_pixelFormat,_dataType,_packing)*t;
|
||||||
|
|
||||||
// need to sort out what size to really use...
|
// need to sort out what size to really use...
|
||||||
unsigned char* newData = (unsigned char *)malloc(newTotalSize);
|
unsigned char* newData = new unsigned char [newTotalSize];
|
||||||
if (!newData)
|
if (!newData)
|
||||||
{
|
{
|
||||||
// should we throw an exception??? Just return for time being.
|
// should we throw an exception??? Just return for time being.
|
||||||
@ -331,15 +343,13 @@ void Image::scaleImage(int s,int t,int r)
|
|||||||
{
|
{
|
||||||
|
|
||||||
// free old image.
|
// free old image.
|
||||||
::free(_data);
|
|
||||||
|
|
||||||
_s = s;
|
_s = s;
|
||||||
_t = t;
|
_t = t;
|
||||||
_data = newData;
|
setData(newData,USE_NEW_DELETE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
::free(newData);
|
delete [] newData;
|
||||||
|
|
||||||
notify(WARN) << "Error Image::scaleImage() do not succeed : errorString = "<<gluErrorString((GLenum)status)<<std::endl;
|
notify(WARN) << "Error Image::scaleImage() do not succeed : errorString = "<<gluErrorString((GLenum)status)<<std::endl;
|
||||||
}
|
}
|
||||||
@ -448,7 +458,7 @@ void Image::flipVertical(int image)
|
|||||||
unsigned char* imageData = _data+image*imageSizeInBytes;
|
unsigned char* imageData = _data+image*imageSizeInBytes;
|
||||||
|
|
||||||
// make temp. buffer for one image
|
// make temp. buffer for one image
|
||||||
unsigned char *tmpData = (unsigned char*) malloc(imageSizeInBytes);
|
unsigned char *tmpData = new unsigned char [imageSizeInBytes];
|
||||||
|
|
||||||
for (int t=0; t<_t; ++t)
|
for (int t=0; t<_t; ++t)
|
||||||
{
|
{
|
||||||
@ -460,7 +470,8 @@ void Image::flipVertical(int image)
|
|||||||
// insert fliped image
|
// insert fliped image
|
||||||
memcpy(imageData, tmpData, imageSizeInBytes);
|
memcpy(imageData, tmpData, imageSizeInBytes);
|
||||||
|
|
||||||
free(tmpData);
|
delete [] tmpData;
|
||||||
|
|
||||||
++_modifiedTag;
|
++_modifiedTag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,7 +210,7 @@ int *numComponents_ret)
|
|||||||
int ncpal=4; // default number of colours per palette entry
|
int ncpal=4; // default number of colours per palette entry
|
||||||
size -= sizeof(bmpheader)+infsize;
|
size -= sizeof(bmpheader)+infsize;
|
||||||
if (inf.ImageSize<size) inf.ImageSize=size;
|
if (inf.ImageSize<size) inf.ImageSize=size;
|
||||||
imbuff = (unsigned char *)malloc( inf.ImageSize); // read from disk
|
imbuff = new unsigned char [ inf.ImageSize]; // read from disk
|
||||||
fread((char *)imbuff, sizeof(unsigned char),inf.ImageSize, fp);
|
fread((char *)imbuff, sizeof(unsigned char),inf.ImageSize, fp);
|
||||||
ncolours=inf.Colorbits/8;
|
ncolours=inf.Colorbits/8;
|
||||||
switch (ncolours) {
|
switch (ncolours) {
|
||||||
@ -234,8 +234,9 @@ int *numComponents_ret)
|
|||||||
if (infsize==12 || infsize==64) ncpal=3; // OS2 - uses 3 colours per palette entry
|
if (infsize==12 || infsize==64) ncpal=3; // OS2 - uses 3 colours per palette entry
|
||||||
else ncpal=4; // Windoze uses 4!
|
else ncpal=4; // Windoze uses 4!
|
||||||
}
|
}
|
||||||
if (ncomp>0) buffer = (unsigned char *)malloc( (ncomp==BW?3:ncomp)*inf.width*inf.height*sizeof(unsigned char)); // to be returned
|
|
||||||
else buffer = (unsigned char *)malloc( 3*inf.width*inf.height*sizeof(unsigned char)); // default full colour to be returned
|
if (ncomp>0) buffer = new unsigned char [(ncomp==BW?3:ncomp)*inf.width*inf.height]; // to be returned
|
||||||
|
else buffer = new unsigned char [ 3*inf.width*inf.height]; // default full colour to be returned
|
||||||
|
|
||||||
unsigned long off=0;
|
unsigned long off=0;
|
||||||
unsigned long rowbytes=ncomp*sizeof(unsigned char)*inf.width;
|
unsigned long rowbytes=ncomp*sizeof(unsigned char)*inf.width;
|
||||||
@ -271,7 +272,7 @@ int *numComponents_ret)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
free(imbuff); // free the on-disk storage
|
delete [] imbuff; // free the on-disk storage
|
||||||
|
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
|
||||||
@ -342,7 +343,8 @@ class ReaderWriterBMP : public osgDB::ReaderWriter
|
|||||||
internalFormat,
|
internalFormat,
|
||||||
pixelFormat,
|
pixelFormat,
|
||||||
dataType,
|
dataType,
|
||||||
imageData);
|
imageData,
|
||||||
|
osg::Image::USE_NEW_DELETE);
|
||||||
|
|
||||||
return pOsgImage;
|
return pOsgImage;
|
||||||
|
|
||||||
|
@ -163,17 +163,17 @@ int *numComponents_ret)
|
|||||||
transparent = -1; /* no transparent color by default */
|
transparent = -1; /* no transparent color by default */
|
||||||
|
|
||||||
n = giffile->SHeight * giffile->SWidth;
|
n = giffile->SHeight * giffile->SWidth;
|
||||||
buffer = (unsigned char *)malloc(n * 4);
|
buffer = new unsigned char [n * 4];
|
||||||
if (!buffer)
|
if (!buffer)
|
||||||
{
|
{
|
||||||
giferror = ERR_MEM;
|
giferror = ERR_MEM;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
rowdata = (unsigned char *)malloc(giffile->SWidth);
|
rowdata = new unsigned char [giffile->SWidth];
|
||||||
if (!rowdata)
|
if (!rowdata)
|
||||||
{
|
{
|
||||||
giferror = ERR_MEM;
|
giferror = ERR_MEM;
|
||||||
free(buffer);
|
delete [] buffer;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -208,8 +208,8 @@ int *numComponents_ret)
|
|||||||
if (DGifGetRecordType(giffile, &recordtype) == GIF_ERROR)
|
if (DGifGetRecordType(giffile, &recordtype) == GIF_ERROR)
|
||||||
{
|
{
|
||||||
giferror = ERR_READ;
|
giferror = ERR_READ;
|
||||||
free(buffer);
|
delete [] buffer;
|
||||||
free(rowdata);
|
delete [] rowdata;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
switch (recordtype)
|
switch (recordtype)
|
||||||
@ -218,8 +218,8 @@ int *numComponents_ret)
|
|||||||
if (DGifGetImageDesc(giffile) == GIF_ERROR)
|
if (DGifGetImageDesc(giffile) == GIF_ERROR)
|
||||||
{
|
{
|
||||||
giferror = ERR_READ;
|
giferror = ERR_READ;
|
||||||
free(buffer);
|
delete [] buffer;
|
||||||
free(rowdata);
|
delete [] rowdata;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
/* subimage position in composite image */
|
/* subimage position in composite image */
|
||||||
@ -232,8 +232,8 @@ int *numComponents_ret)
|
|||||||
{
|
{
|
||||||
/* image is not confined to screen dimension */
|
/* image is not confined to screen dimension */
|
||||||
giferror = ERR_READ;
|
giferror = ERR_READ;
|
||||||
free(buffer);
|
delete [] buffer;
|
||||||
free(rowdata);
|
delete [] rowdata;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (giffile->Image.Interlace)
|
if (giffile->Image.Interlace)
|
||||||
@ -248,8 +248,8 @@ int *numComponents_ret)
|
|||||||
if (DGifGetLine(giffile, rowdata, width) == GIF_ERROR)
|
if (DGifGetLine(giffile, rowdata, width) == GIF_ERROR)
|
||||||
{
|
{
|
||||||
giferror = ERR_READ;
|
giferror = ERR_READ;
|
||||||
free(buffer);
|
delete [] buffer;
|
||||||
free(rowdata);
|
delete [] rowdata;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
else decode_row(giffile, buffer, rowdata, col, j, width, transparent);
|
else decode_row(giffile, buffer, rowdata, col, j, width, transparent);
|
||||||
@ -263,8 +263,8 @@ int *numComponents_ret)
|
|||||||
if (DGifGetLine(giffile, rowdata, width) == GIF_ERROR)
|
if (DGifGetLine(giffile, rowdata, width) == GIF_ERROR)
|
||||||
{
|
{
|
||||||
giferror = ERR_READ;
|
giferror = ERR_READ;
|
||||||
free(buffer);
|
delete [] buffer;
|
||||||
free(rowdata);
|
delete [] rowdata;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
else decode_row(giffile, buffer, rowdata, col, row, width, transparent);
|
else decode_row(giffile, buffer, rowdata, col, row, width, transparent);
|
||||||
@ -276,8 +276,8 @@ int *numComponents_ret)
|
|||||||
if (DGifGetExtension(giffile, &extcode, &extension) == GIF_ERROR)
|
if (DGifGetExtension(giffile, &extcode, &extension) == GIF_ERROR)
|
||||||
{
|
{
|
||||||
giferror = ERR_READ;
|
giferror = ERR_READ;
|
||||||
free(buffer);
|
delete [] buffer;
|
||||||
free(rowdata);
|
delete [] rowdata;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
/* transparent test from the gimp gif-plugin. Open Source rulez! */
|
/* transparent test from the gimp gif-plugin. Open Source rulez! */
|
||||||
@ -291,8 +291,8 @@ int *numComponents_ret)
|
|||||||
if (DGifGetExtensionNext(giffile, &extension) == GIF_ERROR)
|
if (DGifGetExtensionNext(giffile, &extension) == GIF_ERROR)
|
||||||
{
|
{
|
||||||
giferror = ERR_READ;
|
giferror = ERR_READ;
|
||||||
free(buffer);
|
delete [] buffer;
|
||||||
free(rowdata);
|
delete [] rowdata;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -305,7 +305,7 @@ int *numComponents_ret)
|
|||||||
}
|
}
|
||||||
while (recordtype != TERMINATE_RECORD_TYPE);
|
while (recordtype != TERMINATE_RECORD_TYPE);
|
||||||
|
|
||||||
free(rowdata);
|
delete [] rowdata;
|
||||||
*width_ret = giffile->SWidth;
|
*width_ret = giffile->SWidth;
|
||||||
*height_ret = giffile->SHeight;
|
*height_ret = giffile->SHeight;
|
||||||
*numComponents_ret = 4;
|
*numComponents_ret = 4;
|
||||||
@ -368,7 +368,8 @@ class ReaderWriterGIF : public osgDB::ReaderWriter
|
|||||||
internalFormat,
|
internalFormat,
|
||||||
pixelFormat,
|
pixelFormat,
|
||||||
dataType,
|
dataType,
|
||||||
imageData);
|
imageData,
|
||||||
|
osg::Image::USE_NEW_DELETE);
|
||||||
|
|
||||||
return pOsgImage;
|
return pOsgImage;
|
||||||
|
|
||||||
|
@ -181,7 +181,7 @@ int *numComponents_ret)
|
|||||||
jpegerror = ERR_JPEGLIB;
|
jpegerror = ERR_JPEGLIB;
|
||||||
jpeg_destroy_decompress(&cinfo);
|
jpeg_destroy_decompress(&cinfo);
|
||||||
fclose(infile);
|
fclose(infile);
|
||||||
if (buffer) free(buffer);
|
if (buffer) delete [] buffer;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
/* Now we can initialize the JPEG decompression object. */
|
/* Now we can initialize the JPEG decompression object. */
|
||||||
@ -235,8 +235,7 @@ int *numComponents_ret)
|
|||||||
((j_common_ptr) &cinfo, JPOOL_IMAGE, row_stride, 1);
|
((j_common_ptr) &cinfo, JPOOL_IMAGE, row_stride, 1);
|
||||||
width = cinfo.output_width;
|
width = cinfo.output_width;
|
||||||
height = cinfo.output_height;
|
height = cinfo.output_height;
|
||||||
buffer = currPtr = (unsigned char*)
|
buffer = currPtr = new unsigned char [width*height*cinfo.output_components];
|
||||||
malloc(width*height*cinfo.output_components);
|
|
||||||
|
|
||||||
/* Step 6: while (scan lines remain to be read) */
|
/* Step 6: while (scan lines remain to be read) */
|
||||||
/* jpeg_read_scanlines(...); */
|
/* jpeg_read_scanlines(...); */
|
||||||
@ -340,7 +339,8 @@ class ReaderWriterJPEG : public osgDB::ReaderWriter
|
|||||||
internalFormat,
|
internalFormat,
|
||||||
pixelFormat,
|
pixelFormat,
|
||||||
dataType,
|
dataType,
|
||||||
imageData);
|
imageData,
|
||||||
|
osg::Image::USE_NEW_DELETE);
|
||||||
|
|
||||||
return pOsgImage;
|
return pOsgImage;
|
||||||
|
|
||||||
|
@ -143,8 +143,8 @@ int *numComponents_ret)
|
|||||||
picerror = ERROR_READING_PALETTE;
|
picerror = ERROR_READING_PALETTE;
|
||||||
}
|
}
|
||||||
|
|
||||||
tmpbuf = (unsigned char *)malloc(width);
|
tmpbuf = new unsigned char [width];
|
||||||
buffer = (unsigned char*) malloc(3*width*height);
|
buffer = new unsigned char [3*width*height];
|
||||||
if (tmpbuf == NULL || buffer == NULL)
|
if (tmpbuf == NULL || buffer == NULL)
|
||||||
{
|
{
|
||||||
picerror = ERROR_MEMORY;
|
picerror = ERROR_MEMORY;
|
||||||
@ -160,8 +160,8 @@ int *numComponents_ret)
|
|||||||
{
|
{
|
||||||
picerror = ERROR_READ_ERROR;
|
picerror = ERROR_READ_ERROR;
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
if (tmpbuf) free(tmpbuf);
|
if (tmpbuf) delete [] tmpbuf;
|
||||||
if (buffer) free(buffer);
|
if (buffer) delete [] buffer;
|
||||||
buffer = NULL;
|
buffer = NULL;
|
||||||
width = height = 0;
|
width = height = 0;
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -180,6 +180,9 @@ int *numComponents_ret)
|
|||||||
*width_ret = width;
|
*width_ret = width;
|
||||||
*height_ret = height;
|
*height_ret = height;
|
||||||
*numComponents_ret = format;
|
*numComponents_ret = format;
|
||||||
|
|
||||||
|
if (tmpbuf) delete [] tmpbuf;
|
||||||
|
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -222,7 +225,8 @@ class ReaderWriterPIC : public osgDB::ReaderWriter
|
|||||||
internalFormat,
|
internalFormat,
|
||||||
pixelFormat,
|
pixelFormat,
|
||||||
dataType,
|
dataType,
|
||||||
imageData);
|
imageData,
|
||||||
|
osg::Image::USE_NEW_DELETE);
|
||||||
|
|
||||||
return pOsgImage;
|
return pOsgImage;
|
||||||
|
|
||||||
|
@ -103,8 +103,8 @@ class ReaderWriterPNG : public osgDB::ReaderWriter
|
|||||||
|
|
||||||
png_read_update_info(png, info);
|
png_read_update_info(png, info);
|
||||||
|
|
||||||
data = (png_bytep) malloc(png_get_rowbytes(png, info)*height);
|
data = (png_bytep) new unsigned char [png_get_rowbytes(png, info)*height];
|
||||||
row_p = (png_bytep *) malloc(sizeof(png_bytep)*height);
|
row_p = new png_bytep [height];
|
||||||
|
|
||||||
bool StandardOrientation = true;
|
bool StandardOrientation = true;
|
||||||
for (i = 0; i < height; i++)
|
for (i = 0; i < height; i++)
|
||||||
@ -116,7 +116,7 @@ class ReaderWriterPNG : public osgDB::ReaderWriter
|
|||||||
}
|
}
|
||||||
|
|
||||||
png_read_image(png, row_p);
|
png_read_image(png, row_p);
|
||||||
free(row_p);
|
delete [] row_p;
|
||||||
|
|
||||||
int iBitCount=0;
|
int iBitCount=0;
|
||||||
|
|
||||||
@ -147,7 +147,7 @@ class ReaderWriterPNG : public osgDB::ReaderWriter
|
|||||||
png_read_end(png, endinfo);
|
png_read_end(png, endinfo);
|
||||||
png_destroy_read_struct(&png, &info, &endinfo);
|
png_destroy_read_struct(&png, &info, &endinfo);
|
||||||
|
|
||||||
// free(data);
|
// delete [] data;
|
||||||
|
|
||||||
if (fp)
|
if (fp)
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
@ -163,13 +163,15 @@ class ReaderWriterPNG : public osgDB::ReaderWriter
|
|||||||
iBitCount / 8,// int internalFormat,
|
iBitCount / 8,// int internalFormat,
|
||||||
GL_RGB, // unsigned int pixelFormat
|
GL_RGB, // unsigned int pixelFormat
|
||||||
GL_UNSIGNED_BYTE,// unsigned int dataType
|
GL_UNSIGNED_BYTE,// unsigned int dataType
|
||||||
data);
|
data,
|
||||||
|
osg::Image::USE_NEW_DELETE);
|
||||||
else
|
else
|
||||||
pOsgImage->setImage(width, height, 1,
|
pOsgImage->setImage(width, height, 1,
|
||||||
iBitCount / 8,// int internalFormat,
|
iBitCount / 8,// int internalFormat,
|
||||||
GL_RGBA, // unsigned int pixelFormat
|
GL_RGBA, // unsigned int pixelFormat
|
||||||
GL_UNSIGNED_BYTE,// unsigned int dataType
|
GL_UNSIGNED_BYTE,// unsigned int dataType
|
||||||
data);
|
data,
|
||||||
|
osg::Image::USE_NEW_DELETE);
|
||||||
return pOsgImage;
|
return pOsgImage;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -87,16 +87,16 @@ static void RawImageClose(rawImageRec *raw)
|
|||||||
{
|
{
|
||||||
fclose(raw->file);
|
fclose(raw->file);
|
||||||
|
|
||||||
if (raw->tmp) free(raw->tmp);
|
if (raw->tmp) delete [] raw->tmp;
|
||||||
if (raw->tmpR) free(raw->tmpR);
|
if (raw->tmpR) delete [] raw->tmpR;
|
||||||
if (raw->tmpG) free(raw->tmpG);
|
if (raw->tmpG) delete [] raw->tmpG;
|
||||||
if (raw->tmpB) free(raw->tmpB);
|
if (raw->tmpB) delete [] raw->tmpB;
|
||||||
if (raw->tmpA) free(raw->tmpA);
|
if (raw->tmpA) delete [] raw->tmpA;
|
||||||
|
|
||||||
if (raw->rowStart) free(raw->rowStart);
|
if (raw->rowStart) delete [] raw->rowStart;
|
||||||
if (raw->rowSize) free(raw->rowSize);
|
if (raw->rowSize) delete [] raw->rowSize;
|
||||||
|
|
||||||
free(raw);
|
delete raw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,7 +122,7 @@ static rawImageRec *RawImageOpen(const char *fileName)
|
|||||||
swapFlag = GL_FALSE;
|
swapFlag = GL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
raw = (rawImageRec *)malloc(sizeof(rawImageRec));
|
raw = new rawImageRec;
|
||||||
if (raw == NULL)
|
if (raw == NULL)
|
||||||
{
|
{
|
||||||
notify(WARN)<< "Out of memory!"<< std::endl;
|
notify(WARN)<< "Out of memory!"<< std::endl;
|
||||||
@ -130,7 +130,7 @@ static rawImageRec *RawImageOpen(const char *fileName)
|
|||||||
}
|
}
|
||||||
if ((raw->file = fopen(fileName, "rb")) == NULL)
|
if ((raw->file = fopen(fileName, "rb")) == NULL)
|
||||||
{
|
{
|
||||||
free(raw);
|
delete raw;
|
||||||
perror(fileName);
|
perror(fileName);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -146,7 +146,7 @@ static rawImageRec *RawImageOpen(const char *fileName)
|
|||||||
raw->rowStart = 0;
|
raw->rowStart = 0;
|
||||||
raw->rowSize = 0;
|
raw->rowSize = 0;
|
||||||
|
|
||||||
raw->tmp = (unsigned char *)malloc(raw->sizeX*256);
|
raw->tmp = new unsigned char [raw->sizeX*256];
|
||||||
if (raw->tmp == NULL )
|
if (raw->tmp == NULL )
|
||||||
{
|
{
|
||||||
notify(FATAL)<< "Out of memory!"<< std::endl;
|
notify(FATAL)<< "Out of memory!"<< std::endl;
|
||||||
@ -156,7 +156,7 @@ static rawImageRec *RawImageOpen(const char *fileName)
|
|||||||
|
|
||||||
if( raw->sizeZ >= 1 )
|
if( raw->sizeZ >= 1 )
|
||||||
{
|
{
|
||||||
if( (raw->tmpR = (unsigned char *)malloc(raw->sizeX)) == NULL )
|
if( (raw->tmpR = new unsigned char [raw->sizeX]) == NULL )
|
||||||
{
|
{
|
||||||
notify(FATAL)<< "Out of memory!"<< std::endl;
|
notify(FATAL)<< "Out of memory!"<< std::endl;
|
||||||
RawImageClose(raw);
|
RawImageClose(raw);
|
||||||
@ -165,7 +165,7 @@ static rawImageRec *RawImageOpen(const char *fileName)
|
|||||||
}
|
}
|
||||||
if( raw->sizeZ >= 2 )
|
if( raw->sizeZ >= 2 )
|
||||||
{
|
{
|
||||||
if( (raw->tmpG = (unsigned char *)malloc(raw->sizeX)) == NULL )
|
if( (raw->tmpG = new unsigned char [raw->sizeX]) == NULL )
|
||||||
{
|
{
|
||||||
notify(FATAL)<< "Out of memory!"<< std::endl;
|
notify(FATAL)<< "Out of memory!"<< std::endl;
|
||||||
RawImageClose(raw);
|
RawImageClose(raw);
|
||||||
@ -174,7 +174,7 @@ static rawImageRec *RawImageOpen(const char *fileName)
|
|||||||
}
|
}
|
||||||
if( raw->sizeZ >= 3 )
|
if( raw->sizeZ >= 3 )
|
||||||
{
|
{
|
||||||
if( (raw->tmpB = (unsigned char *)malloc(raw->sizeX)) == NULL )
|
if( (raw->tmpB = new unsigned char [raw->sizeX]) == NULL )
|
||||||
{
|
{
|
||||||
notify(FATAL)<< "Out of memory!"<< std::endl;
|
notify(FATAL)<< "Out of memory!"<< std::endl;
|
||||||
RawImageClose(raw);
|
RawImageClose(raw);
|
||||||
@ -183,7 +183,7 @@ static rawImageRec *RawImageOpen(const char *fileName)
|
|||||||
}
|
}
|
||||||
if (raw->sizeZ >= 4)
|
if (raw->sizeZ >= 4)
|
||||||
{
|
{
|
||||||
if( (raw->tmpA = (unsigned char *)malloc(raw->sizeX)) == NULL )
|
if( (raw->tmpA = new unsigned char [raw->sizeX]) == NULL )
|
||||||
{
|
{
|
||||||
notify(FATAL)<< "Out of memory!"<< std::endl;
|
notify(FATAL)<< "Out of memory!"<< std::endl;
|
||||||
RawImageClose(raw);
|
RawImageClose(raw);
|
||||||
@ -193,20 +193,21 @@ static rawImageRec *RawImageOpen(const char *fileName)
|
|||||||
|
|
||||||
if ((raw->type & 0xFF00) == 0x0100)
|
if ((raw->type & 0xFF00) == 0x0100)
|
||||||
{
|
{
|
||||||
x = raw->sizeY * raw->sizeZ * sizeof(GLuint);
|
unsigned int ybyz = raw->sizeY * raw->sizeZ;
|
||||||
if ( (raw->rowStart = (GLuint *)malloc(x)) == NULL )
|
if ( (raw->rowStart = new GLuint [ybyz]) == NULL )
|
||||||
{
|
{
|
||||||
notify(FATAL)<< "Out of memory!"<< std::endl;
|
notify(FATAL)<< "Out of memory!"<< std::endl;
|
||||||
RawImageClose(raw);
|
RawImageClose(raw);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( (raw->rowSize = (GLint *)malloc(x)) == NULL )
|
if ( (raw->rowSize = new GLint [ybyz]) == NULL )
|
||||||
{
|
{
|
||||||
notify(FATAL)<< "Out of memory!"<< std::endl;
|
notify(FATAL)<< "Out of memory!"<< std::endl;
|
||||||
RawImageClose(raw);
|
RawImageClose(raw);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
x = ybyz * sizeof(GLuint);
|
||||||
raw->rleEnd = 512 + (2 * x);
|
raw->rleEnd = 512 + (2 * x);
|
||||||
fseek(raw->file, 512, SEEK_SET);
|
fseek(raw->file, 512, SEEK_SET);
|
||||||
fread(raw->rowStart, 1, x, raw->file);
|
fread(raw->rowStart, 1, x, raw->file);
|
||||||
@ -278,8 +279,8 @@ static void RawImageGetData(rawImageRec *raw, unsigned char **data )
|
|||||||
// int width = (int)(floorf((float)raw->sizeX/4.0f)*4.0f);
|
// int width = (int)(floorf((float)raw->sizeX/4.0f)*4.0f);
|
||||||
// if (width!=raw->sizeX) width += 4;
|
// if (width!=raw->sizeX) width += 4;
|
||||||
|
|
||||||
*data = (unsigned char *)malloc(2 * (raw->sizeX+1)*(raw->sizeY+1)*4);
|
// byte aligned.
|
||||||
// *data = (unsigned char *)malloc(2 * (width+1)*(raw->sizeY+1)*4);
|
*data = new unsigned char [(raw->sizeX)*(raw->sizeY)*(raw->sizeZ)];
|
||||||
|
|
||||||
ptr = *data;
|
ptr = *data;
|
||||||
for (i = 0; i < (int)(raw->sizeY); i++)
|
for (i = 0; i < (int)(raw->sizeY); i++)
|
||||||
@ -364,7 +365,8 @@ class ReaderWriterRGB : public osgDB::ReaderWriter
|
|||||||
internalFormat,
|
internalFormat,
|
||||||
pixelFormat,
|
pixelFormat,
|
||||||
dataType,
|
dataType,
|
||||||
data);
|
data,
|
||||||
|
osg::Image::USE_NEW_DELETE);
|
||||||
|
|
||||||
notify(INFO) << "image read ok "<<s<<" "<<t<< std::endl;
|
notify(INFO) << "image read ok "<<s<<" "<<t<< std::endl;
|
||||||
return image;
|
return image;
|
||||||
|
@ -307,7 +307,7 @@ int *numComponents_ret)
|
|||||||
{
|
{
|
||||||
int len = getInt16(&header[5]);
|
int len = getInt16(&header[5]);
|
||||||
indexsize = header[7]>>3;
|
indexsize = header[7]>>3;
|
||||||
colormap = (unsigned char *)malloc(len*indexsize);
|
colormap = new unsigned char [len*indexsize];
|
||||||
fread(colormap, 1, len*indexsize, fp);
|
fread(colormap, 1, len*indexsize, fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -324,10 +324,10 @@ int *numComponents_ret)
|
|||||||
rleIsCompressed = 0;
|
rleIsCompressed = 0;
|
||||||
rleRemaining = 0;
|
rleRemaining = 0;
|
||||||
rleEntrySize = depth;
|
rleEntrySize = depth;
|
||||||
buffer = (unsigned char*)malloc(width*height*format);
|
buffer = new unsigned char [width*height*format];
|
||||||
dest = buffer;
|
dest = buffer;
|
||||||
bpr = format * width;
|
bpr = format * width;
|
||||||
linebuf = (unsigned char *)malloc(width*depth);
|
linebuf = new unsigned char [width*depth];
|
||||||
|
|
||||||
//check the intended image orientation
|
//check the intended image orientation
|
||||||
bool bLeftToRight = (flags&0x10)==0;
|
bool bLeftToRight = (flags&0x10)==0;
|
||||||
@ -383,7 +383,7 @@ int *numComponents_ret)
|
|||||||
fseek(fp, 0, SEEK_END);
|
fseek(fp, 0, SEEK_END);
|
||||||
size = ftell(fp) - pos;
|
size = ftell(fp) - pos;
|
||||||
fseek(fp, pos, SEEK_SET);
|
fseek(fp, pos, SEEK_SET);
|
||||||
buf = (unsigned char *)malloc(size);
|
buf = new unsigned char [size];
|
||||||
if (buf == NULL)
|
if (buf == NULL)
|
||||||
{
|
{
|
||||||
tgaerror = ERR_MEM;
|
tgaerror = ERR_MEM;
|
||||||
@ -406,19 +406,19 @@ int *numComponents_ret)
|
|||||||
}
|
}
|
||||||
dest += lineoffset;
|
dest += lineoffset;
|
||||||
}
|
}
|
||||||
if (buf) free(buf);
|
if (buf) delete [] buf;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
tgaerror = ERR_UNSUPPORTED;
|
tgaerror = ERR_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (linebuf) free(linebuf);
|
if (linebuf) delete [] linebuf;
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
|
||||||
if (tgaerror)
|
if (tgaerror)
|
||||||
{
|
{
|
||||||
if (buffer) free(buffer);
|
if (buffer) delete [] buffer;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -509,7 +509,8 @@ class ReaderWriterTGA : public osgDB::ReaderWriter
|
|||||||
internalFormat,
|
internalFormat,
|
||||||
pixelFormat,
|
pixelFormat,
|
||||||
dataType,
|
dataType,
|
||||||
imageData);
|
imageData,
|
||||||
|
osg::Image::USE_NEW_DELETE);
|
||||||
|
|
||||||
return pOsgImage;
|
return pOsgImage;
|
||||||
|
|
||||||
|
@ -275,7 +275,7 @@ int *numComponents_ret)
|
|||||||
else
|
else
|
||||||
format = 3;
|
format = 3;
|
||||||
|
|
||||||
buffer = (unsigned char*)malloc(w*h*format);
|
buffer = new unsigned char [w*h*format];
|
||||||
|
|
||||||
if (!buffer)
|
if (!buffer)
|
||||||
{
|
{
|
||||||
@ -298,7 +298,7 @@ int *numComponents_ret)
|
|||||||
case pack(PHOTOMETRIC_MINISWHITE, PLANARCONFIG_SEPARATE):
|
case pack(PHOTOMETRIC_MINISWHITE, PLANARCONFIG_SEPARATE):
|
||||||
case pack(PHOTOMETRIC_MINISBLACK, PLANARCONFIG_SEPARATE):
|
case pack(PHOTOMETRIC_MINISBLACK, PLANARCONFIG_SEPARATE):
|
||||||
|
|
||||||
inbuf = (unsigned char *)malloc(TIFFScanlineSize(in));
|
inbuf = new unsigned char [TIFFScanlineSize(in)];
|
||||||
for (row = 0; row < h; row++)
|
for (row = 0; row < h; row++)
|
||||||
{
|
{
|
||||||
if (TIFFReadScanline(in, inbuf, row, 0) < 0)
|
if (TIFFReadScanline(in, inbuf, row, 0) < 0)
|
||||||
@ -330,7 +330,7 @@ int *numComponents_ret)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inbuf = (unsigned char *)malloc(TIFFScanlineSize(in));
|
inbuf = new unsigned char [TIFFScanlineSize(in)];
|
||||||
for (row = 0; row < h; row++)
|
for (row = 0; row < h; row++)
|
||||||
{
|
{
|
||||||
if (TIFFReadScanline(in, inbuf, row, 0) < 0)
|
if (TIFFReadScanline(in, inbuf, row, 0) < 0)
|
||||||
@ -344,7 +344,7 @@ int *numComponents_ret)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case pack(PHOTOMETRIC_RGB, PLANARCONFIG_CONTIG):
|
case pack(PHOTOMETRIC_RGB, PLANARCONFIG_CONTIG):
|
||||||
inbuf = (unsigned char *)malloc(TIFFScanlineSize(in));
|
inbuf = new unsigned char [TIFFScanlineSize(in)];
|
||||||
for (row = 0; row < h; row++)
|
for (row = 0; row < h; row++)
|
||||||
{
|
{
|
||||||
if (TIFFReadScanline(in, inbuf, row, 0) < 0)
|
if (TIFFReadScanline(in, inbuf, row, 0) < 0)
|
||||||
@ -359,7 +359,7 @@ int *numComponents_ret)
|
|||||||
|
|
||||||
case pack(PHOTOMETRIC_RGB, PLANARCONFIG_SEPARATE):
|
case pack(PHOTOMETRIC_RGB, PLANARCONFIG_SEPARATE):
|
||||||
rowsize = TIFFScanlineSize(in);
|
rowsize = TIFFScanlineSize(in);
|
||||||
inbuf = (unsigned char *)malloc(3*rowsize);
|
inbuf = new unsigned char [3*rowsize];
|
||||||
for (row = 0; !tifferror && row < h; row++)
|
for (row = 0; !tifferror && row < h; row++)
|
||||||
{
|
{
|
||||||
int s;
|
int s;
|
||||||
@ -382,12 +382,12 @@ int *numComponents_ret)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inbuf) free(inbuf);
|
if (inbuf) delete [] inbuf;
|
||||||
TIFFClose(in);
|
TIFFClose(in);
|
||||||
|
|
||||||
if (tifferror)
|
if (tifferror)
|
||||||
{
|
{
|
||||||
if (buffer) free(buffer);
|
if (buffer) delete [] buffer;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
*width_ret = width;
|
*width_ret = width;
|
||||||
@ -448,7 +448,8 @@ class ReaderWriterTIFF : public osgDB::ReaderWriter
|
|||||||
internalFormat,
|
internalFormat,
|
||||||
pixelFormat,
|
pixelFormat,
|
||||||
dataType,
|
dataType,
|
||||||
imageData);
|
imageData,
|
||||||
|
osg::Image::USE_NEW_DELETE);
|
||||||
|
|
||||||
return pOsgImage;
|
return pOsgImage;
|
||||||
|
|
||||||
|
@ -138,7 +138,7 @@ Texture2D* txp::GetLocalTexture(trpgrImageHelper& image_helper, trpgLocalMateria
|
|||||||
{
|
{
|
||||||
int32 size = s.x*s.y*depth;
|
int32 size = s.x*s.y*depth;
|
||||||
// int32 size = const_cast<trpgTexture*>(tex)->MipLevelSize(1) ;
|
// int32 size = const_cast<trpgTexture*>(tex)->MipLevelSize(1) ;
|
||||||
data = (char *)::malloc(size);
|
data = new char [size];
|
||||||
|
|
||||||
if(locmat)
|
if(locmat)
|
||||||
image_helper.GetImageForLocalMat(locmat,data,size);
|
image_helper.GetImageForLocalMat(locmat,data,size);
|
||||||
@ -147,14 +147,14 @@ Texture2D* txp::GetLocalTexture(trpgrImageHelper& image_helper, trpgLocalMateria
|
|||||||
|
|
||||||
image->setImage(s.x,s.y,1,depth,
|
image->setImage(s.x,s.y,1,depth,
|
||||||
gltype,GL_UNSIGNED_BYTE,
|
gltype,GL_UNSIGNED_BYTE,
|
||||||
(unsigned char*)data);
|
(unsigned char*)data,osg::Image::USE_NEW_DELETE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int32 size = tex->CalcTotalSize();
|
int32 size = tex->CalcTotalSize();
|
||||||
trpgTexture* tmp_tex = const_cast<trpgTexture*>(tex);
|
trpgTexture* tmp_tex = const_cast<trpgTexture*>(tex);
|
||||||
|
|
||||||
data = (char *)::malloc(size);
|
data = new char [size];
|
||||||
|
|
||||||
if(locmat)
|
if(locmat)
|
||||||
image_helper.GetImageForLocalMat(locmat,data,size);
|
image_helper.GetImageForLocalMat(locmat,data,size);
|
||||||
@ -164,7 +164,8 @@ Texture2D* txp::GetLocalTexture(trpgrImageHelper& image_helper, trpgLocalMateria
|
|||||||
// Load entire texture including mipmaps
|
// Load entire texture including mipmaps
|
||||||
image->setImage(s.x,s.y,1,depth,
|
image->setImage(s.x,s.y,1,depth,
|
||||||
gltype,GL_UNSIGNED_BYTE,
|
gltype,GL_UNSIGNED_BYTE,
|
||||||
(unsigned char*)data);
|
(unsigned char*)data,
|
||||||
|
osg::Image::USE_NEW_DELETE);
|
||||||
|
|
||||||
// now set mipmap data (offsets into image raw data)
|
// now set mipmap data (offsets into image raw data)
|
||||||
Image::MipmapDataType mipmaps;
|
Image::MipmapDataType mipmaps;
|
||||||
|
@ -22,8 +22,8 @@ CubeMapGenerator::CubeMapGenerator(int texture_size)
|
|||||||
for (int i=0; i<6; ++i)
|
for (int i=0; i<6; ++i)
|
||||||
{
|
{
|
||||||
osg::ref_ptr<osg::Image> image = new osg::Image;
|
osg::ref_ptr<osg::Image> image = new osg::Image;
|
||||||
unsigned char* data = (static_cast<unsigned char *>(malloc(texture_size*texture_size*4)));
|
unsigned char* data = new unsigned char [texture_size*texture_size*4];
|
||||||
image->setImage(texture_size, texture_size, 1, 4, GL_RGBA, GL_UNSIGNED_BYTE, data);
|
image->setImage(texture_size, texture_size, 1, 4, GL_RGBA, GL_UNSIGNED_BYTE, data, osg::Image::USE_NEW_DELETE);
|
||||||
images_.push_back(image);
|
images_.push_back(image);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user