Class: Ray::Window
Instance Method Summary collapse
-
#close ⇒ Object
Closes the window.
- #each_event {|event| ... } ⇒ Object
-
#hide_cursor ⇒ Object
Hides the window cursor.
-
#icon=(icon) ⇒ Object
Sets the icon used by the window.
-
#initialize(title = nil, size = [640, 480], opts = {}) ⇒ Window
constructor
A new instance of Window.
-
#input ⇒ Ray::Input
The input used by this object.
- #open(size, opts = {}) ⇒ Object
-
#poll_event(ev) ⇒ Object
Gets the next event from the event queue.
-
#resize(size) ⇒ Object
(also: #size=)
Resizes the window.
-
#show_cursor ⇒ Object
Shows the window cursor.
-
#title=(title) ⇒ Object
Sets the title of the window.
-
#update ⇒ Object
Updates the content of the window.
-
#wait_event(ev) ⇒ Object
Gets the next event from the event queue.
Methods inherited from Target
#[], #clear, #clip, #default_view, #draw, #make_current, #pretty_print, #rect, #shader, #size, #to_image, #turtle, #view, #view=, #viewport_for, #with_view
Methods included from PP
Constructor Details
#initialize(title = nil, size = [640, 480], opts = {}) ⇒ Window
Returns a new instance of Window.
6 7 8 |
# File 'lib/ray/window.rb', line 6 def initialize(title = nil, size = [640, 480], opts = {}) open(title, size, opts) if title end |
Instance Method Details
#close ⇒ Object
Closes the window
68 69 70 71 72 |
# File 'ext/window.c', line 68 static VALUE ray_window_close(VALUE self) { say_window_close(ray_rb2window(self)); return self; } |
#each_event {|event| ... } ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/ray/window.rb', line 13 def each_event return Enumerator.new(self, :each_event) unless block_given? ev = Ray::Event.new until poll_event(ev).type == Ray::Event::TypeNone yield ev end end |
#hide_cursor ⇒ Object
Hides the window cursor
131 132 133 134 135 |
# File 'ext/window.c', line 131 static VALUE ray_window_hide_cursor(VALUE self) { say_window_hide_cursor(ray_rb2window(self)); return self; } |
#icon=(icon) ⇒ Object
79 80 81 82 83 84 85 86 |
# File 'ext/window.c', line 79
static
VALUE ray_window_set_icon(VALUE self, VALUE icon) {
if (!say_window_set_icon(ray_rb2window(self), ray_rb2image(icon))) {
rb_raise(rb_eRuntimeError, "%s", say_error_get_last());
}
return icon;
}
|
#input ⇒ Ray::Input
Returns The input used by this object.
162 163 164 165 |
# File 'ext/window.c', line 162 static VALUE ray_window_input(VALUE self) { return ray_input2rb(say_window_get_input(ray_rb2window(self)), self); } |
#open(size, opts = {}) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'ext/window.c', line 34
static
VALUE ray_window_open(int argc, VALUE *argv, VALUE self) {
VALUE title = Qnil, size = Qnil, opts = Qnil;
rb_scan_args(argc, argv, "21", &title, &size, &opts);
say_window *window = ray_rb2window(self);
uint8_t flags = 0;
if (!NIL_P(opts)) {
if (RTEST(rb_hash_aref(opts, RAY_SYM("resizable"))))
flags |= SAY_WINDOW_RESIZABLE;
if (RTEST(rb_hash_aref(opts, RAY_SYM("no_frame"))))
flags |= SAY_WINDOW_NO_FRAME;
if (RTEST(rb_hash_aref(opts, RAY_SYM("fullscreen"))))
flags |= SAY_WINDOW_FULLSCREEN;
}
say_vector2 c_size = ray_convert_to_vector2(size);
#ifdef SAY_OSX
say_osx_flip_pool();
#endif
if (!say_window_open(window, c_size.x, c_size.y,
StringValuePtr(title), flags)) {
rb_raise(rb_eRuntimeError, "%s", say_error_get_last());
}
return self;
}
|
#poll_event(ev) ⇒ Object
142 143 144 145 146 |
# File 'ext/window.c', line 142
static
VALUE ray_window_poll_event(VALUE self, VALUE ev) {
say_window_poll_event(ray_rb2window(self), ray_rb2event(ev));
return ev;
}
|
#resize(size) ⇒ Object Also known as: size=
104 105 106 107 108 109 110 111 112 |
# File 'ext/window.c', line 104
static
VALUE ray_window_resize(VALUE self, VALUE size) {
say_vector2 c_size = ray_convert_to_vector2(size);
if (!say_window_resize(ray_rb2window(self), c_size.x, c_size.y)) {
rb_raise(rb_eRuntimeError, "%s", say_error_get_last());
}
return size;
}
|
#show_cursor ⇒ Object
Shows the window cursor
124 125 126 127 128 |
# File 'ext/window.c', line 124 static VALUE ray_window_show_cursor(VALUE self) { say_window_show_cursor(ray_rb2window(self)); return self; } |
#title=(title) ⇒ Object
93 94 95 96 97 |
# File 'ext/window.c', line 93
static
VALUE ray_window_set_title(VALUE self, VALUE title) {
say_window_set_title(ray_rb2window(self), StringValuePtr(title));
return title;
}
|
#update ⇒ Object
Updates the content of the window. Must be updated at the end of each frame.
117 118 119 120 121 |
# File 'ext/window.c', line 117 static VALUE ray_window_update(VALUE self) { say_window_update(ray_rb2window(self)); return self; } |
#wait_event(ev) ⇒ Object
155 156 157 158 159 |
# File 'ext/window.c', line 155
static
VALUE ray_window_wait_event(VALUE self, VALUE ev) {
say_window_wait_event(ray_rb2window(self), ray_rb2event(ev));
return ev;
}
|