summaryrefslogtreecommitdiff
path: root/src/shader_loader.hcpp
blob: 9429b323c74b59c11eace3118f69293706ef4ea4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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;
}