Skip to content

Instantly share code, notes, and snippets.

@robertpfeiffer
Created June 4, 2009 20:15
Show Gist options
  • Save robertpfeiffer/123818 to your computer and use it in GitHub Desktop.
Save robertpfeiffer/123818 to your computer and use it in GitHub Desktop.
(define *gl* (gl:make-opengl))
(gl:open-opengl *gl* '(600 600 640 480))
(define init
(lambda ()
(gl:clear-color *gl* 0.0 0.0 0.0 0.0)
(gl:enable *gl* *gl:depth-test*)))
(define view
(lambda ()
(gl:viewport *gl* 0 0 640 480)
(gl:matrix-mode *gl* *gl:projection*)
(gl:load-identity *gl*)
(glu:perspective *gl* 40.0 (/ 640 480) 1.0 10.0)
(gl:enable *gl* *gl:lighting*)
(gl:enable *gl* *gl:light0*)
(gl:enable *gl* *gl:color-material*)
(gl:matrix-mode *gl* *gl:modelview*)))
(define (rot-cube angle)
(gl:translate *gl* 0.5 0.5 0)
(gl:rotate *gl* angle 0 0 1.0)
(gl:translate *gl* 0.5 0.5 0)
(glut:solid-cube *gl* 1.0))
(define draw
(lambda (angle)
(gl:clear *gl* (io:binary-or *gl:depth-buffer-bit* *gl:color-buffer-bit*))
(gl:load-identity *gl*)
;(glu:look-at *gl* 0 0 5 0 0 0 0 1 0)
(gl:translate *gl* 0 0 -7)
(gl:color *gl* 0.5 0.0 0.0)
(gl:rotate *gl* 50 1.0 1.0 1.0)
(glut:solid-cube *gl* 1.0)
(dotimes (i 4)
(gl:rotate *gl* (* i 90) 0 0 1.0)
(gl:push-matrix *gl*)
(gl:color *gl* 0.5 0.5 0.0)
(rot-cube (- (/ angle 2) 90))
(gl:color *gl* 0.0 0.5 0.0)
(rot-cube (- 90 (/ angle 2)))
(gl:pop-matrix *gl*))
(gl:flush *gl*)
(callback (+ (now) 500) 'draw (fmod (+ angle 5) 360))))
(init)
(view)
(draw 0)
(define draw 'nil)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment