Add gltk.Program.get_uniform_locations().
This commit is contained in:
parent
52d7eb5eab
commit
816aca30ac
@ -14,7 +14,7 @@ class Program
|
|||||||
{
|
{
|
||||||
throw new Exception("Failed to allocate an OpenGL program");
|
throw new Exception("Failed to allocate an OpenGL program");
|
||||||
}
|
}
|
||||||
static if (args.length != 0u)
|
static if (args.length > 0u)
|
||||||
{
|
{
|
||||||
build(args);
|
build(args);
|
||||||
}
|
}
|
||||||
@ -63,6 +63,15 @@ class Program
|
|||||||
return glGetUniformLocation(m_id, uniform_name.toStringz());
|
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
|
@property GLuint id() const
|
||||||
{
|
{
|
||||||
return m_id;
|
return m_id;
|
||||||
|
@ -48,10 +48,11 @@ class Gui
|
|||||||
auto f_shader = new gltk.Shader(GL_FRAGMENT_SHADER);
|
auto f_shader = new gltk.Shader(GL_FRAGMENT_SHADER);
|
||||||
f_shader.set_source_from_file("share/jes/shaders/text.f.glsl");
|
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_text_program = new gltk.Program(v_shader, f_shader, "coords", 0);
|
||||||
m_viewport_size = m_text_program.get_uniform_location("viewport_size");
|
m_text_program.get_uniform_locations(
|
||||||
m_texture = m_text_program.get_uniform_location("texture");
|
"viewport_size", &m_viewport_size,
|
||||||
m_color = m_text_program.get_uniform_location("color");
|
"texture", &m_texture,
|
||||||
m_position = m_text_program.get_uniform_location("position");
|
"color", &m_color,
|
||||||
|
"position", &m_position);
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user