diff --git a/include/osg/BlendColor b/include/osg/BlendColor index 44f850a02..41d2f506f 100644 --- a/include/osg/BlendColor +++ b/include/osg/BlendColor @@ -70,13 +70,13 @@ class OSG_EXPORT BlendColor : public StateAttribute class OSG_EXPORT Extensions : public osg::Referenced { public: - Extensions(); + Extensions(unsigned int contextID); Extensions(const Extensions& rhs); void lowestCommonDenominator(const Extensions& rhs); - void setupGLExtenions(); + void setupGLExtenions(unsigned int contextID); void setBlendColorSupported(bool flag) { _isBlendColorSupported=flag; } bool isBlendColorSupported() const { return _isBlendColorSupported; } diff --git a/include/osg/BlendEquation b/include/osg/BlendEquation index 6a2d4725a..136e2a59d 100644 --- a/include/osg/BlendEquation +++ b/include/osg/BlendEquation @@ -97,13 +97,13 @@ class OSG_EXPORT BlendEquation : public StateAttribute class OSG_EXPORT Extensions : public osg::Referenced { public: - Extensions(); + Extensions(unsigned int contextID); Extensions(const Extensions& rhs); void lowestCommonDenominator(const Extensions& rhs); - void setupGLExtenions(); + void setupGLExtenions(unsigned int contextID); void setBlendEquationSupported(bool flag) { _isBlendEquationSupported=flag; } bool isBlendEquationSupported() const { return _isBlendEquationSupported; } diff --git a/include/osg/BufferObject b/include/osg/BufferObject index e6694e701..717d591bb 100644 --- a/include/osg/BufferObject +++ b/include/osg/BufferObject @@ -144,13 +144,13 @@ class OSG_EXPORT BufferObject : public Object class OSG_EXPORT Extensions : public osg::Referenced { public: - Extensions(); + Extensions(unsigned int contextID); Extensions(const Extensions& rhs); void lowestCommonDenominator(const Extensions& rhs); - void setupGLExtenions(); + void setupGLExtenions(unsigned int contextID); bool isBufferObjectSupported() const { return _glGenBuffers!=0; } diff --git a/include/osg/Drawable b/include/osg/Drawable index 17e7affbf..905771997 100644 --- a/include/osg/Drawable +++ b/include/osg/Drawable @@ -492,13 +492,13 @@ class OSG_EXPORT Drawable : public Object class OSG_EXPORT Extensions : public osg::Referenced { public: - Extensions(); + Extensions(unsigned int contextID); Extensions(const Extensions& rhs); void lowestCommonDenominator(const Extensions& rhs); - void setupGLExtenions(); + void setupGLExtenions(unsigned int contextID); void setVertexProgramSupported(bool flag) { _isVertexProgramSupported=flag; } bool isVertexProgramSupported() const { return _isVertexProgramSupported; } diff --git a/include/osg/FragmentProgram b/include/osg/FragmentProgram index 35e4b72f4..f7b362673 100644 --- a/include/osg/FragmentProgram +++ b/include/osg/FragmentProgram @@ -231,13 +231,13 @@ class OSG_EXPORT FragmentProgram : public StateAttribute class OSG_EXPORT Extensions : public osg::Referenced { public: - Extensions(); + Extensions(unsigned int contextID); Extensions(const Extensions& rhs); void lowestCommonDenominator(const Extensions& rhs); - void setupGLExtenions(); + void setupGLExtenions(unsigned int contextID); void setFragmentProgramSupported(bool flag) { _isFragmentProgramSupported=flag; } bool isFragmentProgramSupported() const { return _isFragmentProgramSupported; } diff --git a/include/osg/GLExtensions b/include/osg/GLExtensions index 445053b71..8afaf0229 100644 --- a/include/osg/GLExtensions +++ b/include/osg/GLExtensions @@ -37,7 +37,7 @@ namespace osg { * Note: Must only be called within a valid OpenGL context, * undefined behavior may occur otherwise. */ -extern OSG_EXPORT bool isGLExtensionSupported(const char *extension); +extern OSG_EXPORT bool isGLExtensionSupported(unsigned int contextID, const char *extension); /** Return the address of the specified OpenGL function. * Return NULL if function not supported by OpenGL library. @@ -111,7 +111,7 @@ inline void* getGLExtensionFuncPtr(const char *funcName,const char *fallbackFunc * Note: Must only be called within a valid OpenGL context, * undefined behavior may occur otherwise. */ -extern OSG_EXPORT bool isGLUExtensionSupported(const char *extension); +extern OSG_EXPORT bool isGLUExtensionSupported(unsigned int contextID, const char *extension); } diff --git a/include/osg/Multisample b/include/osg/Multisample index f4a45db92..1970d0500 100644 --- a/include/osg/Multisample +++ b/include/osg/Multisample @@ -99,13 +99,13 @@ class OSG_EXPORT Multisample : public StateAttribute class OSG_EXPORT Extensions : public osg::Referenced { public: - Extensions(); + Extensions(unsigned int contextID); Extensions(const Extensions& rhs); void lowestCommonDenominator(const Extensions& rhs); - void setupGLExtenions(); + void setupGLExtenions(unsigned int contextID); void setMultisampleSupported(bool flag) { _isMultisampleSupported=flag; } void setMultisampleFilterHintSupported(bool flag) { _isMultisampleFilterHintSupported=flag; } diff --git a/include/osg/Point b/include/osg/Point index 84d09de1c..c24511eae 100644 --- a/include/osg/Point +++ b/include/osg/Point @@ -83,13 +83,13 @@ class OSG_EXPORT Point : public StateAttribute class OSG_EXPORT Extensions : public osg::Referenced { public: - Extensions(); + Extensions(unsigned int contextID); Extensions(const Extensions& rhs); void lowestCommonDenominator(const Extensions& rhs); - void setupGLExtenions(); + void setupGLExtenions(unsigned int contextID); void setPointParametersSupported(bool flag) { _isPointParametersSupported=flag; } bool isPointParametersSupported() const { return _isPointParametersSupported; } diff --git a/include/osg/Program b/include/osg/Program index 71cc35199..004dedb02 100644 --- a/include/osg/Program +++ b/include/osg/Program @@ -37,12 +37,12 @@ class Shader; class OSG_EXPORT GL2Extensions : public osg::Referenced { public: - GL2Extensions(); + GL2Extensions(unsigned int contextID); GL2Extensions(const GL2Extensions& rhs); void lowestCommonDenominator(const GL2Extensions& rhs); - void setupGL2Extensions(); + void setupGL2Extensions(unsigned int contextID); /** Does the GL driver support OpenGL Shading Language? */ bool isGlslSupported() const; diff --git a/include/osg/Texture b/include/osg/Texture index 71746ffcc..f7274bb69 100644 --- a/include/osg/Texture +++ b/include/osg/Texture @@ -414,13 +414,13 @@ class OSG_EXPORT Texture : public osg::StateAttribute class OSG_EXPORT Extensions : public osg::Referenced { public: - Extensions(); + Extensions(unsigned int contextID); Extensions(const Extensions& rhs); void lowestCommonDenominator(const Extensions& rhs); - void setupGLExtensions(); + void setupGLExtensions(unsigned int contextID); void setMultiTexturingSupported(bool flag) { _isMultiTexturingSupported=flag; } bool isMultiTexturingSupported() const { return _isMultiTexturingSupported; } diff --git a/include/osg/Texture3D b/include/osg/Texture3D index 1a163121f..ee60d3a11 100644 --- a/include/osg/Texture3D +++ b/include/osg/Texture3D @@ -133,13 +133,13 @@ class OSG_EXPORT Texture3D : public Texture class OSG_EXPORT Extensions : public osg::Referenced { public: - Extensions(); + Extensions(unsigned int contextID); Extensions(const Extensions& rhs); void lowestCommonDenominator(const Extensions& rhs); - void setupGLExtenions(); + void setupGLExtenions(unsigned int contextID); void setTexture3DSupported(bool flag) { _isTexture3DSupported=flag; } bool isTexture3DSupported() const { return _isTexture3DSupported; } diff --git a/include/osg/TextureCubeMap b/include/osg/TextureCubeMap index 416c7f04f..22a6d8622 100644 --- a/include/osg/TextureCubeMap +++ b/include/osg/TextureCubeMap @@ -123,13 +123,13 @@ class OSG_EXPORT TextureCubeMap : public Texture class OSG_EXPORT Extensions : public osg::Referenced { public: - Extensions(); + Extensions(unsigned int contextID); Extensions(const Extensions& rhs); void lowestCommonDenominator(const Extensions& rhs); - void setupGLExtenions(); + void setupGLExtenions(unsigned int contextID); void setCubeMapSupported(bool flag) { _isCubeMapSupported=flag; } bool isCubeMapSupported() const { return _isCubeMapSupported; } diff --git a/include/osg/VertexProgram b/include/osg/VertexProgram index 334a02b72..afba34d02 100644 --- a/include/osg/VertexProgram +++ b/include/osg/VertexProgram @@ -234,13 +234,13 @@ class OSG_EXPORT VertexProgram : public StateAttribute class OSG_EXPORT Extensions : public osg::Referenced { public: - Extensions(); + Extensions(unsigned int contextID); Extensions(const Extensions& rhs); void lowestCommonDenominator(const Extensions& rhs); - void setupGLExtenions(); + void setupGLExtenions(unsigned int contextID); void setVertexProgramSupported(bool flag) { _isVertexProgramSupported=flag; } bool isVertexProgramSupported() const { return _isVertexProgramSupported; } diff --git a/runexamples.bat b/runexamples.bat index 90daad65f..e37084497 100644 --- a/runexamples.bat +++ b/runexamples.bat @@ -64,7 +64,7 @@ echo osglight osglight glider.osg echo osglightpoint -osglightpoint +#osglightpoint echo osglogo osglogo diff --git a/src/osg/BlendColor.cpp b/src/osg/BlendColor.cpp index 4ea3b99d9..6be885b15 100644 --- a/src/osg/BlendColor.cpp +++ b/src/osg/BlendColor.cpp @@ -55,7 +55,7 @@ static BufferedExtensions s_extensions; BlendColor::Extensions* BlendColor::getExtensions(unsigned int contextID,bool createIfNotInitalized) { - if (!s_extensions[contextID] && createIfNotInitalized) s_extensions[contextID] = new Extensions; + if (!s_extensions[contextID] && createIfNotInitalized) s_extensions[contextID] = new Extensions(contextID); return s_extensions[contextID].get(); } @@ -65,9 +65,9 @@ void BlendColor::setExtensions(unsigned int contextID,Extensions* extensions) } -BlendColor::Extensions::Extensions() +BlendColor::Extensions::Extensions(unsigned int contextID) { - setupGLExtenions(); + setupGLExtenions(contextID); } BlendColor::Extensions::Extensions(const Extensions& rhs): @@ -82,9 +82,9 @@ void BlendColor::Extensions::lowestCommonDenominator(const Extensions& rhs) if (!rhs._glBlendColor) _glBlendColor = 0; } -void BlendColor::Extensions::setupGLExtenions() +void BlendColor::Extensions::setupGLExtenions(unsigned int contextID) { - _isBlendColorSupported = isGLExtensionSupported("GL_EXT_blend_color") || + _isBlendColorSupported = isGLExtensionSupported(contextID,"GL_EXT_blend_color") || strncmp((const char*)glGetString(GL_VERSION),"1.2",3)>=0; _glBlendColor = getGLExtensionFuncPtr("glBlendColor", "glBlendColorEXT"); diff --git a/src/osg/BlendEquation.cpp b/src/osg/BlendEquation.cpp index ea6dbeabd..2ad2ab072 100644 --- a/src/osg/BlendEquation.cpp +++ b/src/osg/BlendEquation.cpp @@ -58,7 +58,7 @@ static BufferedExtensions s_extensions; BlendEquation::Extensions* BlendEquation::getExtensions(unsigned int contextID,bool createIfNotInitalized) { - if (!s_extensions[contextID] && createIfNotInitalized) s_extensions[contextID] = new Extensions; + if (!s_extensions[contextID] && createIfNotInitalized) s_extensions[contextID] = new Extensions(contextID); return s_extensions[contextID].get(); } @@ -68,9 +68,9 @@ void BlendEquation::setExtensions(unsigned int contextID,Extensions* extensions) } -BlendEquation::Extensions::Extensions() +BlendEquation::Extensions::Extensions(unsigned int contextID) { - setupGLExtenions(); + setupGLExtenions(contextID); } BlendEquation::Extensions::Extensions(const Extensions& rhs): @@ -85,9 +85,9 @@ void BlendEquation::Extensions::lowestCommonDenominator(const Extensions& rhs) if (!rhs._glBlendEquation) _glBlendEquation = 0; } -void BlendEquation::Extensions::setupGLExtenions() +void BlendEquation::Extensions::setupGLExtenions(unsigned int contextID) { - _isBlendEquationSupported = isGLExtensionSupported("GL_EXT_blend_equation") || + _isBlendEquationSupported = isGLExtensionSupported(contextID,"GL_EXT_blend_equation") || strncmp((const char*)glGetString(GL_VERSION),"1.2",3)>=0; _glBlendEquation = getGLExtensionFuncPtr("glBlendEquation", "glBlendEquationEXT"); diff --git a/src/osg/BufferObject.cpp b/src/osg/BufferObject.cpp index 51accb847..f5fc0fca3 100644 --- a/src/osg/BufferObject.cpp +++ b/src/osg/BufferObject.cpp @@ -140,7 +140,7 @@ static BufferedExtensions s_extensions; BufferObject::Extensions* BufferObject::getExtensions(unsigned int contextID,bool createIfNotInitalized) { - if (!s_extensions[contextID] && createIfNotInitalized) s_extensions[contextID] = new BufferObject::Extensions; + if (!s_extensions[contextID] && createIfNotInitalized) s_extensions[contextID] = new BufferObject::Extensions(contextID); return s_extensions[contextID].get(); } @@ -149,9 +149,9 @@ void BufferObject::setExtensions(unsigned int contextID,Extensions* extensions) s_extensions[contextID] = extensions; } -BufferObject::Extensions::Extensions() +BufferObject::Extensions::Extensions(unsigned int contextID) { - setupGLExtenions(); + setupGLExtenions(contextID); } BufferObject::Extensions::Extensions(const Extensions& rhs): @@ -186,7 +186,7 @@ void BufferObject::Extensions::lowestCommonDenominator(const Extensions& rhs) if (!rhs._glGetBufferParameteriv) _glGetBufferPointerv = rhs._glGetBufferPointerv; } -void BufferObject::Extensions::setupGLExtenions() +void BufferObject::Extensions::setupGLExtenions(unsigned int) { _glGenBuffers = ((GenBuffersProc)osg::getGLExtensionFuncPtr("glGenBuffers","glGenBuffersARB")); _glBindBuffer = ((BindBufferProc)osg::getGLExtensionFuncPtr("glBindBuffer","glBindBufferARB")); diff --git a/src/osg/ColorMatrix.cpp b/src/osg/ColorMatrix.cpp index be26ab216..12a34c707 100644 --- a/src/osg/ColorMatrix.cpp +++ b/src/osg/ColorMatrix.cpp @@ -13,6 +13,7 @@ #include #include #include +#include using namespace osg; @@ -25,10 +26,11 @@ ColorMatrix::~ColorMatrix() { } -void ColorMatrix::apply(State&) const +void ColorMatrix::apply(State& state) const { -// std::cout<<"applying matrix"<<_matrix< +#include #include using namespace osg; @@ -34,7 +35,7 @@ Fog::~Fog() { } -void Fog::apply(State&) const +void Fog::apply(State& state) const { glFogi( GL_FOG_MODE, _mode ); glFogf( GL_FOG_DENSITY, _density ); @@ -42,7 +43,7 @@ void Fog::apply(State&) const glFogf( GL_FOG_END, _end ); glFogfv( GL_FOG_COLOR, (GLfloat*)_color.ptr() ); - static bool fogCoordExtensionSuppoted = osg::isGLExtensionSupported("GL_EXT_fog_coord"); + static bool fogCoordExtensionSuppoted = osg::isGLExtensionSupported(state.getContextID(),"GL_EXT_fog_coord"); if (fogCoordExtensionSuppoted) { glFogi(GL_FOG_COORDINATE_SOURCE,_fogCoordinateSource); diff --git a/src/osg/FragmentProgram.cpp b/src/osg/FragmentProgram.cpp index 5e609c87f..71f8b4a54 100644 --- a/src/osg/FragmentProgram.cpp +++ b/src/osg/FragmentProgram.cpp @@ -207,7 +207,7 @@ static BufferedExtensions s_extensions; FragmentProgram::Extensions* FragmentProgram::getExtensions(unsigned int contextID,bool createIfNotInitalized) { - if (!s_extensions[contextID] && createIfNotInitalized) s_extensions[contextID] = new Extensions; + if (!s_extensions[contextID] && createIfNotInitalized) s_extensions[contextID] = new Extensions(contextID); return s_extensions[contextID].get(); } @@ -216,9 +216,9 @@ void FragmentProgram::setExtensions(unsigned int contextID,Extensions* extension s_extensions[contextID] = extensions; } -FragmentProgram::Extensions::Extensions() +FragmentProgram::Extensions::Extensions(unsigned int contextID) { - setupGLExtenions(); + setupGLExtenions(contextID); } FragmentProgram::Extensions::Extensions(const Extensions& rhs): @@ -245,9 +245,9 @@ void FragmentProgram::Extensions::lowestCommonDenominator(const Extensions& rhs) } -void FragmentProgram::Extensions::setupGLExtenions() +void FragmentProgram::Extensions::setupGLExtenions(unsigned int contextID) { - _isFragmentProgramSupported = isGLExtensionSupported("GL_ARB_fragment_program"); + _isFragmentProgramSupported = isGLExtensionSupported(contextID,"GL_ARB_fragment_program"); _glBindProgram = osg::getGLExtensionFuncPtr("glBindProgramARB"); _glGenPrograms = osg::getGLExtensionFuncPtr("glGenProgramsARB"); diff --git a/src/osg/GLExtensions.cpp b/src/osg/GLExtensions.cpp index 64577fea1..536392085 100644 --- a/src/osg/GLExtensions.cpp +++ b/src/osg/GLExtensions.cpp @@ -14,7 +14,7 @@ #include #include #include - +#include #include #include @@ -24,30 +24,42 @@ #include #include -bool osg::isGLExtensionSupported(const char *extension) +bool osg::isGLExtensionSupported(unsigned int contextID, const char *extension) { typedef std::set ExtensionSet; - static ExtensionSet s_extensionSet; - static const char* s_extensions = NULL; - if (s_extensions==NULL) + static osg::buffered_object s_extensionSetList; + static osg::buffered_object s_rendererList; + static osg::buffered_value s_initializedList; + + ExtensionSet& extensionSet = s_extensionSetList[contextID]; + std::string& rendererString = s_rendererList[contextID]; + + // if not already set up, initialize all the per graphic context values. + if (!s_initializedList[contextID]) { + s_initializedList[contextID] = 1; + + // set up the renderer + const GLubyte* renderer = glGetString(GL_RENDERER); + rendererString = renderer ? (const char*)renderer : ""; + // get the extension list from OpenGL. - s_extensions = (const char*)glGetString(GL_EXTENSIONS); - if (s_extensions==NULL) return false; + const char* extensions = (const char*)glGetString(GL_EXTENSIONS); + if (extensions==NULL) return false; // insert the ' ' delimiated extensions words into the extensionSet. - const char *startOfWord = s_extensions; + const char *startOfWord = extensions; const char *endOfWord; while ((endOfWord = strchr(startOfWord,' '))!=NULL) { - s_extensionSet.insert(std::string(startOfWord,endOfWord)); + extensionSet.insert(std::string(startOfWord,endOfWord)); startOfWord = endOfWord+1; } - if (*startOfWord!=0) s_extensionSet.insert(std::string(startOfWord)); + if (*startOfWord!=0) extensionSet.insert(std::string(startOfWord)); osg::notify(INFO)<<"OpenGL extensions supported by installed OpenGL drivers are:"< ExtensionSet; - static ExtensionSet s_extensionSet; - static const char* s_extensions = NULL; - if (s_extensions==NULL) + static osg::buffered_object s_extensionSetList; + static osg::buffered_object s_rendererList; + static osg::buffered_value s_initializedList; + + ExtensionSet& extensionSet = s_extensionSetList[contextID]; + std::string& rendererString = s_rendererList[contextID]; + + // if not already set up, initialize all the per graphic context values. + if (!s_initializedList[contextID]) { + s_initializedList[contextID] = 1; + + // set up the renderer + const GLubyte* renderer = glGetString(GL_RENDERER); + rendererString = renderer ? (const char*)renderer : ""; + // get the extension list from OpenGL. - s_extensions = (const char*)gluGetString(GLU_EXTENSIONS); - if (s_extensions==NULL) return false; + const char* extensions = (const char*)gluGetString(GLU_EXTENSIONS); + if (extensions==NULL) return false; // insert the ' ' delimiated extensions words into the extensionSet. - const char *startOfWord = s_extensions; + const char *startOfWord = extensions; const char *endOfWord; while ((endOfWord = strchr(startOfWord,' '))!=NULL) { - s_extensionSet.insert(std::string(startOfWord,endOfWord)); + extensionSet.insert(std::string(startOfWord,endOfWord)); startOfWord = endOfWord+1; } - if (*startOfWord!=0) s_extensionSet.insert(std::string(startOfWord)); + if (*startOfWord!=0) extensionSet.insert(std::string(startOfWord)); osg::notify(INFO)<<"OpenGL extensions supported by installed OpenGL drivers are:"<=0 || - isGLExtensionSupported("GL_ARB_point_parameters") || - isGLExtensionSupported("GL_EXT_point_parameters") || - isGLExtensionSupported("GL_SGIS_point_parameters"); + isGLExtensionSupported(contextID,"GL_ARB_point_parameters") || + isGLExtensionSupported(contextID,"GL_EXT_point_parameters") || + isGLExtensionSupported(contextID,"GL_SGIS_point_parameters"); _glPointParameterf = getGLExtensionFuncPtr("glPointParameterf", "glPointParameterfARB"); if (!_glPointParameterf) _glPointParameterf = getGLExtensionFuncPtr("glPointParameterfEXT", "glPointParameterfSGIS"); diff --git a/src/osg/Program.cpp b/src/osg/Program.cpp index 217fa1359..79cfc58c8 100644 --- a/src/osg/Program.cpp +++ b/src/osg/Program.cpp @@ -39,9 +39,9 @@ using namespace osg; /////////////////////////////////////////////////////////////////////////// // Extension function pointers for OpenGL v2.0 -GL2Extensions::GL2Extensions() +GL2Extensions::GL2Extensions(unsigned int contextID) { - setupGL2Extensions(); + setupGL2Extensions(contextID); } @@ -268,15 +268,15 @@ void GL2Extensions::lowestCommonDenominator(const GL2Extensions& rhs) } -void GL2Extensions::setupGL2Extensions() +void GL2Extensions::setupGL2Extensions(unsigned int contextID) { _glVersion = atof( (const char*)glGetString( GL_VERSION ) ); _glslLanguageVersion = 0.0f; - _isShaderObjectsSupported = osg::isGLExtensionSupported("GL_ARB_shader_objects"); - _isVertexShaderSupported = osg::isGLExtensionSupported("GL_ARB_vertex_shader"); - _isFragmentShaderSupported = osg::isGLExtensionSupported("GL_ARB_fragment_shader"); - _isLanguage100Supported = osg::isGLExtensionSupported("GL_ARB_shading_language_100"); + _isShaderObjectsSupported = osg::isGLExtensionSupported(contextID,"GL_ARB_shader_objects"); + _isVertexShaderSupported = osg::isGLExtensionSupported(contextID,"GL_ARB_vertex_shader"); + _isFragmentShaderSupported = osg::isGLExtensionSupported(contextID,"GL_ARB_fragment_shader"); + _isLanguage100Supported = osg::isGLExtensionSupported(contextID,"GL_ARB_shading_language_100"); if( isGlslSupported() ) { @@ -418,7 +418,7 @@ GL2Extensions* GL2Extensions::Get(unsigned int contextID, bool createIfNotInitalized) { if (!s_extensions[contextID] && createIfNotInitalized) - s_extensions[contextID] = new GL2Extensions; + s_extensions[contextID] = new GL2Extensions(contextID); return s_extensions[contextID].get(); } diff --git a/src/osg/State.cpp b/src/osg/State.cpp index 71f409235..742f28006 100644 --- a/src/osg/State.cpp +++ b/src/osg/State.cpp @@ -778,21 +778,21 @@ void State::disableVertexAttribPointersAboveAndIncluding( unsigned int index ) bool State::computeSecondaryColorSupported() const { _isSecondaryColorSupportResolved = true; - _isSecondaryColorSupported = osg::isGLExtensionSupported("GL_EXT_secondary_color"); + _isSecondaryColorSupported = osg::isGLExtensionSupported(_contextID,"GL_EXT_secondary_color"); return _isSecondaryColorSupported; } bool State::computeFogCoordSupported() const { _isFogCoordSupportResolved = true; - _isFogCoordSupported = osg::isGLExtensionSupported("GL_EXT_fog_coord"); + _isFogCoordSupported = osg::isGLExtensionSupported(_contextID,"GL_EXT_fog_coord"); return _isFogCoordSupported; } bool State::computeVertexBufferObjectSupported() const { _isVertexBufferObjectSupportResolved = true; - _isVertexBufferObjectSupported = osg::isGLExtensionSupported("GL_ARB_vertex_buffer_object"); + _isVertexBufferObjectSupported = osg::isGLExtensionSupported(_contextID,"GL_ARB_vertex_buffer_object"); return _isVertexBufferObjectSupported; } diff --git a/src/osg/TexEnv.cpp b/src/osg/TexEnv.cpp index 1df2f1b1b..c773b5eaf 100644 --- a/src/osg/TexEnv.cpp +++ b/src/osg/TexEnv.cpp @@ -12,6 +12,7 @@ */ #include #include +#include using namespace osg; @@ -26,11 +27,11 @@ TexEnv::~TexEnv() { } -void TexEnv::apply(State&) const +void TexEnv::apply(State& state) const { if (_mode==ADD) { - static bool isTexEnvAddSupported = isGLExtensionSupported("GL_ARB_texture_env_add"); + static bool isTexEnvAddSupported = isGLExtensionSupported(state.getContextID(),"GL_ARB_texture_env_add"); if (isTexEnvAddSupported) glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, ADD); else // fallback on OpenGL default. diff --git a/src/osg/TexEnvCombine.cpp b/src/osg/TexEnvCombine.cpp index 022c7fae8..d2782890c 100644 --- a/src/osg/TexEnvCombine.cpp +++ b/src/osg/TexEnvCombine.cpp @@ -12,6 +12,7 @@ */ #include #include +#include #include using namespace osg; @@ -42,19 +43,21 @@ TexEnvCombine::~TexEnvCombine() { } -void TexEnvCombine::apply(State&) const +void TexEnvCombine::apply(State& state) const { + unsigned int contextID = state.getContextID(); + static bool s_isTexEnvCombineSupported = - isGLExtensionSupported("GL_ARB_texture_env_combine"); + isGLExtensionSupported(contextID,"GL_ARB_texture_env_combine"); static bool s_isTexEnvCrossbarSupported = - isGLExtensionSupported("GL_ARB_texture_env_crossbar"); + isGLExtensionSupported(contextID,"GL_ARB_texture_env_crossbar"); static bool s_isNVTexEnvCrossbarSupported = - isGLExtensionSupported("GL_NV_texture_env_combine4"); + isGLExtensionSupported(contextID,"GL_NV_texture_env_combine4"); static bool s_isTexEnvDot3Supported = - isGLExtensionSupported("GL_ARB_texture_env_dot3"); + isGLExtensionSupported(contextID,"GL_ARB_texture_env_dot3"); bool needsTexEnvDot3 = (_combine_RGB==DOT3_RGB) || diff --git a/src/osg/TexEnvFilter.cpp b/src/osg/TexEnvFilter.cpp index e1dd7e055..0de5a680e 100644 --- a/src/osg/TexEnvFilter.cpp +++ b/src/osg/TexEnvFilter.cpp @@ -12,6 +12,7 @@ */ #include #include +#include using namespace osg; @@ -25,11 +26,11 @@ TexEnvFilter::~TexEnvFilter() { } -void TexEnvFilter::apply(State&) const +void TexEnvFilter::apply(State& state) const { // note from RO, need to adapt to do testing per graphics context. static float glVersion = atof( (const char *)glGetString( GL_VERSION ) ); - static bool s_isTexLodBias = glVersion>=1.4 || isGLExtensionSupported("GL_EXT_texture_lod_bias"); + static bool s_isTexLodBias = glVersion>=1.4 || isGLExtensionSupported(state.getContextID(),"GL_EXT_texture_lod_bias"); if (s_isTexLodBias) { diff --git a/src/osg/Texture.cpp b/src/osg/Texture.cpp index 0e5ee3d1f..2d4890096 100644 --- a/src/osg/Texture.cpp +++ b/src/osg/Texture.cpp @@ -1238,7 +1238,7 @@ static BufferedExtensions s_extensions; Texture::Extensions* Texture::getExtensions(unsigned int contextID,bool createIfNotInitalized) { - if (!s_extensions[contextID] && createIfNotInitalized) s_extensions[contextID] = new Extensions; + if (!s_extensions[contextID] && createIfNotInitalized) s_extensions[contextID] = new Extensions(contextID); return s_extensions[contextID].get(); } @@ -1247,9 +1247,9 @@ void Texture::setExtensions(unsigned int contextID,Extensions* extensions) s_extensions[contextID] = extensions; } -Texture::Extensions::Extensions() +Texture::Extensions::Extensions(unsigned int contextID) { - setupGLExtensions(); + setupGLExtensions(contextID); } Texture::Extensions::Extensions(const Extensions& rhs): @@ -1301,31 +1301,31 @@ void Texture::Extensions::lowestCommonDenominator(const Extensions& rhs) if (!rhs._isClientStorageSupported) _isClientStorageSupported = false; } -void Texture::Extensions::setupGLExtensions() +void Texture::Extensions::setupGLExtensions(unsigned int contextID) { float glVersion = atof( (const char *)glGetString( GL_VERSION ) ); _isMultiTexturingSupported = ( glVersion >= 1.3 ) || - isGLExtensionSupported("GL_ARB_multitexture") || - isGLExtensionSupported("GL_EXT_multitexture"); - _isTextureFilterAnisotropicSupported = isGLExtensionSupported("GL_EXT_texture_filter_anisotropic"); + isGLExtensionSupported(contextID,"GL_ARB_multitexture") || + isGLExtensionSupported(contextID,"GL_EXT_multitexture"); + _isTextureFilterAnisotropicSupported = isGLExtensionSupported(contextID,"GL_EXT_texture_filter_anisotropic"); _isTextureCompressionARBSupported = ( glVersion >= 1.3 ) || - isGLExtensionSupported("GL_ARB_texture_compression"); - _isTextureCompressionS3TCSupported = isGLExtensionSupported("GL_EXT_texture_compression_s3tc"); + isGLExtensionSupported(contextID,"GL_ARB_texture_compression"); + _isTextureCompressionS3TCSupported = isGLExtensionSupported(contextID,"GL_EXT_texture_compression_s3tc"); _isTextureMirroredRepeatSupported = ( glVersion >= 1.4 ) || - isGLExtensionSupported("GL_IBM_texture_mirrored_repeat") || - isGLExtensionSupported("GL_ARB_texture_mirrored_repeat"); + isGLExtensionSupported(contextID,"GL_IBM_texture_mirrored_repeat") || + isGLExtensionSupported(contextID,"GL_ARB_texture_mirrored_repeat"); _isTextureEdgeClampSupported = ( glVersion >= 1.2 ) || - isGLExtensionSupported("GL_EXT_texture_edge_clamp") || - isGLExtensionSupported("GL_SGIS_texture_edge_clamp"); + isGLExtensionSupported(contextID,"GL_EXT_texture_edge_clamp") || + isGLExtensionSupported(contextID,"GL_SGIS_texture_edge_clamp"); _isTextureBorderClampSupported = ( glVersion >= 1.3 ) || - isGLExtensionSupported("GL_ARB_texture_border_clamp"); + isGLExtensionSupported(contextID,"GL_ARB_texture_border_clamp"); _isGenerateMipMapSupported = (strncmp((const char*)glGetString(GL_VERSION),"1.4",3)>=0) || - isGLExtensionSupported("GL_SGIS_generate_mipmap"); - _isShadowSupported = isGLExtensionSupported("GL_ARB_shadow"); - _isShadowAmbientSupported = isGLExtensionSupported("GL_ARB_shadow_ambient"); + isGLExtensionSupported(contextID,"GL_SGIS_generate_mipmap"); + _isShadowSupported = isGLExtensionSupported(contextID,"GL_ARB_shadow"); + _isShadowAmbientSupported = isGLExtensionSupported(contextID,"GL_ARB_shadow_ambient"); - _isClientStorageSupported = isGLExtensionSupported("GL_APPLE_client_storage"); + _isClientStorageSupported = isGLExtensionSupported(contextID,"GL_APPLE_client_storage"); glGetIntegerv(GL_MAX_TEXTURE_SIZE,&_maxTextureSize); diff --git a/src/osg/Texture3D.cpp b/src/osg/Texture3D.cpp index 817c52da1..4d9344926 100644 --- a/src/osg/Texture3D.cpp +++ b/src/osg/Texture3D.cpp @@ -383,7 +383,7 @@ static BufferedExtensions s_extensions; Texture3D::Extensions* Texture3D::getExtensions(unsigned int contextID,bool createIfNotInitalized) { - if (!s_extensions[contextID] && createIfNotInitalized) s_extensions[contextID] = new Extensions; + if (!s_extensions[contextID] && createIfNotInitalized) s_extensions[contextID] = new Extensions(contextID); return s_extensions[contextID].get(); } @@ -396,9 +396,9 @@ void Texture3D::setExtensions(unsigned int contextID,Extensions* extensions) #define GL_MAX_3D_TEXTURE_SIZE 0x8073 #endif -Texture3D::Extensions::Extensions() +Texture3D::Extensions::Extensions(unsigned int contextID) { - setupGLExtenions(); + setupGLExtenions(contextID); } Texture3D::Extensions::Extensions(const Extensions& rhs): @@ -428,9 +428,9 @@ void Texture3D::Extensions::lowestCommonDenominator(const Extensions& rhs) if (!rhs._gluBuild3DMipmaps) _gluBuild3DMipmaps = 0; } -void Texture3D::Extensions::setupGLExtenions() +void Texture3D::Extensions::setupGLExtenions(unsigned int contextID) { - _isTexture3DFast = isGLExtensionSupported("GL_EXT_texture3D"); + _isTexture3DFast = isGLExtensionSupported(contextID,"GL_EXT_texture3D"); if (_isTexture3DFast) _isTexture3DSupported = true; else _isTexture3DSupported = strncmp((const char*)glGetString(GL_VERSION),"1.2",3)>=0; diff --git a/src/osg/TextureCubeMap.cpp b/src/osg/TextureCubeMap.cpp index 8a3d20a11..97d628ef1 100644 --- a/src/osg/TextureCubeMap.cpp +++ b/src/osg/TextureCubeMap.cpp @@ -308,7 +308,7 @@ static BufferedExtensions s_extensions; TextureCubeMap::Extensions* TextureCubeMap::getExtensions(unsigned int contextID,bool createIfNotInitalized) { - if (!s_extensions[contextID] && createIfNotInitalized) s_extensions[contextID] = new Extensions; + if (!s_extensions[contextID] && createIfNotInitalized) s_extensions[contextID] = new Extensions(contextID); return s_extensions[contextID].get(); } @@ -317,9 +317,9 @@ void TextureCubeMap::setExtensions(unsigned int contextID,Extensions* extensions s_extensions[contextID] = extensions; } -TextureCubeMap::Extensions::Extensions() +TextureCubeMap::Extensions::Extensions(unsigned int contextID) { - setupGLExtenions(); + setupGLExtenions(contextID); } TextureCubeMap::Extensions::Extensions(const Extensions& rhs): @@ -333,9 +333,9 @@ void TextureCubeMap::Extensions::lowestCommonDenominator(const Extensions& rhs) if (!rhs._isCubeMapSupported) _isCubeMapSupported = false; } -void TextureCubeMap::Extensions::setupGLExtenions() +void TextureCubeMap::Extensions::setupGLExtenions(unsigned int contextID) { - _isCubeMapSupported = isGLExtensionSupported("GL_ARB_texture_cube_map") || - isGLExtensionSupported("GL_EXT_texture_cube_map") || + _isCubeMapSupported = 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/osg/TextureRectangle.cpp b/src/osg/TextureRectangle.cpp index 17ce14453..486e1362b 100644 --- a/src/osg/TextureRectangle.cpp +++ b/src/osg/TextureRectangle.cpp @@ -121,7 +121,7 @@ void TextureRectangle::setImage(Image* image) void TextureRectangle::apply(State& state) const { - static bool s_rectangleSupported = isGLExtensionSupported("GL_EXT_texture_rectangle") || isGLExtensionSupported("GL_NV_texture_rectangle"); + static bool s_rectangleSupported = isGLExtensionSupported(state.getContextID(),"GL_EXT_texture_rectangle") || isGLExtensionSupported(state.getContextID(),"GL_NV_texture_rectangle"); if (!s_rectangleSupported) { diff --git a/src/osg/VertexProgram.cpp b/src/osg/VertexProgram.cpp index 3423d42fa..6d1409d17 100644 --- a/src/osg/VertexProgram.cpp +++ b/src/osg/VertexProgram.cpp @@ -208,7 +208,7 @@ static BufferedExtensions s_extensions; VertexProgram::Extensions* VertexProgram::getExtensions(unsigned int contextID,bool createIfNotInitalized) { - if (!s_extensions[contextID] && createIfNotInitalized) s_extensions[contextID] = new Extensions; + if (!s_extensions[contextID] && createIfNotInitalized) s_extensions[contextID] = new Extensions(contextID); return s_extensions[contextID].get(); } @@ -217,9 +217,9 @@ void VertexProgram::setExtensions(unsigned int contextID,Extensions* extensions) s_extensions[contextID] = extensions; } -VertexProgram::Extensions::Extensions() +VertexProgram::Extensions::Extensions(unsigned int contextID) { - setupGLExtenions(); + setupGLExtenions(contextID); } VertexProgram::Extensions::Extensions(const Extensions& rhs): @@ -246,9 +246,9 @@ void VertexProgram::Extensions::lowestCommonDenominator(const Extensions& rhs) } -void VertexProgram::Extensions::setupGLExtenions() +void VertexProgram::Extensions::setupGLExtenions(unsigned int contextID) { - _isVertexProgramSupported = isGLExtensionSupported("GL_ARB_vertex_program"); + _isVertexProgramSupported = isGLExtensionSupported(contextID,"GL_ARB_vertex_program"); _glBindProgram = osg::getGLExtensionFuncPtr("glBindProgramARB"); _glGenPrograms = osg::getGLExtensionFuncPtr("glGenProgramsARB"); diff --git a/src/osgFX/Technique.cpp b/src/osgFX/Technique.cpp index 68a5e2309..6783447c0 100644 --- a/src/osgFX/Technique.cpp +++ b/src/osgFX/Technique.cpp @@ -20,7 +20,7 @@ void Technique::addPass(osg::StateSet *ss) } } -bool Technique::validate(osg::State &) const +bool Technique::validate(osg::State& state) const { typedef std::vector String_list; String_list extensions; @@ -28,7 +28,7 @@ bool Technique::validate(osg::State &) const getRequiredExtensions(extensions); for (String_list::const_iterator i=extensions.begin(); i!=extensions.end(); ++i) { - if (!osg::isGLExtensionSupported(i->c_str())) return false; + if (!osg::isGLExtensionSupported(state.getContextID(),i->c_str())) return false; } return true;