-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.lisp
56 lines (47 loc) · 1.58 KB
/
main.lisp
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
(in-package :cepl-start)
(defun-g simple-vert ((position :vec4))
(values position
(v! (x position) (y position))))
(defun-g time-frag ((posxy :vec2) &uniform (time :float))
(let* ((p (* (v! 1.6 1.0) posxy))
(ti (mod (* -15 time) 2pi-f))
(l (* 40 (length p)))
(a (+ (- (atan (x p) (y p)) l) ti))
(r (sin a))
(g (sin (+ a 2)))
(b (* 0.5 (sin (+ a 4)))))
(v4! r g b 1)))
(defpipeline-g time-pipe ()
(simple-vert :vec4)
(time-frag :vec2))
;; -------------------------------------------------------
(defvar *gpu-array* nil)
(defvar *vertex-stream* nil)
(defun now ()
"Float seconds."
(/ (get-internal-real-time)
(coerce internal-time-units-per-second 'single-float)))
(defun draw ()
(step-host)
(update-repl-link)
(clear)
(map-g #'time-pipe *vertex-stream* :time (now))
(swap))
(let ((running nil))
(init)
(defun run-loop ()
(setf *gpu-array*
(make-gpu-array (list (v! -1.0 -1.0 0.0 1.0)
(v! 1.0 -1.0 0.0 1.0)
(v! 1.0 1.0 0.0 1.0)
(v! 1.0 1.0 0.0 1.0)
(v! -1.0 1.0 0.0 1.0)
(v! -1.0 -1.0 0.0 1.0))
:element-type :vec4
:dimensions 6))
(setf *vertex-stream* (make-buffer-stream *gpu-array*))
(setf running t)
(loop :while (and running (not (shutting-down-p))) :do
(continuable (draw))))
(defun stop-loop () (setf running nil)))
(run-loop)