Module: GLFW

Defined in:
lib/glfw/stubs.rb,
lib/glfw/version.rb,
lib/glfw/constants.rb,
lib/glfw/stubs/image.rb,
lib/glfw/stubs/cursor.rb,
lib/glfw/stubs/window.rb,
lib/glfw/stubs/monitor.rb,
lib/glfw/stubs/joystick.rb,
lib/glfw/stubs/video_mode.rb,
lib/glfw/stubs/gamepad_state.rb

Defined Under Namespace

Modules: Joystick Classes: Cursor, GamepadState, Image, Monitor, Point, Size, Vec2, VideoMode, Window

Input States collapse

RELEASE =
0
PRESS =
1
REPEAT =
2

Printable Keys collapse

KEY_SPACE =
32
KEY_APOSTROPHE =
39
KEY_COMMA =
44
KEY_MINUS =
45
KEY_PERIOD =
46
KEY_SLASH =
47
KEY_0 =
48
KEY_1 =
49
KEY_2 =
50
KEY_3 =
51
KEY_4 =
52
KEY_5 =
53
KEY_6 =
54
KEY_7 =
55
KEY_8 =
56
KEY_9 =
57
KEY_SEMICOLON =
59
KEY_EQUAL =
61
KEY_A =
65
KEY_B =
66
KEY_C =
67
KEY_D =
68
KEY_E =
69
KEY_F =
70
KEY_G =
71
KEY_H =
72
KEY_I =
73
KEY_J =
74
KEY_K =
75
KEY_L =
76
KEY_M =
77
KEY_N =
78
KEY_O =
79
KEY_P =
80
KEY_Q =
81
KEY_R =
82
KEY_S =
83
KEY_T =
84
KEY_U =
85
KEY_V =
86
KEY_W =
87
KEY_X =
88
KEY_Y =
89
KEY_Z =
90
KEY_LEFT_BRACKET =
91
KEY_BACKSLASH =
92
KEY_RIGHT_BRACKET =
93
KEY_GRAVE_ACCENT =
96
KEY_WORLD_1 =
161
KEY_WORLD_2 =
162

Non-printable Keys collapse

KEY_UNKNOWN =

An unknown/invalid key

-1
KEY_ESCAPE =
256
KEY_ENTER =
257
KEY_TAB =
258
KEY_BACKSPACE =
259
KEY_INSERT =
260
KEY_DELETE =
261
KEY_RIGHT =
262
KEY_LEFT =
263
KEY_DOWN =
264
KEY_UP =
265
KEY_PAGE_UP =
266
KEY_PAGE_DOWN =
267
KEY_HOME =
268
KEY_END =
269
KEY_CAPS_LOCK =
280
KEY_SCROLL_LOCK =
281
KEY_NUM_LOCK =
282
KEY_PRINT_SCREEN =
283
KEY_PAUSE =
284
KEY_F1 =
290
KEY_F2 =
291
KEY_F3 =
292
KEY_F4 =
293
KEY_F5 =
294
KEY_F6 =
295
KEY_F7 =
296
KEY_F8 =
297
KEY_F9 =
298
KEY_F10 =
299
KEY_F11 =
300
KEY_F12 =
301
KEY_F13 =
302
KEY_F14 =
303
KEY_F15 =
304
KEY_F16 =
305
KEY_F17 =
306
KEY_F18 =
307
KEY_F19 =
308
KEY_F20 =
309
KEY_F21 =
310
KEY_F22 =
311
KEY_F23 =
312
KEY_F24 =
313
KEY_F25 =
314
KEY_KP_0 =
320
KEY_KP_1 =
321
KEY_KP_2 =
322
KEY_KP_3 =
323
KEY_KP_4 =
324
KEY_KP_5 =
325
KEY_KP_6 =
326
KEY_KP_7 =
327
KEY_KP_8 =
328
KEY_KP_9 =
329
KEY_KP_DECIMAL =
330
KEY_KP_DIVIDE =
331
KEY_KP_MULTIPLY =
332
KEY_KP_SUBTRACT =
333
KEY_KP_ADD =
334
KEY_KP_ENTER =
335
KEY_KP_EQUAL =
336
KEY_LEFT_SHIFT =
340
KEY_LEFT_CONTROL =
341
KEY_LEFT_ALT =
342
KEY_LEFT_SUPER =
343
KEY_RIGHT_SHIFT =
344
KEY_RIGHT_CONTROL =
345
KEY_RIGHT_ALT =
346
KEY_RIGHT_SUPER =
347
KEY_MENU =
348

Modifier Keys collapse

MOD_SHIFT =
0x0001
MOD_CONTROL =
0x0002
MOD_ALT =
0x0004
MOD_SUPER =
0x0008
MOD_CAPS_LOCK =
0x0010
MOD_NUM_LOCK =
0x0020

Joystick Hats collapse

HAT_CENTERED =
0
HAT_UP =
1
HAT_RIGHT =
2
HAT_DOWN =
4
HAT_LEFT =
8
HAT_RIGHT_UP =
HAT_RIGHT | HAT_UP
HAT_RIGHT_DOWN =
HAT_RIGHT | HAT_DOWN
HAT_LEFT_UP =
HAT_LEFT  | HAT_UP
HAT_LEFT_DOWN =
HAT_LEFT  | HAT_DOWN

Mouse Buttons collapse

MOUSE_BUTTON_1 =
0
MOUSE_BUTTON_2 =
1
MOUSE_BUTTON_3 =
2
MOUSE_BUTTON_4 =
3
MOUSE_BUTTON_5 =
4
MOUSE_BUTTON_6 =
5
MOUSE_BUTTON_7 =
6
MOUSE_BUTTON_8 =
7
MOUSE_BUTTON_LAST =
MOUSE_BUTTON_8
MOUSE_BUTTON_LEFT =
MOUSE_BUTTON_1
MOUSE_BUTTON_RIGHT =
MOUSE_BUTTON_2
MOUSE_BUTTON_MIDDLE =
MOUSE_BUTTON_3

Joystick Identifiers collapse

JOYSTICK_1 =
0
JOYSTICK_2 =
1
JOYSTICK_3 =
2
JOYSTICK_4 =
3
JOYSTICK_5 =
4
JOYSTICK_6 =
5
JOYSTICK_7 =
6
JOYSTICK_8 =
7
JOYSTICK_9 =
8
JOYSTICK_10 =
9
JOYSTICK_11 =
10
JOYSTICK_12 =
11
JOYSTICK_13 =
12
JOYSTICK_14 =
13
JOYSTICK_15 =
14
JOYSTICK_16 =
15

Error Codes collapse

ERR_NOT_INITIALIZED =
0x00010001
ERR_NO_CURRENT_CONTEXT =
0x00010002
ERR_INVALID_ENUM =
0x00010003
ERR_INVALID_VALUE =
0x00010004
ERR_OUT_OF_MEMORY =
0x00010005
ERR_API_UNAVAILABLE =
0x00010006
ERR_VERSION_UNAVAILABLE =
0x00010007
ERR_PLATFORM_ERROR =
0x00010008
ERR_FORMAT_UNAVAILABLE =
0x00010009
ERR_NO_WINDOW_CONTEXT =
0x0001000A

Window Hints collapse

HINT_RESIZABLE =
0x00020003
HINT_VISIBLE =
0x00020004
HINT_DECORATED =
0x00020005
HINT_AUTO_ICONIFY =
0x00020006
HINT_FLOATING =
0x00020007
HINT_MAXIMIZED =
0x00020008
HINT_CENTER_CURSOR =
0x00020009
HINT_TRANSPARENT_FRAMEBUFFER =
0x0002000A
HINT_FOCUS_ON_SHOW =
0x0002000C
HINT_SCALE_TO_MONITOR =
0x0002200C
HINT_RED_BITS =
0x00021001
HINT_GREEN_BITS =
0x00021002
HINT_BLUE_BITS =
0x00021003
HINT_ALPHA_BITS =
0x00021004
HINT_DEPTH_BITS =
0x00021005
HINT_STENCIL_BITS =
0x00021006
HINT_ACCUM_RED_BITS =
0x00021007
HINT_ACCUM_GREEN_BITS =
0x00021008
HINT_ACCUM_BLUE_BITS =
0x00021009
HINT_ACCUM_ALPHA_BITS =
0x0002100A
HINT_AUX_BUFFERS =
0x0002100B
HINT_SAMPLES =
0x0002100D
HINT_REFRESH_RATE =
0x0002100F
HINT_STEREO =
0x0002100C
HINT_SRGB_CAPABLE =
0x0002100E
HINT_DOUBLEBUFFER =
0x00021010
HINT_CLIENT_API =
0x00022001
HINT_CONTEXT_VERSION_MAJOR =
0x00022002
HINT_CONTEXT_VERSION_MINOR =
0x00022003
HINT_CONTEXT_REVISION =
0x00022004
HINT_CONTEXT_ROBUSTNESS =
0x00022005
HINT_CONTEXT_RELEASE_BEHAVIOR =
0x00022009
HINT_OPENGL_FORWARD_COMPAT =
0x00022006
HINT_OPENGL_DEBUG_CONTEXT =
0x00022007
HINT_OPENGL_PROFILE =
0x00022008
HINT_COCOA_RETINA_FRAMEBUFFER =
0x00023001
HINT_COCOA_FRAME_NAME =
0x00023002
HINT_COCOA_GRAPHICS_SWITCHING =
0x00023003
HINT_X11_CLASS_NAME =
0x00024001
HINT_X11_INSTANCE_NAME =
0x00024002
HINT_CONTEXT_NO_ERROR =
0x0002200A
HINT_CONTEXT_CREATION_API =
0x0002200B

Values for HINT_RELEASE_BEHAVIOR collapse

RELEASE_BEHAVIOR_ANY =
0
RELEASE_BEHAVIOR_FLUSH =
0x00035001
RELEASE_BEHAVIOR_NONE =
0x00035002

Values for HINT_CONTEXT_CREATION_API collapse

CONTEXT_API_NATIVE =
0x00036001
CONTEXT_API_EGL =
0x00036002
CONTEXT_API_OSMESA =
0x00036003

Values for HINT_CLIENT_API collapse

API_NONE =
0
API_OPENGL =
0x00030001
API_OPENGL_ES =
0x00030002

Values for HINT_OPENGL_PROFILE collapse

PROFILE_OPENGL_ANY =
0
PROFILE_OPENGL_CORE =
0x00032001
PROFILE_OPENGL_COMPAT =
0x00032002

Value for HINT_CONTEXT_ROBUSTNESS collapse

ROBUSTNESS_NONE =
0
ROBUSTNESS_NO_RESET_NOTIFICATION =
0x00031001
ROBUSTNESS_LOSE_CONTEXT_ON_RESET =
0x00031002

Library initialization hints collapse

JOYSTICK_HAT_BUTTONS =
0x00050001
COCOA_CHDIR_RESOURCES =
0x00051001
COCOA_MENUBAR =
0x00051002

Constant Summary collapse

VERSION =

The GLFW gem version. As of 3.3.2, the major, minor, and revision components of the gem version match the version of GLFW that it is built against, while the build component is for gem versioning within that release.

'3.3.2.0'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.timeFloat

The current time measured by GLFW, in seconds. Unless the time has been set using glfwSetTime it measures time elapsed since GLFW was initialized.

The resolution of the timer is system dependent, but is usually on the order of a few micro- or nanoseconds. It uses the highest-resolution monotonic time source on each supported platform.

Returns:

  • (Float)

    the current GLFW time, in seconds.



171
172
173
# File 'lib/glfw/stubs.rb', line 171

def time
  @time
end

.timer_frequencyInteger (readonly)

Returns the frequency, in Hz, of the raw timer.

Returns:

  • (Integer)

    the frequency, in Hz, of the raw timer.



161
162
163
# File 'lib/glfw/stubs.rb', line 161

def timer_frequency
  @timer_frequency
end

.timer_valueInteger (readonly)

Returns the current value of the raw timer, measured in 1 / {timer_frequency) seconds.

Returns:

  • (Integer)

    the current value of the raw timer, measured in 1 / {timer_frequency) seconds.



157
158
159
# File 'lib/glfw/stubs.rb', line 157

def timer_value
  @timer_value
end

.versionString (readonly)

Returns the version of the native GLFW library, in "MAJOR.MINOR.REVISION" format.

Returns:

  • (String)

    the version of the native GLFW library, in "MAJOR.MINOR.REVISION" format.



149
150
151
# File 'lib/glfw/stubs.rb', line 149

def version
  @version
end

.version_strString (readonly)

Returns a version string, including information such as driver version, etc.

Returns:

  • (String)

    a version string, including information such as driver version, etc.



153
154
155
# File 'lib/glfw/stubs.rb', line 153

def version_str
  @version_str
end

Class Method Details

.event_timeout(timeout) ⇒ void

This method returns an undefined value.

Puts the calling thread to sleep until at least one event is available in the event queue, or until the specified timeout is reached. If one or more events are available, it behaves exactly like poll_events.

Parameters:

  • timeout (Float)

    The maximum amount of time, in seconds, to wait.



100
101
# File 'lib/glfw/stubs.rb', line 100

def event_timeout(timeout)
end

.import(name, args, return_type) ⇒ Fiddle::Function

Convenience method for importing OpenGL functions using Fiddle (standard library since Ruby 1.9)

Parameters:

  • name (String)

    The name of an OpenGL function.

  • args (Array<Integer>)

    An array describing the argument prototypes, same as when creating a Fiddle::Function.

  • return_type (Integer)

    A value describing the argument prototypes, same as when creating a Fiddle::Function.

Returns:

  • (Fiddle::Function)

See Also:



121
122
# File 'lib/glfw/stubs.rb', line 121

def import(name, args, return_type)
end

.initBoolean .init(&block) ⇒ void

Initializes the GLFW library. This method must be called before attempting to use any other feature, or after a call to terminate was made.

Overloads:

  • .initBoolean
    Note:

    Calling this method while library is already initialized is a no-op and returns true immediately.

    When called without a block, returns a value indicating if library initialized successfully.

    Returns:

    • (Boolean)

      true if library initialized successfully, otherwise false.

  • .init(&block) ⇒ void

    This method returns an undefined value.

    When called with a block, yields and automatically calls terminate when the block exits.

See Also:



28
29
# File 'lib/glfw/stubs.rb', line 28

def init
end

.init_hint(hint, value) ⇒ void

This method returns an undefined value.

Sets hints that affect how the library behaves until termination.

Parameters:

  • hint (Integer)

    A value indicating the hint to change.

  • value (Integer, Boolean, String)

    The desired value to set for this hint.

See Also:



49
50
# File 'lib/glfw/stubs.rb', line 49

def init_hint(hint, value)
end

.key_name(key, scancode = 0) ⇒ String?

Note:

When scancode is specified, the key argument is ignored.

Returns the name of the specified printable key, encoded as UTF-8. This is typically the character that key would produce without any modifier keys, intended for displaying key bindings to the user. For dead keys, it is typically the diacritic it would add to a character.

Parameters:

  • key (Integer)

    The key to query.

  • scancode (Integer) (defaults to: 0)

    The scancode of the key to query.

Returns:

  • (String?)

    The UTF-8 encoded, layout-specific name of the key, or nil.



135
136
# File 'lib/glfw/stubs.rb', line 135

def key_name(key, scancode = 0)
end

.poll_eventsvoid

This method returns an undefined value.

Processes only those events that are already in the event queue and then returns immediately. Processing events will cause the window and input callbacks associated with those events to be called.



78
79
# File 'lib/glfw/stubs.rb', line 78

def poll_events
end

.post_empty_eventvoid

This method returns an undefined value.

Posts an empty event from the current thread to the event queue, causing wait_vents or events_timeout to return.



91
92
# File 'lib/glfw/stubs.rb', line 91

def post_empty_event
end

.proc_address(name) ⇒ Fiddle::Pointer

Returns a function pointer for the specified OpenGL function, as a Fiddle::Pointer.

Parameters:

  • name (String)

    The name of an OpenGL function.

Returns:

  • (Fiddle::Pointer)

    a function pointer.



109
110
# File 'lib/glfw/stubs.rb', line 109

def proc_address(name)
end

.scancode(key) ⇒ Integer

returns the platform-specific scancode of the specified key.

Parameters:

  • key (Integer)

    The key to query.

Returns:

  • (Integer)

    the platform-specific scancode for the key, or -1 if an error occurred.



144
145
# File 'lib/glfw/stubs.rb', line 144

def scancode(key)
end

.supported?(extension_name) ⇒ Boolean

Returns whether the specified API extension is supported by the current OpenGL or OpenGL ES context. It searches both for client API extension and context creation API extensions.

A context must be current on the calling thread.

Parameters:

  • extenion_name (String)

    The name of an extension to query.

Returns:

  • (Boolean)

    true if extension is supported, otherwise false.



60
61
# File 'lib/glfw/stubs.rb', line 60

def supported?(extension_name)
end

.swap_interval(interval) ⇒ void

This method returns an undefined value.

This function sets the swap interval for the current OpenGL or OpenGL ES context, i.e. the number of screen updates to wait from the time GLFW::Window#swap_buffers was called before swapping the buffers and returning. This is sometimes called vertical synchronization, vertical retrace synchronization or just vsync.

Parameters:

  • interval (Integer)

    The minimum number of screen updates to wait for until the buffers are swapped by GLFW::Window#swap_buffers



71
72
# File 'lib/glfw/stubs.rb', line 71

def swap_interval(interval)
end

.terminatevoid

This method returns an undefined value.

Destroys the all windows, their contexts, cursors, etc., restoring the library to an uninitialized state.

See Also:



36
37
# File 'lib/glfw/stubs.rb', line 36

def terminate
end

.wait_eventsvoid

This method returns an undefined value.

puts the calling thread to sleep until at least one event is available in the event queue. Once one or more events are available, it behaves exactly like poll_events.



85
86
# File 'lib/glfw/stubs.rb', line 85

def wait_events
end