From be713c960e2b9f675e04c6d7cdabb3cd61a0d62d Mon Sep 17 00:00:00 2001 From: Tom Black Date: Tue, 1 Jan 2019 10:33:02 -0600 Subject: Add ability to take screenshot --- ext/ruby2d/extconf.rb | 2 +- ext/ruby2d/ruby2d.c | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) (limited to 'ext') diff --git a/ext/ruby2d/extconf.rb b/ext/ruby2d/extconf.rb index 3cd2302..a079241 100644 --- a/ext/ruby2d/extconf.rb +++ b/ext/ruby2d/extconf.rb @@ -1,7 +1,7 @@ require 'mkmf' require_relative '../../lib/ruby2d/colorize' -S2D_VERSION = '1.0.1' # Simple 2D minimum version required +S2D_VERSION = '1.1.0' # Simple 2D minimum version required $errors = [] def print_errors diff --git a/ext/ruby2d/ruby2d.c b/ext/ruby2d/ruby2d.c index f9cf3b4..de22762 100644 --- a/ext/ruby2d/ruby2d.c +++ b/ext/ruby2d/ruby2d.c @@ -154,6 +154,21 @@ double normalize_controller_axis(int val) { } +/* + * Ruby2D#self.ext_screenshot + */ +#if MRUBY +static R_VAL ruby2d_ext_screenshot(mrb_state* mrb, R_VAL self) { + mrb_value path; + mrb_get_args(mrb, "o", &path); +#else +static R_VAL ruby2d_ext_screenshot(R_VAL self, R_VAL path) { +#endif + S2D_Screenshot(window, RSTRING_PTR(path)); + return R_NIL; +} + + /* * Ruby2D::Triangle#ext_render */ @@ -1183,6 +1198,9 @@ void Init_ruby2d() { // Ruby2D::Window#ext_show r_define_method(ruby2d_window_class, "ext_show", ruby2d_window_ext_show, r_args_none); + // Ruby2D::Window#ext_screenshot + r_define_method(ruby2d_window_class, "ext_screenshot", ruby2d_ext_screenshot, r_args_req(1)); + // Ruby2D::Window#ext_close r_define_method(ruby2d_window_class, "ext_close", ruby2d_window_ext_close, r_args_none); -- cgit v1.2.3