Added differentiation between Non power of two textures when mip mapped vs
when not mipped mapped to get round the issue of incomplete support under ATI cards.
This commit is contained in:
@@ -480,7 +480,12 @@ class OSG_EXPORT Texture : public osg::StateAttribute
|
||||
|
||||
bool isClientStorageSupported() const { return _isClientStorageSupported; }
|
||||
|
||||
bool isNonPowerOfTwoTextureSupported() const { return _isNonPowerOfTwoTextureSupported; }
|
||||
bool isNonPowerOfTwoTextureSupported(GLenum filter) const
|
||||
{
|
||||
return (filter==GL_LINEAR || filter==GL_NEAREST) ?
|
||||
_isNonPowerOfTwoTextureNonMipMappedSupported :
|
||||
_isNonPowerOfTwoTextureMipMappedSupported;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
@@ -497,7 +502,8 @@ class OSG_EXPORT Texture : public osg::StateAttribute
|
||||
bool _isShadowSupported;
|
||||
bool _isShadowAmbientSupported;
|
||||
bool _isClientStorageSupported;
|
||||
bool _isNonPowerOfTwoTextureSupported;
|
||||
bool _isNonPowerOfTwoTextureMipMappedSupported;
|
||||
bool _isNonPowerOfTwoTextureNonMipMappedSupported;
|
||||
|
||||
GLint _maxTextureSize;
|
||||
GLint _numTextureUnits;
|
||||
|
||||
@@ -713,7 +713,7 @@ void Texture::computeRequiredTextureDimensions(State& state, const osg::Image& i
|
||||
|
||||
int width,height;
|
||||
|
||||
if( !_resizeNonPowerOfTwoHint && extensions->isNonPowerOfTwoTextureSupported() )
|
||||
if( !_resizeNonPowerOfTwoHint && extensions->isNonPowerOfTwoTextureSupported(_min_filter) )
|
||||
{
|
||||
width = image.s();
|
||||
height = image.t();
|
||||
@@ -1286,7 +1286,8 @@ Texture::Extensions::Extensions(const Extensions& rhs):
|
||||
|
||||
_isClientStorageSupported = rhs._isClientStorageSupported;
|
||||
|
||||
_isNonPowerOfTwoTextureSupported = rhs._isNonPowerOfTwoTextureSupported;
|
||||
_isNonPowerOfTwoTextureMipMappedSupported = rhs._isNonPowerOfTwoTextureMipMappedSupported;
|
||||
_isNonPowerOfTwoTextureNonMipMappedSupported = rhs._isNonPowerOfTwoTextureNonMipMappedSupported;
|
||||
}
|
||||
|
||||
void Texture::Extensions::lowestCommonDenominator(const Extensions& rhs)
|
||||
@@ -1315,12 +1316,15 @@ void Texture::Extensions::lowestCommonDenominator(const Extensions& rhs)
|
||||
|
||||
if (!rhs._isClientStorageSupported) _isClientStorageSupported = false;
|
||||
|
||||
if (!rhs._isNonPowerOfTwoTextureSupported) _isNonPowerOfTwoTextureSupported = false;
|
||||
if (!rhs._isNonPowerOfTwoTextureMipMappedSupported) _isNonPowerOfTwoTextureMipMappedSupported = false;
|
||||
if (!rhs._isNonPowerOfTwoTextureNonMipMappedSupported) _isNonPowerOfTwoTextureNonMipMappedSupported = false;
|
||||
}
|
||||
|
||||
void Texture::Extensions::setupGLExtensions(unsigned int contextID)
|
||||
{
|
||||
float glVersion = atof( (const char *)glGetString( GL_VERSION ) );
|
||||
const char* renderer = (const char*) glGetString(GL_RENDERER);
|
||||
std::string rendererString(renderer ? renderer : "");
|
||||
|
||||
_isMultiTexturingSupported = ( glVersion >= 1.3 ) ||
|
||||
isGLExtensionSupported(contextID,"GL_ARB_multitexture") ||
|
||||
@@ -1344,9 +1348,17 @@ void Texture::Extensions::setupGLExtensions(unsigned int contextID)
|
||||
|
||||
_isClientStorageSupported = isGLExtensionSupported(contextID,"GL_APPLE_client_storage");
|
||||
|
||||
_isNonPowerOfTwoTextureSupported = ( glVersion >= 2.0 ) ||
|
||||
_isNonPowerOfTwoTextureNonMipMappedSupported = ( glVersion >= 2.0 ) ||
|
||||
isGLExtensionSupported(contextID,"GL_ARB_texture_non_power_of_two");
|
||||
|
||||
_isNonPowerOfTwoTextureMipMappedSupported = _isNonPowerOfTwoTextureNonMipMappedSupported;
|
||||
|
||||
if (rendererString.find("Radeon")!=std::string::npos)
|
||||
{
|
||||
_isNonPowerOfTwoTextureMipMappedSupported = false;
|
||||
osg::notify(osg::INFO)<<"Disabling _isNonPowerOfTwoTextureMipMappedSupported for ATI hardware."<<std::endl;
|
||||
}
|
||||
|
||||
glGetIntegerv(GL_MAX_TEXTURE_SIZE,&_maxTextureSize);
|
||||
|
||||
char *ptr;
|
||||
|
||||
@@ -189,8 +189,11 @@ void Texture1D::applyTexImage1D(GLenum target, Image* image, State& state, GLsiz
|
||||
bool compressed = isCompressedInternalFormat(_internalFormat);
|
||||
|
||||
//Rescale if resize hint is set or NPOT not supported or dimension exceeds max size
|
||||
if( _resizeNonPowerOfTwoHint || !extensions->isNonPowerOfTwoTextureSupported() || inwidth > extensions->maxTextureSize() )
|
||||
if( _resizeNonPowerOfTwoHint || !extensions->isNonPowerOfTwoTextureSupported(_min_filter) || inwidth > extensions->maxTextureSize() )
|
||||
{
|
||||
// this is not thread safe... should really create local image data and rescale to that as per Texture2D.
|
||||
image->ensureValidSizeForTexturing(extensions->maxTextureSize());
|
||||
}
|
||||
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT,image->getPacking());
|
||||
|
||||
|
||||
@@ -101,7 +101,7 @@ void Texture3D::computeRequiredTextureDimensions(State& state, const osg::Image&
|
||||
|
||||
int width,height,depth;
|
||||
|
||||
if( !_resizeNonPowerOfTwoHint && texExtensions->isNonPowerOfTwoTextureSupported() )
|
||||
if( !_resizeNonPowerOfTwoHint && texExtensions->isNonPowerOfTwoTextureSupported(_min_filter) )
|
||||
{
|
||||
width = image.s();
|
||||
height = image.t();
|
||||
@@ -278,7 +278,7 @@ void Texture3D::applyTexImage3D(GLenum target, Image* image, State& state, GLsiz
|
||||
}
|
||||
|
||||
//Rescale if resize hint is set or NPOT not supported or dimensions exceed max size
|
||||
if( _resizeNonPowerOfTwoHint || !texExtensions->isNonPowerOfTwoTextureSupported()
|
||||
if( _resizeNonPowerOfTwoHint || !texExtensions->isNonPowerOfTwoTextureSupported(_min_filter)
|
||||
|| inwidth > extensions->maxTexture3DSize()
|
||||
|| inheight > extensions->maxTexture3DSize()
|
||||
|| indepth > extensions->maxTexture3DSize() )
|
||||
|
||||
Reference in New Issue
Block a user