1 | /*
|
---|
2 | ** THIS SOFTWARE IS SUBJECT TO COPYRIGHT PROTECTION AND IS OFFERED ONLY
|
---|
3 | ** PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT
|
---|
4 | ** TO USE THE GLIDE TRADEMARK WITHOUT PRIOR WRITTEN PERMISSION OF 3DFX
|
---|
5 | ** INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE
|
---|
6 | ** DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com).
|
---|
7 | ** THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
|
---|
8 | ** EXPRESSED OR IMPLIED. SEE THE 3DFX GLIDE GENERAL PUBLIC LICENSE FOR A
|
---|
9 | ** FULL TEXT OF THE NON-WARRANTY PROVISIONS.
|
---|
10 | **
|
---|
11 | ** USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO
|
---|
12 | ** RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS IN
|
---|
13 | ** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 252.227-7013,
|
---|
14 | ** AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR
|
---|
15 | ** SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF
|
---|
16 | ** THE UNITED STATES.
|
---|
17 | **
|
---|
18 | ** COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED
|
---|
19 | **
|
---|
20 | ** $Revision: 1.1 $
|
---|
21 | ** $Date: 2000-02-25 00:38:01 $
|
---|
22 | */
|
---|
23 |
|
---|
24 | #ifndef __TEXUSINT_H__
|
---|
25 | #define __TEXUSINT_H__
|
---|
26 |
|
---|
27 | #include "texus.h"
|
---|
28 |
|
---|
29 | #define GR_TEXFMT_SIZE(x) ((x < GR_TEXFMT_16BIT) ? 1: \
|
---|
30 | ((x < GR_TEXFMT_32BIT) ? 2: 4))
|
---|
31 |
|
---|
32 | #define TX_OFORMAT_3DF 10
|
---|
33 | #define TX_OFORMAT_TGA 11
|
---|
34 | #define TX_OFORMAT_PPM 12
|
---|
35 |
|
---|
36 | #define TX_MAX_LEVEL 16
|
---|
37 | typedef struct _TxMip {
|
---|
38 | int format; // GR_TEXFMT_...
|
---|
39 | int width; // pixels
|
---|
40 | int height; // pixels
|
---|
41 | int depth; // mipmap levels
|
---|
42 | int size; // bytes
|
---|
43 | void *data[TX_MAX_LEVEL];
|
---|
44 | FxU32 pal[256];
|
---|
45 | } TxMip;
|
---|
46 |
|
---|
47 | FxBool txMipRead(TxMip *txMip, const char *filename, int preferredFormat);
|
---|
48 | FxBool txMipReadFromFP(TxMip *txMip, const char *debug_filename, FILE *file, int preferredFormat);
|
---|
49 | void txMipWrite(TxMip *txMip, char *file, char *ext, int split);
|
---|
50 | void txMipResample(TxMip *destMip, TxMip *srcMip);
|
---|
51 | void txMipClamp( TxMip *dstMip, TxMip *srcMip );
|
---|
52 | void txMipMipmap(TxMip *txMip);
|
---|
53 |
|
---|
54 | void txMipQuantize(TxMip *pxMip, TxMip *txMip, int fmt, FxU32 d, FxU32 comp);
|
---|
55 | void txMipNcc(TxMip *pxMip, TxMip *txMip, int fmt, FxU32 dither, FxU32 comp);
|
---|
56 | void txMipNccNNet(TxMip *pxMip, TxMip *txMip, int fmt, FxU32 dither, FxU32 comp);
|
---|
57 | int txMipPal256(TxMip *pxMip, TxMip *txMip, int fmt, FxU32 dither, FxU32 comp);
|
---|
58 |
|
---|
59 | void txMipDequantize(TxMip *txMip, TxMip *pxMip);
|
---|
60 | void txMipView(TxMip *txMip, char *filename, int wait, int bgcolor);
|
---|
61 | void txViewClose();
|
---|
62 |
|
---|
63 | int txLog2(int n);
|
---|
64 | int txFloorPow2(int n);
|
---|
65 | int txCeilPow2(int n);
|
---|
66 | int txGCD(int a, int b);
|
---|
67 | int txAspectRatio(int w, int h);
|
---|
68 | void txPanic(char *);
|
---|
69 | void txError(char *);
|
---|
70 | void txYABtoPal256(long *palette, const long* yabTable);
|
---|
71 | void txRectCopy(FxU8 *dst, int dstStride, const FxU8 *src, int srcStride,
|
---|
72 | int width, int height);
|
---|
73 | FxBool txMipAlloc(TxMip *txMip);
|
---|
74 | FxBool txMipSetMipPointers(TxMip *txMip);
|
---|
75 | int txMemRequired(TxMip *txMip);
|
---|
76 | void txBasename(const char *name, char *base);
|
---|
77 | void txPathAndBasename(const char *name, char* pathbase);
|
---|
78 | void txExtension(const char *name, char *ext);
|
---|
79 |
|
---|
80 | void txMipFree( TxMip *mip );
|
---|
81 | void txMipTrueToFixedPal( TxMip *outputMip, TxMip *trueColorMip, const FxU32 *pal,
|
---|
82 | FxU32 flags );
|
---|
83 |
|
---|
84 |
|
---|
85 |
|
---|
86 | extern int txVerbose;
|
---|
87 | extern int *explode3;
|
---|
88 | #define DISTANCE(ar, ag, ab, br, bg, bb) \
|
---|
89 | ((explode3[(ar)-(br)] << 1) + (explode3[(ag)-(bg)]<<2) + explode3[(ab)-(bb)])
|
---|
90 |
|
---|
91 | void txDiffuseIndex(TxMip *pxMip, TxMip *txMip, int pixsize,
|
---|
92 | const FxU32 *palette, int ncolors);
|
---|
93 | int txNearestColor(long ir, long ig, long ib, const FxU32 *pal, int npal);
|
---|
94 |
|
---|
95 | FxBool _txReadTGAHeader( FILE *stream, FxU32 cookie, TxMip *info);
|
---|
96 | FxBool _txReadTGAData( FILE *stream, TxMip *info);
|
---|
97 |
|
---|
98 | FxBool _txReadRGTHeader( FILE *stream, FxU32 cookie, TxMip *info);
|
---|
99 | FxBool _txReadRGTData( FILE *stream, TxMip *info);
|
---|
100 |
|
---|
101 | FxBool _txReadSBIHeader( FILE *stream, FxU32 cookie, TxMip *info);
|
---|
102 | FxBool _txReadSBIData( FILE *stream, TxMip *info);
|
---|
103 |
|
---|
104 | FxBool _txReadPPMHeader( FILE *stream, FxU32 cookie, TxMip *info);
|
---|
105 | FxBool _txReadPPMData( FILE *stream, TxMip *info);
|
---|
106 |
|
---|
107 | FxBool _txRead3DFHeader( FILE *stream, FxU32 cookie, TxMip *info);
|
---|
108 | FxBool _txRead3DFData( FILE *stream, TxMip *info);
|
---|
109 |
|
---|
110 | int _txReadHeader( FILE *stream, TxMip *info );
|
---|
111 |
|
---|
112 | void txPalToNcc( GuNccTable *ncc_table, const FxU32 *pal );
|
---|
113 | void txNccToPal( FxU32 *pal, const GuNccTable *ncc_table );
|
---|
114 |
|
---|
115 | #define MAX_TEXWIDTH 1024
|
---|
116 |
|
---|
117 | extern TxErrorCallbackFnc_t _txErrorCallback;
|
---|
118 |
|
---|
119 | extern char *Format_Name[];
|
---|
120 |
|
---|
121 | #endif /* __TEXUSINT_H__ */
|
---|