Update shader loading

This commit is contained in:
2021-01-10 23:39:13 +01:00
parent 5afb752fca
commit e90c043c6b
4 changed files with 22 additions and 10 deletions

View File

@@ -10,6 +10,8 @@
#include <Windows.h>
#else
#include <pthread.h>
#include <fstream>
#endif
namespace openVulkanoCpp
@@ -24,4 +26,16 @@ namespace openVulkanoCpp
pthread_setname_np(pthread_self(), name.c_str());
#endif
}
Array<char> Utils::ReadFile(const std::string& filePath)
{
std::ifstream file(filePath, std::ios::ate | std::ios::binary);
if (!file.is_open()) throw std::runtime_error("Failed to open file '" + filePath + "'!");
const size_t fileSize = static_cast<size_t>(file.tellg());
Array<char> data(fileSize);
file.seekg(0);
file.read(data.Data(), fileSize);
file.close();
return data;
}
}