DI-Guy SDK Documentation  13.5
diguy_graphics_ogl.h
Go to the documentation of this file.
1 
2 /*********************************************************************
3  ** Copyright (c) 1992-2020 MAK Technologies, Inc.
4  ** All rights reserved.
5  *********************************************************************/
6 
7 /*********************************************************************
8  **
9  *t DI-Guy API, OpenGL Graphics Module
10  **
11  *b Link against: libdiguy_graphics_ogl
12  */
13 
14 #ifndef __diguy_graphics_ogl_H
15 #define __diguy_graphics_ogl_H
16 
17 #include <diguy_api.h>
19 
21 
22 #ifdef __cplusplus
23 extern "C" {
24 
25 class diguyScenario;
26 class diguyViewLight;
27 #endif
28 
29 
30 /*****************************************************************************
31  **
32  *2 Functions
33  **
34  */
35 
36 /*l
37  *b Description:
38  **
39  ** This function initializes the DI-Guy Runtime API for the
40  ** OpenGL environment.
41  **
42  *i This function should only be called once per program execution.
43  *i Do not call this function again, even after calling
44  *i diguy_deinitialize().
45  **
46  ** Use diguy_ogl_get_defaults() to fill out the init structure before
47  ** changing specific entries.
48  **
49  *b Arguments:
50  **
51  *a init - pointer to type bdiGraphicsInitOgl; passing NULL will cause
52  *a defaults to be used for all values
53  **
54  *b Returns:
55  **
56  ** 0 on success, non-zero error code on failure
57  **
58  ** Refer to diguy_constants.h for error code values.
59  */
60 BDI_DECLSPEC_diguy_graphics int
62 
63 /*l
64  *b Description:
65  **
66  ** Fills out the init structure with default values. Selected entries can
67  ** then be changed before calling diguy_ogl_initialize().
68  **
69  *b Arguments:
70  **
71  *a init - pointer to type bdiGraphicsInitOgl
72  **
73  *b Returns:
74  **
75  ** 0 on success, -1 on failure
76  */
77 BDI_DECLSPEC_diguy_graphics int
79 
80 
81 /*l
82  *b Description:
83  **
84  ** This function is the default fire intersection function. It uses a
85  ** minimal render of the scene and characters into the back buffer to fill
86  ** out the impact structure.
87  **
88  ** It may be useful to combine your intersection results with the results
89  ** from this function.
90  */
91 BDI_DECLSPEC_diguy_graphics
93  float from_x,
94  float from_y,
95  float from_z,
96  float to_x,
97  float to_y,
98  float to_z,
100 
101 
102 /****************************************************************************/
103 /****************************************************************************/
104 /*****************************************************************************
105  **
106  *2 Experimental Functions
107  **
108  ** The following functions are experimental and may change or
109  ** disappear with no warning.
110  */
111 /****************************************************************************/
112 /****************************************************************************/
113 /****************************************************************************/
114 
115 #ifdef CPLUSPLUS_ONLY
116 
117 /*l
118  *b Description:
119  **
120  ** This function queries the character for the OpenGL texture
121  ** objects it is using and stores them in an internal list. This
122  ** internal list can then be accessed via the following functions:
123  **
124  *e diguy_ogl_get_character_texture_list_num_textures();
125  *e diguy_ogl_get_character_texture_list_texture_object_at_index();
126  *e diguy_ogl_get_character_texture_list_texture_filename_at_index();
127  **
128  ** The function diguy_ogl_release_character_texture_list() should
129  ** be called once query calls are complete to avoid a resource leak.
130  **
131  ** Note that there is currently only one internal texture list; there
132  ** are not separate lists per character. Calling this function again,
133  ** even with a different scenario pointer and/or character index, will
134  ** clobber the previous texture list.
135  **
136  *b Arguments:
137  **
138  *a scenario - pointer to character's scenario
139  *a character_index - index of character to be queried
140  **
141  *b Returns:
142  **
143  ** 0 on success, -1 on failure
144  **
145  *b C++ Example:
146  **
147  *e diguy_ogl_generate_character_texture_list(scenario,
148  *e character_index);
149  *e
150  *e int texture_count = diguy_ogl_get_character_texture_list_num_textures(scenario,
151  *e character_index);
152  *e
153  *e if (texture_count > 0)
154  *e {
155  *e int texture_index;
156  *e
157  *e for (texture_index = 0;
158  *e texture_index < texture_count;
159  *e texture_index++)
160  *e {
161  *e GLuint texture_object = diguy_ogl_get_character_texture_list_texture_object_at_index(scenario,
162  *e character_index,
163  *e texture_index);
164  *e
165  *e const char* texture_filename = diguy_ogl_get_character_texture_list_texture_filename_at_index(scenario,
166  *e character_index,
167  *e texture_index);
168  *e
169  *e bdi_log_printf(BDI_LOG_WARN, "\ttexture object = %ld, filename = %s\n",
170  *e texture_object,
171  *e texture_filename);
172  *e }
173  *e
174  *e GLuint texture_object = diguy_ogl_get_character_texture_list_texture_object_at_index(scenario,
175  *e character_index,
176  *e 0); // the first texture in the list
177  *e
178  *e //
179  *e // (Code to override/replace the texture)
180  *e //
181  *e
182  *e diguy_ogl_set_character_texture_objects_modified(scenario,
183  *e character_index);
184  *e
185  *e diguy_ogl_release_character_texture_list(scenario,
186  *e character_index);
187  *e }
188  */
189 BDI_DECLSPEC_diguy_graphics
191  int character_index);
192 
193 /*l
194  *b Description:
195  **
196  ** This function releases a texture list generated by
197  ** diguy_ogl_generate_character_texture_list().
198  **
199  *b Arguments:
200  **
201  *a scenario - pointer to character's scenario
202  *a character_index - index of character to be queried
203  **
204  *b Returns:
205  **
206  ** 0 on success, -1 on failure
207  **
208  */
209 BDI_DECLSPEC_diguy_graphics
211  int character_index);
212 
213 /*l
214  *b Description:
215  **
216  ** This function returns the number of textures used by the specified
217  ** character.
218  **
219  ** The function diguy_ogl_generate_character_texture_list() must be
220  ** called before this function. The scenario and character_index
221  ** arguments passed to this function must match those passed to the
222  ** generate function.
223  **
224  *b Arguments:
225  **
226  *a scenario - pointer to character's scenario
227  *a character_index - index of character to be queried
228  **
229  *b Returns:
230  **
231  ** number of textures in texture list
232  **
233  */
234 BDI_DECLSPEC_diguy_graphics
236  int character_index);
237 
238 /*l
239  *b Description:
240  **
241  ** This function returns the OpenGL texture object at the specified
242  ** index.
243  **
244  ** The function diguy_ogl_generate_character_texture_list() must be
245  ** called before this function. The scenario and character_index
246  ** arguments passed to this function must match those passed to the
247  ** generate function.
248  **
249  *b Arguments:
250  **
251  *a scenario - pointer to character's scenario
252  *a character_index - index of character to be queried
253  *a texture_list_index - index of texture in texture list
254  **
255  *b Returns:
256  **
257  ** OpenGL texture object
258  **
259  */
260 BDI_DECLSPEC_diguy_graphics
262  int character_index,
263  int texture_list_index);
264 
265 /*l
266  *b Description:
267  **
268  ** This function returns the filename of the texture at the specified
269  ** index.
270  **
271  ** The function diguy_ogl_generate_character_texture_list() must be
272  ** called before this function. The scenario and character_index
273  ** arguments passed to this function must match those passed to the
274  ** generate function.
275  **
276  *b Arguments:
277  **
278  *a scenario - pointer to character's scenario
279  *a character_index - index of character to be queried
280  *a texture_list_index - index of texture in texture list
281  **
282  *b Returns:
283  **
284  ** filename of the texture
285  **
286  */
287 BDI_DECLSPEC_diguy_graphics
289  int character_index,
290  int texture_list_index);
291 
292 /*l
293  *b Description:
294  **
295  ** This function notifies the character that its texture objects have
296  ** been modified and that it should take any steps necessary to update
297  ** its internal state to ensure proper display.
298  **
299  *b Arguments:
300  **
301  *a scenario - pointer to character's scenario
302  *a character_index - index of character to be queried
303  **
304  *b Returns:
305  **
306  ** 0 on success, -1 on failure
307  **
308  */
309 BDI_DECLSPEC_diguy_graphics
311  int character_index);
312 
313 
314 
315 /*l
316  *b Description:
317  **
318  ** This function turns far position rendering on or off. See
319  ** diguyViewCamera for more information on far positions.
320  **
321  *b Arguments:
322  **
323  *a val - pass 1 to use far positions, 0 to not use them
324  **
325  */
326 BDI_DECLSPEC_diguy_graphics
327 void diguy_ogl_set_use_far_positions(int val);
328 
329 /*l
330  *b Returns:
331  **
332  ** 1 if far positions are in use, else 0
333  */
334 BDI_DECLSPEC_diguy_graphics
336 
337 /*l
338  *b Description:
339  **
340  ** This function sets the shader source files that will be used for the
341  ** specified shader.
342  **
343  ** The default filenames for the "diguy_character" shader are
344  ** "diguy_character_glsl.vert" and "diguy_character_glsl.frag".
345  **
346  *b Arguments:
347  **
348  *a shader_name - name with which vertex/pixel shader pair can be
349  *a referenced
350  *a vert_filename - name of vertex shader source file
351  *a pixel_filename - name of pixel (fragment) shader source file
352  **
353  */
354 BDI_DECLSPEC_diguy_graphics
355 void diguy_ogl_set_default_shader_source_files(const char* shader_name,
356  const char* vert_filename,
357  const char* pixel_filename);
358 
359 
360 /*l
361  *b Description:
362  **
363  ** Applies active lights to the OpenGL state, also updates default shader uniforms
364  ** and calls diguyScenario::set_num_active_point_lights()
365  **
366  *b Returns:
367  **
368  ** The number of active lights
369  **/
370 //BDI_DECLSPEC_diguy_graphics
371 //int diguy_ogl_apply_active_lights(diguyScenario* scenario);
372 
373 
374 /****************************************************************************/
375 /****************************************************************************/
376 /*****************************************************************************
377  **
378  *2 Experimental Heads-Up Display Functions
379  **
380  ** The following functions are experimental and may change or
381  ** disappear with no warning.
382  */
383 /****************************************************************************/
384 /****************************************************************************/
385 /****************************************************************************/
386 
387 BDI_DECLSPEC_diguy_graphics
388 int diguy_ogl_2d_set_color(float r, float g, float b, float a);
389 
390 BDI_DECLSPEC_diguy_graphics
391 int diguy_ogl_2d_draw_filled_rect(int x0, int y0, int x1, int y1);
392 
393 BDI_DECLSPEC_diguy_graphics
395 
396 BDI_DECLSPEC_diguy_graphics
398 
399 BDI_DECLSPEC_diguy_graphics
400 int diguy_ogl_2d_draw_text(int x, int y, const char* text);
401 
402 BDI_DECLSPEC_diguy_graphics
403 int diguy_ogl_2d_get_text_width(const char* text);
404 
405 BDI_DECLSPEC_diguy_graphics
406 int diguy_ogl_2d_get_text_height(const char* text);
407 
408 BDI_DECLSPEC_diguy_graphics
410 
411 BDI_DECLSPEC_diguy_graphics
413 
414 
415 /*****************************************************************************
416  **
417  *2 Experimental frame stats API
418  **
419  ** Currently available stats:
420  *>
421  *- - "characters_drawn"
422  *- - "links_drawn"
423  *- - "shapes_drawn"
424  *- - "nodes_drawn"
425  *- - "mats_bound"
426  *- - "groups_drawn"
427  *- - "textures_bound"
428  *- - "vbos_drawn"
429  *- - "rigid_vbos_drawn",
430  *- - "skinned_vbos_drawn"
431  *- - "tris_drawn"
432  *- - "verts_drawn"
433  *<
434  ** Stats should be cleared once a frame to get accurate results.
435  */
436 BDI_DECLSPEC_diguy_graphics
438 
439 BDI_DECLSPEC_diguy_graphics
440 const char* diguy_ogl_frame_stat_name(int index);
441 
442 BDI_DECLSPEC_diguy_graphics
443 int diguy_ogl_get_frame_stat(const char* stat_name);
444 
445 BDI_DECLSPEC_diguy_graphics
447 
448 BDI_DECLSPEC_diguy_graphics
449 int diguy_ogl_draw_frame_stats(int sx, int sy);
450 
451 
452 #endif // CPLUSPLUS_ONLY
453 
454 #ifdef __cplusplus
455 }
456 #endif
457 
458 
459 #endif /* __diguy_graphics_ogl_H */
460 
461 
462 /*********************************************************************
463  ** Copyright (c) 1992-2020 MAK Technologies, Inc.
464  ** All rights reserved.
465  *********************************************************************/
466 
int diguy_ogl_draw_frame_stats(int sx, int sy)
int diguy_ogl_clear_all_frame_stats()
int diguy_ogl_release_character_texture_list(diguyScenario *scenario, int character_index)
This function releases a texture list generated by diguy_ogl_generate_character_texture_list().
void diguy_ogl_set_use_far_positions(int val)
This function turns far position rendering on or off.
Definition: diguyViewLight.h:55
int diguy_ogl_2d_get_text_width(const char *text)
A class that represents a bullet impact in the world, often used by AIs to make reaction decisions...
Definition: diguyImpact.h:41
int diguy_ogl_get_fbo_texture_id()
GLuint diguy_ogl_get_character_texture_list_texture_object_at_index(diguyScenario *scenario, int character_index, int texture_list_index)
This function returns the OpenGL texture object at the specified index.
int diguy_ogl_get_use_far_positions()
Returns: 1 if far positions are in use, else 0.
int diguy_default_fire_weapon_intersection_function(diguyImpact *impact, float from_x, float from_y, float from_z, float to_x, float to_y, float to_z, diguyScenario *scenario)
This function is the default fire intersection function.
Definition: diguyOglUtils.cpp:366
Definition: graphics_init_ogl.h:21
int diguy_ogl_begin_2d_text_mode()
void diguy_ogl_set_default_shader_source_files(const char *shader_name, const char *vert_filename, const char *pixel_filename)
This function sets the shader source files that will be used for the specified shader.
Represents the scenario currently being portrayed.
Definition: diguyScenario.h:100
int diguy_ogl_get_frame_stat(const char *stat_name)
int diguy_ogl_2d_get_text_height(const char *text)
const char * diguy_ogl_frame_stat_name(int index)
int diguy_ogl_2d_draw_filled_rect(int x0, int y0, int x1, int y1)
int diguy_ogl_get_num_frame_stats()
int diguy_ogl_reload_changed_textures()
int diguy_ogl_generate_character_texture_list(diguyScenario *scenario, int character_index)
This function queries the character for the OpenGL texture objects it is using and stores them in an ...
int diguy_ogl_initialize(bdiGraphicsInitOgl *init)
This function initializes the DI-Guy Runtime API for the OpenGL environment.
int diguy_ogl_2d_draw_text(int x, int y, const char *text)
int diguy_ogl_set_character_texture_objects_modified(diguyScenario *scenario, int character_index)
This function notifies the character that its texture objects have been modified and that it should t...
int diguy_ogl_end_2d_mode()
static diguyScenario * scenario
Definition: simple_playback_ogl.cpp:56
int diguy_ogl_get_character_texture_list_num_textures(diguyScenario *scenario, int character_index)
This function returns the number of textures used by the specified character.
int diguy_ogl_2d_set_color(float r, float g, float b, float a)
Applies active lights to the OpenGL state, also updates default shader uniforms and calls diguyScenar...
int diguy_ogl_get_defaults(bdiGraphicsInitOgl *init)
Fills out the init structure with default values.
const char * diguy_ogl_get_character_texture_list_texture_filename_at_index(diguyScenario *scenario, int character_index, int texture_list_index)
This function returns the filename of the texture at the specified index.