6 #ifndef GLCXX_SHADER_HPP 7 #define GLCXX_SHADER_HPP 25 Shader(GLenum shader_type);
40 void set_source(
const char * source,
int length = -1);
65 static std::shared_ptr<Shader>
66 create(GLenum shader_type,
const char * source,
int length = -1)
68 std::shared_ptr<Shader> shader = std::make_shared<Shader>(shader_type);
69 shader->set_source(source, length);
79 static std::shared_ptr<Shader>
82 std::shared_ptr<Shader> shader = std::make_shared<Shader>(shader_type);
83 shader->set_source_from_file(filename);
void allocate()
Allocate the OpenGL shader object.
Definition: Shader.cpp:81
C++ wrapper for an OpenGL shader object.
Definition: Shader.hpp:17
GLuint id() const
Get the shader object's ID.
Definition: Shader.hpp:54
Include module for the main OpenGL header.
GLenum m_shader_type
The OpenGL shader type.
Definition: Shader.hpp:96
~Shader()
Destroy the shader object.
Definition: Shader.cpp:15
Shader(GLenum shader_type)
Create and allocate an OpenGL shader object.
Definition: Shader.cpp:9
GLuint m_id
The shader object's ID.
Definition: Shader.hpp:91
void set_source_from_file(const char *filename)
Load shader source from a file.
Definition: Shader.cpp:65
void set_source(const char *source, int length=-1)
Load shader source from memory.
Definition: Shader.cpp:20
static std::shared_ptr< Shader > create(GLenum shader_type, const char *source, int length=-1)
Factory method to construct a Shader object.
Definition: Shader.hpp:66
static std::shared_ptr< Shader > create_from_file(GLenum shader_type, const char *filename)
Factory method to construct a Shader object.
Definition: Shader.hpp:80