Moved Texture*::Extensions functionality into GL2Extensions

git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14581 16af8721-9629-0410-8352-f15c8da7e697
This commit is contained in:
Robert Osfield
2014-12-09 10:05:59 +00:00
parent a8804e2366
commit cceee38727
15 changed files with 293 additions and 590 deletions

View File

@@ -845,6 +845,73 @@ class OSG_EXPORT GL2Extensions : public osg::Referenced
void (GL_APIENTRY * glProgramLocalParameter4fv) (GLenum target, GLuint index, const GLfloat *params);
// Texture Extensions
bool isMultiTexturingSupported;
bool isTextureFilterAnisotropicSupported;
bool isTextureSwizzleSupported;
bool isTextureCompressionARBSupported;
bool isTextureCompressionS3TCSupported;
bool isTextureCompressionPVRTC2BPPSupported;
bool isTextureCompressionPVRTC4BPPSupported;
bool isTextureCompressionETCSupported;
bool isTextureCompressionETC2Supported;
bool isTextureCompressionRGTCSupported;
bool isTextureCompressionPVRTCSupported;
bool isTextureMirroredRepeatSupported;
bool isTextureEdgeClampSupported;
bool isTextureBorderClampSupported;
bool isGenerateMipMapSupported;
bool preferGenerateMipmapSGISForPowerOfTwo;
bool isTextureMultisampledSupported;
bool isShadowSupported;
bool isShadowAmbientSupported;
bool isTextureMaxLevelSupported;
GLint maxTextureSize;
bool _isTextureStorageEnabled;
bool isClientStorageSupported;
bool isTextureIntegerEXTSupported;
bool isTextureStorageEnabled;
bool isTexStorage2DSupported() const { return glTexStorage2D != 0; }
bool isCompressedTexImage2DSupported() const { return glCompressedTexImage2D!=0; }
bool isCompressedTexSubImage2DSupported() const { return glCompressedTexSubImage2D!=0; }
bool isBindImageTextureSupported() const { return glBindImageTexture!=0; }
bool isNonPowerOfTwoTextureMipMappedSupported;
bool isNonPowerOfTwoTextureNonMipMappedSupported;
bool isNonPowerOfTwoTextureSupported(GLenum filter) const
{
return (filter==GL_LINEAR || filter==GL_NEAREST) ?
isNonPowerOfTwoTextureNonMipMappedSupported :
isNonPowerOfTwoTextureMipMappedSupported;
}
void (GL_APIENTRY * glTexStorage2D) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
void (GL_APIENTRY * glCompressedTexImage2D) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data);
void (GL_APIENTRY * glCompressedTexSubImage2D) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data);
void (GL_APIENTRY * glGetCompressedTexImage) (GLenum target, GLint level, GLvoid *data);
void (GL_APIENTRY * glTexImage2DMultisample) (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations);
void (GL_APIENTRY * glTexParameterIiv) (GLenum target, GLenum pname, const GLint* data);
void (GL_APIENTRY * glTexParameterIuiv) (GLenum target, GLenum pname, const GLuint* data);
void (GL_APIENTRY * glBindImageTexture) (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format);
// Texture3D extensions
bool isTexture3DSupported;
bool isTexture3DFast;
GLint maxTexture3DSize;
bool isCompressedTexImage3DSupported() const { return glCompressedTexImage3D!=0; }
bool isCompressedTexSubImage3DSupported() const { return glCompressedTexSubImage3D!=0; }
void (GL_APIENTRY * glTexImage3D) ( GLenum target, GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
void (GL_APIENTRY * glTexSubImage3D) ( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels);
void (GL_APIENTRY * glCopyTexSubImage3D) ( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height );
void (GL_APIENTRY * glCompressedTexImage3D) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data);
void (GL_APIENTRY * glCompressedTexSubImage3D) ( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data );
// Texture2DArray extensions
bool isTexture2DArraySupported;
GLint maxLayerCount;
GLint max2DSize;
};
}

View File

@@ -782,204 +782,6 @@ class OSG_EXPORT Texture : public osg::StateAttribute
* for all graphics contexts. */
virtual void releaseGLObjects(State* state=0) const;
/** Encapsulates queries of extension availability, obtains extension
* function pointers, and provides convenience wrappers for
* calling extension functions. */
class OSG_EXPORT Extensions : public osg::Referenced
{
public:
Extensions(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 setTextureSwizzleSupported(bool flag) { _isTextureSwizzleSupported=flag; }
bool isTextureSwizzleSupported() const { return _isTextureSwizzleSupported; }
void setTextureCompressionARBSupported(bool flag) { _isTextureCompressionARBSupported=flag; }
bool isTextureCompressionARBSupported() const { return _isTextureCompressionARBSupported; }
void setTextureCompressionS3TCSupported(bool flag) { _isTextureCompressionS3TCSupported=flag; }
bool isTextureCompressionS3TCSupported() const { return _isTextureCompressionS3TCSupported; }
void setTextureCompressionPVRTC2BPPSupported(bool flag) { _isTextureCompressionPVRTC2BPPSupported=flag; }
bool isTextureCompressionPVRTC2BPPSupported() const { return _isTextureCompressionPVRTC2BPPSupported; }
void setTextureCompressionPVRTC4BPPSupported(bool flag) { _isTextureCompressionPVRTC4BPPSupported=flag; }
bool isTextureCompressionPVRTC4BPPSupported() const { return _isTextureCompressionPVRTC4BPPSupported; }
void setTextureCompressionETCSupported(bool flag) { _isTextureCompressionETCSupported=flag; }
bool isTextureCompressionETCSupported() const { return _isTextureCompressionETCSupported; }
void setTextureCompressionETC2Supported(bool flag) { _isTextureCompressionETC2Supported=flag; }
bool isTextureCompressionETC2Supported() const { return _isTextureCompressionETC2Supported; }
void setTextureCompressionRGTCSupported(bool flag) { _isTextureCompressionRGTCSupported=flag; }
bool isTextureCompressionRGTCSupported() const { return _isTextureCompressionRGTCSupported; }
void setTextureCompressionPVRTCSupported(bool flag) { _isTextureCompressionPVRTCSupported=flag; }
bool isTextureCompressionPVRTCSupported() const { return _isTextureCompressionPVRTCSupported; }
void setTextureMirroredRepeatSupported(bool flag) { _isTextureMirroredRepeatSupported=flag; }
bool isTextureMirroredRepeatSupported() const { return _isTextureMirroredRepeatSupported; }
void setTextureEdgeClampSupported(bool flag) { _isTextureEdgeClampSupported=flag; }
bool isTextureEdgeClampSupported() const { return _isTextureEdgeClampSupported; }
void setTextureBorderClampSupported(bool flag) { _isTextureBorderClampSupported=flag; }
bool isTextureBorderClampSupported() const { return _isTextureBorderClampSupported; }
void setGenerateMipMapSupported(bool flag) { _isGenerateMipMapSupported=flag; }
bool isGenerateMipMapSupported() const { return _isGenerateMipMapSupported; }
void setPreferGenerateMipmapSGISForPowerOfTwo(bool flag) { _preferGenerateMipmapSGISForPowerOfTwo = flag; }
bool getPreferGenerateMipmapSGISForPowerOfTwo() const { return _preferGenerateMipmapSGISForPowerOfTwo; }
void setTextureMultisampledSupported(bool flag) { _isTextureMultisampledSupported=flag; }
bool isTextureMultisampledSupported() const { return _isTextureMultisampledSupported; }
void setShadowSupported(bool flag) { _isShadowSupported = flag; }
bool isShadowSupported() const { return _isShadowSupported; }
void setShadowAmbientSupported(bool flag) { _isShadowAmbientSupported = flag; }
bool isShadowAmbientSupported() const { return _isShadowAmbientSupported; }
void setTextureMaxLevelSupported(bool flag) { _isTextureMaxLevelSupported = flag; }
bool isTextureMaxLevelSupported() const { return _isTextureMaxLevelSupported; }
void setMaxTextureSize(GLint maxsize) { _maxTextureSize=maxsize; }
GLint maxTextureSize() const { return _maxTextureSize; }
bool isTexStorage2DSupported() const { return _glTexStorage2D != 0; }
bool isTexStorageEnabled() const { return _isTextureStorageEnabled; }
bool isCompressedTexImage2DSupported() const { return _glCompressedTexImage2D!=0; }
bool isCompressedTexSubImage2DSupported() const { return _glCompressedTexSubImage2D!=0; }
bool isClientStorageSupported() const { return _isClientStorageSupported; }
bool isNonPowerOfTwoTextureSupported(GLenum filter) const
{
return (filter==GL_LINEAR || filter==GL_NEAREST) ?
_isNonPowerOfTwoTextureNonMipMappedSupported :
_isNonPowerOfTwoTextureMipMappedSupported;
}
void setTextureIntegerSupported(bool flag) { _isTextureIntegerEXTSupported=flag; }
bool isTextureIntegerSupported() const { return _isTextureIntegerEXTSupported; }
bool isBindImageTextureSupported() const { return _glBindImageTexture!=0; }
void glTexStorage2D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height) const
{
_glTexStorage2D(target, levels, internalformat, width, height);
}
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 glTexImage2DMultisample(GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations) const
{
_glTexImage2DMultisample(target, samples, internalformat, width, height, fixedsamplelocations);
}
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);
}
// ARB_shader_image_load_store
void glBindImageTexture(GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format) const
{
_glBindImageTexture(unit, texture, level, layered, layer, access, format);
}
protected:
~Extensions() {}
typedef void (GL_APIENTRY * TexStorage2DArbProc) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
typedef void (GL_APIENTRY * CompressedTexImage2DArbProc) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data);
typedef void (GL_APIENTRY * CompressedTexSubImage2DArbProc) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data);
typedef void (GL_APIENTRY * GetCompressedTexImageArbProc) (GLenum target, GLint level, GLvoid *data);
typedef void (GL_APIENTRY * TexImage2DMultisample)(GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations);
typedef void (GL_APIENTRY * TexParameterIivProc)(GLenum target, GLenum pname, const GLint* data);
typedef void (GL_APIENTRY * TexParameterIuivProc)(GLenum target, GLenum pname, const GLuint* data);
typedef void (GL_APIENTRY * BindImageTextureProc)( GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format );
CompressedTexImage2DArbProc _glCompressedTexImage2D;
CompressedTexSubImage2DArbProc _glCompressedTexSubImage2D;
GetCompressedTexImageArbProc _glGetCompressedTexImage;
TexImage2DMultisample _glTexImage2DMultisample;
TexParameterIivProc _glTexParameterIiv;
TexParameterIuivProc _glTexParameterIuiv;
// ARB_shader_image_load_store
BindImageTextureProc _glBindImageTexture;
// ARB_texture_storage
TexStorage2DArbProc _glTexStorage2D;
bool _isMultiTexturingSupported;
bool _isTextureFilterAnisotropicSupported;
bool _isTextureSwizzleSupported;
bool _isTextureCompressionARBSupported;
bool _isTextureCompressionS3TCSupported;
bool _isTextureCompressionPVRTC2BPPSupported;
bool _isTextureCompressionPVRTC4BPPSupported;
bool _isTextureCompressionETCSupported;
bool _isTextureCompressionETC2Supported;
bool _isTextureCompressionRGTCSupported;
bool _isTextureCompressionPVRTCSupported;
bool _isTextureMirroredRepeatSupported;
bool _isTextureEdgeClampSupported;
bool _isTextureBorderClampSupported;
bool _isGenerateMipMapSupported;
bool _preferGenerateMipmapSGISForPowerOfTwo;
bool _isTextureMultisampledSupported;
bool _isShadowSupported;
bool _isShadowAmbientSupported;
bool _isClientStorageSupported;
bool _isNonPowerOfTwoTextureMipMappedSupported;
bool _isNonPowerOfTwoTextureNonMipMappedSupported;
bool _isTextureIntegerEXTSupported;
bool _isTextureMaxLevelSupported;
bool _isTextureStorageEnabled;
GLint _maxTextureSize;
};
/** Gets the extension for the specified context. Creates the
* Extensions object for that context if it doesn't exist.
* Returns NULL if the Extensions object for the context doesn't
* exist and the createIfNotInitalized flag is false. */
static Extensions* getExtensions(unsigned int contextID,bool createIfNotInitalized);
/** Overrides Extensions objects across graphics contexts. Typically
* used to ensure the same lowest common denominator of extensions
* on systems with different graphics pipes. */
static void setExtensions(unsigned int contextID,Extensions* extensions);
/** Determine whether the given internalFormat is a compressed
* image format. */
static bool isCompressedInternalFormat(GLint internalFormat);

View File

@@ -120,86 +120,6 @@ class OSG_EXPORT Texture2DArray : public Texture
*/
virtual void apply(State& state) const;
/** Extensions class which encapsulates the querying of extensions and
* associated function pointers, and provides convenience wrappers to
* check for the extensions or use the associated functions.
*/
class OSG_EXPORT Extensions : public osg::Referenced
{
public:
Extensions(unsigned int contextID);
Extensions(const Extensions& rhs);
void lowestCommonDenominator(const Extensions& rhs);
void setupGLExtensions(unsigned int contextID);
void setTexture2DArraySupported(bool flag) { _isTexture2DArraySupported=flag; }
bool isTexture2DArraySupported() const { return _isTexture2DArraySupported; }
void setTexture3DSupported(bool flag) { _isTexture3DSupported=flag; }
bool isTexture3DSupported() const { return _isTexture3DSupported; }
void setMaxLayerCount(GLint count) { _maxLayerCount = count; }
GLint maxLayerCount() const { return _maxLayerCount; }
void setMax2DSize(GLint size) { _max2DSize = size; }
GLint max2DSize() const { return _max2DSize; }
void glTexImage3D( GLenum target, GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels) const;
void glTexSubImage3D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels) const;
void glCopyTexSubImage3D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height ) const;
bool isCompressedTexImage3DSupported() const { return _glCompressedTexImage3D!=0; }
void glCompressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data) const;
bool isCompressedTexSubImage3DSupported() const { return _glCompressedTexSubImage3D!=0; }
void glCompressedTexSubImage3D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data ) const;
protected:
~Extensions() {}
bool _isTexture2DArraySupported;
bool _isTexture3DSupported;
GLint _maxLayerCount;
GLint _max2DSize;
typedef void (GL_APIENTRY * GLTexImage3DProc) ( GLenum target, GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
typedef void (GL_APIENTRY * GLTexSubImage3DProc) ( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels);
typedef void (GL_APIENTRY * CompressedTexImage3DArbProc) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data);
typedef void (GL_APIENTRY * CompressedTexSubImage3DArbProc) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data);
typedef void (GL_APIENTRY * GLCopyTexSubImageProc) ( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height );
GLTexImage3DProc _glTexImage3D;
GLTexSubImage3DProc _glTexSubImage3D;
CompressedTexImage3DArbProc _glCompressedTexImage3D;
CompressedTexSubImage3DArbProc _glCompressedTexSubImage3D;
GLCopyTexSubImageProc _glCopyTexSubImage3D;
};
/** Function to call to get the extension of a specified context.
* If the Extension object for that context has not yet been created
* and the 'createIfNotInitalized' flag been set to false then returns NULL.
* If 'createIfNotInitalized' is true then the Extensions object is
* automatically created. However, in this case the extension object will
* only be created with the graphics context associated with ContextID.
*/
static Extensions* getExtensions(unsigned int contextID,bool createIfNotInitalized);
/** The setExtensions method allows users to override the extensions across graphics contexts.
* Typically used when you have different extensions supported across graphics pipes
* but need to ensure that they all use the same low common denominator extensions.
*/
static void setExtensions(unsigned int contextID,Extensions* extensions);
protected :
virtual ~Texture2DArray();

View File

@@ -136,65 +136,6 @@ class OSG_EXPORT Texture3D : public Texture
* compiled, create the texture mipmap levels. */
virtual void apply(State& state) const;
/** Encapsulates queries of extension availability, obtains extension
* function pointers, and provides convenience wrappers for
* calling extension functions. */
class OSG_EXPORT Extensions : public osg::Referenced
{
public:
Extensions(unsigned int contextID);
Extensions(const Extensions& rhs);
void lowestCommonDenominator(const Extensions& rhs);
void setupGLExtensions(unsigned int contextID);
void setTexture3DSupported(bool flag) { _isTexture3DSupported=flag; }
bool isTexture3DSupported() const { return _isTexture3DSupported; }
void setTexture3DFast(bool flag) { _isTexture3DFast=flag; }
bool isTexture3DFast() const { return _isTexture3DFast; }
void setMaxTexture3DSize(GLint maxsize) { _maxTexture3DSize=maxsize; }
GLint maxTexture3DSize() const { return _maxTexture3DSize; }
bool isCompressedTexImage3DSupported() const { return glCompressedTexImage3D!=0; }
bool isCompressedTexSubImage3DSupported() const { return glCompressedTexSubImage3D!=0; }
typedef void (GL_APIENTRY * GLTexImage3DProc) ( GLenum target, GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
typedef void (GL_APIENTRY * GLTexSubImage3DProc) ( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels);
typedef void (GL_APIENTRY * CompressedTexImage3DArbProc) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data);
typedef void (GL_APIENTRY * CompressedTexSubImage3DArbProc) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data);
typedef void (GL_APIENTRY * GLCopyTexSubImageProc) ( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height );
GLTexImage3DProc glTexImage3D;
GLTexSubImage3DProc glTexSubImage3D;
CompressedTexImage3DArbProc glCompressedTexImage3D;
CompressedTexSubImage3DArbProc glCompressedTexSubImage3D;
GLCopyTexSubImageProc glCopyTexSubImage3D;
protected:
~Extensions() {}
bool _isTexture3DSupported;
bool _isTexture3DFast;
GLint _maxTexture3DSize;
};
/** Encapsulates queries of extension availability, obtains extension
* function pointers, and provides convenience wrappers for
* calling extension functions. */
static Extensions* getExtensions(unsigned int contextID,bool createIfNotInitalized);
/** Overrides Extensions objects across graphics contexts. Typically
* used to ensure the same lowest common denominator of extensions
* on systems with different graphics pipes. */
static void setExtensions(unsigned int contextID,Extensions* extensions);
protected :
virtual ~Texture3D();