
/*********************************************************************
 ** Copyright (c) 1992-2022 MAK Technologies, Inc.
 ** All rights reserved. 
 *********************************************************************/

/*********************************************************************
 **
 *t  DI-Guy API, Info Graphics Module
 **
 *b    Link against: libdiguy_graphics_api
 */

#ifndef __diguy_graphics_api_H
#define __diguy_graphics_api_H

#include <diguy_api.h>
#include <diguy_typedefs.h>

#ifndef BDI_GRAPHICS_API_ogl
#include <bdigraphics/bdiGraphicsInitGraphicsAPI.h>
#endif

// these typedefs have actually been moved to diguy_typedefs.h but very few files depend on this
// header file so it's not worth breaking backwards compatibility to remove these.
#include <diguyGraphicsLink.h>     // for diguyGraphicsLinkCreateFunc
#include <diguyGraphicsShape.h>    // for diguyGraphicsShapeCreateFunc
#include <diguyGraphicsFile.h>     // for diguyGraphicsFileCreateFunc
#include <diguyGraphicsState.h>    // for diguyGraphicsStateCreateFunc
#include <diguyGraphicsMaterial.h> // for diguyGraphicsMaterialCreateFunc
#include <diguyGraphicsTexture.h>  // for diguyGraphicsTextureCreateFunc
#include <diguyGraphicsMesh.h>     // for diguyGraphicsMeshCreateFunc
#include <diguyGraphicsShaderProgram.h>  // for diguyGraphicsShaderProgramCreateFunc
#include <diguyGraphicsShaderInstance.h> // for diguyGraphicsShaderInstanceCreateFunc
#include <diguyGraphicsInstanceGroup.h>  // for diguyGraphicsInstanceGroupCreateFunc

#include <declspec_diguy_graphics.h>

#ifdef __cplusplus
extern "C" {
#endif


/*****************************************************************************/
/**
 *2  Graphics API Initialization Functions
 **
 ** \ingroup diguyGraphicsAPI
 */

#ifndef BDI_GRAPHICS_API_ogl

/*l
 *b  Description:
 **
 **    This function initializes the DI-Guy Runtime API for accessing
 **    information about DI-Guy graphics and geometry.
 **
 **    Use diguy_graphics_get_defaults() to fill out the init structure
 **    before changing specific entries.
 **
 *b  Arguments:
 **
 *a    init - pointer to type bdiGraphicsInitGraphicsAPI; passing NULL
 *a           will cause defaults to be used for all values
 **
 *b  Returns:
 **
 **    0 on success, non-zero error code on failure
 **
 **    Refer to diguy_constants.h for error code values.
 **    
 ** \ingroup diguyGraphicsAPI
 */
BDI_DECLSPEC_diguy_graphics int
diguy_graphics_initialize(bdiGraphicsInitGraphicsAPI* init);

/*l
 *b  Description:
 **
 **    Fills out the init structure with default values.  Selected entries
 **    can then be changed before calling diguy_graphics_initialize().
 **
 **    The default values are:
 *-    - init->use_shaders = 1;
 *-    - init->shader_language = DIGUY_GRAPHICS_SHADER_LANGUAGE_GLSL;
 *-    - init->transpose_shader_matrices = 0;
 *-    - init->use_4x3_shader_matrices = 1;
 *-    - init->use_cached_optimized_geometry = 1;
 *-    - init->use_cached_compressed_textures = 1;
 *-    - init->use_sRGB_corrected_textures = 1;
 *-    - init->characters_have_world_space_triangle_query = 1;
 *-    - init->scene_objects_have_world_space_triangle_query = 0;
 **
 *b  Arguments:
 **
 *a    init - pointer to type bdiGraphicsInitGraphicsAPI
 **
 *b  Returns:
 **
 **    0 on success, -1 on failure
 */
BDI_DECLSPEC_diguy_graphics int
diguy_graphics_get_defaults(bdiGraphicsInitGraphicsAPI* init);

/*l
 *b  Description:
 **
 **    Fills out the init structure with default OSG values.  Selected entries
 **    can then be changed before calling diguy_graphics_initialize().
 **
 **    The differences for the default values are:
 *-    - init->transpose_shader_matrices = 1;
 *-    - init->use_4x3_shader_matrices = 0;
 *-    - init->use_sRGB_corrected_textures = 0;
 **
 *b  Arguments:
 **
 *a    init - pointer to type bdiGraphicsInitGraphicsAPI
 **
 *b  Returns:
 **
 **    0 on success, -1 on failure
 */
BDI_DECLSPEC_diguy_graphics int
diguy_graphics_get_osg_defaults(bdiGraphicsInitGraphicsAPI* init);

/*l
 *b  Description:
 **
 **    Fills out the init structure with default values.  Selected entries
 **    can then be changed before calling diguy_graphics_initialize().
 **
 **    The differences for the default values are:
 *-    - init->transpose_shader_matrices = 1
 *-    - init->use_4x3_shader_matrices = 0
 *-    - init->shader_language = DIGUY_GRAPHICS_SHADER_LANGUAGE_HLSL
 **
 *b  Arguments:
 **
 *a    init - pointer to type bdiGraphicsInitGraphicsAPI
 **
 *b  Returns:
 **
 **    0 on success, -1 on failure
 */

BDI_DECLSPEC_diguy_graphics int
diguy_graphics_get_dx9_defaults(bdiGraphicsInitGraphicsAPI* init);

#endif 

/*l
 *b  Description:
 **
 **    This function turns far position rendering on or off.  It must be
 **    called after diguy_graphics_initialize().
 **
 *b  Arguments:
 **
 *a    flag - pass 1 to turn far positions on, 0 to turn them off
 **
 */
BDI_DECLSPEC_diguy_graphics
void diguy_graphics_set_use_far_positions(int flag);

/*l
 *b  Description:
 **
 **    This function gets the status of far position rendering.
 **    It can only be called after diguy_graphics_initialize().
 **
 *b  Returns:
 **
 **    1 if far position rendering is on, 0 if not
 **
 */
BDI_DECLSPEC_diguy_graphics
int diguy_graphics_get_use_far_positions();


/*****************************************************************************/
/**
 *2  DI-Guy Graphics Object Create Functions
 **
 ** \ingroup diguyGraphicsAPI
 */


/**
 **  Function responsible for allowing end users to implement their own diguyUniformBufferUpdater
 **  see diguyOglUniformBufferUpdater for an example. Providing this class is essential for modern
 **  immediate mode rendering including our OpenGL 3.2+ and dx11 samples. Note you should new this
 **  object and pass it to diguy which then takes ownership of it.
 */
BDI_DECLSPEC_diguy_graphics int
diguy_graphics_set_uniform_updater(diguyUniformBufferUpdater* uniform_buffer_updater);

/**
 **  Function responsible for allowing end users to subclass from a diguyGraphicsLink 
 ** \ingroup diguyGraphicsAPI
 */
BDI_DECLSPEC_diguy_graphics int
diguy_graphics_set_link_create_func(diguyGraphicsLinkCreateFunc* func);

/**
 **  Function responsible for allowing end users to subclass from a diguyGraphicsShape
 */
BDI_DECLSPEC_diguy_graphics int
diguy_graphics_set_shape_create_func(diguyGraphicsShapeCreateFunc* func);

/**
 **  Function responsible for allowing end users to subclass from a diguyGraphicsFile
 */
BDI_DECLSPEC_diguy_graphics int
diguy_graphics_set_file_create_func(diguyGraphicsFileCreateFunc* func);

/**
 **  Function responsible for allowing end users to subclass from a diguyGraphicsState
 */
BDI_DECLSPEC_diguy_graphics int
diguy_graphics_set_state_create_func(diguyGraphicsStateCreateFunc* func);

/**
 **  Function responsible for allowing end users to subclass from a diguyGraphicsMaterial
 */
BDI_DECLSPEC_diguy_graphics int
diguy_graphics_set_material_create_func(diguyGraphicsMaterialCreateFunc* func);

/**
 **  Function responsible for allowing end users to subclass from a diguyGraphicsTexture
 */
BDI_DECLSPEC_diguy_graphics int
diguy_graphics_set_texture_create_func(diguyGraphicsTextureCreateFunc* func);

/**
 **  Function responsible for allowing end users to subclass from a diguyGraphicsTextureArray
 */
BDI_DECLSPEC_diguy_graphics int
diguy_graphics_set_texture_array_create_func(diguyGraphicsTextureArrayCreateFunc* func);

/**
 **  Function responsible for allowing end users to subclass from a diguyGraphicsMesh
 */
BDI_DECLSPEC_diguy_graphics int
diguy_graphics_set_mesh_create_func(diguyGraphicsMeshCreateFunc* func);

/**
 **  Function responsible for allowing end users to subclass from a diguyGraphicsShaderProgram
 */
BDI_DECLSPEC_diguy_graphics int
diguy_graphics_set_shader_program_create_func(diguyGraphicsShaderProgramCreateFunc* func);

/**
 **  Function responsible for allowing end users to subclass from a diguyGraphicsShaderTechnique
 */
BDI_DECLSPEC_diguy_graphics int
diguy_graphics_set_shader_technique_create_func(diguyGraphicsShaderTechniqueCreateFunc* func);

/**
 **  Function responsible for allowing end users to subclass from a diguyGraphicsShaderInstance
 */
BDI_DECLSPEC_diguy_graphics int
diguy_graphics_set_shader_instance_create_func(diguyGraphicsShaderInstanceCreateFunc* func);

/**
 **  Function responsible for allowing end users to subclass from a diguyGraphicsInstanceGroup
 */
BDI_DECLSPEC_diguy_graphics int
diguy_graphics_set_instance_group_create_func(diguyGraphicsInstanceGroupCreateFunc* func);

/**
**  Function responsible for allowing end users to subclass from a diguyGraphicsFrameBuffer
*/
BDI_DECLSPEC_diguy_graphics int
diguy_graphics_set_frame_buffer_create_func(diguyGraphicsFrameBufferCreateFunc* func);

/**
 **  Function responsible for allowing end users to subclass from a diguyViewPainter
 */
BDI_DECLSPEC_diguy_graphics int
diguy_graphics_set_painter_create_func(diguyViewPainterCreateFunc* func);


/**
 **  Function responsible for allowing end users to subclass from a diguyParticleSystem
 **  currently this is only needed to allow diguy to control an external particle system 
 **  which isn't a common use case.
 */
BDI_DECLSPEC_diguy_graphics int
diguy_graphics_set_particle_system_create_func(diguyParticleSystemCreateFunc* func);

/**
**  Function responsible for allowing end users to provide their own particle renderer 
**  implementation we currently provide 2 of these diguyOglParticleSystemRenderer for compatibility with OpenGL 3.2+
**  and diguyOglParticleSystemRenderer_21 which OpenGL 2.1 class and is used by our OpenSceneGraph samples.
*/
BDI_DECLSPEC_diguy_graphics int
diguy_graphics_set_particle_renderer_create_func(diguyParticleRendererCreateFunc* func);

BDI_DECLSPEC_diguy_graphics int
diguy_graphics_set_particle_manager_create_func(diguyParticleManagerCreateFunc* func);

#ifdef __cplusplus
}
#endif


#endif /* __diguy_graphics_api_H */


/*********************************************************************
 ** Copyright (c) 1992-2022 MAK Technologies, Inc.
 ** All rights reserved. 
 *********************************************************************/

