Skip to content

Commit

Permalink
Added array versions of the SetUniform*f methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
bwrrp committed Jan 18, 2010
1 parent 4dbaaf7 commit a251881
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 0 deletions.
68 changes: 68 additions & 0 deletions GLProgram.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,74 @@ bool GLProgram::SetUniform4f(const string &name,
return true;
}

// ----------------------------------------------------------------------------
bool GLProgram::SetUniform1fv(const string &name, int num, float *v)
{
GLint loc = glGetUniformLocation(id, name.c_str());
#ifndef NDEBUG
GLUtility::CheckOpenGLError(
"GLProgram: SetUniform1fv() - glGetUniformLocation()");
#endif
if (loc == -1) return false;

glUniform1fv(loc, num, v);
#ifndef NDEBUG
GLUtility::CheckOpenGLError("GLProgram: glUniform1fv");
#endif
return true;
}

// ----------------------------------------------------------------------------
bool GLProgram::SetUniform2fv(const string &name, int num, float *v)
{
GLint loc = glGetUniformLocation(id, name.c_str());
#ifndef NDEBUG
GLUtility::CheckOpenGLError(
"GLProgram: SetUniform2fv() - glGetUniformLocation()");
#endif
if (loc == -1) return false;

glUniform2fv(loc, num, v);
#ifndef NDEBUG
GLUtility::CheckOpenGLError("GLProgram: glUniform2fv");
#endif
return true;
}

// ----------------------------------------------------------------------------
bool GLProgram::SetUniform3fv(const string &name, int num, float *v)
{
GLint loc = glGetUniformLocation(id, name.c_str());
#ifndef NDEBUG
GLUtility::CheckOpenGLError(
"GLProgram: SetUniform3fv() - glGetUniformLocation()");
#endif
if (loc == -1) return false;

glUniform3fv(loc, num, v);
#ifndef NDEBUG
GLUtility::CheckOpenGLError("GLProgram: glUniform3fv");
#endif
return true;
}

// ----------------------------------------------------------------------------
bool GLProgram::SetUniform4fv(const string &name, int num, float *v)
{
GLint loc = glGetUniformLocation(id, name.c_str());
#ifndef NDEBUG
GLUtility::CheckOpenGLError(
"GLProgram: SetUniform4fv() - glGetUniformLocation()");
#endif
if (loc == -1) return false;

glUniform4fv(loc, num, v);
#ifndef NDEBUG
GLUtility::CheckOpenGLError("GLProgram: glUniform4fv");
#endif
return true;
}

// ----------------------------------------------------------------------------
bool GLProgram::SetUniform1i(const string &name, int v0)
{
Expand Down
5 changes: 5 additions & 0 deletions GLProgram.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ class GLProgram : public GLResource
bool SetUniform4f(const std::string &name,
float v1, float v2, float v3, float v4);

bool SetUniform1fv(const std::string &name, int num, float *v);
bool SetUniform2fv(const std::string &name, int num, float *v);
bool SetUniform3fv(const std::string &name, int num, float *v);
bool SetUniform4fv(const std::string &name, int num, float *v);

bool SetUniform1i(const std::string &name, int v1);
bool SetUniform2i(const std::string &name, int v1, int v2);
bool SetUniform3i(const std::string &name, int v1, int v2, int v3);
Expand Down

0 comments on commit a251881

Please sign in to comment.