diff --git a/src/osg/Texture.cpp b/src/osg/Texture.cpp index f30d26808..59dde1dba 100644 --- a/src/osg/Texture.cpp +++ b/src/osg/Texture.cpp @@ -1740,7 +1740,7 @@ void Texture::applyTexImage2D_load(State& state, GLenum target, const Image* ima #endif } - unsigned char* data = (unsigned char*)image->data(); + unsigned char* dataPtr = (unsigned char*)image->data(); // osg::notify(osg::NOTICE)<<"inwidth="<getFileName()"<getFileName()<getPixelFormat(),image->getDataType(),image->getPacking())*inheight; - data = new unsigned char [newTotalSize]; + dataPtr = new unsigned char [newTotalSize]; - if (!data) + if (!dataPtr) { notify(WARN)<<"Warning:: Not enough memory to resize image, cannot apply to texture."<getPacking()); gluScaleImage(image->getPixelFormat(), image->s(),image->t(),image->getDataType(),image->data(), - inwidth,inheight,image->getDataType(),data); - - } + inwidth,inheight,image->getDataType(),dataPtr); + + } bool mipmappingRequired = _min_filter != LINEAR && _min_filter != NEAREST; bool useHardwareMipMapGeneration = mipmappingRequired && (!image->isMipmap() && isHardwareMipmapGenerationEnabled(state)); bool useGluBuildMipMaps = mipmappingRequired && (!useHardwareMipMapGeneration && !image->isMipmap()); - const unsigned char* dataPtr = image->data(); GLBufferObject* pbo = image->getOrCreateGLBufferObject(contextID); if (pbo && !needImageRescale && !useGluBuildMipMaps) { state.bindPixelBufferObject(pbo); - dataPtr = reinterpret_cast(pbo->getOffset(image->getBufferIndex())); + dataPtr = reinterpret_cast(pbo->getOffset(image->getBufferIndex())); #ifdef DO_TIMING osg::notify(osg::NOTICE)<<"after PBO "<delta_m(start_tick,osg::Timer::instance()->tick())<<"ms"<getPixelFormat(), (GLenum)image->getDataType(), - data); + dataPtr); int width = image->s(); int height = image->t(); @@ -1930,7 +1929,7 @@ void Texture::applyTexImage2D_load(State& state, GLenum target, const Image* ima if (needImageRescale) { // clean up the resized image. - delete [] data; + delete [] dataPtr; } if (useClientStorage)