From 2e3dbff3cca34b0e66c70f95510c72fd2f683888 Mon Sep 17 00:00:00 2001 From: William Robinson Date: Sat, 15 Dec 2007 10:02:15 +0000 Subject: [PATCH] Added with-projection-matrix macro. --- lib/opengl-convenience.lisp | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/lib/opengl-convenience.lisp b/lib/opengl-convenience.lisp index 952947b..bd9571a 100644 --- a/lib/opengl-convenience.lisp +++ b/lib/opengl-convenience.lisp @@ -43,6 +43,28 @@ (unwind-protect (progn ,@forms) (gl:matrix-mode gl:+modelview+)))) +(defmacro with-projection-matrix ((&body projection-matrix-setup-forms) + &body forms) + "Temporarily change the projection matrix: +Saves the current projection matrix, +loads identity in the projection matrix, +runs projection-matrix-setup-forms in projection matrix-mode, +runs forms in modelview matrix-mode, +restores the saved projection-matrix +and leaves in modelview matrix-mode." + `(progn + (gl:matrix-mode gl:+projection+) + (gl:push-matrix) + (gl:load-identity) + (unwind-protect + (progn + ,@projection-matrix-setup-forms + (gl:matrix-mode gl:+modelview+) + ,@forms) + (gl:matrix-mode gl:+projection+) + (gl:pop-matrix) + (gl:matrix-mode gl:+modelview+)))) + ;; 1.1 Conveniences (defmacro with-push-client-attrib ((&rest attrib-bits) &body forms) @@ -318,7 +340,7 @@ For an example, please see examples/synchronized-shader.lisp." -(export '(with-new-list with-push-name with-begin with-push-attrib with-push-matrix with-setup-projection +(export '(with-new-list with-push-name with-begin with-push-attrib with-push-matrix with-setup-projection with-projection-matrix ;; 1.1 with-push-client-attrib ;; ARB_vertex_buffer_object -- 2.11.4.GIT