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