work on moving shader loading/compilation to a separate file
This commit is contained in:
23
src/util.cpp
Normal file
23
src/util.cpp
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user