diff --git a/examples/osgvertexprogram/osgvertexprogram.cpp b/examples/osgvertexprogram/osgvertexprogram.cpp index a8d211e96..ed5e1b7e2 100644 --- a/examples/osgvertexprogram/osgvertexprogram.cpp +++ b/examples/osgvertexprogram/osgvertexprogram.cpp @@ -404,10 +404,10 @@ int main(int argc, char *argv[]) ++itr) { unsigned int contextID = (*itr)->getState()->getContextID(); - osg::VertexProgram::Extensions* vpExt = osg::VertexProgram::getExtensions(contextID,false); + osg::GL2Extensions* vpExt = osg::GL2Extensions::Get(contextID,false); if (vpExt) { - if (!vpExt->isVertexProgramSupported()) + if (!vpExt->isVertexProgramSupported) { std::cout<<"Warning: ARB_vertex_program not supported by OpenGL drivers, unable to run application."< lock(s_mutex_deletedFragmentProgramObjectCache); - const Extensions* extensions = getExtensions(contextID,true); + const GL2Extensions* extensions = GL2Extensions::Get(contextID,true); FragmentProgramObjectList& vpol = s_deletedFragmentProgramObjectCache[contextID]; @@ -127,10 +127,9 @@ void FragmentProgram::apply(State& state) const { #ifdef OSG_GL_FIXED_FUNCTION_AVAILABLE - const unsigned int contextID = state.getContextID(); - const Extensions* extensions = getExtensions(contextID,true); + const GL2Extensions* extensions = state.get(); - if (!extensions->isFragmentProgramSupported()) + if (!extensions->isFragmentProgramSupported) return; @@ -213,118 +212,3 @@ void FragmentProgram::releaseGLObjects(State* state) const } } } - - -typedef buffered_value< ref_ptr > BufferedExtensions; -static BufferedExtensions s_extensions; - -FragmentProgram::Extensions* FragmentProgram::getExtensions(unsigned int contextID,bool createIfNotInitalized) -{ - if (!s_extensions[contextID] && createIfNotInitalized) s_extensions[contextID] = new Extensions(contextID); - return s_extensions[contextID].get(); -} - -void FragmentProgram::setExtensions(unsigned int contextID,Extensions* extensions) -{ - s_extensions[contextID] = extensions; -} - -FragmentProgram::Extensions::Extensions(unsigned int contextID) -{ - setupGLExtensions(contextID); -} - -FragmentProgram::Extensions::Extensions(const Extensions& rhs): - Referenced() -{ - _isFragmentProgramSupported = rhs._isFragmentProgramSupported; - _glBindProgram = rhs._glBindProgram; - _glGenPrograms = rhs._glGenPrograms; - _glDeletePrograms = rhs._glDeletePrograms; - _glProgramString = rhs._glProgramString; - _glProgramLocalParameter4fv = rhs._glProgramLocalParameter4fv; -} - - -void FragmentProgram::Extensions::lowestCommonDenominator(const Extensions& rhs) -{ - if (!rhs._isFragmentProgramSupported) _isFragmentProgramSupported = false; - - if (!rhs._glBindProgram) _glBindProgram = 0; - if (!rhs._glGenPrograms) _glGenPrograms = 0; - if (!rhs._glDeletePrograms) _glDeletePrograms = 0; - if (!rhs._glProgramString) _glProgramString = 0; - if (!rhs._glProgramLocalParameter4fv) _glProgramLocalParameter4fv = 0; - -} - -void FragmentProgram::Extensions::setupGLExtensions(unsigned int contextID) -{ - _isFragmentProgramSupported = isGLExtensionSupported(contextID,"GL_ARB_fragment_program"); - - setGLExtensionFuncPtr(_glBindProgram, "glBindProgramARB"); - setGLExtensionFuncPtr(_glGenPrograms, "glGenProgramsARB"); - setGLExtensionFuncPtr(_glDeletePrograms, "glDeleteProgramsARB"); - setGLExtensionFuncPtr(_glProgramString, "glProgramStringARB"); - setGLExtensionFuncPtr(_glProgramLocalParameter4fv, "glProgramLocalParameter4fvARB"); -} - -void FragmentProgram::Extensions::glBindProgram(GLenum target, GLuint id) const -{ - if (_glBindProgram) - { - _glBindProgram(target,id); - } - else - { - OSG_WARN<<"Error: glBindProgram not supported by OpenGL driver"< lock(s_mutex_deletedVertexProgramObjectCache); - const Extensions* extensions = getExtensions(contextID,true); + const GL2Extensions* extensions = GL2Extensions::Get(contextID,true); VertexProgramObjectList& vpol = s_deletedVertexProgramObjectCache[contextID]; @@ -127,10 +127,9 @@ void VertexProgram::apply(State& state) const { #ifdef OSG_GL_FIXED_FUNCTION_AVAILABLE - const unsigned int contextID = state.getContextID(); - const Extensions* extensions = getExtensions(contextID,true); + const GL2Extensions* extensions = state.get(); - if (!extensions->isVertexProgramSupported()) + if (!extensions->isVertexProgramSupported) return; @@ -213,118 +212,3 @@ void VertexProgram::releaseGLObjects(State* state) const } } } - - -typedef buffered_value< ref_ptr > BufferedExtensions; -static BufferedExtensions s_extensions; - -VertexProgram::Extensions* VertexProgram::getExtensions(unsigned int contextID,bool createIfNotInitalized) -{ - if (!s_extensions[contextID] && createIfNotInitalized) s_extensions[contextID] = new Extensions(contextID); - return s_extensions[contextID].get(); -} - -void VertexProgram::setExtensions(unsigned int contextID,Extensions* extensions) -{ - s_extensions[contextID] = extensions; -} - -VertexProgram::Extensions::Extensions(unsigned int contextID) -{ - setupGLExtensions(contextID); -} - -VertexProgram::Extensions::Extensions(const Extensions& rhs): - Referenced() -{ - _isVertexProgramSupported = rhs._isVertexProgramSupported; - _glBindProgram = rhs._glBindProgram; - _glGenPrograms = rhs._glGenPrograms; - _glDeletePrograms = rhs._glDeletePrograms; - _glProgramString = rhs._glProgramString; - _glProgramLocalParameter4fv = rhs._glProgramLocalParameter4fv; -} - - -void VertexProgram::Extensions::lowestCommonDenominator(const Extensions& rhs) -{ - if (!rhs._isVertexProgramSupported) _isVertexProgramSupported = false; - - if (!rhs._glBindProgram) _glBindProgram = 0; - if (!rhs._glGenPrograms) _glGenPrograms = 0; - if (!rhs._glDeletePrograms) _glDeletePrograms = 0; - if (!rhs._glProgramString) _glProgramString = 0; - if (!rhs._glProgramLocalParameter4fv) _glProgramLocalParameter4fv = 0; - -} - -void VertexProgram::Extensions::setupGLExtensions(unsigned int contextID) -{ - _isVertexProgramSupported = isGLExtensionSupported(contextID,"GL_ARB_vertex_program"); - - setGLExtensionFuncPtr(_glBindProgram,"glBindProgramARB"); - setGLExtensionFuncPtr(_glGenPrograms, "glGenProgramsARB"); - setGLExtensionFuncPtr(_glDeletePrograms, "glDeleteProgramsARB"); - setGLExtensionFuncPtr(_glProgramString, "glProgramStringARB"); - setGLExtensionFuncPtr(_glProgramLocalParameter4fv, "glProgramLocalParameter4fvARB"); -} - -void VertexProgram::Extensions::glBindProgram(GLenum target, GLuint id) const -{ - if (_glBindProgram) - { - _glBindProgram(target,id); - } - else - { - OSG_WARN<<"Error: glBindProgram not supported by OpenGL driver"<