Skip to content

Commit

Permalink
Fix remaining uses of shader-subject where shader-entity should be us…
Browse files Browse the repository at this point in the history
…ed instead.
  • Loading branch information
Shinmera committed Aug 17, 2017
1 parent 70af691 commit 75aa660
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 13 deletions.
2 changes: 2 additions & 0 deletions assets/texture.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@
(gl:bind-texture target texture)
(images-to-textures target images)
(unless (eql target :texture-2d-multisample)
;; FIXME: generating mipmaps for depth-stencil textures is apparently not
;; allowed on all drivers.
(when (find min-filter '(:linear-mipmap-linear :linear-mipmap-nearest
:nearest-mipmap-linear :nearest-mipmap-nearest))
(gl:generate-mipmap target))
Expand Down
2 changes: 1 addition & 1 deletion scene-buffer.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
(register (render-pass buffer) buffer)
(pack buffer))

(defmethod enter :after ((subject shader-subject) (buffer scene-buffer))
(defmethod enter :after ((subject shader-entity) (buffer scene-buffer))
(register-object-for-pass buffer subject))

(defmethod paint ((pass shader-pass) (buffer scene-buffer))
Expand Down
2 changes: 1 addition & 1 deletion selection-buffer.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ void main(){
color = selection_color;
}")

(define-shader-subject selectable ()
(define-shader-entity selectable ()
((selection-color :initarg :selection-color :initform (find-new-selection-color) :accessor selection-color)))

(defun find-new-selection-color ()
Expand Down
18 changes: 9 additions & 9 deletions shader-pass.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
;; Pass changed, recompile everything
(loop for class being the hash-keys of assets
do (refresh class)))
((and (typep subject-class 'shader-subject-class)
((and (typep subject-class 'shader-entity-class)
(not (typep subject-class 'shader-pass-class)))
;; Object changed, recompile it
(refresh subject-class))))))
Expand All @@ -122,7 +122,7 @@
(loop for v being the hash-values of (assets pass)
do (load v)))

(defmethod shader-program-for-pass ((pass per-object-pass) (subject shader-subject))
(defmethod shader-program-for-pass ((pass per-object-pass) (subject shader-entity))
(gethash (class-of subject) (assets pass)))

(defmethod coerce-pass-shader ((pass per-object-pass) class type spec)
Expand All @@ -132,22 +132,22 @@
(defmethod determine-effective-shader-class ((name symbol))
(determine-effective-shader-class (find-class name)))

(defmethod determine-effective-shader-class ((object shader-subject))
(defmethod determine-effective-shader-class ((object shader-entity))
(determine-effective-shader-class (class-of object)))

(defmethod determine-effective-shader-class ((class standard-class))
NIL)

(defmethod determine-effective-shader-class ((class shader-subject-class))
(defmethod determine-effective-shader-class ((class shader-entity-class))
(if (direct-shaders class)
class
(let* ((effective-superclasses (list (find-class 'shader-subject))))
(let* ((effective-superclasses (list (find-class 'shader-entity))))
;; Loop through superclasses and push new, effective superclasses.
(loop for superclass in (c2mop:class-direct-superclasses class)
for effective-class = (determine-effective-shader-class superclass)
do (when (and effective-class (not (find effective-class effective-superclasses)))
(push effective-class effective-superclasses)))
;; If we have one or two --one always being the shader-subject class--
;; If we have one or two --one always being the shader-entity class--
;; then we just return the more specific of the two, as there's no class
;; combination happening that would produce new shaders.
(if (<= (length effective-superclasses) 2)
Expand All @@ -160,7 +160,7 @@
(for:for ((object over container))
(register-object-for-pass pass object)))

(defmethod register-object-for-pass ((pass per-object-pass) (class shader-subject-class))
(defmethod register-object-for-pass ((pass per-object-pass) (class shader-entity-class))
(let ((shaders ()))
(let ((effective-class (determine-effective-shader-class class)))
(unless (gethash effective-class (assets pass))
Expand All @@ -172,10 +172,10 @@
(make-asset 'shader-program shaders)))
(setf (gethash class (assets pass)) (gethash effective-class (assets pass))))))

(defmethod register-object-for-pass ((pass per-object-pass) (subject shader-subject))
(defmethod register-object-for-pass ((pass per-object-pass) (subject shader-entity))
(register-object-for-pass pass (class-of subject)))

(defmethod paint :around ((subject shader-subject) (pass per-object-pass))
(defmethod paint :around ((subject shader-entity) (pass per-object-pass))
(let ((program (shader-program-for-pass pass subject)))
(gl:use-program (resource program))
(prepare-pass-program pass program)
Expand Down
2 changes: 1 addition & 1 deletion shader-subject.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
(defclass shader-subject-class (subject-class shader-entity-class)
())

(defclass shader-subject (subject)
(defclass shader-subject (subject shader-entity)
()
(:metaclass shader-subject-class))

Expand Down
2 changes: 1 addition & 1 deletion skybox.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

(in-package #:org.shirakumo.fraf.trial)

(define-shader-subject skybox ()
(define-shader-entity skybox ()
((texture :initarg :texture :accessor texture)
(vertex-array :initform NIL :Accessor vertex-array))
(:default-initargs :texture (error "TEXTURE required.")))
Expand Down

0 comments on commit 75aa660

Please sign in to comment.