/*
 * ----------------------------------------------------------------------------
 *
 *                      Copyright 1994 Division Limited.
 *                            All Rights Reserved
 *
 *
 * System       : 
 * Module       : 
 * Object Name  : $RCSfile: dplutils.h,v $
 * Revision     : $Revision: 1.3 $
 * Date         : $Date: 1995/05/19 09:23:43 $
 * Author       : $Author: nga $
 *
 * Description  :
 *
 * Notes        :
 *
 * History      :
 *
 * $Log: dplutils.h,v $
 * Revision 1.3  1995/05/19  09:23:43  nga
 * Added texture enable/disable functions.
 *
 * Revision 1.2  1995/04/26  20:09:51  nga
 * Added "special" functions.
 *
 * Revision 1.1  1995/03/10  15:58:16  nga
 * Initial revision
 *
 * ----------------------------------------------------------------------------
 */

#ifndef _DPLUTILS_H
#define _DPLUTILS_H


#include <dpl/dpltypes.h>

#ifdef __cplusplus
extern "C" {
#endif

/*
 * !!! - temporary definitions to make PP5 build. 
 */

#define dpl_SetExtnGeoLoadFunc dpl_SetExtnObjectLoadFunc
#define dpl_SetExtnTexLoadFunc dpl_SetExtnTexmapLoadFunc
#define dpl_b2zRead NULL


/*
 * Types. 
 */    

/* dPL load mode. */
typedef enum
{
    dpl_load_normal = 0x00,
    dpl_load_nocache = 0x01,
    dpl_load_noload = 0x02,
    dpl_load_noreference = 0x04
} dpl_LOAD_MODE;

/* dPL look up mode. */
typedef enum
{
    dpl_lookup_normal = 0x00,
    dpl_lookup_nocreate = 0x01,
    dpl_lookup_define = 0x02,
    dpl_lookup_noreference = 0x04
} dpl_LOOKUP_MODE;

/* dPL path type. */
typedef enum
{
    dpl_path_system,
    dpl_path_user,
    dpl_path_offset
} dpl_PATH_TYPE;

/* dPL create/delete callback function type. */
typedef void (dpl_CREATE_DELETE_CALLBACK)(dpl_TYPE type, void *handle);

/* dPL special callback function type. */
typedef void (dpl_SPECIAL_CALLBACK)(dpl_TYPE type, void *handle,
				    char8 *special, uint32 special_len);

/* dPL material name callback function type. */
typedef char8 *(dpl_MATERIAL_NAME_CALLBACK)(char8 *mat_name);


/*
 * Prototypes. 
 */

extern void
dpl_SetObjectFileCacheSize(uint32 size);

extern uint32
dpl_GetObjectFileCacheSize(void);

extern void
dpl_SetTexmapFileCacheSize(uint32 size);

extern uint32
dpl_GetTexmapFileCacheSize(void);

extern void
dpl_SetMaterialFileCacheSize(uint32 size);

extern uint32
dpl_GetMaterialFileCacheSize(void);

extern void
dpl_SetMaterialItemCacheSize(uint32 size);

extern uint32
dpl_GetMaterialItemCacheSize(void);

extern void
dpl_SetHandleCacheSize(uint32 size);

extern uint32
dpl_GetHandleCacheSize(void);

/* Add a path to object search path. */
extern void
dpl_AddToObjectFilePath(char8 *path, dpl_PATH_TYPE type);

/* Set entire object search path. */
extern void
dpl_SetObjectFilePath(char8 *sys_path, char8 *user_path, char8 *offset);

/* Get entire object search path. */
extern char8 *
dpl_GetObjectFilePath(void);

/* Associate an extension with a object load function. */
extern void
dpl_SetExtnObjectLoadFunc(char8 *extn, dpl_LOAD_FUNCTION *load_func);

/* Get a load function associated with an extension. */
extern dpl_LOAD_FUNCTION *
dpl_GetExtnObjectLoadFunc(char8 *e);

/* Get object file extensions. */
extern char8 *
dpl_GetObjectFileExtns(void);

/* Add a path to texmap search path. */
extern void
dpl_AddToTexmapFilePath(char8 *path, dpl_PATH_TYPE type);

/* Set entire texmap search path. */
extern void
dpl_SetTexmapFilePath(char8 *sys_path, char8 *user_path, char8 *offset);

/* Get entire texmap search path. */
extern char8 *
dpl_GetTexmapFilePath(void);

/* Associate an extension with a texmap load function. */
extern void
dpl_SetExtnTexmapLoadFunc(char8 *extn, dpl_LOAD_FUNCTION *load_func);

/* Get a load function associated with an extension. */
extern dpl_LOAD_FUNCTION *
dpl_GetExtnTexmapLoadFunc(char8 *e);

/* Get texmap file extensions. */
extern char8 *
dpl_GetTexmapFileExtns(void);

/* Add a path to material search path. */
extern void
dpl_AddToMaterialFilePath(char8 *path, dpl_PATH_TYPE type);

/* Set entire material search path. */
extern void
dpl_SetMaterialFilePath(char8 *sys_path, char8 *user_path, char8 *offset);

/* Get entire material search path. */
extern char8 *
dpl_GetMaterialFilePath(void);

/* Set texture load enable. */
void
dpl_SetTextureLoadEnable(int32 i);

/* Get texture load enable. */
int32
dpl_GetTextureLoadEnable(void);

/* Set detail texture load enable. */
void
dpl_SetDetailTextureLoadEnable(int32 i);

/* Get detail texture load enable. */
int32
dpl_GetDetailTextureLoadEnable(void);


/*
 * Built-in load functions. 
 */

/* bgf object file reader. */
extern void *
dpl_bgfRead(char8 *);

/* vtx texmap file reader. */
extern void *
dpl_vtxRead(char8 *);

/* SGI texmap file reader. */
extern void *
dpl_sgiRead(char8 *);

/* TGA texmap file reader. */
extern void *
dpl_tgaRead(char8 *);


/*
 * Find file & perform the loading function, based on extension returning
 * NULL where the load fails.
 */

extern dpl_OBJECT *
dpl_LoadObject(char8 *fname, dpl_LOAD_MODE mode);

extern void
dpl_UnloadObject(dpl_OBJECT *o);

extern dpl_TEXMAP *
dpl_LoadTexmap(char8 *fname, dpl_LOAD_MODE mode);

extern void
dpl_UnloadTexmap(dpl_TEXMAP *t);


/*
 * dPL lookup functions.
 */

extern dpl_MATERIAL *
dpl_LookupMaterial(char8 *name, dpl_LOOKUP_MODE mode, int32 *status);

extern void
dpl_ReferenceMaterial(dpl_MATERIAL *m);

extern void
dpl_UnreferenceMaterial(dpl_MATERIAL *m);

extern char8 *
dpl_LookupMaterialName(dpl_MATERIAL *m);

extern dpl_MATERIAL *
dpl_GetFirstMaterial(char8 **name);

extern dpl_MATERIAL *
dpl_GetNextMaterial(char8 **name);

extern dpl_TEXTURE *
dpl_LookupTexture(char8 *name, dpl_LOOKUP_MODE mode, int32 *status);

extern void
dpl_ReferenceTexture(dpl_TEXTURE *t);

extern void
dpl_UnreferenceTexture(dpl_TEXTURE *t);

extern char8 *
dpl_LookupTextureName(dpl_TEXTURE *t);

extern dpl_TEXTURE *
dpl_GetFirstTexture(char8 **name);

extern dpl_TEXTURE *
dpl_GetNextTexture(char8 **name);

extern dpl_RAMP *
dpl_LookupRamp(char8 *name, dpl_LOOKUP_MODE mode, int32 *status);

extern void
dpl_ReferenceRamp(dpl_RAMP *r);

extern void
dpl_UnreferenceRamp(dpl_RAMP *r);

extern char8 *
dpl_LookupRampName(dpl_RAMP *r);

extern dpl_RAMP *
dpl_GetFirstRamp(char8 **name);

extern dpl_RAMP *
dpl_GetNextRamp(char8 **name);

extern dpl_LOD *
dpl_LookupLod(dpl_OBJECT *object, char8 *name, dpl_LOOKUP_MODE mode,
	      int32 *status);

extern void
dpl_ReferenceLod(dpl_LOD *l);

extern void
dpl_UnreferenceLod(dpl_LOD *l);

extern char8 *
dpl_LookupLodName(dpl_LOD *l);

extern dpl_LOD *
dpl_GetFirstLod(char8 **name);

extern dpl_LOD *
dpl_GetNextLod(char8 **name);

extern dpl_GEOGROUP *
dpl_LookupGeogroup(dpl_OBJECT *object, char8 *name, dpl_LOOKUP_MODE mode,
		   int32 *status);

extern void
dpl_ReferenceGeogroup(dpl_GEOGROUP *g);

extern void
dpl_UnreferenceGeogroup(dpl_GEOGROUP *g);

extern dpl_GEOGROUP *
dpl_GetFirstGeogroup(char8 **name);

extern dpl_GEOGROUP *
dpl_GetNextGeogroup(char8 **name);

extern char8 *
dpl_LookupGeogroupName(dpl_GEOGROUP *g);

extern char8 *
dpl_LookupGeogroupSpecial(dpl_GEOGROUP *g, uint32 *len);

extern char8 *
dpl_LookupObjectFileName(dpl_OBJECT *o);

extern char8 *
dpl_LookupObjectName(dpl_OBJECT *o);

extern char8 *
dpl_LookupObjectSpecial(dpl_OBJECT *o, uint32 *len);

extern char8 *
dpl_LookupTexmapFileName(dpl_TEXMAP *t);


/*
 * dPL callback function. 
 */

extern void
dpl_SetCreateNodeCallback(dpl_CREATE_DELETE_CALLBACK *func);

extern dpl_CREATE_DELETE_CALLBACK *
dpl_GetCreateNodeCallback(void);

extern void
dpl_SetDeleteNodeCallback(dpl_CREATE_DELETE_CALLBACK *func);

extern dpl_CREATE_DELETE_CALLBACK *
dpl_GetDeleteNodeCallback(void);

extern void
dpl_SetSpecialCallback(dpl_SPECIAL_CALLBACK *func);

extern dpl_SPECIAL_CALLBACK *
dpl_GetSpecialCallback(void);

extern void
dpl_SetMaterialNameCallback(dpl_MATERIAL_NAME_CALLBACK *func);

extern dpl_MATERIAL_NAME_CALLBACK *
dpl_GetMaterialNameCallback(void);


/*
 * dPL error and warning message function. 
 */

extern void
dpl_SetWarnLogFile(FILE *fp);

extern void
dpl_Warn(dpl_WARN_LEVEL l, char8 *format, ...);


/*
 * dPL Utilities version. 
 */

extern char8 *
dpl_UtilsVersion(void);

#ifdef __cplusplus
}
#endif


#endif /* _DPLUTILS_H */
