;; this file: ;; https://dataswamp.org/~incal/common-lisp/general-base/polygon.lisp (defvar *poly*) (setq *poly* nil) (defun init-poly () (setq *poly* (gl:gen-lists 1)) (gl:new-list *poly* :compile) (gl:push-matrix) (draw-polygon-test) (gl:pop-matrix) (gl:end-list) ) (defun draw-poly () (unless *poly* (init-poly) ) (gl:call-list *poly*) ) (defun draw-polygon (ps &optional r g b) (gl:with-primitive :polygon (let ((rnd)) (if (and r g b) (gl:color r g b) (when (eq r 'random) (setf rnd t) )) (loop for (x y z) in ps do (when rnd (random-color)) (gl:vertex x y z) )))) (defun draw-polygon-test (&optional (vert 4)) (let ((poly)) (dotimes (_ vert) (push (random-xyz) poly) ) (draw-polygon poly 'random) ))