/* PixFmt.h*/
/* Prototypes and structures for PixFmt.c*/
/* Author : Frederic PHILIPPE*/
/* Last update : 08/07/1997*/
 
#ifndef __PIXFMT_H
#define __PIXFMT_H
 
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
 
#include "acp_base.h"
 
/* #ifdef GLI_D3D */
#if !defined(U64)	/* N64 does not want D3D stuffs... thanks*/
/*#include <d3d.h>*/
#endif /* U64 */
/* #endif */
 
/* format predefini de pixel */
#define GLD_C_xUndefinedPixelFormat  0  /* 0000 0000  0000 0000  0000 0000  0000 0000 */
#define GLD_C_xN1B5G5R5PixelFormat   1  /* 0000 0000  0000 0000  0BBB BBGG  GGGR RRRR */
#define GLD_C_xA1B5G5R5PixelFormat   2  /* 0000 0000  0000 0000  ABBB BBGG  GGGR RRRR */
#define GLD_C_xN1R5G5B5PixelFormat   3  /* 0000 0000  0000 0000  0RRR RRGG  GGGB BBBB */
#define GLD_C_xA4B4G4R4PixelFormat   4  /* 0000 0000  0000 0000  AAAA BBBB  GGGG RRRR */
#define GLD_C_xB8G8R8PixelFormat     5  /* 0000 0000  BBBB BBBB  GGGG GGGG  RRRR RRRR */
#define GLD_C_xA8B8G8R8PixelFormat   6  /* AAAA AAAA  BBBB BBBB  GGGG GGGG  RRRR RRRR */
#define GLD_C_xB5G6R5PixelFormat     7  /* 0000 0000  0000 0000  BBBB BGGG  GGGR RRRR */
#define GLD_C_xB6G5R5PixelFormat     8  /* 0000 0000  0000 0000  BBBB BBGG  GGGR RRRR */
#define GLD_C_xB5G5R6PixelFormat     9  /* 0000 0000  0000 0000  BBBB BGGG  GGRR RRRR */
#define GLD_C_xB5G5R5A1PixelFormat  10  /* 0000 0000  0000 0000  BBBB BGGG  GGRR RRRA */
#define GLD_C_xR5G6B5PixelFormat    11  /* 0000 0000  0000 0000  RRRR RGGG  GGGB BBBB */
#define GLD_C_xR6G5B5PixelFormat    12  /* 0000 0000  0000 0000  RRRR RRGG  GGGB BBBB */
#define GLD_C_xR5G5B6PixelFormat    13  /* 0000 0000  0000 0000  RRRR RGGG  GGBB BBBB */
#if defined(U64)
#define GLD_C_xR5G5B5A1PixelFormat	14	/* 0000 0000  0000 0000  RRRR RGGG  GGBB BBBA */
#endif /* U64 */
 
#define GLD_C_lMaxNumberOfPixelFormat 16
 
/* pixel format */
typedef struct GLD_stPixelFormat
{
  /* numero du format */
  ACP_tdxIndex xFormatNumber;
 
  /* alpha ? */
  ACP_tdxBool bAlpha;
 
  /* nombre de bits total du pixel */
  long lPixelNbBits;
  /* masque du pixel */
  unsigned long ulPixelMask;
  /* nombre d octets par pixel */
  long lPixelNbBytes;
 
  /* composante rouge */
  long lRedNbBits;
  long lRedShift;
  unsigned long ulRedMask;
 
  /* composante verte */
  long lGreenNbBits;
  long lGreenShift;
  unsigned long ulGreenMask;
 
  /* composante bleue */
  long lBlueNbBits;
  long lBlueShift;
  unsigned long ulBlueMask;
 
  /* composante alpha */
  long lAlphaNbBits;
  long lAlphaShift;
  unsigned long ulAlphaMask;
 
} GLD_tdstPixelFormat, *GLD_tdpstPixelFormat;
 
void GLD_vSetDefinedPixelFormat ( GLD_tdpstPixelFormat p_stPixelFormat, ACP_tdxIndex xPixelFormatNumber );
void GLD_vCopyPixelFormat ( GLD_tdpstPixelFormat p_stDstPixelFormat, GLD_tdpstPixelFormat p_stSrcPixelFormat );
GLD_tdstPixelFormat *GLD_fn_p_stGetDefinedPixelFormat( long _lFormatIndex );
long GLD_fn_lAddDefinedPixelFormat( GLD_tdstPixelFormat *_p_stNewPF );
 
#if !defined(U64)	/* N64 does not want DirectDraw Pixel Foramt... thanks*/
/*extern CPA_EXPORT void GLD_vConvertDDPixelFormatToPixelFormat ( ACP_tdxIndex xFormatNumber, GLD_tdpstPixelFormat p_stDstPixelFormat, LPDDPIXELFORMAT p_stDDPixelFormat );*/
/*extern CPA_EXPORT ACP_tdxBool GLD_bConvertDDPixelFormatToDefinedPixelFormat ( GLD_tdpstPixelFormat p_stDstPixelFormat, LPDDPIXELFORMAT p_stDDPixelFormat );*/
#endif /* U64 */
 
extern CPA_EXPORT ACP_tdxBool GLD_bGetPixelFormatOfDevice ( GLD_tdpstPixelFormat p_stDstPixelFormat, GLD_tdhDevice hDev, GLD_tdhViewport hVP );
 
/* attention : convertion entre les formats RGB 16 bits seulement */
extern CPA_EXPORT void GLD_vBitmapConvert16bPixelFormat ( GLD_tdpstPixelFormat p_stDstPixelFormat, GLD_tdpstPixelFormat p_stSrcPixelFormat, unsigned short *p_usBuffer, long lBufferSize );
extern CPA_EXPORT void GLD_vYInvertBitmap24b ( unsigned char *_p_ucBuffer, long _lWidth, long _lHeight );
extern CPA_EXPORT void GLD_vBitmapConvert24bTo16bPixelFormat ( unsigned short *_p_usDstBuffer, unsigned char *_p_ucSrcBuffer, long _lWidth, long _lHeight );
extern CPA_EXPORT void GLD_vBitmapConvert24bTo16bPixelFormatAndFiltre ( unsigned short *_p_usDstBuffer, long _lWDst, long _lHDst, unsigned char *_p_ucSrcBuffer, long _lWSrc, long _lHSrc );
extern CPA_EXPORT void GLD_fn_vBlit16b ( long _lW, long _lH, unsigned short *_p_usBufferDst, long _lPitch, unsigned short *_p_usBufferSrc );
extern CPA_EXPORT void GLD_fn_vBlitStretched16b ( long _lWDst, long _lHDst, unsigned short *_p_usBufferDst, long _lPitch, long _lWSrc, long _lHSrc, unsigned short *_p_usBufferSrc );
extern CPA_EXPORT void GLD_vBitmapConvertAndBlit24bTo16bPixelFormat ( GLD_tdhDevice _hGLDDevice, GLD_tdhViewport _hGLDViewport, long _lWidth, long _lHeight, unsigned char *_p_ucBufferSrc );
extern CPA_EXPORT void GLD_vGetFrontBufferIn24BitsAA( GLD_tdhDevice,GLD_tdhViewport,unsigned long _lWidth,unsigned long _lHeight,unsigned char *p_lBufferDst );
#ifdef __cplusplus
};
#endif /* __cplusplus */
 
#endif /* __PIXFMT_H*/
