Flow Visualisation
Shader.h
Go to the documentation of this file.
1 //
2 // Shader.h
3 // flowviz
4 //
5 // Created by Johann Götz on 01.05.15.
6 // Copyright (c) 2015 Johann Götz. All rights reserved.
7 //
8 
9 #ifndef __flowviz__Shader__
10 #define __flowviz__Shader__
11 
12 #include <stdio.h>
13 #include <OpenGL/gl3.h>
14 #include <OpenGL/OpenGL.h>
15 
16 #include "glm.hpp"
17 #include "type_ptr.hpp"
18 
19 #include "ISceneGraphPart.h"
20 #include "SceneContext.h"
21 
22 namespace render {
23 
27  class Uniform
28  {
29  private:
30  GLint m_uniformLocation;
32  public:
33  Uniform(void);
34  Uniform(GLint uniformLocation);
35  ~Uniform(void);
36 
37  void set1i(const int);
38  void set1f(const float);
39  void set2f(const float, const float);
40  void set3fv(const glm::vec3*, int num = 1);
41  void set4fv(const glm::vec4*, int num = 1);
42  void set3x3fv(const glm::mat3*, int num = 1);
43  void set3x3fv(const glm::mat4*, int num = 1);
44  void set4x4fv(const glm::mat4*, int num = 1);
45  };
46 
47 
51  class Shader : public ISceneGraphPart
52  {
53  private:
54  GLuint m_program;
55 
56  public:
57  Shader() : m_program(0) { }
58  //Shader(const char *vertexShaderFilename, const char *pixelShaderFilename);
59  virtual ~Shader(void);
60 
66  bool init(const char *vertexShaderFilename, const char* pixelShaderFilename);
67 
71  void uninit(void);
72 
77 
78  //void bindFullAttributeLocations();
79  //void bindFontAttributeLocations();
80  //void bindGuiAttributeLocations();
81 
85  void use(void);
86 
91  Uniform getUniform(const char* uniformName) { return Uniform(glGetUniformLocation(m_program, uniformName)); }
92 
100  virtual void render(SceneContext *context);
101  };
102 
103 }
104 
105 #endif /* defined(__flowviz__Shader__) */
void uninit(void)
Cleans up shader.
Definition: Shader.cpp:195
~Uniform(void)
Definition: Shader.cpp:23
void set4x4fv(const glm::mat4 *, int num=1)
Definition: Shader.cpp:63
Definition: type_mat2x2.hpp:45
Represents a shader uniform and allows setting of variables.
Definition: Shader.h:27
void set1f(const float)
Definition: Shader.cpp:31
void set3x3fv(const glm::mat3 *, int num=1)
Definition: Shader.cpp:51
void set4fv(const glm::vec4 *, int num=1)
Definition: Shader.cpp:46
void set2f(const float, const float)
Definition: Shader.cpp:36
Represents the current state of rendering.
Definition: SceneContext.h:22
virtual void render(SceneContext *context)
Sets shader active and saves it in.
Definition: Shader.cpp:218
void set1i(const int)
Definition: Shader.cpp:26
Represents part of the SceneGraph.
Definition: ISceneGraphPart.h:23
Definition: Camera.h:19
virtual ~Shader(void)
Definition: Shader.cpp:82
Definition: type_mat2x2.hpp:39
Uniform(void)
the uniform loaction
Definition: Shader.cpp:15
void set3fv(const glm::vec3 *, int num=1)
Definition: Shader.cpp:41
void use(void)
Sets this shader active.
Definition: Shader.cpp:213
Uniform getUniform(const char *uniformName)
Gets uniform by name.
Definition: Shader.h:91
Definition: type_mat2x2.hpp:40
Shader()
Definition: Shader.h:57
bool init(const char *vertexShaderFilename, const char *pixelShaderFilename)
Reads Shader from tex files.
Definition: Shader.cpp:88
OpenGL shader class.
Definition: Shader.h:51
Definition: type_mat2x2.hpp:49
void bindAttributeLocations()
Binds correct attribute locations.
Definition: Shader.cpp:159