8 #include <ThirdParty/glm/glm/glm.hpp> 9 #include <ThirdParty/EASTL-master/include/EASTL/map.h> 10 #include <ThirdParty/EASTL-master/include/EASTL/shared_ptr.h> 11 #include <ThirdParty/glew-2.1.0/include/GL/glew.h> 25 friend class OpenGLShader;
33 bool IsValid()
const {
return _location != -1; }
39 GLenum GetType()
const {
return _type; }
45 GLint GetLocation()
const {
return _location; }
50 void SetValue(
float val)
const;
56 void SetValue(
int val)
const;
62 void SetValue(
bool val)
const;
68 void SetValue(
const glm::vec2& vec)
const;
74 void SetValue(
const glm::vec3& vec)
const;
80 void SetValue(
const glm::vec4& vec)
const;
86 void SetValue(
const Color& color);
93 void SetValue(
const glm::mat4x4& mtx,
bool transpose =
false)
const;
99 void SetValue(Texture& texture_)
const;
111 ShaderParameter(OpenGLShader* shader, eastl::string name, GLenum type, GLint location, GLint sampler = -1)
115 , _location(location)
122 ShaderParameter() : _shader(nullptr), _name(
""), _type(0), _location(-1), _sampler(-1) {}
132 void Reset(OpenGLShader* shader, eastl::string name, GLenum type, GLint location, GLint sampler = -1)
134 this->_shader = shader;
136 this->_location = location;
138 this->_sampler = sampler;
156 OpenGLShader* _shader;
183 class ShaderAttribute
185 friend class OpenGLShader;
193 bool IsValid()
const {
return _location != -1; }
199 GLenum GetType()
const {
return _type; }
205 GLint GetLocation()
const {
return _location; }
216 void SetAttributePointer(
219 GLboolean normalized,
221 const GLvoid * pointer)
const;
226 void DisableAttributePointer()
const;
238 ShaderAttribute(OpenGLShader* shader, eastl::string name, GLenum type, GLint location) :
248 ShaderAttribute() : _shader(nullptr), _name(
""), _type(0), _location(-1) {}
258 void Reset(OpenGLShader* shader, eastl::string name, GLenum type, GLint location)
260 this->_shader = shader;
262 this->_location = location;
282 OpenGLShader* _shader;
308 friend class OpenGLRenderer;
318 explicit OpenGLShader(
const eastl::string& vertexFileName,
319 const eastl::string& fragmentFileName);
331 explicit OpenGLShader(
const eastl::string& vertexFileName,
332 const eastl::string& fragmentFileName,
333 const eastl::string& geometryFileName);
335 explicit OpenGLShader(
const Shader& other) =
delete;
336 OpenGLShader(OpenGLShader &&other) =
delete;
350 bool LoadSource(
const eastl::string& vertexShader,
351 const eastl::string& fragmentShader,
352 const eastl::string& geometryShader);
359 eastl::weak_ptr<ShaderParameter> GetParameter(
const eastl::string& name);
366 eastl::weak_ptr<ShaderAttribute> GetAttribute(
const eastl::string& name);
372 GLuint GetProgram()
const;
377 void Activate()
override;
381 void Deactivate()
override;
385 void LoadParameters();
387 bool Validate()
const;
390 eastl::map<eastl::string, eastl::shared_ptr<ShaderParameter>> parameters;
393 eastl::map<eastl::string, eastl::shared_ptr<ShaderAttribute>> attributes;