diff options
-rw-r--r-- | wheelwork.lisp | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/wheelwork.lisp b/wheelwork.lisp index c9ce939..ccb38cb 100644 --- a/wheelwork.lisp +++ b/wheelwork.lisp @@ -6,7 +6,7 @@ "current application") (defclass/std unit () - ((cached-model :a) + ((cached-model cached-projected-matrix :a) (container :with :a) (width height :with :std 1.0) (rotation x y :with :std 0.0) @@ -16,7 +16,8 @@ (newval class (unit unit) slot) (case (closer-mop:slot-definition-name slot) ((x y width height rotation ) - (setf (cached-model unit) nil)))) + (setf (cached-model unit) nil + (cached-projected-matrix unit) nil)))) (defclass/std container () ((units :with :a)) @@ -288,12 +289,12 @@ necessary." (sdl2:gl-swap-window (application-window app)) (sleep (frame-wait app))) - - - (defgeneric model-matrix (thing) (:documentation "Returns the model matrix")) +(defgeneric projected-matrix (thing) + (:documentation "Returns the raw array of the model matrix after it + has been prjected by the application's projecion matrix")) (defmethod model-matrix ((u unit)) (or (cached-model u) @@ -308,6 +309,12 @@ necessary." (mat:nmscale m (vec:vec (unit-width u) (unit-height u) 1.0)) m)))) +(defmethod projected-matrix ((thing unit)) + (or (cached-projected-matrix thing) + (setf (cached-projected-matrix thing) + (mat:marr (mat:m* (application-projection *application*) + (model-matrix thing)))))) + (defgeneric ensure-loaded (asset) (:documentation "Ensures that the asset is loaded into memory and ready for use. Returns the asset.")) @@ -594,7 +601,9 @@ give focus to whatever was clicked." (gl:program-uniform-matrix-4fv shader (gl:get-uniform-location shader "TRANSFORM") - (mat:marr (mat:m* (application-projection *application*) (model-matrix bitmap)))) + (projected-matrix bitmap) + ;(mat:marr (mat:m* (application-projection *application*) (model-matrix bitmap))) + ) (gl:bind-vertex-array vao) (gl:draw-arrays :triangles 0 6) (gl:bind-vertex-array 0))) |