C++ SDK Reference  12.5
 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-2013 Boston Dynamics
4  * ALL RIGHTS RESERVED.
5  *
6  * These coded instructions, statements, and computer programs
7  * contain unpublished proprietary information of Boston Dynamics
8  * and are protected by Copyright Laws of the United States.
9  * They may not be used, duplicated, or disclosed in any form, in
10  * whole or in part, without the prior written consent from Boston
11  * Dynamics.
12  *
13  * RESTRICTED RIGHTS LEGEND
14  * Use, duplication, or disclosure by the government is subject
15  * to restrictions as set forth in FAR 52.227.19(c)(2) or
16  * subparagraph (c)(1)(ii) of the Rights in Technical Data and
17  * Computer Software clause at DFARS 252.227-7013 and/or in
18  * similar or successor clauses in the FAR, or the DOD or NASA
19  * FAR Supplement, or to subparagraphs (c)(1) and (c)(2) of the
20  * Commercial Computer Software--Restricted Rights at 48 CFR
21  * 52.227-19, as applicable. Unpublished-rights reserved under
22  * the Copyright Laws of the United States.
23  * Contractor/Manufacturer is:
24  * Boston Dynamics/78 Fourth Avenue/Waltham MA 02451.
25  */
26 
27 /*********************************************************************/
34 #ifndef __diguyGraphicsShaderInstance_H
35 #define __diguyGraphicsShaderInstance_H
36 
37 #ifdef SWIG
39 #else
40 #define CPLUSPLUS_ONLY
41 #endif
42 
43 #ifdef CPLUSPLUS_ONLY
44 #include <diguy_constants.h>
45 #include <declspec_diguy.h>
46 
50 class diguyCharacter;
51 class bdiShaderProgramInstance;
52 
53 /****************************************************************************/
54 
55 #endif
56 
57 
58 /****************************************************************************/
75 class BDI_DECLSPEC_diguy diguyGraphicsShaderInstance
76 {
77 
78 public:
79 
80 /*****************************************************************************/
90  /*l
91  *b Description:
92  **
93  ** This function returns the shader technique this shader instance is
94  ** associated with.
95  **
96  *b Returns:
97  **
98  ** pointer to type diguyGraphicsShaderTechnique; should never be NULL
99  **
100  *b Callable From:
101  **
102  *- - C++
103  */
104  diguyGraphicsShaderTechnique* get_shader_technique();
105 
106 
107 #ifdef CPLUSPLUS_ONLY
108 
109  /*l
110  *b Description:
111  **
112  ** This function returns a pointer to shader matrix data. This is
113  ** the same pointer that is passed into bind_link_matrices().
114  **
115  ** The returned pointer should not be cached for later used, as it
116  ** may change multiple times during the lifetime of this shader
117  ** instance.
118  **
119  *b Returns:
120  **
121  ** pointer to first value in array of floats
122  **
123  *b Callable From:
124  **
125  *- - C++
126  */
127  const float* get_shader_matrix_data_ptr();
128 
129 #endif
130 
131  /*l
132  *b Description:
133  **
134  ** This function returns a pointer to the character that this shader
135  ** instance is associated with.
136  **
137  *b Returns:
138  **
139  ** pointer to type diguyCharacter; may be NULL
140  **
141  *b Callable From:
142  **
143  *- - C++
144  */
145  diguyCharacter* get_character();
146 
147 
148 /*****************************************************************************/
160 #ifdef CPLUSPLUS_ONLY
161 
162  /*l
163  *b Description:
164  **
165  ** This function will be called by DI-Guy when it is time for the
166  ** object that this shader instance is attached to to be rendered.
167  ** This happens during the Draw Stage, just before the geometry of a
168  ** character or scene object is to be rendered.
169  **
170  ** Any instance level shader control variables should be set in this
171  ** function. Instance level variables will affect only shader
172  ** operations in which this instance is active. Variables that
173  ** should affect the overall program of a shader should be set in
174  ** diguyGraphicsShaderProgram::bind().
175  **
176  *i Immediate Mode:
177  **
178  ** Immediate mode renderers usually do override this function.
179  **
180  *i Scene Graph:
181  **
182  ** Scene graph renderers usually do not override this function; the
183  ** renderer will typically do this internally. If shader variables
184  ** need to be bound, however, this function should be overridden.
185  **
186  *b Callable From:
187  **
188  *- - N/A (automatically called by DI-Guy Graphics API during
189  *- the Draw Stage)
190  */
191  virtual int bind();
192 
193  /*l
194  *b Description:
195  **
196  ** This function will be called by DI-Guy when the object this shader
197  ** is attached to is done being rendered.
198  **
199  ** This happens during the Draw Stage, just after the geometry of a
200  ** character has been rendered.
201  **
202  ** Any shader variables bound in bind() should be unbound here.
203  **
204  *i Immediate Mode:
205  **
206  ** Immediate mode renderers usually do override this function.
207  **
208  *i Scene Graph:
209  **
210  ** Scene graph renderers usually do not override this function; the
211  ** renderer will typically do this internally. If the bind()
212  ** function was overridden, however, this function probably should
213  ** be, too.
214  **
215  *b Callable From:
216  **
217  *- - N/A (automatically called by DI-Guy Graphics API during
218  *- the Draw Stage)
219  */
220  virtual int unbind();
221 
222 #endif
223 
224 
225 /*****************************************************************************/
239  int get_num_variables();
240  const char* get_variable_name_at_index(int index);
241  int has_variable(const char* name);
242  const char* get_variable_type(const char* name);
243 
244  void reset_variables_to_initial_values();
245  void reset_variables_to_program_defaults();
246 
247  int set_variable_float(const char* name, float value, int set_current = 1, int set_initial = 0, float blend_time = 0.0f);
248  int set_variable_vec2(const char* name, float x, float y, int set_current = 1, int set_initial = 0, float blend_time = 0.0f);
249  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);
250  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);
251  int set_variable_int(const char* name, int value, int set_current = 1, int set_initial = 0);
252 
253  int get_variable_float(const char* name, float* value, int get_current = 1);
254  int get_variable_vec2(const char* name, float* x, float* y, int get_current = 1);
255  int get_variable_vec3(const char* name, float* x, float* y, float* z, int get_current = 1);
256  int get_variable_vec4(const char* name, float* r, float* g, float* b, float* a, int get_current = 1);
257  int get_variable_int(const char* name, int* value, int get_current = 1);
258 
259 
260 /****************************************************************************/
261 /****************************************************************************/
262 /****************************************************************************/
274  /*l
275  *b Deprecated Functions: changed due to API restructuring
276  **
277  ** This function returns the shader program this shader instance is
278  ** associated with.
279  **
280  *b Returns:
281  **
282  ** pointer to type diguyGraphicsShaderProgram; should never be NULL
283  **
284  *b Callable From:
285  **
286  *- - C++
287  */
288  diguyGraphicsShaderProgram* get_shader_program();
289 /****************************************************************************/
290 /****************************************************************************/
291 /****************************************************************************/
292 
293  /*l
294  *b Description:
295  **
296  ** This function has been deprecated. Skinned matrices are now bound
297  ** at a per shape level.
298  **
299  ** This function returns the number of link matrices this instance
300  ** needs to support. This is useful to know when requesting
301  ** resources during shader initialization (e.g., requesting uniform
302  ** variable space).
303  **
304  ** This same number will be passed to update_link_matrices() and
305  ** bind_link_matrices().
306  **
307  *b Returns:
308  **
309  ** number of link matrices needed by this shader instance
310  **
311  *b Callable From:
312  **
313  *- - C++
314  */
315  int get_num_link_matrices();
316 
317  /*l
318  *b Description:
319  **
320  ** This function has been deprecated as of DI-Guy 12. Skinned
321  ** matrices are now updated at a per shape level.
322  **
323  ** This function will be called by DI-Guy when the matrix data of
324  ** a character's links needs to be updated. Scene graph renderers
325  ** will queue up this data to be sent to the graphics card at the
326  ** appropriate time.
327  **
328  ** Note that the format of the data in mat_data will be affected by
329  ** the bdiGraphicsInitGraphicsAPI variable
330  ** transpose_shader_matrices value.
331  **
332  *i Immediate Mode:
333  **
334  ** Immediate mode renderers usually do not override this function,
335  ** but instead use bind_link_matrices() during the Draw Stage.
336  **
337  *i Scene Graph:
338  **
339  ** Scene graph renderers usually do override this function.
340  **
341  *b Callable From:
342  **
343  *- - N/A (automatically called by DI-Guy Graphics API during
344  *- the Update Stage)
345  */
346  virtual int update_link_matrices(int num_matrices,
347  const float* mat_data);
348 
353 #ifdef CPLUSPLUS_ONLY
354  bdiShaderProgramInstance* get_internal_data() {return m_internal_data;}
355 
356 protected:
357 
358  /*l
359  ** A protected constructor. Constructors are called automatically
360  ** by DI-Guy.
361  */
362  diguyGraphicsShaderInstance(void* internal_data);
363 
364  /*l
365  ** A protected destructor. Destructors are called automatically
366  ** by DI-Guy.
367  */
368  virtual ~diguyGraphicsShaderInstance();
369 
370 private:
371 
372  /*l
373  ** A pointer to internal data.
374  */
375  bdiShaderProgramInstance* m_internal_data;
376 
377  friend class bdiShaderProgramInstance;
378  friend class bdiGeometryFactory;
379 #endif
380 };
381 
382 
383 #endif /* __diguyGraphicsShaderInstance_H */
384