diff --git a/src/gltk/program.d b/src/gltk/program.d index 4c096d5..2544b69 100644 --- a/src/gltk/program.d +++ b/src/gltk/program.d @@ -14,7 +14,7 @@ class Program { throw new Exception("Failed to allocate an OpenGL program"); } - static if (args.length != 0u) + static if (args.length > 0u) { build(args); } @@ -63,6 +63,15 @@ class Program return glGetUniformLocation(m_id, uniform_name.toStringz()); } + void get_uniform_locations(Args...)(string uniform_name, GLint * uniform_location, Args args) + { + *uniform_location = get_uniform_location(uniform_name); + static if (args.length > 0u) + { + get_uniform_locations(args); + } + } + @property GLuint id() const { return m_id; diff --git a/src/jes/gui/package.d b/src/jes/gui/package.d index b777cfe..2ea4815 100644 --- a/src/jes/gui/package.d +++ b/src/jes/gui/package.d @@ -48,10 +48,11 @@ class Gui auto f_shader = new gltk.Shader(GL_FRAGMENT_SHADER); f_shader.set_source_from_file("share/jes/shaders/text.f.glsl"); m_text_program = new gltk.Program(v_shader, f_shader, "coords", 0); - m_viewport_size = m_text_program.get_uniform_location("viewport_size"); - m_texture = m_text_program.get_uniform_location("texture"); - m_color = m_text_program.get_uniform_location("color"); - m_position = m_text_program.get_uniform_location("position"); + m_text_program.get_uniform_locations( + "viewport_size", &m_viewport_size, + "texture", &m_texture, + "color", &m_color, + "position", &m_position); glActiveTexture(GL_TEXTURE0); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);