X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=gacela_draw.lisp;h=d957cd77e5a51a15789fc65fa01d476bce8f7278;hb=140e9b0c96754bf60bcc3fa2bf12292e7787fe44;hp=7a6dca6e08e3c9782b1cd233b74418bbc266baec;hpb=b4bb1b1a7180f521bceb564003d906308f93b5b7;p=gacela.git diff --git a/gacela_draw.lisp b/gacela_draw.lisp index 7a6dca6..d957cd7 100644 --- a/gacela_draw.lisp +++ b/gacela_draw.lisp @@ -14,9 +14,18 @@ ;;; You should have received a copy of the GNU General Public License ;;; along with this program. If not, see . - (in-package :gacela) +(let ((mode '2d)) + (defun 2d-mode () + (setq mode '2d)) + + (defun 3d-mode () + (setq mode '3d)) + + (defun 3d-mode? () + (eq mode '3d))) + (defun draw (&rest vertexes) (begin-draw (length vertexes)) (draw-vertexes vertexes) @@ -32,9 +41,13 @@ (draw-vertexes (cdr vertexes))))) (defun draw-vertex (vertex &key texture-coord) - (cond ((consp (car vertex)) (apply #'glColor3f (car vertex)) (apply #'glVertex3f (cadr vertex))) + (cond ((consp (car vertex)) (draw-color (car vertex)) (apply #'simple-draw-vertex (cadr vertex))) (t (cond (texture-coord (apply #'glTexCoord2f texture-coord))) - (apply #'glVertex3f vertex)))) + (apply #'simple-draw-vertex vertex)))) + +(defun simple-draw-vertex (x y &optional (z 0)) + (cond ((3d-mode?) (glVertex3f x y z)) + (t (glVertex2f x y)))) (defun draw-color (color) (apply #'glColor3f color))