3 * Main Mesa data structures.
5 * Please try to mark derived values with a leading underscore ('_').
9 * Mesa 3-D graphics library
12 * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
14 * Permission is hereby granted, free of charge, to any person obtaining a
15 * copy of this software and associated documentation files (the "Software"),
16 * to deal in the Software without restriction, including without limitation
17 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
18 * and/or sell copies of the Software, and to permit persons to whom the
19 * Software is furnished to do so, subject to the following conditions:
21 * The above copyright notice and this permission notice shall be included
22 * in all copies or substantial portions of the Software.
24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
25 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
27 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
28 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
39 #include "config.h" /* Hardwired parameters */
40 #include "glapitable.h"
42 #include "math/m_matrix.h" /* GLmatrix */
46 * Color channel data type.
49 typedef GLubyte GLchan
;
51 #define CHAN_MAXF 255.0F
52 #define CHAN_TYPE GL_UNSIGNED_BYTE
54 typedef GLushort GLchan
;
55 #define CHAN_MAX 65535
56 #define CHAN_MAXF 65535.0F
57 #define CHAN_TYPE GL_UNSIGNED_SHORT
59 typedef GLfloat GLchan
;
61 #define CHAN_MAXF 1.0F
62 #define CHAN_TYPE GL_FLOAT
64 #error "illegal number of color channel bits"
69 * Accumulation buffer data type.
72 typedef GLbyte GLaccum
;
74 typedef GLshort GLaccum
;
76 typedef GLfloat GLaccum
;
78 # error "illegal number of accumulation bits"
83 * Stencil buffer data type.
86 typedef GLubyte GLstencil
;
87 # define STENCIL_MAX 0xff
88 #elif STENCIL_BITS==16
89 typedef GLushort GLstencil
;
90 # define STENCIL_MAX 0xffff
92 # error "illegal number of stencil bits"
97 * Depth buffer data type.
99 * \note Must be 32-bits!
101 typedef GLuint GLdepth
;
105 * Fixed point data type.
109 * Fixed point arithmetic macros
112 #define FIXED_ONE 0x00004000
113 #define FIXED_HALF 0x00002000
114 #define FIXED_FRAC_MASK 0x00003FFF
115 #define FIXED_SCALE 16384.0f
116 #define FIXED_SHIFT 14
118 #define FIXED_ONE 0x00000800
119 #define FIXED_HALF 0x00000400
120 #define FIXED_FRAC_MASK 0x000007FF
121 #define FIXED_SCALE 2048.0f
122 #define FIXED_SHIFT 11
124 #define FIXED_INT_MASK (~FIXED_FRAC_MASK)
125 #define FIXED_EPSILON 1
126 #define FloatToFixed(X) (IROUND((X) * FIXED_SCALE))
127 #define IntToFixed(I) ((I) << FIXED_SHIFT)
128 #define FixedToInt(X) ((X) >> FIXED_SHIFT)
129 #define FixedToUns(X) (((unsigned int)(X)) >> FIXED_SHIFT)
130 #define FixedCeil(X) (((X) + FIXED_ONE - FIXED_EPSILON) & FIXED_INT_MASK)
131 #define FixedFloor(X) ((X) & FIXED_INT_MASK)
132 #define FixedToFloat(X) ((X) * (1.0F / FIXED_SCALE))
133 #define PosFloatToFixed(X) FloatToFixed(X)
134 #define SignedFloatToFixed(X) FloatToFixed(X)
139 * \name Some forward type declarations
142 struct _mesa_HashTable
;
143 struct gl_texture_image
;
144 struct gl_texture_object
;
145 typedef struct __GLcontextRec GLcontext
;
146 typedef struct __GLcontextModesRec GLvisual
;
147 typedef struct gl_frame_buffer GLframebuffer
;
153 * These define the aliases between numbered vertex attributes and
154 * conventional OpenGL vertex attributes. We use these values in
155 * quite a few places.
161 VERT_ATTRIB_WEIGHT
= 1,
162 VERT_ATTRIB_NORMAL
= 2,
163 VERT_ATTRIB_COLOR0
= 3,
164 VERT_ATTRIB_COLOR1
= 4,
167 VERT_ATTRIB_SEVEN
= 7,
168 VERT_ATTRIB_TEX0
= 8,
169 VERT_ATTRIB_TEX1
= 9,
170 VERT_ATTRIB_TEX2
= 10,
171 VERT_ATTRIB_TEX3
= 11,
172 VERT_ATTRIB_TEX4
= 12,
173 VERT_ATTRIB_TEX5
= 13,
174 VERT_ATTRIB_TEX6
= 14,
175 VERT_ATTRIB_TEX7
= 15,
179 /* These are used in bitfields in many places */
180 #define VERT_BIT_POS (1 << VERT_ATTRIB_POS)
181 #define VERT_BIT_WEIGHT (1 << VERT_ATTRIB_WEIGHT)
182 #define VERT_BIT_NORMAL (1 << VERT_ATTRIB_NORMAL)
183 #define VERT_BIT_COLOR0 (1 << VERT_ATTRIB_COLOR0)
184 #define VERT_BIT_COLOR1 (1 << VERT_ATTRIB_COLOR1)
185 #define VERT_BIT_FOG (1 << VERT_ATTRIB_FOG)
186 #define VERT_BIT_SIX (1 << VERT_ATTRIB_SIX)
187 #define VERT_BIT_SEVEN (1 << VERT_ATTRIB_SEVEN)
188 #define VERT_BIT_TEX0 (1 << VERT_ATTRIB_TEX0)
189 #define VERT_BIT_TEX1 (1 << VERT_ATTRIB_TEX1)
190 #define VERT_BIT_TEX2 (1 << VERT_ATTRIB_TEX2)
191 #define VERT_BIT_TEX3 (1 << VERT_ATTRIB_TEX3)
192 #define VERT_BIT_TEX4 (1 << VERT_ATTRIB_TEX4)
193 #define VERT_BIT_TEX5 (1 << VERT_ATTRIB_TEX5)
194 #define VERT_BIT_TEX6 (1 << VERT_ATTRIB_TEX6)
195 #define VERT_BIT_TEX7 (1 << VERT_ATTRIB_TEX7)
197 #define VERT_BIT_TEX(u) (1 << (VERT_ATTRIB_TEX0 + (u)))
200 /* Fragment programs use a different but related set of attributes:
203 /* Fragment input registers / attributes */
204 #define FRAG_ATTRIB_WPOS 0
205 #define FRAG_ATTRIB_COL0 1
206 #define FRAG_ATTRIB_COL1 2
207 #define FRAG_ATTRIB_FOGC 3
208 #define FRAG_ATTRIB_TEX0 4
209 #define FRAG_ATTRIB_TEX1 5
210 #define FRAG_ATTRIB_TEX2 6
211 #define FRAG_ATTRIB_TEX3 7
212 #define FRAG_ATTRIB_TEX4 8
213 #define FRAG_ATTRIB_TEX5 9
214 #define FRAG_ATTRIB_TEX6 10
215 #define FRAG_ATTRIB_TEX7 11
217 /* Bitmasks for the above */
218 #define FRAG_BIT_WPOS (1 << FRAG_ATTRIB_WPOS)
219 #define FRAG_BIT_COL0 (1 << FRAG_ATTRIB_COL0)
220 #define FRAG_BIT_COL1 (1 << FRAG_ATTRIB_COL1)
221 #define FRAG_BIT_FOGC (1 << FRAG_ATTRIB_FOGC)
222 #define FRAG_BIT_TEX0 (1 << FRAG_ATTRIB_TEX0)
223 #define FRAG_BIT_TEX1 (1 << FRAG_ATTRIB_TEX1)
224 #define FRAG_BIT_TEX2 (1 << FRAG_ATTRIB_TEX2)
225 #define FRAG_BIT_TEX3 (1 << FRAG_ATTRIB_TEX3)
226 #define FRAG_BIT_TEX4 (1 << FRAG_ATTRIB_TEX4)
227 #define FRAG_BIT_TEX5 (1 << FRAG_ATTRIB_TEX5)
228 #define FRAG_BIT_TEX6 (1 << FRAG_ATTRIB_TEX6)
229 #define FRAG_BIT_TEX7 (1 << FRAG_ATTRIB_TEX7)
231 #define FRAG_BITS_TEX_ANY (FRAG_BIT_TEX0| \
243 * Maximum number of temporary vertices required for clipping.
245 * Used in array_cache and tnl modules.
247 #define MAX_CLIPPED_VERTICES ((2 * (6 + MAX_CLIP_PLANES))+1)
251 * Data structure for color tables
253 struct gl_color_table
{
254 GLenum Format
; /**< GL_ALPHA, GL_RGB, GL_RGB, etc */
256 GLuint Size
; /**< number of entries (rows) in table */
257 GLvoid
*Table
; /**< either GLfloat * or GLchan * */
258 GLboolean FloatTable
; /**< are entries stored as floats? */
263 GLubyte LuminanceSize
;
264 GLubyte IntensitySize
;
269 * \name Bit flags used for updating material values.
272 #define MAT_ATTRIB_FRONT_AMBIENT 0
273 #define MAT_ATTRIB_BACK_AMBIENT 1
274 #define MAT_ATTRIB_FRONT_DIFFUSE 2
275 #define MAT_ATTRIB_BACK_DIFFUSE 3
276 #define MAT_ATTRIB_FRONT_SPECULAR 4
277 #define MAT_ATTRIB_BACK_SPECULAR 5
278 #define MAT_ATTRIB_FRONT_EMISSION 6
279 #define MAT_ATTRIB_BACK_EMISSION 7
280 #define MAT_ATTRIB_FRONT_SHININESS 8
281 #define MAT_ATTRIB_BACK_SHININESS 9
282 #define MAT_ATTRIB_FRONT_INDEXES 10
283 #define MAT_ATTRIB_BACK_INDEXES 11
284 #define MAT_ATTRIB_MAX 12
286 #define MAT_ATTRIB_AMBIENT(f) (MAT_ATTRIB_FRONT_AMBIENT+(f))
287 #define MAT_ATTRIB_DIFFUSE(f) (MAT_ATTRIB_FRONT_DIFFUSE+(f))
288 #define MAT_ATTRIB_SPECULAR(f) (MAT_ATTRIB_FRONT_SPECULAR+(f))
289 #define MAT_ATTRIB_EMISSION(f) (MAT_ATTRIB_FRONT_EMISSION+(f))
290 #define MAT_ATTRIB_SHININESS(f)(MAT_ATTRIB_FRONT_SHININESS+(f))
291 #define MAT_ATTRIB_INDEXES(f) (MAT_ATTRIB_FRONT_INDEXES+(f))
293 #define MAT_INDEX_AMBIENT 0
294 #define MAT_INDEX_DIFFUSE 1
295 #define MAT_INDEX_SPECULAR 2
297 #define MAT_BIT_FRONT_AMBIENT (1<<MAT_ATTRIB_FRONT_AMBIENT)
298 #define MAT_BIT_BACK_AMBIENT (1<<MAT_ATTRIB_BACK_AMBIENT)
299 #define MAT_BIT_FRONT_DIFFUSE (1<<MAT_ATTRIB_FRONT_DIFFUSE)
300 #define MAT_BIT_BACK_DIFFUSE (1<<MAT_ATTRIB_BACK_DIFFUSE)
301 #define MAT_BIT_FRONT_SPECULAR (1<<MAT_ATTRIB_FRONT_SPECULAR)
302 #define MAT_BIT_BACK_SPECULAR (1<<MAT_ATTRIB_BACK_SPECULAR)
303 #define MAT_BIT_FRONT_EMISSION (1<<MAT_ATTRIB_FRONT_EMISSION)
304 #define MAT_BIT_BACK_EMISSION (1<<MAT_ATTRIB_BACK_EMISSION)
305 #define MAT_BIT_FRONT_SHININESS (1<<MAT_ATTRIB_FRONT_SHININESS)
306 #define MAT_BIT_BACK_SHININESS (1<<MAT_ATTRIB_BACK_SHININESS)
307 #define MAT_BIT_FRONT_INDEXES (1<<MAT_ATTRIB_FRONT_INDEXES)
308 #define MAT_BIT_BACK_INDEXES (1<<MAT_ATTRIB_BACK_INDEXES)
311 #define FRONT_MATERIAL_BITS (MAT_BIT_FRONT_EMISSION | \
312 MAT_BIT_FRONT_AMBIENT | \
313 MAT_BIT_FRONT_DIFFUSE | \
314 MAT_BIT_FRONT_SPECULAR | \
315 MAT_BIT_FRONT_SHININESS | \
316 MAT_BIT_FRONT_INDEXES)
318 #define BACK_MATERIAL_BITS (MAT_BIT_BACK_EMISSION | \
319 MAT_BIT_BACK_AMBIENT | \
320 MAT_BIT_BACK_DIFFUSE | \
321 MAT_BIT_BACK_SPECULAR | \
322 MAT_BIT_BACK_SHININESS | \
323 MAT_BIT_BACK_INDEXES)
325 #define ALL_MATERIAL_BITS (FRONT_MATERIAL_BITS | BACK_MATERIAL_BITS)
329 #define EXP_TABLE_SIZE 512 /**< Specular exponent lookup table sizes */
330 #define SHINE_TABLE_SIZE 256 /**< Material shininess lookup table sizes */
333 * Material shininess lookup table.
335 struct gl_shine_tab
{
336 struct gl_shine_tab
*next
, *prev
;
337 GLfloat tab
[SHINE_TABLE_SIZE
+1];
347 struct gl_light
*next
; /**< double linked list with sentinel */
348 struct gl_light
*prev
;
350 GLfloat Ambient
[4]; /**< ambient color */
351 GLfloat Diffuse
[4]; /**< diffuse color */
352 GLfloat Specular
[4]; /**< specular color */
353 GLfloat EyePosition
[4]; /**< position in eye coordinates */
354 GLfloat EyeDirection
[4]; /**< spotlight dir in eye coordinates */
355 GLfloat SpotExponent
;
356 GLfloat SpotCutoff
; /**< in degrees */
357 GLfloat _CosCutoff
; /**< = MAX(0, cos(SpotCutoff)) */
358 GLfloat ConstantAttenuation
;
359 GLfloat LinearAttenuation
;
360 GLfloat QuadraticAttenuation
;
361 GLboolean Enabled
; /**< On/off flag */
364 * \name Derived fields
367 GLuint _Flags
; /**< State */
369 GLfloat _Position
[4]; /**< position in eye/obj coordinates */
370 GLfloat _VP_inf_norm
[3]; /**< Norm direction to infinite light */
371 GLfloat _h_inf_norm
[3]; /**< Norm( _VP_inf_norm + <0,0,1> ) */
372 GLfloat _NormDirection
[4]; /**< normalized spotlight direction */
373 GLfloat _VP_inf_spot_attenuation
;
375 GLfloat _SpotExpTable
[EXP_TABLE_SIZE
][2]; /**< to replace a pow() call */
376 GLfloat _MatAmbient
[2][3]; /**< material ambient * light ambient */
377 GLfloat _MatDiffuse
[2][3]; /**< material diffuse * light diffuse */
378 GLfloat _MatSpecular
[2][3]; /**< material spec * light specular */
379 GLfloat _dli
; /**< CI diffuse light intensity */
380 GLfloat _sli
; /**< CI specular light intensity */
388 struct gl_lightmodel
{
389 GLfloat Ambient
[4]; /**< ambient color */
390 GLboolean LocalViewer
; /**< Local (or infinite) view point? */
391 GLboolean TwoSide
; /**< Two (or one) sided lighting? */
392 GLenum ColorControl
; /**< either GL_SINGLE_COLOR
393 * or GL_SEPARATE_SPECULAR_COLOR */
402 GLfloat Attrib
[MAT_ATTRIB_MAX
][4];
407 * Accumulation buffer attributes.
409 struct gl_accum_attrib
{
410 GLfloat ClearColor
[4]; /**< Accumulation buffer clear color */
415 * \name Clipping planes bits
417 * Used in gl_colorbuffer_attrib::_DrawDestMask and
418 * gl_colorbuffer_attrib::_ReadSrcMask below to identify color buffers.
421 #define FRONT_LEFT_BIT 0x1
422 #define FRONT_RIGHT_BIT 0x2
423 #define BACK_LEFT_BIT 0x4
424 #define BACK_RIGHT_BIT 0x8
425 #define AUX0_BIT 0x10
426 #define AUX1_BIT 0x20
427 #define AUX2_BIT 0x40
428 #define AUX3_BIT 0x80
433 * Color buffers attributes.
435 struct gl_colorbuffer_attrib
{
436 GLuint ClearIndex
; /**< Index to use for glClear */
437 GLclampf ClearColor
[4]; /**< Color to use for glClear */
439 GLuint IndexMask
; /**< Color index write mask */
440 GLubyte ColorMask
[4]; /**< Each flag is 0xff or 0x0 */
442 GLenum DrawBuffer
; /**< Which buffer to draw into */
443 GLubyte _DrawDestMask
; /**< bitwise-OR of FRONT/BACK_LEFT/RIGHT_BITs */
446 * \name alpha testing
449 GLboolean AlphaEnabled
; /**< Alpha test enabled flag */
450 GLenum AlphaFunc
; /**< Alpha test function */
451 GLclampf AlphaRef
; /**< Alpha reference value */
458 GLboolean BlendEnabled
; /**< Blending enabled flag */
459 GLenum BlendSrcRGB
; /**< Blending source operator */
460 GLenum BlendDstRGB
; /**< Blending destination operator */
461 GLenum BlendSrcA
; /**< GL_INGR_blend_func_separate */
462 GLenum BlendDstA
; /**< GL_INGR_blend_func_separate */
463 GLenum BlendEquationRGB
; /**< Blending equation */
464 GLenum BlendEquationA
; /**< GL_EXT_blend_equation_separate */
465 GLfloat BlendColor
[4]; /**< Blending color */
472 GLenum LogicOp
; /**< Logic operator */
473 GLboolean IndexLogicOpEnabled
; /**< Color index logic op enabled flag */
474 GLboolean ColorLogicOpEnabled
; /**< RGBA logic op enabled flag */
475 GLboolean _LogicOpEnabled
; /**< RGBA logic op + EXT_blend_logic_op enabled flag */
478 GLboolean DitherFlag
; /**< Dither enable flag */
483 * Current attributes.
485 struct gl_current_attrib
{
487 * \name Values valid only when FLUSH_VERTICES has been called.
490 GLfloat Attrib
[VERT_ATTRIB_MAX
][4]; /**< Current vertex attributes
491 * indexed by VERT_ATTRIB_* */
492 GLfloat Index
; /**< Current color index */
493 GLboolean EdgeFlag
; /**< Current edge flag */
497 * \name Values are always valid.
499 * \note BTW, note how similar this set of attributes is to the SWvertex
500 * data type in the software rasterizer...
503 GLfloat RasterPos
[4]; /**< Current raster position */
504 GLfloat RasterDistance
; /**< Current raster distance */
505 GLfloat RasterColor
[4]; /**< Current raster color */
506 GLfloat RasterSecondaryColor
[4]; /**< Current raster secondary color */
507 GLfloat RasterIndex
; /**< Current raster index */
508 GLfloat RasterTexCoords
[MAX_TEXTURE_UNITS
][4];/**< Current raster texcoords */
509 GLboolean RasterPosValid
; /**< Raster pos valid flag */
515 * Depth buffer attributes.
517 struct gl_depthbuffer_attrib
{
518 GLenum Func
; /**< Function for depth buffer compare */
519 GLclampd Clear
; /**< Value to clear depth buffer to */
520 GLboolean Test
; /**< Depth buffering enabled flag */
521 GLboolean Mask
; /**< Depth buffer writable? */
522 GLboolean OcclusionTest
; /**< GL_HP_occlusion_test */
523 GLboolean BoundsTest
; /**< GL_EXT_depth_bounds_test */
524 GLfloat BoundsMin
, BoundsMax
;/**< GL_EXT_depth_bounds_test */
529 * glEnable()/glDisable() attributes.
531 struct gl_enable_attrib
{
533 GLboolean AutoNormal
;
536 GLboolean ColorMaterial
;
537 GLboolean ColorTable
; /* SGI_color_table */
538 GLboolean PostColorMatrixColorTable
; /* SGI_color_table */
539 GLboolean PostConvolutionColorTable
; /* SGI_color_table */
540 GLboolean Convolution1D
;
541 GLboolean Convolution2D
;
542 GLboolean Separable2D
;
548 GLboolean Light
[MAX_LIGHTS
];
550 GLboolean LineSmooth
;
551 GLboolean LineStipple
;
552 GLboolean IndexLogicOp
;
553 GLboolean ColorLogicOp
;
554 GLboolean Map1Color4
;
556 GLboolean Map1Normal
;
557 GLboolean Map1TextureCoord1
;
558 GLboolean Map1TextureCoord2
;
559 GLboolean Map1TextureCoord3
;
560 GLboolean Map1TextureCoord4
;
561 GLboolean Map1Vertex3
;
562 GLboolean Map1Vertex4
;
563 GLboolean Map1Attrib
[16]; /* GL_NV_vertex_program */
564 GLboolean Map2Color4
;
566 GLboolean Map2Normal
;
567 GLboolean Map2TextureCoord1
;
568 GLboolean Map2TextureCoord2
;
569 GLboolean Map2TextureCoord3
;
570 GLboolean Map2TextureCoord4
;
571 GLboolean Map2Vertex3
;
572 GLboolean Map2Vertex4
;
573 GLboolean Map2Attrib
[16]; /* GL_NV_vertex_program */
576 GLboolean PixelTexture
;
577 GLboolean PointSmooth
;
578 GLboolean PolygonOffsetPoint
;
579 GLboolean PolygonOffsetLine
;
580 GLboolean PolygonOffsetFill
;
581 GLboolean PolygonSmooth
;
582 GLboolean PolygonStipple
;
583 GLboolean RescaleNormals
;
586 GLboolean MultisampleEnabled
; /* GL_ARB_multisample */
587 GLboolean SampleAlphaToCoverage
; /* GL_ARB_multisample */
588 GLboolean SampleAlphaToOne
; /* GL_ARB_multisample */
589 GLboolean SampleCoverage
; /* GL_ARB_multisample */
590 GLboolean SampleCoverageInvert
; /* GL_ARB_multisample */
591 GLboolean RasterPositionUnclipped
; /* GL_IBM_rasterpos_clip */
592 GLuint Texture
[MAX_TEXTURE_IMAGE_UNITS
];
593 GLuint TexGen
[MAX_TEXTURE_COORD_UNITS
];
594 /* SGI_texture_color_table */
595 GLboolean TextureColorTable
[MAX_TEXTURE_IMAGE_UNITS
];
596 /* GL_NV_vertex_program */
597 GLboolean VertexProgram
;
598 GLboolean VertexProgramPointSize
;
599 GLboolean VertexProgramTwoSide
;
600 /* GL_ARB_point_sprite / GL_NV_point_sprite */
601 GLboolean PointSprite
;
608 struct gl_eval_attrib
{
613 GLboolean Map1Color4
;
615 GLboolean Map1Normal
;
616 GLboolean Map1TextureCoord1
;
617 GLboolean Map1TextureCoord2
;
618 GLboolean Map1TextureCoord3
;
619 GLboolean Map1TextureCoord4
;
620 GLboolean Map1Vertex3
;
621 GLboolean Map1Vertex4
;
622 GLboolean Map1Attrib
[16]; /* GL_NV_vertex_program */
623 GLboolean Map2Color4
;
625 GLboolean Map2Normal
;
626 GLboolean Map2TextureCoord1
;
627 GLboolean Map2TextureCoord2
;
628 GLboolean Map2TextureCoord3
;
629 GLboolean Map2TextureCoord4
;
630 GLboolean Map2Vertex3
;
631 GLboolean Map2Vertex4
;
632 GLboolean Map2Attrib
[16]; /* GL_NV_vertex_program */
633 GLboolean AutoNormal
;
637 * \name Map Grid endpoints and divisions and calculated du values
641 GLfloat MapGrid1u1
, MapGrid1u2
, MapGrid1du
;
642 GLint MapGrid2un
, MapGrid2vn
;
643 GLfloat MapGrid2u1
, MapGrid2u2
, MapGrid2du
;
644 GLfloat MapGrid2v1
, MapGrid2v2
, MapGrid2dv
;
652 struct gl_fog_attrib
{
653 GLboolean Enabled
; /**< Fog enabled flag */
654 GLfloat Color
[4]; /**< Fog color */
655 GLfloat Density
; /**< Density >= 0.0 */
656 GLfloat Start
; /**< Start distance in eye coords */
657 GLfloat End
; /**< End distance in eye coords */
658 GLfloat Index
; /**< Fog index */
659 GLenum Mode
; /**< Fog mode */
660 GLboolean ColorSumEnabled
;
661 GLenum FogCoordinateSource
; /**< GL_EXT_fog_coord */
668 * Values are always one of GL_FASTEST, GL_NICEST, or GL_DONT_CARE.
670 struct gl_hint_attrib
{
671 GLenum PerspectiveCorrection
;
674 GLenum PolygonSmooth
;
676 GLenum ClipVolumeClipping
; /**< GL_EXT_clip_volume_hint */
677 GLenum TextureCompression
; /**< GL_ARB_texture_compression */
678 GLenum GenerateMipmap
; /**< GL_SGIS_generate_mipmap */
683 * Histogram attributes.
685 struct gl_histogram_attrib
{
686 GLuint Width
; /**< number of table entries */
687 GLint Format
; /**< GL_ALPHA, GL_RGB, etc */
688 GLuint Count
[HISTOGRAM_TABLE_SIZE
][4]; /**< the histogram */
689 GLboolean Sink
; /**< terminate image transfer? */
690 GLubyte RedSize
; /**< Bits per counter */
694 GLubyte LuminanceSize
;
698 struct gl_minmax_attrib
{
701 GLfloat Min
[4], Max
[4]; /**< RGBA */
705 struct gl_convolution_attrib
{
707 GLenum InternalFormat
;
710 GLfloat Filter
[MAX_CONVOLUTION_WIDTH
* MAX_CONVOLUTION_HEIGHT
* 4];
714 #define LIGHT_SPOT 0x1
715 #define LIGHT_LOCAL_VIEWER 0x2
716 #define LIGHT_POSITIONAL 0x4
717 #define LIGHT_NEED_VERTICES (LIGHT_POSITIONAL|LIGHT_LOCAL_VIEWER)
720 * Lighting attributes.
722 struct gl_light_attrib
{
723 struct gl_light Light
[MAX_LIGHTS
]; /**< Array of lights */
724 struct gl_lightmodel Model
; /**< Lighting model */
727 * Must flush FLUSH_VERTICES before referencing:
730 struct gl_material Material
; /**< Includes front & back values */
733 GLboolean Enabled
; /**< Lighting enabled flag */
734 GLenum ShadeModel
; /**< GL_FLAT or GL_SMOOTH */
735 GLenum ColorMaterialFace
; /**< GL_FRONT, BACK or FRONT_AND_BACK */
736 GLenum ColorMaterialMode
; /**< GL_AMBIENT, GL_DIFFUSE, etc */
737 GLuint ColorMaterialBitmask
; /**< bitmask formed from Face and Mode */
738 GLboolean ColorMaterialEnabled
;
740 struct gl_light EnabledList
; /**< List sentinel */
743 * Derived for optimizations:
746 GLboolean _NeedEyeCoords
;
747 GLboolean _NeedVertices
; /**< Use fast shader? */
748 GLuint _Flags
; /**< LIGHT_* flags, see above */
749 GLfloat _BaseColor
[2][3];
757 struct gl_line_attrib
{
758 GLboolean SmoothFlag
; /**< GL_LINE_SMOOTH enabled? */
759 GLboolean StippleFlag
; /**< GL_LINE_STIPPLE enabled? */
760 GLushort StipplePattern
; /**< Stipple pattern */
761 GLint StippleFactor
; /**< Stipple repeat factor */
762 GLfloat Width
; /**< Line width */
763 GLfloat _Width
; /**< Clamped Line width */
767 struct gl_list_attrib
{
772 struct gl_list_opcode
{
774 void (*execute
)( GLcontext
*ctx
, void *data
);
775 void (*destroy
)( GLcontext
*ctx
, void *data
);
776 void (*print
)( GLcontext
*ctx
, void *data
);
779 #define GL_MAX_EXT_OPCODES 16
781 struct gl_list_extensions
{
782 struct gl_list_opcode opcode
[GL_MAX_EXT_OPCODES
];
787 struct gl_multisample_attrib
{
789 GLboolean SampleAlphaToCoverage
;
790 GLboolean SampleAlphaToOne
;
791 GLboolean SampleCoverage
;
792 GLfloat SampleCoverageValue
;
793 GLboolean SampleCoverageInvert
;
800 struct gl_pixel_attrib
{
801 GLenum ReadBuffer
; /**< source buffer for glReadPixels()/glCopyPixels() */
802 GLubyte _ReadSrcMask
; /**< Not really a mask, but like _DrawDestMask
804 * May be: FRONT_LEFT_BIT, BACK_LEFT_BIT,
805 * FRONT_RIGHT_BIT or BACK_RIGHT_BIT. */
806 GLfloat RedBias
, RedScale
;
807 GLfloat GreenBias
, GreenScale
;
808 GLfloat BlueBias
, BlueScale
;
809 GLfloat AlphaBias
, AlphaScale
;
810 GLfloat DepthBias
, DepthScale
;
811 GLint IndexShift
, IndexOffset
;
812 GLboolean MapColorFlag
;
813 GLboolean MapStencilFlag
;
814 GLfloat ZoomX
, ZoomY
;
815 /* XXX move these out of gl_pixel_attrib */
816 GLint MapStoSsize
; /**< Size of each pixel map */
826 GLint MapStoS
[MAX_PIXEL_MAP_TABLE
]; /**< Pixel map tables */
827 GLint MapItoI
[MAX_PIXEL_MAP_TABLE
];
828 GLfloat MapItoR
[MAX_PIXEL_MAP_TABLE
];
829 GLfloat MapItoG
[MAX_PIXEL_MAP_TABLE
];
830 GLfloat MapItoB
[MAX_PIXEL_MAP_TABLE
];
831 GLfloat MapItoA
[MAX_PIXEL_MAP_TABLE
];
832 GLubyte MapItoR8
[MAX_PIXEL_MAP_TABLE
]; /**< converted to 8-bit color */
833 GLubyte MapItoG8
[MAX_PIXEL_MAP_TABLE
];
834 GLubyte MapItoB8
[MAX_PIXEL_MAP_TABLE
];
835 GLubyte MapItoA8
[MAX_PIXEL_MAP_TABLE
];
836 GLfloat MapRtoR
[MAX_PIXEL_MAP_TABLE
];
837 GLfloat MapGtoG
[MAX_PIXEL_MAP_TABLE
];
838 GLfloat MapBtoB
[MAX_PIXEL_MAP_TABLE
];
839 GLfloat MapAtoA
[MAX_PIXEL_MAP_TABLE
];
840 /** GL_EXT_histogram */
841 GLboolean HistogramEnabled
;
842 GLboolean MinMaxEnabled
;
843 /** GL_SGIS_pixel_texture */
844 GLboolean PixelTextureEnabled
;
845 GLenum FragmentRgbSource
;
846 GLenum FragmentAlphaSource
;
847 /** GL_SGI_color_matrix */
848 GLfloat PostColorMatrixScale
[4]; /**< RGBA */
849 GLfloat PostColorMatrixBias
[4]; /**< RGBA */
850 /** GL_SGI_color_table */
851 GLfloat ColorTableScale
[4];
852 GLfloat ColorTableBias
[4];
853 GLboolean ColorTableEnabled
;
854 GLfloat PCCTscale
[4];
856 GLboolean PostConvolutionColorTableEnabled
;
857 GLfloat PCMCTscale
[4];
858 GLfloat PCMCTbias
[4];
859 GLboolean PostColorMatrixColorTableEnabled
;
860 /** GL_SGI_texture_color_table */
861 GLfloat TextureColorTableScale
[4];
862 GLfloat TextureColorTableBias
[4];
864 GLboolean Convolution1DEnabled
;
865 GLboolean Convolution2DEnabled
;
866 GLboolean Separable2DEnabled
;
867 GLfloat ConvolutionBorderColor
[3][4];
868 GLenum ConvolutionBorderMode
[3];
869 GLfloat ConvolutionFilterScale
[3][4];
870 GLfloat ConvolutionFilterBias
[3][4];
871 GLfloat PostConvolutionScale
[4]; /**< RGBA */
872 GLfloat PostConvolutionBias
[4]; /**< RGBA */
879 struct gl_point_attrib
{
880 GLboolean SmoothFlag
; /**< True if GL_POINT_SMOOTH is enabled */
881 GLfloat Size
; /**< User-specified point size */
882 GLfloat _Size
; /**< Size clamped to Const.Min/MaxPointSize */
883 GLfloat Params
[3]; /**< GL_EXT_point_parameters */
884 GLfloat MinSize
, MaxSize
; /**< GL_EXT_point_parameters */
885 GLfloat Threshold
; /**< GL_EXT_point_parameters */
886 GLboolean _Attenuated
; /**< True if Params != [1, 0, 0] */
887 GLboolean PointSprite
; /**< GL_NV_point_sprite / GL_NV_point_sprite */
888 GLboolean CoordReplace
[MAX_TEXTURE_UNITS
]; /**< GL_NV_point_sprite / GL_NV_point_sprite */
889 GLenum SpriteRMode
; /**< GL_NV_point_sprite (only!) */
894 * Polygon attributes.
896 struct gl_polygon_attrib
{
897 GLenum FrontFace
; /**< Either GL_CW or GL_CCW */
898 GLenum FrontMode
; /**< Either GL_POINT, GL_LINE or GL_FILL */
899 GLenum BackMode
; /**< Either GL_POINT, GL_LINE or GL_FILL */
900 GLboolean _FrontBit
; /**< 0=GL_CCW, 1=GL_CW */
901 GLboolean CullFlag
; /**< Culling on/off flag */
902 GLboolean SmoothFlag
; /**< True if GL_POLYGON_SMOOTH is enabled */
903 GLboolean StippleFlag
; /**< True if GL_POLYGON_STIPPLE is enabled */
904 GLenum CullFaceMode
; /**< Culling mode GL_FRONT or GL_BACK */
905 GLfloat OffsetFactor
; /**< Polygon offset factor, from user */
906 GLfloat OffsetUnits
; /**< Polygon offset units, from user */
907 GLboolean OffsetPoint
; /**< Offset in GL_POINT mode */
908 GLboolean OffsetLine
; /**< Offset in GL_LINE mode */
909 GLboolean OffsetFill
; /**< Offset in GL_FILL mode */
914 * Scissor attributes.
916 struct gl_scissor_attrib
{
917 GLboolean Enabled
; /**< Scissor test enabled? */
918 GLint X
, Y
; /**< Lower left corner of box */
919 GLsizei Width
, Height
; /**< Size of box */
924 * Stencil attributes.
926 struct gl_stencil_attrib
{
927 GLboolean Enabled
; /**< Enabled flag */
928 GLboolean TestTwoSide
; /**< GL_EXT_stencil_two_side */
929 GLubyte ActiveFace
; /**< GL_EXT_stencil_two_side (0 or 1) */
930 GLenum Function
[2]; /**< Stencil function */
931 GLenum FailFunc
[2]; /**< Fail function */
932 GLenum ZPassFunc
[2]; /**< Depth buffer pass function */
933 GLenum ZFailFunc
[2]; /**< Depth buffer fail function */
934 GLstencil Ref
[2]; /**< Reference value */
935 GLstencil ValueMask
[2]; /**< Value mask */
936 GLstencil WriteMask
[2]; /**< Write mask */
937 GLstencil Clear
; /**< Clear value */
941 #define NUM_TEXTURE_TARGETS 5 /* 1D, 2D, 3D, CUBE and RECT */
943 #define TEXTURE_1D_INDEX 0
944 #define TEXTURE_2D_INDEX 1
945 #define TEXTURE_3D_INDEX 2
946 #define TEXTURE_CUBE_INDEX 3
947 #define TEXTURE_RECT_INDEX 4
949 /* Texture.Unit[]._ReallyEnabled flags: */
950 #define TEXTURE_1D_BIT (1 << TEXTURE_1D_INDEX)
951 #define TEXTURE_2D_BIT (1 << TEXTURE_2D_INDEX)
952 #define TEXTURE_3D_BIT (1 << TEXTURE_3D_INDEX)
953 #define TEXTURE_CUBE_BIT (1 << TEXTURE_CUBE_INDEX)
954 #define TEXTURE_RECT_BIT (1 << TEXTURE_RECT_INDEX)
957 /* TexGenEnabled flags */
963 /* Bitmap versions of the GL_ constants. */
964 #define TEXGEN_SPHERE_MAP 0x1
965 #define TEXGEN_OBJ_LINEAR 0x2
966 #define TEXGEN_EYE_LINEAR 0x4
967 #define TEXGEN_REFLECTION_MAP_NV 0x8
968 #define TEXGEN_NORMAL_MAP_NV 0x10
970 #define TEXGEN_NEED_NORMALS (TEXGEN_SPHERE_MAP | \
971 TEXGEN_REFLECTION_MAP_NV | \
972 TEXGEN_NORMAL_MAP_NV)
973 #define TEXGEN_NEED_EYE_COORD (TEXGEN_SPHERE_MAP | \
974 TEXGEN_REFLECTION_MAP_NV | \
975 TEXGEN_NORMAL_MAP_NV | \
978 /* A selection of state flags to make driver and module's lives easier. */
979 #define ENABLE_TEXGEN0 0x1
980 #define ENABLE_TEXGEN1 0x2
981 #define ENABLE_TEXGEN2 0x4
982 #define ENABLE_TEXGEN3 0x8
983 #define ENABLE_TEXGEN4 0x10
984 #define ENABLE_TEXGEN5 0x20
985 #define ENABLE_TEXGEN6 0x40
986 #define ENABLE_TEXGEN7 0x80
988 #define ENABLE_TEXMAT0 0x1 /* Ie. not the identity matrix */
989 #define ENABLE_TEXMAT1 0x2
990 #define ENABLE_TEXMAT2 0x4
991 #define ENABLE_TEXMAT3 0x8
992 #define ENABLE_TEXMAT4 0x10
993 #define ENABLE_TEXMAT5 0x20
994 #define ENABLE_TEXMAT6 0x40
995 #define ENABLE_TEXMAT7 0x80
997 #define ENABLE_TEXGEN(i) (ENABLE_TEXGEN0 << (i))
998 #define ENABLE_TEXMAT(i) (ENABLE_TEXMAT0 << (i))
1002 * Texel fetch function prototype. We use texel fetch functions to
1003 * extract RGBA, color indexes and depth components out of 1D, 2D and 3D
1004 * texture images. These functions help to isolate us from the gritty
1005 * details of all the various texture image encodings.
1007 * \param texImage texture image.
1008 * \param col texel column.
1009 * \param row texel row.
1010 * \param img texel image level/layer.
1011 * \param texelOut output texel (up to 4 GLchans)
1013 typedef void (*FetchTexelFuncC
)( const struct gl_texture_image
*texImage
,
1014 GLint col
, GLint row
, GLint img
,
1018 * As above, but returns floats.
1019 * Used for depth component images and for upcoming signed/float
1022 typedef void (*FetchTexelFuncF
)( const struct gl_texture_image
*texImage
,
1023 GLint col
, GLint row
, GLint img
,
1024 GLfloat
*texelOut
);
1027 * Texture format record
1029 struct gl_texture_format
{
1030 GLint MesaFormat
; /**< One of the MESA_FORMAT_* values */
1032 GLenum BaseFormat
; /**< Either GL_ALPHA, GL_INTENSITY, GL_LUMINANCE,
1033 * GL_LUMINANCE_ALPHA, GL_RGB, GL_RGBA,
1034 * GL_COLOR_INDEX or GL_DEPTH_COMPONENT.
1036 GLubyte RedBits
; /**< Bits per texel component */
1037 GLubyte GreenBits
; /**< These are just rough approximations for */
1038 GLubyte BlueBits
; /**< compressed texture formats. */
1040 GLubyte LuminanceBits
;
1041 GLubyte IntensityBits
;
1045 GLint TexelBytes
; /**< Bytes per texel (0 for compressed formats */
1048 * \name Texel fetch function pointers
1051 FetchTexelFuncC FetchTexel1D
;
1052 FetchTexelFuncC FetchTexel2D
;
1053 FetchTexelFuncC FetchTexel3D
;
1054 FetchTexelFuncF FetchTexel1Df
;
1055 FetchTexelFuncF FetchTexel2Df
;
1056 FetchTexelFuncF FetchTexel3Df
;
1062 * Texture image record
1064 struct gl_texture_image
{
1065 GLenum Format
; /**< GL_ALPHA, GL_LUMINANCE, GL_LUMINANCE_ALPHA,
1066 * GL_INTENSITY, GL_RGB, GL_RGBA,
1067 * GL_COLOR_INDEX or GL_DEPTH_COMPONENT only.
1068 * Used for choosing TexEnv arithmetic.
1070 GLint IntFormat
; /**< Internal format as given by the user */
1071 GLuint Border
; /**< 0 or 1 */
1072 GLuint Width
; /**< = 2^WidthLog2 + 2*Border */
1073 GLuint Height
; /**< = 2^HeightLog2 + 2*Border */
1074 GLuint Depth
; /**< = 2^DepthLog2 + 2*Border */
1075 GLuint RowStride
; /**< == Width unless IsClientData and padded */
1076 GLuint Width2
; /**< = Width - 2*Border */
1077 GLuint Height2
; /**< = Height - 2*Border */
1078 GLuint Depth2
; /**< = Depth - 2*Border */
1079 GLuint WidthLog2
; /**< = log2(Width2) */
1080 GLuint HeightLog2
; /**< = log2(Height2) */
1081 GLuint DepthLog2
; /**< = log2(Depth2) */
1082 GLuint MaxLog2
; /**< = MAX(WidthLog2, HeightLog2) */
1083 GLfloat WidthScale
; /**< used for mipmap LOD computation */
1084 GLfloat HeightScale
; /**< used for mipmap LOD computation */
1085 GLfloat DepthScale
; /**< used for mipmap LOD computation */
1086 GLvoid
*Data
; /**< Image data, accessed via FetchTexel() */
1087 GLboolean IsClientData
; /**< Data owned by client? */
1088 GLboolean _IsPowerOfTwo
; /**< Are all dimensions powers of two? */
1090 const struct gl_texture_format
*TexFormat
;
1092 FetchTexelFuncC FetchTexelc
; /**< GLchan texel fetch function pointer */
1093 FetchTexelFuncF FetchTexelf
; /**< Float texel fetch function pointer */
1095 GLboolean IsCompressed
; /**< GL_ARB_texture_compression */
1096 GLuint CompressedSize
; /**< GL_ARB_texture_compression */
1099 * \name For device driver:
1102 void *DriverData
; /**< Arbitrary device driver data */
1106 #define FACE_POS_X 0
1107 #define FACE_NEG_X 1
1108 #define FACE_POS_Y 2
1109 #define FACE_NEG_Y 3
1110 #define FACE_POS_Z 4
1111 #define FACE_NEG_Z 5
1115 * Texture object record
1117 struct gl_texture_object
{
1118 _glthread_Mutex Mutex
; /**< for thread safety */
1119 GLint RefCount
; /**< reference count */
1120 GLuint Name
; /**< an unsigned integer */
1121 GLenum Target
; /**< GL_TEXTURE_1D, GL_TEXTURE_2D, etc. */
1122 GLfloat Priority
; /**< in [0,1] */
1123 GLfloat BorderColor
[4]; /**< unclamped */
1124 GLchan _BorderChan
[4]; /**< clamped, as GLchan */
1125 /** \name Wrap modes
1126 * Are GL_CLAMP, REPEAT, GL_CLAMP_TO_EDGE, and GL_CLAMP_TO_BORDER_ARB. */
1132 GLenum MinFilter
; /**< minification filter */
1133 GLenum MagFilter
; /**< magnification filter */
1134 GLfloat MinLod
; /**< min lambda, OpenGL 1.2 */
1135 GLfloat MaxLod
; /**< max lambda, OpenGL 1.2 */
1136 GLfloat LodBias
; /**< OpenGL 1.4 */
1137 GLint BaseLevel
; /**< min mipmap level, OpenGL 1.2 */
1138 GLint MaxLevel
; /**< max mipmap level, OpenGL 1.2 */
1139 GLfloat MaxAnisotropy
; /**< GL_EXT_texture_filter_anisotropic */
1140 GLboolean CompareFlag
; /**< GL_SGIX_shadow */
1141 GLenum CompareOperator
; /**< GL_SGIX_shadow */
1142 GLfloat ShadowAmbient
;
1143 GLenum CompareMode
; /**< GL_ARB_shadow */
1144 GLenum CompareFunc
; /**< GL_ARB_shadow */
1145 GLenum DepthMode
; /**< GL_ARB_depth_texture */
1146 GLint _MaxLevel
; /**< actual max mipmap level (q in the spec) */
1147 GLfloat _MaxLambda
; /**< = _MaxLevel - BaseLevel (q - b in spec) */
1148 GLboolean GenerateMipmap
; /**< GL_SGIS_generate_mipmap */
1149 GLboolean _IsPowerOfTwo
; /**< Are all image dimensions powers of two? */
1151 struct gl_texture_image
*Image
[MAX_FACES
][MAX_TEXTURE_LEVELS
];
1153 /** GL_EXT_paletted_texture */
1154 struct gl_color_table Palette
;
1156 GLboolean Complete
; /**< Is texture object complete? */
1157 struct gl_texture_object
*Next
; /**< Next in linked list */
1160 * \name For device driver
1163 void *DriverData
; /**< Arbitrary device driver data */
1169 * Texture unit record
1171 struct gl_texture_unit
{
1172 GLuint Enabled
; /**< bitmask of TEXTURE_*_BIT flags */
1173 GLuint _ReallyEnabled
; /**< 0 or exactly one of TEXTURE_*_BIT flags */
1175 GLenum EnvMode
; /**< GL_MODULATE, GL_DECAL, GL_BLEND, etc. */
1176 GLfloat EnvColor
[4];
1177 GLuint TexGenEnabled
; /**< Bitwise-OR of [STRQ]_BIT values */
1178 /** \name Tex coord generation mode
1179 * Either GL_OBJECT_LINEAR, GL_EYE_LINEAR or GL_SPHERE_MAP. */
1190 GLuint _GenFlags
; /**< bitwise or of GenBit[STRQ] */
1191 GLfloat ObjectPlaneS
[4];
1192 GLfloat ObjectPlaneT
[4];
1193 GLfloat ObjectPlaneR
[4];
1194 GLfloat ObjectPlaneQ
[4];
1195 GLfloat EyePlaneS
[4];
1196 GLfloat EyePlaneT
[4];
1197 GLfloat EyePlaneR
[4];
1198 GLfloat EyePlaneQ
[4];
1199 GLfloat LodBias
; /**< for biasing mipmap levels */
1202 * \name GL_EXT_texture_env_combine
1205 GLenum CombineModeRGB
; /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */
1206 GLenum CombineModeA
; /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */
1207 GLenum CombineSourceRGB
[3]; /**< GL_PRIMARY_COLOR, GL_TEXTURE, etc. */
1208 GLenum CombineSourceA
[3]; /**< GL_PRIMARY_COLOR, GL_TEXTURE, etc. */
1209 GLenum CombineOperandRGB
[3]; /**< SRC_COLOR, ONE_MINUS_SRC_COLOR, etc */
1210 GLenum CombineOperandA
[3]; /**< SRC_ALPHA, ONE_MINUS_SRC_ALPHA, etc */
1211 GLuint CombineScaleShiftRGB
; /**< 0, 1 or 2 */
1212 GLuint CombineScaleShiftA
; /**< 0, 1 or 2 */
1215 struct gl_texture_object
*Current1D
;
1216 struct gl_texture_object
*Current2D
;
1217 struct gl_texture_object
*Current3D
;
1218 struct gl_texture_object
*CurrentCubeMap
; /**< GL_ARB_texture_cube_map */
1219 struct gl_texture_object
*CurrentRect
; /**< GL_NV_texture_rectangle */
1221 struct gl_texture_object
*_Current
; /**< Points to really enabled tex obj */
1223 struct gl_texture_object Saved1D
; /**< only used by glPush/PopAttrib */
1224 struct gl_texture_object Saved2D
;
1225 struct gl_texture_object Saved3D
;
1226 struct gl_texture_object SavedCubeMap
;
1227 struct gl_texture_object SavedRect
;
1229 /* GL_SGI_texture_color_table */
1230 struct gl_color_table ColorTable
;
1231 struct gl_color_table ProxyColorTable
;
1232 GLboolean ColorTableEnabled
;
1237 * Texture attributes
1239 struct gl_texture_attrib
{
1244 GLuint CurrentUnit
; /**< Active texture unit */
1245 GLuint _EnabledUnits
; /**< one bit set for each really-enabled unit */
1246 GLuint _EnabledCoordUnits
; /**< one bit per enabled coordinate unit */
1247 GLuint _GenFlags
; /**< for texgen */
1248 GLuint _TexGenEnabled
;
1249 GLuint _TexMatEnabled
;
1252 struct gl_texture_unit Unit
[MAX_TEXTURE_UNITS
];
1254 struct gl_texture_object
*Proxy1D
;
1255 struct gl_texture_object
*Proxy2D
;
1256 struct gl_texture_object
*Proxy3D
;
1257 struct gl_texture_object
*ProxyCubeMap
;
1258 struct gl_texture_object
*ProxyRect
;
1260 /** GL_EXT_shared_texture_palette */
1261 GLboolean SharedPalette
;
1262 struct gl_color_table Palette
;
1267 * Transformation attributes.
1269 struct gl_transform_attrib
{
1270 GLenum MatrixMode
; /**< Matrix mode */
1271 GLfloat EyeUserPlane
[MAX_CLIP_PLANES
][4]; /**< User clip planes */
1272 GLfloat _ClipUserPlane
[MAX_CLIP_PLANES
][4]; /**< derived */
1273 GLuint ClipPlanesEnabled
; /**< on/off bitmask */
1274 GLboolean Normalize
; /**< Normalize all normals? */
1275 GLboolean RescaleNormals
; /**< GL_EXT_rescale_normal */
1276 GLboolean RasterPositionUnclipped
; /**< GL_IBM_rasterpos_clip */
1281 * Viewport attributes.
1283 struct gl_viewport_attrib
{
1284 GLint X
, Y
; /**< position */
1285 GLsizei Width
, Height
; /**< size */
1286 GLfloat Near
, Far
; /**< Depth buffer range */
1287 GLmatrix _WindowMap
; /**< Mapping transformation as a matrix. */
1292 * Node for the attribute stack
1294 struct gl_attrib_node
{
1297 struct gl_attrib_node
*next
;
1302 * GL_ARB_vertex_buffer_object buffer object
1304 struct gl_buffer_object
{
1309 GLvoid
*Pointer
; /**< Only valid while buffer is mapped */
1310 GLuint Size
; /**< Size of data array in bytes */
1311 GLubyte
*Data
; /**< The storage */
1317 * Client pixel packing/unpacking attributes
1319 struct gl_pixelstore_attrib
{
1324 GLint ImageHeight
; /**< for GL_EXT_texture3D */
1325 GLint SkipImages
; /**< for GL_EXT_texture3D */
1326 GLboolean SwapBytes
;
1328 GLboolean ClientStorage
; /**< GL_APPLE_client_storage */
1329 GLboolean Invert
; /**< GL_MESA_pack_invert */
1333 #define CA_CLIENT_DATA 0x1 /**< Data not allocated by mesa */
1337 * Client vertex array attributes
1339 struct gl_client_array
{
1342 GLsizei Stride
; /**< user-specified stride */
1343 GLsizei StrideB
; /**< actual stride in bytes */
1345 GLuint Enabled
; /**< one of the _NEW_ARRAY_ bits */
1346 GLboolean Normalized
; /**< GL_ARB_vertex_program */
1348 /**< GL_ARB_vertex_buffer_object */
1349 struct gl_buffer_object
*BufferObj
;
1359 struct gl_array_attrib
{
1360 struct gl_client_array Vertex
; /**< client data descriptors */
1361 struct gl_client_array Normal
;
1362 struct gl_client_array Color
;
1363 struct gl_client_array SecondaryColor
;
1364 struct gl_client_array FogCoord
;
1365 struct gl_client_array Index
;
1366 struct gl_client_array TexCoord
[MAX_TEXTURE_COORD_UNITS
];
1367 struct gl_client_array EdgeFlag
;
1369 struct gl_client_array VertexAttrib
[VERT_ATTRIB_MAX
]; /**< GL_NV_vertex_program */
1371 GLint ActiveTexture
; /**< Client Active Texture */
1372 GLuint LockFirst
; /**< GL_EXT_compiled_vertex_array */
1373 GLuint LockCount
; /**< GL_EXT_compiled_vertex_array */
1375 GLuint _Enabled
; /**< _NEW_ARRAY_* - bit set if array enabled */
1376 GLuint NewState
; /**< _NEW_ARRAY_* */
1378 #if FEATURE_ARB_vertex_buffer_object
1379 struct gl_buffer_object
*NullBufferObj
;
1380 struct gl_buffer_object
*ArrayBufferObj
;
1381 struct gl_buffer_object
*ElementArrayBufferObj
;
1383 GLuint _MaxElement
; /* Min of all enabled array's maxes */
1387 struct gl_feedback
{
1389 GLuint _Mask
; /* FB_* bits */
1397 * Selection attributes.
1399 struct gl_selection
{
1400 GLuint
*Buffer
; /**< selection buffer */
1401 GLuint BufferSize
; /**< size of the selection buffer */
1402 GLuint BufferCount
; /**< number of values in the selection buffer */
1403 GLuint Hits
; /**< number of records in the selection buffer */
1404 GLuint NameStackDepth
; /**< name stack depth */
1405 GLuint NameStack
[MAX_NAME_STACK_DEPTH
]; /**< name stack */
1406 GLboolean HitFlag
; /**< hit flag */
1407 GLfloat HitMinZ
; /**< minimum hit depth */
1408 GLfloat HitMaxZ
; /**< maximum hit depth */
1413 * 1-D Evaluator control points
1417 GLuint Order
; /**< Number of control points */
1418 GLfloat u1
, u2
, du
; /**< u1, u2, 1.0/(u2-u1) */
1419 GLfloat
*Points
; /**< Points to contiguous control points */
1424 * 2-D Evaluator control points
1428 GLuint Uorder
; /**< Number of control points in U dimension */
1429 GLuint Vorder
; /**< Number of control points in V dimension */
1432 GLfloat
*Points
; /**< Points to contiguous control points */
1437 * All evaluator control points
1439 struct gl_evaluators
1445 struct gl_1d_map Map1Vertex3
;
1446 struct gl_1d_map Map1Vertex4
;
1447 struct gl_1d_map Map1Index
;
1448 struct gl_1d_map Map1Color4
;
1449 struct gl_1d_map Map1Normal
;
1450 struct gl_1d_map Map1Texture1
;
1451 struct gl_1d_map Map1Texture2
;
1452 struct gl_1d_map Map1Texture3
;
1453 struct gl_1d_map Map1Texture4
;
1454 struct gl_1d_map Map1Attrib
[16]; /**< GL_NV_vertex_program */
1461 struct gl_2d_map Map2Vertex3
;
1462 struct gl_2d_map Map2Vertex4
;
1463 struct gl_2d_map Map2Index
;
1464 struct gl_2d_map Map2Color4
;
1465 struct gl_2d_map Map2Normal
;
1466 struct gl_2d_map Map2Texture1
;
1467 struct gl_2d_map Map2Texture2
;
1468 struct gl_2d_map Map2Texture3
;
1469 struct gl_2d_map Map2Texture4
;
1470 struct gl_2d_map Map2Attrib
[16]; /**< GL_NV_vertex_program */
1476 * NV_fragment_program runtime state
1480 GLfloat Temporaries
[MAX_NV_FRAGMENT_PROGRAM_TEMPS
][4];
1481 GLfloat Inputs
[MAX_NV_FRAGMENT_PROGRAM_INPUTS
][4];
1482 GLfloat Outputs
[MAX_NV_FRAGMENT_PROGRAM_OUTPUTS
][4];
1483 GLuint CondCodes
[4];
1488 * Names of the various vertex/fragment register files
1492 PROGRAM_TEMPORARY
= 10,
1495 PROGRAM_LOCAL_PARAM
,
1497 PROGRAM_NAMED_PARAM
,
1504 /* Vertex and fragment instructions */
1505 struct vp_instruction
;
1506 struct fp_instruction
;
1508 struct program_parameter_list
;
1512 * Base class for any kind of program object
1517 GLubyte
*String
; /* Null-terminated program text */
1519 GLenum Format
; /* String encoding format */
1522 GLfloat LocalParams
[MAX_PROGRAM_LOCAL_PARAMS
][4];
1523 GLuint NumInstructions
; /* GL_ARB_vertex/fragment_program */
1524 GLuint NumTemporaries
;
1525 GLuint NumParameters
;
1526 GLuint NumAttributes
;
1527 GLuint NumAddressRegs
;
1531 /** Vertex program object */
1532 struct vertex_program
1534 struct program Base
; /* base class */
1535 struct vp_instruction
*Instructions
; /* Compiled instructions */
1536 GLboolean IsPositionInvariant
; /* GL_NV_vertex_program1_1 */
1537 GLuint InputsRead
; /* Bitmask of which input regs are read */
1538 GLuint OutputsWritten
; /* Bitmask of which output regs are written to */
1539 struct program_parameter_list
*Parameters
; /**< array [NumParameters] */
1543 /** Fragment program object */
1544 struct fragment_program
1546 struct program Base
; /**< base class */
1547 struct fp_instruction
*Instructions
; /**< Compiled instructions */
1548 GLuint InputsRead
; /**< Bitmask of which input regs are read */
1549 GLuint OutputsWritten
; /**< Bitmask of which output regs are written to */
1550 GLuint TexturesUsed
[MAX_TEXTURE_IMAGE_UNITS
]; /**< TEXTURE_x_INDEX bitmask */
1551 GLuint NumAluInstructions
; /**< GL_ARB_fragment_program */
1552 GLuint NumTexInstructions
;
1553 GLuint NumTexIndirections
;
1554 struct program_parameter_list
*Parameters
; /**< array [NumParameters] */
1559 * State common to vertex and fragment programs.
1561 struct program_state
{
1562 GLint ErrorPos
; /* GL_PROGRAM_ERROR_POSITION_NV */
1563 const char *ErrorString
; /* GL_PROGRAM_ERROR_STRING_NV */
1568 * State vars for GL_NV_vertex_program
1570 struct vertex_program_state
1572 GLboolean Enabled
; /**< GL_VERTEX_PROGRAM_NV */
1573 GLboolean PointSizeEnabled
; /**< GL_VERTEX_PROGRAM_POINT_SIZE_NV */
1574 GLboolean TwoSideEnabled
; /**< GL_VERTEX_PROGRAM_TWO_SIDE_NV */
1575 struct vertex_program
*Current
; /**< ptr to currently bound program */
1577 GLenum TrackMatrix
[MAX_NV_VERTEX_PROGRAM_PARAMS
/ 4];
1578 GLenum TrackMatrixTransform
[MAX_NV_VERTEX_PROGRAM_PARAMS
/ 4];
1580 GLfloat Parameters
[MAX_NV_VERTEX_PROGRAM_PARAMS
][4]; /* Env params */
1581 /* Only used during program execution (may be moved someday): */
1582 GLfloat Temporaries
[MAX_NV_VERTEX_PROGRAM_TEMPS
][4];
1583 GLfloat Inputs
[MAX_NV_VERTEX_PROGRAM_INPUTS
][4];
1584 GLfloat Outputs
[MAX_NV_VERTEX_PROGRAM_OUTPUTS
][4];
1585 GLint AddressReg
[4];
1587 #if FEATURE_MESA_program_debug
1588 GLprogramcallbackMESA Callback
;
1589 GLvoid
*CallbackData
;
1590 GLboolean CallbackEnabled
;
1591 GLuint CurrentPosition
;
1597 * State for GL_ARB/NV_fragment_program
1599 struct fragment_program_state
1601 GLboolean Enabled
; /* GL_VERTEX_PROGRAM_NV */
1602 struct fragment_program
*Current
; /* ptr to currently bound program */
1603 struct fp_machine Machine
; /* machine state */
1604 GLfloat Parameters
[MAX_NV_FRAGMENT_PROGRAM_PARAMS
][4]; /* Env params */
1606 #if FEATURE_MESA_program_debug
1607 GLprogramcallbackMESA Callback
;
1608 GLvoid
*CallbackData
;
1609 GLboolean CallbackEnabled
;
1610 GLuint CurrentPosition
;
1616 * State for GL_ARB_occlusion_query
1618 struct occlusion_state
1621 GLuint CurrentQueryObject
;
1622 GLuint PassedCounter
;
1623 struct _mesa_HashTable
*QueryObjects
;
1628 * State which can be shared by multiple contexts:
1630 struct gl_shared_state
1632 _glthread_Mutex Mutex
; /**< for thread safety */
1633 GLint RefCount
; /**< Reference count */
1634 struct _mesa_HashTable
*DisplayList
; /**< Display lists hash table */
1635 struct _mesa_HashTable
*TexObjects
; /**< Texture objects hash table */
1636 struct gl_texture_object
*TexObjectList
;/**< Linked list of texture objects */
1639 * \name Default texture objects (shared by all multi-texture units)
1642 struct gl_texture_object
*Default1D
;
1643 struct gl_texture_object
*Default2D
;
1644 struct gl_texture_object
*Default3D
;
1645 struct gl_texture_object
*DefaultCubeMap
;
1646 struct gl_texture_object
*DefaultRect
;
1650 * \name GL_NV_vertex/_program
1653 struct _mesa_HashTable
*Programs
;
1654 #if FEATURE_ARB_vertex_program
1655 struct program
*DefaultVertexProgram
;
1657 #if FEATURE_ARB_fragment_program
1658 struct program
*DefaultFragmentProgram
;
1662 #if FEATURE_ARB_vertex_buffer_object
1663 struct _mesa_HashTable
*BufferObjects
;
1666 void *DriverData
; /**< Device driver shared state */
1673 * A "frame buffer" is a color buffer and its optional ancillary buffers:
1674 * depth, accum, stencil, and software-simulated alpha buffers.
1675 * In C++ terms, think of this as a base class from which device drivers
1676 * will make derived classes.
1678 struct gl_frame_buffer
1680 GLvisual Visual
; /**< The corresponding visual */
1682 GLuint Width
, Height
; /**< size of frame buffer in pixels */
1684 GLboolean UseSoftwareDepthBuffer
;
1685 GLboolean UseSoftwareAccumBuffer
;
1686 GLboolean UseSoftwareStencilBuffer
;
1687 GLboolean UseSoftwareAlphaBuffers
;
1689 /** \name Software depth (aka Z) buffer */
1691 GLvoid
*DepthBuffer
; /**< array [Width*Height] of GLushort or GLuint*/
1694 /** \name Software stencil buffer */
1696 GLstencil
*Stencil
; /**< array [Width*Height] of GLstencil values */
1699 /** \name Software accumulation buffer */
1701 GLaccum
*Accum
; /**< array [4*Width*Height] of GLaccum values */
1704 /** \name Software alpha planes */
1706 GLchan
*FrontLeftAlpha
; /**< array [Width*Height] of GLchan */
1707 GLchan
*BackLeftAlpha
; /**< array [Width*Height] of GLchan */
1708 GLchan
*FrontRightAlpha
; /**< array [Width*Height] of GLchan */
1709 GLchan
*BackRightAlpha
; /**< array [Width*Height] of GLchan */
1713 * \name Drawing bounds
1715 * Intersection of window size and scissor box
1718 GLint _Xmin
; /**< inclusive */
1719 GLint _Ymin
; /**< inclusive */
1720 GLint _Xmax
; /**< exclusive */
1721 GLint _Ymax
; /**< exclusive */
1727 * Constants which may be overridden by device driver during context creation
1728 * but are never changed after that.
1732 GLint MaxTextureLevels
; /**< Maximum number of allowed mipmap levels. */
1733 GLint Max3DTextureLevels
; /**< Maximum number of allowed mipmap levels for 3D texture targets. */
1734 GLint MaxCubeTextureLevels
; /**< Maximum number of allowed mipmap levels for GL_ARB_texture_cube_map */
1735 GLint MaxTextureRectSize
; /* GL_NV_texture_rectangle */
1736 GLuint MaxTextureCoordUnits
;
1737 GLuint MaxTextureImageUnits
;
1738 GLuint MaxTextureUnits
; /* = MAX(CoordUnits, ImageUnits) */
1739 GLfloat MaxTextureMaxAnisotropy
; /* GL_EXT_texture_filter_anisotropic */
1740 GLfloat MaxTextureLodBias
; /* GL_EXT_texture_lod_bias */
1741 GLuint MaxArrayLockSize
;
1743 GLfloat MinPointSize
, MaxPointSize
; /* aliased */
1744 GLfloat MinPointSizeAA
, MaxPointSizeAA
; /* antialiased */
1745 GLfloat PointSizeGranularity
;
1746 GLfloat MinLineWidth
, MaxLineWidth
; /* aliased */
1747 GLfloat MinLineWidthAA
, MaxLineWidthAA
; /* antialiased */
1748 GLfloat LineWidthGranularity
;
1749 GLuint NumAuxBuffers
;
1750 GLuint MaxColorTableSize
;
1751 GLuint MaxConvolutionWidth
;
1752 GLuint MaxConvolutionHeight
;
1753 GLuint MaxClipPlanes
;
1755 GLfloat MaxShininess
; /* GL_NV_light_max_exponent */
1756 GLfloat MaxSpotExponent
; /* GL_NV_light_max_exponent */
1757 /* GL_ARB_vertex_program */
1758 GLuint MaxVertexProgramInstructions
;
1759 GLuint MaxVertexProgramAttribs
;
1760 GLuint MaxVertexProgramTemps
;
1761 GLuint MaxVertexProgramLocalParams
;
1762 GLuint MaxVertexProgramEnvParams
;
1763 GLuint MaxVertexProgramAddressRegs
;
1764 /* GL_ARB_fragment_program */
1765 GLuint MaxFragmentProgramInstructions
;
1766 GLuint MaxFragmentProgramAttribs
;
1767 GLuint MaxFragmentProgramTemps
;
1768 GLuint MaxFragmentProgramLocalParams
;
1769 GLuint MaxFragmentProgramEnvParams
;
1770 GLuint MaxFragmentProgramAddressRegs
;
1771 GLuint MaxFragmentProgramAluInstructions
;
1772 GLuint MaxFragmentProgramTexInstructions
;
1773 GLuint MaxFragmentProgramTexIndirections
;
1774 /* vertex or fragment program */
1775 GLuint MaxProgramMatrices
;
1776 GLuint MaxProgramMatrixStackDepth
;
1777 /* vertex array / buffer object bounds checking */
1778 GLboolean CheckArrayBounds
;
1783 * List of extensions.
1785 struct gl_extensions
1788 * \name Flags to quickly test if certain extensions are available.
1790 * Not every extension needs to have such a flag, but it's encouraged.
1793 GLboolean dummy
; /* don't remove this! */
1794 GLboolean ARB_depth_texture
;
1795 GLboolean ARB_fragment_program
;
1796 GLboolean ARB_imaging
;
1797 GLboolean ARB_multisample
;
1798 GLboolean ARB_multitexture
;
1799 GLboolean ARB_occlusion_query
;
1800 GLboolean ARB_point_sprite
;
1801 GLboolean ARB_shadow
;
1802 GLboolean ARB_texture_border_clamp
;
1803 GLboolean ARB_texture_compression
;
1804 GLboolean ARB_texture_cube_map
;
1805 GLboolean ARB_texture_env_combine
;
1806 GLboolean ARB_texture_env_crossbar
;
1807 GLboolean ARB_texture_env_dot3
;
1808 GLboolean ARB_texture_mirrored_repeat
;
1809 GLboolean ARB_texture_non_power_of_two
;
1810 GLboolean ARB_vertex_buffer_object
;
1811 GLboolean ARB_vertex_program
;
1812 GLboolean ARB_window_pos
;
1813 GLboolean ATI_texture_mirror_once
;
1814 GLboolean ATI_texture_env_combine3
;
1815 GLboolean EXT_blend_color
;
1816 GLboolean EXT_blend_equation_separate
;
1817 GLboolean EXT_blend_func_separate
;
1818 GLboolean EXT_blend_logic_op
;
1819 GLboolean EXT_blend_minmax
;
1820 GLboolean EXT_blend_subtract
;
1821 GLboolean EXT_convolution
;
1822 GLboolean EXT_compiled_vertex_array
;
1823 GLboolean EXT_depth_bounds_test
;
1824 GLboolean EXT_fog_coord
;
1825 GLboolean EXT_histogram
;
1826 GLboolean EXT_multi_draw_arrays
;
1827 GLboolean EXT_paletted_texture
;
1828 GLboolean EXT_point_parameters
;
1829 GLboolean EXT_shadow_funcs
;
1830 GLboolean EXT_secondary_color
;
1831 GLboolean EXT_shared_texture_palette
;
1832 GLboolean EXT_stencil_wrap
;
1833 GLboolean EXT_stencil_two_side
;
1834 GLboolean EXT_texture3D
;
1835 GLboolean EXT_texture_compression_s3tc
;
1836 GLboolean EXT_texture_env_add
;
1837 GLboolean EXT_texture_env_combine
;
1838 GLboolean EXT_texture_env_dot3
;
1839 GLboolean EXT_texture_filter_anisotropic
;
1840 GLboolean EXT_texture_lod_bias
;
1841 GLboolean EXT_texture_mirror_clamp
;
1842 GLboolean EXT_vertex_array_set
;
1843 GLboolean HP_occlusion_test
;
1844 GLboolean IBM_rasterpos_clip
;
1845 GLboolean IBM_multimode_draw_arrays
;
1846 GLboolean MESA_pack_invert
;
1847 GLboolean MESA_packed_depth_stencil
;
1848 GLboolean MESA_program_debug
;
1849 GLboolean MESA_resize_buffers
;
1850 GLboolean MESA_ycbcr_texture
;
1851 GLboolean NV_blend_square
;
1852 GLboolean NV_fragment_program
;
1853 GLboolean NV_point_sprite
;
1854 GLboolean NV_texture_rectangle
;
1855 GLboolean NV_vertex_program
;
1856 GLboolean NV_vertex_program1_1
;
1857 GLboolean SGI_color_matrix
;
1858 GLboolean SGI_color_table
;
1859 GLboolean SGI_texture_color_table
;
1860 GLboolean SGIS_generate_mipmap
;
1861 GLboolean SGIS_pixel_texture
;
1862 GLboolean SGIS_texture_edge_clamp
;
1863 GLboolean SGIX_depth_texture
;
1864 GLboolean SGIX_pixel_texture
;
1865 GLboolean SGIX_shadow
;
1866 GLboolean SGIX_shadow_ambient
; /* or GL_ARB_shadow_ambient */
1867 GLboolean TDFX_texture_compression_FXT1
;
1868 GLboolean APPLE_client_storage
;
1871 /* The extension string */
1872 const GLubyte
*String
;
1877 * A stack of matrices (projection, modelview, color, texture, etc).
1881 GLmatrix
*Top
; /**< points into Stack */
1882 GLmatrix
*Stack
; /**< array [MaxDepth] of GLmatrix */
1883 GLuint Depth
; /**< 0 <= Depth < MaxDepth */
1884 GLuint MaxDepth
; /**< size of Stack[] array */
1885 GLuint DirtyFlag
; /**< _NEW_MODELVIEW or _NEW_PROJECTION, for example */
1890 * \name Bits for image transfer operations
1892 * \sa __GLcontextRec::ImageTransferState.
1895 #define IMAGE_SCALE_BIAS_BIT 0x1
1896 #define IMAGE_SHIFT_OFFSET_BIT 0x2
1897 #define IMAGE_MAP_COLOR_BIT 0x4
1898 #define IMAGE_COLOR_TABLE_BIT 0x8
1899 #define IMAGE_CONVOLUTION_BIT 0x10
1900 #define IMAGE_POST_CONVOLUTION_SCALE_BIAS 0x20
1901 #define IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT 0x40
1902 #define IMAGE_COLOR_MATRIX_BIT 0x80
1903 #define IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT 0x100
1904 #define IMAGE_HISTOGRAM_BIT 0x200
1905 #define IMAGE_MIN_MAX_BIT 0x400
1907 /** Transfer ops up to convolution */
1908 #define IMAGE_PRE_CONVOLUTION_BITS (IMAGE_SCALE_BIAS_BIT | \
1909 IMAGE_SHIFT_OFFSET_BIT | \
1910 IMAGE_MAP_COLOR_BIT | \
1911 IMAGE_COLOR_TABLE_BIT)
1913 /** Transfer ops after convolution */
1914 #define IMAGE_POST_CONVOLUTION_BITS (IMAGE_POST_CONVOLUTION_SCALE_BIAS | \
1915 IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT | \
1916 IMAGE_COLOR_MATRIX_BIT | \
1917 IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT |\
1918 IMAGE_HISTOGRAM_BIT | \
1924 * \name Bits to indicate what state has changed.
1929 #define _NEW_MODELVIEW 0x1 /**< __GLcontextRec::ModelView */
1930 #define _NEW_PROJECTION 0x2 /**< __GLcontextRec::Projection */
1931 #define _NEW_TEXTURE_MATRIX 0x4 /**< __GLcontextRec::TextureMatrix */
1932 #define _NEW_COLOR_MATRIX 0x8 /**< __GLcontextRec::ColorMatrix */
1933 #define _NEW_ACCUM 0x10 /**< __GLcontextRec::Accum */
1934 #define _NEW_COLOR 0x20 /**< __GLcontextRec::Color */
1935 #define _NEW_DEPTH 0x40 /**< __GLcontextRec::Depth */
1936 #define _NEW_EVAL 0x80 /**< __GLcontextRec::Eval, __GLcontextRec::EvalMap */
1937 #define _NEW_FOG 0x100 /**< __GLcontextRec::Fog */
1938 #define _NEW_HINT 0x200 /**< __GLcontextRec::Hint */
1939 #define _NEW_LIGHT 0x400 /**< __GLcontextRec::Light */
1940 #define _NEW_LINE 0x800 /**< __GLcontextRec::Line */
1941 #define _NEW_PIXEL 0x1000 /**< __GLcontextRec::Pixel */
1942 #define _NEW_POINT 0x2000 /**< __GLcontextRec::Point */
1943 #define _NEW_POLYGON 0x4000 /**< __GLcontextRec::Polygon */
1944 #define _NEW_POLYGONSTIPPLE 0x8000 /**< __GLcontextRec::PolygonStipple */
1945 #define _NEW_SCISSOR 0x10000 /**< __GLcontextRec::Scissor */
1946 #define _NEW_STENCIL 0x20000 /**< __GLcontextRec::Stencil */
1947 #define _NEW_TEXTURE 0x40000 /**< __GLcontextRec::Texture */
1948 #define _NEW_TRANSFORM 0x80000 /**< __GLcontextRec::Transform */
1949 #define _NEW_VIEWPORT 0x100000 /**< __GLcontextRec::Viewport */
1950 #define _NEW_PACKUNPACK 0x200000 /**< __GLcontextRec::Pack, __GLcontextRec::Unpack */
1951 #define _NEW_ARRAY 0x400000 /**< __GLcontextRec::Array */
1952 #define _NEW_RENDERMODE 0x800000 /**< __GLcontextRec::RenderMode, __GLcontextRec::Feedback, __GLcontextRec::Select */
1953 #define _NEW_BUFFERS 0x1000000 /**< __GLcontextRec::Visual, __GLcontextRec::DrawBuffer, */
1954 #define _NEW_MULTISAMPLE 0x2000000 /**< __GLcontextRec::Multisample */
1955 #define _NEW_TRACK_MATRIX 0x4000000 /**< __GLcontextRec::VertexProgram */
1956 #define _NEW_PROGRAM 0x8000000 /**< __GLcontextRec::VertexProgram */
1962 * \name Bits to track array state changes
1964 * Also used to summarize array enabled.
1967 #define _NEW_ARRAY_VERTEX VERT_BIT_POS
1968 #define _NEW_ARRAY_WEIGHT VERT_BIT_WEIGHT
1969 #define _NEW_ARRAY_NORMAL VERT_BIT_NORMAL
1970 #define _NEW_ARRAY_COLOR0 VERT_BIT_COLOR0
1971 #define _NEW_ARRAY_COLOR1 VERT_BIT_COLOR1
1972 #define _NEW_ARRAY_FOGCOORD VERT_BIT_FOG
1973 #define _NEW_ARRAY_INDEX VERT_BIT_SIX
1974 #define _NEW_ARRAY_EDGEFLAG VERT_BIT_SEVEN
1975 #define _NEW_ARRAY_TEXCOORD_0 VERT_BIT_TEX0
1976 #define _NEW_ARRAY_TEXCOORD_1 VERT_BIT_TEX1
1977 #define _NEW_ARRAY_TEXCOORD_2 VERT_BIT_TEX2
1978 #define _NEW_ARRAY_TEXCOORD_3 VERT_BIT_TEX3
1979 #define _NEW_ARRAY_TEXCOORD_4 VERT_BIT_TEX4
1980 #define _NEW_ARRAY_TEXCOORD_5 VERT_BIT_TEX5
1981 #define _NEW_ARRAY_TEXCOORD_6 VERT_BIT_TEX6
1982 #define _NEW_ARRAY_TEXCOORD_7 VERT_BIT_TEX7
1983 #define _NEW_ARRAY_ATTRIB_0 0x10000 /* start at bit 16 */
1984 #define _NEW_ARRAY_ALL 0xffffffff
1987 #define _NEW_ARRAY_TEXCOORD(i) (_NEW_ARRAY_TEXCOORD_0 << (i))
1988 #define _NEW_ARRAY_ATTRIB(i) (_NEW_ARRAY_ATTRIB_0 << (i))
1993 * \name A bunch of flags that we think might be useful to drivers.
1995 * Set in the __GLcontextRec::_TriangleCaps bitfield.
1998 #define DD_FLATSHADE 0x1
1999 #define DD_SEPARATE_SPECULAR 0x2
2000 #define DD_TRI_CULL_FRONT_BACK 0x4 /* special case on some hw */
2001 #define DD_TRI_LIGHT_TWOSIDE 0x8
2002 #define DD_TRI_UNFILLED 0x10
2003 #define DD_TRI_SMOOTH 0x20
2004 #define DD_TRI_STIPPLE 0x40
2005 #define DD_TRI_OFFSET 0x80
2006 #define DD_LINE_SMOOTH 0x100
2007 #define DD_LINE_STIPPLE 0x200
2008 #define DD_LINE_WIDTH 0x400
2009 #define DD_POINT_SMOOTH 0x800
2010 #define DD_POINT_SIZE 0x1000
2011 #define DD_POINT_ATTEN 0x2000
2016 * \name Define the state changes under which each of these bits might change
2019 #define _DD_NEW_FLATSHADE _NEW_LIGHT
2020 #define _DD_NEW_SEPARATE_SPECULAR (_NEW_LIGHT | _NEW_FOG | _NEW_PROGRAM)
2021 #define _DD_NEW_TRI_CULL_FRONT_BACK _NEW_POLYGON
2022 #define _DD_NEW_TRI_LIGHT_TWOSIDE _NEW_LIGHT
2023 #define _DD_NEW_TRI_UNFILLED _NEW_POLYGON
2024 #define _DD_NEW_TRI_SMOOTH _NEW_POLYGON
2025 #define _DD_NEW_TRI_STIPPLE _NEW_POLYGON
2026 #define _DD_NEW_TRI_OFFSET _NEW_POLYGON
2027 #define _DD_NEW_LINE_SMOOTH _NEW_LINE
2028 #define _DD_NEW_LINE_STIPPLE _NEW_LINE
2029 #define _DD_NEW_LINE_WIDTH _NEW_LINE
2030 #define _DD_NEW_POINT_SMOOTH _NEW_POINT
2031 #define _DD_NEW_POINT_SIZE _NEW_POINT
2032 #define _DD_NEW_POINT_ATTEN _NEW_POINT
2036 #define _MESA_NEW_NEED_EYE_COORDS (_NEW_LIGHT | \
2041 #define _MESA_NEW_NEED_NORMALS (_NEW_LIGHT | \
2044 #define _IMAGE_NEW_TRANSFER_STATE (_NEW_PIXEL | _NEW_COLOR_MATRIX)
2050 * Forward declaration of display list data types:
2053 typedef union node Node
;
2056 /* This has to be included here. */
2060 #define NUM_VERTEX_FORMAT_ENTRIES (sizeof(GLvertexformat) / sizeof(void *))
2063 * Core Mesa's support for tnl modules:
2065 struct gl_tnl_module
{
2067 * Vertex format to be lazily swapped into current dispatch.
2069 GLvertexformat
*Current
;
2072 * \name Record of functions swapped out.
2073 * On restore, only need to swap these functions back in.
2076 void *Swapped
[NUM_VERTEX_FORMAT_ENTRIES
][2];
2081 struct mesa_list_state
{
2082 GLuint CallDepth
; /**< Current recursion calling depth */
2083 Node
*CurrentListPtr
; /**< Head of list being compiled */
2084 GLuint CurrentListNum
; /**< Number of the list being compiled */
2085 Node
*CurrentBlock
; /**< Pointer to current block of nodes */
2086 GLuint CurrentPos
; /**< Index into current block of nodes */
2087 GLvertexformat ListVtxfmt
;
2089 GLubyte ActiveAttribSize
[VERT_ATTRIB_MAX
];
2090 GLfloat CurrentAttrib
[VERT_ATTRIB_MAX
][4];
2092 GLubyte ActiveMaterialSize
[MAT_ATTRIB_MAX
];
2093 GLfloat CurrentMaterial
[MAT_ATTRIB_MAX
][4];
2095 GLubyte ActiveIndex
;
2096 GLfloat CurrentIndex
;
2098 GLubyte ActiveEdgeFlag
;
2099 GLboolean CurrentEdgeFlag
;
2106 * This is the central context data structure for Mesa. Almost all
2107 * OpenGL state is contained in this structure.
2108 * Think of this as a base class from which device drivers will derive
2111 struct __GLcontextRec
{
2113 * \name OS related interfaces.
2115 * These \b must be the first members of this structure, because they are
2116 * exposed to the outside world (i.e. GLX extension).
2119 __GLimports imports
;
2120 __GLexports exports
;
2123 /** State possibly shared with other contexts in the address space */
2124 struct gl_shared_state
*Shared
;
2126 /** \name API function pointer tables */
2128 struct _glapi_table
*Save
; /**< Display list save functions */
2129 struct _glapi_table
*Exec
; /**< Execute functions */
2130 struct _glapi_table
*CurrentDispatch
; /**< == Save or Exec !! */
2134 GLframebuffer
*DrawBuffer
; /**< buffer for writing */
2135 GLframebuffer
*ReadBuffer
; /**< buffer for reading */
2138 * Device driver function pointer table
2140 struct dd_function_table Driver
;
2142 void *DriverCtx
; /**< Points to device driver context/state */
2143 void *DriverMgrCtx
; /**< Points to device driver manager (optional)*/
2145 /** Core/Driver constants */
2146 struct gl_constants Const
;
2148 /** \name The various 4x4 matrix stacks */
2150 struct matrix_stack ModelviewMatrixStack
;
2151 struct matrix_stack ProjectionMatrixStack
;
2152 struct matrix_stack ColorMatrixStack
;
2153 struct matrix_stack TextureMatrixStack
[MAX_TEXTURE_COORD_UNITS
];
2154 struct matrix_stack ProgramMatrixStack
[MAX_PROGRAM_MATRICES
];
2155 struct matrix_stack
*CurrentStack
; /**< Points to one of the above stacks */
2158 /** Combined modelview and projection matrix */
2159 GLmatrix _ModelProjectMatrix
;
2161 /** \name Display lists */
2162 struct mesa_list_state ListState
;
2164 GLboolean ExecuteFlag
; /**< Execute GL commands? */
2165 GLboolean CompileFlag
; /**< Compile GL commands into display list? */
2168 struct gl_extensions Extensions
;
2170 /** \name Renderer attribute stack */
2172 GLuint AttribStackDepth
;
2173 struct gl_attrib_node
*AttribStack
[MAX_ATTRIB_STACK_DEPTH
];
2176 /** \name Renderer attribute groups
2178 * We define a struct for each attribute group to make pushing and popping
2179 * attributes easy. Also it's a good organization.
2182 struct gl_accum_attrib Accum
; /**< Accumulation buffer attributes */
2183 struct gl_colorbuffer_attrib Color
; /**< Color buffers attributes */
2184 struct gl_current_attrib Current
; /**< Current attributes */
2185 struct gl_depthbuffer_attrib Depth
; /**< Depth buffer attributes */
2186 struct gl_eval_attrib Eval
; /**< Eval attributes */
2187 struct gl_fog_attrib Fog
; /**< Fog attributes */
2188 struct gl_hint_attrib Hint
; /**< Hint attributes */
2189 struct gl_light_attrib Light
; /**< Light attributes */
2190 struct gl_line_attrib Line
; /**< Line attributes */
2191 struct gl_list_attrib List
; /**< List attributes */
2192 struct gl_multisample_attrib Multisample
;
2193 struct gl_pixel_attrib Pixel
; /**< Pixel attributes */
2194 struct gl_point_attrib Point
; /**< Point attributes */
2195 struct gl_polygon_attrib Polygon
; /**< Polygon attributes */
2196 GLuint PolygonStipple
[32]; /**< Polygon stipple */
2197 struct gl_scissor_attrib Scissor
; /**< Scissor attributes */
2198 struct gl_stencil_attrib Stencil
; /**< Stencil buffer attributes */
2199 struct gl_texture_attrib Texture
; /**< Texture attributes */
2200 struct gl_transform_attrib Transform
; /**< Transformation attributes */
2201 struct gl_viewport_attrib Viewport
; /**< Viewport attributes */
2204 /** \name Other attribute groups */
2206 struct gl_histogram_attrib Histogram
;
2207 struct gl_minmax_attrib MinMax
;
2208 struct gl_convolution_attrib Convolution1D
;
2209 struct gl_convolution_attrib Convolution2D
;
2210 struct gl_convolution_attrib Separable2D
;
2213 /** \name Client attribute stack */
2215 GLuint ClientAttribStackDepth
;
2216 struct gl_attrib_node
*ClientAttribStack
[MAX_CLIENT_ATTRIB_STACK_DEPTH
];
2219 /** \name Client attribute groups */
2221 struct gl_array_attrib Array
; /**< Vertex arrays */
2222 struct gl_pixelstore_attrib Pack
; /**< Pixel packing */
2223 struct gl_pixelstore_attrib Unpack
; /**< Pixel unpacking */
2225 struct gl_evaluators EvalMap
; /**< All evaluators */
2226 struct gl_feedback Feedback
; /**< Feedback */
2227 struct gl_selection Select
; /**< Selection */
2229 struct gl_color_table ColorTable
; /**< Pre-convolution */
2230 struct gl_color_table ProxyColorTable
; /**< Pre-convolution */
2231 struct gl_color_table PostConvolutionColorTable
;
2232 struct gl_color_table ProxyPostConvolutionColorTable
;
2233 struct gl_color_table PostColorMatrixColorTable
;
2234 struct gl_color_table ProxyPostColorMatrixColorTable
;
2236 struct program_state Program
; /**< for vertex or fragment progs */
2237 struct vertex_program_state VertexProgram
; /**< GL_NV_vertex_program */
2238 struct fragment_program_state FragmentProgram
; /**< GL_NV_fragment_program */
2240 struct occlusion_state Occlusion
; /**< GL_ARB_occlusion_query */
2242 GLenum ErrorValue
; /**< Last error code */
2243 GLenum RenderMode
; /**< either GL_RENDER, GL_SELECT, GL_FEEDBACK */
2244 GLuint NewState
; /**< bitwise-or of _NEW_* flags */
2247 /** \name Derived */
2249 GLuint _TriangleCaps
; /**< bitwise-or of DD_* flags */
2250 GLuint _ImageTransferState
;/**< bitwise-or of IMAGE_*_BIT flags */
2251 GLfloat _EyeZDir
[3];
2252 GLfloat _ModelViewInvScale
;
2253 GLuint _NeedEyeCoords
;
2254 GLuint _ForceEyeCoords
;
2255 GLboolean _RotateMode
;
2256 GLenum _CurrentProgram
; /* currently executing program */
2258 struct gl_shine_tab
*_ShineTable
[2]; /**< Active shine tables */
2259 struct gl_shine_tab
*_ShineTabList
; /**< MRU list of inactive shine tables */
2262 struct gl_list_extensions listext
; /**< driver dlist extensions */
2265 GLboolean OcclusionResult
; /**< for GL_HP_occlusion_test */
2266 GLboolean OcclusionResultSaved
; /**< for GL_HP_occlusion_test */
2267 GLuint _Facing
; /**< This is a hack for 2-sided stencil test.
2269 * We don't have a better way to communicate this value from
2270 * swrast_setup to swrast. */
2273 /** \name Z buffer stuff */
2275 GLuint DepthMax
; /**< Max depth buffer value */
2276 GLfloat DepthMaxF
; /**< Float max depth buffer value */
2277 GLfloat MRD
; /**< minimum resolvable difference in Z values */
2280 /** Should 3Dfx Glide driver catch signals? */
2281 GLboolean CatchSignals
;
2283 /** \name For debugging/development only */
2285 GLboolean FirstTimeCurrent
;
2288 /** Dither disable via MESA_NO_DITHER env var */
2291 /** Core tnl module support */
2292 struct gl_tnl_module TnlModule
;
2295 * \name Hooks for module contexts.
2297 * These will eventually live in the driver or elsewhere.
2300 void *swrast_context
;
2301 void *swsetup_context
;
2302 void *swtnl_context
;
2304 void *acache_context
;
2310 /** The string names for GL_POINT, GL_LINE_LOOP, etc */
2311 extern const char *_mesa_prim_name
[GL_POLYGON
+4];
2315 extern int MESA_VERBOSE
;
2316 extern int MESA_DEBUG_FLAGS
;
2317 # define MESA_FUNCTION __FUNCTION__
2319 # define MESA_VERBOSE 0
2320 # define MESA_DEBUG_FLAGS 0
2321 # define MESA_FUNCTION "a function"
2329 VERBOSE_VARRAY
= 0x0001,
2330 VERBOSE_TEXTURE
= 0x0002,
2331 VERBOSE_IMMEDIATE
= 0x0004,
2332 VERBOSE_PIPELINE
= 0x0008,
2333 VERBOSE_DRIVER
= 0x0010,
2334 VERBOSE_STATE
= 0x0020,
2335 VERBOSE_API
= 0x0040,
2336 VERBOSE_DISPLAY_LIST
= 0x0100,
2337 VERBOSE_LIGHTING
= 0x0200,
2338 VERBOSE_PRIMS
= 0x0400,
2339 VERBOSE_VERTS
= 0x0800
2344 DEBUG_ALWAYS_FLUSH
= 0x1
2349 #define Elements(x) sizeof(x)/sizeof(*(x))
2352 #endif /* TYPES_H */