diff options
| author | Tom Black <[email protected]> | 2016-07-18 00:35:51 -0500 |
|---|---|---|
| committer | Tom Black <[email protected]> | 2016-07-18 00:35:51 -0500 |
| commit | 721986fea456997a5fc7d26f3fc6bb893b6d191c (patch) | |
| tree | ae500796aedcefff9c261a6c6e36c606c5bfbfee | |
| parent | ef5a0a34e448dc6096495c85bfb173a5c693d0a1 (diff) | |
| download | ruby2d-721986fea456997a5fc7d26f3fc6bb893b6d191c.tar.gz ruby2d-721986fea456997a5fc7d26f3fc6bb893b6d191c.zip | |
Clean up window attributes
| -rw-r--r-- | ext/ruby2d/ruby2d.c | 7 | ||||
| -rw-r--r-- | lib/ruby2d/window.rb | 9 |
2 files changed, 9 insertions, 7 deletions
diff --git a/ext/ruby2d/ruby2d.c b/ext/ruby2d/ruby2d.c index 52b852a..300198d 100644 --- a/ext/ruby2d/ruby2d.c +++ b/ext/ruby2d/ruby2d.c @@ -257,6 +257,7 @@ static void render() { static VALUE ruby2d_show(VALUE s) { self = s; + // Get window attributes char *title = RSTRING_PTR(rb_iv_get(self, "@title")); int width = NUM2INT(rb_iv_get(self, "@width")); int height = NUM2INT(rb_iv_get(self, "@height")); @@ -298,11 +299,11 @@ static VALUE ruby2d_show(VALUE s) { title, width, height, update, render, flags ); - window->on_key = on_key; - window->on_key_down = on_key_down; - window->on_controller = on_controller; window->viewport.width = viewport_width; window->viewport.height = viewport_height; + window->on_key = on_key; + window->on_key_down = on_key_down; + window->on_controller = on_controller; S2D_Show(window); diff --git a/lib/ruby2d/window.rb b/lib/ruby2d/window.rb index 811b950..9d9012b 100644 --- a/lib/ruby2d/window.rb +++ b/lib/ruby2d/window.rb @@ -5,7 +5,8 @@ module Ruby2D attr_reader :title, :width, :height, :mouse_x, :mouse_y def initialize(width: 640, height: 480, title: "Ruby 2D", fps: 60, vsync: true) - @width, @height, @title = width, height, title + @title = title + @width, @height = width, height @viewport_width, @viewport_height = nil, nil @background = Color.new([0.0, 0.0, 0.0, 1.0]) @resizable = false @@ -34,9 +35,9 @@ module Ruby2D def set(opts) # Store new window attributes, or ignore if nil - @title = opts[:title] || @title - @width = opts[:width] || @width - @height = opts[:height] || @height + @title = opts[:title] || @title + @width = opts[:width] || @width + @height = opts[:height] || @height @viewport_width = opts[:viewport_width] || @viewport_width @viewport_height = opts[:viewport_height] || @viewport_height @resizable = opts[:resizable] || @resizable |
