add color effects.

This commit is contained in:
2015-04-16 19:28:15 -07:00
parent 63469535cb
commit d866c00cd9

View File

@@ -490,13 +490,24 @@ with the tiled map file at `path` and `unit` scale.
(let [^Batch batch (.getBatch renderer)] (let [^Batch batch (.getBatch renderer)]
(.setProjectionMatrix batch (.combined camera)) (.setProjectionMatrix batch (.combined camera))
(.begin batch) (.begin batch)
(doseq [{:keys [additive? opacity] :as entity} entities] (doseq [{:keys [additive? opacity colorize?] :as entity :or {opacity 1.0}} entities
:when (> opacity 0.0)]
(when additive? (when additive?
(.setBlendFunction ^Batch batch (gl :gl-src-alpha) (gl :gl-one))) (.setBlendFunction ^Batch batch (gl :gl-src-alpha) (gl :gl-one)))
(.setColor batch (color 1 1 1 (or opacity 1.0))) (if colorize?
(e/draw! entity screen batch) (do (.setBlendFunction ^Batch batch (gl :gl-dst-color) (gl :gl-one-minus-src-alpha))
(.setColor batch (color 1 1 1 1)) (.setColor batch (color 1 1 1 opacity))
(when additive? (e/draw! entity screen batch)
(.setColor batch (color 1 1 1 (* opacity 0.25)))
(.setBlendFunction ^Batch batch (gl :gl-src-alpha) (gl :gl-one))
(e/draw! entity screen batch))
(do (.setColor batch (color 1 1 1 opacity))
(e/draw! entity screen batch)
(.setColor batch (color 1 1 1 1))))
(when (or additive? colorize?)
(.setBlendFunction ^Batch batch (gl :gl-src-alpha) (gl :gl-one-minus-src-alpha)))) (.setBlendFunction ^Batch batch (gl :gl-src-alpha) (gl :gl-one-minus-src-alpha))))
(.end batch)) (.end batch))
entities) entities)