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)))
202 * Maximum number of temporary vertices required for clipping.
204 * Used in array_cache and tnl modules.
206 #define MAX_CLIPPED_VERTICES ((2 * (6 + MAX_CLIP_PLANES))+1)
210 * Data structure for color tables
212 struct gl_color_table
{
213 GLenum Format
; /**< GL_ALPHA, GL_RGB, GL_RGB, etc */
215 GLuint Size
; /**< number of entries (rows) in table */
216 GLvoid
*Table
; /**< either GLfloat * or GLchan * */
217 GLboolean FloatTable
; /**< are entries stored as floats? */
222 GLubyte LuminanceSize
;
223 GLubyte IntensitySize
;
228 * \name Bit flags used for updating material values.
231 #define MAT_ATTRIB_FRONT_AMBIENT 0
232 #define MAT_ATTRIB_BACK_AMBIENT 1
233 #define MAT_ATTRIB_FRONT_DIFFUSE 2
234 #define MAT_ATTRIB_BACK_DIFFUSE 3
235 #define MAT_ATTRIB_FRONT_SPECULAR 4
236 #define MAT_ATTRIB_BACK_SPECULAR 5
237 #define MAT_ATTRIB_FRONT_EMISSION 6
238 #define MAT_ATTRIB_BACK_EMISSION 7
239 #define MAT_ATTRIB_FRONT_SHININESS 8
240 #define MAT_ATTRIB_BACK_SHININESS 9
241 #define MAT_ATTRIB_FRONT_INDEXES 10
242 #define MAT_ATTRIB_BACK_INDEXES 11
243 #define MAT_ATTRIB_MAX 12
245 #define MAT_ATTRIB_AMBIENT(f) (MAT_ATTRIB_FRONT_AMBIENT+(f))
246 #define MAT_ATTRIB_DIFFUSE(f) (MAT_ATTRIB_FRONT_DIFFUSE+(f))
247 #define MAT_ATTRIB_SPECULAR(f) (MAT_ATTRIB_FRONT_SPECULAR+(f))
248 #define MAT_ATTRIB_EMISSION(f) (MAT_ATTRIB_FRONT_EMISSION+(f))
249 #define MAT_ATTRIB_SHININESS(f)(MAT_ATTRIB_FRONT_SHININESS+(f))
250 #define MAT_ATTRIB_INDEXES(f) (MAT_ATTRIB_FRONT_INDEXES+(f))
252 #define MAT_INDEX_AMBIENT 0
253 #define MAT_INDEX_DIFFUSE 1
254 #define MAT_INDEX_SPECULAR 2
256 #define MAT_BIT_FRONT_AMBIENT (1<<MAT_ATTRIB_FRONT_AMBIENT)
257 #define MAT_BIT_BACK_AMBIENT (1<<MAT_ATTRIB_BACK_AMBIENT)
258 #define MAT_BIT_FRONT_DIFFUSE (1<<MAT_ATTRIB_FRONT_DIFFUSE)
259 #define MAT_BIT_BACK_DIFFUSE (1<<MAT_ATTRIB_BACK_DIFFUSE)
260 #define MAT_BIT_FRONT_SPECULAR (1<<MAT_ATTRIB_FRONT_SPECULAR)
261 #define MAT_BIT_BACK_SPECULAR (1<<MAT_ATTRIB_BACK_SPECULAR)
262 #define MAT_BIT_FRONT_EMISSION (1<<MAT_ATTRIB_FRONT_EMISSION)
263 #define MAT_BIT_BACK_EMISSION (1<<MAT_ATTRIB_BACK_EMISSION)
264 #define MAT_BIT_FRONT_SHININESS (1<<MAT_ATTRIB_FRONT_SHININESS)
265 #define MAT_BIT_BACK_SHININESS (1<<MAT_ATTRIB_BACK_SHININESS)
266 #define MAT_BIT_FRONT_INDEXES (1<<MAT_ATTRIB_FRONT_INDEXES)
267 #define MAT_BIT_BACK_INDEXES (1<<MAT_ATTRIB_BACK_INDEXES)
270 #define FRONT_MATERIAL_BITS (MAT_BIT_FRONT_EMISSION | \
271 MAT_BIT_FRONT_AMBIENT | \
272 MAT_BIT_FRONT_DIFFUSE | \
273 MAT_BIT_FRONT_SPECULAR | \
274 MAT_BIT_FRONT_SHININESS | \
275 MAT_BIT_FRONT_INDEXES)
277 #define BACK_MATERIAL_BITS (MAT_BIT_BACK_EMISSION | \
278 MAT_BIT_BACK_AMBIENT | \
279 MAT_BIT_BACK_DIFFUSE | \
280 MAT_BIT_BACK_SPECULAR | \
281 MAT_BIT_BACK_SHININESS | \
282 MAT_BIT_BACK_INDEXES)
284 #define ALL_MATERIAL_BITS (FRONT_MATERIAL_BITS | BACK_MATERIAL_BITS)
288 #define EXP_TABLE_SIZE 512 /**< Specular exponent lookup table sizes */
289 #define SHINE_TABLE_SIZE 256 /**< Material shininess lookup table sizes */
292 * Material shininess lookup table.
294 struct gl_shine_tab
{
295 struct gl_shine_tab
*next
, *prev
;
296 GLfloat tab
[SHINE_TABLE_SIZE
+1];
306 struct gl_light
*next
; /**< double linked list with sentinel */
307 struct gl_light
*prev
;
309 GLfloat Ambient
[4]; /**< ambient color */
310 GLfloat Diffuse
[4]; /**< diffuse color */
311 GLfloat Specular
[4]; /**< specular color */
312 GLfloat EyePosition
[4]; /**< position in eye coordinates */
313 GLfloat EyeDirection
[4]; /**< spotlight dir in eye coordinates */
314 GLfloat SpotExponent
;
315 GLfloat SpotCutoff
; /**< in degrees */
316 GLfloat _CosCutoff
; /**< = MAX(0, cos(SpotCutoff)) */
317 GLfloat ConstantAttenuation
;
318 GLfloat LinearAttenuation
;
319 GLfloat QuadraticAttenuation
;
320 GLboolean Enabled
; /**< On/off flag */
323 * \name Derived fields
326 GLuint _Flags
; /**< State */
328 GLfloat _Position
[4]; /**< position in eye/obj coordinates */
329 GLfloat _VP_inf_norm
[3]; /**< Norm direction to infinite light */
330 GLfloat _h_inf_norm
[3]; /**< Norm( _VP_inf_norm + <0,0,1> ) */
331 GLfloat _NormDirection
[4]; /**< normalized spotlight direction */
332 GLfloat _VP_inf_spot_attenuation
;
334 GLfloat _SpotExpTable
[EXP_TABLE_SIZE
][2]; /**< to replace a pow() call */
335 GLfloat _MatAmbient
[2][3]; /**< material ambient * light ambient */
336 GLfloat _MatDiffuse
[2][3]; /**< material diffuse * light diffuse */
337 GLfloat _MatSpecular
[2][3]; /**< material spec * light specular */
338 GLfloat _dli
; /**< CI diffuse light intensity */
339 GLfloat _sli
; /**< CI specular light intensity */
347 struct gl_lightmodel
{
348 GLfloat Ambient
[4]; /**< ambient color */
349 GLboolean LocalViewer
; /**< Local (or infinite) view point? */
350 GLboolean TwoSide
; /**< Two (or one) sided lighting? */
351 GLenum ColorControl
; /**< either GL_SINGLE_COLOR
352 * or GL_SEPARATE_SPECULAR_COLOR */
361 GLfloat Attrib
[MAT_ATTRIB_MAX
][4];
366 * Accumulation buffer attributes.
368 struct gl_accum_attrib
{
369 GLfloat ClearColor
[4]; /**< Accumulation buffer clear color */
374 * \name Clipping planes bits
376 * Used in gl_colorbuffer_attrib::_DrawDestMask and
377 * gl_colorbuffer_attrib::_ReadSrcMask below to identify color buffers.
380 #define FRONT_LEFT_BIT 0x1
381 #define FRONT_RIGHT_BIT 0x2
382 #define BACK_LEFT_BIT 0x4
383 #define BACK_RIGHT_BIT 0x8
384 #define AUX0_BIT 0x10
385 #define AUX1_BIT 0x20
386 #define AUX2_BIT 0x40
387 #define AUX3_BIT 0x80
392 * Color buffers attributes.
394 struct gl_colorbuffer_attrib
{
395 GLuint ClearIndex
; /**< Index to use for glClear */
396 GLclampf ClearColor
[4]; /**< Color to use for glClear */
398 GLuint IndexMask
; /**< Color index write mask */
399 GLubyte ColorMask
[4]; /**< Each flag is 0xff or 0x0 */
401 GLenum DrawBuffer
; /**< Which buffer to draw into */
402 GLubyte _DrawDestMask
; /**< bitwise-OR of FRONT/BACK_LEFT/RIGHT_BITs */
405 * \name alpha testing
408 GLboolean AlphaEnabled
; /**< Alpha test enabled flag */
409 GLenum AlphaFunc
; /**< Alpha test function */
410 GLclampf AlphaRef
; /**< Alpha reference value */
417 GLboolean BlendEnabled
; /**< Blending enabled flag */
418 GLenum BlendSrcRGB
; /**< Blending source operator */
419 GLenum BlendDstRGB
; /**< Blending destination operator */
420 GLenum BlendSrcA
; /**< GL_INGR_blend_func_separate */
421 GLenum BlendDstA
; /**< GL_INGR_blend_func_separate */
422 GLenum BlendEquation
; /**< Blending equation */
423 GLfloat BlendColor
[4]; /**< Blending color */
430 GLenum LogicOp
; /**< Logic operator */
431 GLboolean IndexLogicOpEnabled
; /**< Color index logic op enabled flag */
432 GLboolean ColorLogicOpEnabled
; /**< RGBA logic op enabled flag */
433 GLboolean _LogicOpEnabled
; /**< RGBA logic op + EXT_blend_logic_op enabled flag */
436 GLboolean DitherFlag
; /**< Dither enable flag */
441 * Current attributes.
443 struct gl_current_attrib
{
445 * \name Values valid only when FLUSH_VERTICES has been called.
448 GLfloat Attrib
[VERT_ATTRIB_MAX
][4]; /**< Current vertex attributes
449 * indexed by VERT_ATTRIB_* */
450 GLfloat Index
; /**< Current color index */
451 GLboolean EdgeFlag
; /**< Current edge flag */
455 * \name Values are always valid.
457 * \note BTW, note how similar this set of attributes is to the SWvertex
458 * data type in the software rasterizer...
461 GLfloat RasterPos
[4]; /**< Current raster position */
462 GLfloat RasterDistance
; /**< Current raster distance */
463 GLfloat RasterColor
[4]; /**< Current raster color */
464 GLfloat RasterSecondaryColor
[4]; /**< Current raster secondary color */
465 GLfloat RasterIndex
; /**< Current raster index */
466 GLfloat RasterTexCoords
[MAX_TEXTURE_UNITS
][4];/**< Current raster texcoords */
467 GLboolean RasterPosValid
; /**< Raster pos valid flag */
473 * Depth buffer attributes.
475 struct gl_depthbuffer_attrib
{
476 GLenum Func
; /**< Function for depth buffer compare */
477 GLclampd Clear
; /**< Value to clear depth buffer to */
478 GLboolean Test
; /**< Depth buffering enabled flag */
479 GLboolean Mask
; /**< Depth buffer writable? */
480 GLboolean OcclusionTest
; /**< GL_HP_occlusion_test */
481 GLboolean BoundsTest
; /**< GL_EXT_depth_bounds_test */
482 GLfloat BoundsMin
, BoundsMax
;/**< GL_EXT_depth_bounds_test */
487 * glEnable()/glDisable() attributes.
489 struct gl_enable_attrib
{
491 GLboolean AutoNormal
;
494 GLboolean ColorMaterial
;
495 GLboolean ColorTable
; /* SGI_color_table */
496 GLboolean PostColorMatrixColorTable
; /* SGI_color_table */
497 GLboolean PostConvolutionColorTable
; /* SGI_color_table */
498 GLboolean Convolution1D
;
499 GLboolean Convolution2D
;
500 GLboolean Separable2D
;
506 GLboolean Light
[MAX_LIGHTS
];
508 GLboolean LineSmooth
;
509 GLboolean LineStipple
;
510 GLboolean IndexLogicOp
;
511 GLboolean ColorLogicOp
;
512 GLboolean Map1Color4
;
514 GLboolean Map1Normal
;
515 GLboolean Map1TextureCoord1
;
516 GLboolean Map1TextureCoord2
;
517 GLboolean Map1TextureCoord3
;
518 GLboolean Map1TextureCoord4
;
519 GLboolean Map1Vertex3
;
520 GLboolean Map1Vertex4
;
521 GLboolean Map1Attrib
[16]; /* GL_NV_vertex_program */
522 GLboolean Map2Color4
;
524 GLboolean Map2Normal
;
525 GLboolean Map2TextureCoord1
;
526 GLboolean Map2TextureCoord2
;
527 GLboolean Map2TextureCoord3
;
528 GLboolean Map2TextureCoord4
;
529 GLboolean Map2Vertex3
;
530 GLboolean Map2Vertex4
;
531 GLboolean Map2Attrib
[16]; /* GL_NV_vertex_program */
534 GLboolean PixelTexture
;
535 GLboolean PointSmooth
;
536 GLboolean PolygonOffsetPoint
;
537 GLboolean PolygonOffsetLine
;
538 GLboolean PolygonOffsetFill
;
539 GLboolean PolygonSmooth
;
540 GLboolean PolygonStipple
;
541 GLboolean RescaleNormals
;
544 GLboolean MultisampleEnabled
; /* GL_ARB_multisample */
545 GLboolean SampleAlphaToCoverage
; /* GL_ARB_multisample */
546 GLboolean SampleAlphaToOne
; /* GL_ARB_multisample */
547 GLboolean SampleCoverage
; /* GL_ARB_multisample */
548 GLboolean SampleCoverageInvert
; /* GL_ARB_multisample */
549 GLboolean RasterPositionUnclipped
; /* GL_IBM_rasterpos_clip */
550 GLuint Texture
[MAX_TEXTURE_IMAGE_UNITS
];
551 GLuint TexGen
[MAX_TEXTURE_COORD_UNITS
];
552 /* SGI_texture_color_table */
553 GLboolean TextureColorTable
[MAX_TEXTURE_IMAGE_UNITS
];
554 /* GL_NV_vertex_program */
555 GLboolean VertexProgram
;
556 GLboolean VertexProgramPointSize
;
557 GLboolean VertexProgramTwoSide
;
558 /* GL_ARB_point_sprite / GL_NV_point_sprite */
559 GLboolean PointSprite
;
566 struct gl_eval_attrib
{
571 GLboolean Map1Color4
;
573 GLboolean Map1Normal
;
574 GLboolean Map1TextureCoord1
;
575 GLboolean Map1TextureCoord2
;
576 GLboolean Map1TextureCoord3
;
577 GLboolean Map1TextureCoord4
;
578 GLboolean Map1Vertex3
;
579 GLboolean Map1Vertex4
;
580 GLboolean Map1Attrib
[16]; /* GL_NV_vertex_program */
581 GLboolean Map2Color4
;
583 GLboolean Map2Normal
;
584 GLboolean Map2TextureCoord1
;
585 GLboolean Map2TextureCoord2
;
586 GLboolean Map2TextureCoord3
;
587 GLboolean Map2TextureCoord4
;
588 GLboolean Map2Vertex3
;
589 GLboolean Map2Vertex4
;
590 GLboolean Map2Attrib
[16]; /* GL_NV_vertex_program */
591 GLboolean AutoNormal
;
595 * \name Map Grid endpoints and divisions and calculated du values
599 GLfloat MapGrid1u1
, MapGrid1u2
, MapGrid1du
;
600 GLint MapGrid2un
, MapGrid2vn
;
601 GLfloat MapGrid2u1
, MapGrid2u2
, MapGrid2du
;
602 GLfloat MapGrid2v1
, MapGrid2v2
, MapGrid2dv
;
610 struct gl_fog_attrib
{
611 GLboolean Enabled
; /**< Fog enabled flag */
612 GLfloat Color
[4]; /**< Fog color */
613 GLfloat Density
; /**< Density >= 0.0 */
614 GLfloat Start
; /**< Start distance in eye coords */
615 GLfloat End
; /**< End distance in eye coords */
616 GLfloat Index
; /**< Fog index */
617 GLenum Mode
; /**< Fog mode */
618 GLboolean ColorSumEnabled
;
619 GLenum FogCoordinateSource
; /**< GL_EXT_fog_coord */
626 * Values are always one of GL_FASTEST, GL_NICEST, or GL_DONT_CARE.
628 struct gl_hint_attrib
{
629 GLenum PerspectiveCorrection
;
632 GLenum PolygonSmooth
;
634 GLenum ClipVolumeClipping
; /**< GL_EXT_clip_volume_hint */
635 GLenum TextureCompression
; /**< GL_ARB_texture_compression */
636 GLenum GenerateMipmap
; /**< GL_SGIS_generate_mipmap */
641 * Histogram attributes.
643 struct gl_histogram_attrib
{
644 GLuint Width
; /**< number of table entries */
645 GLint Format
; /**< GL_ALPHA, GL_RGB, etc */
646 GLuint Count
[HISTOGRAM_TABLE_SIZE
][4]; /**< the histogram */
647 GLboolean Sink
; /**< terminate image transfer? */
648 GLubyte RedSize
; /**< Bits per counter */
652 GLubyte LuminanceSize
;
656 struct gl_minmax_attrib
{
659 GLfloat Min
[4], Max
[4]; /**< RGBA */
663 struct gl_convolution_attrib
{
665 GLenum InternalFormat
;
668 GLfloat Filter
[MAX_CONVOLUTION_WIDTH
* MAX_CONVOLUTION_HEIGHT
* 4];
672 #define LIGHT_SPOT 0x1
673 #define LIGHT_LOCAL_VIEWER 0x2
674 #define LIGHT_POSITIONAL 0x4
675 #define LIGHT_NEED_VERTICES (LIGHT_POSITIONAL|LIGHT_LOCAL_VIEWER)
678 * Lighting attributes.
680 struct gl_light_attrib
{
681 struct gl_light Light
[MAX_LIGHTS
]; /**< Array of lights */
682 struct gl_lightmodel Model
; /**< Lighting model */
685 * Must flush FLUSH_VERTICES before referencing:
688 struct gl_material Material
; /**< Includes front & back values */
691 GLboolean Enabled
; /**< Lighting enabled flag */
692 GLenum ShadeModel
; /**< GL_FLAT or GL_SMOOTH */
693 GLenum ColorMaterialFace
; /**< GL_FRONT, BACK or FRONT_AND_BACK */
694 GLenum ColorMaterialMode
; /**< GL_AMBIENT, GL_DIFFUSE, etc */
695 GLuint ColorMaterialBitmask
; /**< bitmask formed from Face and Mode */
696 GLboolean ColorMaterialEnabled
;
698 struct gl_light EnabledList
; /**< List sentinel */
701 * Derived for optimizations:
704 GLboolean _NeedEyeCoords
;
705 GLboolean _NeedVertices
; /**< Use fast shader? */
706 GLuint _Flags
; /**< LIGHT_* flags, see above */
707 GLfloat _BaseColor
[2][3];
715 struct gl_line_attrib
{
716 GLboolean SmoothFlag
; /**< GL_LINE_SMOOTH enabled? */
717 GLboolean StippleFlag
; /**< GL_LINE_STIPPLE enabled? */
718 GLushort StipplePattern
; /**< Stipple pattern */
719 GLint StippleFactor
; /**< Stipple repeat factor */
720 GLfloat Width
; /**< Line width */
721 GLfloat _Width
; /**< Clamped Line width */
725 struct gl_list_attrib
{
730 struct gl_list_opcode
{
732 void (*execute
)( GLcontext
*ctx
, void *data
);
733 void (*destroy
)( GLcontext
*ctx
, void *data
);
734 void (*print
)( GLcontext
*ctx
, void *data
);
737 #define GL_MAX_EXT_OPCODES 16
739 struct gl_list_extensions
{
740 struct gl_list_opcode opcode
[GL_MAX_EXT_OPCODES
];
745 struct gl_multisample_attrib
{
747 GLboolean SampleAlphaToCoverage
;
748 GLboolean SampleAlphaToOne
;
749 GLboolean SampleCoverage
;
750 GLfloat SampleCoverageValue
;
751 GLboolean SampleCoverageInvert
;
758 struct gl_pixel_attrib
{
759 GLenum ReadBuffer
; /**< source buffer for glReadPixels()/glCopyPixels() */
760 GLubyte _ReadSrcMask
; /**< Not really a mask, but like _DrawDestMask
762 * May be: FRONT_LEFT_BIT, BACK_LEFT_BIT,
763 * FRONT_RIGHT_BIT or BACK_RIGHT_BIT. */
764 GLfloat RedBias
, RedScale
;
765 GLfloat GreenBias
, GreenScale
;
766 GLfloat BlueBias
, BlueScale
;
767 GLfloat AlphaBias
, AlphaScale
;
768 GLfloat DepthBias
, DepthScale
;
769 GLint IndexShift
, IndexOffset
;
770 GLboolean MapColorFlag
;
771 GLboolean MapStencilFlag
;
772 GLfloat ZoomX
, ZoomY
;
773 /* XXX move these out of gl_pixel_attrib */
774 GLint MapStoSsize
; /**< Size of each pixel map */
784 GLint MapStoS
[MAX_PIXEL_MAP_TABLE
]; /**< Pixel map tables */
785 GLint MapItoI
[MAX_PIXEL_MAP_TABLE
];
786 GLfloat MapItoR
[MAX_PIXEL_MAP_TABLE
];
787 GLfloat MapItoG
[MAX_PIXEL_MAP_TABLE
];
788 GLfloat MapItoB
[MAX_PIXEL_MAP_TABLE
];
789 GLfloat MapItoA
[MAX_PIXEL_MAP_TABLE
];
790 GLubyte MapItoR8
[MAX_PIXEL_MAP_TABLE
]; /**< converted to 8-bit color */
791 GLubyte MapItoG8
[MAX_PIXEL_MAP_TABLE
];
792 GLubyte MapItoB8
[MAX_PIXEL_MAP_TABLE
];
793 GLubyte MapItoA8
[MAX_PIXEL_MAP_TABLE
];
794 GLfloat MapRtoR
[MAX_PIXEL_MAP_TABLE
];
795 GLfloat MapGtoG
[MAX_PIXEL_MAP_TABLE
];
796 GLfloat MapBtoB
[MAX_PIXEL_MAP_TABLE
];
797 GLfloat MapAtoA
[MAX_PIXEL_MAP_TABLE
];
798 /** GL_EXT_histogram */
799 GLboolean HistogramEnabled
;
800 GLboolean MinMaxEnabled
;
801 /** GL_SGIS_pixel_texture */
802 GLboolean PixelTextureEnabled
;
803 GLenum FragmentRgbSource
;
804 GLenum FragmentAlphaSource
;
805 /** GL_SGI_color_matrix */
806 GLfloat PostColorMatrixScale
[4]; /**< RGBA */
807 GLfloat PostColorMatrixBias
[4]; /**< RGBA */
808 /** GL_SGI_color_table */
809 GLfloat ColorTableScale
[4];
810 GLfloat ColorTableBias
[4];
811 GLboolean ColorTableEnabled
;
812 GLfloat PCCTscale
[4];
814 GLboolean PostConvolutionColorTableEnabled
;
815 GLfloat PCMCTscale
[4];
816 GLfloat PCMCTbias
[4];
817 GLboolean PostColorMatrixColorTableEnabled
;
818 /** GL_SGI_texture_color_table */
819 GLfloat TextureColorTableScale
[4];
820 GLfloat TextureColorTableBias
[4];
822 GLboolean Convolution1DEnabled
;
823 GLboolean Convolution2DEnabled
;
824 GLboolean Separable2DEnabled
;
825 GLfloat ConvolutionBorderColor
[3][4];
826 GLenum ConvolutionBorderMode
[3];
827 GLfloat ConvolutionFilterScale
[3][4];
828 GLfloat ConvolutionFilterBias
[3][4];
829 GLfloat PostConvolutionScale
[4]; /**< RGBA */
830 GLfloat PostConvolutionBias
[4]; /**< RGBA */
837 struct gl_point_attrib
{
838 GLboolean SmoothFlag
; /**< True if GL_POINT_SMOOTH is enabled */
839 GLfloat Size
; /**< User-specified point size */
840 GLfloat _Size
; /**< Size clamped to Const.Min/MaxPointSize */
841 GLfloat Params
[3]; /**< GL_EXT_point_parameters */
842 GLfloat MinSize
, MaxSize
; /**< GL_EXT_point_parameters */
843 GLfloat Threshold
; /**< GL_EXT_point_parameters */
844 GLboolean _Attenuated
; /**< True if Params != [1, 0, 0] */
845 GLboolean PointSprite
; /**< GL_NV_point_sprite / GL_NV_point_sprite */
846 GLboolean CoordReplace
[MAX_TEXTURE_UNITS
]; /**< GL_NV_point_sprite / GL_NV_point_sprite */
847 GLenum SpriteRMode
; /**< GL_NV_point_sprite (only!) */
852 * Polygon attributes.
854 struct gl_polygon_attrib
{
855 GLenum FrontFace
; /**< Either GL_CW or GL_CCW */
856 GLenum FrontMode
; /**< Either GL_POINT, GL_LINE or GL_FILL */
857 GLenum BackMode
; /**< Either GL_POINT, GL_LINE or GL_FILL */
858 GLboolean _FrontBit
; /**< 0=GL_CCW, 1=GL_CW */
859 GLboolean CullFlag
; /**< Culling on/off flag */
860 GLboolean SmoothFlag
; /**< True if GL_POLYGON_SMOOTH is enabled */
861 GLboolean StippleFlag
; /**< True if GL_POLYGON_STIPPLE is enabled */
862 GLenum CullFaceMode
; /**< Culling mode GL_FRONT or GL_BACK */
863 GLfloat OffsetFactor
; /**< Polygon offset factor, from user */
864 GLfloat OffsetUnits
; /**< Polygon offset units, from user */
865 GLboolean OffsetPoint
; /**< Offset in GL_POINT mode */
866 GLboolean OffsetLine
; /**< Offset in GL_LINE mode */
867 GLboolean OffsetFill
; /**< Offset in GL_FILL mode */
872 * Scissor attributes.
874 struct gl_scissor_attrib
{
875 GLboolean Enabled
; /**< Scissor test enabled? */
876 GLint X
, Y
; /**< Lower left corner of box */
877 GLsizei Width
, Height
; /**< Size of box */
882 * Stencil attributes.
884 struct gl_stencil_attrib
{
885 GLboolean Enabled
; /**< Enabled flag */
886 GLboolean TestTwoSide
; /**< GL_EXT_stencil_two_side */
887 GLubyte ActiveFace
; /**< GL_EXT_stencil_two_side (0 or 1) */
888 GLenum Function
[2]; /**< Stencil function */
889 GLenum FailFunc
[2]; /**< Fail function */
890 GLenum ZPassFunc
[2]; /**< Depth buffer pass function */
891 GLenum ZFailFunc
[2]; /**< Depth buffer fail function */
892 GLstencil Ref
[2]; /**< Reference value */
893 GLstencil ValueMask
[2]; /**< Value mask */
894 GLstencil WriteMask
[2]; /**< Write mask */
895 GLstencil Clear
; /**< Clear value */
899 #define NUM_TEXTURE_TARGETS 5 /* 1D, 2D, 3D, CUBE and RECT */
901 #define TEXTURE_1D_INDEX 0
902 #define TEXTURE_2D_INDEX 1
903 #define TEXTURE_3D_INDEX 2
904 #define TEXTURE_CUBE_INDEX 3
905 #define TEXTURE_RECT_INDEX 4
907 /* Texture.Unit[]._ReallyEnabled flags: */
908 #define TEXTURE_1D_BIT (1 << TEXTURE_1D_INDEX)
909 #define TEXTURE_2D_BIT (1 << TEXTURE_2D_INDEX)
910 #define TEXTURE_3D_BIT (1 << TEXTURE_3D_INDEX)
911 #define TEXTURE_CUBE_BIT (1 << TEXTURE_CUBE_INDEX)
912 #define TEXTURE_RECT_BIT (1 << TEXTURE_RECT_INDEX)
915 /* TexGenEnabled flags */
921 /* Bitmap versions of the GL_ constants. */
922 #define TEXGEN_SPHERE_MAP 0x1
923 #define TEXGEN_OBJ_LINEAR 0x2
924 #define TEXGEN_EYE_LINEAR 0x4
925 #define TEXGEN_REFLECTION_MAP_NV 0x8
926 #define TEXGEN_NORMAL_MAP_NV 0x10
928 #define TEXGEN_NEED_NORMALS (TEXGEN_SPHERE_MAP | \
929 TEXGEN_REFLECTION_MAP_NV | \
930 TEXGEN_NORMAL_MAP_NV)
931 #define TEXGEN_NEED_EYE_COORD (TEXGEN_SPHERE_MAP | \
932 TEXGEN_REFLECTION_MAP_NV | \
933 TEXGEN_NORMAL_MAP_NV | \
936 /* A selection of state flags to make driver and module's lives easier. */
937 #define ENABLE_TEXGEN0 0x1
938 #define ENABLE_TEXGEN1 0x2
939 #define ENABLE_TEXGEN2 0x4
940 #define ENABLE_TEXGEN3 0x8
941 #define ENABLE_TEXGEN4 0x10
942 #define ENABLE_TEXGEN5 0x20
943 #define ENABLE_TEXGEN6 0x40
944 #define ENABLE_TEXGEN7 0x80
946 #define ENABLE_TEXMAT0 0x1 /* Ie. not the identity matrix */
947 #define ENABLE_TEXMAT1 0x2
948 #define ENABLE_TEXMAT2 0x4
949 #define ENABLE_TEXMAT3 0x8
950 #define ENABLE_TEXMAT4 0x10
951 #define ENABLE_TEXMAT5 0x20
952 #define ENABLE_TEXMAT6 0x40
953 #define ENABLE_TEXMAT7 0x80
955 #define ENABLE_TEXGEN(i) (ENABLE_TEXGEN0 << (i))
956 #define ENABLE_TEXMAT(i) (ENABLE_TEXMAT0 << (i))
960 * Texel fetch function prototype. We use texel fetch functions to
961 * extract RGBA, color indexes and depth components out of 1D, 2D and 3D
962 * texture images. These functions help to isolate us from the gritty
963 * details of all the various texture image encodings.
965 * \param texImage texture image.
966 * \param col texel column.
967 * \param row texel row.
968 * \param img texel image level/layer.
969 * \param texelOut output texel (up to 4 GLchans)
971 typedef void (*FetchTexelFuncC
)( const struct gl_texture_image
*texImage
,
972 GLint col
, GLint row
, GLint img
,
976 * As above, but returns floats.
977 * Used for depth component images and for upcoming signed/float
980 typedef void (*FetchTexelFuncF
)( const struct gl_texture_image
*texImage
,
981 GLint col
, GLint row
, GLint img
,
985 * Texture format record
987 struct gl_texture_format
{
988 GLint MesaFormat
; /**< One of the MESA_FORMAT_* values */
990 GLenum BaseFormat
; /**< Either GL_ALPHA, GL_INTENSITY, GL_LUMINANCE,
991 * GL_LUMINANCE_ALPHA, GL_RGB, GL_RGBA,
992 * GL_COLOR_INDEX or GL_DEPTH_COMPONENT.
994 GLubyte RedBits
; /**< Bits per texel component */
995 GLubyte GreenBits
; /**< These are just rough approximations for */
996 GLubyte BlueBits
; /**< compressed texture formats. */
998 GLubyte LuminanceBits
;
999 GLubyte IntensityBits
;
1003 GLint TexelBytes
; /**< Bytes per texel (0 for compressed formats */
1006 * \name Texel fetch function pointers
1009 FetchTexelFuncC FetchTexel1D
;
1010 FetchTexelFuncC FetchTexel2D
;
1011 FetchTexelFuncC FetchTexel3D
;
1012 FetchTexelFuncF FetchTexel1Df
;
1013 FetchTexelFuncF FetchTexel2Df
;
1014 FetchTexelFuncF FetchTexel3Df
;
1020 * Texture image record
1022 struct gl_texture_image
{
1023 GLenum Format
; /**< GL_ALPHA, GL_LUMINANCE, GL_LUMINANCE_ALPHA,
1024 * GL_INTENSITY, GL_RGB, GL_RGBA,
1025 * GL_COLOR_INDEX or GL_DEPTH_COMPONENT only.
1026 * Used for choosing TexEnv arithmetic.
1028 GLint IntFormat
; /**< Internal format as given by the user */
1029 GLuint Border
; /**< 0 or 1 */
1030 GLuint Width
; /**< = 2^WidthLog2 + 2*Border */
1031 GLuint Height
; /**< = 2^HeightLog2 + 2*Border */
1032 GLuint Depth
; /**< = 2^DepthLog2 + 2*Border */
1033 GLuint RowStride
; /**< == Width unless IsClientData and padded */
1034 GLuint Width2
; /**< = Width - 2*Border */
1035 GLuint Height2
; /**< = Height - 2*Border */
1036 GLuint Depth2
; /**< = Depth - 2*Border */
1037 GLuint WidthLog2
; /**< = log2(Width2) */
1038 GLuint HeightLog2
; /**< = log2(Height2) */
1039 GLuint DepthLog2
; /**< = log2(Depth2) */
1040 GLuint MaxLog2
; /**< = MAX(WidthLog2, HeightLog2) */
1041 GLfloat WidthScale
; /**< used for mipmap LOD computation */
1042 GLfloat HeightScale
; /**< used for mipmap LOD computation */
1043 GLfloat DepthScale
; /**< used for mipmap LOD computation */
1044 GLvoid
*Data
; /**< Image data, accessed via FetchTexel() */
1045 GLboolean IsClientData
; /**< Data owned by client? */
1046 GLboolean _IsPowerOfTwo
; /**< Are all dimensions powers of two? */
1048 const struct gl_texture_format
*TexFormat
;
1050 FetchTexelFuncC FetchTexelc
; /**< GLchan texel fetch function pointer */
1051 FetchTexelFuncF FetchTexelf
; /**< Float texel fetch function pointer */
1053 GLboolean IsCompressed
; /**< GL_ARB_texture_compression */
1054 GLuint CompressedSize
; /**< GL_ARB_texture_compression */
1057 * \name For device driver:
1060 void *DriverData
; /**< Arbitrary device driver data */
1066 * Texture object record
1068 struct gl_texture_object
{
1069 _glthread_Mutex Mutex
; /**< for thread safety */
1070 GLint RefCount
; /**< reference count */
1071 GLuint Name
; /**< an unsigned integer */
1072 GLenum Target
; /**< GL_TEXTURE_1D, GL_TEXTURE_2D, etc. */
1073 GLfloat Priority
; /**< in [0,1] */
1074 GLfloat BorderColor
[4]; /**< unclamped */
1075 GLchan _BorderChan
[4]; /**< clamped, as GLchan */
1076 /** \name Wrap modes
1077 * Are GL_CLAMP, REPEAT, GL_CLAMP_TO_EDGE, and GL_CLAMP_TO_BORDER_ARB. */
1083 GLenum MinFilter
; /**< minification filter */
1084 GLenum MagFilter
; /**< magnification filter */
1085 GLfloat MinLod
; /**< min lambda, OpenGL 1.2 */
1086 GLfloat MaxLod
; /**< max lambda, OpenGL 1.2 */
1087 GLfloat LodBias
; /**< OpenGL 1.4 */
1088 GLint BaseLevel
; /**< min mipmap level, OpenGL 1.2 */
1089 GLint MaxLevel
; /**< max mipmap level, OpenGL 1.2 */
1090 GLfloat MaxAnisotropy
; /**< GL_EXT_texture_filter_anisotropic */
1091 GLboolean CompareFlag
; /**< GL_SGIX_shadow */
1092 GLenum CompareOperator
; /**< GL_SGIX_shadow */
1093 GLfloat ShadowAmbient
;
1094 GLenum CompareMode
; /**< GL_ARB_shadow */
1095 GLenum CompareFunc
; /**< GL_ARB_shadow */
1096 GLenum DepthMode
; /**< GL_ARB_depth_texture */
1097 GLint _MaxLevel
; /**< actual max mipmap level (q in the spec) */
1098 GLfloat _MaxLambda
; /**< = _MaxLevel - BaseLevel (q - b in spec) */
1099 GLboolean GenerateMipmap
; /**< GL_SGIS_generate_mipmap */
1100 GLboolean _IsPowerOfTwo
; /**< Are all image dimensions powers of two? */
1102 struct gl_texture_image
*Image
[MAX_TEXTURE_LEVELS
];
1105 * \name Texture cube faces
1107 * Image[] is alias for *PosX[MAX_TEXTURE_LEVELS];
1110 struct gl_texture_image
*NegX
[MAX_TEXTURE_LEVELS
];
1111 struct gl_texture_image
*PosY
[MAX_TEXTURE_LEVELS
];
1112 struct gl_texture_image
*NegY
[MAX_TEXTURE_LEVELS
];
1113 struct gl_texture_image
*PosZ
[MAX_TEXTURE_LEVELS
];
1114 struct gl_texture_image
*NegZ
[MAX_TEXTURE_LEVELS
];
1117 /** GL_EXT_paletted_texture */
1118 struct gl_color_table Palette
;
1120 GLboolean Complete
; /**< Is texture object complete? */
1121 struct gl_texture_object
*Next
; /**< Next in linked list */
1124 * \name For device driver
1127 void *DriverData
; /**< Arbitrary device driver data */
1133 * Texture unit record
1135 struct gl_texture_unit
{
1136 GLuint Enabled
; /**< bitmask of TEXTURE_*_BIT flags */
1137 GLuint _ReallyEnabled
; /**< 0 or exactly one of TEXTURE_*_BIT flags */
1139 GLenum EnvMode
; /**< GL_MODULATE, GL_DECAL, GL_BLEND, etc. */
1140 GLfloat EnvColor
[4];
1141 GLuint TexGenEnabled
; /**< Bitwise-OR of [STRQ]_BIT values */
1142 /** \name Tex coord generation mode
1143 * Either GL_OBJECT_LINEAR, GL_EYE_LINEAR or GL_SPHERE_MAP. */
1154 GLuint _GenFlags
; /**< bitwise or of GenBit[STRQ] */
1155 GLfloat ObjectPlaneS
[4];
1156 GLfloat ObjectPlaneT
[4];
1157 GLfloat ObjectPlaneR
[4];
1158 GLfloat ObjectPlaneQ
[4];
1159 GLfloat EyePlaneS
[4];
1160 GLfloat EyePlaneT
[4];
1161 GLfloat EyePlaneR
[4];
1162 GLfloat EyePlaneQ
[4];
1163 GLfloat LodBias
; /**< for biasing mipmap levels */
1166 * \name GL_EXT_texture_env_combine
1169 GLenum CombineModeRGB
; /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */
1170 GLenum CombineModeA
; /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */
1171 GLenum CombineSourceRGB
[3]; /**< GL_PRIMARY_COLOR, GL_TEXTURE, etc. */
1172 GLenum CombineSourceA
[3]; /**< GL_PRIMARY_COLOR, GL_TEXTURE, etc. */
1173 GLenum CombineOperandRGB
[3]; /**< SRC_COLOR, ONE_MINUS_SRC_COLOR, etc */
1174 GLenum CombineOperandA
[3]; /**< SRC_ALPHA, ONE_MINUS_SRC_ALPHA, etc */
1175 GLuint CombineScaleShiftRGB
; /**< 0, 1 or 2 */
1176 GLuint CombineScaleShiftA
; /**< 0, 1 or 2 */
1179 struct gl_texture_object
*Current1D
;
1180 struct gl_texture_object
*Current2D
;
1181 struct gl_texture_object
*Current3D
;
1182 struct gl_texture_object
*CurrentCubeMap
; /**< GL_ARB_texture_cube_map */
1183 struct gl_texture_object
*CurrentRect
; /**< GL_NV_texture_rectangle */
1185 struct gl_texture_object
*_Current
; /**< Points to really enabled tex obj */
1187 struct gl_texture_object Saved1D
; /**< only used by glPush/PopAttrib */
1188 struct gl_texture_object Saved2D
;
1189 struct gl_texture_object Saved3D
;
1190 struct gl_texture_object SavedCubeMap
;
1191 struct gl_texture_object SavedRect
;
1193 /* GL_SGI_texture_color_table */
1194 struct gl_color_table ColorTable
;
1195 struct gl_color_table ProxyColorTable
;
1196 GLboolean ColorTableEnabled
;
1201 * Texture attributes
1203 struct gl_texture_attrib
{
1208 GLuint CurrentUnit
; /**< Active texture unit */
1209 GLuint _EnabledUnits
; /**< one bit set for each really-enabled unit */
1210 GLuint _EnabledCoordUnits
; /**< one bit per enabled coordinate unit */
1211 GLuint _GenFlags
; /**< for texgen */
1212 GLuint _TexGenEnabled
;
1213 GLuint _TexMatEnabled
;
1216 struct gl_texture_unit Unit
[MAX_TEXTURE_UNITS
];
1218 struct gl_texture_object
*Proxy1D
;
1219 struct gl_texture_object
*Proxy2D
;
1220 struct gl_texture_object
*Proxy3D
;
1221 struct gl_texture_object
*ProxyCubeMap
;
1222 struct gl_texture_object
*ProxyRect
;
1224 /** GL_EXT_shared_texture_palette */
1225 GLboolean SharedPalette
;
1226 struct gl_color_table Palette
;
1231 * Transformation attributes.
1233 struct gl_transform_attrib
{
1234 GLenum MatrixMode
; /**< Matrix mode */
1235 GLfloat EyeUserPlane
[MAX_CLIP_PLANES
][4]; /**< User clip planes */
1236 GLfloat _ClipUserPlane
[MAX_CLIP_PLANES
][4]; /**< derived */
1237 GLuint ClipPlanesEnabled
; /**< on/off bitmask */
1238 GLboolean Normalize
; /**< Normalize all normals? */
1239 GLboolean RescaleNormals
; /**< GL_EXT_rescale_normal */
1240 GLboolean RasterPositionUnclipped
; /**< GL_IBM_rasterpos_clip */
1245 * Viewport attributes.
1247 struct gl_viewport_attrib
{
1248 GLint X
, Y
; /**< position */
1249 GLsizei Width
, Height
; /**< size */
1250 GLfloat Near
, Far
; /**< Depth buffer range */
1251 GLmatrix _WindowMap
; /**< Mapping transformation as a matrix. */
1256 * Node for the attribute stack
1258 struct gl_attrib_node
{
1261 struct gl_attrib_node
*next
;
1266 * GL_ARB_vertex_buffer_object buffer object
1268 struct gl_buffer_object
{
1273 GLvoid
*Pointer
; /**< Only valid while buffer is mapped */
1274 GLuint Size
; /**< Size of data array in bytes */
1275 GLubyte
*Data
; /**< The storage */
1281 * Client pixel packing/unpacking attributes
1283 struct gl_pixelstore_attrib
{
1288 GLint ImageHeight
; /**< for GL_EXT_texture3D */
1289 GLint SkipImages
; /**< for GL_EXT_texture3D */
1290 GLboolean SwapBytes
;
1292 GLboolean ClientStorage
; /**< GL_APPLE_client_storage */
1293 GLboolean Invert
; /**< GL_MESA_pack_invert */
1297 #define CA_CLIENT_DATA 0x1 /**< Data not allocated by mesa */
1301 * Client vertex array attributes
1303 struct gl_client_array
{
1306 GLsizei Stride
; /**< user-specified stride */
1307 GLsizei StrideB
; /**< actual stride in bytes */
1309 GLuint Enabled
; /**< one of the _NEW_ARRAY_ bits */
1310 GLboolean Normalized
; /**< GL_ARB_vertex_program */
1312 /**< GL_ARB_vertex_buffer_object */
1313 struct gl_buffer_object
*BufferObj
;
1323 struct gl_array_attrib
{
1324 struct gl_client_array Vertex
; /**< client data descriptors */
1325 struct gl_client_array Normal
;
1326 struct gl_client_array Color
;
1327 struct gl_client_array SecondaryColor
;
1328 struct gl_client_array FogCoord
;
1329 struct gl_client_array Index
;
1330 struct gl_client_array TexCoord
[MAX_TEXTURE_COORD_UNITS
];
1331 struct gl_client_array EdgeFlag
;
1333 struct gl_client_array VertexAttrib
[VERT_ATTRIB_MAX
]; /**< GL_NV_vertex_program */
1335 GLint ActiveTexture
; /**< Client Active Texture */
1336 GLuint LockFirst
; /**< GL_EXT_compiled_vertex_array */
1337 GLuint LockCount
; /**< GL_EXT_compiled_vertex_array */
1339 GLuint _Enabled
; /**< _NEW_ARRAY_* - bit set if array enabled */
1340 GLuint NewState
; /**< _NEW_ARRAY_* */
1342 #if FEATURE_ARB_vertex_buffer_object
1343 struct gl_buffer_object
*NullBufferObj
;
1344 struct gl_buffer_object
*ArrayBufferObj
;
1345 struct gl_buffer_object
*ElementArrayBufferObj
;
1347 GLuint _MaxElement
; /* Min of all enabled array's maxes */
1351 struct gl_feedback
{
1353 GLuint _Mask
; /* FB_* bits */
1361 * Selection attributes.
1363 struct gl_selection
{
1364 GLuint
*Buffer
; /**< selection buffer */
1365 GLuint BufferSize
; /**< size of the selection buffer */
1366 GLuint BufferCount
; /**< number of values in the selection buffer */
1367 GLuint Hits
; /**< number of records in the selection buffer */
1368 GLuint NameStackDepth
; /**< name stack depth */
1369 GLuint NameStack
[MAX_NAME_STACK_DEPTH
]; /**< name stack */
1370 GLboolean HitFlag
; /**< hit flag */
1371 GLfloat HitMinZ
; /**< minimum hit depth */
1372 GLfloat HitMaxZ
; /**< maximum hit depth */
1377 * 1-D Evaluator control points
1381 GLuint Order
; /**< Number of control points */
1382 GLfloat u1
, u2
, du
; /**< u1, u2, 1.0/(u2-u1) */
1383 GLfloat
*Points
; /**< Points to contiguous control points */
1388 * 2-D Evaluator control points
1392 GLuint Uorder
; /**< Number of control points in U dimension */
1393 GLuint Vorder
; /**< Number of control points in V dimension */
1396 GLfloat
*Points
; /**< Points to contiguous control points */
1401 * All evaluator control points
1403 struct gl_evaluators
1409 struct gl_1d_map Map1Vertex3
;
1410 struct gl_1d_map Map1Vertex4
;
1411 struct gl_1d_map Map1Index
;
1412 struct gl_1d_map Map1Color4
;
1413 struct gl_1d_map Map1Normal
;
1414 struct gl_1d_map Map1Texture1
;
1415 struct gl_1d_map Map1Texture2
;
1416 struct gl_1d_map Map1Texture3
;
1417 struct gl_1d_map Map1Texture4
;
1418 struct gl_1d_map Map1Attrib
[16]; /**< GL_NV_vertex_program */
1425 struct gl_2d_map Map2Vertex3
;
1426 struct gl_2d_map Map2Vertex4
;
1427 struct gl_2d_map Map2Index
;
1428 struct gl_2d_map Map2Color4
;
1429 struct gl_2d_map Map2Normal
;
1430 struct gl_2d_map Map2Texture1
;
1431 struct gl_2d_map Map2Texture2
;
1432 struct gl_2d_map Map2Texture3
;
1433 struct gl_2d_map Map2Texture4
;
1434 struct gl_2d_map Map2Attrib
[16]; /**< GL_NV_vertex_program */
1440 * NV_fragment_program runtime state
1444 GLfloat Temporaries
[MAX_NV_FRAGMENT_PROGRAM_TEMPS
][4];
1445 GLfloat Inputs
[MAX_NV_FRAGMENT_PROGRAM_INPUTS
][4];
1446 GLfloat Outputs
[MAX_NV_FRAGMENT_PROGRAM_OUTPUTS
][4];
1447 GLuint CondCodes
[4];
1452 * Names of the various vertex/fragment register files
1456 PROGRAM_TEMPORARY
= 10,
1459 PROGRAM_LOCAL_PARAM
,
1461 PROGRAM_NAMED_PARAM
,
1468 /* Vertex and fragment instructions */
1469 struct vp_instruction
;
1470 struct fp_instruction
;
1472 struct program_parameter_list
;
1476 * Base class for any kind of program object
1481 GLubyte
*String
; /* Null-terminated program text */
1483 GLenum Format
; /* String encoding format */
1486 GLfloat LocalParams
[MAX_PROGRAM_LOCAL_PARAMS
][4];
1487 GLuint NumInstructions
; /* GL_ARB_vertex/fragment_program */
1488 GLuint NumTemporaries
;
1489 GLuint NumParameters
;
1490 GLuint NumAttributes
;
1491 GLuint NumAddressRegs
;
1495 /** Vertex program object */
1496 struct vertex_program
1498 struct program Base
; /* base class */
1499 struct vp_instruction
*Instructions
; /* Compiled instructions */
1500 GLboolean IsPositionInvariant
; /* GL_NV_vertex_program1_1 */
1501 GLuint InputsRead
; /* Bitmask of which input regs are read */
1502 GLuint OutputsWritten
; /* Bitmask of which output regs are written to */
1503 struct program_parameter_list
*Parameters
; /**< array [NumParameters] */
1507 /** Fragment program object */
1508 struct fragment_program
1510 struct program Base
; /**< base class */
1511 struct fp_instruction
*Instructions
; /**< Compiled instructions */
1512 GLuint InputsRead
; /**< Bitmask of which input regs are read */
1513 GLuint OutputsWritten
; /**< Bitmask of which output regs are written to */
1514 GLuint TexturesUsed
[MAX_TEXTURE_IMAGE_UNITS
]; /**< TEXTURE_x_INDEX bitmask */
1515 GLuint NumAluInstructions
; /**< GL_ARB_fragment_program */
1516 GLuint NumTexInstructions
;
1517 GLuint NumTexIndirections
;
1518 struct program_parameter_list
*Parameters
; /**< array [NumParameters] */
1523 * State common to vertex and fragment programs.
1525 struct program_state
{
1526 GLint ErrorPos
; /* GL_PROGRAM_ERROR_POSITION_NV */
1527 const char *ErrorString
; /* GL_PROGRAM_ERROR_STRING_NV */
1532 * State vars for GL_NV_vertex_program
1534 struct vertex_program_state
1536 GLboolean Enabled
; /**< GL_VERTEX_PROGRAM_NV */
1537 GLboolean PointSizeEnabled
; /**< GL_VERTEX_PROGRAM_POINT_SIZE_NV */
1538 GLboolean TwoSideEnabled
; /**< GL_VERTEX_PROGRAM_TWO_SIDE_NV */
1539 struct vertex_program
*Current
; /**< ptr to currently bound program */
1541 GLenum TrackMatrix
[MAX_NV_VERTEX_PROGRAM_PARAMS
/ 4];
1542 GLenum TrackMatrixTransform
[MAX_NV_VERTEX_PROGRAM_PARAMS
/ 4];
1544 GLfloat Parameters
[MAX_NV_VERTEX_PROGRAM_PARAMS
][4]; /* Env params */
1545 /* Only used during program execution (may be moved someday): */
1546 GLfloat Temporaries
[MAX_NV_VERTEX_PROGRAM_TEMPS
][4];
1547 GLfloat Inputs
[MAX_NV_VERTEX_PROGRAM_INPUTS
][4];
1548 GLfloat Outputs
[MAX_NV_VERTEX_PROGRAM_OUTPUTS
][4];
1549 GLint AddressReg
[4];
1551 #if FEATURE_MESA_program_debug
1552 GLprogramcallbackMESA Callback
;
1553 GLvoid
*CallbackData
;
1554 GLboolean CallbackEnabled
;
1555 GLuint CurrentPosition
;
1561 * State for GL_ARB/NV_fragment_program
1563 struct fragment_program_state
1565 GLboolean Enabled
; /* GL_VERTEX_PROGRAM_NV */
1566 struct fragment_program
*Current
; /* ptr to currently bound program */
1567 struct fp_machine Machine
; /* machine state */
1568 GLfloat Parameters
[MAX_NV_FRAGMENT_PROGRAM_PARAMS
][4]; /* Env params */
1570 #if FEATURE_MESA_program_debug
1571 GLprogramcallbackMESA Callback
;
1572 GLvoid
*CallbackData
;
1573 GLboolean CallbackEnabled
;
1574 GLuint CurrentPosition
;
1580 * State for GL_ARB_occlusion_query
1582 struct occlusion_state
1585 GLuint CurrentQueryObject
;
1586 GLuint PassedCounter
;
1587 struct _mesa_HashTable
*QueryObjects
;
1592 * State which can be shared by multiple contexts:
1594 struct gl_shared_state
1596 _glthread_Mutex Mutex
; /**< for thread safety */
1597 GLint RefCount
; /**< Reference count */
1598 struct _mesa_HashTable
*DisplayList
; /**< Display lists hash table */
1599 struct _mesa_HashTable
*TexObjects
; /**< Texture objects hash table */
1600 struct gl_texture_object
*TexObjectList
;/**< Linked list of texture objects */
1603 * \name Default texture objects (shared by all multi-texture units)
1606 struct gl_texture_object
*Default1D
;
1607 struct gl_texture_object
*Default2D
;
1608 struct gl_texture_object
*Default3D
;
1609 struct gl_texture_object
*DefaultCubeMap
;
1610 struct gl_texture_object
*DefaultRect
;
1614 * \name GL_NV_vertex/_program
1617 struct _mesa_HashTable
*Programs
;
1618 #if FEATURE_ARB_vertex_program
1619 struct program
*DefaultVertexProgram
;
1621 #if FEATURE_ARB_fragment_program
1622 struct program
*DefaultFragmentProgram
;
1626 #if FEATURE_ARB_vertex_buffer_object
1627 struct _mesa_HashTable
*BufferObjects
;
1630 void *DriverData
; /**< Device driver shared state */
1637 * A "frame buffer" is a color buffer and its optional ancillary buffers:
1638 * depth, accum, stencil, and software-simulated alpha buffers.
1639 * In C++ terms, think of this as a base class from which device drivers
1640 * will make derived classes.
1642 struct gl_frame_buffer
1644 GLvisual Visual
; /**< The corresponding visual */
1646 GLuint Width
, Height
; /**< size of frame buffer in pixels */
1648 GLboolean UseSoftwareDepthBuffer
;
1649 GLboolean UseSoftwareAccumBuffer
;
1650 GLboolean UseSoftwareStencilBuffer
;
1651 GLboolean UseSoftwareAlphaBuffers
;
1653 /** \name Software depth (aka Z) buffer */
1655 GLvoid
*DepthBuffer
; /**< array [Width*Height] of GLushort or GLuint*/
1658 /** \name Software stencil buffer */
1660 GLstencil
*Stencil
; /**< array [Width*Height] of GLstencil values */
1663 /** \name Software accumulation buffer */
1665 GLaccum
*Accum
; /**< array [4*Width*Height] of GLaccum values */
1668 /** \name Software alpha planes */
1670 GLchan
*FrontLeftAlpha
; /**< array [Width*Height] of GLchan */
1671 GLchan
*BackLeftAlpha
; /**< array [Width*Height] of GLchan */
1672 GLchan
*FrontRightAlpha
; /**< array [Width*Height] of GLchan */
1673 GLchan
*BackRightAlpha
; /**< array [Width*Height] of GLchan */
1677 * \name Drawing bounds
1679 * Intersection of window size and scissor box
1682 GLint _Xmin
; /**< inclusive */
1683 GLint _Ymin
; /**< inclusive */
1684 GLint _Xmax
; /**< exclusive */
1685 GLint _Ymax
; /**< exclusive */
1691 * Constants which may be overridden by device driver during context creation
1692 * but are never changed after that.
1696 GLint MaxTextureLevels
; /**< Maximum number of allowed mipmap levels. */
1697 GLint Max3DTextureLevels
; /**< Maximum number of allowed mipmap levels for 3D texture targets. */
1698 GLint MaxCubeTextureLevels
; /**< Maximum number of allowed mipmap levels for GL_ARB_texture_cube_map */
1699 GLint MaxTextureRectSize
; /* GL_NV_texture_rectangle */
1700 GLuint MaxTextureCoordUnits
;
1701 GLuint MaxTextureImageUnits
;
1702 GLuint MaxTextureUnits
; /* = MAX(CoordUnits, ImageUnits) */
1703 GLfloat MaxTextureMaxAnisotropy
; /* GL_EXT_texture_filter_anisotropic */
1704 GLfloat MaxTextureLodBias
; /* GL_EXT_texture_lod_bias */
1705 GLuint MaxArrayLockSize
;
1707 GLfloat MinPointSize
, MaxPointSize
; /* aliased */
1708 GLfloat MinPointSizeAA
, MaxPointSizeAA
; /* antialiased */
1709 GLfloat PointSizeGranularity
;
1710 GLfloat MinLineWidth
, MaxLineWidth
; /* aliased */
1711 GLfloat MinLineWidthAA
, MaxLineWidthAA
; /* antialiased */
1712 GLfloat LineWidthGranularity
;
1713 GLuint NumAuxBuffers
;
1714 GLuint MaxColorTableSize
;
1715 GLuint MaxConvolutionWidth
;
1716 GLuint MaxConvolutionHeight
;
1717 GLuint MaxClipPlanes
;
1719 GLfloat MaxShininess
; /* GL_NV_light_max_exponent */
1720 GLfloat MaxSpotExponent
; /* GL_NV_light_max_exponent */
1721 /* GL_ARB_vertex_program */
1722 GLuint MaxVertexProgramInstructions
;
1723 GLuint MaxVertexProgramAttribs
;
1724 GLuint MaxVertexProgramTemps
;
1725 GLuint MaxVertexProgramLocalParams
;
1726 GLuint MaxVertexProgramEnvParams
;
1727 GLuint MaxVertexProgramAddressRegs
;
1728 /* GL_ARB_fragment_program */
1729 GLuint MaxFragmentProgramInstructions
;
1730 GLuint MaxFragmentProgramAttribs
;
1731 GLuint MaxFragmentProgramTemps
;
1732 GLuint MaxFragmentProgramLocalParams
;
1733 GLuint MaxFragmentProgramEnvParams
;
1734 GLuint MaxFragmentProgramAddressRegs
;
1735 GLuint MaxFragmentProgramAluInstructions
;
1736 GLuint MaxFragmentProgramTexInstructions
;
1737 GLuint MaxFragmentProgramTexIndirections
;
1738 /* vertex or fragment program */
1739 GLuint MaxProgramMatrices
;
1740 GLuint MaxProgramMatrixStackDepth
;
1741 /* vertex array / buffer object bounds checking */
1742 GLboolean CheckArrayBounds
;
1747 * List of extensions.
1749 struct gl_extensions
1752 * \name Flags to quickly test if certain extensions are available.
1754 * Not every extension needs to have such a flag, but it's encouraged.
1757 GLboolean dummy
; /* don't remove this! */
1758 GLboolean ARB_depth_texture
;
1759 GLboolean ARB_fragment_program
;
1760 GLboolean ARB_imaging
;
1761 GLboolean ARB_multisample
;
1762 GLboolean ARB_multitexture
;
1763 GLboolean ARB_occlusion_query
;
1764 GLboolean ARB_point_sprite
;
1765 GLboolean ARB_shadow
;
1766 GLboolean ARB_texture_border_clamp
;
1767 GLboolean ARB_texture_compression
;
1768 GLboolean ARB_texture_cube_map
;
1769 GLboolean ARB_texture_env_combine
;
1770 GLboolean ARB_texture_env_crossbar
;
1771 GLboolean ARB_texture_env_dot3
;
1772 GLboolean ARB_texture_mirrored_repeat
;
1773 GLboolean ARB_texture_non_power_of_two
;
1774 GLboolean ARB_vertex_buffer_object
;
1775 GLboolean ARB_vertex_program
;
1776 GLboolean ARB_window_pos
;
1777 GLboolean ATI_texture_mirror_once
;
1778 GLboolean ATI_texture_env_combine3
;
1779 GLboolean EXT_blend_color
;
1780 GLboolean EXT_blend_func_separate
;
1781 GLboolean EXT_blend_logic_op
;
1782 GLboolean EXT_blend_minmax
;
1783 GLboolean EXT_blend_subtract
;
1784 GLboolean EXT_convolution
;
1785 GLboolean EXT_compiled_vertex_array
;
1786 GLboolean EXT_depth_bounds_test
;
1787 GLboolean EXT_fog_coord
;
1788 GLboolean EXT_histogram
;
1789 GLboolean EXT_multi_draw_arrays
;
1790 GLboolean EXT_paletted_texture
;
1791 GLboolean EXT_point_parameters
;
1792 GLboolean EXT_shadow_funcs
;
1793 GLboolean EXT_secondary_color
;
1794 GLboolean EXT_shared_texture_palette
;
1795 GLboolean EXT_stencil_wrap
;
1796 GLboolean EXT_stencil_two_side
;
1797 GLboolean EXT_texture3D
;
1798 GLboolean EXT_texture_compression_s3tc
;
1799 GLboolean EXT_texture_env_add
;
1800 GLboolean EXT_texture_env_combine
;
1801 GLboolean EXT_texture_env_dot3
;
1802 GLboolean EXT_texture_filter_anisotropic
;
1803 GLboolean EXT_texture_lod_bias
;
1804 GLboolean EXT_texture_mirror_clamp
;
1805 GLboolean EXT_vertex_array_set
;
1806 GLboolean HP_occlusion_test
;
1807 GLboolean IBM_rasterpos_clip
;
1808 GLboolean IBM_multimode_draw_arrays
;
1809 GLboolean MESA_pack_invert
;
1810 GLboolean MESA_packed_depth_stencil
;
1811 GLboolean MESA_program_debug
;
1812 GLboolean MESA_resize_buffers
;
1813 GLboolean MESA_ycbcr_texture
;
1814 GLboolean NV_blend_square
;
1815 GLboolean NV_fragment_program
;
1816 GLboolean NV_point_sprite
;
1817 GLboolean NV_texture_rectangle
;
1818 GLboolean NV_vertex_program
;
1819 GLboolean NV_vertex_program1_1
;
1820 GLboolean SGI_color_matrix
;
1821 GLboolean SGI_color_table
;
1822 GLboolean SGI_texture_color_table
;
1823 GLboolean SGIS_generate_mipmap
;
1824 GLboolean SGIS_pixel_texture
;
1825 GLboolean SGIS_texture_edge_clamp
;
1826 GLboolean SGIX_depth_texture
;
1827 GLboolean SGIX_pixel_texture
;
1828 GLboolean SGIX_shadow
;
1829 GLboolean SGIX_shadow_ambient
; /* or GL_ARB_shadow_ambient */
1830 GLboolean TDFX_texture_compression_FXT1
;
1831 GLboolean APPLE_client_storage
;
1834 /* The extension string */
1835 const GLubyte
*String
;
1840 * A stack of matrices (projection, modelview, color, texture, etc).
1844 GLmatrix
*Top
; /**< points into Stack */
1845 GLmatrix
*Stack
; /**< array [MaxDepth] of GLmatrix */
1846 GLuint Depth
; /**< 0 <= Depth < MaxDepth */
1847 GLuint MaxDepth
; /**< size of Stack[] array */
1848 GLuint DirtyFlag
; /**< _NEW_MODELVIEW or _NEW_PROJECTION, for example */
1853 * \name Bits for image transfer operations
1855 * \sa __GLcontextRec::ImageTransferState.
1858 #define IMAGE_SCALE_BIAS_BIT 0x1
1859 #define IMAGE_SHIFT_OFFSET_BIT 0x2
1860 #define IMAGE_MAP_COLOR_BIT 0x4
1861 #define IMAGE_COLOR_TABLE_BIT 0x8
1862 #define IMAGE_CONVOLUTION_BIT 0x10
1863 #define IMAGE_POST_CONVOLUTION_SCALE_BIAS 0x20
1864 #define IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT 0x40
1865 #define IMAGE_COLOR_MATRIX_BIT 0x80
1866 #define IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT 0x100
1867 #define IMAGE_HISTOGRAM_BIT 0x200
1868 #define IMAGE_MIN_MAX_BIT 0x400
1870 /** Transfer ops up to convolution */
1871 #define IMAGE_PRE_CONVOLUTION_BITS (IMAGE_SCALE_BIAS_BIT | \
1872 IMAGE_SHIFT_OFFSET_BIT | \
1873 IMAGE_MAP_COLOR_BIT | \
1874 IMAGE_COLOR_TABLE_BIT)
1876 /** Transfer ops after convolution */
1877 #define IMAGE_POST_CONVOLUTION_BITS (IMAGE_POST_CONVOLUTION_SCALE_BIAS | \
1878 IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT | \
1879 IMAGE_COLOR_MATRIX_BIT | \
1880 IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT |\
1881 IMAGE_HISTOGRAM_BIT | \
1887 * \name Bits to indicate what state has changed.
1892 #define _NEW_MODELVIEW 0x1 /**< __GLcontextRec::ModelView */
1893 #define _NEW_PROJECTION 0x2 /**< __GLcontextRec::Projection */
1894 #define _NEW_TEXTURE_MATRIX 0x4 /**< __GLcontextRec::TextureMatrix */
1895 #define _NEW_COLOR_MATRIX 0x8 /**< __GLcontextRec::ColorMatrix */
1896 #define _NEW_ACCUM 0x10 /**< __GLcontextRec::Accum */
1897 #define _NEW_COLOR 0x20 /**< __GLcontextRec::Color */
1898 #define _NEW_DEPTH 0x40 /**< __GLcontextRec::Depth */
1899 #define _NEW_EVAL 0x80 /**< __GLcontextRec::Eval, __GLcontextRec::EvalMap */
1900 #define _NEW_FOG 0x100 /**< __GLcontextRec::Fog */
1901 #define _NEW_HINT 0x200 /**< __GLcontextRec::Hint */
1902 #define _NEW_LIGHT 0x400 /**< __GLcontextRec::Light */
1903 #define _NEW_LINE 0x800 /**< __GLcontextRec::Line */
1904 #define _NEW_PIXEL 0x1000 /**< __GLcontextRec::Pixel */
1905 #define _NEW_POINT 0x2000 /**< __GLcontextRec::Point */
1906 #define _NEW_POLYGON 0x4000 /**< __GLcontextRec::Polygon */
1907 #define _NEW_POLYGONSTIPPLE 0x8000 /**< __GLcontextRec::PolygonStipple */
1908 #define _NEW_SCISSOR 0x10000 /**< __GLcontextRec::Scissor */
1909 #define _NEW_STENCIL 0x20000 /**< __GLcontextRec::Stencil */
1910 #define _NEW_TEXTURE 0x40000 /**< __GLcontextRec::Texture */
1911 #define _NEW_TRANSFORM 0x80000 /**< __GLcontextRec::Transform */
1912 #define _NEW_VIEWPORT 0x100000 /**< __GLcontextRec::Viewport */
1913 #define _NEW_PACKUNPACK 0x200000 /**< __GLcontextRec::Pack, __GLcontextRec::Unpack */
1914 #define _NEW_ARRAY 0x400000 /**< __GLcontextRec::Array */
1915 #define _NEW_RENDERMODE 0x800000 /**< __GLcontextRec::RenderMode, __GLcontextRec::Feedback, __GLcontextRec::Select */
1916 #define _NEW_BUFFERS 0x1000000 /**< __GLcontextRec::Visual, __GLcontextRec::DrawBuffer, */
1917 #define _NEW_MULTISAMPLE 0x2000000 /**< __GLcontextRec::Multisample */
1918 #define _NEW_TRACK_MATRIX 0x4000000 /**< __GLcontextRec::VertexProgram */
1919 #define _NEW_PROGRAM 0x8000000 /**< __GLcontextRec::VertexProgram */
1925 * \name Bits to track array state changes
1927 * Also used to summarize array enabled.
1930 #define _NEW_ARRAY_VERTEX VERT_BIT_POS
1931 #define _NEW_ARRAY_WEIGHT VERT_BIT_WEIGHT
1932 #define _NEW_ARRAY_NORMAL VERT_BIT_NORMAL
1933 #define _NEW_ARRAY_COLOR0 VERT_BIT_COLOR0
1934 #define _NEW_ARRAY_COLOR1 VERT_BIT_COLOR1
1935 #define _NEW_ARRAY_FOGCOORD VERT_BIT_FOG
1936 #define _NEW_ARRAY_INDEX VERT_BIT_SIX
1937 #define _NEW_ARRAY_EDGEFLAG VERT_BIT_SEVEN
1938 #define _NEW_ARRAY_TEXCOORD_0 VERT_BIT_TEX0
1939 #define _NEW_ARRAY_TEXCOORD_1 VERT_BIT_TEX1
1940 #define _NEW_ARRAY_TEXCOORD_2 VERT_BIT_TEX2
1941 #define _NEW_ARRAY_TEXCOORD_3 VERT_BIT_TEX3
1942 #define _NEW_ARRAY_TEXCOORD_4 VERT_BIT_TEX4
1943 #define _NEW_ARRAY_TEXCOORD_5 VERT_BIT_TEX5
1944 #define _NEW_ARRAY_TEXCOORD_6 VERT_BIT_TEX6
1945 #define _NEW_ARRAY_TEXCOORD_7 VERT_BIT_TEX7
1946 #define _NEW_ARRAY_ATTRIB_0 0x10000 /* start at bit 16 */
1947 #define _NEW_ARRAY_ALL 0xffffffff
1950 #define _NEW_ARRAY_TEXCOORD(i) (_NEW_ARRAY_TEXCOORD_0 << (i))
1951 #define _NEW_ARRAY_ATTRIB(i) (_NEW_ARRAY_ATTRIB_0 << (i))
1956 * \name A bunch of flags that we think might be useful to drivers.
1958 * Set in the __GLcontextRec::_TriangleCaps bitfield.
1961 #define DD_FLATSHADE 0x1
1962 #define DD_SEPARATE_SPECULAR 0x2
1963 #define DD_TRI_CULL_FRONT_BACK 0x4 /* special case on some hw */
1964 #define DD_TRI_LIGHT_TWOSIDE 0x8
1965 #define DD_TRI_UNFILLED 0x10
1966 #define DD_TRI_SMOOTH 0x20
1967 #define DD_TRI_STIPPLE 0x40
1968 #define DD_TRI_OFFSET 0x80
1969 #define DD_LINE_SMOOTH 0x100
1970 #define DD_LINE_STIPPLE 0x200
1971 #define DD_LINE_WIDTH 0x400
1972 #define DD_POINT_SMOOTH 0x800
1973 #define DD_POINT_SIZE 0x1000
1974 #define DD_POINT_ATTEN 0x2000
1979 * \name Define the state changes under which each of these bits might change
1982 #define _DD_NEW_FLATSHADE _NEW_LIGHT
1983 #define _DD_NEW_SEPARATE_SPECULAR (_NEW_LIGHT | _NEW_FOG | _NEW_PROGRAM)
1984 #define _DD_NEW_TRI_CULL_FRONT_BACK _NEW_POLYGON
1985 #define _DD_NEW_TRI_LIGHT_TWOSIDE _NEW_LIGHT
1986 #define _DD_NEW_TRI_UNFILLED _NEW_POLYGON
1987 #define _DD_NEW_TRI_SMOOTH _NEW_POLYGON
1988 #define _DD_NEW_TRI_STIPPLE _NEW_POLYGON
1989 #define _DD_NEW_TRI_OFFSET _NEW_POLYGON
1990 #define _DD_NEW_LINE_SMOOTH _NEW_LINE
1991 #define _DD_NEW_LINE_STIPPLE _NEW_LINE
1992 #define _DD_NEW_LINE_WIDTH _NEW_LINE
1993 #define _DD_NEW_POINT_SMOOTH _NEW_POINT
1994 #define _DD_NEW_POINT_SIZE _NEW_POINT
1995 #define _DD_NEW_POINT_ATTEN _NEW_POINT
1999 #define _MESA_NEW_NEED_EYE_COORDS (_NEW_LIGHT | \
2004 #define _MESA_NEW_NEED_NORMALS (_NEW_LIGHT | \
2007 #define _IMAGE_NEW_TRANSFER_STATE (_NEW_PIXEL | _NEW_COLOR_MATRIX)
2013 * Forward declaration of display list data types:
2016 typedef union node Node
;
2019 /* This has to be included here. */
2023 #define NUM_VERTEX_FORMAT_ENTRIES (sizeof(GLvertexformat) / sizeof(void *))
2026 * Core Mesa's support for tnl modules:
2028 struct gl_tnl_module
{
2030 * Vertex format to be lazily swapped into current dispatch.
2032 GLvertexformat
*Current
;
2035 * \name Record of functions swapped out.
2036 * On restore, only need to swap these functions back in.
2039 void *Swapped
[NUM_VERTEX_FORMAT_ENTRIES
][2];
2044 struct mesa_list_state
{
2045 GLuint CallDepth
; /**< Current recursion calling depth */
2046 Node
*CurrentListPtr
; /**< Head of list being compiled */
2047 GLuint CurrentListNum
; /**< Number of the list being compiled */
2048 Node
*CurrentBlock
; /**< Pointer to current block of nodes */
2049 GLuint CurrentPos
; /**< Index into current block of nodes */
2050 GLvertexformat ListVtxfmt
;
2052 GLubyte ActiveAttribSize
[VERT_ATTRIB_MAX
];
2053 GLfloat CurrentAttrib
[VERT_ATTRIB_MAX
][4];
2055 GLubyte ActiveMaterialSize
[MAT_ATTRIB_MAX
];
2056 GLfloat CurrentMaterial
[MAT_ATTRIB_MAX
][4];
2058 GLubyte ActiveIndex
;
2059 GLfloat CurrentIndex
;
2061 GLubyte ActiveEdgeFlag
;
2062 GLboolean CurrentEdgeFlag
;
2069 * This is the central context data structure for Mesa. Almost all
2070 * OpenGL state is contained in this structure.
2071 * Think of this as a base class from which device drivers will derive
2074 struct __GLcontextRec
{
2076 * \name OS related interfaces.
2078 * These \b must be the first members of this structure, because they are
2079 * exposed to the outside world (i.e. GLX extension).
2082 __GLimports imports
;
2083 __GLexports exports
;
2086 /** State possibly shared with other contexts in the address space */
2087 struct gl_shared_state
*Shared
;
2089 /** \name API function pointer tables */
2091 struct _glapi_table
*Save
; /**< Display list save functions */
2092 struct _glapi_table
*Exec
; /**< Execute functions */
2093 struct _glapi_table
*CurrentDispatch
; /**< == Save or Exec !! */
2097 GLframebuffer
*DrawBuffer
; /**< buffer for writing */
2098 GLframebuffer
*ReadBuffer
; /**< buffer for reading */
2101 * Device driver function pointer table
2103 struct dd_function_table Driver
;
2105 void *DriverCtx
; /**< Points to device driver context/state */
2106 void *DriverMgrCtx
; /**< Points to device driver manager (optional)*/
2108 /** Core/Driver constants */
2109 struct gl_constants Const
;
2111 /** \name The various 4x4 matrix stacks */
2113 struct matrix_stack ModelviewMatrixStack
;
2114 struct matrix_stack ProjectionMatrixStack
;
2115 struct matrix_stack ColorMatrixStack
;
2116 struct matrix_stack TextureMatrixStack
[MAX_TEXTURE_COORD_UNITS
];
2117 struct matrix_stack ProgramMatrixStack
[MAX_PROGRAM_MATRICES
];
2118 struct matrix_stack
*CurrentStack
; /**< Points to one of the above stacks */
2121 /** Combined modelview and projection matrix */
2122 GLmatrix _ModelProjectMatrix
;
2124 /** \name Display lists */
2125 struct mesa_list_state ListState
;
2127 GLboolean ExecuteFlag
; /**< Execute GL commands? */
2128 GLboolean CompileFlag
; /**< Compile GL commands into display list? */
2131 struct gl_extensions Extensions
;
2133 /** \name Renderer attribute stack */
2135 GLuint AttribStackDepth
;
2136 struct gl_attrib_node
*AttribStack
[MAX_ATTRIB_STACK_DEPTH
];
2139 /** \name Renderer attribute groups
2141 * We define a struct for each attribute group to make pushing and popping
2142 * attributes easy. Also it's a good organization.
2145 struct gl_accum_attrib Accum
; /**< Accumulation buffer attributes */
2146 struct gl_colorbuffer_attrib Color
; /**< Color buffers attributes */
2147 struct gl_current_attrib Current
; /**< Current attributes */
2148 struct gl_depthbuffer_attrib Depth
; /**< Depth buffer attributes */
2149 struct gl_eval_attrib Eval
; /**< Eval attributes */
2150 struct gl_fog_attrib Fog
; /**< Fog attributes */
2151 struct gl_hint_attrib Hint
; /**< Hint attributes */
2152 struct gl_light_attrib Light
; /**< Light attributes */
2153 struct gl_line_attrib Line
; /**< Line attributes */
2154 struct gl_list_attrib List
; /**< List attributes */
2155 struct gl_multisample_attrib Multisample
;
2156 struct gl_pixel_attrib Pixel
; /**< Pixel attributes */
2157 struct gl_point_attrib Point
; /**< Point attributes */
2158 struct gl_polygon_attrib Polygon
; /**< Polygon attributes */
2159 GLuint PolygonStipple
[32]; /**< Polygon stipple */
2160 struct gl_scissor_attrib Scissor
; /**< Scissor attributes */
2161 struct gl_stencil_attrib Stencil
; /**< Stencil buffer attributes */
2162 struct gl_texture_attrib Texture
; /**< Texture attributes */
2163 struct gl_transform_attrib Transform
; /**< Transformation attributes */
2164 struct gl_viewport_attrib Viewport
; /**< Viewport attributes */
2167 /** \name Other attribute groups */
2169 struct gl_histogram_attrib Histogram
;
2170 struct gl_minmax_attrib MinMax
;
2171 struct gl_convolution_attrib Convolution1D
;
2172 struct gl_convolution_attrib Convolution2D
;
2173 struct gl_convolution_attrib Separable2D
;
2176 /** \name Client attribute stack */
2178 GLuint ClientAttribStackDepth
;
2179 struct gl_attrib_node
*ClientAttribStack
[MAX_CLIENT_ATTRIB_STACK_DEPTH
];
2182 /** \name Client attribute groups */
2184 struct gl_array_attrib Array
; /**< Vertex arrays */
2185 struct gl_pixelstore_attrib Pack
; /**< Pixel packing */
2186 struct gl_pixelstore_attrib Unpack
; /**< Pixel unpacking */
2188 struct gl_evaluators EvalMap
; /**< All evaluators */
2189 struct gl_feedback Feedback
; /**< Feedback */
2190 struct gl_selection Select
; /**< Selection */
2192 struct gl_color_table ColorTable
; /**< Pre-convolution */
2193 struct gl_color_table ProxyColorTable
; /**< Pre-convolution */
2194 struct gl_color_table PostConvolutionColorTable
;
2195 struct gl_color_table ProxyPostConvolutionColorTable
;
2196 struct gl_color_table PostColorMatrixColorTable
;
2197 struct gl_color_table ProxyPostColorMatrixColorTable
;
2199 struct program_state Program
; /**< for vertex or fragment progs */
2200 struct vertex_program_state VertexProgram
; /**< GL_NV_vertex_program */
2201 struct fragment_program_state FragmentProgram
; /**< GL_NV_fragment_program */
2203 struct occlusion_state Occlusion
; /**< GL_ARB_occlusion_query */
2205 GLenum ErrorValue
; /**< Last error code */
2206 GLenum RenderMode
; /**< either GL_RENDER, GL_SELECT, GL_FEEDBACK */
2207 GLuint NewState
; /**< bitwise-or of _NEW_* flags */
2210 /** \name Derived */
2212 GLuint _TriangleCaps
; /**< bitwise-or of DD_* flags */
2213 GLuint _ImageTransferState
;/**< bitwise-or of IMAGE_*_BIT flags */
2214 GLfloat _EyeZDir
[3];
2215 GLfloat _ModelViewInvScale
;
2216 GLuint _NeedEyeCoords
;
2217 GLuint _ForceEyeCoords
;
2218 GLboolean _RotateMode
;
2219 GLenum _CurrentProgram
; /* currently executing program */
2221 struct gl_shine_tab
*_ShineTable
[2]; /**< Active shine tables */
2222 struct gl_shine_tab
*_ShineTabList
; /**< MRU list of inactive shine tables */
2225 struct gl_list_extensions listext
; /**< driver dlist extensions */
2228 GLboolean OcclusionResult
; /**< for GL_HP_occlusion_test */
2229 GLboolean OcclusionResultSaved
; /**< for GL_HP_occlusion_test */
2230 GLuint _Facing
; /**< This is a hack for 2-sided stencil test.
2232 * We don't have a better way to communicate this value from
2233 * swrast_setup to swrast. */
2236 /** \name Z buffer stuff */
2238 GLuint DepthMax
; /**< Max depth buffer value */
2239 GLfloat DepthMaxF
; /**< Float max depth buffer value */
2240 GLfloat MRD
; /**< minimum resolvable difference in Z values */
2243 /** Should 3Dfx Glide driver catch signals? */
2244 GLboolean CatchSignals
;
2246 /** \name For debugging/development only */
2248 GLboolean FirstTimeCurrent
;
2251 /** Dither disable via MESA_NO_DITHER env var */
2254 /** Core tnl module support */
2255 struct gl_tnl_module TnlModule
;
2258 * \name Hooks for module contexts.
2260 * These will eventually live in the driver or elsewhere.
2263 void *swrast_context
;
2264 void *swsetup_context
;
2265 void *swtnl_context
;
2267 void *acache_context
;
2273 /** The string names for GL_POINT, GL_LINE_LOOP, etc */
2274 extern const char *_mesa_prim_name
[GL_POLYGON
+4];
2278 extern int MESA_VERBOSE
;
2279 extern int MESA_DEBUG_FLAGS
;
2280 # define MESA_FUNCTION __FUNCTION__
2282 # define MESA_VERBOSE 0
2283 # define MESA_DEBUG_FLAGS 0
2284 # define MESA_FUNCTION "a function"
2292 VERBOSE_VARRAY
= 0x0001,
2293 VERBOSE_TEXTURE
= 0x0002,
2294 VERBOSE_IMMEDIATE
= 0x0004,
2295 VERBOSE_PIPELINE
= 0x0008,
2296 VERBOSE_DRIVER
= 0x0010,
2297 VERBOSE_STATE
= 0x0020,
2298 VERBOSE_API
= 0x0040,
2299 VERBOSE_DISPLAY_LIST
= 0x0100,
2300 VERBOSE_LIGHTING
= 0x0200,
2301 VERBOSE_PRIMS
= 0x0400,
2302 VERBOSE_VERTS
= 0x0800
2307 DEBUG_ALWAYS_FLUSH
= 0x1
2312 #define Elements(x) sizeof(x)/sizeof(*(x))
2315 #endif /* TYPES_H */