diff options
| author | Tom Black <[email protected]> | 2017-09-28 14:11:38 -0700 |
|---|---|---|
| committer | Tom Black <[email protected]> | 2017-11-27 22:51:39 -0800 |
| commit | efeff37021c3cf5afb801a9941f093752b0d826e (patch) | |
| tree | f58b5031eef2dba6d9df02d201183b590fe975a6 /ext | |
| parent | 00c54e70107efe2a62f52170613faa5b55cc1ae7 (diff) | |
| download | ruby2d-efeff37021c3cf5afb801a9941f093752b0d826e.tar.gz ruby2d-efeff37021c3cf5afb801a9941f093752b0d826e.zip | |
Add iOS and tvOS support
Diffstat (limited to 'ext')
| -rw-r--r-- | ext/ruby2d/ruby2d.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/ext/ruby2d/ruby2d.c b/ext/ruby2d/ruby2d.c index d5c2191..6cbe219 100644 --- a/ext/ruby2d/ruby2d.c +++ b/ext/ruby2d/ruby2d.c @@ -1,7 +1,11 @@ // ruby2d.c – Native C extension for Ruby and MRuby // Simple 2D includes -#include <simple2d.h> +#if RUBY2D_IOS_TVOS + #include <Simple2D/simple2d.h> +#else + #include <simple2d.h> +#endif // Ruby includes #if MRUBY @@ -801,6 +805,22 @@ static void render() { /* + * Ruby2D::Window#ext_get_display_dimensions + */ +#if MRUBY +static R_VAL ruby2d_window_ext_get_display_dimensions(mrb_state* mrb, R_VAL self) { +#else +static R_VAL ruby2d_window_ext_get_display_dimensions(R_VAL self) { +#endif + int w; int h; + S2D_GetDisplayDimensions(&w, &h); + r_iv_set(self, "@display_width" , INT2NUM(w)); + r_iv_set(self, "@display_height", INT2NUM(h)); + return R_NIL; +} + + +/* * Ruby2D::Window#ext_show */ #if MRUBY @@ -977,6 +997,9 @@ void Init_ruby2d() { // Ruby2D::Window R_CLASS ruby2d_window_class = r_define_class(ruby2d_module, "Window"); + // Ruby2D::Window#ext_get_display_dimensions + r_define_method(ruby2d_window_class, "ext_get_display_dimensions", ruby2d_window_ext_get_display_dimensions, r_args_none); + // Ruby2D::Window#ext_show r_define_method(ruby2d_window_class, "ext_show", ruby2d_window_ext_show, r_args_none); |
