#pragma once
#include <stdbool.h>
#include <stdio.h>
#include <stdint.h>
#include <malloc.h>
#include <string.h>
#include "../display/shader.h"

/** Prefix of all asset load methods, may be customizable in future. */
#define ASSET_PREFIX "../assets/"

/**
 * Method to load an asset into memory as a raw string.
 * 
 * @param assetName Path leading to the asset within the root asset directory.
 * @return Pointer to char array of data from asset, NULL if unsuccesful.
 */
char * assetStringLoad(char *assetName);

/**
 * Platform-centric method to open a file buffer to an asset.
 * 
 * @param assetName The asset name to open a buffer for.
 * @return Pointer to a buffer, NULL if unsuccessfuil.
 */
FILE * assetBufferOpen(char *assetName);

/**
 * Closes a previously opened asset buffer.
 * 
 * @param buffer Buffer to close.
 * @return True if successful, otherwise false.
 */
bool assetBufferClose(FILE *buffer);

/**
 * Read bytes from buffer.
 * 
 * @param buffer The buffer pointing to an asset.
 * @param data Pointer to a ubyte array to buffer data into.
 * @param size Length of the data buffer. Represents how many bytes can be read.
 * @return The count of bytes read. Complete when less than data array size.
 */
int32_t assetBufferRead(FILE *buffer, char *data, int32_t size);

/**
 * Skip to the end of the buffer, useful to find the length of the buffer.
 * 
 * @param Buffer The buffer pointing to an asset.
 * @return How many bytes were skipped
 */
int32_t assetBufferEnd(FILE *buffer);

/**
 * Method to skip n bytes in the buffer
 * 
 * @param buffer The buffer pointing to an asset.
 * @param n Count of bytes to skip.
 */
void assetBufferSkip(FILE *buffer, int32_t n);

/**
 * 
 * @param fileVertex The file path of the vertex shader
 * @param fileFragment The file path of the fragment shader
 * @return The loaded shader_t instance (From shaderCompile)
 */
shader_t * assetShaderLoad(char *fileVertex, char *fileFragment);