PageRenderTime 36ms CodeModel.GetById 30ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 1ms

/examples/opengl_101.scm

http://github.com/digego/extempore
Lisp | 33 lines | 24 code | 3 blank | 6 comment | 0 complexity | ac6e57dd108b2d627d44967067889730 MD5 | raw file
 1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 2;
 3; Simplest possible OpenGL example
 4;
 5
 6;; a trivial opengl draw loop
 7(definec my-gl-loop
 8  (let ((size 0.01))
 9    (lambda (degree)
10      (glClear (+ GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT))
11      (glLoadIdentity)
12      (glTranslated 0.0 -1.0 0.0)
13      (let ((i:double 0.0))
14	(dotimes (i 1000.0)
15	  (glTranslated (/ i 2000.0) 0.0 0.0)
16	  (glColor3d (/ i 1500.0) 0.0 1.0)
17	  (glRotated degree (/ i 200000.0) 0.5 0.0)
18	  (glBegin GL_QUADS)
19	  (glVertex2d 0.0 0.0)
20	  (glVertex2d size 0.0)
21	  (glVertex2d size size)
22	  (glVertex2d 0.0 size)       
23	  (glEnd))))))
24
25;; standard impromptu callback                                                
26(define opengl-test
27  (lambda (degree)
28    (my-gl-loop degree)
29    (gl:swap-buffers glctx)
30    (callback (+ (now) 500) 'opengl-test (+ degree .005))))
31
32(define glctx (gl:make-ctx ":0.0" #f 0.0 0.0 1024.0 768.0))
33(opengl-test 70.0)