Moved TextureCubeMap::Extension functionality into GL2Extensions

git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14576 16af8721-9629-0410-8352-f15c8da7e697
This commit is contained in:
Robert Osfield
2014-12-05 20:05:18 +00:00
parent f634152de0
commit 9b03b3f8ce
5 changed files with 19 additions and 97 deletions

View File

@@ -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);

View File

@@ -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();

View File

@@ -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");

View File

@@ -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<GL2Extensions>();
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<GL2Extensions>();
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<TextureCubeMap::Extensions> > 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;;
}

View File

@@ -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<osg::GL2Extensions>();
return ext ? ext->isCubeMapSupported : false;
}
protected: