Skip to content

Commit

Permalink
added mat4 support for (shader-set\!)
Browse files Browse the repository at this point in the history
 resetting some variables on (clear): (show-axis), (fog), (show-fps), (clear-colour)
  • Loading branch information
gaborpapp committed Jun 30, 2011
1 parent 309e258 commit 618e4c9
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 2 deletions.
14 changes: 13 additions & 1 deletion libfluxus/src/GLSLShader.cpp
Expand Up @@ -302,8 +302,20 @@ void GLSLShader::SetVector(const string &name, dVector s, int size /* = 4 */)
case 4:
glUniform4f(param, s.x, s.y, s.z, s.w);
break;
default:
assert(false);
break;
}
CHECK_GL_ERRORS("glUniform");
#endif
}

void GLSLShader::SetMatrix(const string &name, dMatrix &m)
{
#ifdef GLSL
if (!m_Enabled) return;

GLuint param = glGetUniformLocation(m_Program, name.c_str());
glUniformMatrix4fv(param, 1, GL_FALSE, m.arr());
#endif
}

Expand Down
1 change: 1 addition & 0 deletions libfluxus/src/GLSLShader.h
Expand Up @@ -86,6 +86,7 @@ class GLSLShader
void SetColour(const string &name, dColour s);
void SetIntArray(const string &name, const vector<int,FLX_ALLOC(int) > &s);
void SetFloatArray(const string &name, const vector<float,FLX_ALLOC(float) > &s);
void SetMatrix(const string &name, dMatrix &m);
void SetVectorArray(const string &name, const vector<dVector,FLX_ALLOC(dVector) > &s);
void SetColourArray(const string &name, const vector<dColour,FLX_ALLOC(dColour) > &s);
///@}
Expand Down
10 changes: 10 additions & 0 deletions libfluxus/src/Renderer.cpp
Expand Up @@ -94,6 +94,16 @@ Renderer::~Renderer()

void Renderer::Clear()
{
m_ShowAxis = false;

m_FogDensity = 0;
m_FogStart = 0;
m_FogEnd = 100;

m_FPSDisplay = false;

m_BGColour = dColour(0, 0, 0, 1);

m_World.Clear();
m_StateStack.clear();
m_CameraVec.clear();
Expand Down
9 changes: 8 additions & 1 deletion modules/fluxus-engine/src/LocalStateFunctions.cpp
Expand Up @@ -2843,8 +2843,15 @@ Scheme_Object *shader_set(int argc, Scheme_Object **argv)
shader->SetVector(param, vec, vecsize);
}
else
if (vecsize == 16)
{
Trace::Stream << "shader is expecting vector size 2, 3 or 4, but found " << vecsize <<
dMatrix m;
FloatsFromScheme(listvec, m.arr(), vecsize);
shader->SetMatrix(param, m);
}
else
{
Trace::Stream << "shader is expecting vector size 2, 3, 4 or 16 but found " << vecsize <<
" for variable " << param << endl;
}
}
Expand Down

0 comments on commit 618e4c9

Please sign in to comment.