6 #ifndef GLW_SHADER_PROGRAM_H 7 #define GLW_SHADER_PROGRAM_H 11 #include <glbinding/gl/gl.h> 22 vertex = (
unsigned int)gl::GLenum::GL_VERTEX_SHADER,
23 tess_ctrl = (
unsigned int)gl::GLenum::GL_TESS_CONTROL_SHADER,
24 tess_eval = (
unsigned int)gl::GLenum::GL_TESS_EVALUATION_SHADER,
25 geometry = (
unsigned int)gl::GLenum::GL_GEOMETRY_SHADER,
26 fragment = (
unsigned int)gl::GLenum::GL_FRAGMENT_SHADER,
27 compute = (
unsigned int)gl::GLenum::GL_COMPUTE_SHADER,
28 none = (
unsigned int)gl::GLenum::GL_NONE
36 using PShader = std::shared_ptr<class Shader>;
43 using ReplaceMap = std::map<std::string, std::string>;
46 static PShader Create(
const ShaderType shader_type);
49 static PShader CreateFromFile(
const ShaderType shader_type,
const std::string &file_name,
const ReplaceMap &replace_map = ReplaceMap());
52 static PShader CreateFromStr(
const ShaderType shader_type,
const std::string &shader_code,
const ReplaceMap &replace_map = ReplaceMap());
58 Shader(
const gl::GLenum shader_type);
64 bool LoadFromStr(
const std::string &shader_code,
const ReplaceMap &replace_map = ReplaceMap());
67 bool LoadFromFile(
const std::string &file_name,
const ReplaceMap &replace_map = ReplaceMap());
73 bool IsCompiled()
const;
76 gl::GLuint GetID()
const;
82 std::string GetCompilationLog()
const;
86 gl::GLuint shader_id_ = 0;
87 bool was_compiled_successfully_ =
false;
92 using PProgram = std::shared_ptr <class Program>;
99 static PProgram Create();
108 bool AttachShader(
const PShader &shader_ptr);
114 bool IsLinked()
const;
117 gl::GLuint GetID()
const;
120 std::string GetLinkLog()
const;
126 gl::GLint GetUniformLocation(
const std::string &name)
const;
129 gl::GLint GetUniformBlockLocation(
const std::string &name)
const;
132 gl::GLuint program_id_ = 0;
133 bool is_linked_successfuly =
false;
134 std::map<ShaderType, PShader> attached_shaders_;
OpenGL wrapper library namespace. Provides simplified interface for using OpenGL features.
Definition: API.h:17
Maintains the source code strings that defines a shader.
Definition: ShaderProgram.h:39
Holds several compiled shaders which are used as a whole.
Definition: ShaderProgram.h:95
GLW_API glw::ShaderType GetShaderTypeFromFileName(const std::string &filename)
Creates ShaderType from extension of specified shader file name.
ShaderType
Indicates the type of shader.
Definition: ShaderProgram.h:20