|
From: <axl...@us...> - 2009-06-14 15:14:36
|
Revision: 326
http://hgengine.svn.sourceforge.net/hgengine/?rev=326&view=rev
Author: axlecrusher
Date: 2009-06-14 13:55:32 +0000 (Sun, 14 Jun 2009)
Log Message:
-----------
fix shader uniforms
Modified Paths:
--------------
Mercury2/src/Shader.cpp
Mercury2/src/Shader.h
Modified: Mercury2/src/Shader.cpp
===================================================================
--- Mercury2/src/Shader.cpp 2009-06-14 13:08:31 UTC (rev 325)
+++ Mercury2/src/Shader.cpp 2009-06-14 13:55:32 UTC (rev 326)
@@ -327,6 +327,7 @@
glGetActiveUniformARB( iProgramID, i, 1024, &bufflen, &size, &type, buffer );
buffer[bufflen] = 0;
m_vShaderTabs[i] = SHADERATTRIBUTES.GetHandle( buffer );
+ m_vShaderTabs[i]->name = buffer;
}
return true;
}
@@ -407,17 +408,19 @@
for( unsigned i = 0; i < m_vShaderTabs.size(); ++i )
{
+ int location = glGetUniformLocationARB( iProgramID, m_vShaderTabs[i]->name.c_str() );
+
ShaderAttribute * sa = m_vShaderTabs[i];
- switch( sa->typ )
+ switch( sa->type )
{
case ShaderAttribute::TYPE_INT:
case ShaderAttribute::TYPE_SAMPLER:
- glUniform1iARB( i, sa->sau.iInt );
+ glUniform1iARB( location, sa->value.iInt );
GLERRORCHECK;
break;
case ShaderAttribute::TYPE_FLOAT:
case ShaderAttribute::TYPE_FLOATV4:
- glUniform4fvARB( i, 4, &sa->sau.fFloatV4[0] );
+ glUniform4fvARB( location, 4, &sa->value.fFloatV4[0] );
GLERRORCHECK;
break;
};
Modified: Mercury2/src/Shader.h
===================================================================
--- Mercury2/src/Shader.h 2009-06-14 13:08:31 UTC (rev 325)
+++ Mercury2/src/Shader.h 2009-06-14 13:55:32 UTC (rev 326)
@@ -9,7 +9,7 @@
class ShaderAttribute
{
public:
- ShaderAttribute() : typ( TYPE_INT ) { sau.iInt = 0; }
+ ShaderAttribute() : type( TYPE_INT ) { value.iInt = 0; }
///Type of ShaderAttribute for shader
enum ShaderAttributeTyp
@@ -18,7 +18,7 @@
TYPE_SAMPLER, ///Synonomous to 'sampler2D' when passing into a shader
TYPE_FLOAT, ///Synonomous to 'float' when passing into a shader
TYPE_FLOATV4 ///Synonomous to 'vec4' when passing into a shader
- } typ;
+ } type;
///Actual data for value.
union ShaderAttributeVal
@@ -27,7 +27,9 @@
unsigned int iSampler; ///Synonomous to 'sampler2D'
float fFloat; ///Synonomous to 'float'
float fFloatV4[4]; ///Synonomous to 'vec4'
- } sau;
+ } value;
+
+ MString name;
};
///Shader Attribute Retainer
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|