From 1f2c96da23204570d6dd47158a35b353b82e33b3 Mon Sep 17 00:00:00 2001 From: D Herring Date: Mon, 17 Mar 2008 22:17:09 -0400 Subject: [PATCH] bitmask tweak and grid generator --- examples/color-selector.lisp | 4 ++-- examples/viewer.lisp | 31 +++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/examples/color-selector.lisp b/examples/color-selector.lisp index 1871cf5..489ae4f 100644 --- a/examples/color-selector.lisp +++ b/examples/color-selector.lisp @@ -59,8 +59,8 @@ (gl:viewport 0 0 width height) (gl:clear-color 0 0 0 0) - (gl:clear (+ gl:+color-buffer-bit+ - gl:+depth-buffer-bit+)) + (gl:clear (logior gl:+color-buffer-bit+ + gl:+depth-buffer-bit+)) (gl:matrix-mode gl:+projection+) (gl:load-identity) diff --git a/examples/viewer.lisp b/examples/viewer.lisp index 222b46d..cf10ab6 100644 --- a/examples/viewer.lisp +++ b/examples/viewer.lisp @@ -205,6 +205,37 @@ (,-phi 0 1) (,-phi 0 -1)))))) +(defun make-grid (rows cols) + "makes a triangle-strip with 1+r+2rc vertices; +fills (0 to rows, 0 to cols, 0)" + (let ((v (make-array (list (+ 1 rows (* 2 rows cols)) + 3) + :initial-element 0)) + (i 1) ; first vertex is (0, 0) + ) + (flet ((put (r c) + (setf (aref v i 0) r + (aref v i 1) c) + (incf i))) + (dotimes (row rows) + (if (= (mod row 2) 0) + (loop for col from 0 below cols + do (progn + (put (1+ row) col) + (put row (1+ col))) + finally (put (1+ row) cols)) + (loop for col from cols above 0 + do (progn + (put (1+ row) col) + (put row (1- col))) + finally (put (1+ row) 0))))) + (make-gl-object + :type :triangle-strip + :position v))) + +(defparameter *grid* (make-grid 4 5)) +(tricolor *grid*) + ;;;; The viewer (defparameter *view-rotx* 0) (defparameter *view-roty* 0) -- 2.11.4.GIT