|
From: <axl...@us...> - 2010-05-03 02:26:00
|
Revision: 720
http://hgengine.svn.sourceforge.net/hgengine/?rev=720&view=rev
Author: axlecrusher
Date: 2010-05-03 02:25:54 +0000 (Mon, 03 May 2010)
Log Message:
-----------
It is not necessary to look up the uniform by name again when we just found it and can just pass the uniform location along.
Modified Paths:
--------------
Mercury2/src/Shader.cpp
Mercury2/src/Shader.h
Modified: Mercury2/src/Shader.cpp
===================================================================
--- Mercury2/src/Shader.cpp 2010-05-03 02:22:28 UTC (rev 719)
+++ Mercury2/src/Shader.cpp 2010-05-03 02:25:54 UTC (rev 720)
@@ -442,7 +442,7 @@
{
ShaderAttribute* a = m_globalAttributes.get( ui->name );
if( a )
- SetAttributeInternal(ui->name,*a);
+ SetAttributeInternal(ui->id,*a);
}
}
@@ -479,26 +479,30 @@
void Shader::SetAttributeInternal(const MString& name, const ShaderAttribute& x)
{
int location = GetUniformLocation( name );
+ SetAttributeInternal(location, x);
+}
- if ( location != -1 )
+void Shader::SetAttributeInternal(int uniformLoc, const ShaderAttribute& x)
+{
+ if ( uniformLoc != -1 )
{
switch( x.type )
{
case ShaderAttribute::TYPE_INT:
case ShaderAttribute::TYPE_SAMPLER:
- GLCALL( glUniform1iARB( location, x.value.iInt ) );
+ GLCALL( glUniform1iARB( uniformLoc, x.value.iInt ) );
break;
case ShaderAttribute::TYPE_FLOAT:
- GLCALL( glUniform1fARB( location, x.value.fFloat ) );
+ GLCALL( glUniform1fARB( uniformLoc, x.value.fFloat ) );
break;
case ShaderAttribute::TYPE_FLOATV4:
- GLCALL( glUniform4fvARB( location, 1, &x.value.fFloatV4[0] ) );
+ GLCALL( glUniform4fvARB( uniformLoc, 1, &x.value.fFloatV4[0] ) );
break;
case ShaderAttribute::TYPE_MATRIX:
- GLCALL( glUniformMatrix4fvARB(location, 1, 1, x.value.matrix) ); //transpose too
+ GLCALL( glUniformMatrix4fvARB(uniformLoc, 1, 1, x.value.matrix) ); //transpose too
break;
case ShaderAttribute::TYPE_INT4:
- GLCALL( glUniform4ivARB( location, 1, x.value.iInts ) );
+ GLCALL( glUniform4ivARB( uniformLoc, 1, x.value.iInts ) );
break;
};
GLERRORCHECK;
Modified: Mercury2/src/Shader.h
===================================================================
--- Mercury2/src/Shader.h 2010-05-03 02:22:28 UTC (rev 719)
+++ Mercury2/src/Shader.h 2010-05-03 02:25:54 UTC (rev 720)
@@ -100,6 +100,7 @@
int32_t GetUniformLocation(const MString& n);
void SetAttributeInternal(const MString& name, const ShaderAttribute& x);
+ void SetAttributeInternal(int uniformLoc, const ShaderAttribute& x);
///Suggested function for loading shaders.
/** This function looks for {sShaderName}.vert and {sShaderName}.frag. It will
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|