26 static constexpr GLenum gl_shader_type_lut[] =
37 const GLenum gl_shader_type = gl_shader_type_lut[
static_cast<std::size_t
>(m_stage)];
40 gl_shader_id = glCreateShader(gl_shader_type);
43 throw std::runtime_error(
"Unable to create OpenGL shader object");
49 glDeleteShader(gl_shader_id);
55 const GLint gl_length =
static_cast<GLint
>(source_code.length());
56 const GLchar* gl_string = source_code.data();
57 glShaderSource(gl_shader_id, 1, &gl_string, &gl_length);
66 glCompileShader(gl_shader_id);
69 GLint gl_compile_status;
70 glGetShaderiv(gl_shader_id, GL_COMPILE_STATUS, &gl_compile_status);
71 m_compiled = (gl_compile_status == GL_TRUE);
74 GLint gl_info_log_length;
75 glGetShaderiv(gl_shader_id, GL_INFO_LOG_LENGTH, &gl_info_log_length);
77 if (gl_info_log_length > 0)
80 info_log.resize(gl_info_log_length);
83 glGetShaderInfoLog(gl_shader_id, gl_info_log_length, &gl_info_log_length, info_log.data());
bool compile()
Compiles the shader object.
~shader_object()
Destroys a shader object.
void source(std::string_view source_code)
Replaces the source code of the shader object.
shader_object(shader_stage stage)
Creates an empty shader object for the specified shader stage.
Graphics library interface.
shader_stage
Enumerates all supported shader stages.