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

#pragma once
#include <dawn/dawn.h>

/**
 * Creates a new primitive.
 * @param primitive Primitive to initialize.
 * @param verticeCount How many vertices can the primitive hold.
 * @param indiceCount How many indices can the primitive hold.
 */
void primitiveInit(primitive_t *primitive, int32_t verticeCount, int32_t indiceCount);

/**
 * Buffer Vertices to a primitive for use in rendering.
 * @param primitive The primitive to buffer vertices into.
 * @param position The position (index) to overwrite the vertices of.
 * @param count The count of vertices to buffer.
 * @param vertices Array of vertices to buffer into the primitive.
 */
void primitiveBufferVertices(primitive_t *primitive,
  int32_t position, int32_t count, vertice_t *vertices
);

/**
 * Buffer Indices to a primitive for use in rendering.
 * @param primitive The primitive to buffer indices into.
 * @param position The position (index) to overwrite the indices of.
 * @param count The count of indices to buffer.
 * @param indices Array of indices to buffer into the primitive.
 */
void primitiveBufferIndices(primitive_t *primitive, 
  int32_t position, int32_t count, indice_t *indices
);

/**
 * Draw a primitive. Primitives are drawn by their indices.
 * @param primitive Primitive to draw.
 * @param start Start indice (index) to draw.
 * @param count Count of indices to draw. Use -1 to draw all.
 */
void primitiveDraw(primitive_t *primitive, int32_t start, int32_t count);

/**
 * Cleanup a previously initialized primitive.
 * @param primitive Primitive to cleanup.
 */
void primitiveDispose(primitive_t *primitive);