render: sprite: Rewrite sprite batching API.
authorDavid Thompson <dthompson2@worcester.edu>
Fri, 10 May 2019 12:34:53 +0000 (08:34 -0400)
committerDavid Thompson <dthompson2@worcester.edu>
Sun, 12 May 2019 15:38:43 +0000 (11:38 -0400)
commit34975b307a85cbb34b040b8a0c6a0f9104b4c331
tree26e27980c64491026eaa1d1d51af9c861d5f7102
parentdd1ccc8afc8ec0411ac636f542fd4bb8d4d242af
render: sprite: Rewrite sprite batching API.

This new version performs better and has a better API. It closely
resembles Love2D's sprite batch API.

* chickadee/render/sprite.scm (with-batched-sprites,
  sprite-batch-reset!, sprite-batch-begin!,
  draw-sprite-batched, *batch?*, %batch): Delete.
  (draw-sprite-unbatched): Rename to 'draw-sprite*'.
  (<sprite-batch>)[index-buffer, position-buffer, texture-buffer]:
  Delete fields.
  [vertex-buffer]: New field.
  (init-sprite-batch, double-sprite-batch-size!, sprite-batch-add!,
  sprite-batch-flush!): Rewrite.
  (make-sprite-batch): Add 'capacity' and 'blend-mode' arguments.
  (draw-sprite-batch): New procedure.
  (draw-nine-patch*): Stop using sprite batches for now.
* chickadee/render/font.scm: (<font>)[sprite-batches]: New field.
  (load-tile-font, load-font): Create a sprite batch for each texture
  loaded.
  (draw-text*): Use sprite batches.
* chickadee/render/tiled.scm: (<tile>)[batch]: New field.
  (<tileset>)[batch]: New field.
  (load-tile-map): Create a sprite batch for each tileset.
  (draw-tile-layer): Use new sprite batch API.
  (draw-tile-map*): Remove reference to deleted macro.
chickadee/render/font.scm
chickadee/render/sprite.scm
chickadee/render/tiled.scm
doc/api.texi
examples/sprite-batch.scm