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