-
-
Notifications
You must be signed in to change notification settings - Fork 679
/
Copy pathwrapper.odin
255 lines (218 loc) · 8.06 KB
/
wrapper.odin
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
package glfw
import "core:c"
import glfw "bindings"
Init :: glfw.Init
Terminate :: glfw.Terminate
InitHint :: glfw.InitHint
InitAllocator :: glfw.InitAllocator
InitVulkanLoader :: glfw.InitVulkanLoader
GetVersion :: proc "c" () -> (major, minor, rev: c.int) {
glfw.GetVersion(&major, &minor, &rev)
return
}
GetError :: proc "c" () -> (description: string, code: c.int) {
desc: cstring
code = glfw.GetError(&desc)
description = string(desc)
return
}
GetPrimaryMonitor :: glfw.GetPrimaryMonitor
GetMonitors :: proc "c" () -> []MonitorHandle {
count: c.int
monitors := glfw.GetMonitors(&count)
return monitors[:count]
}
GetMonitorPos :: proc "c" (monitor: MonitorHandle) -> (xpos, ypos: c.int) {
glfw.GetMonitorPos(monitor, &xpos, &ypos)
return
}
GetMonitorWorkarea :: proc "c" (monitor: MonitorHandle) -> (xpos, ypos, width, height: c.int) {
glfw.GetMonitorWorkarea(monitor, &xpos, &ypos, &width, &height)
return
}
GetMonitorPhysicalSize :: proc "c" (monitor: MonitorHandle) -> (widthMM, heightMM: c.int) {
glfw.GetMonitorPhysicalSize(monitor, &widthMM, &heightMM)
return
}
GetMonitorContentScale :: proc "c" (monitor: MonitorHandle) -> (xscale, yscale: f32) {
glfw.GetMonitorContentScale(monitor, &xscale, &yscale)
return
}
SetMonitorUserPointer :: glfw.SetMonitorUserPointer
GetMonitorUserPointer :: glfw.GetMonitorUserPointer
GetVideoMode :: glfw.GetVideoMode
SetGamma :: glfw.SetGamma
GetGammaRamp :: glfw.GetGammaRamp
SetGammaRamp :: glfw.SetGammaRamp
CreateWindow :: glfw.CreateWindow
DestroyWindow :: glfw.DestroyWindow
WindowHint_int :: proc "contextless" (hint: c.int, value: c.int) {
glfw.WindowHint(hint, value)
}
WindowHint_bool :: proc "contextless" (hint: c.int, value: b32) {
glfw.WindowHint(hint, cast(c.int) value)
}
WindowHint :: proc {
WindowHint_int,
WindowHint_bool,
}
DefaultWindowHints :: glfw.DefaultWindowHints
WindowHintString :: glfw.WindowHintString
WindowShouldClose :: glfw.WindowShouldClose
SwapInterval :: glfw.SwapInterval
SwapBuffers :: glfw.SwapBuffers
SetWindowTitle :: glfw.SetWindowTitle
SetWindowIcon :: proc "c" (window: WindowHandle, images: []Image) {
glfw.SetWindowIcon(window, c.int(len(images)), raw_data(images))
}
SetWindowPos :: glfw.SetWindowPos
SetWindowSizeLimits :: glfw.SetWindowSizeLimits
SetWindowAspectRatio :: glfw.SetWindowAspectRatio
SetWindowSize :: glfw.SetWindowSize
GetWindowPos :: proc "c" (window: WindowHandle) -> (xpos, ypos: c.int) {
glfw.GetWindowPos(window, &xpos, &ypos)
return
}
GetWindowSize :: proc "c" (window: WindowHandle) -> (width, height: c.int) {
glfw.GetWindowSize(window, &width, &height)
return
}
GetFramebufferSize :: proc "c" (window: WindowHandle) -> (width, height: c.int) {
glfw.GetFramebufferSize(window, &width, &height)
return
}
GetWindowFrameSize :: proc "c" (window: WindowHandle) -> (left, top, right, bottom: c.int) {
glfw.GetWindowFrameSize(window, &left, &top, &right, &bottom)
return
}
GetWindowContentScale :: proc "c" (window: WindowHandle) -> (xscale, yscale: f32) {
glfw.GetWindowContentScale(window, &xscale, &yscale)
return
}
GetWindowOpacity :: glfw.GetWindowOpacity
SetWindowOpacity :: glfw.SetWindowOpacity
GetVersionString :: proc "c" () -> string {
return string(glfw.GetVersionString())
}
GetMonitorName :: proc "c" (monitor: MonitorHandle) -> string {
return string(glfw.GetMonitorName(monitor))
}
GetClipboardString :: proc "c" (window: WindowHandle) -> string {
return string(glfw.GetClipboardString(window))
}
GetVideoModes :: proc "c" (monitor: MonitorHandle) -> []VidMode {
count: c.int
modes := glfw.GetVideoModes(monitor, &count)
return modes[:count]
}
GetKey :: glfw.GetKey
GetKeyName :: proc "c" (key, scancode: c.int) -> string {
return string(glfw.GetKeyName(key, scancode))
}
SetWindowShouldClose :: glfw.SetWindowShouldClose
GetWindowTitle :: glfw.GetWindowTitle
JoystickPresent :: glfw.JoystickPresent
GetJoystickName :: proc "c" (joy: c.int) -> string {
return string(glfw.GetJoystickName(joy))
}
GetKeyScancode :: glfw.GetKeyScancode
IconifyWindow :: glfw.IconifyWindow
RestoreWindow :: glfw.RestoreWindow
MaximizeWindow :: glfw.MaximizeWindow
ShowWindow :: glfw.ShowWindow
HideWindow :: glfw.HideWindow
FocusWindow :: glfw.FocusWindow
RequestWindowAttention :: glfw.RequestWindowAttention
GetWindowMonitor :: glfw.GetWindowMonitor
SetWindowMonitor :: glfw.SetWindowMonitor
GetWindowAttrib :: glfw.GetWindowAttrib
SetWindowUserPointer :: glfw.SetWindowUserPointer
GetWindowUserPointer :: glfw.GetWindowUserPointer
SetWindowAttrib :: glfw.SetWindowAttrib
PollEvents :: glfw.PollEvents
WaitEvents :: glfw.WaitEvents
WaitEventsTimeout :: glfw.WaitEventsTimeout
PostEmptyEvent :: glfw.PostEmptyEvent
RawMouseMotionSupported :: glfw.RawMouseMotionSupported
GetInputMode :: glfw.GetInputMode
SetInputMode :: glfw.SetInputMode
GetMouseButton :: glfw.GetMouseButton
GetCursorPos :: proc "c" (window: WindowHandle) -> (xpos, ypos: f64) {
glfw.GetCursorPos(window, &xpos, &ypos)
return
}
SetCursorPos :: glfw.SetCursorPos
CreateCursor :: glfw.CreateCursor
DestroyCursor :: glfw.DestroyCursor
SetCursor :: glfw.SetCursor
CreateStandardCursor :: glfw.CreateStandardCursor
GetJoystickAxes :: proc "c" (joy: c.int) -> []f32 {
count: c.int
axes := glfw.GetJoystickAxes(joy, &count)
return axes[:count]
}
GetJoystickButtons :: proc "c" (joy: c.int) -> []u8 {
count: c.int
buttons := glfw.GetJoystickButtons(joy, &count)
return buttons[:count]
}
GetJoystickHats :: proc "c" (jid: c.int) -> []u8 {
count: c.int
hats := glfw.GetJoystickHats(jid, &count)
return hats[:count]
}
GetJoystickGUID :: proc "c" (jid: c.int) -> string {
return string(glfw.GetJoystickGUID(jid))
}
SetJoystickUserPointer :: glfw.SetJoystickUserPointer
GetJoystickUserPointer :: glfw.GetJoystickUserPointer
JoystickIsGamepad :: glfw.JoystickIsGamepad
UpdateGamepadMappings :: glfw.UpdateGamepadMappings
GetGamepadName :: proc "c" (jid: c.int) -> string {
return string(glfw.GetGamepadName(jid))
}
GetGamepadState :: glfw.GetGamepadState
SetClipboardString :: glfw.SetClipboardString
SetTime :: glfw.SetTime
GetTime :: glfw.GetTime
GetTimerValue :: glfw.GetTimerValue
GetTimerFrequency :: glfw.GetTimerFrequency
MakeContextCurrent :: glfw.MakeContextCurrent
GetCurrentContext :: glfw.GetCurrentContext
GetProcAddress :: glfw.GetProcAddress
ExtensionSupported :: glfw.ExtensionSupported
VulkanSupported :: glfw.VulkanSupported
GetRequiredInstanceExtensions :: proc "c" () -> []cstring {
count: u32
exts := glfw.GetRequiredInstanceExtensions(&count)
return exts[:count]
}
GetInstanceProcAddress :: glfw.GetInstanceProcAddress
GetPhysicalDevicePresentationSupport :: glfw.GetPhysicalDevicePresentationSupport
CreateWindowSurface :: glfw.CreateWindowSurface
SetWindowIconifyCallback :: glfw.SetWindowIconifyCallback
SetWindowRefreshCallback :: glfw.SetWindowRefreshCallback
SetWindowFocusCallback :: glfw.SetWindowFocusCallback
SetWindowCloseCallback :: glfw.SetWindowCloseCallback
SetWindowSizeCallback :: glfw.SetWindowSizeCallback
SetWindowPosCallback :: glfw.SetWindowPosCallback
SetFramebufferSizeCallback :: glfw.SetFramebufferSizeCallback
SetDropCallback :: glfw.SetDropCallback
SetMonitorCallback :: glfw.SetMonitorCallback
SetWindowMaximizeCallback :: glfw.SetWindowMaximizeCallback
SetWindowContentScaleCallback :: glfw.SetWindowContentScaleCallback
SetKeyCallback :: glfw.SetKeyCallback
SetMouseButtonCallback :: glfw.SetMouseButtonCallback
SetCursorPosCallback :: glfw.SetCursorPosCallback
SetScrollCallback :: glfw.SetScrollCallback
SetCharCallback :: glfw.SetCharCallback
SetCharModsCallback :: glfw.SetCharModsCallback
SetCursorEnterCallback :: glfw.SetCursorEnterCallback
SetJoystickCallback :: glfw.SetJoystickCallback
SetErrorCallback :: glfw.SetErrorCallback
GetPlatform :: glfw.GetPlatform
PlatformSupported :: glfw.PlatformSupported
// Used by vendor:OpenGL
gl_set_proc_address :: proc(p: rawptr, name: cstring) {
(^rawptr)(p)^ = GetProcAddress(name)
}