C++ SDK Reference  12.5
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
diguy_graphics_ogl.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 /*********************************************************************
28  **
29  *t DI-Guy API, OpenGL Graphics Module
30  **
31  *b Link against: libdiguy_graphics_ogl
32  */
33 
34 #ifndef __diguy_graphics_ogl_H
35 #define __diguy_graphics_ogl_H
36 
37 #include <diguy_api.h>
39 
41 
42 #ifdef __cplusplus
43 extern "C" {
44 
45 class diguyScenario;
46 class diguyViewLight;
47 #endif
48 
49 
50 /*****************************************************************************
51  **
52  *2 Functions
53  **
54  */
55 
56 /*l
57  *b Description:
58  **
59  ** This function initializes the DI-Guy Runtime API for the
60  ** OpenGL environment.
61  **
62  *i This function should only be called once per program execution.
63  *i Do not call this function again, even after calling
64  *i diguy_deinitialize().
65  **
66  ** Use diguy_ogl_get_defaults() to fill out the init structure before
67  ** changing specific entries.
68  **
69  *b Arguments:
70  **
71  *a init - pointer to type bdiGraphicsInitOgl; passing NULL will cause
72  *a defaults to be used for all values
73  **
74  *b Returns:
75  **
76  ** 0 on success, non-zero error code on failure
77  **
78  ** Refer to diguy_constants.h for error code values.
79  */
80 BDI_DECLSPEC_diguy_graphics int
82 
83 /*l
84  *b Description:
85  **
86  ** Fills out the init structure with default values. Selected entries can
87  ** then be changed before calling diguy_ogl_initialize().
88  **
89  *b Arguments:
90  **
91  *a init - pointer to type bdiGraphicsInitOgl
92  **
93  *b Returns:
94  **
95  ** 0 on success, -1 on failure
96  */
97 BDI_DECLSPEC_diguy_graphics int
99 
100 
101 /*l
102  * Documentation Pending.
103  **
104  *b Description:
105  **
106  ** This function is the default fire intersection function. It uses a
107  ** minimal render of the scene and characters into the back buffer to fill
108  ** out the impact structure.
109  **
110  ** It may be useful to combine your intersection results with the results
111  ** from this function.
112  */
113 BDI_DECLSPEC_diguy_graphics
115  float from_x,
116  float from_y,
117  float from_z,
118  float to_x,
119  float to_y,
120  float to_z,
121  diguyScenario* scenario);
122 
123 
124 /****************************************************************************/
125 /****************************************************************************/
126 /*****************************************************************************
127  **
128  *2 Experimental Functions
129  **
130  ** The following functions are experimental and may change or
131  ** disappear with no warning.
132  */
133 /****************************************************************************/
134 /****************************************************************************/
135 /****************************************************************************/
136 
137 #ifdef CPLUSPLUS_ONLY
138 
139 /*l
140  *b Description:
141  **
142  ** This function queries the character for the OpenGL texture
143  ** objects it is using and stores them in an internal list. This
144  ** internal list can then be accessed via the following functions:
145  **
146  *e diguy_ogl_get_character_texture_list_num_textures();
147  *e diguy_ogl_get_character_texture_list_texture_object_at_index();
148  *e diguy_ogl_get_character_texture_list_texture_filename_at_index();
149  **
150  ** The function diguy_ogl_release_character_texture_list() should
151  ** be called once query calls are complete to avoid a resource leak.
152  **
153  ** Note that there is currently only one internal texture list; there
154  ** are not separate lists per character. Calling this function again,
155  ** even with a different scenario pointer and/or character index, will
156  ** clobber the previous texture list.
157  **
158  *b Arguments:
159  **
160  *a scenario - pointer to character's scenario
161  *a character_index - index of character to be queried
162  **
163  *b Returns:
164  **
165  ** 0 on success, -1 on failure
166  **
167  *b C++ Example:
168  **
169  *e diguy_ogl_generate_character_texture_list(scenario,
170  *e character_index);
171  *e
172  *e int texture_count = diguy_ogl_get_character_texture_list_num_textures(scenario,
173  *e character_index);
174  *e
175  *e if (texture_count > 0)
176  *e {
177  *e int texture_index;
178  *e
179  *e for (texture_index = 0;
180  *e texture_index < texture_count;
181  *e texture_index++)
182  *e {
183  *e GLuint texture_object = diguy_ogl_get_character_texture_list_texture_object_at_index(scenario,
184  *e character_index,
185  *e texture_index);
186  *e
187  *e const char* texture_filename = diguy_ogl_get_character_texture_list_texture_filename_at_index(scenario,
188  *e character_index,
189  *e texture_index);
190  *e
191  *e bdi_log_printf(BDI_LOG_WARN, "\ttexture object = %ld, filename = %s\n",
192  *e texture_object,
193  *e texture_filename);
194  *e }
195  *e
196  *e GLuint texture_object = diguy_ogl_get_character_texture_list_texture_object_at_index(scenario,
197  *e character_index,
198  *e 0); // the first texture in the list
199  *e
200  *e //
201  *e // (Code to override/replace the texture)
202  *e //
203  *e
204  *e diguy_ogl_set_character_texture_objects_modified(scenario,
205  *e character_index);
206  *e
207  *e diguy_ogl_release_character_texture_list(scenario,
208  *e character_index);
209  *e }
210  */
211 BDI_DECLSPEC_diguy_graphics
213  int character_index);
214 
215 /*l
216  *b Description:
217  **
218  ** This function releases a texture list generated by
219  ** diguy_ogl_generate_character_texture_list().
220  **
221  *b Arguments:
222  **
223  *a scenario - pointer to character's scenario
224  *a character_index - index of character to be queried
225  **
226  *b Returns:
227  **
228  ** 0 on success, -1 on failure
229  **
230  */
231 BDI_DECLSPEC_diguy_graphics
233  int character_index);
234 
235 /*l
236  *b Description:
237  **
238  ** This function returns the number of textures used by the specified
239  ** character.
240  **
241  ** The function diguy_ogl_generate_character_texture_list() must be
242  ** called before this function. The scenario and character_index
243  ** arguments passed to this function must match those passed to the
244  ** generate function.
245  **
246  *b Arguments:
247  **
248  *a scenario - pointer to character's scenario
249  *a character_index - index of character to be queried
250  **
251  *b Returns:
252  **
253  ** number of textures in texture list
254  **
255  */
256 BDI_DECLSPEC_diguy_graphics
258  int character_index);
259 
260 /*l
261  *b Description:
262  **
263  ** This function returns the OpenGL texture object at the specified
264  ** index.
265  **
266  ** The function diguy_ogl_generate_character_texture_list() must be
267  ** called before this function. The scenario and character_index
268  ** arguments passed to this function must match those passed to the
269  ** generate function.
270  **
271  *b Arguments:
272  **
273  *a scenario - pointer to character's scenario
274  *a character_index - index of character to be queried
275  *a texture_list_index - index of texture in texture list
276  **
277  *b Returns:
278  **
279  ** OpenGL texture object
280  **
281  */
282 BDI_DECLSPEC_diguy_graphics
284  int character_index,
285  int texture_list_index);
286 
287 /*l
288  *b Description:
289  **
290  ** This function returns the filename of the texture at the specified
291  ** index.
292  **
293  ** The function diguy_ogl_generate_character_texture_list() must be
294  ** called before this function. The scenario and character_index
295  ** arguments passed to this function must match those passed to the
296  ** generate function.
297  **
298  *b Arguments:
299  **
300  *a scenario - pointer to character's scenario
301  *a character_index - index of character to be queried
302  *a texture_list_index - index of texture in texture list
303  **
304  *b Returns:
305  **
306  ** filename of the texture
307  **
308  */
309 BDI_DECLSPEC_diguy_graphics
311  int character_index,
312  int texture_list_index);
313 
314 /*l
315  *b Description:
316  **
317  ** This function notifies the character that its texture objects have
318  ** been modified and that it should take any steps necessary to update
319  ** its internal state to ensure proper display.
320  **
321  *b Arguments:
322  **
323  *a scenario - pointer to character's scenario
324  *a character_index - index of character to be queried
325  **
326  *b Returns:
327  **
328  ** 0 on success, -1 on failure
329  **
330  */
331 BDI_DECLSPEC_diguy_graphics
333  int character_index);
334 
335 /*l
336  *b Description:
337  **
338  ** This function returns the texture unit that DI-Guy is currently set to
339  ** use.
340  **
341  *b Returns:
342  **
343  ** integer identifying texture unit; e.g., 0 for texture unit 0
344  **
345  */
346 BDI_DECLSPEC_diguy_graphics
348 
349 /*l
350  *b Description:
351  **
352  ** This function sets the texture unit that DI-Guy should use.
353  **
354  *b Arguments:
355  **
356  *a texture_unit - integer identifying texture unit
357  **
358  ** Possible values are:
359  **
360  *a 0 - use GL_TEXTURE0
361  *a 1 - use GL_TEXTURE1
362  *a 2 - use GL_TEXTURE2
363  *a 3 - use GL_TEXTURE3
364  **
365  *b Returns:
366  **
367  ** 0 on success, -1 on failure
368  **
369  */
370 BDI_DECLSPEC_diguy_graphics
371 int diguy_ogl_set_texture_unit(int texture_unit);
372 
373 /*l
374  *b Description:
375  **
376  ** This function turns far position rendering on or off. See
377  ** diguyViewCamera for more information on far positions.
378  **
379  *b Arguments:
380  **
381  *a val - pass 1 to use far positions, 0 to not use them
382  **
383  */
384 BDI_DECLSPEC_diguy_graphics
385 void diguy_ogl_set_use_far_positions(int val);
386 
387 /*l
388  *b Returns:
389  **
390  ** 1 if far positions are in use, else 0
391  */
392 BDI_DECLSPEC_diguy_graphics
394 
395 /*l
396  *b Description:
397  **
398  ** This function sets the shader source files that will be used for the
399  ** specified shader.
400  **
401  ** The default filenames for the "diguy_character" shader are
402  ** "diguy_character_glsl.vert" and "diguy_character_glsl.frag".
403  **
404  *b Arguments:
405  **
406  *a shader_name - name with which vertex/pixel shader pair can be
407  *a referenced
408  *a vert_filename - name of vertex shader source file
409  *a pixel_filename - name of pixel (fragment) shader source file
410  **
411  */
412 BDI_DECLSPEC_diguy_graphics
413 void diguy_ogl_set_default_shader_source_files(const char* shader_name,
414  const char* vert_filename,
415  const char* pixel_filename);
416 
417 /*l
418  *b Description:
419  **
420  ** Renders a shadow pass of the world and binds into the target texture unit.
421  **/
422 BDI_DECLSPEC_diguy_graphics
423 int diguy_ogl_render_shadow_map(unsigned int texture_unit, // 0 to 7, not GL_TEXTURE0 to GL_TEXTURE7
424  diguyViewLight* light,
425  diguyScenario* scenario,
426  float pos_above_terrain);
427 
428 /*l
429  *b Description:
430  **
431  ** Applies active lights to the OpenGL state, also updates default shader uniforms
432  ** and calls diguyScenario::set_num_active_point_lights()
433  **
434  *b Returns:
435  **
436  ** The number of active lights
437  **/
438 BDI_DECLSPEC_diguy_graphics
440 
441 /****************************************************************************/
442 /****************************************************************************/
443 /*****************************************************************************
444  **
445  *2 Experimental Heads-Up Display Functions
446  **
447  ** The following functions are experimental and may change or
448  ** disappear with no warning.
449  */
450 /****************************************************************************/
451 /****************************************************************************/
452 /****************************************************************************/
453 
454 BDI_DECLSPEC_diguy_graphics
455 int diguy_ogl_2d_set_color(float r, float g, float b, float a);
456 
457 BDI_DECLSPEC_diguy_graphics
458 int diguy_ogl_2d_draw_filled_rect(int x0, int y0, int x1, int y1);
459 
460 BDI_DECLSPEC_diguy_graphics
461 int diguy_ogl_2d_draw_text(int x, int y, const char* text);
462 
463 BDI_DECLSPEC_diguy_graphics
464 int diguy_ogl_2d_get_text_width(const char* text);
465 
466 BDI_DECLSPEC_diguy_graphics
467 int diguy_ogl_2d_get_text_height(const char* text);
468 
469 BDI_DECLSPEC_diguy_graphics
471 
472 BDI_DECLSPEC_diguy_graphics
474 
475 
476 /*****************************************************************************
477  **
478  *2 Experimental frame stats API
479  **
480  ** Currently available stats:
481  *>
482  *- - "characters_drawn"
483  *- - "links_drawn"
484  *- - "shapes_drawn"
485  *- - "nodes_drawn"
486  *- - "mats_bound"
487  *- - "groups_drawn"
488  *- - "textures_bound"
489  *- - "vbos_drawn"
490  *- - "rigid_vbos_drawn",
491  *- - "skinned_vbos_drawn"
492  *- - "tris_drawn"
493  *- - "verts_drawn"
494  *<
495  ** Stats should be cleared once a frame to get accurate results.
496  */
497 BDI_DECLSPEC_diguy_graphics
499 
500 BDI_DECLSPEC_diguy_graphics
501 const char* diguy_ogl_frame_stat_name(int index);
502 
503 BDI_DECLSPEC_diguy_graphics
504 int diguy_ogl_get_frame_stat(const char* stat_name);
505 
506 BDI_DECLSPEC_diguy_graphics
508 
509 BDI_DECLSPEC_diguy_graphics
510 int diguy_ogl_draw_frame_stats(int sx, int sy);
511 
512 #endif // CPLUSPLUS_ONLY
513 
514 #ifdef __cplusplus
515 }
516 #endif
517 
518 
519 #endif /* __diguy_graphics_ogl_H */
520 
521 
522 /*
523  * Copyright (C) 1992-2013 Boston Dynamics
524  * ALL RIGHTS RESERVED.
525  *
526  * These coded instructions, statements, and computer programs
527  * contain unpublished proprietary information of Boston Dynamics
528  * and are protected by Copyright Laws of the United States.
529  * They may not be used, duplicated, or disclosed in any form, in
530  * whole or in part, without the prior written consent from Boston
531  * Dynamics.
532  *
533  * RESTRICTED RIGHTS LEGEND
534  * Use, duplication, or disclosure by the government is subject
535  * to restrictions as set forth in FAR 52.227.19(c)(2) or
536  * subparagraph (c)(1)(ii) of the Rights in Technical Data and
537  * Computer Software clause at DFARS 252.227-7013 and/or in
538  * similar or successor clauses in the FAR, or the DOD or NASA
539  * FAR Supplement, or to subparagraphs (c)(1) and (c)(2) of the
540  * Commercial Computer Software--Restricted Rights at 48 CFR
541  * 52.227-19, as applicable. Unpublished-rights reserved under
542  * the Copyright Laws of the United States.
543  * Contractor/Manufacturer is:
544  * Boston Dynamics/78 Fourth Avenue/Waltham MA 02451.
545  */
546