From 652c274d099293d5ed088369c4109b1b5afabe3e Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 11 Jan 2011 17:18:44 +0000 Subject: [PATCH] From Chris Hanson, "As an extension to this excellent work: http://forum.openscenegraph.org/viewtopic.php?t=7285 This file adds the same string API wrapper to the State object for other older apps that track Uniforms by string. The original comment about performance is preserved." --- include/osg/State | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/osg/State b/include/osg/State index 89477e2fd..673d23813 100644 --- a/include/osg/State +++ b/include/osg/State @@ -1255,6 +1255,15 @@ class OSG_EXPORT State : public Referenced, public Observer inline const Program::PerContextProgram* getLastAppliedProgramObject() const { return _lastAppliedProgramObject; } inline GLint getUniformLocation( unsigned int uniformNameID ) const { return _lastAppliedProgramObject ? _lastAppliedProgramObject->getUniformLocation(uniformNameID) : -1; } + /** + * Alternative version of getUniformLocation( unsigned int uniformNameID ) + * retrofited into OSG for backward compatibility with osgCal, + * after uniform ids were refactored from std::strings to GLints in OSG version 2.9.10. + * + * Drawbacks: This method is not particularly fast. It has to access mutexed static + * map of uniform ids. So don't overuse it or your app performance will suffer. + */ + inline GLint getUniformLocation( const std::string & uniformName ) const { return _lastAppliedProgramObject ? _lastAppliedProgramObject->getUniformLocation(uniformName) : -1; } inline GLint getAttribLocation( const std::string& name ) const { return _lastAppliedProgramObject ? _lastAppliedProgramObject->getAttribLocation(name) : -1; } typedef std::pair AttributePair;