3 function resize_func(w
, h
)
8 glMatrixMode(gl
.PROJECTION
)
13 gluPerspective(45,ratio
,1,1000)
15 glMatrixMode(gl
.MODELVIEW
)
23 function display_func()
25 if quit
then return end
27 local cur_time
= glutGet(glut
.ELAPSED_TIME
)
28 local delta
= (cur_time
- previous_time
) / 1000
29 previous_time
= cur_time
31 glClear(gl
.COLOR_BUFFER_BIT
+ gl
.DEPTH_BUFFER_BIT
)
36 glRotate(angle
, 0, 1, 0)
37 glRotate(angle2
, 0, 0, 1)
39 -- glutWireSphere(0.75, 10, 10)
42 -- glutWireTeapot(0.75)
46 angle
= angle
+ 200 * delta
47 angle2
= angle2
+ 170 * delta
51 if math
.mod(frames
, 100) == 0 then
52 local fps
= frames
* 1000 / (glutGet(glut
.ELAPSED_TIME
) - start_time
);
53 print('fps: ' .. fps
.. ' time: ' .. glutGet(glut
.ELAPSED_TIME
) .. ' frames: ' .. frames
)
59 function keyboard_func(key
,x
,y
)
60 print('keyboard' .. key
)
61 if key
== 27 then glutDestroyWindow(window
) quit
= true end
64 glutInitWindowSize(600,600)
65 glutInitWindowPosition(0,0)
66 glutInitDisplayMode(glut
.RGB
+ glut
.DOUBLE
+ glut
.DEPTH
)
67 window
= glutCreateWindow("luabind, glut-bindings")
68 glutDisplayFunc(display_func
)
69 glutIdleFunc(display_func
)
70 glutKeyboardFunc(keyboard_func
)
71 glutReshapeFunc(resize_func
)
75 start_time
= glutGet(glut
.ELAPSED_TIME
)