Created
May 2, 2012 09:46
-
-
Save omegatakuma/2575599 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/bin/gosh | |
(use gl) | |
(use gl.glut) | |
(define (draw_cube) | |
(let1 vert '#( | |
(1.0 1.0 1.0) | |
(-1.0 1.0 1.0) | |
(-1.0 -1.0 1.0) | |
(1.0 -1.0 1.0) | |
(1.0 1.0 -1.0) | |
(-1.0 1.0 -1.0) | |
(-1.0 -1.0 -1.0) | |
(1.0 -1.0 -1.0)) | |
(gl-begin GL_QUADS) | |
(apply gl-vertex (ref vert 0)) | |
(apply gl-vertex (ref vert 1)) | |
(apply gl-vertex (ref vert 2)) | |
(apply gl-vertex (ref vert 3)) | |
(apply gl-vertex (ref vert 4)) | |
(apply gl-vertex (ref vert 5)) | |
(apply gl-vertex (ref vert 6)) | |
(apply gl-vertex (ref vert 7)) | |
(apply gl-vertex (ref vert 0)) | |
(apply gl-vertex (ref vert 1)) | |
(apply gl-vertex (ref vert 5)) | |
(apply gl-vertex (ref vert 4)) | |
(apply gl-vertex (ref vert 2)) | |
(apply gl-vertex (ref vert 3)) | |
(apply gl-vertex (ref vert 7)) | |
(apply gl-vertex (ref vert 6)) | |
(apply gl-vertex (ref vert 3)) | |
(apply gl-vertex (ref vert 0)) | |
(apply gl-vertex (ref vert 4)) | |
(apply gl-vertex (ref vert 7)) | |
(apply gl-vertex (ref vert 1)) | |
(apply gl-vertex (ref vert 2)) | |
(apply gl-vertex (ref vert 6)) | |
(apply gl-vertex (ref vert 5)) | |
(gl-end))) | |
(define (display_func) | |
(let1 color '#( | |
(1.0 0.0 0.0 0.0) | |
(0.0 1.0 0.0 0.0)) | |
(gl-clear (logior GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT)) | |
(gl-push-matrix) | |
(gl-translate 0.0 0.0 -15.0) | |
(gl-rotate 30 0.0 1.0 0.0) | |
(apply gl-color (ref color 0)) | |
(draw_cube) | |
(gl-pop-matrix) | |
(gl-push-matrix) | |
(gl-rotate 10 0.0 1.0 0.0) | |
(gl-translate 0.0 0.0 -20.0) | |
(apply gl-color (ref color 1)) | |
(draw_cube) | |
(gl-pop-matrix) | |
(glut-swap-buffers))) | |
(define (reshape_func width height) | |
(gl-viewport 0 0 width height) | |
(gl-matrix-mode GL_PROJECTION) | |
(gl-load-identity) | |
(gl-frustum -1.0 1.0 -1.0 1.0 3.0 10000.0) | |
(gl-matrix-mode GL_MODELVIEW)) | |
(define (main args) | |
(glut-init args) | |
(glut-init-display-mode (logior GLUT_RGB GLUT_DOUBLE GLUT_DEPTH)) | |
(glut-init-window-size 300 300) | |
(glut-create-window "sample") | |
(glut-display-func display_func) | |
(glut-reshape-func reshape_func) | |
(gl-enable GL_DEPTH_TEST) | |
(glut-main-loop)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment