#ifndef __DLL_H__
#define __DLL_H__
 
#define GLI_INTERFACE_FUNC(a) a
 
#include "vertex.h"
#include "PvObj_st.h"
#include "Camera.h"
#include "DLLCaps.h"
#include "TexBench.h"
#include "TMR.h"
 
/*
 =======================================================================================
    DLL identity structure
 =======================================================================================
 */
 
typedef struct tdstGliDriverIdentity_
{
    char            szName[64];
    char            szDesc[256];
    char            szVersion[16];
    unsigned long   ulCode;
} tdstGliDriverIdentity;
 
/*
 =======================================================================================
    Globals
 =======================================================================================
 */
 
extern tdstGliDriverIdentity g_stGliDrvId;
extern tdstGliCaps          *g_p_stGliCaps;
 
typedef struct GLI_tdst_DllInfos_
{
	HINSTANCE       h_Module;
	char            sz_Name[64];
	char            sz_Desc[256];
	char            sz_Version[16];
	unsigned long   ul_Code;
	char            sz_FileName[ _MAX_PATH ];
	char            sz_DriverName[ 32 ];
	char            sz_DeviceName[ 32 ];
	long            l_InitWidth;
	long            l_InitHeight;
	long            l_InitFullScreen;
	long            l_InitBpp;

	long			l_RealWidth;
	long			l_RealHeight;

	float			f_WidthRatio;
	float			f_HeightRatio;
} GLI_tdst_DllInfos;

extern GLI_tdst_DllInfos   GLI_gst_DllInfo; //chbani
 
 
/*
 =======================================================================================
    imported object (Have to be initialized)
 =======================================================================================
 */
extern GLI_tdstInternalGlobalValuesFor3dEngine *GLI_BIG_GLOBALS;
extern long                                    *gs_aDEFTableOfTextureMemoryChannels;
extern GLI_tdstTexture                         **gs_aDEFTableOfTextureAlreadyRead;
extern void                                    *GLI_gs_p_ConvertBufferMipMapping;
 
extern long                                    *GLD_p_lRenderingCounter;
extern void                                    *g_p_vDrawSemaphore;
 
/*
 =======================================================================================
    imported function (Have to be initialized)
 =======================================================================================
 */
 
 /*
 * From GLI
 */
extern void            (* GLI_MDRV_vSetGlobalAlpha)( float );
extern void            (* GLI_MDRV_vSerialProjection)( GLI_tdstCamera *, long , GLI_tdstAligned3DVector *, GLI_tdstAligned2DVector *);
 
extern long            (* GLI_MDRV_xIsGliInit)();
extern void            *(*GLI_MDRV_p_vTmpMalloc)( unsigned long );
extern void            (*GLI_MDRV_vTmpFree)( void * );
extern void            (* GLI_MDRV_vErmPrintMsg)( char *, char *);
extern long            (* GLI_MDRV_lComputeTexturesSize)( void );
extern void            (* GLI_MDRV_vCompressTex565) ( GLI_tdstTexture *, void *);
extern void            (* GLI_MDRV_vCompressTex4444 )( GLI_tdstTexture *, void *);
extern void            (* GLI_MDRV_vCompressTex1555) ( GLI_tdstTexture *, void *);
extern void            (* GLI_MDRV_vDivideBitmapSurfaceBy2) (unsigned long *,unsigned long *,long , long );
extern void            (* GLI_MDRV_vDivideBitmapSurfaceBy2NonZero) (unsigned long *,unsigned long *,long , long , unsigned long);
extern void            (* GLI_MDRV_vDivideBitmapSurfaceBy2Palette) (unsigned long *,unsigned long *,long , long );
extern unsigned long   (* GLI_MDRV_vVerifyTextureIsRealyAlpha) ( GLI_tdstTexture * );
extern void            (* GLI_MDRV_xLoadTextureInTexelField) (GLI_tdstTexture *, long *, BOOL);
extern void            (* GLI_MDRV_vReloadTextures) (void);
extern long            (* GLI_MDRV_lAddDisplayMode)( long , long , long, long );
//extern long            (* GLI_MDRV_lDoDialogBoxLB)( char *, DLGPROC, long );
extern void			   (* GLI_MDRV_vUsePreCalculatedMipMaps)( GLI_tdstTexture * , void **, unsigned char *);
/* 
 * From GLD
 */
extern void            (* GLD_MDRV_vBlitStretched16b)( long , long , unsigned short *, long , long , long , unsigned short * );
extern GLD_tdstPixelFormat * (* GLD_MDRV_fn_p_stGetDefinedPixelFormat) ( long );
extern long            (* GLD_MDRV_fn_lAddDefinedPixelFormat)( GLD_tdstPixelFormat * );
extern long            (* GLD_MDRV_fn_lComputeWaitFrameForSmoothSynchro) ();

/*
 * From GAM
 */
extern void            (* GAM_MDRV_vReadInIniFile)( char *, char *, long, char *);
extern void            (* GAM_MDRV_vWriteInIniFile) (char *, char *, char *);
 
extern void            (* TMR_MDRV_vTimerGetCounter)( short, stTimerCount* );
extern unsigned long   (* TMR_MDRV_ulTimerTickPerSecond)( short );

 
 
/*
 =======================================================================================
    imported function for Not retail version
 =======================================================================================
 */
#ifndef RETAIL
 
extern void (* GAM_MDRV_vShowRasters)();
 
extern void (* MMG_MDRV_vAddMemoryInfo)(long , long , void * );    /* Must be called before making a memory allocation*/
 
/*
 * From PRF
 */
extern long (* PRF_MDRV_lIncIndependantVariable)(unsigned long , long );
extern void (* PRF_MDRV_vSetIndependantVariable)(unsigned long , long );
extern long (* PRF_MDRV_lGetIndependantVariable)(unsigned long );
extern void (* PRF_MDRV_vIncreaseVariable) (unsigned long , void *, unsigned long );
extern void (* PRF_MDRV_vResetVariable)( unsigned long );
extern void (* PRF_MDRV_vStopChrono )(unsigned long , void *);
extern void (* PRF_MDRV_vStartChrono ) (unsigned long , void *);
 
#else
 
#define GAM_MDRV_vShowRasters()
#define MMG_MDRV_vAddMemoryInfo(a, b, c )
#define PRF_MDRV_lIncIndependantVariable(a,b)
#define PRF_MDRV_vSetIndependantVariable(a,b)
#define PRF_MDRV_lGetIndependantVariable(a) 0
#define PRF_MDRV_vIncreaseVariable(a,b,c)
#define PRF_MDRV_vResetVariable(a)
#define PRF_MDRV_vStopChrono(a,b)
#define PRF_MDRV_vStartChrono(a,b)
 
#endif
 
/*
 * BENCH_TEXTURE is defined or not in file TexBench.h
 */
#ifdef BENCH_TEXTURE
 
extern void (*GLI_MDRV_TEXBENCH_vSetTextureSize)( GLI_tdstTexture *, char, long);
 
#else
 
#define GLI_MDRV_TEXBENCH_vSetTextureSize(a,b,c)
 
#endif /* BENCH_TEXTURE */
 
#endif /*__DLL_H__*/
