// Copyright (c) 2021 Dominic Masters
// 
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT

#pragma once
#include <dawn/dawn.h>
#include "primitive.h"
#include "primitives/quad.h"

/**
 * Creates a new Sprite Batch made of standard quads.
 *
 * @param batch Sprite batch to init.
 * @param maxSprites The maxiumum number of sprites the batch can hold.
 */
void spriteBatchInit(spritebatch_t *batch, int32_t maxSprites);

/**
 * Renders a sprite onto a given Sprite Batch.
 * 
 * @param spriteBatch The sprite batch to render to.
 * @param index The index within the sprite batch. Set to -1 to select "next".
 * @param x X coordinate of the sprite.
 * @param y Y coordinate of the sprite.
 * @param width Width of the sprite.
 * @param height Height of the sprite.
 * @param u0 Texture U coordinate (min).
 * @param v0 Texture V coordinate (min).
 * @param u1 Texture U coordinate (max).
 * @param v1 Texture V coordinate (max).
 */
void spriteBatchQuad(spritebatch_t *spriteBatch, int32_t index, 
  float x, float y, float z, float width, float height,
  float u0, float v0, float u1, float v1
);

/**
 * Flushes a sprite batch to reset the indexes.
 * @param spriteBatch The batch.
 */
void spriteBatchFlush(spritebatch_t *spriteBatch);

/**
 * Draws the Sprite Batch.
 * 
 * @param spriteBatch The sprite batch to render.
 * @param start Start index to render from.
 * @param count Count of sprites to render. Set to -1 to render to the current.
 */
void spriteBatchDraw(spritebatch_t *spriteBatch, int32_t start, int32_t count);

/**
 * Disposes a previously created Sprite Batch.
 * 
 * @param spriteBatch The sprite batch to dispose.
 */
void spriteBatchDispose(spritebatch_t *spriteBatch);