| 100 | } |
| 101 | |
| 102 | util::Either<shader_t, std::string> shader_t::compile(const std::string_view &source, GLenum type) { |
| 103 | shader_t shader; |
| 104 | |
| 105 | auto data = source.data(); |
| 106 | GLint length = source.length(); |
| 107 | |
| 108 | shader._shader.el = ctx.CreateShader(type); |
| 109 | ctx.ShaderSource(shader.handle(), 1, &data, &length); |
| 110 | ctx.CompileShader(shader.handle()); |
| 111 | |
| 112 | int status = 0; |
| 113 | ctx.GetShaderiv(shader.handle(), GL_COMPILE_STATUS, &status); |
| 114 | |
| 115 | if (!status) { |
| 116 | return shader.err_str(); |
| 117 | } |
| 118 | |
| 119 | return shader; |
| 120 | } |
| 121 | |
| 122 | GLuint shader_t::handle() const { |
| 123 | return _shader.el; |