work on moving shader loading/compilation to a separate file

This commit is contained in:
2025-08-17 00:32:43 -05:00
parent 06d99cf87e
commit 47564bb3cf
12 changed files with 199 additions and 72 deletions

23
src/util.cpp Normal file
View File

@@ -0,0 +1,23 @@
#include <cstdio>
#include <stdlib.h>
#include "util.hpp"
bool read_file(Array<char>* out, const char* filepath) {
FILE* fp = NULL;
if (fopen_s(&fp, filepath, "r") != 0) {
printf("ERROR Failed to open file %s\n", filepath);
return false;
}
fseek(fp, 0L, SEEK_END);
size_t sz = ftell(fp);
fseek(fp, 0L, 0L);
char *data = (char*)malloc(sizeof(char)*sz);
fread(data, sizeof(char), sz, fp);
fclose(fp);
out->_data = data;
out->len = sz;
return true;
}