[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
In order to make a runnable script, you need to use some windowing system interface. GLUT binding provides a simple way for it.
Here is a complete runnable Scheme script, ported from Example 1-2 in "OpenGL Programming Guide":
(use gl) (use gl.glut) (define (disp) (gl-clear GL_COLOR_BUFFER_BIT) (gl-color '#f32(1.0 1.0 1.0)) (gl-begin* GL_POLYGON (gl-vertex '#f32(0.25 0.25 0.0)) (gl-vertex '#f32(0.75 0.25 0.0)) (gl-vertex '#f32(0.75 0.75 0.0)) (gl-vertex '#f32(0.25 0.75 0.0)) ) (gl-flush) ) (define (init) (gl-clear-color 0.0 0.0 0.0 0.0) (gl-matrix-mode GL_PROJECTION) (gl-load-identity) (gl-ortho 0.0 1.0 0.0 1.0 -1.0 1.0) ) (define (keyboard key x y) (cond ((= key 27) (exit 0)) )) (define (main args) (glut-init args) (glut-init-display-mode (logior GLUT_SINGLE GLUT_RGB)) (glut-init-window-size 250 250) (glut-init-window-position 100 100) (glut-create-window "hello") (init) (glut-display-func disp) (glut-keyboard-func keyboard) (glut-main-loop) 0) |
The (use gl.glut)
form loads GLUT binding.
The name mapping is the same as GL's: mixed case names to
hyphenated names.
In order to handle various events, you can pass a closure
to glut-display-func
etc. In the keyboard and mouse
event callback, all arguments are integers.
There are more examples under the ‘examples/’ directory which uses GLUT.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] |
This document was generated by Shiro Kawai on June, 7 2008 using texi2html 1.78.