Moved osg::Drawable::Extensions into osg::GL2Extensions

git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14575 16af8721-9629-0410-8352-f15c8da7e697
This commit is contained in:
Robert Osfield 2014-12-05 17:26:42 +00:00
parent 1ce8029f39
commit f634152de0
13 changed files with 183 additions and 1026 deletions

View File

@ -495,246 +495,6 @@ class OSG_EXPORT Drawable : public Node
* so one cannot modify it.*/ * so one cannot modify it.*/
virtual void accept(PrimitiveIndexFunctor&) const {} virtual void accept(PrimitiveIndexFunctor&) 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 setVertexProgramSupported(bool flag) { _isVertexProgramSupported=flag; }
bool isVertexProgramSupported() const { return _isVertexProgramSupported; }
void setSecondaryColorSupported(bool flag) { _isSecondaryColorSupported=flag; }
bool isSecondaryColorSupported() const { return _isSecondaryColorSupported; }
void setFogCoordSupported(bool flag) { _isFogCoordSupported=flag; }
bool isFogCoordSupported() const { return _isFogCoordSupported; }
void setMultiTexSupported(bool flag) { _isMultiTexSupported=flag; }
bool isMultiTexSupported() const { return _isMultiTexSupported; }
void setOcclusionQuerySupported(bool flag) { _isOcclusionQuerySupported=flag; }
bool isOcclusionQuerySupported() const { return _isOcclusionQuerySupported; }
void setARBOcclusionQuerySupported(bool flag) { _isARBOcclusionQuerySupported=flag; }
bool isARBOcclusionQuerySupported() const { return _isARBOcclusionQuerySupported; }
void setTimerQuerySupported(bool flag) { _isTimerQuerySupported = flag; }
bool isTimerQuerySupported() const { return _isTimerQuerySupported; }
void setARBTimerQuerySupported(bool flag) { _isARBTimerQuerySupported = flag; }
bool isARBTimerQuerySupported() const { return _isARBTimerQuerySupported; }
void glSecondaryColor3ubv(const GLubyte* coord) const;
void glSecondaryColor3fv(const GLfloat* coord) const;
void glFogCoordfv(const GLfloat* coord) const;
void glMultiTexCoord1f(GLenum target,GLfloat coord) const;
void glMultiTexCoord2fv(GLenum target,const GLfloat* coord) const;
void glMultiTexCoord3fv(GLenum target,const GLfloat* coord) const;
void glMultiTexCoord4fv(GLenum target,const GLfloat* coord) const;
void glMultiTexCoord1d(GLenum target,GLdouble coord) const;
void glMultiTexCoord2dv(GLenum target,const GLdouble* coord) const;
void glMultiTexCoord3dv(GLenum target,const GLdouble* coord) const;
void glMultiTexCoord4dv(GLenum target,const GLdouble* coord) const;
void glVertexAttrib1s(unsigned int index, GLshort s) const;
void glVertexAttrib1f(unsigned int index, GLfloat f) const;
void glVertexAttrib1d(unsigned int index, GLdouble f) const;
void glVertexAttrib2fv(unsigned int index, const GLfloat * v) const;
void glVertexAttrib3fv(unsigned int index, const GLfloat * v) const;
void glVertexAttrib4fv(unsigned int index, const GLfloat * v) const;
void glVertexAttrib2dv(unsigned int index, const GLdouble * v) const;
void glVertexAttrib3dv(unsigned int index, const GLdouble * v) const;
void glVertexAttrib4dv(unsigned int index, const GLdouble * v) const;
void glVertexAttrib4ubv(unsigned int index, const GLubyte * v) const;
void glVertexAttrib4Nubv(unsigned int index, const GLubyte * v) const;
void glGenBuffers (GLsizei n, GLuint *buffers) const;
void glBindBuffer (GLenum target, GLuint buffer) const;
void glBufferData (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage) const;
void glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data) const;
void glDeleteBuffers (GLsizei n, const GLuint *buffers) const;
GLboolean glIsBuffer (GLuint buffer) const;
void glGetBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data) const;
GLvoid* glMapBuffer (GLenum target, GLenum access) const;
GLboolean glUnmapBuffer (GLenum target) const;
void glGetBufferParameteriv (GLenum target, GLenum pname, GLint *params) const;
void glGetBufferPointerv (GLenum target, GLenum pname, GLvoid* *params) const;
void glGenOcclusionQueries( GLsizei n, GLuint *ids ) const;
void glDeleteOcclusionQueries( GLsizei n, const GLuint *ids ) const;
GLboolean glIsOcclusionQuery( GLuint id ) const;
void glBeginOcclusionQuery( GLuint id ) const;
void glEndOcclusionQuery() const;
void glGetOcclusionQueryiv( GLuint id, GLenum pname, GLint *params ) const;
void glGetOcclusionQueryuiv( GLuint id, GLenum pname, GLuint *params ) const;
void glGetQueryiv(GLenum target, GLenum pname, GLint *params) const;
void glGenQueries(GLsizei n, GLuint *ids) const;
void glBeginQuery(GLenum target, GLuint id) const;
void glEndQuery(GLenum target) const;
void glQueryCounter(GLuint id, GLenum target) const;
GLboolean glIsQuery(GLuint id) const;
void glDeleteQueries(GLsizei n, const GLuint *ids) const;
void glGetQueryObjectiv(GLuint id, GLenum pname, GLint *params) const;
void glGetQueryObjectuiv(GLuint id, GLenum pname, GLuint *params) const;
void glGetQueryObjectui64v(GLuint id, GLenum pname, GLuint64 *params) const;
void glGetInteger64v(GLenum pname, GLint64 *params) const;
protected:
friend class ArrayDispatchers;
typedef void (GL_APIENTRY * FogCoordProc) (const GLfloat* coord);
typedef void (GL_APIENTRY * VertexAttrib1sProc) (GLuint index, GLshort s);
typedef void (GL_APIENTRY * VertexAttrib1fProc) (GLuint index, GLfloat f);
typedef void (GL_APIENTRY * VertexAttrib1dProc) (GLuint index, GLdouble f);
typedef void (GL_APIENTRY * VertexAttribfvProc) (GLuint index, const GLfloat * v);
typedef void (GL_APIENTRY * VertexAttribdvProc) (GLuint index, const GLdouble * v);
typedef void (GL_APIENTRY * VertexAttribubvProc) (GLuint index, const GLubyte * v);
typedef void (GL_APIENTRY * SecondaryColor3ubvProc) (const GLubyte* coord);
typedef void (GL_APIENTRY * SecondaryColor3fvProc) (const GLfloat* coord);
typedef void (GL_APIENTRY * MultiTexCoord1fProc) (GLenum target,GLfloat coord);
typedef void (GL_APIENTRY * MultiTexCoordfvProc) (GLenum target,const GLfloat* coord);
typedef void (GL_APIENTRY * MultiTexCoord1dProc) (GLenum target,GLdouble coord);
typedef void (GL_APIENTRY * MultiTexCoorddvProc) (GLenum target,const GLdouble* coord);
typedef void (GL_APIENTRY * GenBuffersProc) (GLsizei n, GLuint *buffers);
typedef void (GL_APIENTRY * BindBufferProc) (GLenum target, GLuint buffer);
typedef void (GL_APIENTRY * BufferDataProc) (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage);
typedef void (GL_APIENTRY * BufferSubDataProc) (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data);
typedef void (GL_APIENTRY * DeleteBuffersProc) (GLsizei n, const GLuint *buffers);
typedef GLboolean (GL_APIENTRY * IsBufferProc) (GLuint buffer);
typedef void (GL_APIENTRY * GetBufferSubDataProc) (GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data);
typedef GLvoid* (GL_APIENTRY * MapBufferProc) (GLenum target, GLenum access);
typedef GLboolean (GL_APIENTRY * UnmapBufferProc) (GLenum target);
typedef void (GL_APIENTRY * GetBufferParameterivProc) (GLenum target, GLenum pname, GLint *params);
typedef void (GL_APIENTRY * GetBufferPointervProc) (GLenum target, GLenum pname, GLvoid* *params);
typedef void (GL_APIENTRY * GenOcclusionQueriesProc) ( GLsizei n, GLuint *ids );
typedef void (GL_APIENTRY * DeleteOcclusionQueriesProc) ( GLsizei n, const GLuint *ids );
typedef GLboolean (GL_APIENTRY * IsOcclusionQueryProc) ( GLuint id );
typedef void (GL_APIENTRY * BeginOcclusionQueryProc) ( GLuint id );
typedef void (GL_APIENTRY * EndOcclusionQueryProc) ();
typedef void (GL_APIENTRY * GetOcclusionQueryivProc) ( GLuint id, GLenum pname, GLint *params );
typedef void (GL_APIENTRY * GetOcclusionQueryuivProc) ( GLuint id, GLenum pname, GLuint *params );
typedef void (GL_APIENTRY * GetOcclusionQueryui64vProc) ( GLuint id, GLenum pname, GLuint64 *params );
typedef void (GL_APIENTRY *GenQueriesProc) (GLsizei n, GLuint *ids);
typedef void (GL_APIENTRY *DeleteQueriesProc) (GLsizei n, const GLuint *ids);
typedef GLboolean (GL_APIENTRY *IsQueryProc) (GLuint id);
typedef void (GL_APIENTRY *BeginQueryProc) (GLenum target, GLuint id);
typedef void (GL_APIENTRY *EndQueryProc) (GLenum target);
typedef void (GL_APIENTRY *QueryCounterProc)(GLuint id, GLenum target);
typedef void (GL_APIENTRY *GetQueryivProc) (GLenum target, GLenum pname, GLint *params);
typedef void (GL_APIENTRY *GetQueryObjectivProc) (GLuint id, GLenum pname, GLint *params);
typedef void (GL_APIENTRY *GetQueryObjectuivProc) (GLuint id, GLenum pname, GLuint *params);
typedef void (GL_APIENTRY *GetQueryObjectui64vProc) (GLuint id, GLenum pname, GLuint64 *params);
typedef void (GL_APIENTRY *GetInteger64vProc) (GLenum pname, GLint64 *params);
~Extensions() {}
bool _isVertexProgramSupported;
bool _isSecondaryColorSupported;
bool _isFogCoordSupported;
bool _isMultiTexSupported;
bool _isOcclusionQuerySupported;
bool _isARBOcclusionQuerySupported;
bool _isTimerQuerySupported;
bool _isARBTimerQuerySupported;
FogCoordProc _glFogCoordfv;
SecondaryColor3ubvProc _glSecondaryColor3ubv;
SecondaryColor3fvProc _glSecondaryColor3fv;
VertexAttrib1sProc _glVertexAttrib1s;
VertexAttrib1fProc _glVertexAttrib1f;
VertexAttrib1dProc _glVertexAttrib1d;
VertexAttribfvProc _glVertexAttrib1fv;
VertexAttribfvProc _glVertexAttrib2fv;
VertexAttribfvProc _glVertexAttrib3fv;
VertexAttribfvProc _glVertexAttrib4fv;
VertexAttribdvProc _glVertexAttrib2dv;
VertexAttribdvProc _glVertexAttrib3dv;
VertexAttribdvProc _glVertexAttrib4dv;
VertexAttribubvProc _glVertexAttrib4ubv;
VertexAttribubvProc _glVertexAttrib4Nubv;
MultiTexCoord1fProc _glMultiTexCoord1f;
MultiTexCoordfvProc _glMultiTexCoord1fv;
MultiTexCoordfvProc _glMultiTexCoord2fv;
MultiTexCoordfvProc _glMultiTexCoord3fv;
MultiTexCoordfvProc _glMultiTexCoord4fv;
MultiTexCoord1dProc _glMultiTexCoord1d;
MultiTexCoorddvProc _glMultiTexCoord2dv;
MultiTexCoorddvProc _glMultiTexCoord3dv;
MultiTexCoorddvProc _glMultiTexCoord4dv;
GenBuffersProc _glGenBuffers;
BindBufferProc _glBindBuffer;
BufferDataProc _glBufferData;
BufferSubDataProc _glBufferSubData;
DeleteBuffersProc _glDeleteBuffers;
IsBufferProc _glIsBuffer;
GetBufferSubDataProc _glGetBufferSubData;
MapBufferProc _glMapBuffer;
UnmapBufferProc _glUnmapBuffer;
GetBufferParameterivProc _glGetBufferParameteriv;
GetBufferPointervProc _glGetBufferPointerv;
GenOcclusionQueriesProc _glGenOcclusionQueries;
DeleteOcclusionQueriesProc _glDeleteOcclusionQueries;
IsOcclusionQueryProc _glIsOcclusionQuery;
BeginOcclusionQueryProc _glBeginOcclusionQuery;
EndOcclusionQueryProc _glEndOcclusionQuery;
GetOcclusionQueryivProc _glGetOcclusionQueryiv;
GetOcclusionQueryuivProc _glGetOcclusionQueryuiv;
GenQueriesProc _gl_gen_queries_arb;
DeleteQueriesProc _gl_delete_queries_arb;
IsQueryProc _gl_is_query_arb;
BeginQueryProc _gl_begin_query_arb;
EndQueryProc _gl_end_query_arb;
QueryCounterProc _glQueryCounter;
GetQueryivProc _gl_get_queryiv_arb;
GetQueryObjectivProc _gl_get_query_objectiv_arb;
GetQueryObjectuivProc _gl_get_query_objectuiv_arb;
GetQueryObjectui64vProc _gl_get_query_objectui64v;
GetInteger64vProc _glGetInteger64v;
};
/** 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 is
* only 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: protected:
Drawable& operator = (const Drawable&) { return *this;} Drawable& operator = (const Drawable&) { return *this;}

View File

@ -595,6 +595,7 @@ class OSG_EXPORT GL2Extensions : public osg::Referenced
bool isGetProgramBinarySupported; bool isGetProgramBinarySupported;
bool isGpuShaderFp64Supported; bool isGpuShaderFp64Supported;
bool isShaderAtomicCountersSupported; bool isShaderAtomicCountersSupported;
bool isRectangleSupported;
void (GL_APIENTRY * glBlendEquationSeparate)(GLenum modeRGB, GLenum modeAlpha); void (GL_APIENTRY * glBlendEquationSeparate)(GLenum modeRGB, GLenum modeAlpha);
void (GL_APIENTRY * glDrawBuffers)(GLsizei n, const GLenum *bufs); void (GL_APIENTRY * glDrawBuffers)(GLsizei n, const GLenum *bufs);
@ -777,9 +778,80 @@ class OSG_EXPORT GL2Extensions : public osg::Referenced
void (GL_APIENTRY * glBlendFuncSeparatei) (GLuint buf, GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha) ; void (GL_APIENTRY * glBlendFuncSeparatei) (GLuint buf, GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha) ;
// Vertex Array extensions
bool isVertexProgramSupported;
bool isSecondaryColorSupported;
bool isFogCoordSupported;
bool isMultiTexSupported;
bool isOcclusionQuerySupported;
bool isARBOcclusionQuerySupported;
bool isTimerQuerySupported;
bool isARBTimerQuerySupported;
void (GL_APIENTRY * glSecondaryColor3ubv) (const GLubyte* coord);
void (GL_APIENTRY * glSecondaryColor3fv) (const GLfloat* coord);
void (GL_APIENTRY * glFogCoordfv) (const GLfloat* coord);
void (GL_APIENTRY * glMultiTexCoord1f) (GLenum target,GLfloat coord);
void (GL_APIENTRY * glMultiTexCoord1fv) (GLenum target,const GLfloat* coord);
void (GL_APIENTRY * glMultiTexCoord2fv) (GLenum target,const GLfloat* coord);
void (GL_APIENTRY * glMultiTexCoord3fv) (GLenum target,const GLfloat* coord);
void (GL_APIENTRY * glMultiTexCoord4fv) (GLenum target,const GLfloat* coord);
void (GL_APIENTRY * glMultiTexCoord1d) (GLenum target,GLdouble coord);
void (GL_APIENTRY * glMultiTexCoord1dv) (GLenum target,const GLdouble* coord);
void (GL_APIENTRY * glMultiTexCoord2dv) (GLenum target,const GLdouble* coord);
void (GL_APIENTRY * glMultiTexCoord3dv) (GLenum target,const GLdouble* coord);
void (GL_APIENTRY * glMultiTexCoord4dv) (GLenum target,const GLdouble* coord);
#if 0
void (GL_APIENTRY * glVertexAttrib1s) (unsigned int index, GLshort s);
void (GL_APIENTRY * glVertexAttrib1f) (unsigned int index, GLfloat f);
void (GL_APIENTRY * glVertexAttrib1d) (unsigned int index, GLdouble f);
void (GL_APIENTRY * glVertexAttrib2fv) (unsigned int index, const GLfloat * v);
void (GL_APIENTRY * glVertexAttrib3fv) (unsigned int index, const GLfloat * v);
void (GL_APIENTRY * glVertexAttrib4fv) (unsigned int index, const GLfloat * v);
void (GL_APIENTRY * glVertexAttrib2dv) (unsigned int index, const GLdouble * v);
void (GL_APIENTRY * glVertexAttrib3dv) (unsigned int index, const GLdouble * v);
void (GL_APIENTRY * glVertexAttrib4dv) (unsigned int index, const GLdouble * v);
void (GL_APIENTRY * glVertexAttrib4ubv) (unsigned int index, const GLubyte * v);
void (GL_APIENTRY * glVertexAttrib4Nubv) (unsigned int index, const GLubyte * v);
void (GL_APIENTRY * glGenBuffers) (GLsizei n, GLuint *buffers);
void (GL_APIENTRY * glBindBuffer (GLenum target, GLuint buffer);
void (GL_APIENTRY * glBufferData (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage);
void (GL_APIENTRY * glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data);
void (GL_APIENTRY * glDeleteBuffers (GLsizei n, const GLuint *buffers);
GLboolean (GL_APIENTRY * glIsBuffer (GLuint buffer);
void (GL_APIENTRY * glGetBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data);
GLvoid* (GL_APIENTRY * glMapBuffer (GLenum target, GLenum access);
GLboolean (GL_APIENTRY * glUnmapBuffer (GLenum target);
void (GL_APIENTRY * glGetBufferParameteriv (GLenum target, GLenum pname, GLint *params);
void (GL_APIENTRY * glGetBufferPointerv (GLenum target, GLenum pname, GLvoid* *params);
#endif
void (GL_APIENTRY * glGenOcclusionQueries) ( GLsizei n, GLuint *ids );
void (GL_APIENTRY * glDeleteOcclusionQueries) ( GLsizei n, const GLuint *ids );
GLboolean (GL_APIENTRY * glIsOcclusionQuery) ( GLuint id );
void (GL_APIENTRY * glBeginOcclusionQuery) ( GLuint id );
void (GL_APIENTRY * glEndOcclusionQuery) ();
void (GL_APIENTRY * glGetOcclusionQueryiv) ( GLuint id, GLenum pname, GLint *params );
void (GL_APIENTRY * glGetOcclusionQueryuiv) ( GLuint id, GLenum pname, GLuint *params );
void (GL_APIENTRY * glGetQueryiv) (GLenum target, GLenum pname, GLint *params);
void (GL_APIENTRY * glGenQueries) (GLsizei n, GLuint *ids);
void (GL_APIENTRY * glBeginQuery) (GLenum target, GLuint id);
void (GL_APIENTRY * glEndQuery) (GLenum target);
void (GL_APIENTRY * glQueryCounter) (GLuint id, GLenum target);
GLboolean (GL_APIENTRY * glIsQuery) (GLuint id);
void (GL_APIENTRY * glDeleteQueries) (GLsizei n, const GLuint *ids);
void (GL_APIENTRY * glGetQueryObjectiv) (GLuint id, GLenum pname, GLint *params);
void (GL_APIENTRY * glGetQueryObjectuiv) (GLuint id, GLenum pname, GLuint *params);
void (GL_APIENTRY * glGetQueryObjectui64v) (GLuint id, GLenum pname, GLuint64 *params);
void (GL_APIENTRY * glGetInteger64v) (GLenum pname, GLint64 *params);
}; };
} }
#endif #endif

View File

@ -173,7 +173,7 @@ class OSG_EXPORT State : public Referenced
* Note, safe to call outwith a the graphics context thread associated with this osg::State. * Note, safe to call outwith a the graphics context thread associated with this osg::State.
* Returns NULL if the desired extension object has not been created yet.*/ * Returns NULL if the desired extension object has not been created yet.*/
template<typename T> template<typename T>
const T* getExisting() const const T* get() const
{ {
const std::type_info* id(&typeid(T)); const std::type_info* id(&typeid(T));
ExtensionMap::const_iterator itr = _extensionMap.find(id); ExtensionMap::const_iterator itr = _extensionMap.find(id);
@ -2778,7 +2778,7 @@ inline bool State::setActiveTextureUnit( unsigned int unit )
// forward declare speciailization of State::get() method // forward declare speciailization of State::get() method
template<> inline GL2Extensions* State::get<GL2Extensions>() { return _gl2Extentsions.get(); } template<> inline GL2Extensions* State::get<GL2Extensions>() { return _gl2Extentsions.get(); }
template<> inline const GL2Extensions* State::getExisting<GL2Extensions>() const { return _gl2Extentsions.get(); } template<> inline const GL2Extensions* State::get<GL2Extensions>() const { return _gl2Extentsions.get(); }
} }

View File

@ -35,7 +35,7 @@ class OSGVIEWER_EXPORT OpenGLQuerySupport : public osg::Referenced
virtual void initialize(osg::State* state, osg::Timer_t startTick); virtual void initialize(osg::State* state, osg::Timer_t startTick);
protected: protected:
const osg::Drawable::Extensions* _extensions; const osg::GL2Extensions* _extensions;
}; };
class OSGVIEWER_EXPORT Renderer : public osg::GraphicsOperation class OSGVIEWER_EXPORT Renderer : public osg::GraphicsOperation

View File

@ -196,7 +196,7 @@ void ArrayDispatchers::init()
#ifdef OSG_GL_VERTEX_FUNCS_AVAILABLE #ifdef OSG_GL_VERTEX_FUNCS_AVAILABLE
Drawable::Extensions* extensions = Drawable::getExtensions(_state->getContextID(),true); GL2Extensions* extensions = _state->get<GL2Extensions>();
#ifndef OSG_GLES1_AVAILABLE #ifndef OSG_GLES1_AVAILABLE
_vertexDispatchers->assign<GLfloat>(Array::Vec2ArrayType, glVertex2fv, 2); _vertexDispatchers->assign<GLfloat>(Array::Vec2ArrayType, glVertex2fv, 2);
@ -216,9 +216,9 @@ void ArrayDispatchers::init()
_colorDispatchers->assign<GLdouble>(Array::Vec3dArrayType, glColor3dv, 3); _colorDispatchers->assign<GLdouble>(Array::Vec3dArrayType, glColor3dv, 3);
_colorDispatchers->assign<GLdouble>(Array::Vec4dArrayType, glColor4dv, 4); _colorDispatchers->assign<GLdouble>(Array::Vec4dArrayType, glColor4dv, 4);
_secondaryColorDispatchers->assign<GLfloat>(Array::Vec3ArrayType, extensions->_glSecondaryColor3fv, 3); _secondaryColorDispatchers->assign<GLfloat>(Array::Vec3ArrayType, extensions->glSecondaryColor3fv, 3);
_fogCoordDispatchers->assign<GLfloat>(Array::FloatArrayType, extensions->_glFogCoordfv, 1); _fogCoordDispatchers->assign<GLfloat>(Array::FloatArrayType, extensions->glFogCoordfv, 1);
#endif #endif
// pre allocate. // pre allocate.
@ -281,7 +281,7 @@ AttributeDispatch* ArrayDispatchers::vertexAttribDispatcher(unsigned int unit, A
void ArrayDispatchers::assignTexCoordDispatchers(unsigned int unit) void ArrayDispatchers::assignTexCoordDispatchers(unsigned int unit)
{ {
#if defined(OSG_GL_VERTEX_FUNCS_AVAILABLE) && !defined(OSG_GLES1_AVAILABLE) #if defined(OSG_GL_VERTEX_FUNCS_AVAILABLE) && !defined(OSG_GLES1_AVAILABLE)
Drawable::Extensions* extensions = Drawable::getExtensions(_state->getContextID(),true); GL2Extensions* extensions = _state->get<GL2Extensions>();
#endif #endif
for(unsigned int i=_texCoordDispatchers.size(); i<=unit; ++i) for(unsigned int i=_texCoordDispatchers.size(); i<=unit; ++i)
@ -300,10 +300,10 @@ void ArrayDispatchers::assignTexCoordDispatchers(unsigned int unit)
else else
{ {
#if defined(OSG_GL_VERTEX_FUNCS_AVAILABLE) && !defined(OSG_GLES1_AVAILABLE) #if defined(OSG_GL_VERTEX_FUNCS_AVAILABLE) && !defined(OSG_GLES1_AVAILABLE)
texCoordDispatcher.targetAssign<GLenum, GLfloat>((GLenum)(GL_TEXTURE0+i), Array::FloatArrayType, extensions->_glMultiTexCoord1fv, 1); texCoordDispatcher.targetAssign<GLenum, GLfloat>((GLenum)(GL_TEXTURE0+i), Array::FloatArrayType, extensions->glMultiTexCoord1fv, 1);
texCoordDispatcher.targetAssign<GLenum, GLfloat>((GLenum)(GL_TEXTURE0+i), Array::Vec2ArrayType, extensions->_glMultiTexCoord2fv, 2); texCoordDispatcher.targetAssign<GLenum, GLfloat>((GLenum)(GL_TEXTURE0+i), Array::Vec2ArrayType, extensions->glMultiTexCoord2fv, 2);
texCoordDispatcher.targetAssign<GLenum, GLfloat>((GLenum)(GL_TEXTURE0+i), Array::Vec3ArrayType, extensions->_glMultiTexCoord3fv, 3); texCoordDispatcher.targetAssign<GLenum, GLfloat>((GLenum)(GL_TEXTURE0+i), Array::Vec3ArrayType, extensions->glMultiTexCoord3fv, 3);
texCoordDispatcher.targetAssign<GLenum, GLfloat>((GLenum)(GL_TEXTURE0+i), Array::Vec4ArrayType, extensions->_glMultiTexCoord4fv, 4); texCoordDispatcher.targetAssign<GLenum, GLfloat>((GLenum)(GL_TEXTURE0+i), Array::Vec4ArrayType, extensions->glMultiTexCoord4fv, 4);
#endif #endif
} }
} }
@ -312,16 +312,16 @@ void ArrayDispatchers::assignTexCoordDispatchers(unsigned int unit)
void ArrayDispatchers::assignVertexAttribDispatchers(unsigned int unit) void ArrayDispatchers::assignVertexAttribDispatchers(unsigned int unit)
{ {
Drawable::Extensions* extensions = Drawable::getExtensions(_state->getContextID(),true); GL2Extensions* extensions = _state->get<GL2Extensions>();
for(unsigned int i=_vertexAttribDispatchers.size(); i<=unit; ++i) for(unsigned int i=_vertexAttribDispatchers.size(); i<=unit; ++i)
{ {
_vertexAttribDispatchers.push_back(new AttributeDispatchMap()); _vertexAttribDispatchers.push_back(new AttributeDispatchMap());
AttributeDispatchMap& vertexAttribDispatcher = *_vertexAttribDispatchers[i]; AttributeDispatchMap& vertexAttribDispatcher = *_vertexAttribDispatchers[i];
vertexAttribDispatcher.targetAssign<GLuint, GLfloat>(i, Array::FloatArrayType, extensions->_glVertexAttrib1fv, 1); vertexAttribDispatcher.targetAssign<GLuint, GLfloat>(i, Array::FloatArrayType, extensions->glVertexAttrib1fv, 1);
vertexAttribDispatcher.targetAssign<GLuint, GLfloat>(i, Array::Vec2ArrayType, extensions->_glVertexAttrib2fv, 2); vertexAttribDispatcher.targetAssign<GLuint, GLfloat>(i, Array::Vec2ArrayType, extensions->glVertexAttrib2fv, 2);
vertexAttribDispatcher.targetAssign<GLuint, GLfloat>(i, Array::Vec3ArrayType, extensions->_glVertexAttrib3fv, 3); vertexAttribDispatcher.targetAssign<GLuint, GLfloat>(i, Array::Vec3ArrayType, extensions->glVertexAttrib3fv, 3);
vertexAttribDispatcher.targetAssign<GLuint, GLfloat>(i, Array::Vec4ArrayType, extensions->_glVertexAttrib4fv, 4); vertexAttribDispatcher.targetAssign<GLuint, GLfloat>(i, Array::Vec4ArrayType, extensions->glVertexAttrib4fv, 4);
} }
} }

View File

@ -627,729 +627,3 @@ void Drawable::setBound(const BoundingBox& bb) const
_boundingBox = bb; _boundingBox = bb;
_boundingBoxComputed = true; _boundingBoxComputed = true;
} }
//////////////////////////////////////////////////////////////////////////////
//
// Extension support
//
typedef buffered_value< ref_ptr<Drawable::Extensions> > BufferedExtensions;
static BufferedExtensions s_extensions;
Drawable::Extensions* Drawable::getExtensions(unsigned int contextID,bool createIfNotInitalized)
{
if (!s_extensions[contextID] && createIfNotInitalized) s_extensions[contextID] = new Drawable::Extensions(contextID);
return s_extensions[contextID].get();
}
void Drawable::setExtensions(unsigned int contextID,Extensions* extensions)
{
s_extensions[contextID] = extensions;
}
Drawable::Extensions::Extensions(unsigned int contextID)
{
setupGLExtensions(contextID);
}
Drawable::Extensions::Extensions(const Extensions& rhs):
Referenced()
{
_isVertexProgramSupported = rhs._isVertexProgramSupported;
_isSecondaryColorSupported = rhs._isSecondaryColorSupported;
_isFogCoordSupported = rhs._isFogCoordSupported;
_isMultiTexSupported = rhs._isMultiTexSupported;
_isOcclusionQuerySupported = rhs._isOcclusionQuerySupported;
_isARBOcclusionQuerySupported = rhs._isARBOcclusionQuerySupported;
_isTimerQuerySupported = rhs._isTimerQuerySupported;
_isARBTimerQuerySupported = rhs._isARBTimerQuerySupported;
_glFogCoordfv = rhs._glFogCoordfv;
_glSecondaryColor3ubv = rhs._glSecondaryColor3ubv;
_glSecondaryColor3fv = rhs._glSecondaryColor3fv;
_glMultiTexCoord1f = rhs._glMultiTexCoord1f;
_glMultiTexCoord2fv = rhs._glMultiTexCoord2fv;
_glMultiTexCoord3fv = rhs._glMultiTexCoord3fv;
_glMultiTexCoord4fv = rhs._glMultiTexCoord4fv;
_glVertexAttrib1s = rhs._glVertexAttrib1s;
_glVertexAttrib1f = rhs._glVertexAttrib1f;
_glVertexAttrib2fv = rhs._glVertexAttrib2fv;
_glVertexAttrib3fv = rhs._glVertexAttrib3fv;
_glVertexAttrib4fv = rhs._glVertexAttrib4fv;
_glVertexAttrib4ubv = rhs._glVertexAttrib4ubv;
_glVertexAttrib4Nubv = rhs._glVertexAttrib4Nubv;
_glGenBuffers = rhs._glGenBuffers;
_glBindBuffer = rhs._glBindBuffer;
_glBufferData = rhs._glBufferData;
_glBufferSubData = rhs._glBufferSubData;
_glDeleteBuffers = rhs._glDeleteBuffers;
_glGenOcclusionQueries = rhs._glGenOcclusionQueries;
_glDeleteOcclusionQueries = rhs._glDeleteOcclusionQueries;
_glIsOcclusionQuery = rhs._glIsOcclusionQuery;
_glBeginOcclusionQuery = rhs._glBeginOcclusionQuery;
_glEndOcclusionQuery = rhs._glEndOcclusionQuery;
_glGetOcclusionQueryiv = rhs._glGetOcclusionQueryiv;
_glGetOcclusionQueryuiv = rhs._glGetOcclusionQueryuiv;
_gl_gen_queries_arb = rhs._gl_gen_queries_arb;
_gl_delete_queries_arb = rhs._gl_delete_queries_arb;
_gl_is_query_arb = rhs._gl_is_query_arb;
_gl_begin_query_arb = rhs._gl_begin_query_arb;
_gl_end_query_arb = rhs._gl_end_query_arb;
_gl_get_queryiv_arb = rhs._gl_get_queryiv_arb;
_gl_get_query_objectiv_arb = rhs._gl_get_query_objectiv_arb;
_gl_get_query_objectuiv_arb = rhs._gl_get_query_objectuiv_arb;
_gl_get_query_objectui64v = rhs._gl_get_query_objectui64v;
_glGetInteger64v = rhs._glGetInteger64v;
}
void Drawable::Extensions::lowestCommonDenominator(const Extensions& rhs)
{
if (!rhs._isVertexProgramSupported) _isVertexProgramSupported = false;
if (!rhs._isSecondaryColorSupported) _isSecondaryColorSupported = false;
if (!rhs._isFogCoordSupported) _isFogCoordSupported = false;
if (!rhs._isMultiTexSupported) _isMultiTexSupported = false;
if (!rhs._isOcclusionQuerySupported) _isOcclusionQuerySupported = false;
if (!rhs._isARBOcclusionQuerySupported) _isARBOcclusionQuerySupported = false;
if (!rhs._isTimerQuerySupported) _isTimerQuerySupported = false;
if (!rhs._isARBTimerQuerySupported) _isARBTimerQuerySupported = false;
if (!rhs._glFogCoordfv) _glFogCoordfv = 0;
if (!rhs._glSecondaryColor3ubv) _glSecondaryColor3ubv = 0;
if (!rhs._glSecondaryColor3fv) _glSecondaryColor3fv = 0;
if (!rhs._glMultiTexCoord1f) _glMultiTexCoord1f = 0;
if (!rhs._glMultiTexCoord2fv) _glMultiTexCoord2fv = 0;
if (!rhs._glMultiTexCoord3fv) _glMultiTexCoord3fv = 0;
if (!rhs._glMultiTexCoord4fv) _glMultiTexCoord4fv = 0;
if (!rhs._glVertexAttrib1s) _glVertexAttrib1s = 0;
if (!rhs._glVertexAttrib1f) _glVertexAttrib1f = 0;
if (!rhs._glVertexAttrib2fv) _glVertexAttrib2fv = 0;
if (!rhs._glVertexAttrib3fv) _glVertexAttrib3fv = 0;
if (!rhs._glVertexAttrib4fv) _glVertexAttrib4fv = 0;
if (!rhs._glVertexAttrib4ubv) _glVertexAttrib4ubv = 0;
if (!rhs._glVertexAttrib4Nubv) _glVertexAttrib4Nubv = 0;
if (!rhs._glGenBuffers) _glGenBuffers = 0;
if (!rhs._glBindBuffer) _glBindBuffer = 0;
if (!rhs._glBufferData) _glBufferData = 0;
if (!rhs._glBufferSubData) _glBufferSubData = 0;
if (!rhs._glDeleteBuffers) _glDeleteBuffers = 0;
if (!rhs._glIsBuffer) _glIsBuffer = 0;
if (!rhs._glGetBufferSubData) _glGetBufferSubData = 0;
if (!rhs._glMapBuffer) _glMapBuffer = 0;
if (!rhs._glUnmapBuffer) _glUnmapBuffer = 0;
if (!rhs._glGetBufferParameteriv) _glGetBufferParameteriv = 0;
if (!rhs._glGetBufferPointerv) _glGetBufferPointerv = 0;
if (!rhs._glGenOcclusionQueries) _glGenOcclusionQueries = 0;
if (!rhs._glDeleteOcclusionQueries) _glDeleteOcclusionQueries = 0;
if (!rhs._glIsOcclusionQuery) _glIsOcclusionQuery = 0;
if (!rhs._glBeginOcclusionQuery) _glBeginOcclusionQuery = 0;
if (!rhs._glEndOcclusionQuery) _glEndOcclusionQuery = 0;
if (!rhs._glGetOcclusionQueryiv) _glGetOcclusionQueryiv = 0;
if (!rhs._glGetOcclusionQueryuiv) _glGetOcclusionQueryuiv = 0;
if (!rhs._gl_gen_queries_arb) _gl_gen_queries_arb = 0;
if (!rhs._gl_delete_queries_arb) _gl_delete_queries_arb = 0;
if (!rhs._gl_is_query_arb) _gl_is_query_arb = 0;
if (!rhs._gl_begin_query_arb) _gl_begin_query_arb = 0;
if (!rhs._gl_end_query_arb) _gl_end_query_arb = 0;
if (!rhs._gl_get_queryiv_arb) _gl_get_queryiv_arb = 0;
if (!rhs._gl_get_query_objectiv_arb) _gl_get_query_objectiv_arb = 0;
if (!rhs._gl_get_query_objectuiv_arb) _gl_get_query_objectuiv_arb = 0;
if (!rhs._gl_get_query_objectui64v) _gl_get_query_objectui64v = 0;
if (!rhs._glGetInteger64v) _glGetInteger64v = 0;
}
void Drawable::Extensions::setupGLExtensions(unsigned int contextID)
{
_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_GL3_FEATURES || osg::isGLExtensionSupported(contextID, "GL_ARB_occlusion_query" );
_isTimerQuerySupported = osg::isGLExtensionSupported(contextID, "GL_EXT_timer_query" );
_isARBTimerQuerySupported = osg::isGLExtensionSupported(contextID, "GL_ARB_timer_query");
setGLExtensionFuncPtr(_glFogCoordfv, "glFogCoordfv","glFogCoordfvEXT");
setGLExtensionFuncPtr(_glSecondaryColor3ubv, "glSecondaryColor3ubv","glSecondaryColor3ubvEXT");
setGLExtensionFuncPtr(_glSecondaryColor3fv, "glSecondaryColor3fv","glSecondaryColor3fvEXT");
setGLExtensionFuncPtr(_glMultiTexCoord1f, "glMultiTexCoord1f","glMultiTexCoord1fARB");
setGLExtensionFuncPtr(_glMultiTexCoord1fv, "glMultiTexCoord1fv","glMultiTexCoord1fvARB");
setGLExtensionFuncPtr(_glMultiTexCoord2fv, "glMultiTexCoord2fv","glMultiTexCoord2fvARB");
setGLExtensionFuncPtr(_glMultiTexCoord3fv, "glMultiTexCoord3fv","glMultiTexCoord3fvARB");
setGLExtensionFuncPtr(_glMultiTexCoord4fv, "glMultiTexCoord4fv","glMultiTexCoord4fvARB");
setGLExtensionFuncPtr(_glMultiTexCoord1d, "glMultiTexCoord1d","glMultiTexCoorddfARB");
setGLExtensionFuncPtr(_glMultiTexCoord2dv, "glMultiTexCoord2dv","glMultiTexCoord2dvARB");
setGLExtensionFuncPtr(_glMultiTexCoord3dv, "glMultiTexCoord3dv","glMultiTexCoord3dvARB");
setGLExtensionFuncPtr(_glMultiTexCoord4dv, "glMultiTexCoord4dv","glMultiTexCoord4dvARB");
setGLExtensionFuncPtr(_glVertexAttrib1s, "glVertexAttrib1s","glVertexAttrib1sARB");
setGLExtensionFuncPtr(_glVertexAttrib1f, "glVertexAttrib1f","glVertexAttrib1fARB");
setGLExtensionFuncPtr(_glVertexAttrib1d, "glVertexAttrib1d","glVertexAttrib1dARB");
setGLExtensionFuncPtr(_glVertexAttrib1fv, "glVertexAttrib1fv","glVertexAttrib1fvARB");
setGLExtensionFuncPtr(_glVertexAttrib2fv, "glVertexAttrib2fv","glVertexAttrib2fvARB");
setGLExtensionFuncPtr(_glVertexAttrib3fv, "glVertexAttrib3fv","glVertexAttrib3fvARB");
setGLExtensionFuncPtr(_glVertexAttrib4fv, "glVertexAttrib4fv","glVertexAttrib4fvARB");
setGLExtensionFuncPtr(_glVertexAttrib2dv, "glVertexAttrib2dv","glVertexAttrib2dvARB");
setGLExtensionFuncPtr(_glVertexAttrib3dv, "glVertexAttrib3dv","glVertexAttrib3dvARB");
setGLExtensionFuncPtr(_glVertexAttrib4dv, "glVertexAttrib4dv","glVertexAttrib4dvARB");
setGLExtensionFuncPtr(_glVertexAttrib4ubv, "glVertexAttrib4ubv","glVertexAttrib4ubvARB");
setGLExtensionFuncPtr(_glVertexAttrib4Nubv, "glVertexAttrib4Nubv","glVertexAttrib4NubvARB");
setGLExtensionFuncPtr(_glGenBuffers, "glGenBuffers","glGenBuffersARB");
setGLExtensionFuncPtr(_glBindBuffer, "glBindBuffer","glBindBufferARB");
setGLExtensionFuncPtr(_glBufferData, "glBufferData","glBufferDataARB");
setGLExtensionFuncPtr(_glBufferSubData, "glBufferSubData","glBufferSubDataARB");
setGLExtensionFuncPtr(_glDeleteBuffers, "glDeleteBuffers","glDeleteBuffersARB");
setGLExtensionFuncPtr(_glIsBuffer, "glIsBuffer","glIsBufferARB");
setGLExtensionFuncPtr(_glGetBufferSubData, "glGetBufferSubData","glGetBufferSubDataARB");
setGLExtensionFuncPtr(_glMapBuffer, "glMapBuffer","glMapBufferARB");
setGLExtensionFuncPtr(_glUnmapBuffer, "glUnmapBuffer","glUnmapBufferARB");
setGLExtensionFuncPtr(_glGetBufferParameteriv, "glGetBufferParameteriv","glGetBufferParameterivARB");
setGLExtensionFuncPtr(_glGetBufferPointerv, "glGetBufferPointerv","glGetBufferPointervARB");
setGLExtensionFuncPtr(_glGenOcclusionQueries, "glGenOcclusionQueries","glGenOcclusionQueriesNV");
setGLExtensionFuncPtr(_glDeleteOcclusionQueries, "glDeleteOcclusionQueries","glDeleteOcclusionQueriesNV");
setGLExtensionFuncPtr(_glIsOcclusionQuery, "glIsOcclusionQuery","_glIsOcclusionQueryNV");
setGLExtensionFuncPtr(_glBeginOcclusionQuery, "glBeginOcclusionQuery","glBeginOcclusionQueryNV");
setGLExtensionFuncPtr(_glEndOcclusionQuery, "glEndOcclusionQuery","glEndOcclusionQueryNV");
setGLExtensionFuncPtr(_glGetOcclusionQueryiv, "glGetOcclusionQueryiv","glGetOcclusionQueryivNV");
setGLExtensionFuncPtr(_glGetOcclusionQueryuiv, "glGetOcclusionQueryuiv","glGetOcclusionQueryuivNV");
setGLExtensionFuncPtr(_gl_gen_queries_arb, "glGenQueries", "glGenQueriesARB");
setGLExtensionFuncPtr(_gl_delete_queries_arb, "glDeleteQueries", "glDeleteQueriesARB");
setGLExtensionFuncPtr(_gl_is_query_arb, "glIsQuery", "glIsQueryARB");
setGLExtensionFuncPtr(_gl_begin_query_arb, "glBeginQuery", "glBeginQueryARB");
setGLExtensionFuncPtr(_gl_end_query_arb, "glEndQuery", "glEndQueryARB");
setGLExtensionFuncPtr(_gl_get_queryiv_arb, "glGetQueryiv", "glGetQueryivARB");
setGLExtensionFuncPtr(_gl_get_query_objectiv_arb, "glGetQueryObjectiv","glGetQueryObjectivARB");
setGLExtensionFuncPtr(_gl_get_query_objectuiv_arb, "glGetQueryObjectuiv","glGetQueryObjectuivARB");
setGLExtensionFuncPtr(_gl_get_query_objectui64v, "glGetQueryObjectui64v","glGetQueryObjectui64vEXT");
setGLExtensionFuncPtr(_glQueryCounter, "glQueryCounter");
setGLExtensionFuncPtr(_glGetInteger64v, "glGetInteger64v");
}
void Drawable::Extensions::glFogCoordfv(const GLfloat* coord) const
{
if (_glFogCoordfv)
{
_glFogCoordfv(coord);
}
else
{
OSG_WARN<<"Error: glFogCoordfv not supported by OpenGL driver"<<std::endl;
}
}
void Drawable::Extensions::glSecondaryColor3ubv(const GLubyte* coord) const
{
if (_glSecondaryColor3ubv)
{
_glSecondaryColor3ubv(coord);
}
else
{
OSG_WARN<<"Error: glSecondaryColor3ubv not supported by OpenGL driver"<<std::endl;
}
}
void Drawable::Extensions::glSecondaryColor3fv(const GLfloat* coord) const
{
if (_glSecondaryColor3fv)
{
_glSecondaryColor3fv(coord);
}
else
{
OSG_WARN<<"Error: glSecondaryColor3fv not supported by OpenGL driver"<<std::endl;
}
}
void Drawable::Extensions::glMultiTexCoord1f(GLenum target,GLfloat coord) const
{
if (_glMultiTexCoord1f)
{
_glMultiTexCoord1f(target,coord);
}
else
{
OSG_WARN<<"Error: glMultiTexCoord1f not supported by OpenGL driver"<<std::endl;
}
}
void Drawable::Extensions::glMultiTexCoord2fv(GLenum target,const GLfloat* coord) const
{
if (_glMultiTexCoord2fv)
{
_glMultiTexCoord2fv(target,coord);
}
else
{
OSG_WARN<<"Error: glMultiTexCoord2fv not supported by OpenGL driver"<<std::endl;
}
}
void Drawable::Extensions::glMultiTexCoord3fv(GLenum target,const GLfloat* coord) const
{
if (_glMultiTexCoord3fv)
{
_glMultiTexCoord3fv(target,coord);
}
else
{
OSG_WARN<<"Error: _glMultiTexCoord3fv not supported by OpenGL driver"<<std::endl;
}
}
void Drawable::Extensions::glMultiTexCoord4fv(GLenum target,const GLfloat* coord) const
{
if (_glMultiTexCoord4fv)
{
_glMultiTexCoord4fv(target,coord);
}
else
{
OSG_WARN<<"Error: glMultiTexCoord4fv not supported by OpenGL driver"<<std::endl;
}
}
void Drawable::Extensions::glMultiTexCoord1d(GLenum target,GLdouble coord) const
{
if (_glMultiTexCoord1d)
{
_glMultiTexCoord1d(target,coord);
}
else
{
OSG_WARN<<"Error: glMultiTexCoord1d not supported by OpenGL driver"<<std::endl;
}
}
void Drawable::Extensions::glMultiTexCoord2dv(GLenum target,const GLdouble* coord) const
{
if (_glMultiTexCoord2dv)
{
_glMultiTexCoord2dv(target,coord);
}
else
{
OSG_WARN<<"Error: glMultiTexCoord2dv not supported by OpenGL driver"<<std::endl;
}
}
void Drawable::Extensions::glMultiTexCoord3dv(GLenum target,const GLdouble* coord) const
{
if (_glMultiTexCoord3dv)
{
_glMultiTexCoord3dv(target,coord);
}
else
{
OSG_WARN<<"Error: _glMultiTexCoord3dv not supported by OpenGL driver"<<std::endl;
}
}
void Drawable::Extensions::glMultiTexCoord4dv(GLenum target,const GLdouble* coord) const
{
if (_glMultiTexCoord4dv)
{
_glMultiTexCoord4dv(target,coord);
}
else
{
OSG_WARN<<"Error: glMultiTexCoord4dv not supported by OpenGL driver"<<std::endl;
}
}
void Drawable::Extensions::glVertexAttrib1s(unsigned int index, GLshort s) const
{
if (_glVertexAttrib1s)
{
_glVertexAttrib1s(index,s);
}
else
{
OSG_WARN<<"Error: glVertexAttrib1s not supported by OpenGL driver"<<std::endl;
}
}
void Drawable::Extensions::glVertexAttrib1f(unsigned int index, GLfloat f) const
{
if (_glVertexAttrib1f)
{
_glVertexAttrib1f(index,f);
}
else
{
OSG_WARN<<"Error: glVertexAttrib1f not supported by OpenGL driver"<<std::endl;
}
}
void Drawable::Extensions::glVertexAttrib1d(unsigned int index, GLdouble f) const
{
if (_glVertexAttrib1d)
{
_glVertexAttrib1d(index,f);
}
else
{
OSG_WARN<<"Error: glVertexAttrib1d not supported by OpenGL driver"<<std::endl;
}
}
void Drawable::Extensions::glVertexAttrib2fv(unsigned int index, const GLfloat * v) const
{
if (_glVertexAttrib2fv)
{
_glVertexAttrib2fv(index,v);
}
else
{
OSG_WARN<<"Error: glVertexAttrib2fv not supported by OpenGL driver"<<std::endl;
}
}
void Drawable::Extensions::glVertexAttrib3fv(unsigned int index, const GLfloat * v) const
{
if (_glVertexAttrib3fv)
{
_glVertexAttrib3fv(index,v);
}
else
{
OSG_WARN<<"Error: glVertexAttrib3fv not supported by OpenGL driver"<<std::endl;
}
}
void Drawable::Extensions::glVertexAttrib4fv(unsigned int index, const GLfloat * v) const
{
if (_glVertexAttrib4fv)
{
_glVertexAttrib4fv(index,v);
}
else
{
OSG_WARN<<"Error: glVertexAttrib4fv not supported by OpenGL driver"<<std::endl;
}
}
void Drawable::Extensions::glVertexAttrib2dv(unsigned int index, const GLdouble * v) const
{
if (_glVertexAttrib2dv)
{
_glVertexAttrib2dv(index,v);
}
else
{
OSG_WARN<<"Error: glVertexAttrib2dv not supported by OpenGL driver"<<std::endl;
}
}
void Drawable::Extensions::glVertexAttrib3dv(unsigned int index, const GLdouble * v) const
{
if (_glVertexAttrib3dv)
{
_glVertexAttrib3dv(index,v);
}
else
{
OSG_WARN<<"Error: glVertexAttrib3dv not supported by OpenGL driver"<<std::endl;
}
}
void Drawable::Extensions::glVertexAttrib4dv(unsigned int index, const GLdouble * v) const
{
if (_glVertexAttrib4dv)
{
_glVertexAttrib4dv(index,v);
}
else
{
OSG_WARN<<"Error: glVertexAttrib4dv not supported by OpenGL driver"<<std::endl;
}
}
void Drawable::Extensions::glVertexAttrib4ubv(unsigned int index, const GLubyte * v) const
{
if (_glVertexAttrib4ubv)
{
_glVertexAttrib4ubv(index,v);
}
else
{
OSG_WARN<<"Error: glVertexAttrib4ubv not supported by OpenGL driver"<<std::endl;
}
}
void Drawable::Extensions::glVertexAttrib4Nubv(unsigned int index, const GLubyte * v) const
{
if (_glVertexAttrib4Nubv)
{
_glVertexAttrib4Nubv(index,v);
}
else
{
OSG_WARN<<"Error: glVertexAttrib4Nubv not supported by OpenGL driver"<<std::endl;
}
}
void Drawable::Extensions::glGenBuffers(GLsizei n, GLuint *buffers) const
{
if (_glGenBuffers) _glGenBuffers(n, buffers);
else OSG_WARN<<"Error: glGenBuffers not supported by OpenGL driver"<<std::endl;
}
void Drawable::Extensions::glBindBuffer(GLenum target, GLuint buffer) const
{
if (_glBindBuffer) _glBindBuffer(target, buffer);
else OSG_WARN<<"Error: glBindBuffer not supported by OpenGL driver"<<std::endl;
}
void Drawable::Extensions::glBufferData(GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage) const
{
if (_glBufferData) _glBufferData(target, size, data, usage);
else OSG_WARN<<"Error: glBufferData not supported by OpenGL driver"<<std::endl;
}
void Drawable::Extensions::glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data) const
{
if (_glBufferSubData) _glBufferSubData(target, offset, size, data);
else OSG_WARN<<"Error: glBufferData not supported by OpenGL driver"<<std::endl;
}
void Drawable::Extensions::glDeleteBuffers(GLsizei n, const GLuint *buffers) const
{
if (_glDeleteBuffers) _glDeleteBuffers(n, buffers);
else OSG_WARN<<"Error: glBufferData not supported by OpenGL driver"<<std::endl;
}
GLboolean Drawable::Extensions::glIsBuffer (GLuint buffer) const
{
if (_glIsBuffer) return _glIsBuffer(buffer);
else
{
OSG_WARN<<"Error: glIsBuffer not supported by OpenGL driver"<<std::endl;
return GL_FALSE;
}
}
void Drawable::Extensions::glGetBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data) const
{
if (_glGetBufferSubData) _glGetBufferSubData(target,offset,size,data);
else OSG_WARN<<"Error: glGetBufferSubData not supported by OpenGL driver"<<std::endl;
}
GLvoid* Drawable::Extensions::glMapBuffer (GLenum target, GLenum access) const
{
if (_glMapBuffer) return _glMapBuffer(target,access);
else
{
OSG_WARN<<"Error: glMapBuffer not supported by OpenGL driver"<<std::endl;
return 0;
}
}
GLboolean Drawable::Extensions::glUnmapBuffer (GLenum target) const
{
if (_glUnmapBuffer) return _glUnmapBuffer(target);
else
{
OSG_WARN<<"Error: glUnmapBuffer not supported by OpenGL driver"<<std::endl;
return GL_FALSE;
}
}
void Drawable::Extensions::glGetBufferParameteriv (GLenum target, GLenum pname, GLint *params) const
{
if (_glGetBufferParameteriv) _glGetBufferParameteriv(target,pname,params);
else OSG_WARN<<"Error: glGetBufferParameteriv not supported by OpenGL driver"<<std::endl;
}
void Drawable::Extensions::glGetBufferPointerv (GLenum target, GLenum pname, GLvoid* *params) const
{
if (_glGetBufferPointerv) _glGetBufferPointerv(target,pname,params);
else OSG_WARN<<"Error: glGetBufferPointerv not supported by OpenGL driver"<<std::endl;
}
void Drawable::Extensions::glGenOcclusionQueries( GLsizei n, GLuint *ids ) const
{
if (_glGenOcclusionQueries)
{
_glGenOcclusionQueries( n, ids );
}
else
{
OSG_WARN<<"Error: glGenOcclusionQueries not supported by OpenGL driver"<<std::endl;
}
}
void Drawable::Extensions::glDeleteOcclusionQueries( GLsizei n, const GLuint *ids ) const
{
if (_glDeleteOcclusionQueries)
{
_glDeleteOcclusionQueries( n, ids );
}
else
{
OSG_WARN<<"Error: glDeleteOcclusionQueries not supported by OpenGL driver"<<std::endl;
}
}
GLboolean Drawable::Extensions::glIsOcclusionQuery( GLuint id ) const
{
if (_glIsOcclusionQuery)
{
return _glIsOcclusionQuery( id );
}
else
{
OSG_WARN<<"Error: glIsOcclusionQuery not supported by OpenGL driver"<<std::endl;
}
return GLboolean( 0 );
}
void Drawable::Extensions::glBeginOcclusionQuery( GLuint id ) const
{
if (_glBeginOcclusionQuery)
{
_glBeginOcclusionQuery( id );
}
else
{
OSG_WARN<<"Error: glBeginOcclusionQuery not supported by OpenGL driver"<<std::endl;
}
}
void Drawable::Extensions::glEndOcclusionQuery() const
{
if (_glEndOcclusionQuery)
{
_glEndOcclusionQuery();
}
else
{
OSG_WARN<<"Error: glEndOcclusionQuery not supported by OpenGL driver"<<std::endl;
}
}
void Drawable::Extensions::glGetOcclusionQueryiv( GLuint id, GLenum pname, GLint *params ) const
{
if (_glGetOcclusionQueryiv)
{
_glGetOcclusionQueryiv( id, pname, params );
}
else
{
OSG_WARN<<"Error: glGetOcclusionQueryiv not supported by OpenGL driver"<<std::endl;
}
}
void Drawable::Extensions::glGetOcclusionQueryuiv( GLuint id, GLenum pname, GLuint *params ) const
{
if (_glGetOcclusionQueryuiv)
{
_glGetOcclusionQueryuiv( id, pname, params );
}
else
{
OSG_WARN<<"Error: glGetOcclusionQueryuiv not supported by OpenGL driver"<<std::endl;
}
}
void Drawable::Extensions::glGetQueryiv(GLenum target, GLenum pname, GLint *params) const
{
if (_gl_get_queryiv_arb)
_gl_get_queryiv_arb(target, pname, params);
else
OSG_WARN << "Error: glGetQueryiv not supported by OpenGL driver" << std::endl;
}
void Drawable::Extensions::glGenQueries(GLsizei n, GLuint *ids) const
{
if (_gl_gen_queries_arb)
_gl_gen_queries_arb(n, ids);
else
OSG_WARN << "Error: glGenQueries not supported by OpenGL driver" << std::endl;
}
void Drawable::Extensions::glBeginQuery(GLenum target, GLuint id) const
{
if (_gl_begin_query_arb)
_gl_begin_query_arb(target, id);
else
OSG_WARN << "Error: glBeginQuery not supported by OpenGL driver" << std::endl;
}
void Drawable::Extensions::glEndQuery(GLenum target) const
{
if (_gl_end_query_arb)
_gl_end_query_arb(target);
else
OSG_WARN << "Error: glEndQuery not supported by OpenGL driver" << std::endl;
}
void Drawable::Extensions::glQueryCounter(GLuint id, GLenum target) const
{
if (_glQueryCounter)
_glQueryCounter(id, target);
else
OSG_WARN << "Error: glQueryCounter not supported by OpenGL driver\n";
}
GLboolean Drawable::Extensions::glIsQuery(GLuint id) const
{
if (_gl_is_query_arb) return _gl_is_query_arb(id);
OSG_WARN << "Error: glIsQuery not supported by OpenGL driver" << std::endl;
return false;
}
void Drawable::Extensions::glDeleteQueries(GLsizei n, const GLuint *ids) const
{
if (_gl_delete_queries_arb)
_gl_delete_queries_arb(n, ids);
else
OSG_WARN << "Error: glIsQuery not supported by OpenGL driver" << std::endl;
}
void Drawable::Extensions::glGetQueryObjectiv(GLuint id, GLenum pname, GLint *params) const
{
if (_gl_get_query_objectiv_arb)
_gl_get_query_objectiv_arb(id, pname, params);
else
OSG_WARN << "Error: glGetQueryObjectiv not supported by OpenGL driver" << std::endl;
}
void Drawable::Extensions::glGetQueryObjectuiv(GLuint id, GLenum pname, GLuint *params) const
{
if (_gl_get_query_objectuiv_arb)
_gl_get_query_objectuiv_arb(id, pname, params);
else
OSG_WARN << "Error: glGetQueryObjectuiv not supported by OpenGL driver" << std::endl;
}
void Drawable::Extensions::glGetQueryObjectui64v(GLuint id, GLenum pname, GLuint64 *params) const
{
if (_gl_get_query_objectui64v)
_gl_get_query_objectui64v(id, pname, params);
else
OSG_WARN << "Error: glGetQueryObjectui64v not supported by OpenGL driver" << std::endl;
}
void Drawable::Extensions::glGetInteger64v(GLenum pname, GLint64 *params)
const
{
if (_glGetInteger64v)
_glGetInteger64v(pname, params);
else
OSG_WARN << "Error: glGetInteger64v not supported by OpenGL driver\n";
}

View File

@ -306,6 +306,82 @@ GL2Extensions::GL2Extensions(unsigned int contextID)
setGLExtensionFuncPtr(glBlendFunci, "glBlendFunci", "glBlendFunciARB"); setGLExtensionFuncPtr(glBlendFunci, "glBlendFunci", "glBlendFunciARB");
setGLExtensionFuncPtr(glBlendFuncSeparatei, "glBlendFuncSeparatei", "glBlendFuncSeparateiARB"); setGLExtensionFuncPtr(glBlendFuncSeparatei, "glBlendFuncSeparatei", "glBlendFuncSeparateiARB");
// Vertex Array extensions
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_GL3_FEATURES || osg::isGLExtensionSupported(contextID, "GL_ARB_occlusion_query" );
isTimerQuerySupported = osg::isGLExtensionSupported(contextID, "GL_EXT_timer_query" );
isARBTimerQuerySupported = osg::isGLExtensionSupported(contextID, "GL_ARB_timer_query");
isRectangleSupported = OSG_GL3_FEATURES ||
isGLExtensionSupported(contextID,"GL_ARB_texture_rectangle") ||
isGLExtensionSupported(contextID,"GL_EXT_texture_rectangle") ||
isGLExtensionSupported(contextID,"GL_NV_texture_rectangle");
setGLExtensionFuncPtr(glFogCoordfv, "glFogCoordfv","glFogCoordfvEXT");
setGLExtensionFuncPtr(glSecondaryColor3ubv, "glSecondaryColor3ubv","glSecondaryColor3ubvEXT");
setGLExtensionFuncPtr(glSecondaryColor3fv, "glSecondaryColor3fv","glSecondaryColor3fvEXT");
setGLExtensionFuncPtr(glMultiTexCoord1f, "glMultiTexCoord1f","glMultiTexCoord1fARB");
setGLExtensionFuncPtr(glMultiTexCoord1fv, "glMultiTexCoord1fv","glMultiTexCoord1fvARB");
setGLExtensionFuncPtr(glMultiTexCoord2fv, "glMultiTexCoord2fv","glMultiTexCoord2fvARB");
setGLExtensionFuncPtr(glMultiTexCoord3fv, "glMultiTexCoord3fv","glMultiTexCoord3fvARB");
setGLExtensionFuncPtr(glMultiTexCoord4fv, "glMultiTexCoord4fv","glMultiTexCoord4fvARB");
setGLExtensionFuncPtr(glMultiTexCoord1d, "glMultiTexCoord1d","glMultiTexCoorddfARB");
setGLExtensionFuncPtr(glMultiTexCoord2dv, "glMultiTexCoord2dv","glMultiTexCoord2dvARB");
setGLExtensionFuncPtr(glMultiTexCoord3dv, "glMultiTexCoord3dv","glMultiTexCoord3dvARB");
setGLExtensionFuncPtr(glMultiTexCoord4dv, "glMultiTexCoord4dv","glMultiTexCoord4dvARB");
setGLExtensionFuncPtr(glVertexAttrib1s, "glVertexAttrib1s","glVertexAttrib1sARB");
setGLExtensionFuncPtr(glVertexAttrib1f, "glVertexAttrib1f","glVertexAttrib1fARB");
setGLExtensionFuncPtr(glVertexAttrib1d, "glVertexAttrib1d","glVertexAttrib1dARB");
setGLExtensionFuncPtr(glVertexAttrib1fv, "glVertexAttrib1fv","glVertexAttrib1fvARB");
setGLExtensionFuncPtr(glVertexAttrib2fv, "glVertexAttrib2fv","glVertexAttrib2fvARB");
setGLExtensionFuncPtr(glVertexAttrib3fv, "glVertexAttrib3fv","glVertexAttrib3fvARB");
setGLExtensionFuncPtr(glVertexAttrib4fv, "glVertexAttrib4fv","glVertexAttrib4fvARB");
setGLExtensionFuncPtr(glVertexAttrib2dv, "glVertexAttrib2dv","glVertexAttrib2dvARB");
setGLExtensionFuncPtr(glVertexAttrib3dv, "glVertexAttrib3dv","glVertexAttrib3dvARB");
setGLExtensionFuncPtr(glVertexAttrib4dv, "glVertexAttrib4dv","glVertexAttrib4dvARB");
setGLExtensionFuncPtr(glVertexAttrib4ubv, "glVertexAttrib4ubv","glVertexAttrib4ubvARB");
setGLExtensionFuncPtr(glVertexAttrib4Nubv, "glVertexAttrib4Nubv","glVertexAttrib4NubvARB");
setGLExtensionFuncPtr(glGenBuffers, "glGenBuffers","glGenBuffersARB");
setGLExtensionFuncPtr(glBindBuffer, "glBindBuffer","glBindBufferARB");
setGLExtensionFuncPtr(glBufferData, "glBufferData","glBufferDataARB");
setGLExtensionFuncPtr(glBufferSubData, "glBufferSubData","glBufferSubDataARB");
setGLExtensionFuncPtr(glDeleteBuffers, "glDeleteBuffers","glDeleteBuffersARB");
setGLExtensionFuncPtr(glIsBuffer, "glIsBuffer","glIsBufferARB");
setGLExtensionFuncPtr(glGetBufferSubData, "glGetBufferSubData","glGetBufferSubDataARB");
setGLExtensionFuncPtr(glMapBuffer, "glMapBuffer","glMapBufferARB");
setGLExtensionFuncPtr(glUnmapBuffer, "glUnmapBuffer","glUnmapBufferARB");
setGLExtensionFuncPtr(glGetBufferParameteriv, "glGetBufferParameteriv","glGetBufferParameterivARB");
setGLExtensionFuncPtr(glGetBufferPointerv, "glGetBufferPointerv","glGetBufferPointervARB");
setGLExtensionFuncPtr(glGenOcclusionQueries, "glGenOcclusionQueries","glGenOcclusionQueriesNV");
setGLExtensionFuncPtr(glDeleteOcclusionQueries, "glDeleteOcclusionQueries","glDeleteOcclusionQueriesNV");
setGLExtensionFuncPtr(glIsOcclusionQuery, "glIsOcclusionQuery","_glIsOcclusionQueryNV");
setGLExtensionFuncPtr(glBeginOcclusionQuery, "glBeginOcclusionQuery","glBeginOcclusionQueryNV");
setGLExtensionFuncPtr(glEndOcclusionQuery, "glEndOcclusionQuery","glEndOcclusionQueryNV");
setGLExtensionFuncPtr(glGetOcclusionQueryiv, "glGetOcclusionQueryiv","glGetOcclusionQueryivNV");
setGLExtensionFuncPtr(glGetOcclusionQueryuiv, "glGetOcclusionQueryuiv","glGetOcclusionQueryuivNV");
setGLExtensionFuncPtr(glGenQueries, "glGenQueries", "glGenQueriesARB");
setGLExtensionFuncPtr(glDeleteQueries, "glDeleteQueries", "glDeleteQueriesARB");
setGLExtensionFuncPtr(glIsQuery, "glIsQuery", "glIsQueryARB");
setGLExtensionFuncPtr(glBeginQuery, "glBeginQuery", "glBeginQueryARB");
setGLExtensionFuncPtr(glEndQuery, "glEndQuery", "glEndQueryARB");
setGLExtensionFuncPtr(glGetQueryiv, "glGetQueryiv", "glGetQueryivARB");
setGLExtensionFuncPtr(glGetQueryObjectiv, "glGetQueryObjectiv","glGetQueryObjectivARB");
setGLExtensionFuncPtr(glGetQueryObjectuiv, "glGetQueryObjectuiv","glGetQueryObjectuivARB");
setGLExtensionFuncPtr(glGetQueryObjectui64v, "glGetQueryObjectui64v","glGetQueryObjectui64vEXT");
setGLExtensionFuncPtr(glQueryCounter, "glQueryCounter");
setGLExtensionFuncPtr(glGetInteger64v, "glGetInteger64v");
} }

View File

@ -37,10 +37,6 @@
#include <OpenThreads/Thread> #include <OpenThreads/Thread>
typedef osg::buffered_value< osg::ref_ptr< osg::Drawable::Extensions > > OcclusionQueryBufferedExtensions;
static OcclusionQueryBufferedExtensions s_OQ_bufferedExtensions;
// //
// Support classes, used by (and private to) OcclusionQueryNode. // Support classes, used by (and private to) OcclusionQueryNode.
// (Note a lot of this is historical. OcclusionQueryNode formaerly // (Note a lot of this is historical. OcclusionQueryNode formaerly
@ -104,7 +100,7 @@ struct RetrieveQueriesCallback : public osg::Camera::DrawCallback
typedef std::vector<osg::TestResult*> ResultsVector; typedef std::vector<osg::TestResult*> ResultsVector;
ResultsVector _results; ResultsVector _results;
RetrieveQueriesCallback( osg::Drawable::Extensions* ext=NULL ) RetrieveQueriesCallback( osg::GL2Extensions* ext=NULL )
: _extensionsFallback( ext ) : _extensionsFallback( ext )
{ {
} }
@ -122,14 +118,12 @@ struct RetrieveQueriesCallback : public osg::Camera::DrawCallback
double elapsedTime( 0. ); double elapsedTime( 0. );
int count( 0 ); int count( 0 );
osg::Drawable::Extensions* ext; const osg::GL2Extensions* ext=0;
if (camera.getGraphicsContext()) if (camera.getGraphicsContext())
{ {
// The typical path, for osgViewer-based applications or any // The typical path, for osgViewer-based applications or any
// app that has set up a valid GraphicsCOntext for the Camera. // app that has set up a valid GraphicsCOntext for the Camera.
unsigned int contextID = camera.getGraphicsContext()->getState()->getContextID(); ext = camera.getGraphicsContext()->getState()->get<osg::GL2Extensions>();
RetrieveQueriesCallback* const_this = const_cast<RetrieveQueriesCallback*>( this );
ext = const_this->getExtensions( contextID, true );
} }
else else
{ {
@ -210,15 +204,7 @@ struct RetrieveQueriesCallback : public osg::Camera::DrawCallback
_results.push_back( tr ); _results.push_back( tr );
} }
osg::Drawable::Extensions* getExtensions( unsigned int contextID, bool createIfNotInitalized ) osg::GL2Extensions* _extensionsFallback;
{
if (!s_OQ_bufferedExtensions[ contextID ] && createIfNotInitalized)
s_OQ_bufferedExtensions[ contextID ] = new osg::Drawable::Extensions( contextID );
return s_OQ_bufferedExtensions[ contextID ].get();
}
osg::Drawable::Extensions* _extensionsFallback;
}; };
@ -293,7 +279,7 @@ void
QueryGeometry::drawImplementation( osg::RenderInfo& renderInfo ) const QueryGeometry::drawImplementation( osg::RenderInfo& renderInfo ) const
{ {
unsigned int contextID = renderInfo.getState()->getContextID(); unsigned int contextID = renderInfo.getState()->getContextID();
osg::Drawable::Extensions* ext = getExtensions( contextID, true ); osg::GL2Extensions* ext = renderInfo.getState()->get<GL2Extensions>();
osg::Camera* cam = renderInfo.getCurrentCamera(); osg::Camera* cam = renderInfo.getCurrentCamera();
// Add callbacks if necessary. // Add callbacks if necessary.
@ -426,7 +412,7 @@ QueryGeometry::flushDeletedQueryObjects( unsigned int contextID, double /*curren
{ {
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(s_mutex_deletedQueryObjectCache); OpenThreads::ScopedLock<OpenThreads::Mutex> lock(s_mutex_deletedQueryObjectCache);
const osg::Drawable::Extensions* extensions = getExtensions( contextID, true ); const osg::GL2Extensions* extensions = osg::GL2Extensions::Get( contextID, true );
QueryObjectList& qol = s_deletedQueryObjectCache[contextID]; QueryObjectList& qol = s_deletedQueryObjectCache[contextID];

View File

@ -966,8 +966,7 @@ void State::initializeExtensionProcs()
_glMaxTextureCoords = 1; _glMaxTextureCoords = 1;
} }
osg::Drawable::Extensions* extensions = osg::Drawable::getExtensions(getContextID(), true); if (_gl2Extentsions->isARBTimerQuerySupported)
if (extensions && extensions->isARBTimerQuerySupported())
{ {
const GLubyte* renderer = glGetString(GL_RENDERER); const GLubyte* renderer = glGetString(GL_RENDERER);
std::string rendererString = renderer ? (const char*)renderer : ""; std::string rendererString = renderer ? (const char*)renderer : "";
@ -982,7 +981,7 @@ void State::initializeExtensionProcs()
else else
{ {
GLint bits = 0; GLint bits = 0;
extensions->glGetQueryiv(GL_TIMESTAMP, GL_QUERY_COUNTER_BITS_ARB, &bits); _gl2Extentsions->glGetQueryiv(GL_TIMESTAMP, GL_QUERY_COUNTER_BITS_ARB, &bits);
setTimestampBits(bits); setTimestampBits(bits);
} }
} }
@ -1758,11 +1757,10 @@ void State::print(std::ostream& fout) const
void State::frameCompleted() void State::frameCompleted()
{ {
osg::Drawable::Extensions* extensions = osg::Drawable::getExtensions(getContextID(), true); if (getTimestampBits())
if (extensions && getTimestampBits())
{ {
GLint64 timestamp; GLint64 timestamp;
extensions->glGetInteger64v(GL_TIMESTAMP, &timestamp); _gl2Extentsions->glGetInteger64v(GL_TIMESTAMP, &timestamp);
setGpuTimestamp(osg::Timer::instance()->tick(), timestamp); setGpuTimestamp(osg::Timer::instance()->tick(), timestamp);
//OSG_NOTICE<<"State::frameCompleted() setting time stamp. timestamp="<<timestamp<<std::endl; //OSG_NOTICE<<"State::frameCompleted() setting time stamp. timestamp="<<timestamp<<std::endl;
} }

View File

@ -157,13 +157,7 @@ void TextureRectangle::setImage(Image* image)
void TextureRectangle::apply(State& state) const void TextureRectangle::apply(State& state) const
{ {
static bool s_rectangleSupported = if (!state.get<GL2Extensions>()->isRectangleSupported)
OSG_GL3_FEATURES ||
isGLExtensionSupported(state.getContextID(),"GL_ARB_texture_rectangle") ||
isGLExtensionSupported(state.getContextID(),"GL_EXT_texture_rectangle") ||
isGLExtensionSupported(state.getContextID(),"GL_NV_texture_rectangle");
if (!s_rectangleSupported)
{ {
OSG_WARN<<"Warning: TextureRectangle::apply(..) failed, texture rectangle is not support by your OpenGL drivers."<<std::endl; OSG_WARN<<"Warning: TextureRectangle::apply(..) failed, texture rectangle is not support by your OpenGL drivers."<<std::endl;
return; return;

View File

@ -838,7 +838,7 @@ void PrecipitationEffect::PrecipitationDrawable::drawImplementation(osg::RenderI
if (!_geometry) return; if (!_geometry) return;
const osg::Geometry::Extensions* extensions = osg::Geometry::getExtensions(renderInfo.getContextID(),true); const osg::GL2Extensions* extensions = renderInfo.getState()->get<osg::GL2Extensions>();
// save OpenGL matrices // save OpenGL matrices
glPushMatrix(); glPushMatrix();

View File

@ -132,7 +132,7 @@ void EXTQuerySupport::endQuery(osg::State* /*state*/)
void OpenGLQuerySupport::initialize(osg::State* state, osg::Timer_t /*startTick*/) void OpenGLQuerySupport::initialize(osg::State* state, osg::Timer_t /*startTick*/)
{ {
_extensions = osg::Drawable::getExtensions(state->getContextID(),true); _extensions = state->get<osg::GL2Extensions>();
} }
void EXTQuerySupport::initialize(osg::State* state, osg::Timer_t startTick) void EXTQuerySupport::initialize(osg::State* state, osg::Timer_t startTick)
@ -464,10 +464,10 @@ void Renderer::initialize(osg::State* state)
if (!_initialized) if (!_initialized)
{ {
_initialized = true; _initialized = true;
osg::Drawable::Extensions* ext = osg::Drawable::getExtensions(state->getContextID(), true); osg::GL2Extensions* ext = state->get<osg::GL2Extensions>();
if (ext->isARBTimerQuerySupported() && state->getTimestampBits() > 0) if (ext->isARBTimerQuerySupported && state->getTimestampBits() > 0)
_querySupport = new ARBQuerySupport(); _querySupport = new ARBQuerySupport();
else if (ext->isTimerQuerySupported()) else if (ext->isTimerQuerySupported)
_querySupport = new EXTQuerySupport(); _querySupport = new EXTQuerySupport();
if (_querySupport.valid()) if (_querySupport.valid())
_querySupport->initialize(state, _startTick); _querySupport->initialize(state, _startTick);

View File

@ -1102,12 +1102,9 @@ void StatsHandler::setUpScene(osgViewer::ViewerBase* viewer)
if ((*citr)->getGraphicsContext()) if ((*citr)->getGraphicsContext())
{ {
const osg::State* state = (*citr)->getGraphicsContext()->getState(); const osg::State* state = (*citr)->getGraphicsContext()->getState();
unsigned int contextID = state->getContextID(); const osg::GL2Extensions* extensions = state->get<osg::GL2Extensions>();
const osg::Drawable::Extensions* extensions = osg::Drawable::getExtensions(contextID, false);
if (extensions && if (extensions &&
(((extensions->isARBTimerQuerySupported() (((extensions->isARBTimerQuerySupported && state->getTimestampBits() > 0)) || extensions->isTimerQuerySupported))
&& state->getTimestampBits() > 0))
|| extensions->isTimerQuerySupported()))
{ {
++numCamrasWithTimerQuerySupport; ++numCamrasWithTimerQuerySupport;
} }