~jl2/blend2d-surface

afd7fe6dbad6c5d3b85e74a5233136a844a87a4f — Jeremiah LaRocco 1 year, 10 months ago 85e331b
Update to use geometry and vertex-buffers method.
1 files changed, 15 insertions(+), 14 deletions(-)

M blend2d-surface.lisp
M blend2d-surface.lisp => blend2d-surface.lisp +15 -14
@@ 20,20 20,8 @@
(defparameter *shader-dir* (asdf:system-relative-pathname :blend2d-surface "shaders/")
  "Directory containing newgl shaders.")

(defclass blend2d-surface (newgl:vertex-object)
  ((newgl:vertices :initform (make-array
                              (* 4 (+ 3 2))
                              :element-type 'single-float
                              :initial-contents '(-1.0f0 1.0f0 0.0f0  0.0f0 1.0f0
                                                  -1.0f0  -1.0f0 0.0f0  0.0f0 0.0f0
                                                   1.0f0  1.0f0 0.0f0  1.0f0 1.0f0
                                                   1.0f0 -1.0f0 0.0f0  1.0f0 0.0f0
                                                  )))
   (newgl:indices :initform (make-array
                       6
                       :element-type 'fixnum
                       :initial-contents '(0 1 2 1 3 2)))
   (newgl:primitive-type :initform :triangles)
(defclass blend2d-surface (newgl:geometry)
  ((newgl:primitive-type :initform :triangles)
   (newgl:shader-program :initform (newgl:make-shader-program
                                    (newgl:shader-from-file (merge-pathnames *shader-dir* "bls-vertex.glsl"))
                                    (newgl:shader-from-file (merge-pathnames *shader-dir* "bls-fragment.glsl"))))


@@ 42,6 30,19 @@
  (:documentation "Base class for all objects that can be rendered in a scene."))


(defmethod newgl:vertex-buffers ((object blend2d-surface))
  (values (make-array
           (* 4 (+ 3 2))
           :element-type 'single-float
           :initial-contents '(-1.0f0 1.0f0 0.0f0  0.0f0 1.0f0
                               -1.0f0  -1.0f0 0.0f0  0.0f0 0.0f0
                               1.0f0  1.0f0 0.0f0  1.0f0 1.0f0
                               1.0f0 -1.0f0 0.0f0  1.0f0 0.0f0))
          (make-array
                       6
                       :element-type 'fixnum
                       :initial-contents '(0 1 2 1 3 2))))

(defgeneric draw-image (obj img ctx size))

(defmethod draw-image ((obj blend2d-surface) img ctx size)