/* 
   Gld_Pub.h
   Structures, prototypes and error codes for Graphic Library for Display.
   Authors :    Christophe MARTINAUD
                Elie Khoury
                Philippe Vimont
   Last update : 10/16/1996  
   Last update : 04/08/1997 : Upgrade to VC++ & VSS 5.0 !!!
*/
 
#ifndef __GLD_PUB_H
#define __GLD_PUB_H
 
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
 
/* For DLLs who are using this module : */ 
#undef CPA_EXPORT
#if defined(CPA_WANTS_IMPORT)
 #define CPA_EXPORT __declspec(dllimport)
#elif defined(CPA_WANTS_EXPORT)
 #define CPA_EXPORT __declspec(dllexport)
#else
 #define CPA_EXPORT
#endif
 
typedef short   GLD_tdhDevice;      /* Handle of devices   */
typedef short   GLD_tdhViewport;    /* Handle of viewports */
/*typedef short   GLD_tdhPicture;     /* Handle of pictures    */
typedef float   GLD_tdxValue;
 
 
/* 007*/
#ifndef RGB
#define RGB(r,g,b) ((COLORREF)(((BYTE)(r)|((WORD)((BYTE)(g))<<8))|(((DWORD)(BYTE)(b))<<16)))
#endif /* RGB */
 
#include "Gld_Pu1.h"
 
/* Screen constantes */
#define GLD_C_lScreenDimInPixX     1024
#define GLD_C_lScreenDimInPixY     768
#define GLD_C_xScreenDimInMetersX  (GLD_tdxValue)( 0.32 )
#define GLD_C_xScreenDimInMetersY  (GLD_tdxValue)( 0.24 )
 
/* Begin : only for moteur D3D */
#define C_DRIVER_HARD   (1)
#define C_DRIVER_SOFT   (1<<1)
#define C_DRIVER_MONO   (1<<2)
#define C_DRIVER_RGB    (1<<3)
/* End : only for moteur D3D */
 
/* Constants used by GLD_bClear[Device/ViewPort]WithChoice */
#define GLD_C_CLEAR_NOTHING       0
#define GLD_C_CLEAR_BACKBUF       1
#define GLD_C_CLEAR_ZBUF          2

/* Structures for Viewports */
typedef unsigned long DWORD;
typedef struct GLD_tdstViewportAttributes_
{
    DWORD			dwInitialHeight;		/* Initial height of viewport in pixels */
    DWORD			dwInitialWidth;			/* Initial width of viewport in pixels  */
    DWORD			dwHeight;				/* Current height of viewport in pixels */
    DWORD			dwWidth;				/* Current width of viewport in pixels  */
 
    /*DWORD			dwBytesPerPixel;*/
 
    DWORD			dwTopInPix;				/* Y of Left up corner */
    DWORD			dwBottomInPix;			/* Y of right down corner */
    DWORD			dwLeftInPix;			/* X of left up corner */
    DWORD			dwRightInPix;			/* X of right down corner */
    DWORD			dwTopInPixForClip;      /* Y of Left up corner */
    DWORD			dwBottomInPixForClip;   /* Y of right down corner */
    DWORD			dwLeftInPixForClip;     /* X of left up corner */
    DWORD			dwRightInPixForClip;    /* X of right down corner */
    
    DWORD			dwWidthInPercent;		
    DWORD			dwHeightInPercent;		
 
    DWORD			dwClipTopInPix;			/* Height of clip top */
    DWORD			dwClipBottomInPix;		/* Height of clip bottom */
    DWORD			dwClipLeftInPix;		/* Width of clip left */
    DWORD			dwClipRightInPix;		/* Width of clip right */
	DWORD			dwClipTopInPercent;		/* For clipping */
	DWORD			dwClipBottomInPercent;
	DWORD			dwClipLeftInPercent;
	DWORD			dwClipRightInPercent;
 
	int				iOffsetPosX;			/* Offset of display window (relative to upper left corner) */
	int				iOffsetPosY;
 
    char			*p_cVirtualScreen;		/* Pointer to back memory associated with the viewport */
    LONG			lPitch;					/* Distance to the start of the next line */
    /*void			*p_vReserved;			/* Reserved   */
    
    void			*p_vSpecificToXD;		/* Additionnal Attributes specific to 2D or 3D */
 
/* Strega 10/12/96 */
    /*void			*p_vReserved2;*/
    GLD_tdhDevice   hDevice;
    GLD_tdhViewport hViewport;
/* Strega fin */
 
} GLD_tdstViewportAttributes, *GLD_tdpstViewportAttributes;
 
/* Structures for Devices */
typedef struct GLD_tdstDeviceAttributes_
{
    DWORD           dwHeight;                       /* Current height of device           */
    DWORD           dwWidth;                        /* Current width of device            */
    /*DWORD           dwBitsPerPixel;                 /* Current depth of device              */
    /*DWORD           dwBytesPerPixel;                /* Current bytes per pixel for device   */
 
    GLD_tdxValue    xPixelDimensionX ;              /* Pixel dimensions in world units    */
    GLD_tdxValue    xPixelDimensionY ;              /* Pixel dimensions in world units    */
 
    char            *p_cVirtualScreen;              /* Pointer to back surface memory         */
    LONG            lPitch;                         /* Distance to the start of the next line */
    short           *p_sZBuffer;                    /* Z Buffer associated with device        */
 
/* Windows only */
    DWORD           dwFullScreenModeX;              /* X resolution when in full screen mode            */
    DWORD           dwFullScreenModeY;              /* Y resolution when in full screen mode            */
    DWORD           dwFullScreenModeBpp;            /* Depth in bits per pixel when in full screen mode */
 
    HWND            hFullScreenModeWnd;             /* Handle of the window associated with the device in full screen mode */
    HWND            hNormalModeWnd;                 /* Handle of the window associated with the device in normal mode      */
 
    BOOL            bFullScreen;                    /* Is the device in full screen/exclusive mode ?                       */
    unsigned int    uiTypeDriver;                   /* The device is hardware or software (version D3D du moteur 3D)       */
    /*void            *p_vReserved;                   /* Reserved                                                              */
    /* Strega 10/12/96 */
    POINT           pClientOnPrimary;    
    RECT            rtClientRect;
    RECT            rtWindowRect;
    /* Strega fin */
} GLD_tdstDeviceAttributes, *GLD_tdpstDeviceAttributes;
 
 
/* Structures for Pictures */
/*typedef struct GLD_tdstPictureAttributes_*/
/*{*/
/*    char            *p_szBitmap;        /* Bitmap loaded in surface      */
/*    DWORD           dwHeight;           /* Height of picture in pixels   */
/*    DWORD           dwWidth;            /* Width of picture in pixels    */
 
/*    char            *p_cVirtualScreen;  /* Pointer to picture                       */
/*    LONG            lPitch;             /* Distance to the start of the next line   */
/*    void            *p_vReserved;       /* Reserved                                 */
 
/*} GLD_tdstPictureAttributes, *GLD_tdpstPictureAttributes;*/
 
 
/* Prototypes */
/* Device management */
extern    CPA_EXPORT BOOL GLD_bIsDeviceHandleValid( GLD_tdhDevice );
extern    CPA_EXPORT void GLD_vInvalidateDeviceHandle( GLD_tdhDevice * );
 
extern    CPA_EXPORT BOOL GLD_bCreateDevice( GLD_tdpstDeviceAttributes, GLD_tdhDevice * );
extern    CPA_EXPORT BOOL GLD_bGetDeviceAttributes( GLD_tdhDevice, GLD_tdpstDeviceAttributes );
extern    CPA_EXPORT BOOL GLD_bRequestWriteToDevice( GLD_tdhDevice, GLD_tdpstDeviceAttributes, BOOL * );
extern    CPA_EXPORT BOOL GLD_bWriteToDeviceFinished( GLD_tdhDevice );
extern    CPA_EXPORT BOOL GLD_bAdjustDeviceToWindow( GLD_tdhDevice ); /* windows only */
 
extern BOOL GLD_bBeginWriteToDevice( GLD_tdhDevice hNotUsed );
extern BOOL GLD_bEndWriteToDevice( GLD_tdhDevice hNotUsed );
extern CPA_EXPORT BOOL GLD_bFlipDeviceWithSynchro(GLD_tdhDevice hDev,enum Synchro eSynchro);
#ifdef U64
extern BOOL GLD_bFlipDevice( GLD_tdhDevice hDev ); /*AR980326*/
#endif
 
extern    CPA_EXPORT BOOL GLD_bDeleteDevice( GLD_tdhDevice );
extern    CPA_EXPORT BOOL GLD_bSwapDeviceMode( GLD_tdhDevice, BOOL );
extern    CPA_EXPORT BOOL GLD_bSwapToWindowedMode( GLD_tdhDevice, BOOL ); /*bart990126*/
extern    CPA_EXPORT BOOL GLD_bSwapToFullScreen( GLD_tdhDevice, BOOL ); /*bart990126*/
extern    CPA_EXPORT BOOL GLD_fn_bReinitDeviceDisplayMode( GLD_tdhDevice ); /*bart990111*/
extern    CPA_EXPORT BOOL GLD_bSetNewWindowForDevice( GLD_tdhDevice, HWND );
extern    CPA_EXPORT BOOL GLD_bClearDevice( GLD_tdhDevice );
extern    CPA_EXPORT BOOL GLD_bClearDeviceWithChoice( GLD_tdhDevice, short );
extern    CPA_EXPORT BOOL GLD_bSetFullScreenModeForDevice( GLD_tdhDevice, DWORD, DWORD, DWORD, HWND );
extern    CPA_EXPORT BOOL GLD_bSetBackgroundColorForDevice( GLD_tdhDevice, COLORREF );
extern    CPA_EXPORT BOOL GLD_bHandleResolutionChange();
extern    CPA_EXPORT LRESULT GLD_lDeviceCallback ( GLD_tdhDevice hDevice, HWND xHWnd , UINT xMessage, WPARAM wParam, LPARAM lParam );
 
/* Viewport management */
extern    CPA_EXPORT BOOL GLD_bIsViewportHandleValid( GLD_tdhViewport );
extern    CPA_EXPORT void GLD_vInvalidateViewportHandle( GLD_tdhViewport * );
 
extern    CPA_EXPORT BOOL GLD_bCreateViewport( GLD_tdhDevice, GLD_tdpstViewportAttributes, GLD_tdhViewport * );
extern    CPA_EXPORT BOOL GLD_bSetViewportPosition( GLD_tdhDevice, GLD_tdhViewport, GLD_tdpstViewportAttributes );
extern    CPA_EXPORT BOOL GLD_bGetViewportAttributes( GLD_tdhDevice, GLD_tdhViewport, GLD_tdpstViewportAttributes );
extern    CPA_EXPORT BOOL GLD_bRequestWriteToViewport( GLD_tdhDevice, GLD_tdhViewport, GLD_tdpstViewportAttributes, BOOL * );
extern    CPA_EXPORT BOOL GLD_bWriteToViewportFinished( GLD_tdhDevice, GLD_tdhViewport );
extern    CPA_EXPORT BOOL GLD_bRequestWriteToViewport2D( GLD_tdhDevice, GLD_tdhViewport, GLD_tdpstViewportAttributes, BOOL * );
extern    CPA_EXPORT BOOL GLD_bWriteToViewportFinished2D( GLD_tdhDevice, GLD_tdhViewport );
extern    CPA_EXPORT BOOL GLD_bRequestWriteToViewport3D( GLD_tdhDevice, GLD_tdhViewport, GLD_tdpstViewportAttributes, BOOL * );
extern    CPA_EXPORT BOOL GLD_bWriteToViewportFinished3D( GLD_tdhDevice, GLD_tdhViewport );
extern    CPA_EXPORT BOOL GLD_bDeleteViewport( GLD_tdhDevice, GLD_tdhViewport );
extern    CPA_EXPORT BOOL GLD_bClearViewport( GLD_tdhDevice, GLD_tdhViewport );
extern    CPA_EXPORT BOOL GLD_bClearViewportWithChoice( GLD_tdhDevice, GLD_tdhViewport, short );
extern    CPA_EXPORT BOOL GLD_bGiveSpecificAttributesToViewport( GLD_tdhDevice, GLD_tdhViewport, void * );
 
/* Picture management */
/*
extern    CPA_EXPORT BOOL GLD_bIsPictureHandleValid( GLD_tdhPicture );
extern    CPA_EXPORT void GLD_vInvalidatePictureHandle( GLD_tdhPicture * );
 
extern    CPA_EXPORT BOOL GLD_bLoadPicture( GLD_tdpstPictureAttributes, GLD_tdhPicture * );
extern    CPA_EXPORT BOOL GLD_bGetPictureAttributes( GLD_tdhPicture, GLD_tdpstPictureAttributes );
extern    CPA_EXPORT BOOL GLD_bRequestReadFromPicture( GLD_tdhPicture, GLD_tdpstPictureAttributes, BOOL * );
extern    CPA_EXPORT BOOL GLD_bReadFromPictureFinished( GLD_tdhPicture );
extern    CPA_EXPORT BOOL GLD_bDeletePicture( GLD_tdhPicture );
*/
/* Strega stuff */
/* Forgotten management */
/*extern CPA_EXPORT BOOL GLD_bSetDeviceAttributes( GLD_tdhDevice hDev, GLD_tdpstDeviceAttributes p_stDevAttrib );*/
/*extern CPA_EXPORT BOOL GLD_bIsGoodDevice( GLD_tdhDevice hDev );*/
/*extern BOOL GLD_bSetViewportAttributes( GLD_tdhDevice hDev, GLD_tdhViewport hVP, GLD_tdpstViewportAttributes p_stViewAttrib );*/
/* Strega end */
 
extern CPA_EXPORT BOOL GLD_bReleaseViewportAndDevice(GLD_tdhDevice hDev, GLD_tdhViewport hVP);
extern CPA_EXPORT void GLD_bHardwareSetContrast( float fContrast);
extern CPA_EXPORT void GLD_bHardwareSetLuminosity( float fLuminosity);
extern CPA_EXPORT void GLD_PrintUsedStaticMemory();
/*extern CPA_EXPORT void GLD_vSetDDDriver(long);*/
/*extern CPA_EXPORT void GLD_vSetD3DDevice(long);*/
 
#ifdef __cplusplus
};
#endif /* __cplusplus */
 
#endif /* __GLD_H */
