From ef5a0a34e448dc6096495c85bfb173a5c693d0a1 Mon Sep 17 00:00:00 2001 From: Tom Black Date: Mon, 18 Jul 2016 00:25:16 -0500 Subject: Set viewport size --- ext/ruby2d/ruby2d.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'ext') diff --git a/ext/ruby2d/ruby2d.c b/ext/ruby2d/ruby2d.c index 32b8ab0..52b852a 100644 --- a/ext/ruby2d/ruby2d.c +++ b/ext/ruby2d/ruby2d.c @@ -276,6 +276,24 @@ static VALUE ruby2d_show(VALUE s) { flags = flags | S2D_HIGHDPI; } + // Check viewport size and set + + int viewport_width; + VALUE vp_w = rb_iv_get(self, "@viewport_width"); + if (vp_w == Qnil) { + viewport_width = width; + } else { + viewport_width = NUM2INT(vp_w); + } + + int viewport_height; + VALUE vp_h = rb_iv_get(self, "@viewport_height"); + if (vp_h == Qnil) { + viewport_height = height; + } else { + viewport_height = NUM2INT(vp_h); + } + window = S2D_CreateWindow( title, width, height, update, render, flags ); @@ -283,6 +301,8 @@ static VALUE ruby2d_show(VALUE s) { 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; S2D_Show(window); -- cgit v1.2.3