Just writing code nothing special.

This commit is contained in:
2021-08-02 22:58:02 -07:00
parent 289e6fccfc
commit c451538def
19 changed files with 254 additions and 30 deletions

View File

@ -9,7 +9,7 @@
char * assetStringLoad(char *assetName) {
// Open a buffer.
FILE *fptr = assetBufferOpen(assetName);
assetbuffer_t *fptr = assetBufferOpen(assetName);
if(fptr == NULL) return NULL;
// Read the count of bytes in the file
@ -32,7 +32,7 @@ char * assetStringLoad(char *assetName) {
return str;
}
FILE * assetBufferOpen(char *assetName) {
assetbuffer_t * assetBufferOpen(char *assetName) {
// Get the directory based on the raw input by creating a new string.
size_t lenAsset = strlen(assetName);// Get the length of asset
size_t lenPrefix = strlen(ASSET_PREFIX);// Get the length of the prefix
@ -49,23 +49,23 @@ FILE * assetBufferOpen(char *assetName) {
FILE *fptr = fopen(joined, "rb");
free(joined);// Free the string we just created
if(!fptr) return NULL;// File available?
return fptr;
return (assetbuffer_t *)fptr;
}
bool assetBufferClose(FILE *buffer) {
return fclose(buffer);
bool assetBufferClose(assetbuffer_t *buffer) {
return fclose((FILE *)buffer);
}
int32_t assetBufferRead(FILE *buffer, char *data, int32_t size) {
return (int32_t)fread(data, 1, size, buffer);
int32_t assetBufferRead(assetbuffer_t *buffer, char *data, int32_t size) {
return (int32_t)fread(data, 1, size, (FILE *)buffer);
}
int32_t assetBufferEnd(FILE *buffer) {
return feof(buffer);
int32_t assetBufferEnd(assetbuffer_t *buffer) {
return feof((FILE *)buffer);
}
void assetBufferSkip(FILE *buffer, int32_t n) {
fseek(buffer, n, SEEK_CUR);
void assetBufferSkip(assetbuffer_t *buffer, int32_t n) {
fseek((FILE *)buffer, n, SEEK_CUR);
}
void assetShaderLoad(shader_t *shader, char *fileVertex, char *fileFragment) {
@ -89,7 +89,7 @@ void assetShaderLoad(shader_t *shader, char *fileVertex, char *fileFragment) {
}
void assetTextureLoad(texture_t *texture, char *fileName) {
FILE *buffer;
assetbuffer_t *buffer;
int channels, width, height;
pixel_t *data;
stbi_io_callbacks OPENGL_STBI_CALLBACKS;

View File

@ -23,14 +23,14 @@ char * assetStringLoad(char *assetName);
* @param assetName The asset name to open a buffer for.
* @return Pointer to a buffer, NULL if unsuccessfuil.
*/
FILE * assetBufferOpen(char *assetName);
assetbuffer_t * assetBufferOpen(char *assetName);
/**
* Closes a previously opened asset buffer.
* @param buffer Buffer to close.
* @return True if successful, otherwise false.
*/
bool assetBufferClose(FILE *buffer);
bool assetBufferClose(assetbuffer_t *buffer);
/**
* Read bytes from buffer.
@ -39,21 +39,21 @@ bool assetBufferClose(FILE *buffer);
* @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);
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(FILE *buffer);
int32_t assetBufferEnd(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.
*/
void assetBufferSkip(FILE *buffer, int32_t n);
void assetBufferSkip(assetbuffer_t *buffer, int32_t n);
/**
* Load a shader program from a vertex and fragment shader file.