Moved local Extensions structs into GL2Extensions
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14584 16af8721-9629-0410-8352-f15c8da7e697
This commit is contained in:
parent
3f1e77d479
commit
e31f682451
@ -80,49 +80,7 @@ class OSG_EXPORT ClampColor : public StateAttribute
|
||||
void setClampReadColor(GLenum mode) { _clampReadColor = mode; }
|
||||
GLenum getClampReadColor() const { return _clampReadColor; }
|
||||
|
||||
|
||||
virtual void apply(State& state) const;
|
||||
/** Encapsulates queries of extension availability, obtains extension
|
||||
* function pointers, and provides convenience wrappers for
|
||||
* calling extension 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 setClampColorSupported(bool flag) { _isClampColorSupported=flag; }
|
||||
bool isClampColorSupported() const { return _isClampColorSupported; }
|
||||
|
||||
void glClampColor(GLenum target, GLenum mode) const;
|
||||
|
||||
protected:
|
||||
|
||||
~Extensions() {}
|
||||
|
||||
typedef void (GL_APIENTRY * GLClampColorProc) (GLenum target, GLenum mode);
|
||||
bool _isClampColorSupported;
|
||||
GLClampColorProc _glClampColor;
|
||||
|
||||
};
|
||||
|
||||
/** Returns the Extensions object for the given context.
|
||||
* If createIfNotInitalized is true and the Extensions object doesn't
|
||||
* exist, getExtensions() creates it on the given context.
|
||||
* Returns NULL if createIfNotInitalized is false and the Extensions
|
||||
* object doesn't exist. */
|
||||
static Extensions* getExtensions(unsigned int contextID,bool createIfNotInitalized);
|
||||
|
||||
/** setExtensions() 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 :
|
||||
|
||||
|
@ -60,14 +60,6 @@ class OSG_EXPORT ColorMaski : public ColorMask
|
||||
|
||||
virtual void apply(State& state) const;
|
||||
|
||||
/** Encapsulates queries of extension availability, obtains extension function pointers. */
|
||||
struct OSG_EXPORT Extensions : public osg::Referenced
|
||||
{
|
||||
Extensions(unsigned int contextID);
|
||||
|
||||
void (GL_APIENTRY * glColorMaski)(GLuint buf, GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
|
||||
};
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~ColorMaski();
|
||||
|
@ -941,6 +941,34 @@ class OSG_EXPORT GL2Extensions : public osg::Referenced
|
||||
void (GL_APIENTRY * glStencilFuncSeparateATI) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask);
|
||||
|
||||
|
||||
// ColorMask
|
||||
void (GL_APIENTRY * glColorMaski)(GLuint buf, GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
|
||||
|
||||
|
||||
// ClampColor
|
||||
bool isClampColorSupported;
|
||||
void (GL_APIENTRY * glClampColor) (GLenum target, GLenum mode);
|
||||
|
||||
|
||||
// PrimitiveRestartIndex
|
||||
void (GL_APIENTRY * glPrimitiveRestartIndex) ( GLuint index );
|
||||
|
||||
|
||||
// Mutlisample
|
||||
bool isMultisampleSupported;
|
||||
bool isMultisampleFilterHintSupported;
|
||||
|
||||
void (GL_APIENTRY * glSampleCoverage) (GLclampf value, GLboolean invert);
|
||||
|
||||
// Point
|
||||
bool isPointParametersSupported;
|
||||
bool isPointSpriteSupported;
|
||||
bool isPointSpriteCoordOriginSupported;
|
||||
|
||||
void (GL_APIENTRY * glPointParameteri) (GLenum pname, GLint param);
|
||||
void (GL_APIENTRY * glPointParameterf) (GLenum pname, GLfloat param);
|
||||
void (GL_APIENTRY * glPointParameterfv) (GLenum pname, const GLfloat *params);
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -92,55 +92,6 @@ class OSG_EXPORT Multisample : public StateAttribute
|
||||
|
||||
virtual void apply(State& state) const;
|
||||
|
||||
|
||||
/** Extensions class which encapsulates the querying of extensions and
|
||||
* associated function pointers, and provide 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 setMultisampleSupported(bool flag) { _isMultisampleSupported=flag; }
|
||||
void setMultisampleFilterHintSupported(bool flag) { _isMultisampleFilterHintSupported=flag; }
|
||||
bool isMultisampleSupported() const { return _isMultisampleSupported; }
|
||||
bool isMultisampleFilterHintSupported() const { return _isMultisampleFilterHintSupported; }
|
||||
|
||||
void glSampleCoverage(GLclampf value, GLboolean invert) const;
|
||||
|
||||
protected:
|
||||
|
||||
~Extensions() {}
|
||||
|
||||
bool _isMultisampleSupported;
|
||||
bool _isMultisampleFilterHintSupported;
|
||||
|
||||
typedef void (GL_APIENTRY * GLSampleCoverageProc) (GLclampf value, GLboolean invert);
|
||||
GLSampleCoverageProc _glSampleCoverage;
|
||||
|
||||
};
|
||||
|
||||
/** Function to call to get the extension of a specified context.
|
||||
* If the Extension 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);
|
||||
|
||||
/** setExtensions 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 ~Multisample();
|
||||
|
@ -87,59 +87,6 @@ class OSG_EXPORT Point : public StateAttribute
|
||||
|
||||
virtual void apply(State& state) const;
|
||||
|
||||
/** Encapsulates queries of extension availability, obtains extension
|
||||
* function pointers, and provides convenience wrappers for
|
||||
* calling extension 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 setPointParametersSupported(bool flag) { _isPointParametersSupported=flag; }
|
||||
bool isPointParametersSupported() const { return _isPointParametersSupported; }
|
||||
|
||||
void setPointSpriteCoordOriginSupported(bool flag) { _isPointSpriteCoordOriginSupported=flag; }
|
||||
bool isPointSpriteCoordOriginSupported() const { return _isPointSpriteCoordOriginSupported; }
|
||||
|
||||
void glPointParameteri(GLenum pname, GLint param) const;
|
||||
void glPointParameterf(GLenum pname, GLfloat param) const;
|
||||
void glPointParameterfv(GLenum pname, const GLfloat *params) const;
|
||||
|
||||
protected:
|
||||
|
||||
~Extensions() {}
|
||||
|
||||
bool _isPointParametersSupported;
|
||||
bool _isPointSpriteCoordOriginSupported;
|
||||
|
||||
typedef void (GL_APIENTRY * GLPointParameteriProc) (GLenum pname, GLint param);
|
||||
typedef void (GL_APIENTRY * GLPointParameterfProc) (GLenum pname, GLfloat param);
|
||||
typedef void (GL_APIENTRY * GLPointParameterfvProc) (GLenum pname, const GLfloat *params);
|
||||
|
||||
GLPointParameteriProc _glPointParameteri;
|
||||
GLPointParameterfProc _glPointParameterf;
|
||||
GLPointParameterfvProc _glPointParameterfv;
|
||||
|
||||
};
|
||||
|
||||
/** Returns the Extensions object for the given context.
|
||||
* If createIfNotInitalized is true and the Extensions object doesn't
|
||||
* exist, getExtensions() creates it on the given context.
|
||||
* Returns NULL if createIfNotInitalized is false and the Extensions
|
||||
* object doesn't exist. */
|
||||
static Extensions* getExtensions(unsigned int contextID,bool createIfNotInitalized);
|
||||
|
||||
/** setExtensions() 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 ~Point();
|
||||
|
@ -59,8 +59,6 @@ public:
|
||||
|
||||
virtual void apply(osg::State& state) const;
|
||||
|
||||
static bool isPointSpriteSupported(unsigned int context);
|
||||
|
||||
enum CoordOriginMode {
|
||||
UPPER_LEFT = GL_UPPER_LEFT,
|
||||
LOWER_LEFT = GL_LOWER_LEFT
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
namespace osg {
|
||||
|
||||
/**
|
||||
/**
|
||||
* osg::PrimitiveRestartIndex does nothing if OpenGL 3.1 is not available.
|
||||
*/
|
||||
class OSG_EXPORT PrimitiveRestartIndex : public StateAttribute
|
||||
@ -35,13 +35,14 @@ class OSG_EXPORT PrimitiveRestartIndex : public StateAttribute
|
||||
|
||||
/** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
|
||||
virtual int compare(const StateAttribute& sa) const;
|
||||
|
||||
|
||||
inline void setRestartIndex(unsigned int restartIndex ) { _restartIndex = restartIndex; }
|
||||
|
||||
|
||||
inline unsigned int getRestartIndex() const { return _restartIndex; }
|
||||
|
||||
virtual void apply(State& state) const;
|
||||
|
||||
#if 0
|
||||
public:
|
||||
|
||||
/** Extensions class which encapsulates the querying of extensions and
|
||||
@ -67,19 +68,19 @@ class OSG_EXPORT PrimitiveRestartIndex : public StateAttribute
|
||||
protected:
|
||||
|
||||
~Extensions() {}
|
||||
|
||||
|
||||
bool _isOpenGL31Supported;
|
||||
bool _isPrimitiveRestartIndexNVSupported;
|
||||
|
||||
typedef void (GL_APIENTRY * PrimitiveRestartIndex)( GLuint index );
|
||||
|
||||
|
||||
PrimitiveRestartIndex _glPrimitiveRestartIndex;
|
||||
};
|
||||
|
||||
static Extensions* getExtensions(unsigned int contextID,bool createIfNotInitalized);
|
||||
|
||||
static void setExtensions(unsigned int contextID,Extensions* extensions);
|
||||
|
||||
#endif
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -31,9 +31,7 @@ namespace osg {
|
||||
* GL_EXT_stencil_wrap extension is present.
|
||||
*
|
||||
* If INCR_WRAP or DECR_WRAP values are used while they are detected to be not supported,
|
||||
* the INCR or DECR values are sent to OpenGL instead. Note: do not use Stencil::getFunction()
|
||||
* to detect whether WRAP operations is used as the object's value is kept intact.
|
||||
* Use osg::Stencil::getExtensions() method instead.
|
||||
* the INCR or DECR values are sent to OpenGL instead.
|
||||
*
|
||||
* OpenGL 2.0 introduced two side stenciling that is available through
|
||||
* osg::StencilTwoSided class.
|
||||
|
@ -42,11 +42,8 @@ void ClampColor::apply(State& state) const
|
||||
|
||||
// get the contextID (user defined ID of 0 upwards) for the
|
||||
// current OpenGL context.
|
||||
const unsigned int contextID = state.getContextID();
|
||||
|
||||
const Extensions* extensions = getExtensions(contextID,true);
|
||||
|
||||
if (!extensions->isClampColorSupported())
|
||||
const GL2Extensions* extensions = state.get<GL2Extensions>();
|
||||
if (!extensions->isClampColorSupported)
|
||||
{
|
||||
OSG_WARN<<"Warning: ClampColor::apply(..) failed, ClampColor is not support by OpenGL driver."<<std::endl;
|
||||
return;
|
||||
@ -56,60 +53,3 @@ void ClampColor::apply(State& state) const
|
||||
extensions->glClampColor(GL_CLAMP_FRAGMENT_COLOR, _clampFragmentColor);
|
||||
extensions->glClampColor(GL_CLAMP_READ_COLOR, _clampReadColor);
|
||||
}
|
||||
|
||||
|
||||
typedef buffered_value< ref_ptr<ClampColor::Extensions> > BufferedExtensions;
|
||||
static BufferedExtensions s_extensions;
|
||||
|
||||
ClampColor::Extensions* ClampColor::getExtensions(unsigned int contextID,bool createIfNotInitalized)
|
||||
{
|
||||
if (!s_extensions[contextID] && createIfNotInitalized) s_extensions[contextID] = new Extensions(contextID);
|
||||
return s_extensions[contextID].get();
|
||||
}
|
||||
|
||||
void ClampColor::setExtensions(unsigned int contextID,Extensions* extensions)
|
||||
{
|
||||
s_extensions[contextID] = extensions;
|
||||
}
|
||||
|
||||
|
||||
ClampColor::Extensions::Extensions(unsigned int contextID)
|
||||
{
|
||||
setupGLExtensions(contextID);
|
||||
}
|
||||
|
||||
ClampColor::Extensions::Extensions(const Extensions& rhs):
|
||||
Referenced()
|
||||
{
|
||||
_isClampColorSupported = rhs._isClampColorSupported;
|
||||
_glClampColor = rhs._glClampColor;
|
||||
}
|
||||
|
||||
void ClampColor::Extensions::lowestCommonDenominator(const Extensions& rhs)
|
||||
{
|
||||
if (!rhs._isClampColorSupported) _isClampColorSupported = false;
|
||||
if (!rhs._glClampColor) _glClampColor = 0;
|
||||
}
|
||||
|
||||
void ClampColor::Extensions::setupGLExtensions(unsigned int contextID)
|
||||
{
|
||||
_isClampColorSupported = OSG_GL3_FEATURES ||
|
||||
isGLExtensionSupported(contextID,"GL_ARB_color_buffer_float") ||
|
||||
strncmp((const char*)glGetString(GL_VERSION),"2.0",3)>=0;
|
||||
|
||||
setGLExtensionFuncPtr(_glClampColor, "glClampColor", "glClampColorARB");
|
||||
}
|
||||
|
||||
void ClampColor::Extensions::glClampColor(GLenum target, GLenum mode) const
|
||||
{
|
||||
if (_glClampColor)
|
||||
{
|
||||
_glClampColor(target,mode);
|
||||
}
|
||||
else
|
||||
{
|
||||
OSG_WARN<<"Error: glClampColor not supported by OpenGL driver"<<std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -16,13 +16,6 @@
|
||||
|
||||
using namespace osg;
|
||||
|
||||
// Set up extensions
|
||||
ColorMaski::Extensions::Extensions(unsigned int contextID)
|
||||
{
|
||||
setGLExtensionFuncPtr(glColorMaski, "glColorMaski", "glColorMaskiARB");
|
||||
}
|
||||
|
||||
|
||||
ColorMaski::ColorMaski():
|
||||
_index(0)
|
||||
{
|
||||
@ -34,7 +27,7 @@ ColorMaski::~ColorMaski()
|
||||
|
||||
void ColorMaski::apply(State& state) const
|
||||
{
|
||||
const Extensions* extensions = state.get<Extensions>();
|
||||
const GL2Extensions* extensions = state.get<GL2Extensions>();
|
||||
if (extensions->glColorMaski)
|
||||
{
|
||||
extensions->glColorMaski((GLboolean)_index, (GLboolean)_red,(GLboolean)_green,(GLboolean)_blue,(GLboolean)_alpha);
|
||||
|
@ -566,6 +566,52 @@ GL2Extensions::GL2Extensions(unsigned int contextID)
|
||||
setGLExtensionFuncPtr(glStencilMaskSeparate, "glStencilMaskSeparate");
|
||||
setGLExtensionFuncPtr(glStencilFuncSeparate, "glStencilFuncSeparate", "glStencilFuncSeparateATI");
|
||||
setGLExtensionFuncPtr(glStencilFuncSeparateATI, "glStencilFuncSeparateATI");
|
||||
|
||||
|
||||
// Color Mask
|
||||
setGLExtensionFuncPtr(glColorMaski, "glColorMaski", "glColorMaskiARB");
|
||||
|
||||
|
||||
// ClampColor
|
||||
isClampColorSupported = OSG_GL3_FEATURES ||
|
||||
isGLExtensionSupported(contextID,"GL_ARB_color_buffer_float") ||
|
||||
strncmp((const char*)glGetString(GL_VERSION),"2.0",3)>=0;
|
||||
|
||||
setGLExtensionFuncPtr(glClampColor, "glClampColor", "glClampColorARB");
|
||||
|
||||
|
||||
// PrimitiveRestartIndex
|
||||
setGLExtensionFuncPtr(glPrimitiveRestartIndex, "glPrimitiveRestartIndex", "glPrimitiveRestartIndexNV");
|
||||
|
||||
|
||||
// Point
|
||||
isPointParametersSupported = OSG_GL3_FEATURES ||
|
||||
strncmp((const char*)glGetString(GL_VERSION),"1.4",3)>=0 ||
|
||||
isGLExtensionSupported(contextID,"GL_ARB_point_parameters") ||
|
||||
isGLExtensionSupported(contextID,"GL_EXT_point_parameters") ||
|
||||
isGLExtensionSupported(contextID,"GL_SGIS_point_parameters");
|
||||
|
||||
|
||||
isPointSpriteSupported = OSG_GL3_FEATURES || isGLExtensionSupported(contextID, "GL_ARB_point_sprite") || isGLExtensionSupported(contextID, "GL_OES_point_sprite") || isGLExtensionSupported(contextID, "GL_NV_point_sprite");
|
||||
isPointSpriteCoordOriginSupported = OSG_GL3_FEATURES || strncmp((const char*)glGetString(GL_VERSION),"2.0",3)>=0;
|
||||
|
||||
|
||||
setGLExtensionFuncPtr(glPointParameteri, "glPointParameteri", "glPointParameteriARB");
|
||||
if (!glPointParameteri) setGLExtensionFuncPtr(glPointParameteri, "glPointParameteriEXT", "glPointParameteriSGIS");
|
||||
|
||||
setGLExtensionFuncPtr(glPointParameterf, "glPointParameterf", "glPointParameterfARB");
|
||||
if (!glPointParameterf) setGLExtensionFuncPtr(glPointParameterf, "glPointParameterfEXT", "glPointParameterfSGIS");
|
||||
|
||||
setGLExtensionFuncPtr(glPointParameterfv, "glPointParameterfv", "glPointParameterfvARB");
|
||||
if (!glPointParameterfv) setGLExtensionFuncPtr(glPointParameterfv, "glPointParameterfvEXT", "glPointParameterfvSGIS");
|
||||
|
||||
|
||||
// Multisample
|
||||
isMultisampleSupported = OSG_GLES2_FEATURES || OSG_GL3_FEATURES || isGLExtensionSupported(contextID,"GL_ARB_multisample");
|
||||
isMultisampleFilterHintSupported = isGLExtensionSupported(contextID, "GL_NV_multisample_filter_hint");
|
||||
|
||||
setGLExtensionFuncPtr(glSampleCoverage, "glSampleCoverageARB");
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -31,78 +31,17 @@ Multisample::~Multisample()
|
||||
|
||||
void Multisample::apply(State& state) const
|
||||
{
|
||||
// get the contextID (user defined ID of 0 upwards) for the
|
||||
// current OpenGL context.
|
||||
const unsigned int contextID = state.getContextID();
|
||||
|
||||
const Extensions* extensions = getExtensions(contextID,true);
|
||||
|
||||
if (!extensions->isMultisampleSupported())
|
||||
const GL2Extensions* extensions = state.get<GL2Extensions>();
|
||||
if (!extensions->isMultisampleSupported)
|
||||
{
|
||||
OSG_WARN<<"Warning: Multisample::apply(..) failed, Multisample is not support by OpenGL driver."<<std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
if(extensions->isMultisampleFilterHintSupported())
|
||||
if(extensions->isMultisampleFilterHintSupported)
|
||||
{
|
||||
glHint(GL_MULTISAMPLE_FILTER_HINT_NV, _mode);
|
||||
}
|
||||
|
||||
extensions->glSampleCoverage(_coverage, _invert);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
typedef buffered_value< ref_ptr<Multisample::Extensions> > BufferedExtensions;
|
||||
static BufferedExtensions s_extensions;
|
||||
|
||||
Multisample::Extensions* Multisample::getExtensions(unsigned int contextID,bool createIfNotInitalized)
|
||||
{
|
||||
if (!s_extensions[contextID] && createIfNotInitalized) s_extensions[contextID] = new Extensions(contextID);
|
||||
return s_extensions[contextID].get();
|
||||
}
|
||||
|
||||
void Multisample::setExtensions(unsigned int contextID,Extensions* extensions)
|
||||
{
|
||||
s_extensions[contextID] = extensions;
|
||||
}
|
||||
|
||||
|
||||
Multisample::Extensions::Extensions(unsigned int contextID)
|
||||
{
|
||||
setupGLExtensions(contextID);
|
||||
}
|
||||
|
||||
Multisample::Extensions::Extensions(const Extensions& rhs):
|
||||
Referenced()
|
||||
{
|
||||
_isMultisampleSupported = rhs._isMultisampleSupported;
|
||||
_isMultisampleFilterHintSupported = rhs._isMultisampleFilterHintSupported;
|
||||
}
|
||||
|
||||
void Multisample::Extensions::lowestCommonDenominator(const Extensions& rhs)
|
||||
{
|
||||
if (!rhs._isMultisampleSupported) _isMultisampleSupported = false;
|
||||
if (!rhs._isMultisampleFilterHintSupported) _isMultisampleFilterHintSupported = false;
|
||||
if (!rhs._glSampleCoverage) _glSampleCoverage = 0;
|
||||
}
|
||||
|
||||
void Multisample::Extensions::setupGLExtensions(unsigned int contextID)
|
||||
{
|
||||
_isMultisampleSupported = OSG_GLES2_FEATURES || OSG_GL3_FEATURES || isGLExtensionSupported(contextID,"GL_ARB_multisample");
|
||||
_isMultisampleFilterHintSupported = isGLExtensionSupported(contextID,"GL_NV_multisample_filter_hint");
|
||||
|
||||
setGLExtensionFuncPtr(_glSampleCoverage, "glSampleCoverageARB");
|
||||
}
|
||||
|
||||
void Multisample::Extensions::glSampleCoverage(GLclampf value, GLboolean invert) const
|
||||
{
|
||||
if (_glSampleCoverage)
|
||||
{
|
||||
_glSampleCoverage(value, invert);
|
||||
}
|
||||
else
|
||||
{
|
||||
OSG_WARN<<"Error: glSampleCoverage not supported by OpenGL driver"<<std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -84,10 +84,9 @@ void Point::apply(State& state) const
|
||||
#ifdef OSG_GL_FIXED_FUNCTION_AVAILABLE
|
||||
glPointSize(_size);
|
||||
|
||||
const unsigned int contextID = state.getContextID();
|
||||
const Extensions* extensions = getExtensions(contextID,true);
|
||||
const GL2Extensions* extensions = state.get<GL2Extensions>();
|
||||
|
||||
if (!extensions->isPointParametersSupported())
|
||||
if (!extensions->isPointParametersSupported)
|
||||
return;
|
||||
|
||||
extensions->glPointParameterfv(GL_POINT_DISTANCE_ATTENUATION, (const GLfloat*)&_distanceAttenuation);
|
||||
@ -98,98 +97,3 @@ void Point::apply(State& state) const
|
||||
OSG_NOTICE<<"Warning: Point::apply(State&) - not supported."<<std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
typedef buffered_value< ref_ptr<Point::Extensions> > BufferedExtensions;
|
||||
static BufferedExtensions s_extensions;
|
||||
|
||||
Point::Extensions* Point::getExtensions(unsigned int contextID,bool createIfNotInitalized)
|
||||
{
|
||||
if (!s_extensions[contextID] && createIfNotInitalized) s_extensions[contextID] = new Extensions(contextID);
|
||||
return s_extensions[contextID].get();
|
||||
}
|
||||
|
||||
void Point::setExtensions(unsigned int contextID,Extensions* extensions)
|
||||
{
|
||||
s_extensions[contextID] = extensions;
|
||||
}
|
||||
|
||||
Point::Extensions::Extensions(unsigned int contextID)
|
||||
{
|
||||
setupGLExtensions(contextID);
|
||||
}
|
||||
|
||||
Point::Extensions::Extensions(const Extensions& rhs):
|
||||
Referenced()
|
||||
{
|
||||
_isPointParametersSupported = rhs._isPointParametersSupported;
|
||||
_isPointSpriteCoordOriginSupported = rhs._isPointSpriteCoordOriginSupported;
|
||||
_glPointParameteri = rhs._glPointParameteri;
|
||||
_glPointParameterf = rhs._glPointParameterf;
|
||||
_glPointParameterfv = rhs._glPointParameterfv;
|
||||
}
|
||||
|
||||
void Point::Extensions::lowestCommonDenominator(const Extensions& rhs)
|
||||
{
|
||||
if (!rhs._isPointParametersSupported) _isPointParametersSupported = false;
|
||||
if (!rhs._isPointSpriteCoordOriginSupported) _isPointSpriteCoordOriginSupported = false;
|
||||
if (!rhs._glPointParameteri) _glPointParameteri = 0;
|
||||
if (!rhs._glPointParameterf) _glPointParameterf = 0;
|
||||
if (!rhs._glPointParameterfv) _glPointParameterfv = 0;
|
||||
}
|
||||
|
||||
void Point::Extensions::setupGLExtensions(unsigned int contextID)
|
||||
{
|
||||
_isPointParametersSupported = OSG_GL3_FEATURES ||
|
||||
strncmp((const char*)glGetString(GL_VERSION),"1.4",3)>=0 ||
|
||||
isGLExtensionSupported(contextID,"GL_ARB_point_parameters") ||
|
||||
isGLExtensionSupported(contextID,"GL_EXT_point_parameters") ||
|
||||
isGLExtensionSupported(contextID,"GL_SGIS_point_parameters");
|
||||
|
||||
_isPointSpriteCoordOriginSupported = OSG_GL3_FEATURES || strncmp((const char*)glGetString(GL_VERSION),"2.0",3)>=0;
|
||||
|
||||
setGLExtensionFuncPtr(_glPointParameteri, "glPointParameteri", "glPointParameteriARB");
|
||||
if (!_glPointParameteri) setGLExtensionFuncPtr(_glPointParameteri, "glPointParameteriEXT", "glPointParameteriSGIS");
|
||||
|
||||
setGLExtensionFuncPtr(_glPointParameterf, "glPointParameterf", "glPointParameterfARB");
|
||||
if (!_glPointParameterf) setGLExtensionFuncPtr(_glPointParameterf, "glPointParameterfEXT", "glPointParameterfSGIS");
|
||||
|
||||
setGLExtensionFuncPtr(_glPointParameterfv, "glPointParameterfv", "glPointParameterfvARB");
|
||||
if (!_glPointParameterfv) setGLExtensionFuncPtr(_glPointParameterfv, "glPointParameterfvEXT", "glPointParameterfvSGIS");
|
||||
}
|
||||
|
||||
void Point::Extensions::glPointParameteri(GLenum pname, GLint param) const
|
||||
{
|
||||
if (_glPointParameteri)
|
||||
{
|
||||
_glPointParameteri(pname, param);
|
||||
}
|
||||
else
|
||||
{
|
||||
OSG_WARN<<"Error: glPointParameteri not supported by OpenGL driver"<<std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void Point::Extensions::glPointParameterf(GLenum pname, GLfloat param) const
|
||||
{
|
||||
if (_glPointParameterf)
|
||||
{
|
||||
_glPointParameterf(pname, param);
|
||||
}
|
||||
else
|
||||
{
|
||||
OSG_WARN<<"Error: glPointParameterf not supported by OpenGL driver"<<std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void Point::Extensions::glPointParameterfv(GLenum pname, const GLfloat *params) const
|
||||
{
|
||||
if (_glPointParameterfv)
|
||||
{
|
||||
_glPointParameterfv(pname, params);
|
||||
}
|
||||
else
|
||||
{
|
||||
OSG_WARN<<"Error: glPointParameterfv not supported by OpenGL driver"<<std::endl;
|
||||
}
|
||||
}
|
||||
|
@ -42,68 +42,42 @@ int PointSprite::compare(const StateAttribute& sa) const
|
||||
|
||||
bool PointSprite::checkValidityOfAssociatedModes(osg::State& state) const
|
||||
{
|
||||
|
||||
bool modeValid = isPointSpriteSupported(state.getContextID());
|
||||
const GL2Extensions* extensions = state.get<GL2Extensions>();
|
||||
bool modeValid = extensions->isPointSpriteSupported;
|
||||
|
||||
#if defined( OSG_GLES1_AVAILABLE ) //point sprites don't exist on es 2.0
|
||||
state.setModeValidity(GL_POINT_SPRITE_OES, modeValid);
|
||||
#else
|
||||
state.setModeValidity(GL_POINT_SPRITE_ARB, modeValid);
|
||||
#endif
|
||||
|
||||
|
||||
return modeValid;
|
||||
}
|
||||
|
||||
void PointSprite::apply(osg::State& state) const
|
||||
{
|
||||
const GL2Extensions* extensions = state.get<GL2Extensions>();
|
||||
#if defined( OSG_GL3_AVAILABLE )
|
||||
|
||||
const Point::Extensions* extensions = Point::getExtensions(state.getContextID(),true);
|
||||
extensions->glPointParameteri(GL_POINT_SPRITE_COORD_ORIGIN,_coordOriginMode);
|
||||
|
||||
extensions->glPointParameteri(GL_POINT_SPRITE_COORD_ORIGIN, _coordOriginMode);
|
||||
|
||||
#elif defined( OSG_GLES1_AVAILABLE ) //point sprites don't exist on es 2.0
|
||||
|
||||
if(!isPointSpriteSupported(state.getContextID())) return;
|
||||
|
||||
|
||||
if (!extensions->isPointSpriteSupported) return;
|
||||
|
||||
glTexEnvi(GL_POINT_SPRITE_OES, GL_COORD_REPLACE_OES, 1);
|
||||
|
||||
|
||||
#elif defined( OSG_GL_FIXED_FUNCTION_AVAILABLE )
|
||||
|
||||
if(!isPointSpriteSupported(state.getContextID())) return;
|
||||
if (!extensions->isPointSpriteSupported) return;
|
||||
|
||||
glTexEnvi(GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, 1);
|
||||
|
||||
const Point::Extensions* extensions = Point::getExtensions(state.getContextID(),true);
|
||||
|
||||
if (extensions->isPointSpriteCoordOriginSupported())
|
||||
extensions->glPointParameteri(GL_POINT_SPRITE_COORD_ORIGIN,_coordOriginMode);
|
||||
if (extensions->isPointSpriteCoordOriginSupported)
|
||||
extensions->glPointParameteri(GL_POINT_SPRITE_COORD_ORIGIN, _coordOriginMode);
|
||||
|
||||
#else
|
||||
OSG_NOTICE<<"Warning: PointSprite::apply(State&) - not supported."<<std::endl;
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
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 = OSG_GL3_FEATURES || isGLExtensionSupported(contextID, "GL_ARB_point_sprite") || isGLExtensionSupported(contextID, "GL_OES_point_sprite") || isGLExtensionSupported(contextID, "GL_NV_point_sprite");
|
||||
}
|
||||
|
||||
return s_extensions[contextID].supported;
|
||||
}
|
||||
|
@ -52,90 +52,13 @@ int PrimitiveRestartIndex::compare(const StateAttribute& sa) const
|
||||
void PrimitiveRestartIndex::apply(State& state) const
|
||||
{
|
||||
// get "per-context" extensions
|
||||
const unsigned int contextID = state.getContextID();
|
||||
const Extensions* extensions = getExtensions(contextID,true);
|
||||
|
||||
if ( (extensions->isOpenGL31Supported()) || (extensions->isPrimitiveRestartIndexNVSupported()) )
|
||||
const GL2Extensions* extensions = state.get<GL2Extensions>();
|
||||
if (extensions->glPrimitiveRestartIndex)
|
||||
{
|
||||
extensions->glPrimitiveRestartIndex( _restartIndex );
|
||||
return;
|
||||
}
|
||||
|
||||
OSG_WARN << "PrimitiveRestartIndex failed as the required graphics capabilities were\n"
|
||||
" not found (contextID " << contextID << "). OpenGL 3.1 or \n"
|
||||
" GL_NV_primitive_restart extension is required." << std::endl;
|
||||
OSG_WARN << "PrimitiveRestartIndex failed as the required graphics capabilities were not found\n"
|
||||
" OpenGL 3.1 or GL_NV_primitive_restart extension is required." << std::endl;
|
||||
}
|
||||
|
||||
|
||||
typedef buffered_value< ref_ptr<PrimitiveRestartIndex::Extensions> > BufferedExtensions;
|
||||
static BufferedExtensions s_extensions;
|
||||
|
||||
PrimitiveRestartIndex::Extensions* PrimitiveRestartIndex::getExtensions(unsigned int contextID,bool createIfNotInitalized)
|
||||
{
|
||||
if (!s_extensions[contextID] && createIfNotInitalized) s_extensions[contextID] = new Extensions(contextID);
|
||||
return s_extensions[contextID].get();
|
||||
}
|
||||
|
||||
void PrimitiveRestartIndex::setExtensions(unsigned int contextID,Extensions* extensions)
|
||||
{
|
||||
s_extensions[contextID] = extensions;
|
||||
}
|
||||
|
||||
PrimitiveRestartIndex::Extensions::Extensions(unsigned int contextID)
|
||||
{
|
||||
setupGLExtensions(contextID);
|
||||
}
|
||||
|
||||
PrimitiveRestartIndex::Extensions::Extensions(const Extensions& rhs):
|
||||
Referenced()
|
||||
{
|
||||
_isOpenGL31Supported = rhs._isOpenGL31Supported;
|
||||
_isPrimitiveRestartIndexNVSupported = rhs._isPrimitiveRestartIndexNVSupported;
|
||||
_glPrimitiveRestartIndex = rhs._glPrimitiveRestartIndex;
|
||||
}
|
||||
|
||||
void PrimitiveRestartIndex::Extensions::lowestCommonDenominator(const Extensions& rhs)
|
||||
{
|
||||
if (!rhs._isOpenGL31Supported) _isOpenGL31Supported = false;
|
||||
if (!rhs._isPrimitiveRestartIndexNVSupported) _isPrimitiveRestartIndexNVSupported = false;
|
||||
if (!rhs._glPrimitiveRestartIndex) _glPrimitiveRestartIndex = NULL;
|
||||
}
|
||||
|
||||
void PrimitiveRestartIndex::Extensions::setupGLExtensions(unsigned int contextID)
|
||||
{
|
||||
// extension support
|
||||
_isPrimitiveRestartIndexNVSupported = isGLExtensionSupported(contextID, "GL_NV_primitive_restart");
|
||||
_isOpenGL31Supported = getGLVersionNumber() >= 3.1;
|
||||
_glPrimitiveRestartIndex = NULL;
|
||||
|
||||
// function pointers
|
||||
if (_isOpenGL31Supported)
|
||||
setGLExtensionFuncPtr(_glPrimitiveRestartIndex, "glPrimitiveRestartIndex");
|
||||
else if (_isPrimitiveRestartIndexNVSupported)
|
||||
setGLExtensionFuncPtr(_glPrimitiveRestartIndex, "glPrimitiveRestartIndexNV");
|
||||
|
||||
// protect against buggy drivers (maybe not necessary)
|
||||
if (!_glPrimitiveRestartIndex) _isPrimitiveRestartIndexNVSupported = false;
|
||||
|
||||
// notify
|
||||
if( _isOpenGL31Supported )
|
||||
{
|
||||
OSG_INFO << "PrimitiveRestartIndex is going to use OpenGL 3.1 API (contextID " << contextID << ")." << std::endl;
|
||||
}
|
||||
else if( _isPrimitiveRestartIndexNVSupported )
|
||||
{
|
||||
OSG_INFO << "PrimitiveRestartIndex is going to use GL_NV_primitive_restart extension (contextID " << contextID << ")." << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
OSG_INFO << "PrimitiveRestartIndex did not found required graphics capabilities\n"
|
||||
" (contextID " << contextID << "). OpenGL 3.1 or \n"
|
||||
" GL_NV_primitive_restart extension is required." << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void PrimitiveRestartIndex::Extensions::glPrimitiveRestartIndex( GLuint index ) const
|
||||
{
|
||||
_glPrimitiveRestartIndex( index );
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user