Remove old unused files accidentally left around.
[luabind.git] / examples / glut / glut_bindings.lua
bloba412838256475786087ebb3951d609444309dd2b
1 quit = false
3 function resize_func(w, h)
4 local ratio = w / h
6 print('====== resize')
8 glMatrixMode(gl.PROJECTION)
9 glLoadIdentity()
11 glViewport(0,0,w,h)
13 gluPerspective(45,ratio,1,1000)
15 glMatrixMode(gl.MODELVIEW)
16 glLoadIdentity()
17 end
19 angle = 0
20 angle2 = 0
21 previous_time = 0
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)
33 glPushMatrix()
35 glTranslate(0,0,-5)
36 glRotate(angle, 0, 1, 0)
37 glRotate(angle2, 0, 0, 1)
38 glColor3(1,0,0)
39 -- glutWireSphere(0.75, 10, 10)
40 glutSolidTeapot(0.75)
41 -- glColor3(1,1,1)
42 -- glutWireTeapot(0.75)
44 glPopMatrix()
46 angle = angle + 200 * delta
47 angle2 = angle2 + 170 * delta
49 frames = frames + 1
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)
54 end
56 glutSwapBuffers()
57 end
59 function keyboard_func(key,x,y)
60 print('keyboard' .. key)
61 if key == 27 then glutDestroyWindow(window) quit = true end
62 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)
73 resize_func(600,600)
75 start_time = glutGet(glut.ELAPSED_TIME)
76 frames = 0
78 glutMainLoop()