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
-
.current_context ⇒ Object
Gets the window for the current GL context in this thread.
-
.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
- #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
.current_context ⇒ Object
Gets the window for the current GL context in this thread.
call-seq:
current_context() -> Glfw::Window
Wraps glfwGetCurrentContext.
1473 1474 1475 1476 |
# File 'ext/glfw3/glfw3.c', line 1473
static VALUE rb_window_get_current_context(VALUE self)
{
return rb_lookup_window(glfwGetCurrentContext());
}
|
.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.
564 565 566 567 568 |
# File 'ext/glfw3/glfw3.c', line 564
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.
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 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 |
# File 'ext/glfw3/glfw3.c', line 625
static VALUE rb_window_new(int argc, VALUE *argv, VALUE self)
{
ID ivar_window = 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 (Q_IS_A(rb_monitor, s_glfw_monitor_klass)) {
Data_Get_Struct(rb_monitor, GLFWmonitor, monitor);
}
if (Q_IS_A(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, kRB_IVAR_WINDOW_KEY_CALLBACK, Qnil);
rb_ivar_set(rb_window, kRB_IVAR_WINDOW_CHAR_CALLBACK, Qnil);
rb_ivar_set(rb_window, kRB_IVAR_WINDOW_MOUSE_BUTTON_CALLBACK, Qnil);
rb_ivar_set(rb_window, kRB_IVAR_WINDOW_CURSOR_POSITION_CALLBACK, Qnil);
rb_ivar_set(rb_window, kRB_IVAR_WINDOW_CURSOR_ENTER_CALLBACK, Qnil);
rb_ivar_set(rb_window, kRB_IVAR_WINDOW_SCROLL_CALLBACK, Qnil);
rb_ivar_set(rb_window, kRB_IVAR_WINDOW_POSITION_CALLBACK, Qnil);
rb_ivar_set(rb_window, kRB_IVAR_WINDOW_SIZE_CALLBACK, Qnil);
rb_ivar_set(rb_window, kRB_IVAR_WINDOW_CLOSE_CALLBACK, Qnil);
rb_ivar_set(rb_window, kRB_IVAR_WINDOW_REFRESH_CALLBACK, Qnil);
rb_ivar_set(rb_window, kRB_IVAR_WINDOW_FOCUS_CALLBACK, Qnil);
rb_ivar_set(rb_window, kRB_IVAR_WINDOW_ICONIFY_CALLBACK, Qnil);
rb_ivar_set(rb_window, 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, 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).
1457 1458 1459 1460 1461 |
# File 'ext/glfw3/glfw3.c', line 1457
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.
580 581 582 583 584 |
# File 'ext/glfw3/glfw3.c', line 580
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.respond_to?(:call)) 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.
1385 1386 1387 1388 |
# File 'ext/glfw3/glfw3.c', line 1385
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.
1368 1369 1370 1371 1372 |
# File 'ext/glfw3/glfw3.c', line 1368
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.respond_to?(:call)) end |
#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.respond_to?(:call)) 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.respond_to?(:call)) end |
#destroy ⇒ Object
Destroys the window.
Wraps glfwDestroyWindow.
705 706 707 708 709 710 711 712 713 714 715 716 |
# File 'ext/glfw3/glfw3.c', line 705
static VALUE rb_window_destroy(VALUE self)
{
VALUE rb_windows = Qnil;
GLFWwindow *window = rb_get_window(self);
if (window) {
glfwDestroyWindow(window);
rb_ivar_set(self, kRB_IVAR_WINDOW_INTERNAL, Qnil);
rb_windows = rb_cvar_get(s_glfw_window_klass, 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.respond_to?(:call)) end |
#framebuffer_size ⇒ Object
Gets the window context’s framebuffer size.
call-seq:
framebuffer_size -> [width, height]
Wraps glfwGetFramebufferSize.
851 852 853 854 855 856 857 |
# File 'ext/glfw3/glfw3.c', line 851
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_fbsize_callback__(func.respond_to?(:call)) 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.
1151 1152 1153 1154 1155 1156 1157 |
# File 'ext/glfw3/glfw3.c', line 1151
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.
1090 1091 1092 1093 |
# File 'ext/glfw3/glfw3.c', line 1090
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.
781 782 783 784 785 786 787 |
# File 'ext/glfw3/glfw3.c', line 781
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.
728 729 730 731 732 |
# File 'ext/glfw3/glfw3.c', line 728
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.
816 817 818 819 820 821 822 |
# File 'ext/glfw3/glfw3.c', line 816
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.
905 906 907 908 909 |
# File 'ext/glfw3/glfw3.c', line 905
static VALUE rb_window_hide(VALUE self)
{
glfwHideWindow(rb_get_window(self));
return self;
}
|
#iconify ⇒ Object
Iconifies the window.
Wraps glfwIconifyWindow.
866 867 868 869 870 |
# File 'ext/glfw3/glfw3.c', line 866
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.respond_to?(:call)) end |
#key(key) ⇒ Object
Gets the last-reported state of the given keyboard key for the window.
call-seq:
key(key) -> Fixed
Wraps glfwGetKey.
1121 1122 1123 1124 |
# File 'ext/glfw3/glfw3.c', line 1121
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.respond_to?(:call)) 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.
1444 1445 1446 1447 1448 |
# File 'ext/glfw3/glfw3.c', line 1444
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.
921 922 923 924 925 926 927 928 929 930 931 |
# File 'ext/glfw3/glfw3.c', line 921
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:
mouse_button(key) -> Fixed
Wraps glfwGetMouseButton.
1136 1137 1138 1139 |
# File 'ext/glfw3/glfw3.c', line 1136
static VALUE rb_window_get_mouse_button(VALUE self, VALUE button)
{
return INT2FIX(glfwGetMouseButton(rb_get_window(self), NUM2INT(button)));
}
|
#mouse_button_callback=(func) ⇒ Object
117 118 119 120 |
# File 'lib/glfw3/window.rb', line 117 def (func) @__mouse_button_callback = func (func.respond_to?(:call)) 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_window_position_callback__(func.respond_to?(:call)) 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.respond_to?(:call)) end |
#restore ⇒ Object
Restores the window.
Wraps glfwRestoreWindow.
879 880 881 882 883 |
# File 'ext/glfw3/glfw3.c', line 879
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.respond_to?(:call)) end |
#set_char_callback(&block) ⇒ Object
113 114 115 |
# File 'lib/glfw3/window.rb', line 113 def set_char_callback(&block) self.char_callback = 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 = 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 = 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.
1171 1172 1173 1174 1175 |
# File 'ext/glfw3/glfw3.c', line 1171
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 = 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 = 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 = 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 = 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.
1105 1106 1107 1108 1109 |
# File 'ext/glfw3/glfw3.c', line 1105
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 = 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. = 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.
800 801 802 803 804 |
# File 'ext/glfw3/glfw3.c', line 800
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 = 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 = 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 = 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.
747 748 749 750 751 752 |
# File 'ext/glfw3/glfw3.c', line 747
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.
835 836 837 838 839 |
# File 'ext/glfw3/glfw3.c', line 835
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 = block end |
#set_window_position_callback__ ⇒ Object
#set_window_size_callback__ ⇒ Object
#show ⇒ Object
Shows the window.
Wraps glfwShowWindow.
892 893 894 895 896 |
# File 'ext/glfw3/glfw3.c', line 892
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_window_size_callback__(func.respond_to?(:call)) 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()
}
1494 1495 1496 1497 1498 |
# File 'ext/glfw3/glfw3.c', line 1494
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.
765 766 767 768 769 |
# File 'ext/glfw3/glfw3.c', line 765
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 |