Refactored Texture::Extensions to simplify it and make it more efficient.
This commit is contained in:
@@ -614,18 +614,12 @@ class OSG_EXPORT Texture : public osg::StateAttribute
|
||||
public:
|
||||
Extensions(unsigned int contextID);
|
||||
|
||||
Extensions(const Extensions& rhs);
|
||||
|
||||
void lowestCommonDenominator(const Extensions& rhs);
|
||||
|
||||
void setupGLExtensions(unsigned int contextID);
|
||||
|
||||
void setMultiTexturingSupported(bool flag) { _isMultiTexturingSupported=flag; }
|
||||
bool isMultiTexturingSupported() const { return _isMultiTexturingSupported; }
|
||||
|
||||
void setTextureFilterAnisotropicSupported(bool flag) { _isTextureFilterAnisotropicSupported=flag; }
|
||||
bool isTextureFilterAnisotropicSupported() const { return _isTextureFilterAnisotropicSupported; }
|
||||
|
||||
|
||||
void setTextureCompressionARBSupported(bool flag) { _isTextureCompressionARBSupported=flag; }
|
||||
bool isTextureCompressionARBSupported() const { return _isTextureCompressionARBSupported; }
|
||||
|
||||
@@ -662,10 +656,6 @@ class OSG_EXPORT Texture : public osg::StateAttribute
|
||||
bool isCompressedTexImage2DSupported() const { return _glCompressedTexImage2D!=0; }
|
||||
bool isCompressedTexSubImage2DSupported() const { return _glCompressedTexSubImage2D!=0; }
|
||||
|
||||
void glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data) const;
|
||||
void glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei type, const GLvoid *data) const;
|
||||
void glGetCompressedTexImage(GLenum target, GLint level, GLvoid *data) const;
|
||||
|
||||
bool isClientStorageSupported() const { return _isClientStorageSupported; }
|
||||
|
||||
bool isNonPowerOfTwoTextureSupported(GLenum filter) const
|
||||
@@ -678,13 +668,48 @@ class OSG_EXPORT Texture : public osg::StateAttribute
|
||||
void setTextureIntegerSupported(bool flag) { _isTextureIntegerEXTSupported=flag; }
|
||||
bool isTextureIntegerSupported() const { return _isTextureIntegerEXTSupported; }
|
||||
|
||||
void glTexParameterIiv(GLenum target, GLenum pname, const GLint* data) const;
|
||||
void glTexParameterIuiv(GLenum target, GLenum pname, const GLuint* data) const;
|
||||
void glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data) const
|
||||
{
|
||||
_glCompressedTexImage2D(target, level, internalformat, width, height, border, imageSize, data);
|
||||
}
|
||||
|
||||
void glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data) const
|
||||
{
|
||||
_glCompressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, imageSize, data);
|
||||
}
|
||||
|
||||
void glGetCompressedTexImage(GLenum target, GLint level, GLvoid *data) const
|
||||
{
|
||||
_glGetCompressedTexImage(target, level, data);
|
||||
}
|
||||
|
||||
void glTexParameterIiv(GLenum target, GLenum pname, const GLint* data) const
|
||||
{
|
||||
glTexParameterIiv(target, pname, data);
|
||||
}
|
||||
|
||||
void glTexParameterIuiv(GLenum target, GLenum pname, const GLuint* data) const
|
||||
{
|
||||
glTexParameterIuiv(target, pname, data);
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
~Extensions() {}
|
||||
|
||||
|
||||
typedef void (APIENTRY * CompressedTexImage2DArbProc) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data);
|
||||
typedef void (APIENTRY * CompressedTexSubImage2DArbProc) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data);
|
||||
typedef void (APIENTRY * GetCompressedTexImageArbProc) (GLenum target, GLint level, GLvoid *data);
|
||||
typedef void (APIENTRY * TexParameterIivProc)(GLenum target, GLenum pname, const GLint* data);
|
||||
typedef void (APIENTRY * TexParameterIuivProc)(GLenum target, GLenum pname, const GLuint* data);
|
||||
|
||||
CompressedTexImage2DArbProc _glCompressedTexImage2D;
|
||||
CompressedTexSubImage2DArbProc _glCompressedTexSubImage2D;
|
||||
GetCompressedTexImageArbProc _glGetCompressedTexImage;
|
||||
TexParameterIivProc _glTexParameterIiv;
|
||||
TexParameterIuivProc _glTexParameterIuiv;
|
||||
|
||||
|
||||
bool _isMultiTexturingSupported;
|
||||
bool _isTextureFilterAnisotropicSupported;
|
||||
bool _isTextureCompressionARBSupported;
|
||||
@@ -703,19 +728,6 @@ class OSG_EXPORT Texture : public osg::StateAttribute
|
||||
|
||||
GLint _maxTextureSize;
|
||||
GLint _numTextureUnits;
|
||||
|
||||
typedef void (APIENTRY * CompressedTexImage2DArbProc) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data);
|
||||
typedef void (APIENTRY * CompressedTexSubImage2DArbProc) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data);
|
||||
typedef void (APIENTRY * GetCompressedTexImageArbProc) (GLenum target, GLint level, GLvoid *data);
|
||||
typedef void (APIENTRY * TexParameterIivProc)(GLenum target, GLenum pname, const GLint* data);
|
||||
typedef void (APIENTRY * TexParameterIuivProc)(GLenum target, GLenum pname, const GLuint* data);
|
||||
|
||||
CompressedTexImage2DArbProc _glCompressedTexImage2D;
|
||||
CompressedTexSubImage2DArbProc _glCompressedTexSubImage2D;
|
||||
GetCompressedTexImageArbProc _glGetCompressedTexImage;
|
||||
TexParameterIivProc _glTexParameterIiv;
|
||||
TexParameterIuivProc _glTexParameterIuiv;
|
||||
|
||||
};
|
||||
|
||||
/** Gets the extension for the specified context. Creates the
|
||||
|
||||
@@ -2153,72 +2153,6 @@ void Texture::setExtensions(unsigned int contextID,Extensions* extensions)
|
||||
}
|
||||
|
||||
Texture::Extensions::Extensions(unsigned int contextID)
|
||||
{
|
||||
setupGLExtensions(contextID);
|
||||
}
|
||||
|
||||
Texture::Extensions::Extensions(const Extensions& rhs):
|
||||
Referenced()
|
||||
{
|
||||
_isMultiTexturingSupported = rhs._isMultiTexturingSupported;
|
||||
_isTextureFilterAnisotropicSupported = rhs._isTextureFilterAnisotropicSupported;
|
||||
_isTextureCompressionARBSupported = rhs._isTextureCompressionARBSupported;
|
||||
_isTextureCompressionS3TCSupported = rhs._isTextureCompressionS3TCSupported;
|
||||
_isTextureMirroredRepeatSupported = rhs._isTextureMirroredRepeatSupported;
|
||||
_isTextureEdgeClampSupported = rhs._isTextureEdgeClampSupported;
|
||||
_isTextureBorderClampSupported = rhs._isTextureBorderClampSupported;
|
||||
_isGenerateMipMapSupported = rhs._isGenerateMipMapSupported;
|
||||
|
||||
_maxTextureSize = rhs._maxTextureSize;
|
||||
|
||||
_glCompressedTexImage2D = rhs._glCompressedTexImage2D;
|
||||
|
||||
_isShadowSupported = rhs._isShadowSupported;
|
||||
_isShadowAmbientSupported = rhs._isShadowAmbientSupported;
|
||||
|
||||
_isClientStorageSupported = rhs._isClientStorageSupported;
|
||||
|
||||
_isNonPowerOfTwoTextureMipMappedSupported = rhs._isNonPowerOfTwoTextureMipMappedSupported;
|
||||
_isNonPowerOfTwoTextureNonMipMappedSupported = rhs._isNonPowerOfTwoTextureNonMipMappedSupported;
|
||||
|
||||
_isTextureIntegerEXTSupported = rhs._isTextureIntegerEXTSupported;
|
||||
_isTextureMaxLevelSupported = rhs._isTextureMaxLevelSupported;
|
||||
}
|
||||
|
||||
void Texture::Extensions::lowestCommonDenominator(const Extensions& rhs)
|
||||
{
|
||||
if (!rhs._isMultiTexturingSupported) _isMultiTexturingSupported = false;
|
||||
|
||||
if (!rhs._isTextureFilterAnisotropicSupported) _isTextureFilterAnisotropicSupported = false;
|
||||
if (!rhs._isTextureMirroredRepeatSupported) _isTextureMirroredRepeatSupported = false;
|
||||
if (!rhs._isTextureEdgeClampSupported) _isTextureEdgeClampSupported = false;
|
||||
if (!rhs._isTextureBorderClampSupported) _isTextureBorderClampSupported = false;
|
||||
|
||||
if (!rhs._isTextureCompressionARBSupported) _isTextureCompressionARBSupported = false;
|
||||
if (!rhs._isTextureCompressionS3TCSupported) _isTextureCompressionS3TCSupported = false;
|
||||
|
||||
if (!rhs._isGenerateMipMapSupported) _isGenerateMipMapSupported = false;
|
||||
|
||||
if (rhs._maxTextureSize<_maxTextureSize) _maxTextureSize = rhs._maxTextureSize;
|
||||
if (rhs._numTextureUnits<_numTextureUnits) _numTextureUnits = rhs._numTextureUnits;
|
||||
|
||||
if (!rhs._glCompressedTexImage2D) _glCompressedTexImage2D = 0;
|
||||
if (!rhs._glCompressedTexSubImage2D) _glCompressedTexSubImage2D = 0;
|
||||
if (!rhs._glGetCompressedTexImage) _glGetCompressedTexImage = 0;
|
||||
|
||||
if (!rhs._isShadowSupported) _isShadowSupported = false;
|
||||
if (!rhs._isShadowAmbientSupported) _isShadowAmbientSupported = false;
|
||||
|
||||
if (!rhs._isClientStorageSupported) _isClientStorageSupported = false;
|
||||
|
||||
if (!rhs._isNonPowerOfTwoTextureMipMappedSupported) _isNonPowerOfTwoTextureMipMappedSupported = false;
|
||||
if (!rhs._isNonPowerOfTwoTextureNonMipMappedSupported) _isNonPowerOfTwoTextureNonMipMappedSupported = false;
|
||||
|
||||
if (!rhs._isTextureIntegerEXTSupported) _isTextureIntegerEXTSupported = false;
|
||||
if (!rhs._isTextureMaxLevelSupported) _isTextureMaxLevelSupported = false;
|
||||
}
|
||||
|
||||
void Texture::Extensions::setupGLExtensions(unsigned int contextID)
|
||||
{
|
||||
const char* version = (const char*) glGetString( GL_VERSION );
|
||||
if (!version)
|
||||
@@ -2328,65 +2262,4 @@ void Texture::Extensions::setupGLExtensions(unsigned int contextID)
|
||||
}
|
||||
|
||||
|
||||
void Texture::Extensions::glTexParameterIiv(GLenum target, GLenum pname, const GLint* data) const
|
||||
{
|
||||
if (_glTexParameterIiv)
|
||||
{
|
||||
_glTexParameterIiv(target, pname, data);
|
||||
}
|
||||
else
|
||||
{
|
||||
notify(WARN)<<"Error: glTexParameterIiv not supported by OpenGL driver"<<std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void Texture::Extensions::glTexParameterIuiv(GLenum target, GLenum pname, const GLuint* data) const
|
||||
{
|
||||
if (_glTexParameterIuiv)
|
||||
{
|
||||
_glTexParameterIuiv(target, pname, data);
|
||||
}
|
||||
else
|
||||
{
|
||||
notify(WARN)<<"Error: glTexParameterIuiv not supported by OpenGL driver"<<std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void Texture::Extensions::glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data) const
|
||||
{
|
||||
if (_glCompressedTexImage2D)
|
||||
{
|
||||
_glCompressedTexImage2D(target, level, internalformat, width, height, border, imageSize, data);
|
||||
}
|
||||
else
|
||||
{
|
||||
notify(WARN)<<"Error: glCompressedTexImage2D not supported by OpenGL driver"<<std::endl;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Texture::Extensions::glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data) const
|
||||
{
|
||||
if (_glCompressedTexSubImage2D)
|
||||
{
|
||||
_glCompressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, imageSize, data);
|
||||
}
|
||||
else
|
||||
{
|
||||
notify(WARN)<<"Error: glCompressedTexImage2D not supported by OpenGL driver"<<std::endl;
|
||||
}
|
||||
|
||||
}
|
||||
void Texture::Extensions::glGetCompressedTexImage(GLenum target, GLint level, GLvoid *data) const
|
||||
{
|
||||
if (_glGetCompressedTexImage)
|
||||
{
|
||||
_glGetCompressedTexImage(target, level, data);
|
||||
}
|
||||
else
|
||||
{
|
||||
notify(WARN)<<"Error: glGetCompressedTexImage not supported by OpenGL driver"<<std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user