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:
@@ -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
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user