Added support for per context extension string.

Note, this required adding a unsigned int context ID to the osg::isGLUExtensionSupported(,)
and osg::isGLExtensionSupported(,) functions.  This may require reimplementation
of end user code to accomodate the new calling convention.
This commit is contained in:
Robert Osfield
2005-04-26 13:15:27 +00:00
parent 59ebf86dd0
commit a1bda0dab8
35 changed files with 191 additions and 162 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -64,7 +64,7 @@ echo osglight
osglight glider.osg
echo osglightpoint
osglightpoint
#osglightpoint
echo osglogo
osglogo

View File

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

View File

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

View File

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

View File

@@ -13,6 +13,7 @@
#include <osg/GLExtensions>
#include <osg/ColorMatrix>
#include <osg/GL>
#include <osg/State>
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<<std::endl;
static bool s_ARB_imaging = isGLExtensionSupported("GL_ARB_imaging");
unsigned int contextID = state.getContextID();
static bool s_ARB_imaging = isGLExtensionSupported(contextID,"GL_ARB_imaging");
if (s_ARB_imaging)
{
glMatrixMode( GL_COLOR );

View File

@@ -752,7 +752,7 @@ static BufferedExtensions s_extensions;
Drawable::Extensions* Drawable::getExtensions(unsigned int contextID,bool createIfNotInitalized)
{
if (!s_extensions[contextID] && createIfNotInitalized) s_extensions[contextID] = new Drawable::Extensions;
if (!s_extensions[contextID] && createIfNotInitalized) s_extensions[contextID] = new Drawable::Extensions(contextID);
return s_extensions[contextID].get();
}
@@ -761,9 +761,9 @@ void Drawable::setExtensions(unsigned int contextID,Extensions* extensions)
s_extensions[contextID] = extensions;
}
Drawable::Extensions::Extensions()
Drawable::Extensions::Extensions(unsigned int contextID)
{
setupGLExtenions();
setupGLExtenions(contextID);
}
Drawable::Extensions::Extensions(const Extensions& rhs):
@@ -866,14 +866,14 @@ void Drawable::Extensions::lowestCommonDenominator(const Extensions& rhs)
if (!rhs._gl_get_query_objectuiv_arb) _gl_get_query_objectuiv_arb = 0;
}
void Drawable::Extensions::setupGLExtenions()
void Drawable::Extensions::setupGLExtenions(unsigned int contextID)
{
_isVertexProgramSupported = isGLExtensionSupported("GL_ARB_vertex_program");
_isSecondaryColorSupported = isGLExtensionSupported("GL_EXT_secondary_color");
_isFogCoordSupported = isGLExtensionSupported("GL_EXT_fog_coord");
_isMultiTexSupported = isGLExtensionSupported("GL_ARB_multitexture");
_isOcclusionQuerySupported = osg::isGLExtensionSupported( "GL_NV_occlusion_query" );
_isARBOcclusionQuerySupported = osg::isGLExtensionSupported( "GL_ARB_occlusion_query" );
_isVertexProgramSupported = isGLExtensionSupported(contextID,"GL_ARB_vertex_program");
_isSecondaryColorSupported = isGLExtensionSupported(contextID,"GL_EXT_secondary_color");
_isFogCoordSupported = isGLExtensionSupported(contextID,"GL_EXT_fog_coord");
_isMultiTexSupported = isGLExtensionSupported(contextID,"GL_ARB_multitexture");
_isOcclusionQuerySupported = osg::isGLExtensionSupported(contextID, "GL_NV_occlusion_query" );
_isARBOcclusionQuerySupported = osg::isGLExtensionSupported(contextID, "GL_ARB_occlusion_query" );
_glFogCoordfv = ((FogCoordProc)osg::getGLExtensionFuncPtr("glFogCoordfv","glFogCoordfvEXT"));
_glSecondaryColor3ubv = ((SecondaryColor3ubvProc)osg::getGLExtensionFuncPtr("glSecondaryColor3ubv","glSecondaryColor3ubvEXT"));

View File

@@ -11,6 +11,7 @@
* OpenSceneGraph Public License for more details.
*/
#include <osg/GLExtensions>
#include <osg/State>
#include <osg/Fog>
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);

View File

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

View File

@@ -14,7 +14,7 @@
#include <osg/GL>
#include <osg/GLU>
#include <osg/Notify>
#include <osg/buffered_value>
#include <stdlib.h>
#include <string.h>
@@ -24,30 +24,42 @@
#include <vector>
#include <set>
bool osg::isGLExtensionSupported(const char *extension)
bool osg::isGLExtensionSupported(unsigned int contextID, const char *extension)
{
typedef std::set<std::string> ExtensionSet;
static ExtensionSet s_extensionSet;
static const char* s_extensions = NULL;
if (s_extensions==NULL)
static osg::buffered_object<ExtensionSet> s_extensionSetList;
static osg::buffered_object<std::string> s_rendererList;
static osg::buffered_value<int> 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:"<<std::endl;
for(ExtensionSet::iterator itr=s_extensionSet.begin();
itr!=s_extensionSet.end();
for(ExtensionSet::iterator itr=extensionSet.begin();
itr!=extensionSet.end();
++itr)
{
osg::notify(INFO)<<" "<<*itr<<std::endl;
@@ -56,20 +68,17 @@ bool osg::isGLExtensionSupported(const char *extension)
}
// true if extension found in extensionSet.
bool result = s_extensionSet.find(extension)!=s_extensionSet.end();
bool result = extensionSet.find(extension)!=extensionSet.end();
// now see if extension is in the extension disabled list
bool extensionDisabled = false;
if (result)
{
const std::string& disableString = getGLExtensionDisableString();
if (!disableString.empty())
{
static const GLubyte* s_renderer = glGetString(GL_RENDERER);
static std::string s_rendererString(s_renderer?(const char*)s_renderer:"");
std::string::size_type pos=0;
while ( pos!=std::string::npos && (pos=disableString.find(extension,pos))!=std::string::npos )
{
@@ -103,7 +112,7 @@ bool osg::isGLExtensionSupported(const char *extension)
break;
}
if (s_rendererString.find(renderer)!=std::string::npos)
if (rendererString.find(renderer)!=std::string::npos)
{
extensionDisabled = true;
break;
@@ -141,30 +150,42 @@ std::string& osg::getGLExtensionDisableString()
}
bool osg::isGLUExtensionSupported(const char *extension)
bool osg::isGLUExtensionSupported(unsigned int contextID, const char *extension)
{
typedef std::set<std::string> ExtensionSet;
static ExtensionSet s_extensionSet;
static const char* s_extensions = NULL;
if (s_extensions==NULL)
static osg::buffered_object<ExtensionSet> s_extensionSetList;
static osg::buffered_object<std::string> s_rendererList;
static osg::buffered_value<int> 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:"<<std::endl;
for(ExtensionSet::iterator itr=s_extensionSet.begin();
itr!=s_extensionSet.end();
for(ExtensionSet::iterator itr=extensionSet.begin();
itr!=extensionSet.end();
++itr)
{
osg::notify(INFO)<<" "<<*itr<<std::endl;
@@ -173,7 +194,7 @@ bool osg::isGLUExtensionSupported(const char *extension)
}
// true if extension found in extensionSet.
bool result = s_extensionSet.find(extension)!=s_extensionSet.end();
bool result = extensionSet.find(extension)!=extensionSet.end();
if (result) osg::notify(INFO)<<"OpenGL utility library extension '"<<extension<<"' is supported."<<std::endl;
else osg::notify(INFO)<<"OpenGL utility library extension '"<<extension<<"' is not supported."<<std::endl;

View File

@@ -57,7 +57,7 @@ static BufferedExtensions s_extensions;
Multisample::Extensions* Multisample::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();
}
@@ -67,9 +67,9 @@ void Multisample::setExtensions(unsigned int contextID,Extensions* extensions)
}
Multisample::Extensions::Extensions()
Multisample::Extensions::Extensions(unsigned int contextID)
{
setupGLExtenions();
setupGLExtenions(contextID);
}
Multisample::Extensions::Extensions(const Extensions& rhs):
@@ -86,10 +86,10 @@ void Multisample::Extensions::lowestCommonDenominator(const Extensions& rhs)
if (!rhs._glSampleCoverage) _glSampleCoverage = 0;
}
void Multisample::Extensions::setupGLExtenions()
void Multisample::Extensions::setupGLExtenions(unsigned int contextID)
{
_isMultisampleSupported = isGLExtensionSupported("GL_ARB_multisample");
_isMultisampleFilterHintSupported = isGLExtensionSupported("GL_NV_multisample_filter_hint");
_isMultisampleSupported = isGLExtensionSupported(contextID,"GL_ARB_multisample");
_isMultisampleFilterHintSupported = isGLExtensionSupported(contextID,"GL_NV_multisample_filter_hint");
_glSampleCoverage = getGLExtensionFuncPtr("glSampleCoverageARB");
}

View File

@@ -93,7 +93,7 @@ static BufferedExtensions s_extensions;
Point::Extensions* Point::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();
}
@@ -102,9 +102,9 @@ void Point::setExtensions(unsigned int contextID,Extensions* extensions)
s_extensions[contextID] = extensions;
}
Point::Extensions::Extensions()
Point::Extensions::Extensions(unsigned int contextID)
{
setupGLExtenions();
setupGLExtenions(contextID);
}
Point::Extensions::Extensions(const Extensions& rhs):
@@ -120,12 +120,12 @@ void Point::Extensions::lowestCommonDenominator(const Extensions& rhs)
if (!rhs._glPointParameterfv) _glPointParameterfv = 0;
}
void Point::Extensions::setupGLExtenions()
void Point::Extensions::setupGLExtenions(unsigned int contextID)
{
_isPointParametersSupported = strncmp((const char*)glGetString(GL_VERSION),"1.4",3)>=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");

View File

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

View File

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

View File

@@ -12,6 +12,7 @@
*/
#include <osg/GLExtensions>
#include <osg/TexEnv>
#include <osg/State>
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.

View File

@@ -12,6 +12,7 @@
*/
#include <osg/GLExtensions>
#include <osg/TexEnvCombine>
#include <osg/State>
#include <osg/Notify>
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) ||

View File

@@ -12,6 +12,7 @@
*/
#include <osg/GLExtensions>
#include <osg/TexEnvFilter>
#include <osg/State>
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)
{

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -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<std::string> 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;