7 #include <gls/headercheck.hpp>
8 #include <gls/errorcheck.hpp>
9 #include <gls/objects/object.hpp>
11 #if !defined( NDEBUG )
12 #if !defined( GLS_ERROR_STREAM )
14 #define GLS_ERROR_STREAM std::cerr
22 void create_shader( GLsizei, GLuint* name ) { *name = glCreateShader( Type ); }
23 void delete_shader( GLsizei,
const GLuint* name ) { glDeleteShader( *name ); }
42 return m_object.name();
59 bool compile(
const std::string& source ) {
60 auto c_str = source.c_str();
62 check_gl_error( glShaderSource(
name(), 1, reinterpret_cast<const GLchar**>( &c_str ),
nullptr ) );
63 check_gl_error( glCompileShader(
name() ) );
65 auto compile_status = GL_FALSE;
66 check_gl_error( glGetShaderiv(
name(), GL_COMPILE_STATUS, &compile_status ) );
68 #if !defined( NDEBUG )
71 if( !info_log.empty() ) {
72 GLS_ERROR_STREAM << std::move( info_log );
76 return compile_status == GL_TRUE;
91 auto info_log_length = GLint();
92 check_gl_error( glGetShaderiv(
name(), GL_INFO_LOG_LENGTH, &info_log_length ) );
94 if( !info_log_length ) {
98 auto info_log = std::vector<GLchar>(
static_cast<std::size_t
>( info_log_length ), 0 );
99 check_gl_error( glGetShaderInfoLog(
name(), info_log_length,
nullptr, info_log.data() ) );
101 return std::string( static_cast<const char*>( info_log.data() ) );
Class encapsulating an OpenGL shader object.
Definition: shader.hpp:33
bool compile(const std::string &source)
Compile this shader from the given source.
Definition: shader.hpp:59
std::string get_info_log() const
Get the link information log.
Definition: shader.hpp:90
GLuint name() const
Retrieve the OpenGL name of this shader.
Definition: shader.hpp:41
A RAII wrapper around any OpenGL object.
Definition: object.hpp:21
Definition: buffer.hpp:12