From: <axl...@us...> - 2009-06-17 01:06:16
|
Revision: 344 http://hgengine.svn.sourceforge.net/hgengine/?rev=344&view=rev Author: axlecrusher Date: 2009-06-17 01:06:15 +0000 (Wed, 17 Jun 2009) Log Message: ----------- use list Modified Paths: -------------- Mercury2/src/Shader.cpp Mercury2/src/Shader.h Modified: Mercury2/src/Shader.cpp =================================================================== --- Mercury2/src/Shader.cpp 2009-06-17 01:05:04 UTC (rev 343) +++ Mercury2/src/Shader.cpp 2009-06-17 01:06:15 UTC (rev 344) @@ -327,7 +327,9 @@ GLenum type; glGetActiveUniformARB( iProgramID, i, 1024, &bufflen, &size, &type, buffer ); buffer[bufflen] = 0; - m_uniforms[buffer] = glGetUniformLocationARB( iProgramID, buffer ); +// m_uniforms[buffer] = glGetUniformLocationARB( iProgramID, buffer ); + int location = glGetUniformLocationARB( iProgramID, buffer ); + m_uniforms.push_back( std::pair<MString,int> (buffer, location) ); } return true; } @@ -411,7 +413,7 @@ GLERRORCHECK; //set attributes here - std::map< MString, int >::iterator ui = m_uniforms.begin(); + std::list< std::pair< MString, int > >::iterator ui = m_uniforms.begin(); for (;ui != m_uniforms.end(); ++ui) { std::map< MString, ShaderAttribute >::iterator sai = m_globalAttributes.find( ui->first ); @@ -431,9 +433,11 @@ int32_t Shader::GetUniformLocation(const MString& n) { if ( !iProgramID ) return -1; - std::map< MString, int >::iterator i = m_uniforms.find(n); - if ( i == m_uniforms.end() ) return -1; - return i->second; + + std::list< std::pair< MString, int > >::iterator i = m_uniforms.begin(); + for (;i != m_uniforms.end(); ++i) + if (i->first == n) return i->second; + return -1; } void Shader::SetAttribute(const MString& name, const ShaderAttribute& x) Modified: Mercury2/src/Shader.h =================================================================== --- Mercury2/src/Shader.h 2009-06-17 01:05:04 UTC (rev 343) +++ Mercury2/src/Shader.h 2009-06-17 01:06:15 UTC (rev 344) @@ -149,8 +149,10 @@ unsigned int fragmentShader; ///Shader attributes - /** These are the attributes linked into the shader */ - std::map< MString, int > m_uniforms; + /** These are the attributes linked into the shader. + There are so few uniforms in a shader that a list with + a linear search should be faster than a tree*/ + std::list< std::pair< MString, int > > m_uniforms; ///Name of the shader MString sShaderName; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |