diff --git a/src/osg/Texture2D.cpp b/src/osg/Texture2D.cpp index 8594bb44d..8dc49eb37 100644 --- a/src/osg/Texture2D.cpp +++ b/src/osg/Texture2D.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include using namespace osg; @@ -246,16 +247,38 @@ void Texture2D::copyTexImage2D(State& state, int x, int y, int width, int height _image = NULL; // switch off mip-mapping. - _min_filter = LINEAR; - _mag_filter = LINEAR; - + // _textureObjectBuffer[contextID] = textureObject = generateTextureObject(contextID,GL_TEXTURE_2D); textureObject->bind(); applyTexParameters(GL_TEXTURE_2D,state); + + + bool needHardwareMipMap = (_min_filter != LINEAR && _min_filter != NEAREST); + bool hardwareMipMapOn = false; + if (needHardwareMipMap) + { + const Extensions* extensions = getExtensions(contextID,true); + bool generateMipMapSupported = extensions->isGenerateMipMapSupported(); + + hardwareMipMapOn = _useHardwareMipMapGeneration && generateMipMapSupported; + + if (!hardwareMipMapOn) + { + // have to swtich off mip mapping + notify(NOTICE)<<"Warning: Texture2D::copyTexImage2D(,,,,) switch of mip mapping as hardware support not available."<bind(); applyTexParameters(GL_TEXTURE_2D,state); - glCopyTexSubImage2D( GL_TEXTURE_2D, 0, xoffset,yoffset, x, y, width, height); - /* Redundant, delete later */ - //glBindTexture( GL_TEXTURE_2D, handle ); + bool needHardwareMipMap = (_min_filter != LINEAR && _min_filter != NEAREST); + bool hardwareMipMapOn = false; + if (needHardwareMipMap) + { + const Extensions* extensions = getExtensions(contextID,true); + bool generateMipMapSupported = extensions->isGenerateMipMapSupported(); + + hardwareMipMapOn = _useHardwareMipMapGeneration && generateMipMapSupported; + + if (!hardwareMipMapOn) + { + // have to swtich off mip mapping + notify(NOTICE)<<"Warning: Texture2D::copyTexImage2D(,,,,) switch of mip mapping as hardware support not available."<