From 4fc4e60cc385994a48b55685daa8cfe9d5b0fb76 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Wed, 8 Mar 2006 16:11:54 +0000 Subject: [PATCH] From Bob Kuehne, added osg::getGlVersion() and fixed a minor typo in Texture3D. --- include/osg/GLExtensions | 6 ++++++ include/osg/Texture3D | 2 +- src/osg/GLExtensions.cpp | 8 ++++++++ src/osg/Texture3D.cpp | 4 ++-- src/osgWrappers/osg/Texture3D.cpp | 4 ++-- 5 files changed, 19 insertions(+), 5 deletions(-) diff --git a/include/osg/GLExtensions b/include/osg/GLExtensions index 7b73ac8a6..3bef91e58 100644 --- a/include/osg/GLExtensions +++ b/include/osg/GLExtensions @@ -20,6 +20,12 @@ namespace osg { +/** Return floating-point OpenGL version number. + * Note: Must only be called within a valid OpenGL context, + * undefined behavior may occur otherwise. +*/ +extern OSG_EXPORT float getGLVersionNumber(); + /** Return true if OpenGL "extension" is supported. * Note: Must only be called within a valid OpenGL context, * undefined behavior may occur otherwise. diff --git a/include/osg/Texture3D b/include/osg/Texture3D index acfbf1639..98d47e001 100644 --- a/include/osg/Texture3D +++ b/include/osg/Texture3D @@ -144,7 +144,7 @@ class OSG_EXPORT Texture3D : public Texture void lowestCommonDenominator(const Extensions& rhs); - void setupGLExtenions(unsigned int contextID); + void setupGLExtensions(unsigned int contextID); void setTexture3DSupported(bool flag) { _isTexture3DSupported=flag; } bool isTexture3DSupported() const { return _isTexture3DSupported; } diff --git a/src/osg/GLExtensions.cpp b/src/osg/GLExtensions.cpp index 6158d44d0..8bcf92d60 100644 --- a/src/osg/GLExtensions.cpp +++ b/src/osg/GLExtensions.cpp @@ -28,6 +28,14 @@ #include #endif +float osg::getGLVersionNumber() +{ + // needs to be extended to do proper things with subversions like 1.5.1, etc. + char *versionstring = (char*) glGetString( GL_VERSION ); + std::string vs( versionstring ); + return( atof( vs.substr( 0, vs.find( " " ) ).c_str() ) ); +} + bool osg::isGLExtensionSupported(unsigned int contextID, const char *extension) { typedef std::set ExtensionSet; diff --git a/src/osg/Texture3D.cpp b/src/osg/Texture3D.cpp index 28157e98e..960b2e76a 100644 --- a/src/osg/Texture3D.cpp +++ b/src/osg/Texture3D.cpp @@ -439,7 +439,7 @@ void Texture3D::setExtensions(unsigned int contextID,Extensions* extensions) Texture3D::Extensions::Extensions(unsigned int contextID) { - setupGLExtenions(contextID); + setupGLExtensions(contextID); } Texture3D::Extensions::Extensions(const Extensions& rhs): @@ -469,7 +469,7 @@ void Texture3D::Extensions::lowestCommonDenominator(const Extensions& rhs) if (!rhs._gluBuild3DMipmaps) _gluBuild3DMipmaps = 0; } -void Texture3D::Extensions::setupGLExtenions(unsigned int contextID) +void Texture3D::Extensions::setupGLExtensions(unsigned int contextID) { _isTexture3DFast = isGLExtensionSupported(contextID,"GL_EXT_texture3D"); diff --git a/src/osgWrappers/osg/Texture3D.cpp b/src/osgWrappers/osg/Texture3D.cpp index 8e5ac4840..aa9133053 100644 --- a/src/osgWrappers/osg/Texture3D.cpp +++ b/src/osgWrappers/osg/Texture3D.cpp @@ -74,7 +74,7 @@ BEGIN_OBJECT_REFLECTOR(osg::Texture3D::Extensions) I_Constructor1(IN, unsigned int, contextID); I_Constructor1(IN, const osg::Texture3D::Extensions &, rhs); I_Method1(void, lowestCommonDenominator, IN, const osg::Texture3D::Extensions &, rhs); - I_Method1(void, setupGLExtenions, IN, unsigned int, contextID); + I_Method1(void, setupGLExtensions, IN, unsigned int, contextID); I_Method1(void, setTexture3DSupported, IN, bool, flag); I_Method0(bool, isTexture3DSupported); I_Method1(void, setTexture3DFast, IN, bool, flag); @@ -104,7 +104,7 @@ BEGIN_OBJECT_REFLECTOR(osg::Texture3D::Extensions) I_WriteOnlyProperty(void *, TexSubImage3DProc); I_WriteOnlyProperty(bool, Texture3DFast); I_WriteOnlyProperty(bool, Texture3DSupported); - I_WriteOnlyProperty(unsigned int, upGLExtenions); + I_WriteOnlyProperty(unsigned int, upGLExtensions); END_REFLECTOR BEGIN_ABSTRACT_OBJECT_REFLECTOR(osg::Texture3D::SubloadCallback)