summaryrefslogtreecommitdiffhomepage
path: root/ext
diff options
context:
space:
mode:
authorTom Black <[email protected]>2019-01-01 10:33:02 -0600
committerTom Black <[email protected]>2019-01-01 10:41:32 -0600
commitbe713c960e2b9f675e04c6d7cdabb3cd61a0d62d (patch)
treebe89fa7f1390ea527cf033bd65150fda4f0db815 /ext
parent2ca4a07d60357c3b32625a706f7411997b6258c0 (diff)
downloadruby2d-be713c960e2b9f675e04c6d7cdabb3cd61a0d62d.tar.gz
ruby2d-be713c960e2b9f675e04c6d7cdabb3cd61a0d62d.zip
Add ability to take screenshot
Diffstat (limited to 'ext')
-rw-r--r--ext/ruby2d/extconf.rb2
-rw-r--r--ext/ruby2d/ruby2d.c18
2 files changed, 19 insertions, 1 deletions
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
@@ -155,6 +155,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
*/
#if MRUBY
@@ -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);