diff options
author | Edward O'Callaghan <funfunctor@folklore1984.net> | 2017-02-07 22:04:02 +1100 |
---|---|---|
committer | Edward O'Callaghan <funfunctor@folklore1984.net> | 2017-02-07 22:04:02 +1100 |
commit | fd1f26b416cf7b2bb8cd47acca7e097a48a2ff06 (patch) | |
tree | 7df5118ecd011284eb6459eb197778a09f3c9a5d /src | |
parent | f5bacf193a77a10b9d69c9e2e8842d0dac34ee56 (diff) |
src/shader_loader.hcpp: Add shader loader
Signed-off-by: Edward O'Callaghan <funfunctor@folklore1984.net>
Diffstat (limited to 'src')
-rw-r--r-- | src/shader_loader.hcpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/shader_loader.hcpp b/src/shader_loader.hcpp new file mode 100644 index 0000000..9429b32 --- /dev/null +++ b/src/shader_loader.hcpp @@ -0,0 +1,18 @@ +#include <fstream> + +static std::vector<char> readFile(const std::string& filename) { + std::ifstream file(filename, std::ios::ate | std::ios::binary); + + if (!file.is_open()) + throw std::runtime_error("failed to open file!"); + + size_t file_sz = (size_t) file.tellg(); + std::vector<char> buffer(file_sz); + + file.seekg(0); + file.read(buffer.data(), file_sz); + + file.close(); + + return buffer; +} |