Skip to content

Commit

Permalink
Allow extracting texture spec
Browse files Browse the repository at this point in the history
  • Loading branch information
Shinmera committed Mar 23, 2019
1 parent b919944 commit b617810
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion resources/texture.lisp
Expand Up @@ -45,6 +45,15 @@
(define-unbound-reader texture border-color (vec 0 0 0 0))
(define-unbound-reader texture storage :dynamic)

(defun texture-texspec (texture)
(loop for slot in '(width height depth target levels samples internal-format
pixel-format pixel-type pixel-data
mag-filter min-filter mipmap-levels mipmap-lod
anisotropy wrapping border-color storage)
when (slot-boundp texture slot)
collect (intern (string slot) "KEYWORD")
and collect (slot-value texture slot)))

(defmethod shared-initialize :around ((texture texture) slots &rest args)
(when (getf args :wrapping)
(setf (getf args :wrapping) (enlist (getf args :wrapping)
Expand Down Expand Up @@ -195,10 +204,10 @@
(defmethod resize ((texture texture) width height)
(when (or (/= width (width texture))
(/= height (height texture)))
(assert (eql :dynamic (storage texture)))
(setf (width texture) width)
(setf (height texture) height)
(when (allocated-p texture)
(assert (eql :dynamic (storage texture)))
(gl:bind-texture (target texture) (gl-name texture))
(allocate-texture-storage texture)
(when (find (min-filter texture) '(:linear-mipmap-linear :linear-mipmap-nearest
Expand Down

0 comments on commit b617810

Please sign in to comment.