File: example7-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 (63 lines) | stat: -rw-r--r-- 1,305 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
;; Example 7-2  Using a Display list

(use gl)
(use gl.glut)

(define *list-name* 0)

(define (init)
  (set! *list-name* (gl-gen-lists 1))
  (gl-new-list *list-name* GL_COMPILE)
  (gl-color 1.0 0.0 0.0)
  (gl-begin GL_TRIANGLES)
  (gl-vertex 0.0 0.0)
  (gl-vertex 1.0 0.0)
  (gl-vertex 0.0 1.0)
  (gl-end)
  (gl-translate 1.5 0.0 0.0)
  (gl-end-list)
  (gl-shade-model GL_FLAT)
  )

(define (draw-line)
  (gl-begin GL_LINES)
  (gl-vertex 0.0 0.5)
  (gl-vertex 15.0 0.5)
  (gl-end))

(define (disp)
  (gl-clear GL_COLOR_BUFFER_BIT)
  (gl-color 0.0 1.0 0.0)
  (dotimes (i 10) (gl-call-list *list-name*))
  (draw-line)
  (gl-flush)
  )

(define (reshape w h)
  (gl-viewport 0 0 w h)
  (gl-matrix-mode GL_PROJECTION)
  (gl-load-identity)
  (if (<= w h)
      (glu-ortho-2d 0.0 1.0 (* -0.5 (/ h w)) (* 1.5 (/ h w)))
      (glu-ortho-2d 0.0 (* 2.0 (/ w h)) -0.5 1.5))
  (gl-matrix-mode GL_MODELVIEW)
  (gl-load-identity)
  )

(define (keyboard key x y)
  (cond
   ((= key 27)                          ;ESC
    (exit 0)))
  )

(define (main args)
  (glut-init args)
  (glut-init-display-mode (logior GLUT_SINGLE GLUT_RGB))
  (glut-init-window-size 650 50)
  (glut-create-window (car args))
  (init)
  (glut-reshape-func reshape)
  (glut-keyboard-func keyboard)
  (glut-display-func disp)
  (glut-main-loop)
  0)