1 /* 2 * Copyright (c) 1997-8 S3 Inc. All Rights Reserved. 3 * 4 * Module Name: s3_intrf.h 5 * 6 * Purpose: Constant, structure, and prototype definitions for S3TC 7 * interface to DX surface 8 * 9 * Author: Dan Hung, Martin Hoffesommer 10 * 11 * Revision History: 12 * version Beta 1.00.00-98-03-26 13 */ 14 15 /* High-level interface */ 16 17 #ifndef _S3_INTRF_H_ 18 #define _S3_INTRF_H_ 19 20 #ifndef NOMINMAX 21 22 #ifndef max 23 #define max(a,b) (((a) > (b)) ? (a) : (b)) 24 #endif 25 26 #ifndef min 27 #define min(a,b) (((a) < (b)) ? (a) : (b)) 28 #endif 29 30 #endif /* NOMINMAX */ 31 32 /* RGB encoding types */ 33 #define S3TC_ENCODE_RGB_FULL 0x0 34 #define S3TC_ENCODE_RGB_COLOR_KEY 0x1 35 #define S3TC_ENCODE_RGB_ALPHA_COMPARE 0x2 36 #define _S3TC_ENCODE_RGB_MASK 0xff 37 38 /* alpha encoding types */ 39 #define S3TC_ENCODE_ALPHA_NONE 0x000 40 #define S3TC_ENCODE_ALPHA_EXPLICIT 0x100 41 #define S3TC_ENCODE_ALPHA_INTERPOLATED 0x200 42 #define _S3TC_ENCODE_ALPHA_MASK 0xff00 43 44 /* common encoding types */ 45 /*@@@TBD */ 46 47 /* error codes */ 48 #define NO_ERROR 0L 49 #define ERROR_ABORTED -1L 50 51 /* 52 * PALETTEENTRY 53 */ 54 typedef struct S3_COLOR 55 { 56 char cRed; 57 char cGreen; 58 char cBlue; 59 char cAlpha; 60 } S3_COLOR; 61 62 /* 63 * S3_COLOR_SPACE 64 */ 65 typedef struct _S3_COLOR_SPACE 66 { 67 unsigned long nLowBoundary; /* low boundary of color space, inclusive */ 68 unsigned long nHighBoundary; /* high boundary of color space, inclusive */ 69 } S3_COLOR_SPACE; 70 71 /* 72 * S3_PIXEL_FORMAT 73 */ 74 typedef struct _S3_PIXEL_FORMAT 75 { 76 unsigned long nFlags; /* pixel format flags */ 77 unsigned long nARGBBitCount; /* how many bits per pixel */ 78 unsigned long nRedMask; /* mask for red channel */ 79 unsigned long nGreenMask; /* mask for green channel */ 80 unsigned long nBlueMask; /* mask for blue channel */ 81 unsigned long nAlphaMask; /* mask for alpha channel */ 82 } S3_PIXEL_FORMAT; 83 84 /**************************************************************************** 85 * 86 * S3_PIXEL_FORMAT FLAGS 87 * 88 ****************************************************************************/ 89 90 /* 91 * The pixel format includes an alpha 92 */ 93 #define S3_TF_HASALPHA 0x00000001l 94 95 /* 96 * The pixel format is palletized 97 */ 98 #define S3_TF_PALETTISED 0x00000002l 99 100 /* 101 * The pixel format is compressed 102 */ 103 #define S3_TF_COMPRESSED 0x00000004l 104 105 /* 106 * S3_TEXTURE 107 */ 108 typedef struct _S3_TEXTURE 109 { 110 unsigned long lWidth; /* width of texture */ 111 unsigned long lHeight; /* height of texture */ 112 long lPitch; /* distance to start of next line */ 113 void* pSurface; /* pointer to the associated surface memory */ 114 S3_COLOR_SPACE ColorKey; /* color key for color key alpha encoding */ 115 S3_PIXEL_FORMAT PixelFormat; /* pixel format description of the surface */ 116 S3_COLOR* pPalette; /* pointer to first item in palette */ 117 } S3_TEXTURE; 118 119 #ifdef __cplusplus 120 extern "C" { 121 #endif 122 123 /* Progress Callback for S3TCencode */ 124 typedef int (* S3TC_PROGRESS_CALLBACK)(float fProgress, void* pUser1, void* pUser2); 125 126 /* set alpha reference value for alpha compare encoding */ 127 void S3TC_SetAlphaReference(int nRef); 128 129 /* set alpha reference value for alpha compare encoding */ 130 void S3TC_SetColorWeighting(float fRed, float fGreen, float fBlue); 131 132 /* determine number of bytes needed to compress given source image */ 133 unsigned int S3TC_GetEncodeSize(unsigned long lWidth, /* [in]*/ 134 unsigned long lHeight, /* [in]*/ 135 unsigned int nEncodeType /* [in]*/ 136 ); 137 138 /* encode (compress) given source image to given destination surface */ 139 int S3TC_Encode(S3_TEXTURE *pSrc, /* [in]*/ 140 S3_TEXTURE *pDest, /* [out]*/ 141 void *lpDestBuf, /* [in]*/ 142 unsigned int nEncodeType, /* [in]*/ 143 S3TC_PROGRESS_CALLBACK pS3TCProgressProc, /* [in], may be NULL */ 144 void* pArg1, /* in*/ 145 void* pArg2 /* in*/ 146 ); 147 148 /* determine number of bytes needed do decompress given compressed image */ 149 unsigned int S3TC_GetDecodeSize(unsigned long lWidth, /* [in]*/ 150 unsigned long lHeight /* [in]*/ 151 ); 152 153 /* decode (decompress) to ARGB8888 */ 154 void S3TC_Decode(S3_TEXTURE *pSrc, /* [in]*/ 155 S3_TEXTURE *pDest, /* [out]*/ 156 void *pDestBuf /* [in]*/ 157 ); 158 159 #ifdef __cplusplus 160 }; 161 #endif 162 163 #endif 164