From ee319215203e6b4bac48bf22304d2752e1eb8e66 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Mon, 8 Aug 2016 17:57:20 +0100 Subject: [PATCH] Streamlined State::_is*Supported variables --- include/osg/State | 18 +++++------------- src/osg/State.cpp | 42 ++++-------------------------------------- 2 files changed, 9 insertions(+), 51 deletions(-) diff --git a/include/osg/State b/include/osg/State index 4297c70bd..570cac5aa 100644 --- a/include/osg/State +++ b/include/osg/State @@ -715,7 +715,7 @@ class OSG_EXPORT State : public Referenced void dirtyAllVertexArrays(); - inline bool isVertexBufferObjectSupported() const { return _isVertexBufferObjectSupportResolved?_isVertexBufferObjectSupported:computeVertexBufferObjectSupported(); } + inline bool isVertexBufferObjectSupported() const { return _isVertexBufferObjectSupported; } inline bool isVertexArrayObjectSupported() const { return _isVertexArrayObjectSupported; } @@ -1302,19 +1302,11 @@ class OSG_EXPORT State : public Referenced void loadModelViewMatrix(); - mutable bool _isSecondaryColorSupportResolved; - mutable bool _isSecondaryColorSupported; - bool computeSecondaryColorSupported() const; - - mutable bool _isFogCoordSupportResolved; - mutable bool _isFogCoordSupported; - bool computeFogCoordSupported() const; - - mutable bool _isVertexBufferObjectSupportResolved; - mutable bool _isVertexBufferObjectSupported; - bool computeVertexBufferObjectSupported() const; - + bool _isSecondaryColorSupported; + bool _isFogCoordSupported; + bool _isVertexBufferObjectSupported; bool _isVertexArrayObjectSupported; + bool _useVertexArrayObject; typedef void (GL_APIENTRY * ActiveTextureProc) (GLenum texture); diff --git a/src/osg/State.cpp b/src/osg/State.cpp index 157764210..73f84c097 100644 --- a/src/osg/State.cpp +++ b/src/osg/State.cpp @@ -92,15 +92,9 @@ State::State(): _currentEBO = 0; _currentPBO = 0; - _isSecondaryColorSupportResolved = false; _isSecondaryColorSupported = false; - - _isFogCoordSupportResolved = false; _isFogCoordSupported = false; - - _isVertexBufferObjectSupportResolved = false; _isVertexBufferObjectSupported = false; - _isVertexArrayObjectSupported = false; _useVertexArrayObject = false; @@ -176,13 +170,12 @@ void State::initializeExtensionProcs() _glExtensions = new GLExtensions(_contextID); GLExtensions::Set(_contextID, _glExtensions.get()); - computeSecondaryColorSupported(); - computeFogCoordSupported(); - computeVertexBufferObjectSupported(); + _isSecondaryColorSupported = osg::isGLExtensionSupported(_contextID,"GL_EXT_secondary_color"); + _isFogCoordSupported = osg::isGLExtensionSupported(_contextID,"GL_EXT_fog_coord"); + _isVertexBufferObjectSupported = OSG_GLES2_FEATURES || OSG_GL3_FEATURES || osg::isGLExtensionSupported(_contextID,"GL_ARB_vertex_buffer_object"); + _isVertexArrayObjectSupported = _glExtensions->isVAOSupported; const DisplaySettings* ds = getDisplaySettings() ? getDisplaySettings() : osg::DisplaySettings::instance(); - - _isVertexArrayObjectSupported = _glExtensions->isVAOSupported; _useVertexArrayObject = _isVertexArrayObjectSupported && (ds->getGeometryImplementation()==DisplaySettings::VERTEX_ARRAY_OBJECT); @@ -1079,33 +1072,6 @@ unsigned int State::getClientActiveTextureUnit() const } - -///////////////////////////////////////////////////////////////////////// -// -// End of Moved from State header -// - -bool State::computeSecondaryColorSupported() const -{ - _isSecondaryColorSupportResolved = true; - _isSecondaryColorSupported = osg::isGLExtensionSupported(_contextID,"GL_EXT_secondary_color"); - return _isSecondaryColorSupported; -} - -bool State::computeFogCoordSupported() const -{ - _isFogCoordSupportResolved = true; - _isFogCoordSupported = osg::isGLExtensionSupported(_contextID,"GL_EXT_fog_coord"); - return _isFogCoordSupported; -} - -bool State::computeVertexBufferObjectSupported() const -{ - _isVertexBufferObjectSupportResolved = true; - _isVertexBufferObjectSupported = OSG_GLES2_FEATURES || OSG_GL3_FEATURES || osg::isGLExtensionSupported(_contextID,"GL_ARB_vertex_buffer_object"); - return _isVertexBufferObjectSupported; -} - bool State::checkGLErrors(const char* str) const { GLenum errorNo = glGetError();