From Ravi Mathur, added extension checks for point sprite support.

From Robert Osfield, tweaks of the above to use osg::buffer_object and a local struct to store
initialized to help with multi-thread and out of order context usage.
This commit is contained in:
Robert Osfield
2005-09-19 15:28:31 +00:00
parent d1108ea862
commit 871cc70c32
2 changed files with 31 additions and 1 deletions

View File

@@ -50,6 +50,8 @@ public:
virtual void apply(osg::State& state) const;
static bool isPointSpriteSupported(unsigned int context);
protected:
virtual ~PointSprite( void ) {}
};

View File

@@ -14,6 +14,8 @@
#include <osg/GLExtensions>
#include <osg/GL>
#include <osg/PointSprite>
#include <osg/State>
#include <osg/buffered_value>
using namespace osg;
@@ -28,7 +30,33 @@ int PointSprite::compare(const StateAttribute& sa) const
return 0; // passed all the above comparison macro's, must be equal.
}
void PointSprite::apply(osg::State&) const
void PointSprite::apply(osg::State& state) const
{
if(!isPointSpriteSupported(state.getContextID())) return;
glTexEnvi(GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, 1);
}
struct IntializedSupportedPair
{
IntializedSupportedPair():
initialized(false),
supported(false) {}
bool initialized;
bool supported;
};
typedef osg::buffered_object< IntializedSupportedPair > BufferedExtensions;
static BufferedExtensions s_extensions;
bool PointSprite::isPointSpriteSupported(unsigned int contextID)
{
if (!s_extensions[contextID].initialized)
{
s_extensions[contextID].initialized = true;
s_extensions[contextID].supported = isGLExtensionSupported(contextID, "GL_ARB_point_sprite") || isGLExtensionSupported(contextID, "GL_NV_point_sprite");
}
return s_extensions[contextID].supported;
}