;;; You should have received a copy of the GNU General Public License
;;; along with this program. If not, see <http://www.gnu.org/licenses/>.
-(in-package :gacela)
+
+(eval-when (compile load eval)
+ (when (not (find-package 'gacela)) (make-package 'gacela :nicknames '(gg) :use '(lisp)))
+ (in-package 'gacela :nicknames '(gg) :use '(lisp)))
+
(defmacro with-color (color &body code)
(cond (color
(defun translate (x y &optional (z 0))
(glTranslatef x y z))
-(defun rotate (xrot yrot zrot)
+(defun rotate (&rest rot)
+ (cond ((3d-mode?) (apply #'3d-rotate rot))
+ (t (apply #'2d-rotate rot))))
+
+(defun 3d-rotate (xrot yrot zrot)
(glRotatef xrot 1 0 0)
(glRotatef yrot 0 1 0)
(glRotatef zrot 0 0 1))
(defun 2d-rotate (rot)
- (rotate 0 0 rot))
\ No newline at end of file
+ (glRotatef rot 0 0 1))
+
+(defun to-origin ()
+ (glLoadIdentity)
+ (cond ((3d-mode?) (camera-look))))
+
+(let ((camera-eye '(0 0 0)) (camera-center '(0 0 -100)) (camera-up '(0 1 0)))
+ (defun set-camera (&key eye center up)
+ (cond (eye (setq camera-eye eye)))
+ (cond (center (setq camera-center center)))
+ (cond (up (setq camera-up up))))
+
+ (defun camera-look ()
+ (apply #'gluLookAt (concatenate 'list camera-eye camera-center camera-up))))