From db3ffa84af272464b923325f6b137fb4ad57ea4c Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Mon, 3 Sep 2012 00:55:45 -0400 Subject: [PATCH] add get_uniform_location{,s}() --- src/client/GLProgram.cc | 13 +++++++++++++ src/client/GLProgram.h | 2 ++ 2 files changed, 15 insertions(+) diff --git a/src/client/GLProgram.cc b/src/client/GLProgram.cc index 1132940..9a10a68 100644 --- a/src/client/GLProgram.cc +++ b/src/client/GLProgram.cc @@ -58,3 +58,16 @@ bool GLProgram::create(const char *v_source, const char *f_source, return true; } + +GLint GLProgram::get_uniform_location(const char *name) +{ + return glGetUniformLocation(m_id, name); +} + +void GLProgram::get_uniform_locations(const char **names, int num, GLint *locs) +{ + for (int i = 0; i < num; i++) + { + locs[i] = get_uniform_location(names[i]); + } +} diff --git a/src/client/GLProgram.h b/src/client/GLProgram.h index d2039b8..3edcf23 100644 --- a/src/client/GLProgram.h +++ b/src/client/GLProgram.h @@ -17,6 +17,8 @@ class GLProgram bool create(const char *v_source, const char *f_source, AttributeBinding *bindings = NULL); GLuint get_id() { return m_id; } + GLint get_uniform_location(const char *name); + void get_uniform_locations(const char **names, int num, GLint *locs); protected: GLuint m_id; GLShader m_v_shader;