link programs before getting uniform locations; add Widget#draw_rect; fix GL.draw_rect; store uniforms as GLint

This commit is contained in:
Josh Holtrop 2014-08-04 23:19:30 -04:00
parent 7cc541ed29
commit be8f71296f
4 changed files with 7 additions and 3 deletions

View File

@ -16,6 +16,7 @@ class GLProgram
raise NotImplementedError.new("Other arguments not yet implemented")
end
end
link
options.each do |option, value|
case option
when :uniforms
@ -26,6 +27,5 @@ class GLProgram
raise "Unknown option #{option.inspect}"
end
end
link
end
end

View File

@ -30,4 +30,8 @@ module Widget
def render_end
end
def draw_rect(x, y, width, height, r, g, b, a)
GL.draw_rect(@x + x, @y + y, width, height, r, g, b, a)
end
end

View File

@ -46,7 +46,7 @@ void GL_Init()
{
ruby_module = rb_define_module("GL");
rb_define_singleton_method(ruby_module, "draw_rect",
(VALUE(*)(...))GL_draw_rect, 4);
(VALUE(*)(...))GL_draw_rect, 8);
}
static void load_gl_buffers()

View File

@ -17,7 +17,7 @@ enum
struct GLProgram
{
GLuint id;
std::unordered_map<int, GLuint> uniforms;
std::unordered_map<int, GLint> uniforms;
};
void GLProgram_Init();