diff options
5 files changed, 29 insertions, 24 deletions
diff --git a/include/vcl/opengl/OpenGLHelper.hxx b/include/vcl/opengl/OpenGLHelper.hxx index 9cc485b03646..87a71fac5ab9 100644 --- a/include/vcl/opengl/OpenGLHelper.hxx +++ b/include/vcl/opengl/OpenGLHelper.hxx @@ -36,6 +36,9 @@ public: */ static void createFramebuffer(long nWidth, long nHeight, GLuint& nFramebufferId, GLuint& nRenderbufferTextId, GLuint& nRenderbufferColorId); + + // Get OpenGL version (needs a context) + static float getGLVersion(); }; VCLOPENGL_DLLPUBLIC std::ostream& operator<<(std::ostream& rStrm, const glm::mat4& rMatrix); diff --git a/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionerImpl.cxx b/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionerImpl.cxx index 36c1dd085279..378de36ce5e4 100644 --- a/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionerImpl.cxx +++ b/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionerImpl.cxx @@ -61,6 +61,7 @@ #include <vcl/canvastools.hxx> #include <vcl/opengl/OpenGLContext.hxx> +#include <vcl/opengl/OpenGLHelper.hxx> #include <vcl/window.hxx> #include <boost/noncopyable.hpp> @@ -337,14 +338,8 @@ void OGLTransitionerImpl::impl_initializeFlags( bool const bGLXPresent ) { mbGLXPresent = bGLXPresent; if ( bGLXPresent ) { - const GLubyte* version = glGetString( GL_VERSION ); - if( version && version[0] ) { - mnGLVersion = version[0] - '0'; - if( version[1] == '.' && version[2] ) - mnGLVersion += (version[2] - '0')/10.0; - } else - mnGLVersion = 1.0; - SAL_INFO("slideshow.opengl", "GL version: " << version << " parsed: " << mnGLVersion << "" ); + mnGLVersion = OpenGLHelper::getGLVersion(); + SAL_INFO("slideshow.opengl", "GL version: " << mnGLVersion << "" ); const GLubyte* vendor = glGetString( GL_VENDOR ); mbMesa = ( vendor && strstr( (const char *) vendor, "Mesa" ) ); diff --git a/slideshow/source/engine/OGLTrans/mac/OGLTrans_TransitionerImpl.mm b/slideshow/source/engine/OGLTrans/mac/OGLTrans_TransitionerImpl.mm index 47cdb2d7ee66..62b135a446d3 100644 --- a/slideshow/source/engine/OGLTrans/mac/OGLTrans_TransitionerImpl.mm +++ b/slideshow/source/engine/OGLTrans/mac/OGLTrans_TransitionerImpl.mm @@ -56,6 +56,8 @@ #include <vcl/syschild.hxx> #include <vcl/sysdata.hxx> +#include <vcl/opengl/OpenGLHelper.hxx> + #include <boost/noncopyable.hpp> #include <premac.h> @@ -311,14 +313,8 @@ bool OGLTransitionerImpl::initialize( const Reference< presentation::XSlideShowV if( instance->initWindowFromSlideShowView( xView ) ) { - const GLubyte* version = glGetString( GL_VERSION ); - if( version && version[0] ) { - cnGLVersion = version[0] - '0'; - if( version[1] == '.' && version[2] ) - cnGLVersion += (version[2] - '0')/10.0; - } else - cnGLVersion = 1.0; - OSL_TRACE("GL version: %s parsed: %f", version, cnGLVersion ); + cnGLVersion = OpenGLHelper::getGLVersion(); + OSL_TRACE("GL version: %f", cnGLVersion ); const GLubyte* vendor = glGetString( GL_VENDOR ); cbMesa = ( vendor && strstr( (const char *) vendor, "Mesa" ) ); diff --git a/slideshow/source/engine/OGLTrans/win/OGLTrans_TransitionerImpl.cxx b/slideshow/source/engine/OGLTrans/win/OGLTrans_TransitionerImpl.cxx index 19f22fdea618..2fcd3b537976 100644 --- a/slideshow/source/engine/OGLTrans/win/OGLTrans_TransitionerImpl.cxx +++ b/slideshow/source/engine/OGLTrans/win/OGLTrans_TransitionerImpl.cxx @@ -56,6 +56,8 @@ #include <vcl/syschild.hxx> #include <vcl/sysdata.hxx> +#include <vcl/opengl/OpenGLHelper.hxx> + #include <boost/noncopyable.hpp> #include <GL/gl.h> @@ -314,14 +316,8 @@ bool OGLTransitionerImpl::initialize( const Reference< presentation::XSlideShowV instance = new OGLTransitionerImpl( NULL ); if( instance->initWindowFromSlideShowView( xView ) ) { - const GLubyte* version = glGetString( GL_VERSION ); - if( version && version[0] ) { - cnGLVersion = version[0] - '0'; - if( version[1] == '.' && version[2] ) - cnGLVersion += (version[2] - '0')/10.0; - } else - cnGLVersion = 1.0; - OSL_TRACE("GL version: %s parsed: %f", version, cnGLVersion ); + cnGLVersion = OpenGLHelper::getGLVersion(); + OSL_TRACE("GL version: %f", cnGLVersion ); const GLubyte* vendor = glGetString( GL_VENDOR ); cbMesa = ( vendor && strstr( (const char *) vendor, "Mesa" ) ); diff --git a/vcl/source/opengl/OpenGLHelper.cxx b/vcl/source/opengl/OpenGLHelper.cxx index a2d9b83aae61..0629d90b88a6 100644 --- a/vcl/source/opengl/OpenGLHelper.cxx +++ b/vcl/source/opengl/OpenGLHelper.cxx @@ -305,5 +305,20 @@ void OpenGLHelper::createFramebuffer(long nWidth, long nHeight, glBindFramebuffer(GL_FRAMEBUFFER, 0); } +float OpenGLHelper::getGLVersion() +{ + float fVersion = 1.0; + const GLubyte* aVersion = glGetString( GL_VERSION ); + if( aVersion && aVersion[0] ) + { + fVersion = aVersion[0] - '0'; + if( aVersion[1] == '.' && aVersion[2] ) + { + fVersion += (aVersion[2] - '0')/10.0; + } + } + return fVersion; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |