Vis 2 Demo  1.0
Technical illustration type real-time rendering of geometry
 All Classes Namespaces Files Functions Variables Typedefs Macros
ShaderController.h
Go to the documentation of this file.
1 #ifndef __SHADER_CONTROLLER_H__
2 #define __SHADER_CONTROLLER_H__
3 
4 #include <glew.h>
5 #include <iostream>
6 #include <glm/glm.hpp>
7 #include <glm/gtc/matrix_transform.hpp>
8 #include <glm/gtc/type_ptr.hpp>
9 #include "Shader.h"
10 #include "Texture.h"
11 
12 #define VIS2_MAX_NR_SHADER_TYPES 20
13 
14 #define VIS2_SHADER_TYPE_BASIC 0
15 #define VIS2_SHADER_TYPE_BASIC_TEXTURED 1
16 #define VIS2_SHADER_TYPE_SOLID_COLOR 2
17 #define VIS2_SHADER_TYPE_PHONG_TEXTURED 3
18 
19 #define VIS2_SHADER_TYPE_EDGE_DETECT_H 4
20 #define VIS2_SHADER_TYPE_EDGE_DETECT_V 5
21 
22 #define VIS2_SHADER_TYPE_BLUR_H 6
23 #define VIS2_SHADER_TYPE_BLUR_V 7
24 
25 #define VIS2_SHADER_TYPE_MASK 8
26 
27 #define VIS2_SHADER_TYPE_DEPTH_PEEL 9
28 #define VIS2_SHADER_TYPE_DEPTH_PEEL_BLEND 10
29 #define VIS2_SHADER_TYPE_COMPLEX_BLEND 11
30 
31 
32 #define VIS2_SHADER_INVARS_SETUP_SUCCESS 0
33 #define VIS2_SHADER_INVARS_SETUP_INCOMPLETE 1
34 #define VIS2_SHADER_INVARS_SETUP_FAIL -1
35 
36 #define VIS2_SHADER_UNIFORMS_SETUP_SUCCESS 0
37 #define VIS2_SHADER_UNIFORMS_SETUP_INCOMPLETE 1
38 #define VIS2_SHADER_UNIFORMS_SETUP_FAIL -1
39 
40 #define VIS2_NR_TEXTURE_SLOTS 5
41 #define VIS2_TEXTURE_DIFFUSE_SLOT 0
42 #define VIS2_TEXTURE_1 1
43 #define VIS2_TEXTURE_2 2
44 #define VIS2_TEXTURE_3 3
45 #define VIS2_TEXTURE_4 4
46 
47 #define VIS2_LIGHT_0 0
48 #define VIS2_LIGHT_1 1
49 
50 namespace vis2
51 {
53 
58  {
59  public:
61 
65  ShaderController(Shader* _shader_program, unsigned int _shader_type);
66 
69 
71 
81  int setupShaderInVars( GLuint _position_buffer_handle,
82  GLuint _normal_buffer_handle,
83  GLuint _uv_buffer_handle,
84  GLuint _index_buffer_handle);
85 
87  inline GLuint getVAOHandle() const { return vao_handle; }
88 
90 
94  void assignTexture(Texture* _texture, const unsigned int _slot);
95 
97 
102  void setLightSource(const glm::vec3 _light_pos, const glm::vec3 _light_col, const unsigned int _slot);
103 
105 
109  void setViewData(const glm::vec3 _viewer_pos, const glm::vec3 _viewer_lookAt);
110 
112 
116  void setNearFar(float _near, float _far);
117 
119 
124  void setBlurParams( const int _use_gaussian,
125  const int _gauss_kernel_size,
126  const int _blur_dist);
127 
129 
135  void setMaskingParams( const glm::vec3 _masking_color,
136  const glm::vec3 _exculde_color,
137  const float _masking_tolerance,
138  const int _use_prev_pass);
139 
141 
145  void setPeelingParams( float _window_w, float _window_h);
146 
148 
152  void setPeelingBlendParams(const float _alpha, const glm::vec3 _bcgrd_col);
153 
155 
158  void setBlendAllParams( const glm::vec3 & _neighb_shading_col);
159 
161 
168  int updateShaderUniforms( glm::mat4 & _projectionMatrix,
169  glm::mat4 & _modelMatrix,
170  const glm::vec3 & _obj_color,
171  const glm::vec3 & _contour_color);
172 
174  const unsigned int shader_type;
175 
176  private:
179 
182 
184  GLuint vao_handle;
186 
189 
190  glm::vec3 vec_diffuse_color;
191 
192  glm::vec3 vec_light_pos_0;
193  glm::vec3 vec_light_pos_1;
194 
195  glm::vec3 vec_light_col_0;
196  glm::vec3 vec_light_col_1;
197 
198  glm::vec3 vec_viewer_pos;
199  glm::vec3 vec_viewer_lookAt;
200 
201  float near_plane;
202  float far_plane;
203 
204  int use_gauss;
207 
208  glm::vec3 masking_color;
209  glm::vec3 exculde_color;
212 
213  float window_w;
214  float window_h;
215 
216  float depth_peel_blend[4];
218 
220 
221  };
222 }
223 
224 
225 
226 #endif