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:
@@ -39,22 +39,22 @@ int main( int argc, char **argv )
|
||||
{
|
||||
// use an ArgumentParser object to manage the program arguments.
|
||||
osg::ArgumentParser arguments(&argc,argv);
|
||||
|
||||
|
||||
// construct the viewer.
|
||||
osgViewer::Viewer viewer;
|
||||
|
||||
// load the nodes from the commandline arguments.
|
||||
osg::Node* rootnode = osgDB::readNodeFiles(arguments);
|
||||
|
||||
|
||||
// if not loaded assume no arguments passed in, try use default mode instead.
|
||||
if (!rootnode) rootnode = osgDB::readNodeFile("cessnafire.osgt");
|
||||
|
||||
|
||||
if (!rootnode)
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"Please specify a model filename on the command line."<<std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
osg::Image* image = osgDB::readImageFile("Images/reflect.rgb");
|
||||
if (image)
|
||||
{
|
||||
@@ -72,7 +72,7 @@ int main( int argc, char **argv )
|
||||
stateset->setTextureAttributeAndModes(1,texture,osg::StateAttribute::ON);
|
||||
stateset->setTextureAttributeAndModes(1,texgen,osg::StateAttribute::ON);
|
||||
stateset->setTextureAttribute(1,texenv);
|
||||
|
||||
|
||||
rootnode->setStateSet(stateset);
|
||||
}
|
||||
else
|
||||
@@ -83,21 +83,21 @@ int main( int argc, char **argv )
|
||||
// run optimization over the scene graph
|
||||
osgUtil::Optimizer optimzer;
|
||||
optimzer.optimize(rootnode);
|
||||
|
||||
|
||||
// add a viewport to the viewer and attach the scene graph.
|
||||
viewer.setSceneData( rootnode );
|
||||
|
||||
|
||||
// create the windows and run the threads.
|
||||
viewer.realize();
|
||||
|
||||
for(unsigned int contextID = 0;
|
||||
for(unsigned int contextID = 0;
|
||||
contextID<osg::DisplaySettings::instance()->getMaxNumberOfGraphicsContexts();
|
||||
++contextID)
|
||||
{
|
||||
osg::Texture::Extensions* textExt = osg::Texture::getExtensions(contextID,false);
|
||||
osg::GL2Extensions* textExt = osg::GL2Extensions::Get(contextID,false);
|
||||
if (textExt)
|
||||
{
|
||||
if (!textExt->isMultiTexturingSupported())
|
||||
if (!textExt->isMultiTexturingSupported)
|
||||
{
|
||||
std::cout<<"Warning: multi-texturing not supported by OpenGL drivers, unable to run application."<<std::endl;
|
||||
return 1;
|
||||
|
||||
@@ -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;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -398,6 +398,7 @@ GL2Extensions::GL2Extensions(unsigned int contextID)
|
||||
isSampleMaskiSupported = glSampleMaski!=0;
|
||||
|
||||
|
||||
|
||||
// old styple Vertex/Fragment Programs
|
||||
isVertexProgramSupported = isGLExtensionSupported(contextID,"GL_ARB_vertex_program");
|
||||
isFragmentProgramSupported = isGLExtensionSupported(contextID,"GL_ARB_fragment_program");
|
||||
@@ -410,6 +411,121 @@ GL2Extensions::GL2Extensions(unsigned int contextID)
|
||||
|
||||
|
||||
|
||||
// Texture extensions
|
||||
const char* renderer = (const char*) glGetString(GL_RENDERER);
|
||||
std::string rendererString(renderer ? renderer : "");
|
||||
|
||||
bool radeonHardwareDetected = (rendererString.find("Radeon")!=std::string::npos || rendererString.find("RADEON")!=std::string::npos);
|
||||
bool fireGLHardwareDetected = (rendererString.find("FireGL")!=std::string::npos || rendererString.find("FIREGL")!=std::string::npos);
|
||||
|
||||
bool builtInSupport = OSG_GLES2_FEATURES || OSG_GL3_FEATURES;
|
||||
|
||||
isMultiTexturingSupported = builtInSupport || OSG_GLES1_FEATURES ||
|
||||
isGLExtensionOrVersionSupported( contextID,"GL_ARB_multitexture", 1.3f) ||
|
||||
isGLExtensionOrVersionSupported(contextID,"GL_EXT_multitexture", 1.3f);
|
||||
|
||||
isTextureFilterAnisotropicSupported = isGLExtensionSupported(contextID,"GL_EXT_texture_filter_anisotropic");
|
||||
isTextureSwizzleSupported = isGLExtensionSupported(contextID,"GL_ARB_texture_swizzle");
|
||||
isTextureCompressionARBSupported = builtInSupport || isGLExtensionOrVersionSupported(contextID,"GL_ARB_texture_compression", 1.3f);
|
||||
isTextureCompressionS3TCSupported = isGLExtensionSupported(contextID,"GL_EXT_texture_compression_s3tc");
|
||||
isTextureCompressionPVRTC2BPPSupported = isGLExtensionSupported(contextID,"GL_IMG_texture_compression_pvrtc");
|
||||
isTextureCompressionPVRTC4BPPSupported = isTextureCompressionPVRTC2BPPSupported;//covered by same extension
|
||||
isTextureCompressionETCSupported = isGLExtensionSupported(contextID,"GL_OES_compressed_ETC1_RGB8_texture");
|
||||
isTextureCompressionETC2Supported = isGLExtensionSupported(contextID,"GL_ARB_ES3_compatibility");
|
||||
isTextureCompressionRGTCSupported = isGLExtensionSupported(contextID,"GL_EXT_texture_compression_rgtc");
|
||||
isTextureCompressionPVRTCSupported = isGLExtensionSupported(contextID,"GL_IMG_texture_compression_pvrtc");
|
||||
|
||||
isTextureMirroredRepeatSupported = builtInSupport ||
|
||||
isGLExtensionOrVersionSupported(contextID,"GL_IBM_texture_mirrored_repeat", 1.4f) ||
|
||||
isGLExtensionOrVersionSupported(contextID,"GL_ARB_texture_mirrored_repeat", 1.4f);
|
||||
|
||||
isTextureEdgeClampSupported = builtInSupport ||
|
||||
isGLExtensionOrVersionSupported(contextID,"GL_EXT_texture_edge_clamp", 1.2f) ||
|
||||
isGLExtensionOrVersionSupported(contextID,"GL_SGIS_texture_edge_clamp", 1.2f);
|
||||
|
||||
|
||||
isTextureBorderClampSupported = OSG_GL3_FEATURES || ((OSG_GL1_FEATURES || OSG_GL2_FEATURES) && isGLExtensionOrVersionSupported(contextID,"GL_ARB_texture_border_clamp", 1.3f));
|
||||
isGenerateMipMapSupported = builtInSupport || isGLExtensionOrVersionSupported(contextID,"GL_SGIS_generate_mipmap", 1.4f);
|
||||
preferGenerateMipmapSGISForPowerOfTwo = (radeonHardwareDetected||fireGLHardwareDetected) ? false : true;
|
||||
isTextureMultisampledSupported = isGLExtensionSupported(contextID,"GL_ARB_texture_multisample");
|
||||
isShadowSupported = OSG_GL3_FEATURES || isGLExtensionSupported(contextID,"GL_ARB_shadow");
|
||||
isShadowAmbientSupported = isGLExtensionSupported(contextID,"GL_ARB_shadow_ambient");
|
||||
isClientStorageSupported = isGLExtensionSupported(contextID,"GL_APPLE_client_storage");
|
||||
isNonPowerOfTwoTextureNonMipMappedSupported = builtInSupport || isGLExtensionOrVersionSupported(contextID,"GL_ARB_texture_non_power_of_two", 2.0) || isGLExtensionSupported(contextID,"GL_APPLE_texture_2D_limited_npot");
|
||||
isNonPowerOfTwoTextureMipMappedSupported = builtInSupport || isNonPowerOfTwoTextureNonMipMappedSupported;
|
||||
isTextureIntegerEXTSupported = OSG_GL3_FEATURES || isGLExtensionSupported(contextID, "GL_EXT_texture_integer");
|
||||
|
||||
if (rendererString.find("GeForce FX")!=std::string::npos)
|
||||
{
|
||||
isNonPowerOfTwoTextureMipMappedSupported = false;
|
||||
OSG_INFO<<"Disabling _isNonPowerOfTwoTextureMipMappedSupported for GeForce FX hardware."<<std::endl;
|
||||
}
|
||||
|
||||
maxTextureSize=0;
|
||||
glGetIntegerv(GL_MAX_TEXTURE_SIZE,&maxTextureSize);
|
||||
|
||||
char *ptr;
|
||||
if( (ptr = getenv("OSG_MAX_TEXTURE_SIZE")) != 0)
|
||||
{
|
||||
GLint osg_max_size = atoi(ptr);
|
||||
|
||||
if (osg_max_size<maxTextureSize)
|
||||
{
|
||||
|
||||
maxTextureSize = osg_max_size;
|
||||
}
|
||||
}
|
||||
|
||||
setGLExtensionFuncPtr(glTexStorage2D,"glTexStorage2D","glTexStorage2DARB");
|
||||
setGLExtensionFuncPtr(glCompressedTexImage2D,"glCompressedTexImage2D","glCompressedTexImage2DARB");
|
||||
setGLExtensionFuncPtr(glCompressedTexSubImage2D,"glCompressedTexSubImage2D","glCompressedTexSubImage2DARB");
|
||||
setGLExtensionFuncPtr(glGetCompressedTexImage,"glGetCompressedTexImage","glGetCompressedTexImageARB");;
|
||||
setGLExtensionFuncPtr(glTexImage2DMultisample, "glTexImage2DMultisample", "glTexImage2DMultisampleARB");
|
||||
|
||||
setGLExtensionFuncPtr(glTexParameterIiv, "glTexParameterIiv", "glTexParameterIivARB");
|
||||
setGLExtensionFuncPtr(glTexParameterIuiv, "glTexParameterIuiv", "glTexParameterIuivARB");
|
||||
|
||||
|
||||
if (glTexParameterIiv == NULL) setGLExtensionFuncPtr(glTexParameterIiv, "glTexParameterIivEXT");
|
||||
if (glTexParameterIuiv == NULL) setGLExtensionFuncPtr(glTexParameterIuiv, "glTexParameterIuivEXT");
|
||||
|
||||
setGLExtensionFuncPtr(glBindImageTexture, "glBindImageTexture", "glBindImageTextureARB");
|
||||
|
||||
isTextureMaxLevelSupported = ( getGLVersionNumber() >= 1.2f );
|
||||
|
||||
isTextureStorageEnabled = isTexStorage2DSupported();
|
||||
if ( (ptr = getenv("OSG_GL_TEXTURE_STORAGE")) != 0 && isTexStorage2DSupported())
|
||||
{
|
||||
if (strcmp(ptr,"OFF")==0 || strcmp(ptr,"DISABLE")==0 ) isTextureStorageEnabled = false;
|
||||
else isTextureStorageEnabled = true;
|
||||
}
|
||||
|
||||
|
||||
// Texture3D extensions
|
||||
isTexture3DFast = OSG_GL3_FEATURES || isGLExtensionSupported(contextID,"GL_EXT_texture3D");
|
||||
|
||||
if (isTexture3DFast) isTexture3DSupported = true;
|
||||
else isTexture3DSupported = strncmp((const char*)glGetString(GL_VERSION),"1.2",3)>=0;
|
||||
|
||||
maxTexture3DSize = 0;
|
||||
glGetIntegerv(GL_MAX_3D_TEXTURE_SIZE, &maxTexture3DSize);
|
||||
|
||||
setGLExtensionFuncPtr(glTexImage3D, "glTexImage3D","glTexImage3DEXT");
|
||||
setGLExtensionFuncPtr(glTexSubImage3D, "glTexSubImage3D","glTexSubImage3DEXT");
|
||||
setGLExtensionFuncPtr(glCompressedTexImage3D, "glCompressedTexImage3D","glCompressedTexImage3DARB");
|
||||
setGLExtensionFuncPtr(glCompressedTexSubImage3D, "glCompressedTexSubImage3D","glCompressedTexSubImage3DARB");
|
||||
setGLExtensionFuncPtr(glCopyTexSubImage3D, "glCopyTexSubImage3D","glCopyTexSubImage3DEXT");
|
||||
|
||||
|
||||
// Texture2DArray extensions
|
||||
isTexture2DArraySupported = OSG_GL3_FEATURES || isGLExtensionSupported(contextID,"GL_EXT_texture_array");
|
||||
|
||||
max2DSize = 0;
|
||||
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &max2DSize);
|
||||
maxLayerCount = 0;
|
||||
glGetIntegerv(GL_MAX_ARRAY_TEXTURE_LAYERS_EXT, &maxLayerCount);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1053,10 +1053,7 @@ void Image::readImageFromCurrentTexture(unsigned int contextID, bool copyMipMaps
|
||||
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE)
|
||||
// OSG_NOTICE<<"Image::readImageFromCurrentTexture()"<<std::endl;
|
||||
|
||||
const osg::Texture::Extensions* extensions = osg::Texture::getExtensions(contextID,true);
|
||||
const osg::Texture3D::Extensions* extensions3D = osg::Texture3D::getExtensions(contextID,true);
|
||||
const osg::Texture2DArray::Extensions* extensions2DArray = osg::Texture2DArray::getExtensions(contextID,true);
|
||||
|
||||
const osg::GL2Extensions* extensions = osg::GL2Extensions::Get(contextID,true);
|
||||
|
||||
GLboolean binding1D = GL_FALSE, binding2D = GL_FALSE, binding3D = GL_FALSE, binding2DArray = GL_FALSE, bindingCubeMap = GL_FALSE;
|
||||
|
||||
@@ -1065,7 +1062,7 @@ void Image::readImageFromCurrentTexture(unsigned int contextID, bool copyMipMaps
|
||||
glGetBooleanv(GL_TEXTURE_BINDING_3D, &binding3D);
|
||||
glGetBooleanv(GL_TEXTURE_BINDING_CUBE_MAP, &bindingCubeMap);
|
||||
|
||||
if (extensions2DArray->isTexture2DArraySupported())
|
||||
if (extensions->isTexture2DArraySupported)
|
||||
{
|
||||
glGetBooleanv(GL_TEXTURE_BINDING_2D_ARRAY_EXT, &binding2DArray);
|
||||
}
|
||||
@@ -1136,14 +1133,14 @@ void Image::readImageFromCurrentTexture(unsigned int contextID, bool copyMipMaps
|
||||
}
|
||||
else if (textureMode==GL_TEXTURE_3D)
|
||||
{
|
||||
if (extensions3D->isCompressedTexImage3DSupported())
|
||||
if (extensions->isCompressedTexImage3DSupported())
|
||||
{
|
||||
glGetTexLevelParameteriv(textureMode, 0, GL_TEXTURE_COMPRESSED_ARB,&compressed);
|
||||
}
|
||||
}
|
||||
else if (textureMode==GL_TEXTURE_2D_ARRAY_EXT)
|
||||
{
|
||||
if (extensions2DArray->isCompressedTexImage3DSupported())
|
||||
if (extensions->isCompressedTexImage3DSupported())
|
||||
{
|
||||
glGetTexLevelParameteriv(textureMode, 0, GL_TEXTURE_COMPRESSED_ARB,&compressed);
|
||||
}
|
||||
|
||||
@@ -62,9 +62,6 @@ namespace osg {
|
||||
ApplicationUsageProxy Texture_e0(ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_MAX_TEXTURE_SIZE","Set the maximum size of textures.");
|
||||
ApplicationUsageProxy Texture_e1(ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_GL_TEXTURE_STORAGE","ON|OFF or ENABLE|DISABLE, Enables/disables usage of glTexStorage for textures where supported, default is ENABLED.");
|
||||
|
||||
typedef buffered_value< ref_ptr<Texture::Extensions> > BufferedExtensions;
|
||||
static BufferedExtensions s_extensions;
|
||||
|
||||
struct InternalPixelRelations
|
||||
{
|
||||
GLenum sizedInternalFormat;
|
||||
@@ -1468,12 +1465,12 @@ void Texture::computeInternalFormatWithImage(const osg::Image& image) const
|
||||
{
|
||||
|
||||
const unsigned int contextID = 0; // state.getContextID(); // set to 0 right now, assume same parameters for each graphics context...
|
||||
const Extensions* extensions = getExtensions(contextID,true);
|
||||
const GL2Extensions* extensions = GL2Extensions::Get(contextID,true);
|
||||
|
||||
switch(_internalFormatMode)
|
||||
{
|
||||
case(USE_ARB_COMPRESSION):
|
||||
if (extensions->isTextureCompressionARBSupported())
|
||||
if (extensions->isTextureCompressionARBSupported)
|
||||
{
|
||||
switch(image.getPixelFormat())
|
||||
{
|
||||
@@ -1492,7 +1489,7 @@ void Texture::computeInternalFormatWithImage(const osg::Image& image) const
|
||||
break;
|
||||
|
||||
case(USE_S3TC_DXT1_COMPRESSION):
|
||||
if (extensions->isTextureCompressionS3TCSupported())
|
||||
if (extensions->isTextureCompressionS3TCSupported)
|
||||
{
|
||||
switch(image.getPixelFormat())
|
||||
{
|
||||
@@ -1506,7 +1503,7 @@ void Texture::computeInternalFormatWithImage(const osg::Image& image) const
|
||||
break;
|
||||
|
||||
case(USE_S3TC_DXT1c_COMPRESSION):
|
||||
if (extensions->isTextureCompressionS3TCSupported())
|
||||
if (extensions->isTextureCompressionS3TCSupported)
|
||||
{
|
||||
switch(image.getPixelFormat())
|
||||
{
|
||||
@@ -1520,7 +1517,7 @@ void Texture::computeInternalFormatWithImage(const osg::Image& image) const
|
||||
break;
|
||||
|
||||
case(USE_S3TC_DXT1a_COMPRESSION):
|
||||
if (extensions->isTextureCompressionS3TCSupported())
|
||||
if (extensions->isTextureCompressionS3TCSupported)
|
||||
{
|
||||
switch(image.getPixelFormat())
|
||||
{
|
||||
@@ -1534,7 +1531,7 @@ void Texture::computeInternalFormatWithImage(const osg::Image& image) const
|
||||
break;
|
||||
|
||||
case(USE_S3TC_DXT3_COMPRESSION):
|
||||
if (extensions->isTextureCompressionS3TCSupported())
|
||||
if (extensions->isTextureCompressionS3TCSupported)
|
||||
{
|
||||
switch(image.getPixelFormat())
|
||||
{
|
||||
@@ -1548,7 +1545,7 @@ void Texture::computeInternalFormatWithImage(const osg::Image& image) const
|
||||
break;
|
||||
|
||||
case(USE_S3TC_DXT5_COMPRESSION):
|
||||
if (extensions->isTextureCompressionS3TCSupported())
|
||||
if (extensions->isTextureCompressionS3TCSupported)
|
||||
{
|
||||
switch(image.getPixelFormat())
|
||||
{
|
||||
@@ -1562,7 +1559,7 @@ void Texture::computeInternalFormatWithImage(const osg::Image& image) const
|
||||
break;
|
||||
|
||||
case(USE_PVRTC_2BPP_COMPRESSION):
|
||||
if (extensions->isTextureCompressionPVRTC2BPPSupported())
|
||||
if (extensions->isTextureCompressionPVRTC2BPPSupported)
|
||||
{
|
||||
switch(image.getPixelFormat())
|
||||
{
|
||||
@@ -1576,7 +1573,7 @@ void Texture::computeInternalFormatWithImage(const osg::Image& image) const
|
||||
break;
|
||||
|
||||
case(USE_PVRTC_4BPP_COMPRESSION):
|
||||
if (extensions->isTextureCompressionPVRTC4BPPSupported())
|
||||
if (extensions->isTextureCompressionPVRTC4BPPSupported)
|
||||
{
|
||||
switch(image.getPixelFormat())
|
||||
{
|
||||
@@ -1590,7 +1587,7 @@ void Texture::computeInternalFormatWithImage(const osg::Image& image) const
|
||||
break;
|
||||
|
||||
case(USE_ETC_COMPRESSION):
|
||||
if (extensions->isTextureCompressionETCSupported())
|
||||
if (extensions->isTextureCompressionETCSupported)
|
||||
{
|
||||
switch(image.getPixelFormat())
|
||||
{
|
||||
@@ -1602,7 +1599,7 @@ void Texture::computeInternalFormatWithImage(const osg::Image& image) const
|
||||
break;
|
||||
|
||||
case(USE_ETC2_COMPRESSION):
|
||||
if (extensions->isTextureCompressionETC2Supported())
|
||||
if (extensions->isTextureCompressionETC2Supported)
|
||||
{
|
||||
switch(image.getPixelFormat())
|
||||
{
|
||||
@@ -1620,7 +1617,7 @@ void Texture::computeInternalFormatWithImage(const osg::Image& image) const
|
||||
break;
|
||||
|
||||
case(USE_RGTC1_COMPRESSION):
|
||||
if (extensions->isTextureCompressionRGTCSupported())
|
||||
if (extensions->isTextureCompressionRGTCSupported)
|
||||
{
|
||||
switch(image.getPixelFormat())
|
||||
{
|
||||
@@ -1634,7 +1631,7 @@ void Texture::computeInternalFormatWithImage(const osg::Image& image) const
|
||||
break;
|
||||
|
||||
case(USE_RGTC2_COMPRESSION):
|
||||
if (extensions->isTextureCompressionRGTCSupported())
|
||||
if (extensions->isTextureCompressionRGTCSupported)
|
||||
{
|
||||
switch(image.getPixelFormat())
|
||||
{
|
||||
@@ -1815,7 +1812,7 @@ void Texture::getCompressedSize(GLenum internalFormat, GLint width, GLint height
|
||||
else if (internalFormat == GL_COMPRESSED_RGBA_S3TC_DXT3_EXT || internalFormat == GL_COMPRESSED_RGBA_S3TC_DXT5_EXT)
|
||||
blockSize = 16;
|
||||
else if (internalFormat == GL_ETC1_RGB8_OES)
|
||||
blockSize = 8;
|
||||
blockSize = 8;
|
||||
else if (internalFormat == GL_COMPRESSED_RGB8_ETC2 || internalFormat == GL_COMPRESSED_SRGB8_ETC2)
|
||||
blockSize = 8;
|
||||
else if (internalFormat == GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 || internalFormat == GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2)
|
||||
@@ -1876,12 +1873,12 @@ void Texture::applyTexParameters(GLenum target, State& state) const
|
||||
// get the contextID (user defined ID of 0 upwards) for the
|
||||
// current OpenGL context.
|
||||
const unsigned int contextID = state.getContextID();
|
||||
const Extensions* extensions = getExtensions(contextID,true);
|
||||
const GL2Extensions* extensions = state.get<GL2Extensions>();
|
||||
|
||||
WrapMode ws = _wrap_s, wt = _wrap_t, wr = _wrap_r;
|
||||
|
||||
// GL_IBM_texture_mirrored_repeat, fall-back REPEAT
|
||||
if (!extensions->isTextureMirroredRepeatSupported())
|
||||
if (!extensions->isTextureMirroredRepeatSupported)
|
||||
{
|
||||
if (ws == MIRROR)
|
||||
ws = REPEAT;
|
||||
@@ -1892,7 +1889,7 @@ void Texture::applyTexParameters(GLenum target, State& state) const
|
||||
}
|
||||
|
||||
// GL_EXT_texture_edge_clamp, fall-back CLAMP
|
||||
if (!extensions->isTextureEdgeClampSupported())
|
||||
if (!extensions->isTextureEdgeClampSupported)
|
||||
{
|
||||
if (ws == CLAMP_TO_EDGE)
|
||||
ws = CLAMP;
|
||||
@@ -1902,7 +1899,7 @@ void Texture::applyTexParameters(GLenum target, State& state) const
|
||||
wr = CLAMP;
|
||||
}
|
||||
|
||||
if(!extensions->isTextureBorderClampSupported())
|
||||
if(!extensions->isTextureBorderClampSupported)
|
||||
{
|
||||
if(ws == CLAMP_TO_BORDER)
|
||||
ws = CLAMP;
|
||||
@@ -1921,7 +1918,7 @@ void Texture::applyTexParameters(GLenum target, State& state) const
|
||||
const Image * image = getImage(0);
|
||||
if( image &&
|
||||
image->isMipmap() &&
|
||||
extensions->isTextureMaxLevelSupported() &&
|
||||
extensions->isTextureMaxLevelSupported &&
|
||||
int( image->getNumMipmapLevels() ) <
|
||||
Image::computeNumberOfMipmapLevels( image->s(), image->t(), image->r() ) )
|
||||
glTexParameteri( target, GL_TEXTURE_MAX_LEVEL, image->getNumMipmapLevels() - 1 );
|
||||
@@ -1938,7 +1935,7 @@ void Texture::applyTexParameters(GLenum target, State& state) const
|
||||
glTexParameteri( target, GL_TEXTURE_MAG_FILTER, _mag_filter);
|
||||
|
||||
// Art: I think anisotropic filtering is not supported by the integer textures
|
||||
if (extensions->isTextureFilterAnisotropicSupported() &&
|
||||
if (extensions->isTextureFilterAnisotropicSupported &&
|
||||
_internalFormatType != SIGNED_INTEGER && _internalFormatType != UNSIGNED_INTEGER)
|
||||
{
|
||||
// note, GL_TEXTURE_MAX_ANISOTROPY_EXT will either be defined
|
||||
@@ -1946,14 +1943,14 @@ void Texture::applyTexParameters(GLenum target, State& state) const
|
||||
glTexParameterf(target, GL_TEXTURE_MAX_ANISOTROPY_EXT, _maxAnisotropy);
|
||||
}
|
||||
|
||||
if (extensions->isTextureSwizzleSupported())
|
||||
if (extensions->isTextureSwizzleSupported)
|
||||
{
|
||||
// note, GL_TEXTURE_SWIZZLE_RGBA will either be defined
|
||||
// by gl.h (or via glext.h) or by include/osg/Texture.
|
||||
glTexParameteriv(target, GL_TEXTURE_SWIZZLE_RGBA, _swizzle.ptr());
|
||||
}
|
||||
|
||||
if (extensions->isTextureBorderClampSupported())
|
||||
if (extensions->isTextureBorderClampSupported)
|
||||
{
|
||||
|
||||
#ifndef GL_TEXTURE_BORDER_COLOR
|
||||
@@ -1977,7 +1974,7 @@ void Texture::applyTexParameters(GLenum target, State& state) const
|
||||
|
||||
// integer textures are not supported by the shadow
|
||||
// GL_TEXTURE_1D_ARRAY_EXT could be included in the check below but its not yet implemented in OSG
|
||||
if (extensions->isShadowSupported() &&
|
||||
if (extensions->isShadowSupported &&
|
||||
(target == GL_TEXTURE_2D || target == GL_TEXTURE_1D || target == GL_TEXTURE_RECTANGLE || target == GL_TEXTURE_CUBE_MAP || target == GL_TEXTURE_2D_ARRAY_EXT ) &&
|
||||
_internalFormatType != SIGNED_INTEGER && _internalFormatType != UNSIGNED_INTEGER)
|
||||
{
|
||||
@@ -1989,7 +1986,7 @@ void Texture::applyTexParameters(GLenum target, State& state) const
|
||||
|
||||
// if ambient value is 0 - it is default behaviour of GL_ARB_shadow
|
||||
// no need for GL_ARB_shadow_ambient in this case
|
||||
if (extensions->isShadowAmbientSupported() && _shadow_ambient > 0)
|
||||
if (extensions->isShadowAmbientSupported && _shadow_ambient > 0)
|
||||
{
|
||||
glTexParameterf(target, TEXTURE_COMPARE_FAIL_VALUE_ARB, _shadow_ambient);
|
||||
}
|
||||
@@ -2019,8 +2016,7 @@ void Texture::applyTexParameters(GLenum target, State& state) const
|
||||
|
||||
void Texture::computeRequiredTextureDimensions(State& state, const osg::Image& image,GLsizei& inwidth, GLsizei& inheight,GLsizei& numMipmapLevels) const
|
||||
{
|
||||
const unsigned int contextID = state.getContextID();
|
||||
const Extensions* extensions = getExtensions(contextID,true);
|
||||
const GL2Extensions* extensions = state.get<GL2Extensions>();
|
||||
|
||||
int width,height;
|
||||
|
||||
@@ -2036,8 +2032,8 @@ void Texture::computeRequiredTextureDimensions(State& state, const osg::Image& i
|
||||
}
|
||||
|
||||
// cap the size to what the graphics hardware can handle.
|
||||
if (width>extensions->maxTextureSize()) width = extensions->maxTextureSize();
|
||||
if (height>extensions->maxTextureSize()) height = extensions->maxTextureSize();
|
||||
if (width>extensions->maxTextureSize) width = extensions->maxTextureSize;
|
||||
if (height>extensions->maxTextureSize) height = extensions->maxTextureSize;
|
||||
|
||||
inwidth = width;
|
||||
inheight = height;
|
||||
@@ -2081,10 +2077,8 @@ void Texture::applyTexImage2D_load(State& state, GLenum target, const Image* ima
|
||||
OSG_NOTICE<<"glTexImage2D pixelFormat = "<<std::hex<<image->getPixelFormat()<<std::dec<<std::endl;
|
||||
#endif
|
||||
|
||||
// get the contextID (user defined ID of 0 upwards) for the
|
||||
// current OpenGL context.
|
||||
const unsigned int contextID = state.getContextID();
|
||||
const Extensions* extensions = getExtensions(contextID,true);
|
||||
// get extensions object
|
||||
const GL2Extensions* extensions = state.get<GL2Extensions>();
|
||||
|
||||
// select the internalFormat required for the texture.
|
||||
bool compressed_image = isCompressedInternalFormat((GLenum)image->getPixelFormat());
|
||||
@@ -2136,7 +2130,7 @@ void Texture::applyTexImage2D_load(State& state, GLenum target, const Image* ima
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT,image->getPacking());
|
||||
unsigned int rowLength = image->getRowLength();
|
||||
|
||||
bool useClientStorage = extensions->isClientStorageSupported() && getClientStorageHint();
|
||||
bool useClientStorage = extensions->isClientStorageSupported && getClientStorageHint();
|
||||
if (useClientStorage)
|
||||
{
|
||||
glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE,GL_TRUE);
|
||||
@@ -2200,7 +2194,7 @@ void Texture::applyTexImage2D_load(State& state, GLenum target, const Image* ima
|
||||
bool useHardwareMipMapGeneration = mipmappingRequired && (!image->isMipmap() && isHardwareMipmapGenerationEnabled(state));
|
||||
bool useGluBuildMipMaps = mipmappingRequired && (!useHardwareMipMapGeneration && !image->isMipmap());
|
||||
|
||||
GLBufferObject* pbo = image->getOrCreateGLBufferObject(contextID);
|
||||
GLBufferObject* pbo = image->getOrCreateGLBufferObject(state.getContextID());
|
||||
if (pbo && !needImageRescale && !useGluBuildMipMaps)
|
||||
{
|
||||
state.bindPixelBufferObject(pbo);
|
||||
@@ -2261,7 +2255,7 @@ void Texture::applyTexImage2D_load(State& state, GLenum target, const Image* ima
|
||||
int width = inwidth;
|
||||
int height = inheight;
|
||||
|
||||
bool useTexStorrage = extensions->isTexStorageEnabled();
|
||||
bool useTexStorrage = extensions->isTextureStorageEnabled;
|
||||
GLenum sizedInternalFormat = 0;
|
||||
|
||||
if(useTexStorrage)
|
||||
@@ -2491,7 +2485,7 @@ void Texture::applyTexImage2D_subload(State& state, GLenum target, const Image*
|
||||
// get the contextID (user defined ID of 0 upwards) for the
|
||||
// current OpenGL context.
|
||||
const unsigned int contextID = state.getContextID();
|
||||
const Extensions* extensions = getExtensions(contextID,true);
|
||||
const GL2Extensions* extensions = state.get<GL2Extensions>();
|
||||
|
||||
// select the internalFormat required for the texture.
|
||||
bool compressed_image = isCompressedInternalFormat((GLenum)image->getPixelFormat());
|
||||
@@ -2678,9 +2672,9 @@ bool Texture::isHardwareMipmapGenerationEnabled(const State& state) const
|
||||
if (_useHardwareMipMapGeneration)
|
||||
{
|
||||
unsigned int contextID = state.getContextID();
|
||||
const Extensions* extensions = getExtensions(contextID,true);
|
||||
const GL2Extensions* extensions = state.get<GL2Extensions>();
|
||||
|
||||
if (extensions->isGenerateMipMapSupported())
|
||||
if (extensions->isGenerateMipMapSupported)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -2705,11 +2699,12 @@ Texture::GenerateMipmapMode Texture::mipmapBeforeTexImage(const State& state, bo
|
||||
#else
|
||||
|
||||
FBOExtensions* fbo_ext = FBOExtensions::instance(state.getContextID(),true);
|
||||
const GL2Extensions* tex_ext = state.get<GL2Extensions>();
|
||||
bool useGenerateMipMap = fbo_ext->isSupported() && fbo_ext->glGenerateMipmap;
|
||||
|
||||
if (useGenerateMipMap)
|
||||
{
|
||||
if (Texture::getExtensions(state.getContextID(),true)->getPreferGenerateMipmapSGISForPowerOfTwo())
|
||||
if (tex_ext->preferGenerateMipmapSGISForPowerOfTwo)
|
||||
{
|
||||
int width = getTextureWidth();
|
||||
int height = getTextureHeight();
|
||||
@@ -2823,6 +2818,7 @@ void Texture::releaseGLObjects(State* state) const
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
Texture::Extensions* Texture::getExtensions(unsigned int contextID,bool createIfNotInitalized)
|
||||
{
|
||||
if (!s_extensions[contextID] && createIfNotInitalized) s_extensions[contextID] = new Extensions(contextID);
|
||||
@@ -2960,6 +2956,6 @@ Texture::Extensions::Extensions(unsigned int contextID)
|
||||
|
||||
OSG_DEBUG<<"Texture::Extensions::Extensionts() _isTextureStorageEnabled = "<<_isTextureStorageEnabled<<std::endl;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
@@ -277,11 +277,8 @@ void Texture1D::applyTexImage1D(GLenum target, Image* image, State& state, GLsiz
|
||||
if (!image || !image->data())
|
||||
return;
|
||||
|
||||
// get the contextID (user defined ID of 0 upwards) for the
|
||||
// current OpenGL context.
|
||||
const unsigned int contextID = state.getContextID();
|
||||
const Extensions* extensions = getExtensions(contextID,true);
|
||||
|
||||
// get extension object
|
||||
const GL2Extensions* extensions = state.get<GL2Extensions>();
|
||||
|
||||
// compute the internal texture format, this set the _internalFormat to an appropriate value.
|
||||
computeInternalFormat();
|
||||
@@ -290,10 +287,10 @@ 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(_min_filter) || 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());
|
||||
image->ensureValidSizeForTexturing(extensions->maxTextureSize);
|
||||
}
|
||||
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT,image->getPacking());
|
||||
|
||||
@@ -225,10 +225,10 @@ void Texture2DArray::apply(State& state) const
|
||||
ElapsedTime elapsedTime(&(tom->getApplyTime()));
|
||||
tom->getNumberApplied()++;
|
||||
|
||||
const Extensions* extensions = getExtensions(contextID,true);
|
||||
const GL2Extensions* extensions = state.get<GL2Extensions>();
|
||||
|
||||
// if not supported, then return
|
||||
if (!extensions->isTexture2DArraySupported() || !extensions->isTexture3DSupported())
|
||||
if (!extensions->isTexture2DArraySupported || !extensions->isTexture3DSupported)
|
||||
{
|
||||
OSG_WARN<<"Warning: Texture2DArray::apply(..) failed, 2D texture arrays are not support by OpenGL driver."<<std::endl;
|
||||
return;
|
||||
@@ -367,10 +367,10 @@ void Texture2DArray::apply(State& state) const
|
||||
}
|
||||
}
|
||||
|
||||
const Texture::Extensions* texExtensions = Texture::getExtensions(contextID,true);
|
||||
const GL2Extensions* extensions = state.get<GL2Extensions>();
|
||||
// source images have no mipmamps but we could generate them...
|
||||
if( _min_filter != LINEAR && _min_filter != NEAREST && !_images[0]->isMipmap() &&
|
||||
_useHardwareMipMapGeneration && texExtensions->isGenerateMipMapSupported() )
|
||||
_useHardwareMipMapGeneration && extensions->isGenerateMipMapSupported )
|
||||
{
|
||||
_numMipmapLevels = Image::computeNumberOfMipmapLevels( _textureWidth, _textureHeight );
|
||||
generateMipmap( state );
|
||||
@@ -434,9 +434,7 @@ void Texture2DArray::applyTexImage2DArray_subload(State& state, Image* image, GL
|
||||
|
||||
// get the contextID (user defined ID of 0 upwards) for the
|
||||
// current OpenGL context.
|
||||
const unsigned int contextID = state.getContextID();
|
||||
const Extensions* extensions = getExtensions(contextID,true);
|
||||
const Texture::Extensions* texExtensions = Texture::getExtensions(contextID,true);
|
||||
const GL2Extensions* extensions = state.get<GL2Extensions>();
|
||||
GLenum target = GL_TEXTURE_2D_ARRAY_EXT;
|
||||
|
||||
// compute the internal texture format, this set the _internalFormat to an appropriate value.
|
||||
@@ -447,7 +445,7 @@ void Texture2DArray::applyTexImage2DArray_subload(State& state, Image* image, GL
|
||||
bool compressed_image = isCompressedInternalFormat((GLenum)image->getPixelFormat());
|
||||
|
||||
// if the required layer is exceeds the maximum allowed layer sizes
|
||||
if (indepth > extensions->maxLayerCount())
|
||||
if (indepth > extensions->maxLayerCount)
|
||||
{
|
||||
// we give a warning and do nothing
|
||||
OSG_WARN<<"Warning: Texture2DArray::applyTexImage2DArray_subload(..) the given layer number exceeds the maximum number of supported layers."<<std::endl;
|
||||
@@ -455,10 +453,10 @@ void Texture2DArray::applyTexImage2DArray_subload(State& state, Image* image, GL
|
||||
}
|
||||
|
||||
//Rescale if resize hint is set or NPOT not supported or dimensions exceed max size
|
||||
if( _resizeNonPowerOfTwoHint || !texExtensions->isNonPowerOfTwoTextureSupported(_min_filter)
|
||||
|| inwidth > extensions->max2DSize()
|
||||
|| inheight > extensions->max2DSize())
|
||||
image->ensureValidSizeForTexturing(extensions->max2DSize());
|
||||
if( _resizeNonPowerOfTwoHint || !extensions->isNonPowerOfTwoTextureSupported(_min_filter)
|
||||
|| inwidth > extensions->max2DSize
|
||||
|| inheight > extensions->max2DSize)
|
||||
image->ensureValidSizeForTexturing(extensions->max2DSize);
|
||||
|
||||
// image size or format has changed, this is not allowed, hence return
|
||||
if (image->s()!=inwidth ||
|
||||
@@ -475,7 +473,7 @@ void Texture2DArray::applyTexImage2DArray_subload(State& state, Image* image, GL
|
||||
#endif
|
||||
|
||||
bool useHardwareMipmapGeneration =
|
||||
!image->isMipmap() && _useHardwareMipMapGeneration && texExtensions->isGenerateMipMapSupported();
|
||||
!image->isMipmap() && _useHardwareMipMapGeneration && extensions->isGenerateMipMapSupported;
|
||||
|
||||
// if no special mipmapping is required, then
|
||||
if( _min_filter == LINEAR || _min_filter == NEAREST || useHardwareMipmapGeneration )
|
||||
@@ -584,7 +582,7 @@ void Texture2DArray::applyTexImage2DArray_subload(State& state, Image* image, GL
|
||||
void Texture2DArray::copyTexSubImage2DArray(State& state, int xoffset, int yoffset, int zoffset, int x, int y, int width, int height )
|
||||
{
|
||||
const unsigned int contextID = state.getContextID();
|
||||
const Extensions* extensions = getExtensions(contextID,true);
|
||||
const GL2Extensions* extensions = state.get<GL2Extensions>();
|
||||
|
||||
// get the texture object for the current contextID.
|
||||
TextureObject* textureObject = getTextureObject(contextID);
|
||||
@@ -616,7 +614,7 @@ void Texture2DArray::allocateMipmap(State& state) const
|
||||
|
||||
if (textureObject && _textureWidth != 0 && _textureHeight != 0 && _textureDepth != 0)
|
||||
{
|
||||
const Extensions* extensions = getExtensions(contextID,true);
|
||||
const GL2Extensions* extensions = state.get<GL2Extensions>();
|
||||
|
||||
int safeSourceFormat = _sourceFormat ? _sourceFormat : _internalFormat;
|
||||
|
||||
@@ -674,133 +672,3 @@ void Texture2DArray::allocateMipmap(State& state) const
|
||||
state.haveAppliedTextureAttribute(state.getActiveTextureUnit(), this);
|
||||
}
|
||||
}
|
||||
|
||||
typedef buffered_value< ref_ptr<Texture2DArray::Extensions> > BufferedExtensions;
|
||||
static BufferedExtensions s_extensions;
|
||||
|
||||
Texture2DArray::Extensions* Texture2DArray::getExtensions(unsigned int contextID,bool createIfNotInitalized)
|
||||
{
|
||||
if (!s_extensions[contextID] && createIfNotInitalized) s_extensions[contextID] = new Extensions(contextID);
|
||||
return s_extensions[contextID].get();
|
||||
}
|
||||
|
||||
void Texture2DArray::setExtensions(unsigned int contextID,Extensions* extensions)
|
||||
{
|
||||
s_extensions[contextID] = extensions;
|
||||
}
|
||||
|
||||
Texture2DArray::Extensions::Extensions(unsigned int contextID)
|
||||
{
|
||||
setupGLExtensions(contextID);
|
||||
}
|
||||
|
||||
Texture2DArray::Extensions::Extensions(const Extensions& rhs):
|
||||
Referenced()
|
||||
{
|
||||
_isTexture3DSupported = rhs._isTexture3DSupported;
|
||||
_isTexture2DArraySupported = rhs._isTexture2DArraySupported;
|
||||
|
||||
_max2DSize = rhs._max2DSize;
|
||||
_maxLayerCount = rhs._maxLayerCount;
|
||||
|
||||
_glTexImage3D = rhs._glTexImage3D;
|
||||
_glTexSubImage3D = rhs._glTexSubImage3D;
|
||||
_glCopyTexSubImage3D = rhs._glCopyTexSubImage3D;
|
||||
_glCompressedTexImage3D = rhs._glCompressedTexImage3D;
|
||||
_glCompressedTexSubImage3D = rhs._glCompressedTexSubImage3D;;
|
||||
}
|
||||
|
||||
void Texture2DArray::Extensions::lowestCommonDenominator(const Extensions& rhs)
|
||||
{
|
||||
if (!rhs._isTexture3DSupported) _isTexture3DSupported = false;
|
||||
if (!rhs._isTexture2DArraySupported) _isTexture2DArraySupported = false;
|
||||
if (rhs._max2DSize<_max2DSize) _max2DSize = rhs._max2DSize;
|
||||
if (rhs._maxLayerCount<_maxLayerCount) _maxLayerCount = rhs._maxLayerCount;
|
||||
|
||||
if (!rhs._glTexImage3D) _glTexImage3D = 0;
|
||||
if (!rhs._glTexSubImage3D) _glTexSubImage3D = 0;
|
||||
if (!rhs._glCompressedTexImage3D) _glTexImage3D = 0;
|
||||
if (!rhs._glCompressedTexSubImage3D) _glTexSubImage3D = 0;
|
||||
if (!rhs._glCopyTexSubImage3D) _glCopyTexSubImage3D = 0;
|
||||
}
|
||||
|
||||
void Texture2DArray::Extensions::setupGLExtensions(unsigned int contextID)
|
||||
{
|
||||
_isTexture3DSupported = OSG_GL3_FEATURES ||
|
||||
isGLExtensionSupported(contextID,"GL_EXT_texture3D") ||
|
||||
strncmp((const char*)glGetString(GL_VERSION),"1.2",3)>=0;
|
||||
|
||||
_isTexture2DArraySupported = OSG_GL3_FEATURES || isGLExtensionSupported(contextID,"GL_EXT_texture_array");
|
||||
|
||||
_max2DSize = 0;
|
||||
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &_max2DSize);
|
||||
_maxLayerCount = 0;
|
||||
glGetIntegerv(GL_MAX_ARRAY_TEXTURE_LAYERS_EXT, &_maxLayerCount);
|
||||
|
||||
setGLExtensionFuncPtr(_glTexImage3D, "glTexImage3D","glTexImage3DEXT");
|
||||
setGLExtensionFuncPtr(_glTexSubImage3D, "glTexSubImage3D","glTexSubImage3DEXT");
|
||||
setGLExtensionFuncPtr(_glCompressedTexImage3D, "glCompressedTexImage3D","glCompressedTexImage3DARB");
|
||||
setGLExtensionFuncPtr(_glCompressedTexSubImage3D, "glCompressedTexSubImage3D","glCompressedTexSubImage3DARB");
|
||||
setGLExtensionFuncPtr(_glCopyTexSubImage3D, "glCopyTexSubImage3D","glCopyTexSubImage3DEXT");
|
||||
}
|
||||
|
||||
void Texture2DArray::Extensions::glTexImage3D( GLenum target, GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels) const
|
||||
{
|
||||
if (_glTexImage3D)
|
||||
{
|
||||
_glTexImage3D( target, level, internalFormat, width, height, depth, border, format, type, pixels);
|
||||
}
|
||||
else
|
||||
{
|
||||
OSG_WARN<<"Error: glTexImage3D not supported by OpenGL driver"<<std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void Texture2DArray::Extensions::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
|
||||
{
|
||||
if (_glTexSubImage3D)
|
||||
{
|
||||
_glTexSubImage3D( target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels);
|
||||
}
|
||||
else
|
||||
{
|
||||
OSG_WARN<<"Error: glTexSubImage3D not supported by OpenGL driver"<<std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void Texture2DArray::Extensions::glCompressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data) const
|
||||
{
|
||||
if (_glCompressedTexImage3D)
|
||||
{
|
||||
_glCompressedTexImage3D(target, level, internalformat, width, height, depth, border, imageSize, data);
|
||||
}
|
||||
else
|
||||
{
|
||||
OSG_WARN<<"Error: glCompressedTexImage3D not supported by OpenGL driver"<<std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void Texture2DArray::Extensions::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
|
||||
{
|
||||
if (_glCompressedTexSubImage3D)
|
||||
{
|
||||
_glCompressedTexSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data);
|
||||
}
|
||||
else
|
||||
{
|
||||
OSG_WARN<<"Error: glCompressedTexImage2D not supported by OpenGL driver"<<std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void Texture2DArray::Extensions::glCopyTexSubImage3D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height ) const
|
||||
{
|
||||
if (_glCopyTexSubImage3D)
|
||||
{
|
||||
_glCopyTexSubImage3D(target, level, xoffset, yoffset, zoffset, x, y, width, height);
|
||||
}
|
||||
else
|
||||
{
|
||||
OSG_WARN<<"Error: glCopyTexSubImage3D not supported by OpenGL driver"<<std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -86,8 +86,8 @@ void Texture2DMultisample::apply(State& state) const
|
||||
{
|
||||
// current OpenGL context.
|
||||
const unsigned int contextID = state.getContextID();
|
||||
const Extensions* extensions = getExtensions(contextID,true);
|
||||
if (!extensions->isTextureMultisampledSupported())
|
||||
const GL2Extensions* extensions = state.get<GL2Extensions>();
|
||||
if (!extensions->isTextureMultisampledSupported)
|
||||
{
|
||||
OSG_INFO<<"Texture2DMultisample not supoorted."<<std::endl;
|
||||
return;
|
||||
|
||||
@@ -52,7 +52,7 @@ Texture3D::Texture3D(const Texture3D& text,const CopyOp& copyop):
|
||||
}
|
||||
|
||||
Texture3D::~Texture3D()
|
||||
{
|
||||
{
|
||||
setImage(NULL);
|
||||
}
|
||||
|
||||
@@ -141,13 +141,11 @@ void Texture3D::setImage(Image* image)
|
||||
|
||||
void Texture3D::computeRequiredTextureDimensions(State& state, const osg::Image& image,GLsizei& inwidth, GLsizei& inheight,GLsizei& indepth, GLsizei& numMipmapLevels) const
|
||||
{
|
||||
const unsigned int contextID = state.getContextID();
|
||||
const Extensions* extensions = getExtensions(contextID,true);
|
||||
const Texture::Extensions* texExtensions = Texture::getExtensions(contextID,true);
|
||||
const GL2Extensions* extensions = state.get<GL2Extensions>();
|
||||
|
||||
int width,height,depth;
|
||||
|
||||
if( !_resizeNonPowerOfTwoHint && texExtensions->isNonPowerOfTwoTextureSupported(_min_filter) )
|
||||
if( !_resizeNonPowerOfTwoHint && extensions->isNonPowerOfTwoTextureSupported(_min_filter) )
|
||||
{
|
||||
width = image.s();
|
||||
height = image.t();
|
||||
@@ -161,15 +159,15 @@ void Texture3D::computeRequiredTextureDimensions(State& state, const osg::Image&
|
||||
}
|
||||
|
||||
// cap the size to what the graphics hardware can handle.
|
||||
if (width>extensions->maxTexture3DSize()) width = extensions->maxTexture3DSize();
|
||||
if (height>extensions->maxTexture3DSize()) height = extensions->maxTexture3DSize();
|
||||
if (depth>extensions->maxTexture3DSize()) depth = extensions->maxTexture3DSize();
|
||||
if (width>extensions->maxTexture3DSize) width = extensions->maxTexture3DSize;
|
||||
if (height>extensions->maxTexture3DSize) height = extensions->maxTexture3DSize;
|
||||
if (depth>extensions->maxTexture3DSize) depth = extensions->maxTexture3DSize;
|
||||
|
||||
inwidth = width;
|
||||
inheight = height;
|
||||
indepth = depth;
|
||||
|
||||
bool useHardwareMipMapGeneration = !image.isMipmap() && _useHardwareMipMapGeneration && texExtensions->isGenerateMipMapSupported();
|
||||
bool useHardwareMipMapGeneration = !image.isMipmap() && _useHardwareMipMapGeneration && extensions->isGenerateMipMapSupported;
|
||||
|
||||
if( _min_filter == LINEAR || _min_filter == NEAREST || useHardwareMipMapGeneration )
|
||||
{
|
||||
@@ -210,9 +208,9 @@ void Texture3D::apply(State& state) const
|
||||
ElapsedTime elapsedTime(&(tom->getApplyTime()));
|
||||
tom->getNumberApplied()++;
|
||||
|
||||
const Extensions* extensions = getExtensions(contextID,true);
|
||||
const GL2Extensions* extensions = state.get<GL2Extensions>();
|
||||
|
||||
if (!extensions->isTexture3DSupported())
|
||||
if (!extensions->isTexture3DSupported)
|
||||
{
|
||||
OSG_WARN<<"Warning: Texture3D::apply(..) failed, 3D texturing is not support by OpenGL driver."<<std::endl;
|
||||
return;
|
||||
@@ -367,8 +365,7 @@ void Texture3D::applyTexImage3D(GLenum target, Image* image, State& state, GLsiz
|
||||
// get the contextID (user defined ID of 0 upwards) for the
|
||||
// current OpenGL context.
|
||||
const unsigned int contextID = state.getContextID();
|
||||
const Extensions* extensions = getExtensions(contextID,true);
|
||||
const Texture::Extensions* texExtensions = Texture::getExtensions(contextID,true);
|
||||
const GL2Extensions* extensions = GL2Extensions::Get(contextID,true);
|
||||
|
||||
// compute the internal texture format, this set the _internalFormat to an appropriate value.
|
||||
computeInternalFormat();
|
||||
@@ -384,18 +381,18 @@ 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(_min_filter)
|
||||
|| inwidth > extensions->maxTexture3DSize()
|
||||
|| inheight > extensions->maxTexture3DSize()
|
||||
|| indepth > extensions->maxTexture3DSize() )
|
||||
image->ensureValidSizeForTexturing(extensions->maxTexture3DSize());
|
||||
if( _resizeNonPowerOfTwoHint || !extensions->isNonPowerOfTwoTextureSupported(_min_filter)
|
||||
|| inwidth > extensions->maxTexture3DSize
|
||||
|| inheight > extensions->maxTexture3DSize
|
||||
|| indepth > extensions->maxTexture3DSize )
|
||||
image->ensureValidSizeForTexturing(extensions->maxTexture3DSize);
|
||||
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT,image->getPacking());
|
||||
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE)
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH,image->getRowLength());
|
||||
#endif
|
||||
|
||||
bool useHardwareMipMapGeneration = !image->isMipmap() && _useHardwareMipMapGeneration && texExtensions->isGenerateMipMapSupported();
|
||||
bool useHardwareMipMapGeneration = !image->isMipmap() && _useHardwareMipMapGeneration && extensions->isGenerateMipMapSupported;
|
||||
|
||||
if( _min_filter == LINEAR || _min_filter == NEAREST || useHardwareMipMapGeneration )
|
||||
{
|
||||
@@ -489,7 +486,7 @@ void Texture3D::applyTexImage3D(GLenum target, Image* image, State& state, GLsiz
|
||||
void Texture3D::copyTexSubImage3D(State& state, int xoffset, int yoffset, int zoffset, int x, int y, int width, int height )
|
||||
{
|
||||
const unsigned int contextID = state.getContextID();
|
||||
const Extensions* extensions = getExtensions(contextID,true);
|
||||
const GL2Extensions* extensions = state.get<GL2Extensions>();
|
||||
|
||||
// get the texture object for the current contextID.
|
||||
TextureObject* textureObject = getTextureObject(contextID);
|
||||
@@ -523,7 +520,7 @@ void Texture3D::allocateMipmap(State& state) const
|
||||
|
||||
if (textureObject && _textureWidth != 0 && _textureHeight != 0 && _textureDepth != 0)
|
||||
{
|
||||
const Extensions* extensions = getExtensions(contextID,true);
|
||||
const GL2Extensions* extensions = state.get<GL2Extensions>();
|
||||
|
||||
// bind texture
|
||||
textureObject->bind();
|
||||
@@ -563,6 +560,7 @@ void Texture3D::allocateMipmap(State& state) const
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
typedef buffered_value< ref_ptr<Texture3D::Extensions> > BufferedExtensions;
|
||||
static BufferedExtensions s_extensions;
|
||||
|
||||
@@ -630,3 +628,4 @@ void Texture3D::Extensions::setupGLExtensions(unsigned int contextID)
|
||||
setGLExtensionFuncPtr(glCopyTexSubImage3D,"glCopyTexSubImage3D","glCopyTexSubImage3DEXT");
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -106,7 +106,7 @@ void TextureBuffer::apply(State& state) const
|
||||
|
||||
TextureObject* textureObject = getTextureObject(contextID);
|
||||
TextureBufferObject* textureBufferObject = _textureBufferObjects[contextID].get();
|
||||
|
||||
|
||||
|
||||
if (textureObject)
|
||||
{
|
||||
@@ -118,11 +118,11 @@ void TextureBuffer::apply(State& state) const
|
||||
textureBufferObject->unbindBuffer(GL_TEXTURE_BUFFER_ARB);
|
||||
_modifiedCount[contextID] = _image->getModifiedCount();
|
||||
}
|
||||
textureObject->bind();
|
||||
|
||||
textureObject->bind();
|
||||
|
||||
if( getTextureParameterDirty(contextID) )
|
||||
{
|
||||
const Extensions* extensions = Texture::getExtensions(contextID,true);
|
||||
const GL2Extensions* extensions = state.get<GL2Extensions>();
|
||||
if (extensions->isBindImageTextureSupported() && _imageAttachment.access!=0)
|
||||
{
|
||||
extensions->glBindImageTexture(
|
||||
@@ -138,11 +138,11 @@ void TextureBuffer::apply(State& state) const
|
||||
textureObject = generateTextureObject(this, contextID,GL_TEXTURE_BUFFER_ARB);
|
||||
_textureObjectBuffer[contextID] = textureObject;
|
||||
textureObject->bind();
|
||||
|
||||
|
||||
textureBufferObject = new TextureBufferObject(contextID,_usageHint);
|
||||
_textureBufferObjects[contextID] = textureBufferObject;
|
||||
|
||||
const Extensions* extensions = Texture::getExtensions(contextID,true);
|
||||
|
||||
const GL2Extensions* extensions = state.get<GL2Extensions>();
|
||||
if (extensions->isBindImageTextureSupported() && _imageAttachment.access!=0)
|
||||
{
|
||||
extensions->glBindImageTexture(
|
||||
@@ -151,17 +151,17 @@ void TextureBuffer::apply(State& state) const
|
||||
_imageAttachment.format!=0 ? _imageAttachment.format : _internalFormat);
|
||||
}
|
||||
getTextureParameterDirty(state.getContextID()) = false;
|
||||
|
||||
|
||||
computeInternalFormat();
|
||||
_textureWidth = _image->s();
|
||||
textureBufferObject->bindBuffer(GL_TEXTURE_BUFFER_ARB);
|
||||
textureBufferObject->bufferData( _image.get() );
|
||||
textureObject->setAllocated(true);
|
||||
textureBufferObject->unbindBuffer(GL_TEXTURE_BUFFER_ARB);
|
||||
|
||||
|
||||
textureObject->bind();
|
||||
textureBufferObject->texBuffer(_internalFormat);
|
||||
|
||||
|
||||
_modifiedCount[contextID] = _image->getModifiedCount();
|
||||
}
|
||||
else
|
||||
@@ -176,14 +176,14 @@ void TextureBuffer::apply(State& state) const
|
||||
|
||||
void TextureBuffer::bindBufferAs( unsigned int contextID, GLuint target )
|
||||
{
|
||||
TextureBufferObject* textureBufferObject = _textureBufferObjects[contextID].get();
|
||||
TextureBufferObject* textureBufferObject = _textureBufferObjects[contextID].get();
|
||||
textureBufferObject->bindBuffer(target);
|
||||
|
||||
|
||||
}
|
||||
|
||||
void TextureBuffer::unbindBufferAs( unsigned int contextID, GLuint target )
|
||||
{
|
||||
TextureBufferObject* textureBufferObject = _textureBufferObjects[contextID].get();
|
||||
TextureBufferObject* textureBufferObject = _textureBufferObjects[contextID].get();
|
||||
textureBufferObject->unbindBuffer(target);
|
||||
}
|
||||
|
||||
|
||||
@@ -308,7 +308,7 @@ void TextureRectangle::applyTexImage_load(GLenum target, Image* image, State& st
|
||||
// get the contextID (user defined ID of 0 upwards) for the
|
||||
// current OpenGL context.
|
||||
const unsigned int contextID = state.getContextID();
|
||||
const Extensions* extensions = getExtensions(contextID,true);
|
||||
const GL2Extensions* extensions = state.get<GL2Extensions>();
|
||||
|
||||
// update the modified count to show that it is upto date.
|
||||
getModifiedCount(contextID) = image->getModifiedCount();
|
||||
@@ -321,7 +321,7 @@ void TextureRectangle::applyTexImage_load(GLenum target, Image* image, State& st
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH,image->getRowLength());
|
||||
#endif
|
||||
|
||||
bool useClientStorage = extensions->isClientStorageSupported() && getClientStorageHint();
|
||||
bool useClientStorage = extensions->isClientStorageSupported && getClientStorageHint();
|
||||
if (useClientStorage)
|
||||
{
|
||||
glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE,GL_TRUE);
|
||||
@@ -390,7 +390,7 @@ void TextureRectangle::applyTexImage_subload(GLenum target, Image* image, State&
|
||||
// get the contextID (user defined ID of 0 upwards) for the
|
||||
// current OpenGL context.
|
||||
const unsigned int contextID = state.getContextID();
|
||||
const Extensions* extensions = getExtensions(contextID,true);
|
||||
const GL2Extensions* extensions = state.get<GL2Extensions>();
|
||||
|
||||
|
||||
// update the modified count to show that it is upto date.
|
||||
|
||||
@@ -147,8 +147,8 @@ void GlyphTexture::apply(osg::State& state) const
|
||||
}
|
||||
|
||||
|
||||
const Extensions* extensions = getExtensions(contextID,true);
|
||||
bool generateMipMapSupported = extensions->isGenerateMipMapSupported();
|
||||
const osg::GL2Extensions* extensions = state.get<osg::GL2Extensions>();
|
||||
bool generateMipMapSupported = extensions->isGenerateMipMapSupported;
|
||||
|
||||
// get the texture object for the current contextID.
|
||||
TextureObject* textureObject = getTextureObject(contextID);
|
||||
|
||||
Reference in New Issue
Block a user