embed shaders in binary

This commit is contained in:
David Allemang
2022-11-16 18:33:07 -05:00
parent aa88aee643
commit 501d2e0685
9 changed files with 114 additions and 35 deletions

View File

@@ -23,6 +23,17 @@ public:
// todo throw if compile failed
}
explicit Shader(const std::string_view &src) {
id = glCreateShader(mode);
const char *str = src.data();
const GLint length = (GLint) src.length();
glShaderSource(id, 1, &str, &length);
glCompileShader(id);
// todo throw if compile failed
}
explicit Shader(std::ifstream source)
: Shader(std::string(
std::istreambuf_iterator<char>(source),