summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authoreiko <[email protected]>2018-03-30 12:07:15 -0400
committerTom Black <[email protected]>2018-05-06 17:56:39 -0700
commit36754d58e1e17c11cc243f896d63cd9e1daf95ed (patch)
tree662336f7034eddaf52bf11b51b69e6c06e42ac8c
parent3a7f63f64159b21f4ec5c4e64aa36eafcacf567f (diff)
downloadruby2d-36754d58e1e17c11cc243f896d63cd9e1daf95ed.tar.gz
ruby2d-36754d58e1e17c11cc243f896d63cd9e1daf95ed.zip
Enable setting and getting custom fps_cap
-rw-r--r--ext/ruby2d/ruby2d.c2
-rw-r--r--lib/ruby2d/window.rb6
2 files changed, 6 insertions, 2 deletions
diff --git a/ext/ruby2d/ruby2d.c b/ext/ruby2d/ruby2d.c
index 888c053..b44ba58 100644
--- a/ext/ruby2d/ruby2d.c
+++ b/ext/ruby2d/ruby2d.c
@@ -933,6 +933,7 @@ static R_VAL ruby2d_window_ext_show(R_VAL self) {
char *title = RSTRING_PTR(r_iv_get(self, "@title"));
int width = NUM2INT(r_iv_get(self, "@width"));
int height = NUM2INT(r_iv_get(self, "@height"));
+ int fps_cap = NUM2INT(r_iv_get(self, "@fps_cap"));
int flags = 0;
// Get window flags
@@ -965,6 +966,7 @@ static R_VAL ruby2d_window_ext_show(R_VAL self) {
window->viewport.width = viewport_width;
window->viewport.height = viewport_height;
+ window->fps_cap = fps_cap;
window->on_key = on_key;
window->on_mouse = on_mouse;
window->on_controller = on_controller;
diff --git a/lib/ruby2d/window.rb b/lib/ruby2d/window.rb
index 686c6b0..021353d 100644
--- a/lib/ruby2d/window.rb
+++ b/lib/ruby2d/window.rb
@@ -25,9 +25,9 @@ module Ruby2D
@fullscreen = false
@highdpi = false
@frames = 0
- @fps_cap = args[:fps] || 60
+ @fps_cap = args[:fps_cap] || 60
@fps = @fps_cap
- @vsync = args[:vsync] || true
+ @vsync = args[:vsync] || true
@mouse_x, @mouse_y = 0, 0
@objects = []
@event_key = 0
@@ -76,6 +76,7 @@ module Ruby2D
when :highdpi; @highdpi
when :frames; @frames
when :fps; @fps
+ when :fps_cap; @fps_cap
when :mouse_x; @mouse_x
when :mouse_y; @mouse_y
when :diagnostics; @diagnostics
@@ -90,6 +91,7 @@ module Ruby2D
end
@width = opts[:width] || @width
@height = opts[:height] || @height
+ @fps_cap = opts[:fps_cap] || @fps_cap
@viewport_width = opts[:viewport_width] || @viewport_width
@viewport_height = opts[:viewport_height] || @viewport_height
@resizable = opts[:resizable] || @resizable