diff --git a/src/osg/State.cpp b/src/osg/State.cpp index 778be2f3e..565967dcf 100644 --- a/src/osg/State.cpp +++ b/src/osg/State.cpp @@ -152,6 +152,96 @@ State::~State() //_vertexAttribArrayList.clear(); } +void State::initializeExtensionProcs() +{ + if (_extensionProcsInitialized) return; + + const char* vendor = (const char*) glGetString( GL_VENDOR ); + if (vendor) + { + std::string str_vendor(vendor); + std::replace(str_vendor.begin(), str_vendor.end(), ' ', '_'); + OSG_INFO<<"GL_VENDOR = ["<= 2.0 || osg::isGLExtensionSupported(_contextID, "GL_ARB_vertex_shader") || OSG_GLES2_FEATURES || OSG_GL3_FEATURES) + { + glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS,&_glMaxTextureUnits); + #ifdef OSG_GL_FIXED_FUNCTION_AVAILABLE + glGetIntegerv(GL_MAX_TEXTURE_COORDS, &_glMaxTextureCoords); + #else + _glMaxTextureCoords = _glMaxTextureUnits; + #endif + } + else if ( osg::getGLVersionNumber() >= 1.3 || + osg::isGLExtensionSupported(_contextID,"GL_ARB_multitexture") || + osg::isGLExtensionSupported(_contextID,"GL_EXT_multitexture") || + OSG_GLES1_FEATURES) + { + GLint maxTextureUnits = 0; + glGetIntegerv(GL_MAX_TEXTURE_UNITS,&maxTextureUnits); + _glMaxTextureUnits = maxTextureUnits; + _glMaxTextureCoords = maxTextureUnits; + } + else + { + _glMaxTextureUnits = 1; + _glMaxTextureCoords = 1; + } + + if (_glExtensions->isARBTimerQuerySupported) + { + const GLubyte* renderer = glGetString(GL_RENDERER); + std::string rendererString = renderer ? (const char*)renderer : ""; + if (rendererString.find("Radeon")!=std::string::npos || rendererString.find("RADEON")!=std::string::npos || rendererString.find("FirePro")!=std::string::npos) + { + // AMD/ATI drivers are producing an invalid enumerate error on the + // glGetQueryiv(GL_TIMESTAMP, GL_QUERY_COUNTER_BITS_ARB, &bits); + // call so work around it by assuming 64 bits for counter. + setTimestampBits(64); + //setTimestampBits(0); + } + else + { + GLint bits = 0; + _glExtensions->glGetQueryiv(GL_TIMESTAMP, GL_QUERY_COUNTER_BITS_ARB, &bits); + setTimestampBits(bits); + } + } + + + _extensionProcsInitialized = true; + + if (_graphicsCostEstimator.valid()) + { + RenderInfo renderInfo(this,0); + _graphicsCostEstimator->calibrate(renderInfo); + } +} + void State::releaseGLObjects() { // release any GL objects held by the shader composer @@ -959,96 +1049,6 @@ void State::setInterleavedArrays( GLenum format, GLsizei stride, const GLvoid* p dirtyAllVertexArrays(); } -void State::initializeExtensionProcs() -{ - if (_extensionProcsInitialized) return; - - const char* vendor = (const char*) glGetString( GL_VENDOR ); - if (vendor) - { - std::string str_vendor(vendor); - std::replace(str_vendor.begin(), str_vendor.end(), ' ', '_'); - OSG_INFO<<"GL_VENDOR = ["<= 2.0 || osg::isGLExtensionSupported(_contextID, "GL_ARB_vertex_shader") || OSG_GLES2_FEATURES || OSG_GL3_FEATURES) - { - glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS,&_glMaxTextureUnits); - #ifdef OSG_GL_FIXED_FUNCTION_AVAILABLE - glGetIntegerv(GL_MAX_TEXTURE_COORDS, &_glMaxTextureCoords); - #else - _glMaxTextureCoords = _glMaxTextureUnits; - #endif - } - else if ( osg::getGLVersionNumber() >= 1.3 || - osg::isGLExtensionSupported(_contextID,"GL_ARB_multitexture") || - osg::isGLExtensionSupported(_contextID,"GL_EXT_multitexture") || - OSG_GLES1_FEATURES) - { - GLint maxTextureUnits = 0; - glGetIntegerv(GL_MAX_TEXTURE_UNITS,&maxTextureUnits); - _glMaxTextureUnits = maxTextureUnits; - _glMaxTextureCoords = maxTextureUnits; - } - else - { - _glMaxTextureUnits = 1; - _glMaxTextureCoords = 1; - } - - if (_glExtensions->isARBTimerQuerySupported) - { - const GLubyte* renderer = glGetString(GL_RENDERER); - std::string rendererString = renderer ? (const char*)renderer : ""; - if (rendererString.find("Radeon")!=std::string::npos || rendererString.find("RADEON")!=std::string::npos || rendererString.find("FirePro")!=std::string::npos) - { - // AMD/ATI drivers are producing an invalid enumerate error on the - // glGetQueryiv(GL_TIMESTAMP, GL_QUERY_COUNTER_BITS_ARB, &bits); - // call so work around it by assuming 64 bits for counter. - setTimestampBits(64); - //setTimestampBits(0); - } - else - { - GLint bits = 0; - _glExtensions->glGetQueryiv(GL_TIMESTAMP, GL_QUERY_COUNTER_BITS_ARB, &bits); - setTimestampBits(bits); - } - } - - - _extensionProcsInitialized = true; - - if (_graphicsCostEstimator.valid()) - { - RenderInfo renderInfo(this,0); - _graphicsCostEstimator->calibrate(renderInfo); - } -} - bool State::setClientActiveTextureUnit( unsigned int unit ) { if (unit!=_currentClientActiveTextureUnit)