9#include <initializer_list>
11#include <smk/OpenGL.hpp>
94 Shader(
const std::vector<char>& content, GLenum type);
102 mutable int* ref_count_ =
nullptr;
124 bool IsReady()
const;
127 bool LinkStatus()
const;
137 GLint
Attribute(
const std::string& name)
const;
148 GLboolean normalize)
const;
157 GLuint offset)
const;
160 GLint
Uniform(
const std::string& name);
161 GLint operator[](
const std::string& name);
164 void SetUniform(
const std::string& name,
float x,
float y,
float z);
165 void SetUniform(
const std::string& name,
const glm::vec3& v);
166 void SetUniform(
const std::string& name,
const glm::vec4& v);
167 void SetUniform(
const std::string& name,
const glm::mat4& m);
168 void SetUniform(
const std::string& name,
const glm::mat3& m);
169 void SetUniform(
const std::string& name,
float val);
170 void SetUniform(
const std::string& name,
int val);
186 std::shared_ptr<Impl> impl_;
A shader program is a set of shader (for instance vertex shader + pixel shader) defining the renderin...
GLint Attribute(const std::string &name) const
Return the GPU attribute id.
void SetAttribute(const std::string &name, GLint size, GLsizei stride, GLuint offset, GLboolean normalize, GLenum type) const
Set an OpenGL attribute properties.
ShaderProgram()
The constructor. The ShaderProgram is initially invalid. You need to call AddShader and Link before b...
GLint Uniform(const std::string &name)
Return the uniform ID.
void SetUniform(const std::string &name, float x, float y, float z)
Assign shader vec3 uniform.
void Unuse() const
Unbind the ShaderProgram.
void AddShader(const Shader &shader)
Add a Shader to the program list. This must called multiple time for each shader components before ca...
GLuint id() const
The GPU id to the ShaderProgram.
void Use() const
Bind the ShaderProgram. Future draw will use it. This unbind any previously bound ShaderProgram.
void Link() const
Add a Shader to the program list.
A Shader is a little program that rest on the GPU. They are run on a specific section of the graphic ...
bool CompileStatus() const
Wait until the Shader to be ready.
static Shader FromFile(const std::string &filename, GLenum type)
Load a shader from a file.
GLuint id() const
The GPU shader id.
static Shader FromString(const std::string &content, GLenum type)
Load a shader from a std::string.
bool IsReady() const
Check the status of a Shader. Linking shader is an asynchronous process. Using the shader can causes ...