source: trunk/src/opengl/glide/cvg/texus/texus.h

Last change on this file was 2888, checked in by sandervl, 26 years ago

Created Voodoo 2 dir

File size: 9.9 KB
Line 
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 __TEXUS_H__
25#define __TEXUS_H__
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
31#include <stdlib.h>
32#include <stdio.h>
33
34#ifndef __3DFX_H__
35/*
36** basic data types
37*/
38typedef unsigned char FxU8;
39typedef unsigned short FxU16;
40typedef short FxI16;
41typedef unsigned long FxU32;
42typedef long FxI32;
43typedef int FxBool;
44
45/*
46** fundamental types
47*/
48
49#define FXTRUE 1
50#define FXFALSE 0
51#endif /* __3DFX_H__ */
52
53
54#ifndef __GLIDE_H__
55/* These are defined so we can use them without glide */
56typedef FxU32 GrTextureFormat_t;
57#define GR_TEXFMT_8BIT 0x0
58#define GR_TEXFMT_RGB_332 GR_TEXFMT_8BIT
59#define GR_TEXFMT_YIQ_422 0x1
60#define GR_TEXFMT_ALPHA_8 0x2 /* (0..0xFF) alpha */
61#define GR_TEXFMT_INTENSITY_8 0x3 /* (0..0xFF) intensity */
62#define GR_TEXFMT_ALPHA_INTENSITY_44 0x4
63#define GR_TEXFMT_P_8 0x5
64#define GR_TEXFMT_RSVD1 0x6
65#define GR_TEXFMT_RSVD2 0x7
66#define GR_TEXFMT_16BIT 0x8
67#define GR_TEXFMT_ARGB_8332 GR_TEXFMT_16BIT
68#define GR_TEXFMT_AYIQ_8422 0x9
69#define GR_TEXFMT_RGB_565 0xa
70#define GR_TEXFMT_ARGB_1555 0xb
71#define GR_TEXFMT_ARGB_4444 0xc
72#define GR_TEXFMT_ALPHA_INTENSITY_88 0xd
73#define GR_TEXFMT_AP_88 0xe
74#define GR_TEXFMT_RSVD4 0xf
75
76typedef FxI32 GrLOD_t;
77#ifdef GLIDE3
78#define GR_LOD_256 0x8
79#define GR_LOD_128 0x7
80#define GR_LOD_64 0x6
81#define GR_LOD_32 0x5
82#define GR_LOD_16 0x4
83#define GR_LOD_8 0x3
84#define GR_LOD_4 0x2
85#define GR_LOD_2 0x1
86#define GR_LOD_1 0x0
87#else
88#define GR_LOD_256 0x0
89#define GR_LOD_128 0x1
90#define GR_LOD_64 0x2
91#define GR_LOD_32 0x3
92#define GR_LOD_16 0x4
93#define GR_LOD_8 0x5
94#define GR_LOD_4 0x6
95#define GR_LOD_2 0x7
96#define GR_LOD_1 0x8
97#endif
98
99typedef FxI32 GrAspectRatio_t;
100#ifdef GLIDE3
101#define GR_ASPECT_8x1 3 /* 8W x 1H */
102#define GR_ASPECT_4x1 2 /* 4W x 1H */
103#define GR_ASPECT_2x1 1 /* 2W x 1H */
104#define GR_ASPECT_1x1 0 /* 1W x 1H */
105#define GR_ASPECT_1x2 -1 /* 1W x 2H */
106#define GR_ASPECT_1x4 -2 /* 1W x 4H */
107#define GR_ASPECT_1x8 -3 /* 1W x 8H */
108#else
109#define GR_ASPECT_8x1 0x0 /* 8W x 1H */
110#define GR_ASPECT_4x1 0x1 /* 4W x 1H */
111#define GR_ASPECT_2x1 0x2 /* 2W x 1H */
112#define GR_ASPECT_1x1 0x3 /* 1W x 1H */
113#define GR_ASPECT_1x2 0x4 /* 1W x 2H */
114#define GR_ASPECT_1x4 0x5 /* 1W x 4H */
115#define GR_ASPECT_1x8 0x6 /* 1W x 8H */
116#endif /* GLIDE3 */
117
118/*
119** 3DF texture file structs
120*/
121typedef struct
122{
123 FxU32 width, height;
124 int small_lod, large_lod;
125 GrAspectRatio_t aspect_ratio;
126 GrTextureFormat_t format;
127} Gu3dfHeader;
128
129typedef struct
130{
131 FxU8 yRGB[16];
132 FxI16 iRGB[4][3];
133 FxI16 qRGB[4][3];
134 FxU32 packed_data[12];
135} GuNccTable;
136
137typedef struct {
138 FxU32 data[256];
139} GuTexPalette;
140
141typedef union {
142 GuNccTable nccTable;
143 GuTexPalette palette;
144} GuTexTable;
145
146typedef struct
147{
148 Gu3dfHeader header;
149 GuTexTable table;
150 void *data;
151 FxU32 mem_required; /* memory required for mip map in bytes. */
152} Gu3dfInfo;
153
154#endif // __GLIDE_H__
155
156#define GR_TEXFMT_32BIT 0x10
157#define GR_TEXFMT_ARGB_8888 GR_TEXFMT_32BIT
158#define GR_TEXFMT_RGB_888 0x11
159#define GR_TEXFMT_ANY 0x7fffffff
160
161// Save typing fingers
162#define GR_TEXFMT_A_8 GR_TEXFMT_ALPHA_8
163#define GR_TEXFMT_I_8 GR_TEXFMT_INTENSITY_8
164#define GR_TEXFMT_AI_44 GR_TEXFMT_ALPHA_INTENSITY_44
165#define GR_TEXFMT_AI_88 GR_TEXFMT_ALPHA_INTENSITY_88
166
167#define TX_DITHER_NONE 0x00000000
168#define TX_DITHER_4x4 0x00000001
169#define TX_DITHER_ERR 0x00000002
170#define TX_DITHER_MASK 0x0000000f
171
172#define TX_COMPRESSION_STATISTICAL 0x00000000
173#define TX_COMPRESSION_HEURISTIC 0x00000010
174#define TX_COMPRESSION_MASK 0x000000f0
175
176#define TX_CLAMP_DISABLE 0x00000000
177#define TX_CLAMP_ENABLE 0x00000100
178#define TX_CLAMP_MASK 0x00000f00
179
180#define TX_AUTORESIZE_DISABLE 0x00000000
181#define TX_AUTORESIZE_GROW 0x00001000
182#define TX_AUTORESIZE_SHRINK 0x00002000
183#define TX_AUTORESIZE_MASK 0x0000f000
184
185#define TX_TARGET_PALNCC_BESTFIT 0x00000000
186#define TX_TARGET_PALNCC_SOURCE 0x00010000
187#define TX_TARGET_PALNCC_MASK 0x000f0000
188
189/*
190 * (GaryMcT)
191 * TX_FIXED_PAL_QUANT_DIST - use color distance to map a true color
192 * image back into a user specified palette.
193 * Use this when you have a lot of different
194 * palettes.
195 * TX_FIXED_PAL_QUANT_TABLE- use an inverse palette to map colors
196 * into a user specfied palette.
197 * Use this method when you have a few
198 * palettes. Will run faster if you
199 * process textures with the same
200 * palette sequentially since the palette
201 * is compiled internally to a lookup table.
202 */
203#define TX_FIXED_PAL_QUANT_DIST 0x00000000
204#define TX_FIXED_PAL_QUANT_TABLE 0x00100000
205#define TX_FIXED_PAL_QUANT_MASK 0x00f00000
206
207#define TX_WRITE_3DF 0x00000000
208#define TX_WRITE_TGA 0x00000001
209#define TX_WRITE_MASK 0x0000000f
210
211/*
212 * Publicly accessible functions.
213 */
214
215/*
216 * txInit3dfInfo:
217 * Set up the target parameters for a texture conversion.
218 * info - Glide texture structure to set up.
219 * destFormat - format that we will be converting to.
220 * destWidth, destHeight - geometry of the target texture image.
221 * Are modified if TX_AUTORESIZE is enabled.
222 * mipLevels - number of mipmap levels in the target texture.
223 * Either specifies the number of mipmap levels
224 * to create, or -1 for all possible mipmap levels.
225 * flags -
226 * auto-resample mode - TX_AUTORESIZE_*
227 */
228size_t txInit3dfInfo( Gu3dfInfo *info, GrTextureFormat_t destFormat,
229 int *destWidth, int *destHeight,
230 int mipLevels, FxU32 flags );
231
232size_t txInit3dfInfoFromFile( FILE *file,
233 Gu3dfInfo *info, GrTextureFormat_t destFormat,
234 int *destWidth, int *destHeight,
235 int mipLevels, FxU32 flags );
236
237/*
238 * txConvert: convert from an in memory texture to a Glide Gu3dfInfo.
239 * info - target texture info. . is set up with txInit3dfInfo.
240 * srcFormat - format of in-memory source texture.
241 * srcWidth, srcHeight - geometry of in memory source texture.
242 * This is not limited in size or
243 * aspect ratio.
244 * flags -
245 * dither mode - TX_DITHER_*
246 * compression - TX_COMPRESS_*
247 * clamp mode - TX_CLAMP_*
248 * palette conversion mode - TX_FIXED_PAL_QUANT_*
249 */
250FxBool txConvert( Gu3dfInfo *info, GrTextureFormat_t srcFormat,
251 int srcWidth, int srcHeight,
252 const void *srcImage, FxU32 flags,
253 const void *palNcc );
254
255FxBool txConvertFromFile( FILE *file, Gu3dfInfo *info,
256 FxU32 flags, const void *palNcc );
257
258FxBool txWrite( Gu3dfInfo *info, FILE *fp, FxU32 flags );
259
260/*
261 * Error handling.
262 */
263typedef void (*TxErrorCallbackFnc_t)( const char *string, FxBool fatal );
264
265void txErrorSetCallback( TxErrorCallbackFnc_t fnc );
266
267/*
268 * TEXUS MEMORY ALLOCATION ROUTINES.
269 * These are not to be called directly. . .they are only here
270 * so that you can redefine them to your own memory management
271 * routines.
272 */
273void *txMalloc( size_t size );
274void txFree( void *ptr );
275void *txRealloc( void *ptr, size_t size );
276
277#ifdef __cplusplus
278}
279#endif
280
281#endif /* __TEXUS_H__ */
Note: See TracBrowser for help on using the repository browser.