glfw-ruby 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE.txt +21 -0
- data/README.md +243 -0
- data/Rakefile +8 -0
- data/examples/01_minimal_window.rb +35 -0
- data/examples/02_input_callbacks.rb +56 -0
- data/examples/03_window_attributes.rb +116 -0
- data/examples/04_monitor_info.rb +52 -0
- data/examples/05_custom_cursor_and_icon.rb +93 -0
- data/examples/06_gamepad_inspector.rb +81 -0
- data/examples/07_glfw_34_features.rb +46 -0
- data/examples/example_runtime.rb +66 -0
- data/lib/glfw/api/constants.rb +403 -0
- data/lib/glfw/api/context.rb +11 -0
- data/lib/glfw/api/init.rb +13 -0
- data/lib/glfw/api/input.rb +46 -0
- data/lib/glfw/api/monitor.rb +21 -0
- data/lib/glfw/api/types.rb +96 -0
- data/lib/glfw/api/v34.rb +21 -0
- data/lib/glfw/api/vulkan.rb +11 -0
- data/lib/glfw/api/window.rb +53 -0
- data/lib/glfw/errors.rb +72 -0
- data/lib/glfw/high_level/cursor.rb +31 -0
- data/lib/glfw/high_level/gamepad.rb +43 -0
- data/lib/glfw/high_level/gamma_ramp.rb +32 -0
- data/lib/glfw/high_level/image.rb +27 -0
- data/lib/glfw/high_level/joystick.rb +69 -0
- data/lib/glfw/high_level/monitor.rb +104 -0
- data/lib/glfw/high_level/video_mode.rb +32 -0
- data/lib/glfw/high_level/window.rb +435 -0
- data/lib/glfw/loader.rb +48 -0
- data/lib/glfw/version.rb +5 -0
- data/lib/glfw.rb +143 -0
- metadata +91 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require_relative "example_runtime"
|
|
5
|
+
|
|
6
|
+
def connected_joysticks
|
|
7
|
+
(0..GLFW::GLFW_JOYSTICK_LAST).map { |jid| GLFW::Joystick[jid] }.select(&:present?)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def format_axis_values(values)
|
|
11
|
+
return "(none)" if values.empty?
|
|
12
|
+
|
|
13
|
+
values.map { |value| format("%+.2f", value) }.join(", ")
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def format_pressed_buttons(values)
|
|
17
|
+
pressed = values.each_index.select { |index| values[index] == GLFW::GLFW_PRESS }
|
|
18
|
+
pressed.empty? ? "(none)" : pressed.join(", ")
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def print_joystick_snapshot(joystick)
|
|
22
|
+
puts "[jid #{joystick.jid}] #{joystick.name || '(unnamed)'}"
|
|
23
|
+
puts " guid: #{joystick.guid || '(none)'}"
|
|
24
|
+
puts " axes: #{format_axis_values(joystick.axes)}"
|
|
25
|
+
puts " buttons: #{joystick.buttons.join(', ')}"
|
|
26
|
+
puts " hats: #{joystick.hats.join(', ')}"
|
|
27
|
+
|
|
28
|
+
return unless joystick.gamepad?
|
|
29
|
+
|
|
30
|
+
gamepad = joystick.gamepad
|
|
31
|
+
state = gamepad&.state
|
|
32
|
+
|
|
33
|
+
puts " gamepad_name: #{gamepad&.name || '(unnamed)'}"
|
|
34
|
+
|
|
35
|
+
if state
|
|
36
|
+
puts " pressed_buttons: #{format_pressed_buttons(state.buttons)}"
|
|
37
|
+
puts " gamepad_axes: #{format_axis_values(state.axes)}"
|
|
38
|
+
else
|
|
39
|
+
puts " gamepad_state: unavailable"
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
GLFWExample.with_glfw do
|
|
44
|
+
recent_events = []
|
|
45
|
+
|
|
46
|
+
GLFW::Joystick.on_connect do |joystick, event|
|
|
47
|
+
name = joystick.name || "(unnamed)"
|
|
48
|
+
recent_events << "[#{Time.now.strftime('%H:%M:%S')}] jid=#{joystick.jid} #{name} #{event}"
|
|
49
|
+
recent_events.shift while recent_events.size > 5
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
loop do
|
|
53
|
+
GLFW.poll_events
|
|
54
|
+
joysticks = connected_joysticks
|
|
55
|
+
|
|
56
|
+
GLFWExample.clear_screen
|
|
57
|
+
GLFWExample.print_banner("06 Gamepad Inspector", [
|
|
58
|
+
"Connect a joystick or gamepad to inspect its current state.",
|
|
59
|
+
"Ctrl+C: exit"
|
|
60
|
+
])
|
|
61
|
+
|
|
62
|
+
if joysticks.empty?
|
|
63
|
+
puts "No joysticks detected."
|
|
64
|
+
else
|
|
65
|
+
joysticks.each do |joystick|
|
|
66
|
+
print_joystick_snapshot(joystick)
|
|
67
|
+
puts
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
unless recent_events.empty?
|
|
72
|
+
puts "Recent hotplug events:"
|
|
73
|
+
recent_events.each { |event| puts " #{event}" }
|
|
74
|
+
puts
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
sleep 0.25
|
|
78
|
+
end
|
|
79
|
+
rescue Interrupt
|
|
80
|
+
puts "\nExiting gamepad inspector."
|
|
81
|
+
end
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require_relative "example_runtime"
|
|
5
|
+
|
|
6
|
+
PLATFORM_CONSTANTS = {
|
|
7
|
+
GLFW::GLFW_PLATFORM_WIN32 => :win32,
|
|
8
|
+
GLFW::GLFW_PLATFORM_COCOA => :cocoa,
|
|
9
|
+
GLFW::GLFW_PLATFORM_WAYLAND => :wayland,
|
|
10
|
+
GLFW::GLFW_PLATFORM_X11 => :x11,
|
|
11
|
+
GLFW::GLFW_PLATFORM_NULL => :null
|
|
12
|
+
}.freeze
|
|
13
|
+
|
|
14
|
+
GLFWExample.with_glfw do
|
|
15
|
+
runtime_version = GLFW.version.join(".")
|
|
16
|
+
|
|
17
|
+
GLFWExample.print_banner("07 GLFW 3.4 Features", [
|
|
18
|
+
"Loaded GLFW runtime: #{runtime_version}",
|
|
19
|
+
"Binding constants: #{GLFW::GLFW_VERSION_MAJOR}.#{GLFW::GLFW_VERSION_MINOR}.#{GLFW::GLFW_VERSION_REVISION}"
|
|
20
|
+
])
|
|
21
|
+
|
|
22
|
+
unless GLFW.version_at_least?(3, 4)
|
|
23
|
+
puts "This runtime does not export GLFW 3.4-only entry points."
|
|
24
|
+
puts "Try the example again with a GLFW 3.4 shared library."
|
|
25
|
+
next
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
puts "Current platform: #{GLFW.platform}"
|
|
29
|
+
puts
|
|
30
|
+
puts "platform_supported? matrix:"
|
|
31
|
+
|
|
32
|
+
PLATFORM_CONSTANTS.each do |constant, name|
|
|
33
|
+
puts " #{name}: #{GLFW.platform_supported?(constant)}"
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
puts
|
|
37
|
+
|
|
38
|
+
window = GLFW::Window.new(640, 240, "GLFW 3.4 Feature Check", visible: false)
|
|
39
|
+
|
|
40
|
+
begin
|
|
41
|
+
puts "High-level title: #{window.title.inspect}"
|
|
42
|
+
puts "Low-level glfwGetWindowTitle: #{GLFW::API.glfwGetWindowTitle(window.handle).inspect}"
|
|
43
|
+
ensure
|
|
44
|
+
window.destroy
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
$LOAD_PATH.unshift(File.expand_path("../lib", __dir__))
|
|
5
|
+
|
|
6
|
+
require "glfw"
|
|
7
|
+
|
|
8
|
+
module GLFWExample
|
|
9
|
+
module_function
|
|
10
|
+
|
|
11
|
+
def with_glfw
|
|
12
|
+
initialized = false
|
|
13
|
+
|
|
14
|
+
GLFW.on_error do |code, description|
|
|
15
|
+
warn "[GLFW #{code}] #{description}"
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
GLFW.init
|
|
19
|
+
initialized = true
|
|
20
|
+
yield
|
|
21
|
+
ensure
|
|
22
|
+
GLFW.terminate if initialized
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def with_window(title:, width: 800, height: 600, monitor: nil, share: nil, **hints)
|
|
26
|
+
window = nil
|
|
27
|
+
|
|
28
|
+
with_glfw do
|
|
29
|
+
window = GLFW::Window.new(width, height, title, monitor: monitor, share: share, **hints)
|
|
30
|
+
yield window
|
|
31
|
+
ensure
|
|
32
|
+
window&.destroy
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def loop_until_closed(window, fps: 60)
|
|
37
|
+
frame_duration = fps ? 1.0 / fps : nil
|
|
38
|
+
|
|
39
|
+
until window.should_close?
|
|
40
|
+
started_at = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
|
41
|
+
|
|
42
|
+
yield if block_given?
|
|
43
|
+
GLFW.poll_events
|
|
44
|
+
|
|
45
|
+
next unless frame_duration
|
|
46
|
+
|
|
47
|
+
elapsed = Process.clock_gettime(Process::CLOCK_MONOTONIC) - started_at
|
|
48
|
+
sleep(frame_duration - elapsed) if elapsed < frame_duration
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def print_banner(title, lines = [])
|
|
53
|
+
puts title
|
|
54
|
+
puts("=" * title.length)
|
|
55
|
+
Array(lines).each { |line| puts line }
|
|
56
|
+
puts
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def clear_screen
|
|
60
|
+
print "\e[H\e[2J"
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def format_video_mode(mode)
|
|
64
|
+
"#{mode.width}x#{mode.height}@#{mode.refresh_rate}Hz"
|
|
65
|
+
end
|
|
66
|
+
end
|
|
@@ -0,0 +1,403 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module GLFW
|
|
4
|
+
# Version macros
|
|
5
|
+
GLFW_VERSION_MAJOR = 3
|
|
6
|
+
GLFW_VERSION_MINOR = 4
|
|
7
|
+
GLFW_VERSION_REVISION = 0
|
|
8
|
+
|
|
9
|
+
# Boolean values
|
|
10
|
+
GLFW_TRUE = 1
|
|
11
|
+
GLFW_FALSE = 0
|
|
12
|
+
|
|
13
|
+
# Key actions
|
|
14
|
+
GLFW_RELEASE = 0
|
|
15
|
+
GLFW_PRESS = 1
|
|
16
|
+
GLFW_REPEAT = 2
|
|
17
|
+
|
|
18
|
+
# Hat states
|
|
19
|
+
GLFW_HAT_CENTERED = 0
|
|
20
|
+
GLFW_HAT_UP = 1
|
|
21
|
+
GLFW_HAT_RIGHT = 2
|
|
22
|
+
GLFW_HAT_DOWN = 4
|
|
23
|
+
GLFW_HAT_LEFT = 8
|
|
24
|
+
GLFW_HAT_RIGHT_UP = GLFW_HAT_RIGHT | GLFW_HAT_UP
|
|
25
|
+
GLFW_HAT_RIGHT_DOWN = GLFW_HAT_RIGHT | GLFW_HAT_DOWN
|
|
26
|
+
GLFW_HAT_LEFT_UP = GLFW_HAT_LEFT | GLFW_HAT_UP
|
|
27
|
+
GLFW_HAT_LEFT_DOWN = GLFW_HAT_LEFT | GLFW_HAT_DOWN
|
|
28
|
+
|
|
29
|
+
# Key codes
|
|
30
|
+
GLFW_KEY_UNKNOWN = -1
|
|
31
|
+
GLFW_KEY_SPACE = 32
|
|
32
|
+
GLFW_KEY_APOSTROPHE = 39
|
|
33
|
+
GLFW_KEY_COMMA = 44
|
|
34
|
+
GLFW_KEY_MINUS = 45
|
|
35
|
+
GLFW_KEY_PERIOD = 46
|
|
36
|
+
GLFW_KEY_SLASH = 47
|
|
37
|
+
GLFW_KEY_0 = 48
|
|
38
|
+
GLFW_KEY_1 = 49
|
|
39
|
+
GLFW_KEY_2 = 50
|
|
40
|
+
GLFW_KEY_3 = 51
|
|
41
|
+
GLFW_KEY_4 = 52
|
|
42
|
+
GLFW_KEY_5 = 53
|
|
43
|
+
GLFW_KEY_6 = 54
|
|
44
|
+
GLFW_KEY_7 = 55
|
|
45
|
+
GLFW_KEY_8 = 56
|
|
46
|
+
GLFW_KEY_9 = 57
|
|
47
|
+
GLFW_KEY_SEMICOLON = 59
|
|
48
|
+
GLFW_KEY_EQUAL = 61
|
|
49
|
+
GLFW_KEY_A = 65
|
|
50
|
+
GLFW_KEY_B = 66
|
|
51
|
+
GLFW_KEY_C = 67
|
|
52
|
+
GLFW_KEY_D = 68
|
|
53
|
+
GLFW_KEY_E = 69
|
|
54
|
+
GLFW_KEY_F = 70
|
|
55
|
+
GLFW_KEY_G = 71
|
|
56
|
+
GLFW_KEY_H = 72
|
|
57
|
+
GLFW_KEY_I = 73
|
|
58
|
+
GLFW_KEY_J = 74
|
|
59
|
+
GLFW_KEY_K = 75
|
|
60
|
+
GLFW_KEY_L = 76
|
|
61
|
+
GLFW_KEY_M = 77
|
|
62
|
+
GLFW_KEY_N = 78
|
|
63
|
+
GLFW_KEY_O = 79
|
|
64
|
+
GLFW_KEY_P = 80
|
|
65
|
+
GLFW_KEY_Q = 81
|
|
66
|
+
GLFW_KEY_R = 82
|
|
67
|
+
GLFW_KEY_S = 83
|
|
68
|
+
GLFW_KEY_T = 84
|
|
69
|
+
GLFW_KEY_U = 85
|
|
70
|
+
GLFW_KEY_V = 86
|
|
71
|
+
GLFW_KEY_W = 87
|
|
72
|
+
GLFW_KEY_X = 88
|
|
73
|
+
GLFW_KEY_Y = 89
|
|
74
|
+
GLFW_KEY_Z = 90
|
|
75
|
+
GLFW_KEY_LEFT_BRACKET = 91
|
|
76
|
+
GLFW_KEY_BACKSLASH = 92
|
|
77
|
+
GLFW_KEY_RIGHT_BRACKET = 93
|
|
78
|
+
GLFW_KEY_GRAVE_ACCENT = 96
|
|
79
|
+
GLFW_KEY_WORLD_1 = 161
|
|
80
|
+
GLFW_KEY_WORLD_2 = 162
|
|
81
|
+
|
|
82
|
+
# Function keys
|
|
83
|
+
GLFW_KEY_ESCAPE = 256
|
|
84
|
+
GLFW_KEY_ENTER = 257
|
|
85
|
+
GLFW_KEY_TAB = 258
|
|
86
|
+
GLFW_KEY_BACKSPACE = 259
|
|
87
|
+
GLFW_KEY_INSERT = 260
|
|
88
|
+
GLFW_KEY_DELETE = 261
|
|
89
|
+
GLFW_KEY_RIGHT = 262
|
|
90
|
+
GLFW_KEY_LEFT = 263
|
|
91
|
+
GLFW_KEY_DOWN = 264
|
|
92
|
+
GLFW_KEY_UP = 265
|
|
93
|
+
GLFW_KEY_PAGE_UP = 266
|
|
94
|
+
GLFW_KEY_PAGE_DOWN = 267
|
|
95
|
+
GLFW_KEY_HOME = 268
|
|
96
|
+
GLFW_KEY_END = 269
|
|
97
|
+
GLFW_KEY_CAPS_LOCK = 280
|
|
98
|
+
GLFW_KEY_SCROLL_LOCK = 281
|
|
99
|
+
GLFW_KEY_NUM_LOCK = 282
|
|
100
|
+
GLFW_KEY_PRINT_SCREEN = 283
|
|
101
|
+
GLFW_KEY_PAUSE = 284
|
|
102
|
+
GLFW_KEY_F1 = 290
|
|
103
|
+
GLFW_KEY_F2 = 291
|
|
104
|
+
GLFW_KEY_F3 = 292
|
|
105
|
+
GLFW_KEY_F4 = 293
|
|
106
|
+
GLFW_KEY_F5 = 294
|
|
107
|
+
GLFW_KEY_F6 = 295
|
|
108
|
+
GLFW_KEY_F7 = 296
|
|
109
|
+
GLFW_KEY_F8 = 297
|
|
110
|
+
GLFW_KEY_F9 = 298
|
|
111
|
+
GLFW_KEY_F10 = 299
|
|
112
|
+
GLFW_KEY_F11 = 300
|
|
113
|
+
GLFW_KEY_F12 = 301
|
|
114
|
+
GLFW_KEY_F13 = 302
|
|
115
|
+
GLFW_KEY_F14 = 303
|
|
116
|
+
GLFW_KEY_F15 = 304
|
|
117
|
+
GLFW_KEY_F16 = 305
|
|
118
|
+
GLFW_KEY_F17 = 306
|
|
119
|
+
GLFW_KEY_F18 = 307
|
|
120
|
+
GLFW_KEY_F19 = 308
|
|
121
|
+
GLFW_KEY_F20 = 309
|
|
122
|
+
GLFW_KEY_F21 = 310
|
|
123
|
+
GLFW_KEY_F22 = 311
|
|
124
|
+
GLFW_KEY_F23 = 312
|
|
125
|
+
GLFW_KEY_F24 = 313
|
|
126
|
+
GLFW_KEY_F25 = 314
|
|
127
|
+
GLFW_KEY_KP_0 = 320
|
|
128
|
+
GLFW_KEY_KP_1 = 321
|
|
129
|
+
GLFW_KEY_KP_2 = 322
|
|
130
|
+
GLFW_KEY_KP_3 = 323
|
|
131
|
+
GLFW_KEY_KP_4 = 324
|
|
132
|
+
GLFW_KEY_KP_5 = 325
|
|
133
|
+
GLFW_KEY_KP_6 = 326
|
|
134
|
+
GLFW_KEY_KP_7 = 327
|
|
135
|
+
GLFW_KEY_KP_8 = 328
|
|
136
|
+
GLFW_KEY_KP_9 = 329
|
|
137
|
+
GLFW_KEY_KP_DECIMAL = 330
|
|
138
|
+
GLFW_KEY_KP_DIVIDE = 331
|
|
139
|
+
GLFW_KEY_KP_MULTIPLY = 332
|
|
140
|
+
GLFW_KEY_KP_SUBTRACT = 333
|
|
141
|
+
GLFW_KEY_KP_ADD = 334
|
|
142
|
+
GLFW_KEY_KP_ENTER = 335
|
|
143
|
+
GLFW_KEY_KP_EQUAL = 336
|
|
144
|
+
GLFW_KEY_LEFT_SHIFT = 340
|
|
145
|
+
GLFW_KEY_LEFT_CONTROL = 341
|
|
146
|
+
GLFW_KEY_LEFT_ALT = 342
|
|
147
|
+
GLFW_KEY_LEFT_SUPER = 343
|
|
148
|
+
GLFW_KEY_RIGHT_SHIFT = 344
|
|
149
|
+
GLFW_KEY_RIGHT_CONTROL = 345
|
|
150
|
+
GLFW_KEY_RIGHT_ALT = 346
|
|
151
|
+
GLFW_KEY_RIGHT_SUPER = 347
|
|
152
|
+
GLFW_KEY_MENU = 348
|
|
153
|
+
GLFW_KEY_LAST = GLFW_KEY_MENU
|
|
154
|
+
|
|
155
|
+
# Modifier keys
|
|
156
|
+
GLFW_MOD_SHIFT = 0x0001
|
|
157
|
+
GLFW_MOD_CONTROL = 0x0002
|
|
158
|
+
GLFW_MOD_ALT = 0x0004
|
|
159
|
+
GLFW_MOD_SUPER = 0x0008
|
|
160
|
+
GLFW_MOD_CAPS_LOCK = 0x0010
|
|
161
|
+
GLFW_MOD_NUM_LOCK = 0x0020
|
|
162
|
+
|
|
163
|
+
# Mouse buttons
|
|
164
|
+
GLFW_MOUSE_BUTTON_1 = 0
|
|
165
|
+
GLFW_MOUSE_BUTTON_2 = 1
|
|
166
|
+
GLFW_MOUSE_BUTTON_3 = 2
|
|
167
|
+
GLFW_MOUSE_BUTTON_4 = 3
|
|
168
|
+
GLFW_MOUSE_BUTTON_5 = 4
|
|
169
|
+
GLFW_MOUSE_BUTTON_6 = 5
|
|
170
|
+
GLFW_MOUSE_BUTTON_7 = 6
|
|
171
|
+
GLFW_MOUSE_BUTTON_8 = 7
|
|
172
|
+
GLFW_MOUSE_BUTTON_LAST = GLFW_MOUSE_BUTTON_8
|
|
173
|
+
GLFW_MOUSE_BUTTON_LEFT = GLFW_MOUSE_BUTTON_1
|
|
174
|
+
GLFW_MOUSE_BUTTON_RIGHT = GLFW_MOUSE_BUTTON_2
|
|
175
|
+
GLFW_MOUSE_BUTTON_MIDDLE = GLFW_MOUSE_BUTTON_3
|
|
176
|
+
|
|
177
|
+
# Joysticks
|
|
178
|
+
GLFW_JOYSTICK_1 = 0
|
|
179
|
+
GLFW_JOYSTICK_2 = 1
|
|
180
|
+
GLFW_JOYSTICK_3 = 2
|
|
181
|
+
GLFW_JOYSTICK_4 = 3
|
|
182
|
+
GLFW_JOYSTICK_5 = 4
|
|
183
|
+
GLFW_JOYSTICK_6 = 5
|
|
184
|
+
GLFW_JOYSTICK_7 = 6
|
|
185
|
+
GLFW_JOYSTICK_8 = 7
|
|
186
|
+
GLFW_JOYSTICK_9 = 8
|
|
187
|
+
GLFW_JOYSTICK_10 = 9
|
|
188
|
+
GLFW_JOYSTICK_11 = 10
|
|
189
|
+
GLFW_JOYSTICK_12 = 11
|
|
190
|
+
GLFW_JOYSTICK_13 = 12
|
|
191
|
+
GLFW_JOYSTICK_14 = 13
|
|
192
|
+
GLFW_JOYSTICK_15 = 14
|
|
193
|
+
GLFW_JOYSTICK_16 = 15
|
|
194
|
+
GLFW_JOYSTICK_LAST = GLFW_JOYSTICK_16
|
|
195
|
+
|
|
196
|
+
# Gamepad buttons
|
|
197
|
+
GLFW_GAMEPAD_BUTTON_A = 0
|
|
198
|
+
GLFW_GAMEPAD_BUTTON_B = 1
|
|
199
|
+
GLFW_GAMEPAD_BUTTON_X = 2
|
|
200
|
+
GLFW_GAMEPAD_BUTTON_Y = 3
|
|
201
|
+
GLFW_GAMEPAD_BUTTON_LEFT_BUMPER = 4
|
|
202
|
+
GLFW_GAMEPAD_BUTTON_RIGHT_BUMPER = 5
|
|
203
|
+
GLFW_GAMEPAD_BUTTON_BACK = 6
|
|
204
|
+
GLFW_GAMEPAD_BUTTON_START = 7
|
|
205
|
+
GLFW_GAMEPAD_BUTTON_GUIDE = 8
|
|
206
|
+
GLFW_GAMEPAD_BUTTON_LEFT_THUMB = 9
|
|
207
|
+
GLFW_GAMEPAD_BUTTON_RIGHT_THUMB = 10
|
|
208
|
+
GLFW_GAMEPAD_BUTTON_DPAD_UP = 11
|
|
209
|
+
GLFW_GAMEPAD_BUTTON_DPAD_RIGHT = 12
|
|
210
|
+
GLFW_GAMEPAD_BUTTON_DPAD_DOWN = 13
|
|
211
|
+
GLFW_GAMEPAD_BUTTON_DPAD_LEFT = 14
|
|
212
|
+
GLFW_GAMEPAD_BUTTON_LAST = GLFW_GAMEPAD_BUTTON_DPAD_LEFT
|
|
213
|
+
GLFW_GAMEPAD_BUTTON_CROSS = GLFW_GAMEPAD_BUTTON_A
|
|
214
|
+
GLFW_GAMEPAD_BUTTON_CIRCLE = GLFW_GAMEPAD_BUTTON_B
|
|
215
|
+
GLFW_GAMEPAD_BUTTON_SQUARE = GLFW_GAMEPAD_BUTTON_X
|
|
216
|
+
GLFW_GAMEPAD_BUTTON_TRIANGLE = GLFW_GAMEPAD_BUTTON_Y
|
|
217
|
+
|
|
218
|
+
# Gamepad axes
|
|
219
|
+
GLFW_GAMEPAD_AXIS_LEFT_X = 0
|
|
220
|
+
GLFW_GAMEPAD_AXIS_LEFT_Y = 1
|
|
221
|
+
GLFW_GAMEPAD_AXIS_RIGHT_X = 2
|
|
222
|
+
GLFW_GAMEPAD_AXIS_RIGHT_Y = 3
|
|
223
|
+
GLFW_GAMEPAD_AXIS_LEFT_TRIGGER = 4
|
|
224
|
+
GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER = 5
|
|
225
|
+
GLFW_GAMEPAD_AXIS_LAST = GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER
|
|
226
|
+
|
|
227
|
+
# Error codes
|
|
228
|
+
GLFW_NO_ERROR = 0
|
|
229
|
+
GLFW_NOT_INITIALIZED = 0x00010001
|
|
230
|
+
GLFW_NO_CURRENT_CONTEXT = 0x00010002
|
|
231
|
+
GLFW_INVALID_ENUM = 0x00010003
|
|
232
|
+
GLFW_INVALID_VALUE = 0x00010004
|
|
233
|
+
GLFW_OUT_OF_MEMORY = 0x00010005
|
|
234
|
+
GLFW_API_UNAVAILABLE = 0x00010006
|
|
235
|
+
GLFW_VERSION_UNAVAILABLE = 0x00010007
|
|
236
|
+
GLFW_PLATFORM_ERROR = 0x00010008
|
|
237
|
+
GLFW_FORMAT_UNAVAILABLE = 0x00010009
|
|
238
|
+
GLFW_NO_WINDOW_CONTEXT = 0x0001000A
|
|
239
|
+
GLFW_CURSOR_UNAVAILABLE = 0x0001000B
|
|
240
|
+
GLFW_FEATURE_UNAVAILABLE = 0x0001000C
|
|
241
|
+
GLFW_FEATURE_UNIMPLEMENTED = 0x0001000D
|
|
242
|
+
GLFW_PLATFORM_UNAVAILABLE = 0x0001000E
|
|
243
|
+
|
|
244
|
+
# Window hints / attributes
|
|
245
|
+
GLFW_FOCUSED = 0x00020001
|
|
246
|
+
GLFW_ICONIFIED = 0x00020002
|
|
247
|
+
GLFW_RESIZABLE = 0x00020003
|
|
248
|
+
GLFW_VISIBLE = 0x00020004
|
|
249
|
+
GLFW_DECORATED = 0x00020005
|
|
250
|
+
GLFW_AUTO_ICONIFY = 0x00020006
|
|
251
|
+
GLFW_FLOATING = 0x00020007
|
|
252
|
+
GLFW_MAXIMIZED = 0x00020008
|
|
253
|
+
GLFW_CENTER_CURSOR = 0x00020009
|
|
254
|
+
GLFW_TRANSPARENT_FRAMEBUFFER = 0x0002000A
|
|
255
|
+
GLFW_HOVERED = 0x0002000B
|
|
256
|
+
GLFW_FOCUS_ON_SHOW = 0x0002000C
|
|
257
|
+
GLFW_MOUSE_PASSTHROUGH = 0x0002000D
|
|
258
|
+
GLFW_POSITION_X = 0x0002000E
|
|
259
|
+
GLFW_POSITION_Y = 0x0002000F
|
|
260
|
+
|
|
261
|
+
GLFW_RED_BITS = 0x00021001
|
|
262
|
+
GLFW_GREEN_BITS = 0x00021002
|
|
263
|
+
GLFW_BLUE_BITS = 0x00021003
|
|
264
|
+
GLFW_ALPHA_BITS = 0x00021004
|
|
265
|
+
GLFW_DEPTH_BITS = 0x00021005
|
|
266
|
+
GLFW_STENCIL_BITS = 0x00021006
|
|
267
|
+
GLFW_ACCUM_RED_BITS = 0x00021007
|
|
268
|
+
GLFW_ACCUM_GREEN_BITS = 0x00021008
|
|
269
|
+
GLFW_ACCUM_BLUE_BITS = 0x00021009
|
|
270
|
+
GLFW_ACCUM_ALPHA_BITS = 0x0002100A
|
|
271
|
+
GLFW_AUX_BUFFERS = 0x0002100B
|
|
272
|
+
GLFW_STEREO = 0x0002100C
|
|
273
|
+
GLFW_SAMPLES = 0x0002100D
|
|
274
|
+
GLFW_SRGB_CAPABLE = 0x0002100E
|
|
275
|
+
GLFW_REFRESH_RATE = 0x0002100F
|
|
276
|
+
GLFW_DOUBLEBUFFER = 0x00021010
|
|
277
|
+
|
|
278
|
+
GLFW_CLIENT_API = 0x00022001
|
|
279
|
+
GLFW_CONTEXT_VERSION_MAJOR = 0x00022002
|
|
280
|
+
GLFW_CONTEXT_VERSION_MINOR = 0x00022003
|
|
281
|
+
GLFW_CONTEXT_REVISION = 0x00022004
|
|
282
|
+
GLFW_CONTEXT_ROBUSTNESS = 0x00022005
|
|
283
|
+
GLFW_OPENGL_FORWARD_COMPAT = 0x00022006
|
|
284
|
+
GLFW_OPENGL_DEBUG_CONTEXT = 0x00022007
|
|
285
|
+
GLFW_CONTEXT_DEBUG = GLFW_OPENGL_DEBUG_CONTEXT
|
|
286
|
+
GLFW_OPENGL_PROFILE = 0x00022008
|
|
287
|
+
GLFW_CONTEXT_RELEASE_BEHAVIOR = 0x00022009
|
|
288
|
+
GLFW_CONTEXT_NO_ERROR = 0x0002200A
|
|
289
|
+
GLFW_CONTEXT_CREATION_API = 0x0002200B
|
|
290
|
+
GLFW_SCALE_TO_MONITOR = 0x0002200C
|
|
291
|
+
GLFW_SCALE_FRAMEBUFFER = 0x0002200D
|
|
292
|
+
GLFW_COCOA_RETINA_FRAMEBUFFER = 0x00023001
|
|
293
|
+
GLFW_COCOA_FRAME_NAME = 0x00023002
|
|
294
|
+
GLFW_COCOA_GRAPHICS_SWITCHING = 0x00023003
|
|
295
|
+
GLFW_X11_CLASS_NAME = 0x00024001
|
|
296
|
+
GLFW_X11_INSTANCE_NAME = 0x00024002
|
|
297
|
+
GLFW_WIN32_KEYBOARD_MENU = 0x00025001
|
|
298
|
+
GLFW_WIN32_SHOWDEFAULT = 0x00025002
|
|
299
|
+
GLFW_WAYLAND_APP_ID = 0x00026001
|
|
300
|
+
|
|
301
|
+
# Client API values
|
|
302
|
+
GLFW_NO_API = 0
|
|
303
|
+
GLFW_OPENGL_API = 0x00030001
|
|
304
|
+
GLFW_OPENGL_ES_API = 0x00030002
|
|
305
|
+
|
|
306
|
+
# Robustness
|
|
307
|
+
GLFW_NO_ROBUSTNESS = 0
|
|
308
|
+
GLFW_NO_RESET_NOTIFICATION = 0x00031001
|
|
309
|
+
GLFW_LOSE_CONTEXT_ON_RESET = 0x00031002
|
|
310
|
+
|
|
311
|
+
# OpenGL profile
|
|
312
|
+
GLFW_OPENGL_ANY_PROFILE = 0
|
|
313
|
+
GLFW_OPENGL_CORE_PROFILE = 0x00032001
|
|
314
|
+
GLFW_OPENGL_COMPAT_PROFILE = 0x00032002
|
|
315
|
+
|
|
316
|
+
# Cursor input mode
|
|
317
|
+
GLFW_CURSOR = 0x00033001
|
|
318
|
+
GLFW_STICKY_KEYS = 0x00033002
|
|
319
|
+
GLFW_STICKY_MOUSE_BUTTONS = 0x00033003
|
|
320
|
+
GLFW_LOCK_KEY_MODS = 0x00033004
|
|
321
|
+
GLFW_RAW_MOUSE_MOTION = 0x00033005
|
|
322
|
+
|
|
323
|
+
# Cursor modes
|
|
324
|
+
GLFW_CURSOR_NORMAL = 0x00034001
|
|
325
|
+
GLFW_CURSOR_HIDDEN = 0x00034002
|
|
326
|
+
GLFW_CURSOR_DISABLED = 0x00034003
|
|
327
|
+
GLFW_CURSOR_CAPTURED = 0x00034004
|
|
328
|
+
|
|
329
|
+
# Release behavior
|
|
330
|
+
GLFW_ANY_RELEASE_BEHAVIOR = 0
|
|
331
|
+
GLFW_RELEASE_BEHAVIOR_FLUSH = 0x00035001
|
|
332
|
+
GLFW_RELEASE_BEHAVIOR_NONE = 0x00035002
|
|
333
|
+
|
|
334
|
+
# Context creation API
|
|
335
|
+
GLFW_NATIVE_CONTEXT_API = 0x00036001
|
|
336
|
+
GLFW_EGL_CONTEXT_API = 0x00036002
|
|
337
|
+
GLFW_OSMESA_CONTEXT_API = 0x00036003
|
|
338
|
+
|
|
339
|
+
# ANGLE platform type
|
|
340
|
+
GLFW_ANGLE_PLATFORM_TYPE_NONE = 0x00037001
|
|
341
|
+
GLFW_ANGLE_PLATFORM_TYPE_OPENGL = 0x00037002
|
|
342
|
+
GLFW_ANGLE_PLATFORM_TYPE_OPENGLES = 0x00037003
|
|
343
|
+
GLFW_ANGLE_PLATFORM_TYPE_D3D9 = 0x00037004
|
|
344
|
+
GLFW_ANGLE_PLATFORM_TYPE_D3D11 = 0x00037005
|
|
345
|
+
GLFW_ANGLE_PLATFORM_TYPE_VULKAN = 0x00037007
|
|
346
|
+
GLFW_ANGLE_PLATFORM_TYPE_METAL = 0x00037008
|
|
347
|
+
|
|
348
|
+
# Wayland libdecor
|
|
349
|
+
GLFW_WAYLAND_PREFER_LIBDECOR = 0x00038001
|
|
350
|
+
GLFW_WAYLAND_DISABLE_LIBDECOR = 0x00038002
|
|
351
|
+
|
|
352
|
+
# Standard cursor shapes
|
|
353
|
+
GLFW_ARROW_CURSOR = 0x00036001
|
|
354
|
+
GLFW_IBEAM_CURSOR = 0x00036002
|
|
355
|
+
GLFW_CROSSHAIR_CURSOR = 0x00036003
|
|
356
|
+
GLFW_POINTING_HAND_CURSOR = 0x00036004
|
|
357
|
+
GLFW_RESIZE_EW_CURSOR = 0x00036005
|
|
358
|
+
GLFW_RESIZE_NS_CURSOR = 0x00036006
|
|
359
|
+
GLFW_RESIZE_NWSE_CURSOR = 0x00036007
|
|
360
|
+
GLFW_RESIZE_NESW_CURSOR = 0x00036008
|
|
361
|
+
GLFW_RESIZE_ALL_CURSOR = 0x00036009
|
|
362
|
+
GLFW_NOT_ALLOWED_CURSOR = 0x0003600A
|
|
363
|
+
GLFW_HRESIZE_CURSOR = GLFW_RESIZE_EW_CURSOR
|
|
364
|
+
GLFW_VRESIZE_CURSOR = GLFW_RESIZE_NS_CURSOR
|
|
365
|
+
GLFW_HAND_CURSOR = GLFW_POINTING_HAND_CURSOR
|
|
366
|
+
|
|
367
|
+
# Monitor events
|
|
368
|
+
GLFW_CONNECTED = 0x00040001
|
|
369
|
+
GLFW_DISCONNECTED = 0x00040002
|
|
370
|
+
|
|
371
|
+
# Init hints
|
|
372
|
+
GLFW_JOYSTICK_HAT_BUTTONS = 0x00050001
|
|
373
|
+
GLFW_ANGLE_PLATFORM_TYPE = 0x00050002
|
|
374
|
+
GLFW_ANGLE_PLATFORM_TYPE_HINT = GLFW_ANGLE_PLATFORM_TYPE
|
|
375
|
+
GLFW_PLATFORM = 0x00050003
|
|
376
|
+
GLFW_COCOA_CHDIR_RESOURCES = 0x00051001
|
|
377
|
+
GLFW_COCOA_MENUBAR = 0x00051002
|
|
378
|
+
GLFW_X11_XCB_VULKAN_SURFACE = 0x00052001
|
|
379
|
+
GLFW_WAYLAND_LIBDECOR = 0x00053001
|
|
380
|
+
|
|
381
|
+
# Platform types (3.4)
|
|
382
|
+
GLFW_ANY_PLATFORM = 0x00060000
|
|
383
|
+
GLFW_PLATFORM_WIN32 = 0x00060001
|
|
384
|
+
GLFW_PLATFORM_COCOA = 0x00060002
|
|
385
|
+
GLFW_PLATFORM_WAYLAND = 0x00060003
|
|
386
|
+
GLFW_PLATFORM_X11 = 0x00060004
|
|
387
|
+
GLFW_PLATFORM_NULL = 0x00060005
|
|
388
|
+
|
|
389
|
+
# Special value
|
|
390
|
+
GLFW_DONT_CARE = -1
|
|
391
|
+
GLFW_ANY_POSITION = 0x80000000
|
|
392
|
+
|
|
393
|
+
# Action/state symbols mapping
|
|
394
|
+
ACTION_MAP = { 0 => :release, 1 => :press, 2 => :repeat }.freeze
|
|
395
|
+
|
|
396
|
+
PLATFORM_MAP = {
|
|
397
|
+
GLFW_PLATFORM_WIN32 => :win32,
|
|
398
|
+
GLFW_PLATFORM_COCOA => :cocoa,
|
|
399
|
+
GLFW_PLATFORM_WAYLAND => :wayland,
|
|
400
|
+
GLFW_PLATFORM_X11 => :x11,
|
|
401
|
+
GLFW_PLATFORM_NULL => :null
|
|
402
|
+
}.freeze
|
|
403
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module GLFW
|
|
4
|
+
module API
|
|
5
|
+
attach_function :glfwMakeContextCurrent, [:GLFWwindow], :void
|
|
6
|
+
attach_function :glfwGetCurrentContext, [], :GLFWwindow
|
|
7
|
+
attach_function :glfwSwapInterval, [:int], :void
|
|
8
|
+
attach_function :glfwExtensionSupported, [:string], :int
|
|
9
|
+
attach_function :glfwGetProcAddress, [:string], :GLFWglproc
|
|
10
|
+
end
|
|
11
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module GLFW
|
|
4
|
+
module API
|
|
5
|
+
attach_function :glfwInit, [], :int
|
|
6
|
+
attach_function :glfwTerminate, [], :void
|
|
7
|
+
attach_function :glfwInitHint, [:int, :int], :void
|
|
8
|
+
attach_function :glfwGetVersion, [:pointer, :pointer, :pointer], :void
|
|
9
|
+
attach_function :glfwGetVersionString, [], :string
|
|
10
|
+
attach_function :glfwGetError, [:pointer], :int
|
|
11
|
+
attach_function :glfwSetErrorCallback, [:GLFWerrorfun], :pointer
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module GLFW
|
|
4
|
+
module API
|
|
5
|
+
attach_function :glfwGetInputMode, [:GLFWwindow, :int], :int
|
|
6
|
+
attach_function :glfwSetInputMode, [:GLFWwindow, :int, :int], :void
|
|
7
|
+
attach_function :glfwRawMouseMotionSupported, [], :int
|
|
8
|
+
attach_function :glfwGetKeyName, [:int, :int], :string
|
|
9
|
+
attach_function :glfwGetKeyScancode, [:int], :int
|
|
10
|
+
attach_function :glfwGetKey, [:GLFWwindow, :int], :int
|
|
11
|
+
attach_function :glfwGetMouseButton, [:GLFWwindow, :int], :int
|
|
12
|
+
attach_function :glfwGetCursorPos, [:GLFWwindow, :pointer, :pointer], :void
|
|
13
|
+
attach_function :glfwSetCursorPos, [:GLFWwindow, :double, :double], :void
|
|
14
|
+
attach_function :glfwCreateCursor, [:pointer, :int, :int], :GLFWcursor
|
|
15
|
+
attach_function :glfwCreateStandardCursor, [:int], :GLFWcursor
|
|
16
|
+
attach_function :glfwDestroyCursor, [:GLFWcursor], :void
|
|
17
|
+
attach_function :glfwSetCursor, [:GLFWwindow, :GLFWcursor], :void
|
|
18
|
+
attach_function :glfwSetKeyCallback, [:GLFWwindow, :GLFWkeyfun], :pointer
|
|
19
|
+
attach_function :glfwSetCharCallback, [:GLFWwindow, :GLFWcharfun], :pointer
|
|
20
|
+
attach_function :glfwSetCharModsCallback, [:GLFWwindow, :GLFWcharmodsfun], :pointer
|
|
21
|
+
attach_function :glfwSetMouseButtonCallback, [:GLFWwindow, :GLFWmousebuttonfun], :pointer
|
|
22
|
+
attach_function :glfwSetCursorPosCallback, [:GLFWwindow, :GLFWcursorposfun], :pointer
|
|
23
|
+
attach_function :glfwSetCursorEnterCallback, [:GLFWwindow, :GLFWcursorenterfun], :pointer
|
|
24
|
+
attach_function :glfwSetScrollCallback, [:GLFWwindow, :GLFWscrollfun], :pointer
|
|
25
|
+
attach_function :glfwSetDropCallback, [:GLFWwindow, :GLFWdropfun], :pointer
|
|
26
|
+
attach_function :glfwJoystickPresent, [:int], :int
|
|
27
|
+
attach_function :glfwGetJoystickAxes, [:int, :pointer], :pointer
|
|
28
|
+
attach_function :glfwGetJoystickButtons, [:int, :pointer], :pointer
|
|
29
|
+
attach_function :glfwGetJoystickHats, [:int, :pointer], :pointer
|
|
30
|
+
attach_function :glfwGetJoystickName, [:int], :string
|
|
31
|
+
attach_function :glfwGetJoystickGUID, [:int], :string
|
|
32
|
+
attach_function :glfwSetJoystickUserPointer, [:int, :pointer], :void
|
|
33
|
+
attach_function :glfwGetJoystickUserPointer, [:int], :pointer
|
|
34
|
+
attach_function :glfwJoystickIsGamepad, [:int], :int
|
|
35
|
+
attach_function :glfwUpdateGamepadMappings, [:string], :int
|
|
36
|
+
attach_function :glfwGetGamepadName, [:int], :string
|
|
37
|
+
attach_function :glfwGetGamepadState, [:int, :pointer], :int
|
|
38
|
+
attach_function :glfwSetClipboardString, [:GLFWwindow, :string], :void
|
|
39
|
+
attach_function :glfwGetClipboardString, [:GLFWwindow], :string
|
|
40
|
+
attach_function :glfwGetTime, [], :double
|
|
41
|
+
attach_function :glfwSetTime, [:double], :void
|
|
42
|
+
attach_function :glfwGetTimerValue, [], :uint64
|
|
43
|
+
attach_function :glfwGetTimerFrequency, [], :uint64
|
|
44
|
+
attach_function :glfwSetJoystickCallback, [:GLFWjoystickfun], :pointer
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module GLFW
|
|
4
|
+
module API
|
|
5
|
+
attach_function :glfwGetMonitors, [:pointer], :pointer
|
|
6
|
+
attach_function :glfwGetPrimaryMonitor, [], :GLFWmonitor
|
|
7
|
+
attach_function :glfwGetMonitorPos, [:GLFWmonitor, :pointer, :pointer], :void
|
|
8
|
+
attach_function :glfwGetMonitorWorkarea, [:GLFWmonitor, :pointer, :pointer, :pointer, :pointer], :void
|
|
9
|
+
attach_function :glfwGetMonitorPhysicalSize, [:GLFWmonitor, :pointer, :pointer], :void
|
|
10
|
+
attach_function :glfwGetMonitorContentScale, [:GLFWmonitor, :pointer, :pointer], :void
|
|
11
|
+
attach_function :glfwGetMonitorName, [:GLFWmonitor], :string
|
|
12
|
+
attach_function :glfwSetMonitorUserPointer, [:GLFWmonitor, :pointer], :void
|
|
13
|
+
attach_function :glfwGetMonitorUserPointer, [:GLFWmonitor], :pointer
|
|
14
|
+
attach_function :glfwSetMonitorCallback, [:GLFWmonitorfun], :pointer
|
|
15
|
+
attach_function :glfwGetVideoModes, [:GLFWmonitor, :pointer], :pointer
|
|
16
|
+
attach_function :glfwGetVideoMode, [:GLFWmonitor], :pointer
|
|
17
|
+
attach_function :glfwSetGamma, [:GLFWmonitor, :float], :void
|
|
18
|
+
attach_function :glfwGetGammaRamp, [:GLFWmonitor], :pointer
|
|
19
|
+
attach_function :glfwSetGammaRamp, [:GLFWmonitor, :pointer], :void
|
|
20
|
+
end
|
|
21
|
+
end
|