Class: Glfw::Window
- Inherits:
-
Object
- Object
- Glfw::Window
- Defined in:
- lib/glfw3/window.rb,
ext/glfw3/glfw3.c
Overview
A GLFW window. These contain a context, optionally one shared with other windows and generate events. Each window maintains its own event callbacks.
Wraps GLFWwindow and its associated functions, for the most part.
Event Callbacks
All window event callbacks’ first argument is the window that generated the event. These event callbacks all receive the same arguments as their GLFW C counterparts, so refer to the GLFW 3 documentation for that.
User Data
If you need to associate a particular object or value with a window, you can use its #user_data attribute to store and retreive an arbitrary object for the window. If you need to store multiple values with the window, you might set its user data object to a Hash.
Defined Under Namespace
Classes: InternalWindow
Instance Attribute Summary collapse
-
#user_data ⇒ Object
User data attribute, can be set to any arbitrary object.
Class Method Summary collapse
-
.default_window_hints ⇒ Object
Sets the window hints to their default values.
-
.new(*args) ⇒ Object
Creates a new window with the given parameters.
-
.unset_context ⇒ Object
Unsets the current GL context.
-
.window_hint(target, hint) ⇒ Object
Sets a window hint to the given value.
-
.windows ⇒ Object
Returns an array of all allocated GLFW windows.
Instance Method Summary collapse
- #char_callback=(func) ⇒ Object
-
#clipboard_string ⇒ Object
Gets the system clipboard’s contents as a string.
-
#clipboard_string=(string) ⇒ Object
Sets the system clipboard string.
- #close_callback=(func) ⇒ Object
-
#current_context ⇒ Object
Gets the window for the current GL context in this thread.
- #cursor_enter_callback(func) ⇒ Object
- #cursor_pos=(xy) ⇒ Object
- #cursor_position_callback(func) ⇒ Object
-
#destroy ⇒ Object
Destroys the window.
- #focus_callback=(func) ⇒ Object
-
#framebuffer_size ⇒ Object
Gets the window context’s framebuffer size.
- #framebuffer_size_callback(func) ⇒ Object
-
#get_cursor_pos ⇒ Object
(also: #cursor_pos)
Gets the last-reported cursor position in the window.
-
#get_input_mode(mode) ⇒ Object
Gets the current value for the given input mode.
-
#get_position ⇒ Object
(also: #position)
Gets the windows position.
-
#get_should_close ⇒ Object
(also: #should_close?)
Gets the window’s should-close flag.
-
#get_size ⇒ Object
(also: #size)
Gets the window’s size.
-
#height ⇒ Object
Gets the width of the window.
-
#hide ⇒ Object
Hides the window.
-
#iconify ⇒ Object
Iconifies the window.
- #iconify_callback=(func) ⇒ Object
-
#key(key) ⇒ Object
Gets the last-reported state of the given keyboard key for the window.
- #key_callback=(func) ⇒ Object
-
#make_context_current ⇒ Object
Makes the window’s GL context current.
-
#monitor ⇒ Object
Gets the window’s monitor.
-
#mouse_button(button) ⇒ Object
Gets the last-reported state of the given mouse button for the window.
- #mouse_button_callback(func) ⇒ Object
- #position=(xy) ⇒ Object
- #position_callback=(func) ⇒ Object
- #refresh_callback=(func) ⇒ Object
-
#restore ⇒ Object
Restores the window.
- #scroll_callback(func) ⇒ Object
- #set_char_callback(&block) ⇒ Object
- #set_char_callback__ ⇒ Object
- #set_close_callback(&block) ⇒ Object
- #set_close_callback__ ⇒ Object
- #set_cursor_enter_callback(&block) ⇒ Object
- #set_cursor_enter_callback__ ⇒ Object
-
#set_cursor_pos(x, y) ⇒ Object
Sets the position of the mouse cursor relative to the client area of the window.
- #set_cursor_position_callback(&block) ⇒ Object
- #set_cursor_position_callback__ ⇒ Object
- #set_fbsize_callback__ ⇒ Object
- #set_focus_callback(&block) ⇒ Object
- #set_focus_callback__ ⇒ Object
- #set_framebuffer_size_callback(&block) ⇒ Object
- #set_iconify_callback(&block) ⇒ Object
- #set_iconify_callback__ ⇒ Object
-
#set_input_mode(mode, value) ⇒ Object
Sets the value of the given input mode.
- #set_key_callback(&block) ⇒ Object
- #set_key_callback__ ⇒ Object
- #set_mouse_button_callback(&block) ⇒ Object
- #set_mouse_button_callback__ ⇒ Object
-
#set_position(x, y) ⇒ Object
(also: #move)
Moves the window to a new location (sets its position).
- #set_position_callback(&block) ⇒ Object
- #set_refresh_callback(&block) ⇒ Object
- #set_refresh_callback__ ⇒ Object
- #set_scroll_callback(&block) ⇒ Object
- #set_scroll_callback__ ⇒ Object
-
#set_should_close(value) ⇒ Object
(also: #should_close=)
Sets the window’s should-close flag.
-
#set_size(width, height) ⇒ Object
(also: #resize)
Sets the window’s size.
- #set_size_callback(&block) ⇒ Object
- #set_window_position_callback__ ⇒ Object
- #set_window_size_callback__ ⇒ Object
-
#show ⇒ Object
Shows the window.
- #size=(wh) ⇒ Object
- #size_callback=(func) ⇒ Object
-
#swap_buffers ⇒ Object
Swaps the front and back buffers for the window.
-
#title=(new_title) ⇒ Object
Sets the window’s title.
-
#width ⇒ Object
Gets the width of the window.
-
#x ⇒ Object
Gets the X position of the window in screen space.
-
#y ⇒ Object
Gets the Y position of the window in screen space.
Instance Attribute Details
#user_data ⇒ Object
User data attribute, can be set to any arbitrary object. Used to associate any object with the window for later retrieval.
34 35 36 |
# File 'lib/glfw3/window.rb', line 34 def user_data @user_data end |
Class Method Details
.default_window_hints ⇒ Object
Sets the window hints to their default values. See GLFW 3 documentation for details on what those values are.
call-seq:
default_window_hints() -> self
Wraps glfwDefaultWindowHints.
524 525 526 527 528 |
# File 'ext/glfw3/glfw3.c', line 524 static VALUE rb_window_default_window_hints(VALUE self) { glfwDefaultWindowHints(); return self; } |
.new(*args) ⇒ Object
Creates a new window with the given parameters. If a shared window is provided, the new window will use the context of the shared window.
If GLFW fails to create the window or an error occurred, this function will return nil.
call-seq:
new(width, height, title='', monitor=nil, shared_window=nil) -> Glfw::Window or nil
Wraps glfwCreateWindow.
579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 |
# File 'ext/glfw3/glfw3.c', line 579 static VALUE rb_window_new(int argc, VALUE *argv, VALUE self) { ID ivar_window = rb_intern(kRB_IVAR_WINDOW_INTERNAL); VALUE rb_width, rb_height, rb_title, rb_monitor, rb_share; VALUE rb_window; VALUE rb_window_data; VALUE rb_windows; GLFWwindow *window = NULL; int width, height; const char *title = ""; GLFWmonitor *monitor = NULL; GLFWwindow *share = NULL; // Grab arguments rb_scan_args(argc, argv, "23", &rb_width, &rb_height, &rb_title, &rb_monitor, &rb_share); width = NUM2INT(rb_width); height = NUM2INT(rb_height); if (RTEST(rb_title)) { if (rb_type(rb_title) != T_STRING) { rb_title = rb_any_to_s(rb_title); } title = StringValueCStr(rb_title); } if (RTEST(rb_monitor) && RTEST(rb_obj_is_kind_of(rb_monitor, s_glfw_monitor_klass))) { Data_Get_Struct(rb_monitor, GLFWmonitor, monitor); } if (RTEST(rb_share) && RTEST(rb_obj_is_kind_of(rb_share, s_glfw_window_klass))) { VALUE rb_shared_window = rb_ivar_get(rb_share, ivar_window); Data_Get_Struct(rb_shared_window, GLFWwindow, share); } // Create GLFW window window = glfwCreateWindow(width, height, title, monitor, share); if (window == NULL) { return Qnil; } // Allocate the window wrapper (only used to store the window pointer) rb_window_data = Data_Wrap_Struct(s_glfw_window_internal_klass, 0, 0, window); rb_obj_call_init(rb_window_data, 0, 0); // Allocate the window rb_window = rb_obj_alloc(s_glfw_window_klass); rb_ivar_set(rb_window, ivar_window, rb_window_data); rb_ivar_set(rb_window, rb_intern(kRB_IVAR_WINDOW_KEY_CALLBACK), Qnil); rb_ivar_set(rb_window, rb_intern(kRB_IVAR_WINDOW_CHAR_CALLBACK), Qnil); rb_ivar_set(rb_window, rb_intern(kRB_IVAR_WINDOW_MOUSE_BUTTON_CALLBACK), Qnil); rb_ivar_set(rb_window, rb_intern(kRB_IVAR_WINDOW_CURSOR_POSITION_CALLBACK), Qnil); rb_ivar_set(rb_window, rb_intern(kRB_IVAR_WINDOW_CURSOR_ENTER_CALLBACK), Qnil); rb_ivar_set(rb_window, rb_intern(kRB_IVAR_WINDOW_SCROLL_CALLBACK), Qnil); rb_ivar_set(rb_window, rb_intern(kRB_IVAR_WINDOW_POSITION_CALLBACK), Qnil); rb_ivar_set(rb_window, rb_intern(kRB_IVAR_WINDOW_SIZE_CALLBACK), Qnil); rb_ivar_set(rb_window, rb_intern(kRB_IVAR_WINDOW_CLOSE_CALLBACK), Qnil); rb_ivar_set(rb_window, rb_intern(kRB_IVAR_WINDOW_REFRESH_CALLBACK), Qnil); rb_ivar_set(rb_window, rb_intern(kRB_IVAR_WINDOW_FOCUS_CALLBACK), Qnil); rb_ivar_set(rb_window, rb_intern(kRB_IVAR_WINDOW_ICONIFY_CALLBACK), Qnil); rb_ivar_set(rb_window, rb_intern(kRB_IVAR_WINDOW_FRAMEBUFFER_SIZE_CALLBACK), Qnil); glfwSetWindowUserPointer(window, (void *)rb_window); rb_obj_call_init(rb_window, 0, 0); // Store the window so it can't go out of scope until explicitly destroyed. rb_windows = rb_cvar_get(self, rb_intern(kRB_CVAR_WINDOW_WINDOWS)); rb_hash_aset(rb_windows, INT2FIX((int)window), rb_window); return rb_window; } |
.unset_context ⇒ Object
Unsets the current GL context.
Wraps glfwMakeContextCurrent(NULL).
1356 1357 1358 1359 1360 |
# File 'ext/glfw3/glfw3.c', line 1356 static VALUE rb_window_unset_context(VALUE self) { glfwMakeContextCurrent(NULL); return self; } |
.window_hint(target, hint) ⇒ Object
Sets a window hint to the given value.
call-seq:
window_hint(target, hint) -> self
Wraps glfwWindowHint.
540 541 542 543 544 |
# File 'ext/glfw3/glfw3.c', line 540 static VALUE rb_window_window_hint(VALUE self, VALUE target, VALUE hint) { glfwWindowHint(NUM2INT(target), NUM2INT(hint)); return self; } |
.windows ⇒ Object
Returns an array of all allocated GLFW windows.
call-seq:
windows -> [Glfw::Window, ...]
67 68 69 |
# File 'lib/glfw3/window.rb', line 67 def self.windows @@__windows.values end |
Instance Method Details
#char_callback=(func) ⇒ Object
108 109 110 111 |
# File 'lib/glfw3/window.rb', line 108 def char_callback=(func) @__char_callback = func set_char_callback__(!func.nil?) end |
#clipboard_string ⇒ Object
Gets the system clipboard’s contents as a string. The window this is called from will request the clipboard contents.
call-seq:
clipboard_string() -> String
Wraps glfwGetClipboardString.
1284 1285 1286 1287 |
# File 'ext/glfw3/glfw3.c', line 1284 static VALUE rb_window_get_clipboard_string(VALUE self) { return rb_str_new2(glfwGetClipboardString(rb_get_window(self))); } |
#clipboard_string=(string) ⇒ Object
Sets the system clipboard string. The window this is set for will own the given string.
call-seq:
clipboard_string=(string) -> String
clipboard_string = string -> String
Wraps glfwSetClipboardString.
1267 1268 1269 1270 1271 |
# File 'ext/glfw3/glfw3.c', line 1267 static VALUE rb_window_set_clipboard_string(VALUE self, VALUE string) { glfwSetClipboardString(rb_get_window(self), StringValueCStr(string)); return string; } |
#close_callback=(func) ⇒ Object
171 172 173 174 |
# File 'lib/glfw3/window.rb', line 171 def close_callback=(func) @__close_callback = func set_close_callback__(!func.nil?) end |
#current_context ⇒ Object
Gets the window for the current GL context in this thread.
call-seq:
current_context() -> Glfw::Window
Wraps glfwGetCurrentContext.
1372 1373 1374 1375 1376 1377 1378 1379 1380 |
# File 'ext/glfw3/glfw3.c', line 1372 static VALUE rb_window_get_current_context(VALUE self) { GLFWwindow *window = glfwGetCurrentContext(); if (window) { return (VALUE)glfwGetWindowUserPointer(window); } else { return Qnil; } } |
#cursor_enter_callback(func) ⇒ Object
135 136 137 138 |
# File 'lib/glfw3/window.rb', line 135 def cursor_enter_callback(func) @__cursor_enter_callback = func set_cursor_enter_callback__(!func.nil?) end |
#cursor_pos=(xy) ⇒ Object
43 44 45 |
# File 'lib/glfw3/window.rb', line 43 def cursor_pos=(xy) set_cursor_pos(*xy) end |
#cursor_position_callback(func) ⇒ Object
126 127 128 129 |
# File 'lib/glfw3/window.rb', line 126 def cursor_position_callback(func) @__cursor_position_callback = func set_cursor_position_callback__(!func.nil?) end |
#destroy ⇒ Object
Destroys the window.
Wraps glfwDestroyWindow.
659 660 661 662 663 664 665 666 667 668 669 |
# File 'ext/glfw3/glfw3.c', line 659 static VALUE rb_window_destroy(VALUE self) { GLFWwindow *window = rb_get_window(self); if (window) { glfwDestroyWindow(window); rb_ivar_set(self, rb_intern(kRB_IVAR_WINDOW_INTERNAL), Qnil); VALUE rb_windows = rb_cvar_get(s_glfw_window_klass, rb_intern(kRB_CVAR_WINDOW_WINDOWS)); rb_hash_delete(rb_windows, INT2FIX((int)window)); } return self; } |
#focus_callback=(func) ⇒ Object
189 190 191 192 |
# File 'lib/glfw3/window.rb', line 189 def focus_callback=(func) @__focus_callback = func set_focus_callback__(!func.nil?) end |
#framebuffer_size ⇒ Object
Gets the window context’s framebuffer size.
call-seq:
framebuffer_size -> [width, height]
Wraps glfwGetFramebufferSize.
804 805 806 807 808 809 810 |
# File 'ext/glfw3/glfw3.c', line 804 static VALUE rb_window_get_framebuffer_size(VALUE self) { int width = 0; int height = 0; glfwGetFramebufferSize(rb_get_window(self), &width, &height); return rb_ary_new3(2, INT2FIX(width), INT2FIX(height)); } |
#framebuffer_size_callback(func) ⇒ Object
207 208 209 210 |
# File 'lib/glfw3/window.rb', line 207 def framebuffer_size_callback(func) @__framebuffer_size_callback = func set_framebuffer_size_callback__(!func.nil?) end |
#get_cursor_pos ⇒ Object Also known as: cursor_pos
Gets the last-reported cursor position in the window.
call-seq:
cursor_pos -> [x, y]
Wraps glfwGetCursorPos.
1076 1077 1078 1079 1080 1081 1082 |
# File 'ext/glfw3/glfw3.c', line 1076 static VALUE rb_window_get_cursor_pos(VALUE self) { double xpos = 0; double ypos = 0; glfwGetCursorPos(rb_get_window(self), &xpos, &ypos); return rb_ary_new3(2, rb_float_new(xpos), rb_float_new(ypos)); } |
#get_input_mode(mode) ⇒ Object
Gets the current value for the given input mode.
call-seq:
get_input_mode(mode) -> Fixed
Wraps glfwGetInputMode.
1015 1016 1017 1018 |
# File 'ext/glfw3/glfw3.c', line 1015 static VALUE rb_window_get_input_mode(VALUE self, VALUE mode) { return INT2FIX(glfwGetInputMode(rb_get_window(self), NUM2INT(mode))); } |
#get_position ⇒ Object Also known as: position
Gets the windows position.
call-seq:
position -> [x, y]
Wraps glfwGetWindowPos.
734 735 736 737 738 739 740 |
# File 'ext/glfw3/glfw3.c', line 734 static VALUE rb_window_get_position(VALUE self) { int xpos = 0; int ypos = 0; glfwGetWindowPos(rb_get_window(self), &xpos, &ypos); return rb_ary_new3(2, INT2FIX(xpos), INT2FIX(ypos)); } |
#get_should_close ⇒ Object Also known as: should_close?
Gets the window’s should-close flag.
call-seq:
should_close? -> true or false
Wraps glfwWindowShouldClose.
681 682 683 684 685 |
# File 'ext/glfw3/glfw3.c', line 681 static VALUE rb_window_should_close(VALUE self) { GLFWwindow *window = rb_get_window(self); return glfwWindowShouldClose(window) ? Qtrue : Qfalse; } |
#get_size ⇒ Object Also known as: size
Gets the window’s size.
call-seq:
size -> [width, height]
Wraps glfwGetWindowSize.
769 770 771 772 773 774 775 |
# File 'ext/glfw3/glfw3.c', line 769 static VALUE rb_window_get_size(VALUE self) { int width = 0; int height = 0; glfwGetWindowSize(rb_get_window(self), &width, &height); return rb_ary_new3(2, INT2FIX(width), INT2FIX(height)); } |
#height ⇒ Object
Gets the width of the window. See also #size.
95 96 97 |
# File 'lib/glfw3/window.rb', line 95 def height size[1] end |
#hide ⇒ Object
Hides the window.
Wraps glfwHideWindow.
858 859 860 861 862 |
# File 'ext/glfw3/glfw3.c', line 858 static VALUE rb_window_hide(VALUE self) { glfwHideWindow(rb_get_window(self)); return self; } |
#iconify ⇒ Object
Iconifies the window.
Wraps glfwIconifyWindow.
819 820 821 822 823 |
# File 'ext/glfw3/glfw3.c', line 819 static VALUE rb_window_iconify(VALUE self) { glfwIconifyWindow(rb_get_window(self)); return self; } |
#iconify_callback=(func) ⇒ Object
198 199 200 201 |
# File 'lib/glfw3/window.rb', line 198 def iconify_callback=(func) @__iconify_callback = func set_iconify_callback__(!func.nil?) end |
#key(key) ⇒ Object
Gets the last-reported state of the given keyboard key for the window.
call-seq:
key(key) -> Fixed
Wraps glfwGetKey.
1046 1047 1048 1049 |
# File 'ext/glfw3/glfw3.c', line 1046 static VALUE rb_window_get_key(VALUE self, VALUE key) { return INT2FIX(glfwGetKey(rb_get_window(self), NUM2INT(key))); } |
#key_callback=(func) ⇒ Object
99 100 101 102 |
# File 'lib/glfw3/window.rb', line 99 def key_callback=(func) @__key_callback = func set_key_callback__(!func.nil?) end |
#make_context_current ⇒ Object
Makes the window’s GL context current. You will need to call this before calling any OpenGL functions. See also ::unset_context to unset a context.
Wraps glfwMakeContextCurrent(window).
# Good
window.make_context_current()
Gl.glClear(Gl::GL_COLOR_BUFFER_BIT)
# Bad
Gl.glClear(Gl::GL_COLOR_BUFFER_BIT)
window.make_context_current()
Remember to make a window’s context current before calling any OpenGL functions. A window’s GL context may only be current in one thread at a time.
1343 1344 1345 1346 1347 |
# File 'ext/glfw3/glfw3.c', line 1343 static VALUE rb_window_make_context_current(VALUE self) { glfwMakeContextCurrent(rb_get_window(self)); return self; } |
#monitor ⇒ Object
Gets the window’s monitor.
call-seq:
monitor -> Glfw::Monitor
Wraps glfwGetWindowMonitor.
874 875 876 877 878 879 880 881 882 883 884 |
# File 'ext/glfw3/glfw3.c', line 874 static VALUE rb_window_get_monitor(VALUE self) { GLFWmonitor *monitor = glfwGetWindowMonitor(rb_get_window(self)); VALUE rb_monitor = Qnil; if (monitor != NULL) { // windowed mode Data_Wrap_Struct(s_glfw_monitor_klass, 0, 0, monitor); rb_obj_call_init(rb_monitor, 0, 0); } return rb_monitor; } |
#mouse_button(button) ⇒ Object
Gets the last-reported state of the given mouse button for the window.
call-seq:
(key) -> Fixed
Wraps glfwGetMouseButton.
1061 1062 1063 1064 |
# File 'ext/glfw3/glfw3.c', line 1061 static VALUE (VALUE self, VALUE ) { return INT2FIX(glfwGetMouseButton(rb_get_window(self), NUM2INT())); } |
#mouse_button_callback(func) ⇒ Object
117 118 119 120 |
# File 'lib/glfw3/window.rb', line 117 def (func) = func (!func.nil?) end |
#position=(xy) ⇒ Object
53 54 55 |
# File 'lib/glfw3/window.rb', line 53 def position=(xy) set_position(*xy) end |
#position_callback=(func) ⇒ Object
153 154 155 156 |
# File 'lib/glfw3/window.rb', line 153 def position_callback=(func) @__position_callback = func set_position_callback__(!func.nil?) end |
#refresh_callback=(func) ⇒ Object
180 181 182 183 |
# File 'lib/glfw3/window.rb', line 180 def refresh_callback=(func) @__refresh_callback = func set_refresh_callback__(!func.nil?) end |
#restore ⇒ Object
Restores the window.
Wraps glfwRestoreWindow.
832 833 834 835 836 |
# File 'ext/glfw3/glfw3.c', line 832 static VALUE rb_window_restore(VALUE self) { glfwRestoreWindow(rb_get_window(self)); return self; } |
#scroll_callback(func) ⇒ Object
144 145 146 147 |
# File 'lib/glfw3/window.rb', line 144 def scroll_callback(func) @__scroll_callback = func set_scroll_callback__(!func.nil?) end |
#set_char_callback(&block) ⇒ Object
113 114 115 |
# File 'lib/glfw3/window.rb', line 113 def set_char_callback(&block) self.char_callback = lambda(&block) end |
#set_char_callback__ ⇒ Object
#set_close_callback(&block) ⇒ Object
176 177 178 |
# File 'lib/glfw3/window.rb', line 176 def set_close_callback(&block) self.close_callback = lambda(&block) end |
#set_close_callback__ ⇒ Object
#set_cursor_enter_callback(&block) ⇒ Object
140 141 142 |
# File 'lib/glfw3/window.rb', line 140 def set_cursor_enter_callback(&block) self.cursor_enter_callback = lambda(&block) end |
#set_cursor_enter_callback__ ⇒ Object
#set_cursor_pos(x, y) ⇒ Object
Sets the position of the mouse cursor relative to the client area of the window. If the window isn’t focused at the time of the call, this silently fails.
call-seq:
set_cursor_pos(x, y) -> self
Wraps glfwSetCursorPos.
1096 1097 1098 1099 1100 |
# File 'ext/glfw3/glfw3.c', line 1096 static VALUE rb_window_set_cursor_pos(VALUE self, VALUE x, VALUE y) { glfwSetCursorPos(rb_get_window(self), NUM2DBL(x), NUM2DBL(y)); return self; } |
#set_cursor_position_callback(&block) ⇒ Object
131 132 133 |
# File 'lib/glfw3/window.rb', line 131 def set_cursor_position_callback(&block) self.cursor_position_callback = lambda(&block) end |
#set_cursor_position_callback__ ⇒ Object
#set_fbsize_callback__ ⇒ Object
#set_focus_callback(&block) ⇒ Object
194 195 196 |
# File 'lib/glfw3/window.rb', line 194 def set_focus_callback(&block) self.focus_callback = lambda(&block) end |
#set_focus_callback__ ⇒ Object
#set_framebuffer_size_callback(&block) ⇒ Object
212 213 214 |
# File 'lib/glfw3/window.rb', line 212 def set_framebuffer_size_callback(&block) self.framebuffer_size_callback = lambda(&block) end |
#set_iconify_callback(&block) ⇒ Object
203 204 205 |
# File 'lib/glfw3/window.rb', line 203 def set_iconify_callback(&block) self.iconify_callback = lambda(&block) end |
#set_iconify_callback__ ⇒ Object
#set_input_mode(mode, value) ⇒ Object
Sets the value of the given input mode.
call-seq:
set_input_mode(mode, value) -> self
Wraps glfwSetInputMode.
1030 1031 1032 1033 1034 |
# File 'ext/glfw3/glfw3.c', line 1030 static VALUE rb_window_set_input_mode(VALUE self, VALUE mode, VALUE value) { glfwSetInputMode(rb_get_window(self), NUM2INT(mode), NUM2INT(value)); return self; } |
#set_key_callback(&block) ⇒ Object
104 105 106 |
# File 'lib/glfw3/window.rb', line 104 def set_key_callback(&block) self.key_callback = lambda(&block) end |
#set_key_callback__ ⇒ Object
#set_mouse_button_callback(&block) ⇒ Object
122 123 124 |
# File 'lib/glfw3/window.rb', line 122 def (&block) self. = lambda(&block) end |
#set_mouse_button_callback__ ⇒ Object
#set_position(x, y) ⇒ Object Also known as: move
Moves the window to a new location (sets its position).
call-seq:
set_position(x, y) -> self
move(x, y) -> self
Wraps glfwSetWindowPos.
753 754 755 756 757 |
# File 'ext/glfw3/glfw3.c', line 753 static VALUE rb_window_set_position(VALUE self, VALUE x, VALUE y) { glfwSetWindowPos(rb_get_window(self), NUM2INT(x), NUM2INT(y)); return self; } |
#set_position_callback(&block) ⇒ Object
158 159 160 |
# File 'lib/glfw3/window.rb', line 158 def set_position_callback(&block) self.position_callback = lambda(&block) end |
#set_refresh_callback(&block) ⇒ Object
185 186 187 |
# File 'lib/glfw3/window.rb', line 185 def set_refresh_callback(&block) self.refresh_callback = lambda(&block) end |
#set_refresh_callback__ ⇒ Object
#set_scroll_callback(&block) ⇒ Object
149 150 151 |
# File 'lib/glfw3/window.rb', line 149 def set_scroll_callback(&block) self.scroll_callback = lambda(&block) end |
#set_scroll_callback__ ⇒ Object
#set_should_close(value) ⇒ Object Also known as: should_close=
Sets the window’s should-close flag. Ideally, the value provided should be a boolean, though it is only tested for non-nil and -false status, so it can be anything that would yield true for !!value.
call-seq:
should_close=(value) -> value
should_close = value -> value
Wraps glfwSetWindowShouldClose.
700 701 702 703 704 705 |
# File 'ext/glfw3/glfw3.c', line 700 static VALUE rb_window_set_should_close(VALUE self, VALUE value) { GLFWwindow *window = rb_get_window(self); glfwSetWindowShouldClose(window, RTEST(value) ? GL_TRUE : GL_FALSE); return value; } |
#set_size(width, height) ⇒ Object Also known as: resize
Sets the window’s size.
call-seq:
set_size(width, height) -> self
resize(width, height) -> self
Wraps glfwSetWindowSize.
788 789 790 791 792 |
# File 'ext/glfw3/glfw3.c', line 788 static VALUE rb_window_set_size(VALUE self, VALUE width, VALUE height) { glfwSetWindowSize(rb_get_window(self), NUM2INT(width), NUM2INT(height)); return self; } |
#set_size_callback(&block) ⇒ Object
167 168 169 |
# File 'lib/glfw3/window.rb', line 167 def set_size_callback(&block) self.size_callback = lambda(&block) end |
#set_window_position_callback__ ⇒ Object
#set_window_size_callback__ ⇒ Object
#show ⇒ Object
Shows the window.
Wraps glfwShowWindow.
845 846 847 848 849 |
# File 'ext/glfw3/glfw3.c', line 845 static VALUE rb_window_show(VALUE self) { glfwShowWindow(rb_get_window(self)); return self; } |
#size=(wh) ⇒ Object
57 58 59 |
# File 'lib/glfw3/window.rb', line 57 def size=(wh) set_size(*wh) end |
#size_callback=(func) ⇒ Object
162 163 164 165 |
# File 'lib/glfw3/window.rb', line 162 def size_callback=(func) @__size_callback = func set_size_callback__(!func.nil?) end |
#swap_buffers ⇒ Object
Swaps the front and back buffers for the window. You will typically call this at the end of your drawing routines.
Wraps glfwSwapBuffers.
loop {
Glfw.poll_events()
# ...
window.swap_buffers()
}
1398 1399 1400 1401 1402 |
# File 'ext/glfw3/glfw3.c', line 1398 static VALUE rb_window_swap_buffers(VALUE self) { glfwSwapBuffers(rb_get_window(self)); return self; } |
#title=(new_title) ⇒ Object
Sets the window’s title.
call-seq:
title=(new_title) -> new_title
title = new_title -> new_title
Wraps glfwSetWindowTitle.
718 719 720 721 722 |
# File 'ext/glfw3/glfw3.c', line 718 static VALUE rb_window_set_title(VALUE self, VALUE new_title) { glfwSetWindowTitle(rb_get_window(self), StringValueCStr(new_title)); return new_title; } |
#width ⇒ Object
Gets the width of the window. See also #size.
88 89 90 |
# File 'lib/glfw3/window.rb', line 88 def width size[0] end |
#x ⇒ Object
Gets the X position of the window in screen space. See also #position.
74 75 76 |
# File 'lib/glfw3/window.rb', line 74 def x position[0] end |
#y ⇒ Object
Gets the Y position of the window in screen space. See also #position.
81 82 83 |
# File 'lib/glfw3/window.rb', line 81 def y position[1] end |