Advertisement
Guest User

Untitled

a guest
Nov 10th, 2012
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.71 KB | None | 0 0
  1. void Shader::setParameter(const std::string& name, float* x, int c = 1)
  2. {
  3.     if (m_shaderProgram)
  4.     {
  5.         ensureGlContext();
  6.  
  7.         // Enable program
  8.         GLhandleARB program = glGetHandleARB(GL_PROGRAM_OBJECT_ARB);
  9.         glCheck(glUseProgramObjectARB(m_shaderProgram));
  10.  
  11.         // Get parameter location and assign it new values
  12.         GLint location = glGetUniformLocationARB(m_shaderProgram, name.c_str());
  13.         if (location != -1)
  14.             glCheck(glUniformMatrix4fvARB(location, c, GL_FALSE, x));
  15.         else
  16.             err() << "Parameter \"" << name << "\" not found in shader" << std::endl;
  17.  
  18.         // Disable program
  19.         glCheck(glUseProgramObjectARB(program));
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement