diff options
-rw-r--r-- | sly/render/sprite-batch.scm | 21 |
1 files changed, 5 insertions, 16 deletions
diff --git a/sly/render/sprite-batch.scm b/sly/render/sprite-batch.scm index 7caef67..1f591c2 100644 --- a/sly/render/sprite-batch.scm +++ b/sly/render/sprite-batch.scm @@ -56,7 +56,7 @@ (define-record-type <sprite-batch> (%make-sprite-batch texture size capacity index-buffer - position-buffer texture-buffer vao) + position-buffer texture-buffer mesh) sprite-batch? (texture sprite-batch-texture set-sprite-batch-texture!) (size sprite-batch-size set-sprite-batch-size!) @@ -64,25 +64,15 @@ (index-buffer sprite-batch-index-buffer) (position-buffer sprite-batch-position-buffer) (texture-buffer sprite-batch-texture-buffer) - (vao sprite-batch-vao)) - -;; TODO: Add guardian. + (mesh sprite-batch-mesh)) (define (make-sprite-batch capacity) "Make a sprite batch that can hold CAPACITY sprites." (let* ((index (make-streaming-vertex-buffer 'index (* capacity 6))) (pos (make-streaming-vertex-buffer 'vec3 (* capacity 4))) (tex (make-streaming-vertex-buffer 'vec2 (* capacity 4))) - (vao (generate-vertex-array))) - - ;; Build the vertex array for the buffer. - (glBindVertexArray vao) - (vertex-attrib-pointer vertex-position-location pos) - (vertex-attrib-pointer vertex-texture-location tex) - (apply-vertex-buffer index) - (glBindVertexArray 0) - - (%make-sprite-batch #f 0 capacity index pos tex vao))) + (mesh (make-mesh index pos tex))) + (%make-sprite-batch #f 0 capacity index pos tex mesh))) (define (same-texture? t1 t2) (define (maybe-parent-texture t) @@ -238,13 +228,12 @@ (unmap-vertex-buffer! (sprite-batch-position-buffer batch)) (unmap-vertex-buffer! (sprite-batch-texture-buffer batch)) - (glBindVertexArray (sprite-batch-vao batch)) + (set-graphics-mesh! context (sprite-batch-mesh batch)) (glDrawElements (begin-mode triangles) ;; 6 indices per sprite. (* (sprite-batch-size batch) 6) (data-type unsigned-int) %null-pointer) - (glBindVertexArray 0) (sprite-batch-reset! batch))))))))) |