Class: Glfw::Window

Inherits:
Object
  • Object
show all
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

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#user_dataObject

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_hintsObject

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.



551
552
553
554
555
# File 'ext/glfw3/glfw3.c', line 551

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.



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
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
# File 'ext/glfw3/glfw3.c', line 606

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 (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, 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_contextObject

Unsets the current GL context.

Wraps glfwMakeContextCurrent(NULL).



1383
1384
1385
1386
1387
# File 'ext/glfw3/glfw3.c', line 1383

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.



567
568
569
570
571
# File 'ext/glfw3/glfw3.c', line 567

static VALUE rb_window_window_hint(VALUE self, VALUE target, VALUE hint)
{
  glfwWindowHint(NUM2INT(target), NUM2INT(hint));
  return self;
}

.windowsObject

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_stringObject

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.



1311
1312
1313
1314
# File 'ext/glfw3/glfw3.c', line 1311

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.



1294
1295
1296
1297
1298
# File 'ext/glfw3/glfw3.c', line 1294

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_contextObject

Gets the window for the current GL context in this thread.

call-seq:

current_context() -> Glfw::Window

Wraps glfwGetCurrentContext.



1399
1400
1401
1402
1403
1404
1405
1406
1407
# File 'ext/glfw3/glfw3.c', line 1399

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

#destroyObject

Destroys the window.

Wraps glfwDestroyWindow.



686
687
688
689
690
691
692
693
694
695
696
# File 'ext/glfw3/glfw3.c', line 686

static VALUE rb_window_destroy(VALUE self)
{
  GLFWwindow *window = rb_get_window(self);
  if (window) {
    glfwDestroyWindow(window);
    rb_ivar_set(self, kRB_IVAR_WINDOW_INTERNAL, Qnil);
    VALUE 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.nil?)
end

#framebuffer_sizeObject

Gets the window context’s framebuffer size.

call-seq:

framebuffer_size -> [width, height]

Wraps glfwGetFramebufferSize.



831
832
833
834
835
836
837
# File 'ext/glfw3/glfw3.c', line 831

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_posObject Also known as: cursor_pos

Gets the last-reported cursor position in the window.

call-seq:

cursor_pos -> [x, y]

Wraps glfwGetCursorPos.



1103
1104
1105
1106
1107
1108
1109
# File 'ext/glfw3/glfw3.c', line 1103

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.



1042
1043
1044
1045
# File 'ext/glfw3/glfw3.c', line 1042

static VALUE rb_window_get_input_mode(VALUE self, VALUE mode)
{
  return INT2FIX(glfwGetInputMode(rb_get_window(self), NUM2INT(mode)));
}

#get_positionObject Also known as: position

Gets the windows position.

call-seq:

position -> [x, y]

Wraps glfwGetWindowPos.



761
762
763
764
765
766
767
# File 'ext/glfw3/glfw3.c', line 761

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_closeObject Also known as: should_close?

Gets the window’s should-close flag.

call-seq:

should_close? -> true or false

Wraps glfwWindowShouldClose.



708
709
710
711
712
# File 'ext/glfw3/glfw3.c', line 708

static VALUE rb_window_should_close(VALUE self)
{
  GLFWwindow *window = rb_get_window(self);
  return glfwWindowShouldClose(window) ? Qtrue : Qfalse;
}

#get_sizeObject Also known as: size

Gets the window’s size.

call-seq:

size -> [width, height]

Wraps glfwGetWindowSize.



796
797
798
799
800
801
802
# File 'ext/glfw3/glfw3.c', line 796

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));
}

#heightObject

Gets the width of the window. See also #size.



95
96
97
# File 'lib/glfw3/window.rb', line 95

def height
  size[1]
end

#hideObject

Hides the window.

Wraps glfwHideWindow.



885
886
887
888
889
# File 'ext/glfw3/glfw3.c', line 885

static VALUE rb_window_hide(VALUE self)
{
  glfwHideWindow(rb_get_window(self));
  return self;
}

#iconifyObject

Iconifies the window.

Wraps glfwIconifyWindow.



846
847
848
849
850
# File 'ext/glfw3/glfw3.c', line 846

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.



1073
1074
1075
1076
# File 'ext/glfw3/glfw3.c', line 1073

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_currentObject

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.



1370
1371
1372
1373
1374
# File 'ext/glfw3/glfw3.c', line 1370

static VALUE rb_window_make_context_current(VALUE self)
{
  glfwMakeContextCurrent(rb_get_window(self));
  return self;
}

#monitorObject

Gets the window’s monitor.

call-seq:

monitor -> Glfw::Monitor

Wraps glfwGetWindowMonitor.



901
902
903
904
905
906
907
908
909
910
911
# File 'ext/glfw3/glfw3.c', line 901

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.



1088
1089
1090
1091
# File 'ext/glfw3/glfw3.c', line 1088

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 mouse_button_callback=(func)
  @__mouse_button_callback = func
  set_mouse_button_callback__(!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

#restoreObject

Restores the window.

Wraps glfwRestoreWindow.



859
860
861
862
863
# File 'ext/glfw3/glfw3.c', line 859

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.



1123
1124
1125
1126
1127
# File 'ext/glfw3/glfw3.c', line 1123

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.



1057
1058
1059
1060
1061
# File 'ext/glfw3/glfw3.c', line 1057

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 set_mouse_button_callback(&block)
  self.mouse_button_callback = 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.



780
781
782
783
784
# File 'ext/glfw3/glfw3.c', line 780

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.



727
728
729
730
731
732
# File 'ext/glfw3/glfw3.c', line 727

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.



815
816
817
818
819
# File 'ext/glfw3/glfw3.c', line 815

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

#showObject

Shows the window.

Wraps glfwShowWindow.



872
873
874
875
876
# File 'ext/glfw3/glfw3.c', line 872

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_buffersObject

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()
}


1425
1426
1427
1428
1429
# File 'ext/glfw3/glfw3.c', line 1425

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.



745
746
747
748
749
# File 'ext/glfw3/glfw3.c', line 745

static VALUE rb_window_set_title(VALUE self, VALUE new_title)
{
  glfwSetWindowTitle(rb_get_window(self), StringValueCStr(new_title));
  return new_title;
}

#widthObject

Gets the width of the window. See also #size.



88
89
90
# File 'lib/glfw3/window.rb', line 88

def width
  size[0]
end

#xObject

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

#yObject

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