Class: GLFW::Window
- Inherits:
-
Object
- Object
- GLFW::Window
- Defined in:
- lib/glfw/stubs/window.rb,
lib/glfw/constants.rb
Overview
Represents an application window and OpenGL context.
Cursor Mode collapse
- CURSOR_NORMAL =
The cursor is visible and behaves normally.
0x00034001- CURSOR_HIDDEN =
The cursor is invisible when it is over the content area of the window but does not restrict the cursor from leaving.
0x00034002- CURSOR_DISABLED =
The application window hides and grabs the cursor, providing virtual and unlimited cursor movement, useful for implementing 3D camera controls.
0x00034003
Instance Attribute Summary collapse
-
#auto_focus ⇒ Boolean
A value indicating if window will automatically focus when being restored from minimized state, etc.
-
#clipboard ⇒ String?
A string for the clipboard associated with the window.
-
#content_scale ⇒ Vec2
readonly
The current content scale of the window.
-
#cursor ⇒ Cursor?
The mouse cursor the window uses, or
nilif not specified. -
#cursor_mode ⇒ Integer
A value indicating the behavior of the mouse cursor.
-
#cursor_pos ⇒ Vec2
The location of the mouse cursor.
-
#decorated ⇒ Boolean
A value indicating if the window will be decoarted with a frame, close widget, etc.
-
#framebuffer_size ⇒ Size
readonly
The dimensions of the window's primary framebuffer, in pixel coordinates.
-
#icon ⇒ Image+
The icon(s) to be displayed as a window decoration, on systems that support this functionality.
-
#lock_modifiers ⇒ Boolean
A value indicating if modifier bits for input callback functions will include MOD_CAPS_LOCK, MOD_NUM_LOCK, etc.
-
#monitor ⇒ Monitor?
readonly
The monitor the window is displayed on, or
nilif not a fullscreen window. -
#opacity ⇒ Float
A value determining the visibility of the window (including frame), where
0.0is invisible and1.0is fully opaque. -
#position ⇒ Point
The position of the top-left corner of the window's client area, in screen coordinates.
-
#raw_mouse_motion ⇒ Boolean
When the cursor is disabled, raw (unscaled and unaccelerated) mouse motion can be enabled if available.
-
#resizable ⇒ Boolean
A value indicating if window is resizable by the user.
-
#size ⇒ Size
The size of the window's client area, in screen coordinates.
-
#sticky_buttons ⇒ Boolean
A value indicating if input states for mouse buttons will persist until queried with #button?.
-
#sticky_keys ⇒ Boolean
A value indicating if input states for keys will persist until queried with #key?.
-
#title ⇒ String?
The window caption displayed in the system menubar, window titlebar, etc.
-
#topmost ⇒ Boolean
trueif window is floating (always-on-top) of other application windows, otherwisefalse. -
#visible ⇒ Boolean
The visibility state of the window.
Callback Functions collapse
-
#on_char ⇒ Proc?
The character callback is intended for Unicode text input.
-
#on_close ⇒ Proc?
The previous callback that was set, or
nilif none existed. -
#on_cursor_enter ⇒ Proc?
The previous callback that was set, or
nilif none existed. -
#on_cursor_move ⇒ Proc?
The previous callback that was set, or
nilif none existed. -
#on_file_drop ⇒ Proc?
The previous callback that was set, or
nilif none existed. -
#on_focus ⇒ Proc?
The previous callback that was set, or
nilif none existed. -
#on_framebuffer_resize ⇒ Proc?
The previous callback that was set, or
nilif none existed. -
#on_key ⇒ Proc?
The previous callback that was set, or
nilif none existed. -
#on_maximize ⇒ Proc?
The previous callback that was set, or
nilif none existed. -
#on_minimize ⇒ Proc?
The previous callback that was set, or
nilif none existed. -
#on_mouse_button ⇒ Proc?
The previous callback that was set, or
nilif none existed. -
#on_move ⇒ Proc?
The previous callback that was set, or
nilif none existed. -
#on_refresh ⇒ Proc?
The previous callback that was set, or
nilif none existed. -
#on_resize ⇒ Proc?
The previous callback that was set, or
nilif none existed. -
#on_scale ⇒ Proc?
The previous callback that was set, or
nilif none existed. -
#on_scroll ⇒ Proc?
The previous callback that was set, or
nilif none existed.
Class Method Summary collapse
-
.current ⇒ Window?
The Window whose context is current on the calling thread, or
nilif none is found. -
.default_hints ⇒ void
Resets all window hints that have been applied back to the "default" configuration.
-
.hint(hint, value) ⇒ void
Sets a hint for the next window creation.
Instance Method Summary collapse
-
#aspect_ratio(numerator, denominator) ⇒ void
Modifies the behavior when a user resizes the window to stay locked to the specified aspect ratio.
-
#button?(button) ⇒ Boolean
Returns the last state reported for the specified mouse button to the window.
-
#center ⇒ self
Centers a window on the screen.
-
#change_monitor(monitor, position, size, hz = -1)) ⇒ void
Ssets the monitor that the window uses for full screen mode or, if the monitor is
nil, makes it windowed mode. -
#close(flag = true) ⇒ self
Sets the closing state of the window.
-
#closing? ⇒ Boolean
Retrieves value indicating if window is currently set to close.
-
#current? ⇒ Boolean
Returns value indicating if the OpenGL context of this window is current on the calling thread.
-
#destroy ⇒ void
(also: #dispose)
Destroys the window, reclaiming any resources it is using and invalidating it for further use.
-
#focus ⇒ self
Brings the specified window to front and sets input focus.
-
#focused? ⇒ Boolean
Returns value indicating if the window currently contains the operating system input focus.
-
#frame_size ⇒ Array<Integer>
Retrieves the size, in screen coordinates, of each edge of the frame of the specified window.
-
#fullscreen? ⇒ Boolean
Returns value indicating if window is currently in fullscreen mode on the monitor.
-
#hide ⇒ self
Hides the window if it was previously visible.
-
#hovered? ⇒ Boolean
Returns value indicating if the mouse cursor is currently over thw window's client area.
-
#initialize(width, height, title = nil, **opts) ⇒ Window
constructor
Creates a new instance of the Window class.
-
#key?(key) ⇒ Boolean
Returns the last state reported for the specified key to the window.
-
#make_current ⇒ self
Sets the OpenGL context of the window as current on the calling thread.
-
#maximize ⇒ self
Maximizes the window if it was previously not maximized.
-
#maximized? ⇒ Boolean
Returns value indicated if window is currently maximized to fill the work area of the monitor.
-
#minimize ⇒ self
Mminimizes the window if it was previously restored.
-
#minimized? ⇒ Boolean
Returns value indicating if window is currently minimized to the system toolbar.
-
#move_cursor(x, y) ⇒ void
Moves the mouse cursor to the specified coordinates.
-
#request_attention ⇒ self
Requests user attention to the window.
-
#restore ⇒ self
Restores the window if it was previously minimized or maximized.
-
#show ⇒ self
Makes the window visible if it was previously hidden.
-
#size_limits(min, max) ⇒ void
Sets the minimum and maximum sizes that a user can resize the window to.
-
#swap_buffers ⇒ void
Typically called each frame, swaps the front and back buffers used for rendering, presenting the current back buffer to the user, while staging the current front buffer to be overwritten.
Constructor Details
#initialize(width, height, title = nil, **opts) ⇒ Window
The OpenGL coontext will automatically be made current on the thread for the new window.
Creates a new instance of the GLFW::Window class.
47 48 |
# File 'lib/glfw/stubs/window.rb', line 47 def initialize(width, height, title = nil, **opts) end |
Instance Attribute Details
#auto_focus ⇒ Boolean
Returns a value indicating if window will automatically focus when being restored from minimized state, etc.
338 339 340 |
# File 'lib/glfw/stubs/window.rb', line 338 def auto_focus @auto_focus end |
#clipboard ⇒ String?
Returns a string for the clipboard associated with the window.
334 335 336 |
# File 'lib/glfw/stubs/window.rb', line 334 def clipboard @clipboard end |
#content_scale ⇒ Vec2 (readonly)
Returns the current content scale of the window.
376 377 378 |
# File 'lib/glfw/stubs/window.rb', line 376 def content_scale @content_scale end |
#cursor ⇒ Cursor?
Returns the mouse cursor the window uses, or nil if not specified.
314 315 316 |
# File 'lib/glfw/stubs/window.rb', line 314 def cursor @cursor end |
#cursor_mode ⇒ Integer
Returns a value indicating the behavior of the mouse cursor.
345 346 347 |
# File 'lib/glfw/stubs/window.rb', line 345 def cursor_mode @cursor_mode end |
#cursor_pos ⇒ Vec2
Returns the location of the mouse cursor.
318 319 320 |
# File 'lib/glfw/stubs/window.rb', line 318 def cursor_pos @cursor_pos end |
#decorated ⇒ Boolean
Returns a value indicating if the window will be decoarted with a frame, close widget, etc.
326 327 328 |
# File 'lib/glfw/stubs/window.rb', line 326 def decorated @decorated end |
#framebuffer_size ⇒ Size (readonly)
Returns the dimensions of the window's primary framebuffer, in pixel coordinates.
380 381 382 |
# File 'lib/glfw/stubs/window.rb', line 380 def framebuffer_size @framebuffer_size end |
#icon ⇒ Image+
The icon(s) to be displayed as a window decoration, on systems that support this functionality.
302 303 304 |
# File 'lib/glfw/stubs/window.rb', line 302 def icon @icon end |
#lock_modifiers ⇒ Boolean
Returns a value indicating if modifier bits for input callback functions will include MOD_CAPS_LOCK, MOD_NUM_LOCK, etc.
357 358 359 |
# File 'lib/glfw/stubs/window.rb', line 357 def lock_modifiers @lock_modifiers end |
#monitor ⇒ Monitor? (readonly)
Returns the monitor the window is displayed on, or nil if not a fullscreen window.
372 373 374 |
# File 'lib/glfw/stubs/window.rb', line 372 def monitor @monitor end |
#opacity ⇒ Float
Returns a value determining the visibility of the window (including frame), where 0.0 is invisible and 1.0 is fully opaque.
322 323 324 |
# File 'lib/glfw/stubs/window.rb', line 322 def opacity @opacity end |
#position ⇒ Point
Returns the position of the top-left corner of the window's client area, in screen coordinates.
306 307 308 |
# File 'lib/glfw/stubs/window.rb', line 306 def position @position end |
#raw_mouse_motion ⇒ Boolean
When the cursor is disabled, raw (unscaled and unaccelerated) mouse motion can be enabled if available.
Raw mouse motion is closer to the actual motion of the mouse across a surface. It is not affected by the scaling and acceleration applied to the motion of the desktop cursor. That processing is suitable for a cursor while raw motion is better for controlling for example a 3D camera. Because of this, raw mouse motion is only provided when the cursor is disabled.
368 369 370 |
# File 'lib/glfw/stubs/window.rb', line 368 def raw_mouse_motion @raw_mouse_motion end |
#resizable ⇒ Boolean
Returns a value indicating if window is resizable by the user.
330 331 332 |
# File 'lib/glfw/stubs/window.rb', line 330 def resizable @resizable end |
#size ⇒ Size
Returns the size of the window's client area, in screen coordinates.
310 311 312 |
# File 'lib/glfw/stubs/window.rb', line 310 def size @size end |
#sticky_buttons ⇒ Boolean
Returns a value indicating if input states for mouse buttons will persist until queried with #button?.
353 354 355 |
# File 'lib/glfw/stubs/window.rb', line 353 def @sticky_buttons end |
#sticky_keys ⇒ Boolean
Returns a value indicating if input states for keys will persist until queried with #key?.
349 350 351 |
# File 'lib/glfw/stubs/window.rb', line 349 def sticky_keys @sticky_keys end |
#title ⇒ String?
Returns the window caption displayed in the system menubar, window titlebar, etc.
289 290 291 |
# File 'lib/glfw/stubs/window.rb', line 289 def title @title end |
#topmost ⇒ Boolean
Returns true if window is floating (always-on-top) of other application windows, otherwise false.
297 298 299 |
# File 'lib/glfw/stubs/window.rb', line 297 def topmost @topmost end |
#visible ⇒ Boolean
Returns the visibility state of the window.
293 294 295 |
# File 'lib/glfw/stubs/window.rb', line 293 def visible @visible end |
Class Method Details
.current ⇒ Window?
Returns the GLFW::Window whose context is current on the calling thread, or nil if none is found.
28 29 |
# File 'lib/glfw/stubs/window.rb', line 28 def self.current end |
.default_hints ⇒ void
This method returns an undefined value.
Resets all window hints that have been applied back to the "default" configuration.
11 12 |
# File 'lib/glfw/stubs/window.rb', line 11 def self.default_hints end |
.hint(hint, value) ⇒ void
This method returns an undefined value.
Sets a hint for the next window creation. Once set, the value will persist until changed with this function or the library is terminated.
23 24 |
# File 'lib/glfw/stubs/window.rb', line 23 def self.hint(hint, value) end |
Instance Method Details
#aspect_ratio(numerator, denominator) ⇒ void
This method returns an undefined value.
Modifies the behavior when a user resizes the window to stay locked to the specified aspect ratio.
109 110 |
# File 'lib/glfw/stubs/window.rb', line 109 def aspect_ratio(numerator, denominator) end |
#button?(button) ⇒ Boolean
Returns the last state reported for the specified mouse button to the window.
260 261 |
# File 'lib/glfw/stubs/window.rb', line 260 def () end |
#center ⇒ self
Centers a window on the screen. Has no effect on fullscreen windows.
146 147 |
# File 'lib/glfw/stubs/window.rb', line 146 def center end |
#change_monitor(monitor, position, size, hz = -1)) ⇒ void
This method returns an undefined value.
Ssets the monitor that the window uses for full screen mode or, if the monitor is nil,
makes it windowed mode.
When setting a monitor, this function updates the width, height and refresh rate of the desired video mode and switches to the video mode closest to it. The window position is ignored when setting a monitor.
When the monitor is nil, the position, width and height are used to place the window
content area. The refresh rate is ignored when no monitor is specified.
When a window transitions from full screen to windowed mode, this function restores any previous window settings such as whether it is decorated, floating, resizable, has size or aspect ratio limits, etc.
284 285 |
# File 'lib/glfw/stubs/window.rb', line 284 def change_monitor(monitor, position, size, hz = -1) end |
#close(flag = true) ⇒ self
Sets the closing state of the window.
158 159 |
# File 'lib/glfw/stubs/window.rb', line 158 def close(flag = true) end |
#closing? ⇒ Boolean
Retrieves value indicating if window is currently set to close.
return [Boolean] true if window is set to close, otherwise false.
168 169 |
# File 'lib/glfw/stubs/window.rb', line 168 def closing? end |
#current? ⇒ Boolean
Returns value indicating if the OpenGL context of this window is current on the calling thread.
69 70 |
# File 'lib/glfw/stubs/window.rb', line 69 def current? end |
#destroy ⇒ void Also known as: dispose
This method returns an undefined value.
Destroys the window, reclaiming any resources it is using and invalidating it for further use.
53 54 |
# File 'lib/glfw/stubs/window.rb', line 53 def destroy end |
#focus ⇒ self
Brings the specified window to front and sets input focus. The window should already be visible and not minimized.
200 201 |
# File 'lib/glfw/stubs/window.rb', line 200 def focus end |
#focused? ⇒ Boolean
Returns value indicating if the window currently contains the operating system input focus.
75 76 |
# File 'lib/glfw/stubs/window.rb', line 75 def focused? end |
#frame_size ⇒ Array<Integer>
Values will always be greater than or equal to 0.
Retrieves the size, in screen coordinates, of each edge of the frame of the specified window. This size includes the title bar, if the window has one.
130 131 |
# File 'lib/glfw/stubs/window.rb', line 130 def frame_size end |
#fullscreen? ⇒ Boolean
Returns value indicating if window is currently in fullscreen mode on the monitor.
99 100 |
# File 'lib/glfw/stubs/window.rb', line 99 def fullscreen? end |
#hide ⇒ self
Hides the window if it was previously visible. If the window is already hidden or is in full screen mode, this method does nothing.
194 195 |
# File 'lib/glfw/stubs/window.rb', line 194 def hide end |
#hovered? ⇒ Boolean
Returns value indicating if the mouse cursor is currently over thw window's client area.
93 94 |
# File 'lib/glfw/stubs/window.rb', line 93 def hovered? end |
#key?(key) ⇒ Boolean
Returns the last state reported for the specified key to the window.
249 250 |
# File 'lib/glfw/stubs/window.rb', line 249 def key?(key) end |
#make_current ⇒ self
Sets the OpenGL context of the window as current on the calling thread.
62 63 |
# File 'lib/glfw/stubs/window.rb', line 62 def make_current end |
#maximize ⇒ self
Maximizes the window if it was previously not maximized. If the window is already maximized, this function does nothing. If the window is fullscreen, this function does nothing.
220 221 |
# File 'lib/glfw/stubs/window.rb', line 220 def maximize end |
#maximized? ⇒ Boolean
Returns value indicated if window is currently maximized to fill the work area of the monitor.
87 88 |
# File 'lib/glfw/stubs/window.rb', line 87 def maximized? end |
#minimize ⇒ self
Mminimizes the window if it was previously restored. If the window is already iconified, this function does nothing. If the window is fullscreen, the original monitor resolution is restored until the window is restored.
210 211 |
# File 'lib/glfw/stubs/window.rb', line 210 def minimize end |
#minimized? ⇒ Boolean
Returns value indicating if window is currently minimized to the system toolbar.
81 82 |
# File 'lib/glfw/stubs/window.rb', line 81 def minimized? end |
#move_cursor(x, y) ⇒ void
This method returns an undefined value.
Moves the mouse cursor to the specified coordinates.
140 141 |
# File 'lib/glfw/stubs/window.rb', line 140 def move_cursor(x, y) end |
#on_char {|codepoint| ... } ⇒ Proc? #on_char ⇒ Proc?
The character callback is intended for Unicode text input. As it deals with characters, it is keyboard layout dependent, whereas the key callback is not. Characters do not map 1:1 to physical keys, as a key may produce zero, one or more characters. If you want to know whether a specific physical key was pressed or released, see the key callback instead.
The character callback behaves as system text input normally does and will not be called if modifier keys are held down that would prevent normal text input on that platform, for example a Super (Command) key on macOS or Alt key on Windows.
609 610 |
# File 'lib/glfw/stubs/window.rb', line 609 def on_char end |
#on_close { ... } ⇒ Proc? #on_close ⇒ Proc?
Returns the previous callback that was set, or nil if none existed.
467 468 |
# File 'lib/glfw/stubs/window.rb', line 467 def on_close end |
#on_cursor_enter {|entered| ... } ⇒ Proc? #on_cursor_enter ⇒ Proc?
Returns the previous callback that was set, or nil if none existed.
588 589 |
# File 'lib/glfw/stubs/window.rb', line 588 def on_cursor_enter end |
#on_cursor_move {|x, y| ... } ⇒ Proc? #on_cursor_move ⇒ Proc?
Returns the previous callback that was set, or nil if none existed.
525 526 |
# File 'lib/glfw/stubs/window.rb', line 525 def on_cursor_move end |
#on_file_drop {|paths| ... } ⇒ Proc? #on_file_drop ⇒ Proc?
Returns the previous callback that was set, or nil if none existed.
508 509 |
# File 'lib/glfw/stubs/window.rb', line 508 def on_file_drop end |
#on_focus {|focused| ... } ⇒ Proc? #on_focus ⇒ Proc?
Returns the previous callback that was set, or nil if none existed.
437 438 |
# File 'lib/glfw/stubs/window.rb', line 437 def on_focus end |
#on_framebuffer_resize {|width, height| ... } ⇒ Proc? #on_framebuffer_resize ⇒ Proc?
Returns the previous callback that was set, or nil if none existed.
395 396 |
# File 'lib/glfw/stubs/window.rb', line 395 def on_framebuffer_resize end |
#on_key {|key, scancode, action, modifiers| ... } ⇒ Proc? #on_key ⇒ Proc?
Returns the previous callback that was set, or nil if none existed.
557 558 |
# File 'lib/glfw/stubs/window.rb', line 557 def on_key end |
#on_maximize {|maximized| ... } ⇒ Proc? #on_maximize ⇒ Proc?
Returns the previous callback that was set, or nil if none existed.
495 496 |
# File 'lib/glfw/stubs/window.rb', line 495 def on_maximize end |
#on_minimize {|minimized| ... } ⇒ Proc? #on_minimize ⇒ Proc?
Returns the previous callback that was set, or nil if none existed.
481 482 |
# File 'lib/glfw/stubs/window.rb', line 481 def on_minimize end |
#on_mouse_button {|button, action, modifiers| ... } ⇒ Proc? #on_mouse_button ⇒ Proc?
Returns the previous callback that was set, or nil if none existed.
575 576 |
# File 'lib/glfw/stubs/window.rb', line 575 def end |
#on_move {|x, y| ... } ⇒ Proc? #on_move ⇒ Proc?
Returns the previous callback that was set, or nil if none existed.
423 424 |
# File 'lib/glfw/stubs/window.rb', line 423 def on_move end |
#on_refresh { ... } ⇒ Proc? #on_refresh ⇒ Proc?
On compositing window systems such as Aero, Compiz, Aqua or Wayland, where the window contents are saved off-screen, this callback may be called only very infrequently or never at all.
Returns the previous callback that was set, or nil if none existed.
453 454 |
# File 'lib/glfw/stubs/window.rb', line 453 def on_refresh end |
#on_resize {|width, height| ... } ⇒ Proc? #on_resize ⇒ Proc?
Returns the previous callback that was set, or nil if none existed.
409 410 |
# File 'lib/glfw/stubs/window.rb', line 409 def on_resize end |
#on_scale {|x, y| ... } ⇒ Proc? #on_scale ⇒ Proc?
Returns the previous callback that was set, or nil if none existed.
623 624 |
# File 'lib/glfw/stubs/window.rb', line 623 def on_scale end |
#on_scroll {|x, y| ... } ⇒ Proc? #on_scroll ⇒ Proc?
Returns the previous callback that was set, or nil if none existed.
538 539 |
# File 'lib/glfw/stubs/window.rb', line 538 def on_scroll end |
#request_attention ⇒ self
Requests user attention to the window. On platforms where this is not supported, attention is requested to the application as a whole. Once the user has given attention, usually by focusing the window or application, the system will end the request automatically.
238 239 |
# File 'lib/glfw/stubs/window.rb', line 238 def request_attention end |
#restore ⇒ self
Restores the window if it was previously minimized or maximized. If the window is already restored, this function does nothing. If the window is fullscreen, the resolution chosen for the window is restored on the selected monitor.
230 231 |
# File 'lib/glfw/stubs/window.rb', line 230 def restore end |
#show ⇒ self
Makes the window visible if it was previously hidden. If the window is already visible or is in full screen mode, this method does nothing.
185 186 |
# File 'lib/glfw/stubs/window.rb', line 185 def show end |
#size_limits(min, max) ⇒ void
This method returns an undefined value.
Sets the minimum and maximum sizes that a user can resize the window to.
119 120 |
# File 'lib/glfw/stubs/window.rb', line 119 def size_limits(min, max) end |
#swap_buffers ⇒ void
This method returns an undefined value.
Typically called each frame, swaps the front and back buffers used for rendering, presenting the current back buffer to the user, while staging the current front buffer to be overwritten.
176 177 |
# File 'lib/glfw/stubs/window.rb', line 176 def swap_buffers end |