-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.lean
31 lines (21 loc) · 806 Bytes
/
Main.lean
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
@[extern "lean_glfwInit"]
opaque glfwInit : IO Bool
@[extern "lean_glfwTerminate"]
opaque glfwTerminate : IO Unit
opaque WindowP : NonemptyType
def Window := WindowP.type
@[extern "lean_glfwCreateWindow"]
opaque glfwCreateWindow (width : UInt32) (height : UInt32) (title : String) : IO Window
@[extern "lean_glfwWindowShouldClose"]
opaque glfwWindowShouldClose (win : Window) : IO Bool
@[extern "lean_glfwPollEvents"]
opaque glfwPollEvents : IO Unit
def main : IO Unit := do
unless (<- glfwInit) do
(<- IO.getStderr).putStrLn "Cannot initialize GLFW!!"
return -- TODO: how to exit with EXIT_FAILURE?
let win <- glfwCreateWindow 800 600 "My GLFW window's title"
while (not (<- glfwWindowShouldClose win)) do
glfwPollEvents
glfwTerminate
(<- IO.getStdout).putStrLn "Goodbye."