|
From: <axl...@us...> - 2009-06-14 19:31:10
|
Revision: 332
http://hgengine.svn.sourceforge.net/hgengine/?rev=332&view=rev
Author: axlecrusher
Date: 2009-06-14 19:31:09 +0000 (Sun, 14 Jun 2009)
Log Message:
-----------
shader work
Modified Paths:
--------------
Mercury2/src/Shader.cpp
Mercury2/src/Shader.h
Modified: Mercury2/src/Shader.cpp
===================================================================
--- Mercury2/src/Shader.cpp 2009-06-14 19:21:19 UTC (rev 331)
+++ Mercury2/src/Shader.cpp 2009-06-14 19:31:09 UTC (rev 332)
@@ -72,8 +72,8 @@
void Shader::PostRender(const MercuryNode* node)
{
CurrentShader = OriginalShader;
- if( OriginalShader )
- OriginalShader->ActivateShader();
+ if( CurrentShader )
+ CurrentShader->ActivateShader();
else
DeactivateShader();
}
@@ -314,7 +314,7 @@
}
//Build the list of uniform tabs.
- int iNumUniforms;
+/* int iNumUniforms;
glGetObjectParameterivARB( iProgramID, GL_OBJECT_ACTIVE_UNIFORMS_ARB, &iNumUniforms );
m_vShaderTabs.resize( iNumUniforms );
for( int i = 0; i < iNumUniforms; ++i )
@@ -328,7 +328,7 @@
m_vShaderTabs[i] = SHADERATTRIBUTES.GetHandle( buffer );
m_vShaderTabs[i]->name = buffer;
}
- return true;
+*/ return true;
}
void Shader::DestroyShader()
@@ -404,30 +404,33 @@
void Shader::ActivateShader()
{
- if (iProgramID == 0) return;
+ if ( !iProgramID ) return;
glUseProgramObjectARB( iProgramID );
GLERRORCHECK;
-
+/*
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->type )
+ if ( sa->ShaderControlled )
{
- case ShaderAttribute::TYPE_INT:
- case ShaderAttribute::TYPE_SAMPLER:
- glUniform1iARB( location, sa->value.iInt );
- GLERRORCHECK;
- break;
- case ShaderAttribute::TYPE_FLOAT:
- case ShaderAttribute::TYPE_FLOATV4:
- glUniform4fvARB( location, 4, &sa->value.fFloatV4[0] );
- GLERRORCHECK;
- break;
- };
- }
+ switch( sa->type )
+ {
+ case ShaderAttribute::TYPE_INT:
+ case ShaderAttribute::TYPE_SAMPLER:
+ glUniform1iARB( location, sa->value.iInt );
+ GLERRORCHECK;
+ break;
+ case ShaderAttribute::TYPE_FLOAT:
+ case ShaderAttribute::TYPE_FLOATV4:
+ glUniform4fvARB( location, 4, &sa->value.fFloatV4[0] );
+ GLERRORCHECK;
+ break;
+ };
+ }
+ }*/
}
void Shader::DeactivateShader()
@@ -436,7 +439,13 @@
GLERRORCHECK;
}
+int32_t Shader::GetUniformLocation(const MString& n)
+{
+ if ( !iProgramID ) return -1;
+ return glGetUniformLocationARB( iProgramID, n.c_str() );
+}
+
/*
* Copyright (c) 2009 Charles Lohr
* All rights reserved.
Modified: Mercury2/src/Shader.h
===================================================================
--- Mercury2/src/Shader.h 2009-06-14 19:21:19 UTC (rev 331)
+++ Mercury2/src/Shader.h 2009-06-14 19:31:09 UTC (rev 332)
@@ -9,7 +9,7 @@
class ShaderAttribute
{
public:
- ShaderAttribute() : type( TYPE_INT ) { value.iInt = 0; }
+ ShaderAttribute() : type( TYPE_INT ) { value.iInt = 0; ShaderControlled=0;}
///Type of ShaderAttribute for shader
enum ShaderAttributeTyp
@@ -30,6 +30,7 @@
} value;
MString name;
+ bool ShaderControlled;
};
///Shader Attribute Retainer
@@ -70,9 +71,11 @@
virtual void PostRender(const MercuryNode* node);
static Shader* Generate() { return new Shader; }
virtual void LoadFromXML(const XMLNode& node);
+ int32_t GetUniformLocation(const MString& n);
///Explicitly get the OpenGL ProgramID in the event you need it for advanced techniques
unsigned int GetProgramID() { return iProgramID; }
+ inline static Shader* GetCurrentShader() { return CurrentShader; }
private:
void LoadShader( const MString& path, float priority );
@@ -143,7 +146,7 @@
through all attributes currently set up by dereferencing
the pointers in the attributes repository.
*/
- std::vector< ShaderAttribute * > m_vShaderTabs;
+// std::vector< ShaderAttribute * > m_vShaderTabs;
///Name of the shader
MString sShaderName;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|