Skip to content
Permalink
Browse files

Allow specifying default color for lines

  • Loading branch information
Shinmera committed Dec 24, 2019
1 parent 9746c3d commit 7769204550a41367a89243926ba9cb71b7440a5e
Showing with 5 additions and 5 deletions.
  1. +3 −3 geometry-shapes.lisp
  2. +2 −2 lines.lisp
@@ -239,12 +239,12 @@
(defclass line-vertex (colored-vertex normal-vertex)
())

(defun make-lines (points &key mesh)
(defun make-lines (points &key mesh (default-color (vec 0 0 0 1)))
(with-vertex-filling ((or mesh (make-instance 'vertex-mesh :vertex-type 'line-vertex)))
(loop for (a b) on points by #'cddr
while b
do (destructuring-bind (a ac) (enlist a (vec 0 0 0 1))
(destructuring-bind (b bc) (enlist b (vec 0 0 0 1))
do (destructuring-bind (a ac) (enlist a default-color)
(destructuring-bind (b bc) (enlist b default-color)
(vertex :location a :normal (v- a b) :color ac)
(vertex :location b :normal (v- a b) :color bc)
(vertex :location a :normal (v- b a) :color ac)
@@ -14,8 +14,8 @@
(unless vertex-array
(setf (vertex-array lines) (change-class (make-lines ()) 'vertex-array :data-usage :dynamic-draw))))

(defmethod replace-vertex-data ((lines lines) points &key (update T))
(replace-vertex-data (vertex-array lines) (make-lines points) :update update))
(defmethod replace-vertex-data ((lines lines) points &key (update T) (default-color (vec 0 0 0 1)))
(replace-vertex-data (vertex-array lines) (make-lines points :default-color default-color) :update update))

(defmethod paint :before ((lines lines) (target shader-pass))
(let ((program (shader-program-for-pass target lines)))

0 comments on commit 7769204

Please sign in to comment.
You can’t perform that action at this time.