diff --git a/include/osg/GL2Extensions b/include/osg/GL2Extensions index bf0f670c6..becb0124b 100644 --- a/include/osg/GL2Extensions +++ b/include/osg/GL2Extensions @@ -596,6 +596,7 @@ class OSG_EXPORT GL2Extensions : public osg::Referenced bool isGpuShaderFp64Supported; bool isShaderAtomicCountersSupported; bool isRectangleSupported; + bool isCubeMapSupported; void (GL_APIENTRY * glBlendEquationSeparate)(GLenum modeRGB, GLenum modeAlpha); void (GL_APIENTRY * glDrawBuffers)(GLsizei n, const GLenum *bufs); diff --git a/include/osg/TextureCubeMap b/include/osg/TextureCubeMap index 99956bfe3..8752ce215 100644 --- a/include/osg/TextureCubeMap +++ b/include/osg/TextureCubeMap @@ -117,49 +117,6 @@ class OSG_EXPORT TextureCubeMap : 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 setCubeMapSupported(bool flag) { _isCubeMapSupported=flag; } - bool isCubeMapSupported() const { return _isCubeMapSupported; } - - protected: - - ~Extensions() {} - - bool _isCubeMapSupported; - - }; - - /** Function to call to get the extension of a specified context. - * If the Extensions 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 ~TextureCubeMap(); diff --git a/src/osg/GL2Extensions.cpp b/src/osg/GL2Extensions.cpp index 035ee6f42..4ca7aa787 100644 --- a/src/osg/GL2Extensions.cpp +++ b/src/osg/GL2Extensions.cpp @@ -76,6 +76,18 @@ GL2Extensions::GL2Extensions(unsigned int contextID) isGpuShaderFp64Supported = osg::isGLExtensionSupported(contextID,"GL_ARB_gpu_shader_fp64"); isShaderAtomicCountersSupported = osg::isGLExtensionSupported(contextID,"GL_ARB_shader_atomic_counters"); + isRectangleSupported = OSG_GL3_FEATURES || + isGLExtensionSupported(contextID,"GL_ARB_texture_rectangle") || + isGLExtensionSupported(contextID,"GL_EXT_texture_rectangle") || + isGLExtensionSupported(contextID,"GL_NV_texture_rectangle"); + + isCubeMapSupported = OSG_GLES2_FEATURES || OSG_GL3_FEATURES || + isGLExtensionSupported(contextID,"GL_ARB_texture_cube_map") || + isGLExtensionSupported(contextID,"GL_EXT_texture_cube_map") || + strncmp((const char*)glGetString(GL_VERSION),"1.3",3)>=0;; + + + isGlslSupported = ( glVersion >= 2.0f ) || ( isShaderObjectsSupported && isVertexShaderSupported && @@ -318,12 +330,6 @@ GL2Extensions::GL2Extensions(unsigned int contextID) isTimerQuerySupported = osg::isGLExtensionSupported(contextID, "GL_EXT_timer_query" ); isARBTimerQuerySupported = osg::isGLExtensionSupported(contextID, "GL_ARB_timer_query"); - isRectangleSupported = OSG_GL3_FEATURES || - isGLExtensionSupported(contextID,"GL_ARB_texture_rectangle") || - isGLExtensionSupported(contextID,"GL_EXT_texture_rectangle") || - isGLExtensionSupported(contextID,"GL_NV_texture_rectangle"); - - setGLExtensionFuncPtr(glFogCoordfv, "glFogCoordfv","glFogCoordfvEXT"); setGLExtensionFuncPtr(glSecondaryColor3ubv, "glSecondaryColor3ubv","glSecondaryColor3ubvEXT"); setGLExtensionFuncPtr(glSecondaryColor3fv, "glSecondaryColor3fv","glSecondaryColor3fvEXT"); diff --git a/src/osg/TextureCubeMap.cpp b/src/osg/TextureCubeMap.cpp index 4ae4c96c0..0d7b4186e 100644 --- a/src/osg/TextureCubeMap.cpp +++ b/src/osg/TextureCubeMap.cpp @@ -203,9 +203,9 @@ void TextureCubeMap::apply(State& state) const ElapsedTime elapsedTime(&(tom->getApplyTime())); tom->getNumberApplied()++; - const Extensions* extensions = getExtensions(contextID,true); + const GL2Extensions* extensions = state.get(); - if (!extensions->isCubeMapSupported()) + if (!extensions->isCubeMapSupported) return; // get the texture object for the current contextID. @@ -366,9 +366,9 @@ void TextureCubeMap::apply(State& state) const void TextureCubeMap::copyTexSubImageCubeMap(State& state, int face, int xoffset, int yoffset, 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(); - if (!extensions->isCubeMapSupported()) + if (!extensions->isCubeMapSupported) return; if (_internalFormat==0) _internalFormat=GL_RGBA; @@ -476,41 +476,3 @@ void TextureCubeMap::allocateMipmap(State& state) const state.haveAppliedTextureAttribute(state.getActiveTextureUnit(), this); } } - -typedef buffered_value< ref_ptr > BufferedExtensions; -static BufferedExtensions s_extensions; - -TextureCubeMap::Extensions* TextureCubeMap::getExtensions(unsigned int contextID,bool createIfNotInitalized) -{ - if (!s_extensions[contextID] && createIfNotInitalized) s_extensions[contextID] = new Extensions(contextID); - return s_extensions[contextID].get(); -} - -void TextureCubeMap::setExtensions(unsigned int contextID,Extensions* extensions) -{ - s_extensions[contextID] = extensions; -} - -TextureCubeMap::Extensions::Extensions(unsigned int contextID) -{ - setupGLExtensions(contextID); -} - -TextureCubeMap::Extensions::Extensions(const Extensions& rhs): - Referenced() -{ - _isCubeMapSupported = rhs._isCubeMapSupported; -} - -void TextureCubeMap::Extensions::lowestCommonDenominator(const Extensions& rhs) -{ - if (!rhs._isCubeMapSupported) _isCubeMapSupported = false; -} - -void TextureCubeMap::Extensions::setupGLExtensions(unsigned int contextID) -{ - _isCubeMapSupported = OSG_GLES2_FEATURES || OSG_GL3_FEATURES || - isGLExtensionSupported(contextID,"GL_ARB_texture_cube_map") || - isGLExtensionSupported(contextID,"GL_EXT_texture_cube_map") || - strncmp((const char*)glGetString(GL_VERSION),"1.3",3)>=0;; -} diff --git a/src/osgFX/SpecularHighlights.cpp b/src/osgFX/SpecularHighlights.cpp index dab091676..aa1c7cbcd 100644 --- a/src/osgFX/SpecularHighlights.cpp +++ b/src/osgFX/SpecularHighlights.cpp @@ -114,12 +114,8 @@ namespace { if (!Technique::validate(state)) return false; - osg::TextureCubeMap::Extensions *ext = - osg::TextureCubeMap::getExtensions(state.getContextID(), true); - if (ext) { - return ext->isCubeMapSupported(); - } - return false; + osg::GL2Extensions *ext = state.get(); + return ext ? ext->isCubeMapSupported : false; } protected: