Skip to content

Instantly share code, notes, and snippets.

@shakesoda
Created April 9, 2012 21:18
Show Gist options
  • Save shakesoda/2346610 to your computer and use it in GitHub Desktop.
Save shakesoda/2346610 to your computer and use it in GitHub Desktop.
uniform setter thing
class Uniform
{
public:
// todo: macroify, make m_program actually a thing.
void set_uniform_float(std::string key, float data)
{
using namespace std;
unsigned location = 0;
map<string, unsigned>::iterator it;
it = m_uniforms.find(key);
if (it == m_uniforms.end())
m_uniforms[key] = glGetUniformLocation(m_program, key.c_str());
glUniform1f(location, data);
}
private:
std::map<std::string, unsigned> m_uniforms;
unsigned m_program;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment