VAPOR3 3.9.4
ShaderProgram.h
Go to the documentation of this file.
1#pragma once
2
3#include <vector>
4#include <string>
5#include <map>
6#include <glm/fwd.hpp>
7#include <vapor/MyBase.h>
8
9namespace VAPoR {
10
21
22class Shader;
23class Texture;
24
26 unsigned int _id;
27 std::vector<Shader *> _shaders;
28 bool _linked;
29 int _successStatus;
30 std::map<std::string, int> _samplerLocations;
31
32public:
33 enum class Policy { Strict, Relaxed };
35
38
42 int Link();
43 void Bind();
44 bool IsBound() const;
45 static void UnBind();
46 static int GetBoundProgramID();
47
48 void AddShader(Shader *s);
49
56 int AddShaderFromSource(unsigned int type, const char *source);
57
58 unsigned int GetID() const;
59 unsigned int WasLinkingSuccessful() const;
60
61 int GetAttributeLocation(const std::string &name) const;
62 int GetUniformLocation(const std::string &name) const;
63 bool HasUniform(const std::string &name) const;
65
66 template<typename T> bool SetUniform(const std::string &name, const T &value) const;
67 void SetUniform(int location, const int &value) const;
68 void SetUniform(int location, const float &value) const;
69 void SetUniform(int location, const glm::vec2 &value) const;
70 void SetUniform(int location, const glm::vec3 &value) const;
71 void SetUniform(int location, const glm::vec4 &value) const;
72 void SetUniform(int location, const glm::mat4 &value) const;
73 void SetUniform(int location, const glm::ivec2 &value) const;
74 void SetUniform(int location, const glm::ivec3 &value) const;
75 void SetUniform(int location, const std::vector<float> &value) const;
76
77 template<typename T> void SetUniformArray(const std::string &name, int count, const T *values) const;
78 void SetUniformArray(int location, int count, const int *values) const;
79 void SetUniformArray(int location, int count, const float *values) const;
80 void SetUniformArray(int location, int count, const glm::vec3 *values) const;
81 void SetUniformArray(int location, int count, const glm::vec4 *values) const;
82
90 template<typename T> bool SetSampler(const std::string &name, const T &texture) const;
91
92 std::string GetLog() const;
93 void PrintUniforms() const;
94 static const char *GLTypeToString(const unsigned int type);
95 static bool IsGLTypeSampler(const unsigned int type);
96};
97
110
112 ShaderProgram *_program;
113
114public:
117 ShaderProgram *operator->() { return _program; }
118 bool IsValid() const;
119 friend class ShaderManager;
120};
121} // namespace VAPoR
Resource management class for shaders.
Definition: ShaderManager.h:18
Provides a C++ interface to the OpenGL shader program construct.
Definition: ShaderProgram.h:25
static const char * GLTypeToString(const unsigned int type)
void SetUniform(int location, const glm::mat4 &value) const
void SetUniform(int location, const glm::vec2 &value) const
void SetUniform(int location, const glm::vec3 &value) const
static void UnBind()
bool IsBound() const
void SetUniform(int location, const float &value) const
void SetUniform(int location, const std::vector< float > &value) const
void SetUniformArray(int location, int count, const glm::vec4 *values) const
int GetUniformLocation(const std::string &name) const
bool SetSampler(const std::string &name, const T &texture) const
void SetUniformArray(int location, int count, const int *values) const
void SetUniformArray(int location, int count, const float *values) const
void SetUniformArray(const std::string &name, int count, const T *values) const
void SetUniform(int location, const glm::ivec3 &value) const
void SetUniformArray(int location, int count, const glm::vec3 *values) const
std::string GetLog() const
unsigned int WasLinkingSuccessful() const
static Policy UniformNotFoundPolicy
Definition: ShaderProgram.h:34
void AddShader(Shader *s)
int AddShaderFromSource(unsigned int type, const char *source)
static int GetBoundProgramID()
bool SetUniform(const std::string &name, const T &value) const
int GetAttributeLocation(const std::string &name) const
void ComputeSamplerLocations()
void SetUniform(int location, const glm::vec4 &value) const
void SetUniform(int location, const glm::ivec2 &value) const
void PrintUniforms() const
unsigned int GetID() const
bool HasUniform(const std::string &name) const
void SetUniform(int location, const int &value) const
static bool IsGLTypeSampler(const unsigned int type)
Provides a C++ interface to the OpenGL shader construct.
Definition: Shader.h:16
Provides a C++ interface to the OpenGL shader program construct.
SmartShaderProgram(ShaderProgram *program)
ShaderProgram * operator->()
Wasp base class.
Definition: MyBase.h:67
#define RENDER_API
Definition: common.h:78