DI-Guy SDK Documentation  13.2
diguy_graphics_ogl.h File Reference

Go to the source code of this file.

Functions

int diguy_ogl_initialize (bdiGraphicsInitOgl *init)
 This function initializes the DI-Guy Runtime API for the OpenGL environment. More...
 
int diguy_ogl_get_defaults (bdiGraphicsInitOgl *init)
 Fills out the init structure with default values. More...
 
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. More...
 
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 internal list. More...
 
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(). More...
 
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. More...
 
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. More...
 
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. More...
 
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 take any steps necessary to update its internal state to ensure proper display. More...
 
void diguy_ogl_set_use_far_positions (int val)
 This function turns far position rendering on or off. More...
 
int diguy_ogl_get_use_far_positions ()
 Returns: 1 if far positions are in use, else 0. More...
 
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. More...
 
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 diguyScenario::set_num_active_point_lights() More...
 
int diguy_ogl_2d_draw_filled_rect (int x0, int y0, int x1, int y1)
 
int diguy_ogl_2d_draw_text (int x, int y, const char *text)
 
int diguy_ogl_2d_get_text_width (const char *text)
 
int diguy_ogl_2d_get_text_height (const char *text)
 
int diguy_ogl_get_fbo_texture_id ()
 
int diguy_ogl_reload_changed_textures ()
 
int diguy_ogl_get_num_frame_stats ()
 
const char * diguy_ogl_frame_stat_name (int index)
 
int diguy_ogl_get_frame_stat (const char *stat_name)
 
int diguy_ogl_clear_all_frame_stats ()
 
int diguy_ogl_draw_frame_stats (int sx, int sy)
 

Variables

 LALALALALA
 

Function Documentation

int diguy_ogl_initialize ( bdiGraphicsInitOgl init)

This function initializes the DI-Guy Runtime API for the OpenGL environment.

This function should only be called once per program execution. Do not call this function again, even after calling diguy_deinitialize().

Use diguy_ogl_get_defaults() to fill out the init structure before changing specific entries.

Parameters
initpointer to type bdiGraphicsInitOgl; passing NULL will cause defaults to be used for all values

Returns:

0 on success, non-zero error code on failure

Refer to diguy_constants.h for error code values.

int diguy_ogl_get_defaults ( bdiGraphicsInitOgl init)

Fills out the init structure with default values.

Selected entries can then be changed before calling diguy_ogl_initialize().

Parameters
initpointer to type bdiGraphicsInitOgl

Returns:

0 on success, -1 on failure

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.

It uses a minimal render of the scene and characters into the back buffer to fill out the impact structure.

It may be useful to combine your intersection results with the results from this function.

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 internal list.

This internal list can then be accessed via the following functions:

1 diguy_ogl_get_character_texture_list_num_textures();
2 diguy_ogl_get_character_texture_list_texture_object_at_index();
3 diguy_ogl_get_character_texture_list_texture_filename_at_index();

The function diguy_ogl_release_character_texture_list() should be called once query calls are complete to avoid a resource leak.

Note that there is currently only one internal texture list; there are not separate lists per character. Calling this function again, even with a different scenario pointer and/or character index, will clobber the previous texture list.

Parameters
scenariopointer to character's scenario
character_indexindex of character to be queried

Returns:

0 on success, -1 on failure

C++ Example:

1 diguy_ogl_generate_character_texture_list(scenario,
2  character_index);
3 
4 int texture_count = diguy_ogl_get_character_texture_list_num_textures(scenario,
5  character_index);
6 
7 if (texture_count > 0)
8 {
9  int texture_index;
10 
11  for (texture_index = 0;
12  texture_index < texture_count;
13  texture_index++)
14  {
15  GLuint texture_object = diguy_ogl_get_character_texture_list_texture_object_at_index(scenario,
16  character_index,
17  texture_index);
18 
19  const char* texture_filename = diguy_ogl_get_character_texture_list_texture_filename_at_index(scenario,
20  character_index,
21  texture_index);
22 
23  bdi_log_printf(BDI_LOG_WARN, "\ttexture object = %ld, filename = %s\n",
24  texture_object,
25  texture_filename);
26  }
27 
28  GLuint texture_object = diguy_ogl_get_character_texture_list_texture_object_at_index(scenario,
29  character_index,
30  0); // the first texture in the list
31 
32  //
33  // (Code to override/replace the texture)
34  //
35 
36  diguy_ogl_set_character_texture_objects_modified(scenario,
37  character_index);
38 
39  diguy_ogl_release_character_texture_list(scenario,
40  character_index);
41 }
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().

Parameters
scenariopointer to character's scenario
character_indexindex of character to be queried

Returns:

0 on success, -1 on failure

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.

The function diguy_ogl_generate_character_texture_list() must be called before this function. The scenario and character_index arguments passed to this function must match those passed to the generate function.

Parameters
scenariopointer to character's scenario
character_indexindex of character to be queried

Returns:

number of textures in texture list

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.

The function diguy_ogl_generate_character_texture_list() must be called before this function. The scenario and character_index arguments passed to this function must match those passed to the generate function.

Parameters
scenariopointer to character's scenario
character_indexindex of character to be queried
texture_list_indexindex of texture in texture list

Returns:

OpenGL texture object

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.

The function diguy_ogl_generate_character_texture_list() must be called before this function. The scenario and character_index arguments passed to this function must match those passed to the generate function.

Parameters
scenariopointer to character's scenario
character_indexindex of character to be queried
texture_list_indexindex of texture in texture list

Returns:

filename of the texture

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 take any steps necessary to update its internal state to ensure proper display.

Parameters
scenariopointer to character's scenario
character_indexindex of character to be queried

Returns:

0 on success, -1 on failure

void diguy_ogl_set_use_far_positions ( int  val)

This function turns far position rendering on or off.

See diguyViewCamera for more information on far positions.

Parameters
valpass 1 to use far positions, 0 to not use them
int diguy_ogl_get_use_far_positions ( )

Returns: 1 if far positions are in use, else 0.

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.

The default filenames for the "diguy_character" shader are "diguy_character_glsl.vert" and "diguy_character_glsl.frag".

Parameters
shader_namename with which vertex/pixel shader pair can be referenced
vert_filenamename of vertex shader source file
pixel_filenamename of pixel (fragment) shader source file
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 diguyScenario::set_num_active_point_lights()

Returns:

The number of active lights
int diguy_ogl_2d_draw_filled_rect ( int  x0,
int  y0,
int  x1,
int  y1 
)
int diguy_ogl_2d_draw_text ( int  x,
int  y,
const char *  text 
)
int diguy_ogl_2d_get_text_width ( const char *  text)
int diguy_ogl_2d_get_text_height ( const char *  text)
int diguy_ogl_get_fbo_texture_id ( )
int diguy_ogl_reload_changed_textures ( )
int diguy_ogl_get_num_frame_stats ( )
const char* diguy_ogl_frame_stat_name ( int  index)
int diguy_ogl_get_frame_stat ( const char *  stat_name)
int diguy_ogl_clear_all_frame_stats ( )
int diguy_ogl_draw_frame_stats ( int  sx,
int  sy 
)

Variable Documentation

LALALALALA