/** * Copyright (c) 2021 Dominic Msters * * This software is released under the MIT License. * https://opensource.org/licenses/MIT */ #pragma once #include #include "../display/shader.h" #include "../display/texture.h" /** * 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); /** * Load a shader program from a vertex and fragment shader file. * * @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); /** * Load a texture from a PNG file. * * @param fileName The fike path of the PNG image. * @return The loaded texture object. */ texture_t * assetTextureLoad(char *fileName);