DI-Guy SDK Documentation  13.7
diguyGraphicsState.h
Go to the documentation of this file.
1 /****************************************************************************
2  * Copyright (c) 2021 MAK Technologies, Inc.
3  * All rights reserved.
4  ****************************************************************************/
5 
6 /*********************************************************************/
13 #ifndef __diguyGraphicsState_H
14 #define __diguyGraphicsState_H
15 
16 #ifdef SWIG
17 %module diguyGraphicsState
18 #else
19 #define CPLUSPLUS_ONLY
20 #endif
21 
22 #ifdef CPLUSPLUS_ONLY
23 #include <diguy_constants.h>
24 #include <declspec_diguy.h>
25 
26 // needed for diguyTextureMapType
27 #include <diguyGraphicsTexture.h>
28 
29 class bdiGeometryGeosetState;
30 class diguyGraphicsState;
34 
35 #endif
36 
45 class BDI_DECLSPEC_diguy diguyGraphicsState
46 {
47 
48 public:
49 
50 /*****************************************************************************/
63  /*l
64  *b Description:
65  **
66  ** This function returns the material of this state. Specific
67  ** information about the material can then be accessed from
68  ** the returned object.
69  **
70  *b Returns:
71  **
72  ** object of type diguyGraphicsMaterial; NULL on failure
73  */
74  diguyGraphicsMaterial* get_material();
75 
76  /*l
77  *b Description:
78  **
79  ** This function returns the number of textures this state has.
80  **
81  *b Returns:
82  **
83  ** number of textures associated with this state
84  */
85  int get_num_textures();
86 
87  /*l
88  *b Description:
89  **
90  ** This function returns the nth texture of this state. Specific
91  ** information about the texture can then be accessed from
92  ** the returned object.
93  **
94  *b Returns:
95  **
96  ** object of type diguyGraphicsTexture; NULL on failure
97  */
98  diguyGraphicsTexture* get_texture(int texture_index = 0);
99 
100  /*l
101  *b Description:
102  **
103  ** This function returns the way that a texture is used in the state.
104  ** Possibilities include diffuse, specular, normal.
105  **
106  *b Returns:
107  **
108  ** diguyTextureMapType enum
109  */
110  diguyTextureMapType get_texture_type(int index) const;
111 
112  /*l
113  *b Description:
114  **
115  ** This function returns a bit-wise or'ed mask of available textures
116  ** in this state. Possibilities include DIGUY_TEXTURE_MAP_MASK_DIFFUSE,
117  ** DIGUY_TEXTURE_MAP_MASK_SPECULAR, DIGUY_TEXTURE_MAP_MASK_BUMP,
118  ** etc. See diguyTextureMapMasks enum for a complete list.
119  **
120  */
121  int get_textures_available() const;
122 
123  /*l
124  *b Description:
125  ** return Decal array
126  */
128  diguyGraphicsTextureArray* get_texture_array();
129  const diguyGraphicsTextureArray* get_texture_array() const;
131 
132  /*l
133  *b Description:
134  ** return Decal diffuse, specular or normal array
135  */
137  diguyGraphicsTextureArray* get_texture_array( diguyTextureMapType map_type );
138  const diguyGraphicsTextureArray* get_texture_array( diguyTextureMapType map_type ) const;
140 
141  /*l
142  *b Description:
143  **
144  ** This function returns whether either the material or texture of
145  ** this state contains an alpha component. States that have an alpha
146  ** component can make objects semi-transparent, which can affect when
147  ** said objects should be drawn.
148  **
149  *b Returns:
150  **
151  ** 1 if state contains an alpha component, 0 if not; -1 on failure
152  */
153  int get_contains_alpha_component() const;
154 
155  /*l
156  *b Description:
157  **
158  ** This function returns whether faces drawn with this state should
159  ** be lit or unlit.
160  **
161  *b Returns:
162  **
163  ** 1 if faces unlit, 0 if lit, -1 on failure
164  */
165  int get_is_unlit() const;
166 
167  /*l
168  *b Description:
169  **
170  ** This function frees most memory allocated by the DI-Guy geometry
171  ** loader for this object.
172  **
173  ** This function should only be called during or after the object's
174  ** build() function has been called. After it has been called, calls
175  ** to many accessor functions will fail.
176  */
177  void free_loader_memory();
178 
179 
180 
181 /*****************************************************************************/
193 #ifdef CPLUSPLUS_ONLY
194 
195  /*l
196  *b Description:
197  **
198  ** This function will be called by DI-Guy when it is time for a
199  ** renderer-specific state object to be created. A subclass of
200  ** this class isn't always necessary, particularly for immediate
201  ** mode renderers in which everything might be done in a subclass
202  ** of diguyGraphicsMaterial and a subclass of diguyGraphicsTexture.
203  **
204  *i Immediate Mode:
205  **
206  ** Immediate mode renderers usually do not override this function.
207  **
208  *i Scene Graph:
209  **
210  ** Scene graph renderers may override this function, to
211  ** create a state object that will be associated with
212  ** diguyGraphicsMesh objects.
213  **
214  ** The subclass version of this function may need to refer to
215  ** material and texture objects created by the build() calls
216  ** of subclasses of diguyGraphicsMaterial and
217  ** diguyGraphicsTexture objects.
218  **
219  *b Callable From:
220  **
221  *- - N/A (automatically called by DI-Guy Graphics API during
222  *- the Build Stage)
223  */
224  virtual void build();
225 
226  /*l
227  *b Description:
228  **
229  ** This function will be called by DI-Guy when it is time for a
230  ** renderer-specific state object to be destroyed.
231  **
232  *i Immediate Mode:
233  **
234  ** Immediate mode renderers may override this function, to
235  ** destroy any object that may have been created by build().
236  **
237  *i Scene Graph:
238  **
239  ** Scene graph renderers may override this function, to
240  ** destroy any object that may have been created by build().
241  **
242  *b Callable From:
243  **
244  *- - N/A (automatically called by DI-Guy Graphics API during
245  *- the Unbuild Stage)
246  */
247  virtual void unbuild();
248 
249  /*l
250  *b Description:
251  **
252  ** This function will be called by DI-Guy when the state should
253  ** be made active, or bound.
254  **
255  *i Immediate Mode:
256  **
257  ** Immediate mode renderers can override this function, but
258  ** may not need to. The material and texture of the state
259  ** will receive their own bind_now() calls.
260  **
261  *i Scene Graph:
262  **
263  ** Scene graph renderers usually do not override this function.
264  **
265  *b Callable From:
266  **
267  *- - N/A (automatically called by DI-Guy Graphics API during
268  *- Draw Stage)
269  */
270  virtual void bind_now();
271 
273  void bind(int texture_mask);
274 
275 #endif
276 
277 
278 /****************************************************************************/
279 /****************************************************************************/
280 
285 #ifdef CPLUSPLUS_ONLY
286 
287  bdiGeometryGeosetState* get_scripted_object() {return m_scripted_object;}
288 
289 protected:
290 
291  /*l
292  ** A protected constructor. Constructors are called automatically
293  ** by DI-Guy.
294  */
295  diguyGraphicsState(void* internal_data);
296 
297  /*l
298  ** A protected destructor. Destructors are called automatically
299  ** by DI-Guy.
300  */
301  virtual ~diguyGraphicsState();
302 
303 private:
304 
305  /*l
306  ** A pointer to internal data.
307  */
308  bdiGeometryGeosetState* m_scripted_object;
309 
310  friend class bdiGeometryGeosetState;
311  friend class bdiGeometryFactory;
312 
313 #endif
314 };
315 
316 
317 #endif /* __diguyGraphicsState_H */
318 
A class that represents a shared material/textures combination.
Definition: diguyGraphicsState.h:44
A class that represents a shared texture.
Definition: diguyGraphicsTexture.h:124
A class that represents a shared material.
Definition: diguyGraphicsMaterial.h:42
A class that represents a shared 2D texture array.
Definition: diguyGraphicsTextureArray.h:40
diguyTextureMapType
This enumeration lists the type of texture map a given image file is being used as.
Definition: diguyGraphicsTexture.h:55