/** * Copyright (c) 2021 Dominic Msters * * This software is released under the MIT License. * https://opensource.org/licenses/MIT */ #pragma once #include "../libs.h" #include "../display/shader.h" #include "../display/texture.h" #include "../display/font.h" #include "../script/scripter.h" #include "xml.h" #if !defined(ASSET_PREFIX) #error Asset Prefix has not been defined. #endif /** Definition of an asset ready to be buffered */ typedef FILE assetbuffer_t; /** * 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); uint8_t * assetRawLoad(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. */ assetbuffer_t * assetBufferOpen(char *assetName); /** * Closes a previously opened asset buffer. * @param buffer Buffer to close. * @return True if successful, otherwise false. */ bool assetBufferClose(assetbuffer_t *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(assetbuffer_t *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(assetbuffer_t *buffer); /** * Rewinds an asset buffer to the start. * * @param buffer Buffer to rewind * @return 0 if successful, otherwise unsuccessful. */ int32_t assetBufferStart(assetbuffer_t *buffer); /** * Method to skip n bytes in the buffer * @param buffer The buffer pointing to an asset. * @param n Count of bytes to skip. * @return 0 if successful, otherwise unsuccessful. */ int32_t assetBufferSkip(assetbuffer_t *buffer, int32_t n); /** * Load a shader program from a vertex and fragment shader file. * @param shader Shader to load into. * @param fileVertex The file path of the vertex shader * @param fileFragment The file path of the fragment shader */ void assetShaderLoad(shader_t *shader, char *fileVertex, char *fileFragment); /** * Load a texture from a PNG file. * @param texture Texture to load the file into. * @param fileName The file path of the PNG image. */ void assetTextureLoad(texture_t *texture, char *fileName); /** * Load a font from a TTF file. * @param font Font to load into. * @param assetName Asset name for the TTF font. * @param size Size of the font. */ void assetFontLoad(font_t *font, char *assetName); void assetScripterAppend(scripter_t *scripter, char *fileName);