DI-Guy C++ SDK Reference  13.0
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
diguyGraphicsShaderTechnique.h
Go to the documentation of this file.
1 
2 /*********************************************************************
3  ** Copyright (c) 1992-2014 VT MAK
4  ** All rights reserved.
5  *********************************************************************/
6 
7 /*********************************************************************/
14 #ifndef __diguyGraphicsShaderTechnique_H
15 #define __diguyGraphicsShaderTechnique_H
16 
17 
18 #ifdef SWIG
20 #else
21 #define CPLUSPLUS_ONLY
22 #endif
23 
24 #ifdef CPLUSPLUS_ONLY
25 
26 #include <diguy_constants.h>
27 #include <declspec_diguy.h>
28 
29 class diguyGraphicsLink;
32 class bdiShaderTechnique;
33 
34 #endif
35 
36 /****************************************************************************/
42 {
44  m_shader_instance(NULL),
47  m_shader_lod(-1),
51  m_use_instancing(false)
52  {
53  ;
54  }
55 
59 
62 
65  int m_shader_lod;
66 
68  float m_render_distance;
69 
71  float m_shader_lod_bias;
72 
77 
80 
82  bool m_use_instancing;
83 
87 };
88 
89 /****************************************************************************/
101 class BDI_DECLSPEC_diguy diguyGraphicsShaderTechnique
102 {
103 
104 public:
105 
106 /*****************************************************************************/
119  /*l
120  *b Returns:
121  **
122  ** the name of the shader technique. This pointer will
123  ** never be NULL.
124  */
125  const char* get_name();
126 
127  /*l
128  *b Description:
129  **
130  ** Returns the number of lod shaders the technique has.
131  */
132  int get_num_shader_lod_programs(bool instanced = false);
133 
134  /*l
135  *b Description:
136  **
137  ** Returns the shader program at a lod index.
138  */
139  diguyGraphicsShaderProgram* get_shader_lod_program_at_index(int index, bool instanced = false);
140 
141  /*l
142  *b Description:
143  **
144  ** Returns the distance that a shader lod switches out at.
145  */
146  float get_shader_lod_range_at_index(int index);
147 
148  /*l
149  *b Description:
150  **
151  ** Returns a shader based on the rendering distance.
152  */
153  diguyGraphicsShaderProgram * get_shader_by_distance(float distance, int max_quality_level, bool instanced = false);
154 
155  /*l
156  *b Description:
157  **
158  ** Returns the shader index based on the rendering distance.
159  */
160  int get_program_index_by_distance(float distance, int max_quality_level);
161 
162  /*l
163  *b Description:
164  **
165  ** Returns the shader specified for intersections.
166  */
167  diguyGraphicsShaderProgram* get_intersection_shader();
168 
169  /*l
170  *b Description:
171  **
172  ** Returns the shader specified for shadow map generation.
173  */
174  diguyGraphicsShaderProgram* get_shadow_pass_shader();
175 
176 /*****************************************************************************/
181  /*l
182  *b Description:
183  **
184  ** This function allows you create a new shader that uses the same
185  ** vertex and pixel files as the one passed in. The user is then able
186  ** modify the subclassed shader before calling load().
187  ** This function should allow end users to create an arbitrary number of
188  ** shader permutations and then return them via overriding pick_shader_program().
189  ** See diguyOglGraphicsShaderTechnique::build() for an example of it's usage.
190  ** Override pick_shader_program() to return a procedurally created shader.
191  */
192  diguyGraphicsShaderProgram * find_or_create_shader_variation(diguyGraphicsShaderProgram * program, const char * new_name);
193 
194  /*l
195  *b Description:
196  **
197  ** Adds an additional shader program to the technique these will get
198  ** automatically updated if any of the shader uniform functions are used.
199  ** These are mostly for convenience. Users will probably want their own
200  ** data structures to store shader lookup tables.
201  **/
202  void add_additional_shader(diguyGraphicsShaderProgram* program);
203 
204  /*l
205  *b Returns:
206  ** The number of shaders that have been procedurally added to the technique.
207  */
208  int get_num_additional_shaders();
209 
210  /*l
211  *b Returns:
212  ** A pointer to the procedural shaders that has been procedurally added to
213  ** the technique.
214  */
215  diguyGraphicsShaderProgram* get_additional_shader_at_index(int index);
216 
217 /*****************************************************************************/
221  /*l
222  *b Description:
223  **
224  ** Convenience functions. Loops through all shaders in this technique
225  ** and sets uniform variables if they exist.
226  **
227  *b Callable From:
228  **
229  *- - C++
230  *- - Script
231  */
232  int set_variable_float(const char* name, float value, int set_current = 1, int set_initial = 0);
233  int set_variable_vec2(const char* name, float x, float y, int set_current = 1, int set_initial = 0);
234  int set_variable_vec3(const char* name, float x, float y, float z, int set_current = 1, int set_initial = 0);
235  int set_variable_vec4(const char* name, float x, float y, float z, float w, int set_current = 1, int set_initial = 0);
236  int set_variable_int(const char* name, int value, int set_current = 1, int set_initial = 0);
237 
238 /*****************************************************************************/
250  /*l
251  *b Description:
252  **
253  ** Allows users to use a subclass to override the default shader LOD system
254  ** see diguyOglGraphicsShaderTechnique::pick_shader_program() for an example
255  ** of it's usage.
256  **/
257  virtual diguyGraphicsShaderProgram * pick_shader_program(const diguyShaderPickDescription & desc);
258 
259 
260  /*l
261  *b Description:
262  **
263  ** Allows users to do their own post shader load behavior.
264  **/
265  virtual void build();
266 
272 #ifdef CPLUSPLUS_ONLY
273 
274  bdiShaderTechnique* get_internal_data() {return m_internal_data;}
275 
276 protected:
277 
278  /*l
279  ** A protected constructor. Constructors are called automatically
280  ** by DI-Guy.
281  */
282  diguyGraphicsShaderTechnique(void* internal_data);
283 
284  /*l
285  ** A protected destructor. Destructors are called automatically
286  ** by DI-Guy.
287  */
288  virtual ~diguyGraphicsShaderTechnique();
289 
290 private:
291 
292  /*l
293  ** A pointer to internal data.
294  */
295  bdiShaderTechnique* m_internal_data;
296 
297  friend class bdiShaderTechnique;
298  friend class bdiGeometryFactory;
299 #endif
300 };
303 #endif /* __diguyGraphicsShaderTechnique_H */
304