bug fixes, added missing state query cases
[mesa.git] / src / mesa / main / texformat.h
1 /* $Id: texformat.h,v 1.6 2001/04/04 21:54:21 brianp Exp $ */
2
3 /*
4 * Mesa 3-D graphics library
5 * Version: 3.5
6 *
7 * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
8 *
9 * Permission is hereby granted, free of charge, to any person obtaining a
10 * copy of this software and associated documentation files (the "Software"),
11 * to deal in the Software without restriction, including without limitation
12 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 * and/or sell copies of the Software, and to permit persons to whom the
14 * Software is furnished to do so, subject to the following conditions:
15 *
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
23 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 *
26 * Author:
27 * Gareth Hughes <gareth@valinux.com>
28 */
29
30 #ifndef TEXFORMAT_H
31 #define TEXFORMAT_H
32
33 #include "mtypes.h"
34
35
36 /* The Mesa internal texture image types. These will be set to their
37 * default value, but may be changed by drivers as required.
38 */
39 enum _format {
40 /* Hardware-friendly formats. Drivers can override the default
41 * formats and convert texture images to one of these as required.
42 * These formats are all little endian, as shown below. They will be
43 * most useful for x86-based PC graphics card drivers.
44 *
45 * NOTE: In the default case, some of these formats will be
46 * duplicates of the default formats listed above. However, these
47 * formats guarantee their internal component sizes, while GLchan may
48 * vary betwen GLubyte, GLushort and GLfloat.
49 */
50 /* msb <------ TEXEL BITS -----------> lsb */
51 /* ---- ---- ---- ---- ---- ---- ---- ---- */
52 MESA_FORMAT_RGBA8888, /* RRRR RRRR GGGG GGGG BBBB BBBB AAAA AAAA */
53 MESA_FORMAT_ARGB8888, /* AAAA AAAA RRRR RRRR GGGG GGGG BBBB BBBB */
54 MESA_FORMAT_RGB888, /* RRRR RRRR GGGG GGGG BBBB BBBB */
55 MESA_FORMAT_RGB565, /* RRRR RGGG GGGB BBBB */
56 MESA_FORMAT_ARGB4444, /* AAAA RRRR GGGG BBBB */
57 MESA_FORMAT_ARGB1555, /* ARRR RRGG GGGB BBBB */
58 MESA_FORMAT_AL88, /* AAAA AAAA LLLL LLLL */
59 MESA_FORMAT_RGB332, /* RRRG GGBB */
60 MESA_FORMAT_A8, /* AAAA AAAA */
61 MESA_FORMAT_L8, /* LLLL LLLL */
62 MESA_FORMAT_I8, /* IIII IIII */
63 MESA_FORMAT_CI8, /* CCCC CCCC */
64
65 /* Generic GLchan-based formats. These are the default formats used
66 * by the software rasterizer and, unless the driver overrides the
67 * texture image functions, incoming images will be converted to one
68 * of these formats. Components are arrays of GLchan values, so
69 * there will be no big/little endian issues.
70 *
71 * NOTE: Because these are based on the GLchan datatype, one cannot
72 * assume 8 bits per channel with these formats. If you require
73 * GLubyte per channel, use one of the hardware formats below.
74 */
75 MESA_FORMAT_RGBA,
76 MESA_FORMAT_RGB,
77 MESA_FORMAT_ALPHA,
78 MESA_FORMAT_LUMINANCE,
79 MESA_FORMAT_LUMINANCE_ALPHA,
80 MESA_FORMAT_INTENSITY,
81 MESA_FORMAT_COLOR_INDEX,
82 MESA_FORMAT_DEPTH_COMPONENT
83 };
84
85
86 extern GLboolean
87 _mesa_is_hardware_tex_format( const struct gl_texture_format *format );
88
89 extern const struct gl_texture_format *
90 _mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat,
91 GLenum format, GLenum type );
92
93
94 /* The default formats, GLchan per component:
95 */
96 extern const struct gl_texture_format _mesa_texformat_rgba;
97 extern const struct gl_texture_format _mesa_texformat_rgb;
98 extern const struct gl_texture_format _mesa_texformat_alpha;
99 extern const struct gl_texture_format _mesa_texformat_luminance;
100 extern const struct gl_texture_format _mesa_texformat_luminance_alpha;
101 extern const struct gl_texture_format _mesa_texformat_intensity;
102 extern const struct gl_texture_format _mesa_texformat_color_index;
103 extern const struct gl_texture_format _mesa_texformat_depth_component;
104
105 /* The hardware-friendly formats:
106 */
107 extern const struct gl_texture_format _mesa_texformat_rgba8888;
108 extern const struct gl_texture_format _mesa_texformat_argb8888;
109 extern const struct gl_texture_format _mesa_texformat_rgb888;
110 extern const struct gl_texture_format _mesa_texformat_rgb565;
111 extern const struct gl_texture_format _mesa_texformat_argb4444;
112 extern const struct gl_texture_format _mesa_texformat_argb1555;
113 extern const struct gl_texture_format _mesa_texformat_al88;
114 extern const struct gl_texture_format _mesa_texformat_rgb332;
115 extern const struct gl_texture_format _mesa_texformat_a8;
116 extern const struct gl_texture_format _mesa_texformat_l8;
117 extern const struct gl_texture_format _mesa_texformat_i8;
118 extern const struct gl_texture_format _mesa_texformat_ci8;
119
120 /* The null format:
121 */
122 extern const struct gl_texture_format _mesa_null_texformat;
123
124 #endif