From f634152de05557cca9a65fad2d4c4855a0721816 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 5 Dec 2014 17:26:42 +0000 Subject: [PATCH] Moved osg::Drawable::Extensions into osg::GL2Extensions git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14575 16af8721-9629-0410-8352-f15c8da7e697 --- include/osg/Drawable | 240 -------- include/osg/GL2Extensions | 74 ++- include/osg/State | 4 +- include/osgViewer/Renderer | 2 +- src/osg/ArrayDispatchers.cpp | 26 +- src/osg/Drawable.cpp | 726 ------------------------ src/osg/GL2Extensions.cpp | 76 +++ src/osg/OcclusionQueryNode.cpp | 26 +- src/osg/State.cpp | 10 +- src/osg/TextureRectangle.cpp | 8 +- src/osgParticle/PrecipitationEffect.cpp | 2 +- src/osgViewer/Renderer.cpp | 8 +- src/osgViewer/StatsHandler.cpp | 7 +- 13 files changed, 183 insertions(+), 1026 deletions(-) diff --git a/include/osg/Drawable b/include/osg/Drawable index 0a2f22b05..7304cb2c8 100644 --- a/include/osg/Drawable +++ b/include/osg/Drawable @@ -495,246 +495,6 @@ class OSG_EXPORT Drawable : public Node * so one cannot modify it.*/ 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: Drawable& operator = (const Drawable&) { return *this;} diff --git a/include/osg/GL2Extensions b/include/osg/GL2Extensions index 7a72077e1..bf0f670c6 100644 --- a/include/osg/GL2Extensions +++ b/include/osg/GL2Extensions @@ -595,6 +595,7 @@ class OSG_EXPORT GL2Extensions : public osg::Referenced bool isGetProgramBinarySupported; bool isGpuShaderFp64Supported; bool isShaderAtomicCountersSupported; + bool isRectangleSupported; void (GL_APIENTRY * glBlendEquationSeparate)(GLenum modeRGB, GLenum modeAlpha); 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) ; + // 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 diff --git a/include/osg/State b/include/osg/State index 3eb77b31e..e9b1499c2 100644 --- a/include/osg/State +++ b/include/osg/State @@ -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. * Returns NULL if the desired extension object has not been created yet.*/ template - const T* getExisting() const + const T* get() const { const std::type_info* id(&typeid(T)); 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 template<> inline GL2Extensions* State::get() { return _gl2Extentsions.get(); } -template<> inline const GL2Extensions* State::getExisting() const { return _gl2Extentsions.get(); } +template<> inline const GL2Extensions* State::get() const { return _gl2Extentsions.get(); } } diff --git a/include/osgViewer/Renderer b/include/osgViewer/Renderer index fa4738a17..9567d2b0e 100644 --- a/include/osgViewer/Renderer +++ b/include/osgViewer/Renderer @@ -35,7 +35,7 @@ class OSGVIEWER_EXPORT OpenGLQuerySupport : public osg::Referenced virtual void initialize(osg::State* state, osg::Timer_t startTick); protected: - const osg::Drawable::Extensions* _extensions; + const osg::GL2Extensions* _extensions; }; class OSGVIEWER_EXPORT Renderer : public osg::GraphicsOperation diff --git a/src/osg/ArrayDispatchers.cpp b/src/osg/ArrayDispatchers.cpp index 4dc221674..7c07685c5 100644 --- a/src/osg/ArrayDispatchers.cpp +++ b/src/osg/ArrayDispatchers.cpp @@ -196,7 +196,7 @@ void ArrayDispatchers::init() #ifdef OSG_GL_VERTEX_FUNCS_AVAILABLE - Drawable::Extensions* extensions = Drawable::getExtensions(_state->getContextID(),true); + GL2Extensions* extensions = _state->get(); #ifndef OSG_GLES1_AVAILABLE _vertexDispatchers->assign(Array::Vec2ArrayType, glVertex2fv, 2); @@ -216,9 +216,9 @@ void ArrayDispatchers::init() _colorDispatchers->assign(Array::Vec3dArrayType, glColor3dv, 3); _colorDispatchers->assign(Array::Vec4dArrayType, glColor4dv, 4); - _secondaryColorDispatchers->assign(Array::Vec3ArrayType, extensions->_glSecondaryColor3fv, 3); + _secondaryColorDispatchers->assign(Array::Vec3ArrayType, extensions->glSecondaryColor3fv, 3); - _fogCoordDispatchers->assign(Array::FloatArrayType, extensions->_glFogCoordfv, 1); + _fogCoordDispatchers->assign(Array::FloatArrayType, extensions->glFogCoordfv, 1); #endif // pre allocate. @@ -281,7 +281,7 @@ AttributeDispatch* ArrayDispatchers::vertexAttribDispatcher(unsigned int unit, A void ArrayDispatchers::assignTexCoordDispatchers(unsigned int unit) { #if defined(OSG_GL_VERTEX_FUNCS_AVAILABLE) && !defined(OSG_GLES1_AVAILABLE) - Drawable::Extensions* extensions = Drawable::getExtensions(_state->getContextID(),true); + GL2Extensions* extensions = _state->get(); #endif for(unsigned int i=_texCoordDispatchers.size(); i<=unit; ++i) @@ -300,10 +300,10 @@ void ArrayDispatchers::assignTexCoordDispatchers(unsigned int unit) else { #if defined(OSG_GL_VERTEX_FUNCS_AVAILABLE) && !defined(OSG_GLES1_AVAILABLE) - texCoordDispatcher.targetAssign((GLenum)(GL_TEXTURE0+i), Array::FloatArrayType, extensions->_glMultiTexCoord1fv, 1); - texCoordDispatcher.targetAssign((GLenum)(GL_TEXTURE0+i), Array::Vec2ArrayType, extensions->_glMultiTexCoord2fv, 2); - texCoordDispatcher.targetAssign((GLenum)(GL_TEXTURE0+i), Array::Vec3ArrayType, extensions->_glMultiTexCoord3fv, 3); - texCoordDispatcher.targetAssign((GLenum)(GL_TEXTURE0+i), Array::Vec4ArrayType, extensions->_glMultiTexCoord4fv, 4); + texCoordDispatcher.targetAssign((GLenum)(GL_TEXTURE0+i), Array::FloatArrayType, extensions->glMultiTexCoord1fv, 1); + texCoordDispatcher.targetAssign((GLenum)(GL_TEXTURE0+i), Array::Vec2ArrayType, extensions->glMultiTexCoord2fv, 2); + texCoordDispatcher.targetAssign((GLenum)(GL_TEXTURE0+i), Array::Vec3ArrayType, extensions->glMultiTexCoord3fv, 3); + texCoordDispatcher.targetAssign((GLenum)(GL_TEXTURE0+i), Array::Vec4ArrayType, extensions->glMultiTexCoord4fv, 4); #endif } } @@ -312,16 +312,16 @@ void ArrayDispatchers::assignTexCoordDispatchers(unsigned int unit) void ArrayDispatchers::assignVertexAttribDispatchers(unsigned int unit) { - Drawable::Extensions* extensions = Drawable::getExtensions(_state->getContextID(),true); + GL2Extensions* extensions = _state->get(); for(unsigned int i=_vertexAttribDispatchers.size(); i<=unit; ++i) { _vertexAttribDispatchers.push_back(new AttributeDispatchMap()); AttributeDispatchMap& vertexAttribDispatcher = *_vertexAttribDispatchers[i]; - vertexAttribDispatcher.targetAssign(i, Array::FloatArrayType, extensions->_glVertexAttrib1fv, 1); - vertexAttribDispatcher.targetAssign(i, Array::Vec2ArrayType, extensions->_glVertexAttrib2fv, 2); - vertexAttribDispatcher.targetAssign(i, Array::Vec3ArrayType, extensions->_glVertexAttrib3fv, 3); - vertexAttribDispatcher.targetAssign(i, Array::Vec4ArrayType, extensions->_glVertexAttrib4fv, 4); + vertexAttribDispatcher.targetAssign(i, Array::FloatArrayType, extensions->glVertexAttrib1fv, 1); + vertexAttribDispatcher.targetAssign(i, Array::Vec2ArrayType, extensions->glVertexAttrib2fv, 2); + vertexAttribDispatcher.targetAssign(i, Array::Vec3ArrayType, extensions->glVertexAttrib3fv, 3); + vertexAttribDispatcher.targetAssign(i, Array::Vec4ArrayType, extensions->glVertexAttrib4fv, 4); } } diff --git a/src/osg/Drawable.cpp b/src/osg/Drawable.cpp index 106471d7b..cd2073e42 100644 --- a/src/osg/Drawable.cpp +++ b/src/osg/Drawable.cpp @@ -627,729 +627,3 @@ void Drawable::setBound(const BoundingBox& bb) const _boundingBox = bb; _boundingBoxComputed = true; } - - -////////////////////////////////////////////////////////////////////////////// -// -// Extension support -// - -typedef buffered_value< ref_ptr > 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"< - -typedef osg::buffered_value< osg::ref_ptr< osg::Drawable::Extensions > > OcclusionQueryBufferedExtensions; -static OcclusionQueryBufferedExtensions s_OQ_bufferedExtensions; - // // Support classes, used by (and private to) OcclusionQueryNode. // (Note a lot of this is historical. OcclusionQueryNode formaerly @@ -104,7 +100,7 @@ struct RetrieveQueriesCallback : public osg::Camera::DrawCallback typedef std::vector ResultsVector; ResultsVector _results; - RetrieveQueriesCallback( osg::Drawable::Extensions* ext=NULL ) + RetrieveQueriesCallback( osg::GL2Extensions* ext=NULL ) : _extensionsFallback( ext ) { } @@ -122,14 +118,12 @@ struct RetrieveQueriesCallback : public osg::Camera::DrawCallback double elapsedTime( 0. ); int count( 0 ); - osg::Drawable::Extensions* ext; + const osg::GL2Extensions* ext=0; if (camera.getGraphicsContext()) { // The typical path, for osgViewer-based applications or any // app that has set up a valid GraphicsCOntext for the Camera. - unsigned int contextID = camera.getGraphicsContext()->getState()->getContextID(); - RetrieveQueriesCallback* const_this = const_cast( this ); - ext = const_this->getExtensions( contextID, true ); + ext = camera.getGraphicsContext()->getState()->get(); } else { @@ -210,15 +204,7 @@ struct RetrieveQueriesCallback : public osg::Camera::DrawCallback _results.push_back( tr ); } - osg::Drawable::Extensions* getExtensions( unsigned int contextID, bool createIfNotInitalized ) - { - 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; + osg::GL2Extensions* _extensionsFallback; }; @@ -293,7 +279,7 @@ void QueryGeometry::drawImplementation( osg::RenderInfo& renderInfo ) const { unsigned int contextID = renderInfo.getState()->getContextID(); - osg::Drawable::Extensions* ext = getExtensions( contextID, true ); + osg::GL2Extensions* ext = renderInfo.getState()->get(); osg::Camera* cam = renderInfo.getCurrentCamera(); // Add callbacks if necessary. @@ -426,7 +412,7 @@ QueryGeometry::flushDeletedQueryObjects( unsigned int contextID, double /*curren { OpenThreads::ScopedLock 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]; diff --git a/src/osg/State.cpp b/src/osg/State.cpp index 31078d67c..c5d50e67f 100644 --- a/src/osg/State.cpp +++ b/src/osg/State.cpp @@ -966,8 +966,7 @@ void State::initializeExtensionProcs() _glMaxTextureCoords = 1; } - osg::Drawable::Extensions* extensions = osg::Drawable::getExtensions(getContextID(), true); - if (extensions && extensions->isARBTimerQuerySupported()) + if (_gl2Extentsions->isARBTimerQuerySupported) { const GLubyte* renderer = glGetString(GL_RENDERER); std::string rendererString = renderer ? (const char*)renderer : ""; @@ -982,7 +981,7 @@ void State::initializeExtensionProcs() else { 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); } } @@ -1758,11 +1757,10 @@ void State::print(std::ostream& fout) const void State::frameCompleted() { - osg::Drawable::Extensions* extensions = osg::Drawable::getExtensions(getContextID(), true); - if (extensions && getTimestampBits()) + if (getTimestampBits()) { GLint64 timestamp; - extensions->glGetInteger64v(GL_TIMESTAMP, ×tamp); + _gl2Extentsions->glGetInteger64v(GL_TIMESTAMP, ×tamp); setGpuTimestamp(osg::Timer::instance()->tick(), timestamp); //OSG_NOTICE<<"State::frameCompleted() setting time stamp. timestamp="<()->isRectangleSupported) { OSG_WARN<<"Warning: TextureRectangle::apply(..) failed, texture rectangle is not support by your OpenGL drivers."<get(); // save OpenGL matrices glPushMatrix(); diff --git a/src/osgViewer/Renderer.cpp b/src/osgViewer/Renderer.cpp index b864d39eb..ff7c160eb 100644 --- a/src/osgViewer/Renderer.cpp +++ b/src/osgViewer/Renderer.cpp @@ -132,7 +132,7 @@ void EXTQuerySupport::endQuery(osg::State* /*state*/) void OpenGLQuerySupport::initialize(osg::State* state, osg::Timer_t /*startTick*/) { - _extensions = osg::Drawable::getExtensions(state->getContextID(),true); + _extensions = state->get(); } void EXTQuerySupport::initialize(osg::State* state, osg::Timer_t startTick) @@ -464,10 +464,10 @@ void Renderer::initialize(osg::State* state) if (!_initialized) { _initialized = true; - osg::Drawable::Extensions* ext = osg::Drawable::getExtensions(state->getContextID(), true); - if (ext->isARBTimerQuerySupported() && state->getTimestampBits() > 0) + osg::GL2Extensions* ext = state->get(); + if (ext->isARBTimerQuerySupported && state->getTimestampBits() > 0) _querySupport = new ARBQuerySupport(); - else if (ext->isTimerQuerySupported()) + else if (ext->isTimerQuerySupported) _querySupport = new EXTQuerySupport(); if (_querySupport.valid()) _querySupport->initialize(state, _startTick); diff --git a/src/osgViewer/StatsHandler.cpp b/src/osgViewer/StatsHandler.cpp index 0abdc74de..c6965eb34 100644 --- a/src/osgViewer/StatsHandler.cpp +++ b/src/osgViewer/StatsHandler.cpp @@ -1102,12 +1102,9 @@ void StatsHandler::setUpScene(osgViewer::ViewerBase* viewer) if ((*citr)->getGraphicsContext()) { const osg::State* state = (*citr)->getGraphicsContext()->getState(); - unsigned int contextID = state->getContextID(); - const osg::Drawable::Extensions* extensions = osg::Drawable::getExtensions(contextID, false); + const osg::GL2Extensions* extensions = state->get(); if (extensions && - (((extensions->isARBTimerQuerySupported() - && state->getTimestampBits() > 0)) - || extensions->isTimerQuerySupported())) + (((extensions->isARBTimerQuerySupported && state->getTimestampBits() > 0)) || extensions->isTimerQuerySupported)) { ++numCamrasWithTimerQuerySupport; }