DI-Guy C++ SDK Reference  13.0
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
diguyGraphicsShaderInstance.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 __diguyGraphicsShaderInstance_H
15 #define __diguyGraphicsShaderInstance_H
16 
17 #ifdef SWIG
19 #else
20 #define CPLUSPLUS_ONLY
21 #endif
22 
23 #ifdef CPLUSPLUS_ONLY
24 #include <diguy_constants.h>
25 #include <declspec_diguy.h>
26 
30 class diguyCharacter;
31 class bdiShaderProgramInstance;
32 
33 /****************************************************************************/
34 
35 #endif
36 
37 
38 /****************************************************************************/
55 class BDI_DECLSPEC_diguy diguyGraphicsShaderInstance
56 {
57 
58 public:
59 
60 /*****************************************************************************/
70  /*l
71  *b Description:
72  **
73  ** This function returns the shader technique this shader instance is
74  ** associated with.
75  **
76  *b Returns:
77  **
78  ** pointer to type diguyGraphicsShaderTechnique; should never be NULL
79  **
80  *b Callable From:
81  **
82  *- - C++
83  */
84  diguyGraphicsShaderTechnique* get_shader_technique();
85 
86 
87 #ifdef CPLUSPLUS_ONLY
88 
89  /*l
90  *b Description:
91  **
92  ** This function returns a pointer to shader matrix data. This is
93  ** the same pointer that is passed into bind_link_matrices().
94  **
95  ** The returned pointer should not be cached for later used, as it
96  ** may change multiple times during the lifetime of this shader
97  ** instance.
98  **
99  *b Returns:
100  **
101  ** pointer to first value in array of floats
102  **
103  *b Callable From:
104  **
105  *- - C++
106  */
107  const float* get_shader_matrix_data_ptr();
108 
109 #endif
110 
111  /*l
112  *b Description:
113  **
114  ** This function returns a pointer to the character that this shader
115  ** instance is associated with.
116  **
117  *b Returns:
118  **
119  ** pointer to type diguyCharacter; may be NULL
120  **
121  *b Callable From:
122  **
123  *- - C++
124  */
125  diguyCharacter* get_character();
126 
127 
128 /*****************************************************************************/
140 #ifdef CPLUSPLUS_ONLY
141 
142  /*l
143  *b Description:
144  **
145  ** This function will be called by DI-Guy when it is time for the
146  ** object that this shader instance is attached to to be rendered.
147  ** This happens during the Draw Stage, just before the geometry of a
148  ** character or scene object is to be rendered.
149  **
150  ** Any instance level shader control variables should be set in this
151  ** function. Instance level variables will affect only shader
152  ** operations in which this instance is active. Variables that
153  ** should affect the overall program of a shader should be set in
154  ** diguyGraphicsShaderProgram::bind().
155  **
156  *i Immediate Mode:
157  **
158  ** Immediate mode renderers usually do override this function.
159  **
160  *i Scene Graph:
161  **
162  ** Scene graph renderers usually do not override this function; the
163  ** renderer will typically do this internally. If shader variables
164  ** need to be bound, however, this function should be overridden.
165  **
166  *b Callable From:
167  **
168  *- - N/A (automatically called by DI-Guy Graphics API during
169  *- the Draw Stage)
170  */
171  virtual int bind();
172 
173  /*l
174  *b Description:
175  **
176  ** This function will be called by DI-Guy when the object this shader
177  ** is attached to is done being rendered.
178  **
179  ** This happens during the Draw Stage, just after the geometry of a
180  ** character has been rendered.
181  **
182  ** Any shader variables bound in bind() should be unbound here.
183  **
184  *i Immediate Mode:
185  **
186  ** Immediate mode renderers usually do override this function.
187  **
188  *i Scene Graph:
189  **
190  ** Scene graph renderers usually do not override this function; the
191  ** renderer will typically do this internally. If the bind()
192  ** function was overridden, however, this function probably should
193  ** be, too.
194  **
195  *b Callable From:
196  **
197  *- - N/A (automatically called by DI-Guy Graphics API during
198  *- the Draw Stage)
199  */
200  virtual int unbind();
201 
202 #endif
203 
204 
205 /*****************************************************************************/
219  int get_num_variables();
220  const char* get_variable_name_at_index(int index);
221  int has_variable(const char* name);
222  const char* get_variable_type(const char* name);
223 
224  void reset_variables_to_initial_values();
225  void reset_variables_to_program_defaults();
226 
227  int set_variable_float(const char* name, float value, int set_current = 1, int set_initial = 0, float blend_time = 0.0f);
228  int set_variable_vec2(const char* name, float x, float y, int set_current = 1, int set_initial = 0, float blend_time = 0.0f);
229  int set_variable_vec3(const char* name, float x, float y, float z, int set_current = 1, int set_initial = 0, float blend_time = 0.0f);
230  int set_variable_vec4(const char* name, float x, float y, float z, float w, int set_current = 1, int set_initial = 0, float blend_time = 0.0f);
231  int set_variable_int(const char* name, int value, int set_current = 1, int set_initial = 0);
232 
233  int get_variable_float(const char* name, float* value, int get_current = 1);
234  int get_variable_vec2(const char* name, float* x, float* y, int get_current = 1);
235  int get_variable_vec3(const char* name, float* x, float* y, float* z, int get_current = 1);
236  int get_variable_vec4(const char* name, float* r, float* g, float* b, float* a, int get_current = 1);
237  int get_variable_int(const char* name, int* value, int get_current = 1);
238 
239 
240 /****************************************************************************/
241 /****************************************************************************/
242 /****************************************************************************/
254  /*l
255  *b Deprecated Functions: changed due to API restructuring
256  **
257  ** This function returns the shader program this shader instance is
258  ** associated with.
259  **
260  *b Returns:
261  **
262  ** pointer to type diguyGraphicsShaderProgram; should never be NULL
263  **
264  *b Callable From:
265  **
266  *- - C++
267  */
268  diguyGraphicsShaderProgram* get_shader_program();
269 /****************************************************************************/
270 /****************************************************************************/
271 /****************************************************************************/
272 
273  /*l
274  *b Description:
275  **
276  ** This function has been deprecated. Skinned matrices are now bound
277  ** at a per shape level.
278  **
279  ** This function returns the number of link matrices this instance
280  ** needs to support. This is useful to know when requesting
281  ** resources during shader initialization (e.g., requesting uniform
282  ** variable space).
283  **
284  ** This same number will be passed to update_link_matrices() and
285  ** bind_link_matrices().
286  **
287  *b Returns:
288  **
289  ** number of link matrices needed by this shader instance
290  **
291  *b Callable From:
292  **
293  *- - C++
294  */
295  int get_num_link_matrices();
296 
297  /*l
298  *b Description:
299  **
300  ** This function has been deprecated as of DI-Guy 12. Skinned
301  ** matrices are now updated at a per shape level.
302  **
303  ** This function will be called by DI-Guy when the matrix data of
304  ** a character's links needs to be updated. Scene graph renderers
305  ** will queue up this data to be sent to the graphics card at the
306  ** appropriate time.
307  **
308  ** Note that the format of the data in mat_data will be affected by
309  ** the bdiGraphicsInitGraphicsAPI variable
310  ** transpose_shader_matrices value.
311  **
312  *i Immediate Mode:
313  **
314  ** Immediate mode renderers usually do not override this function,
315  ** but instead use bind_link_matrices() during the Draw Stage.
316  **
317  *i Scene Graph:
318  **
319  ** Scene graph renderers usually do override this function.
320  **
321  *b Callable From:
322  **
323  *- - N/A (automatically called by DI-Guy Graphics API during
324  *- the Update Stage)
325  */
326  virtual int update_link_matrices(int num_matrices,
327  const float* mat_data);
328 
333 #ifdef CPLUSPLUS_ONLY
334  bdiShaderProgramInstance* get_internal_data() {return m_internal_data;}
335 
336 protected:
337 
338  /*l
339  ** A protected constructor. Constructors are called automatically
340  ** by DI-Guy.
341  */
342  diguyGraphicsShaderInstance(void* internal_data);
343 
344  /*l
345  ** A protected destructor. Destructors are called automatically
346  ** by DI-Guy.
347  */
348  virtual ~diguyGraphicsShaderInstance();
349 
350 private:
351 
352  /*l
353  ** A pointer to internal data.
354  */
355  bdiShaderProgramInstance* m_internal_data;
356 
357  friend class bdiShaderProgramInstance;
358  friend class bdiGeometryFactory;
359 #endif
360 };
361 
362 
363 #endif /* __diguyGraphicsShaderInstance_H */
364