From be8f71296f7c38729189e68261211fb40668b5cf Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Mon, 4 Aug 2014 23:19:30 -0400 Subject: [PATCH] link programs before getting uniform locations; add Widget#draw_rect; fix GL.draw_rect; store uniforms as GLint --- runtime/lib/gl_program.rb | 2 +- runtime/lib/widget.rb | 4 ++++ src/GL.cc | 2 +- src/GLProgram.h | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/runtime/lib/gl_program.rb b/runtime/lib/gl_program.rb index b488e22..8c9afdf 100644 --- a/runtime/lib/gl_program.rb +++ b/runtime/lib/gl_program.rb @@ -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 diff --git a/runtime/lib/widget.rb b/runtime/lib/widget.rb index aebdd61..dc7067a 100644 --- a/runtime/lib/widget.rb +++ b/runtime/lib/widget.rb @@ -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 diff --git a/src/GL.cc b/src/GL.cc index 6c99487..2a4e152 100644 --- a/src/GL.cc +++ b/src/GL.cc @@ -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() diff --git a/src/GLProgram.h b/src/GLProgram.h index 86140eb..f161a2b 100644 --- a/src/GLProgram.h +++ b/src/GLProgram.h @@ -17,7 +17,7 @@ enum struct GLProgram { GLuint id; - std::unordered_map uniforms; + std::unordered_map uniforms; }; void GLProgram_Init();