File: example3-2.scm

package info (click to toggle)
gauche-gl 0.6-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, forky, sid, trixie
  • size: 6,052 kB
  • sloc: ansic: 33,199; lisp: 13,740; sh: 2,484; makefile: 288
file content (68 lines) | stat: -rw-r--r-- 1,441 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
;; Example 3-2  Using Modeling transformations

(use gl)
(use gl.glut)

(define (init)
  (gl-clear-color 0.0 0.0 0.0 0.0)
  (gl-shade-model GL_FLAT)
  )

(define (draw-triangle)
  (gl-begin GL_LINE_LOOP)
  (gl-vertex '#f32(-20.0 -20.0))
  (gl-vertex '#f32(20.0 -20.0))
  (gl-vertex '#f32(0.0 14.6410161513775))
  (gl-end))

(define (disp)
  (gl-clear GL_COLOR_BUFFER_BIT)
  
  (gl-load-identity)
  (gl-color '#f32(1.0 1.0 1.0))
  (draw-triangle)

  (gl-enable GL_LINE_STIPPLE)
  (gl-line-stipple 1 #xf0f0)
  (gl-load-identity)
  (gl-translate -20.0 0.0 0.0)
  (draw-triangle)

  (gl-line-stipple 1 #xf00f)
  (gl-load-identity)
  (gl-scale 1.5 0.5 1.0)
  (draw-triangle)

  (gl-line-stipple 1 #x8888)
  (gl-load-identity)
  (gl-rotate 90.0 0.0 0.0 1.0)
  (draw-triangle)
  (gl-disable GL_LINE_STIPPLE)

  (gl-flush)
  )

(define (reshape w h)
  (gl-viewport 0 0 w h)
  (gl-matrix-mode GL_PROJECTION)
  (gl-load-identity)
  (gl-frustum -20.0 20.0 -20.0 20.0 1.5 20.0)
  (glu-look-at 0.0 0.0 5.0 0.0 0.0 0.0 0.0 1.0 0.0)
  (gl-matrix-mode GL_MODELVIEW)
  )

(define (keyboard key x y)
  (when (= key 27) (exit 0)))

(define (main args)
  (glut-init args)
  (glut-init-display-mode (logior GLUT_SINGLE GLUT_RGB))
  (glut-init-window-size 500 500)
  (glut-init-window-position 100 100)
  (glut-create-window *program-name*)
  (init)
  (glut-display-func disp)
  (glut-reshape-func reshape)
  (glut-keyboard-func keyboard)
  (glut-main-loop)
  0)