From Wojciech Lewandowski, "As suggested I have added missing method to PerContextProgram. Tested with our programs.

I see that we should expect some performance penalty for using this method.  It won’t be painful in my current case because I have only a few animated characters. But I suspect  some day I will have to fix osgCal to use int UniformIds natively for larger crowds."
This commit is contained in:
Robert Osfield 2010-12-12 09:22:09 +00:00
parent df5210f729
commit c959bab0a6

View File

@ -238,6 +238,17 @@ class OSG_EXPORT Program : public osg::StateAttribute
const ActiveVarInfoMap& getActiveAttribs() const {return _attribInfoMap;} const ActiveVarInfoMap& getActiveAttribs() const {return _attribInfoMap;}
const UniformBlockMap& getUniformBlocks() const {return _uniformBlockMap; } const UniformBlockMap& getUniformBlocks() const {return _uniformBlockMap; }
inline GLint getUniformLocation( unsigned int uniformNameID ) const { ActiveUniformMap::const_iterator itr = _uniformInfoMap.find(uniformNameID); return (itr!=_uniformInfoMap.end()) ? itr->second._location : -1; } inline GLint getUniformLocation( unsigned int uniformNameID ) const { ActiveUniformMap::const_iterator itr = _uniformInfoMap.find(uniformNameID); return (itr!=_uniformInfoMap.end()) ? itr->second._location : -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 getUniformLocation( Uniform::getNameID( uniformName ) ); }
inline GLint getAttribLocation( const std::string& name ) const { ActiveVarInfoMap::const_iterator itr = _attribInfoMap.find(name); return (itr!=_attribInfoMap.end()) ? itr->second._location : -1; } inline GLint getAttribLocation( const std::string& name ) const { ActiveVarInfoMap::const_iterator itr = _attribInfoMap.find(name); return (itr!=_attribInfoMap.end()) ? itr->second._location : -1; }
inline void addShaderToAttach(Shader *shader) inline void addShaderToAttach(Shader *shader)