-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.li
50 lines (40 loc) · 1.55 KB
/
test.li
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
import sys
import "cmake-build-debug/GL" as GL
# define `future` functions
future fn glutKeyboardFunc(Byte, Integer, Integer) { ... }
future fn glutDisplayFunc { ... }
future fn glutMouseFunc(Integer, Integer, Integer, Integer) { ... }
future fn glutMotionFunc(Integer, Integer) { ... }
future fn glutPassiveMotionFunc(Integer, Integer) { ... }
# init window
GL.glutInit("Test OpenGL application in loli")
GL.glutInitDisplayMode(GL.GLUT_RGBA | GL.GLUT_SINGLE)
GL.glutInitWindowSize(400, 400)
GL.glutInitWindowPosition(200, 200)
# create window
GL.glutCreateWindow("LoliGL Version: " ++ GL.loliGlVersion)
# bind functions
GL.glutDisplayFunc(glutDisplayFunc)
GL.glutKeyboardFunc(glutKeyboardFunc)
GL.glutMouseFunc(glutMouseFunc)
GL.glutMotionFunc(glutMotionFunc)
GL.glutPassiveMotionFunc(glutPassiveMotionFunc)
# main loop
GL.glutMainLoop()
fn glutKeyboardFunc(key: Byte, arg1: Integer, arg2: Integer) {
if (key == 27t): { sys.exit(0) } # on `Esc` press ...
}
fn glutDisplayFunc {
GL.glEnable(GL.GL_STENCIL_TEST)
GL.example() # TODO: delete
GL.glFlush()
}
fn glutMouseFunc(button: Integer, state: Integer, x: Integer, y: Integer) {
GL.glutSetWindowTitle("glutMouseFunc, button: " ++ button ++ ", state: " ++ state ++ ", x: " ++ x ++ ", y: " ++ y)
}
fn glutMotionFunc(x: Integer, y: Integer) {
GL.glutSetWindowTitle("glutMotionFunc, x: " ++ x ++ ", y: " ++ y)
}
fn glutPassiveMotionFunc(x: Integer, y: Integer) {
GL.glutSetWindowTitle("glutPassiveMotionFunc, x: " ++ x ++ ", y: " ++ y)
}