Optimized Shader::setParameter functions, by using a cache internally (#316, #358)

This commit is contained in:
Laurent Gomila 2013-06-18 11:55:21 +02:00
parent 76b67fcd1c
commit 7554c86f7d
2 changed files with 75 additions and 41 deletions

View file

@ -507,10 +507,21 @@ private :
////////////////////////////////////////////////////////////
void bindTextures() const;
////////////////////////////////////////////////////////////
/// \brief Get the location ID of a shader parameter
///
/// \param name Name of the parameter to search
///
/// \return Location ID of the parameter, or -1 if not found
///
////////////////////////////////////////////////////////////
int getParamLocation(const std::string& name);
////////////////////////////////////////////////////////////
// Types
////////////////////////////////////////////////////////////
typedef std::map<int, const Texture*> TextureTable;
typedef std::map<std::string, int> ParamTable;
////////////////////////////////////////////////////////////
// Member data
@ -518,6 +529,7 @@ private :
unsigned int m_shaderProgram; ///< OpenGL identifier for the program
int m_currentTexture; ///< Location of the current texture in the shader
TextureTable m_textures; ///< Texture variables in the shader, mapped to their location
ParamTable m_params; ///< Parameters location cache
};
} // namespace sf