DI-Guy SDK Documentation  13.6
diguyGraphicsShaderInstance.h
Go to the documentation of this file.
1 
2 /*********************************************************************
3  ** Copyright (c) 1992-2022 MAK Technologies, Inc.
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  diguyGraphicsShaderTechnique* get_shader_technique();
83 
84 
85  /*l
86  *b Description:
87  **
88  ** This function returns a pointer to the character that this shader
89  ** instance is associated with.
90  **
91  *b Returns:
92  **
93  ** pointer to type diguyCharacter; may be NULL
94  */
95  diguyCharacter* get_character();
96 
97 
98 /*****************************************************************************/
110 #ifdef CPLUSPLUS_ONLY
111 
112  /*l
113  *b Description:
114  **
115  ** This function will be called by DI-Guy when it is time for the
116  ** object that this shader instance is attached to to be rendered.
117  ** This happens during the Draw Stage, just before the geometry of a
118  ** character or scene object is to be rendered.
119  **
120  ** Any instance level shader control variables should be set in this
121  ** function. Instance level variables will affect only shader
122  ** operations in which this instance is active. Variables that
123  ** should affect the overall program of a shader should be set in
124  ** diguyGraphicsShaderProgram::bind().
125  **
126  *i Immediate Mode:
127  **
128  ** Immediate mode renderers usually do override this function.
129  **
130  *i Scene Graph:
131  **
132  ** Scene graph renderers usually do not override this function; the
133  ** renderer will typically do this internally. If shader variables
134  ** need to be bound, however, this function should be overridden.
135  **
136  *b Callable From:
137  **
138  *- - N/A (automatically called by DI-Guy Graphics API during
139  *- the Draw Stage)
140  */
141  virtual int bind();
142 
143  /*l
144  *b Description:
145  **
146  ** This function will be called by DI-Guy when the object this shader
147  ** is attached to is done being rendered.
148  **
149  ** This happens during the Draw Stage, just after the geometry of a
150  ** character has been rendered.
151  **
152  ** Any shader variables bound in bind() should be unbound here.
153  **
154  *i Immediate Mode:
155  **
156  ** Immediate mode renderers usually do override this function.
157  **
158  *i Scene Graph:
159  **
160  ** Scene graph renderers usually do not override this function; the
161  ** renderer will typically do this internally. If the bind()
162  ** function was overridden, however, this function probably should
163  ** be, too.
164  **
165  *b Callable From:
166  **
167  *- - N/A (automatically called by DI-Guy Graphics API during
168  *- the Draw Stage)
169  */
170  virtual int unbind();
171 
172 #endif
173 
174 
175 /*****************************************************************************/
189  int get_num_variables();
190  const char* get_variable_name_at_index(int index);
191  int has_variable(const char* name);
192  const char* get_variable_type(const char* name);
193 
194  void reset_variables_to_initial_values();
195  void reset_variables_to_program_defaults();
196 
197  int set_variable_float(const char* name, float value, int set_current = 1, int set_initial = 0, float blend_time = 0.0f);
198  int set_variable_vec2(const char* name, float x, float y, int set_current = 1, int set_initial = 0, float blend_time = 0.0f);
199  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);
200  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);
201  int set_variable_int(const char* name, int value, int set_current = 1, int set_initial = 0);
202 
203  int get_variable_float(const char* name, float* value, int get_current = 1);
204  int get_variable_vec2(const char* name, float* x, float* y, int get_current = 1);
205  int get_variable_vec3(const char* name, float* x, float* y, float* z, int get_current = 1);
206  int get_variable_vec4(const char* name, float* r, float* g, float* b, float* a, int get_current = 1);
207  int get_variable_int(const char* name, int* value, int get_current = 1);
208 
209 
210 /****************************************************************************/
211 /****************************************************************************/
212 /****************************************************************************/
224  /*l
225  *b Deprecated Functions: changed due to API restructuring
226  **
227  ** This function returns the shader program this shader instance is
228  ** associated with.
229  **
230  *b Returns:
231  **
232  ** pointer to type diguyGraphicsShaderProgram; should never be NULL
233  */
234  diguyGraphicsShaderProgram* get_shader_program();
235 
236 
237 
242 #ifdef CPLUSPLUS_ONLY
243  bdiShaderProgramInstance* get_internal_data() {return m_internal_data;}
244 
245 protected:
246 
247  /*l
248  ** A protected constructor. Constructors are called automatically
249  ** by DI-Guy.
250  */
251  diguyGraphicsShaderInstance(void* internal_data);
252 
253  /*l
254  ** A protected destructor. Destructors are called automatically
255  ** by DI-Guy.
256  */
257  virtual ~diguyGraphicsShaderInstance();
258 
259 private:
260 
261  /*l
262  ** A pointer to internal data.
263  */
264  bdiShaderProgramInstance* m_internal_data;
265 
266  friend class bdiShaderProgramInstance;
267  friend class bdiGeometryFactory;
268 #endif
269 };
270 
271 
272 #endif /* __diguyGraphicsShaderInstance_H */
273 
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:82
This class implements shader lod system for use with DI-Guy character graphics.
Definition: diguyGraphicsShaderTechnique.h:154
This class implements shader programs for use with DI-Guy character graphics.
Definition: diguyGraphicsShaderProgram.h:94