X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=gacela_draw.lisp;h=40a6c4ccf0a5e7bbab41da7f4a01f587f000b267;hb=b56cc2e7d421a067fbdcd3a542908fe0617352b8;hp=5e93e77b18b55906213707ec73101c4817a60dc4;hpb=485e401435dd0c9d443299cb04b1576e0f15f43f;p=gacela.git diff --git a/gacela_draw.lisp b/gacela_draw.lisp index 5e93e77..40a6c4c 100644 --- a/gacela_draw.lisp +++ b/gacela_draw.lisp @@ -14,9 +14,20 @@ ;;; 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 () + (glDisable GL_DEPTH_TEST) + (setq mode '2d)) + + (defun 3d-mode () + (glEnable GL_DEPTH_TEST) + (setq mode '3d)) + + (defun 3d-mode? () + (eq mode '3d))) + (defun draw (&rest vertexes) (begin-draw (length vertexes)) (draw-vertexes vertexes) @@ -32,9 +43,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)) @@ -57,7 +72,7 @@ (multiple-value-bind (texture width height) (load-texture filename) (cond (texture - (lambda (&optional (f 0.0172)) + (lambda (&optional (f 1)) (draw-rectangle (* f width) (* f height) :texture texture)))))) (defun draw-quad (v1 v2 v3 v4 &key texture color)