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-2003 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))
959 * Texel fetch function prototype.
961 * \param texImage texture image.
962 * \param col texel column.
963 * \param row texel row.
964 * \param img texel level.
965 * \param texelOut output texel. If \p texImage is color-index, \p texelOut
966 * returns <tt>GLchan[1]</tt>. If \p texImage is depth, \p texelOut returns
967 * <tt>GLfloat[1]</tt>. Otherwise, \p texelOut returns <tt>GLchan[4]</tt>.
969 typedef void (*FetchTexelFunc
)( const struct gl_texture_image
*texImage
,
970 GLint col
, GLint row
, GLint img
,
974 * Texture format record
976 struct gl_texture_format
{
977 GLint MesaFormat
; /**< One of the MESA_FORMAT_* values */
979 GLenum BaseFormat
; /**< Either GL_ALPHA, GL_INTENSITY, GL_LUMINANCE,
980 * GL_LUMINANCE_ALPHA, GL_RGB, GL_RGBA,
981 * GL_COLOR_INDEX or GL_DEPTH_COMPONENT.
983 GLubyte RedBits
; /**< Bits per texel component */
984 GLubyte GreenBits
; /**< These are just rough approximations for */
985 GLubyte BlueBits
; /**< compressed texture formats. */
987 GLubyte LuminanceBits
;
988 GLubyte IntensityBits
;
992 GLint TexelBytes
; /**< Bytes per texel (0 for compressed formats */
995 * \name Texel fetch function pointers
998 FetchTexelFunc FetchTexel1D
;
999 FetchTexelFunc FetchTexel2D
;
1000 FetchTexelFunc FetchTexel3D
;
1006 * Texture image record
1008 struct gl_texture_image
{
1009 GLenum Format
; /**< GL_ALPHA, GL_LUMINANCE, GL_LUMINANCE_ALPHA,
1010 * GL_INTENSITY, GL_RGB, GL_RGBA,
1011 * GL_COLOR_INDEX or GL_DEPTH_COMPONENT only.
1012 * Used for choosing TexEnv arithmetic.
1014 GLint IntFormat
; /**< Internal format as given by the user */
1015 GLuint Border
; /**< 0 or 1 */
1016 GLuint Width
; /**< = 2^WidthLog2 + 2*Border */
1017 GLuint Height
; /**< = 2^HeightLog2 + 2*Border */
1018 GLuint Depth
; /**< = 2^DepthLog2 + 2*Border */
1019 GLuint RowStride
; /**< == Width unless IsClientData and padded */
1020 GLuint Width2
; /**< = Width - 2*Border */
1021 GLuint Height2
; /**< = Height - 2*Border */
1022 GLuint Depth2
; /**< = Depth - 2*Border */
1023 GLuint WidthLog2
; /**< = log2(Width2) */
1024 GLuint HeightLog2
; /**< = log2(Height2) */
1025 GLuint DepthLog2
; /**< = log2(Depth2) */
1026 GLuint MaxLog2
; /**< = MAX(WidthLog2, HeightLog2) */
1027 GLfloat WidthScale
; /**< used for mipmap LOD computation */
1028 GLfloat HeightScale
; /**< used for mipmap LOD computation */
1029 GLfloat DepthScale
; /**< used for mipmap LOD computation */
1030 GLvoid
*Data
; /**< Image data, accessed via FetchTexel() */
1031 GLboolean IsClientData
; /**< Data owned by client? */
1032 GLboolean _IsPowerOfTwo
; /**< Are all dimensions powers of two? */
1034 const struct gl_texture_format
*TexFormat
;
1036 FetchTexelFunc FetchTexel
; /**< Texel fetch function pointer */
1038 GLboolean IsCompressed
; /**< GL_ARB_texture_compression */
1039 GLuint CompressedSize
; /**< GL_ARB_texture_compression */
1042 * \name For device driver:
1045 void *DriverData
; /**< Arbitrary device driver data */
1051 * Texture object record
1053 struct gl_texture_object
{
1054 _glthread_Mutex Mutex
; /**< for thread safety */
1055 GLint RefCount
; /**< reference count */
1056 GLuint Name
; /**< an unsigned integer */
1057 GLenum Target
; /**< GL_TEXTURE_1D, GL_TEXTURE_2D, etc. */
1058 GLfloat Priority
; /**< in [0,1] */
1059 GLfloat BorderColor
[4]; /**< unclamped */
1060 GLchan _BorderChan
[4]; /**< clamped, as GLchan */
1061 /** \name Wrap modes
1062 * Are GL_CLAMP, REPEAT, GL_CLAMP_TO_EDGE, and GL_CLAMP_TO_BORDER_ARB. */
1068 GLenum MinFilter
; /**< minification filter */
1069 GLenum MagFilter
; /**< magnification filter */
1070 GLfloat MinLod
; /**< min lambda, OpenGL 1.2 */
1071 GLfloat MaxLod
; /**< max lambda, OpenGL 1.2 */
1072 GLfloat LodBias
; /**< OpenGL 1.4 */
1073 GLint BaseLevel
; /**< min mipmap level, OpenGL 1.2 */
1074 GLint MaxLevel
; /**< max mipmap level, OpenGL 1.2 */
1075 GLfloat MaxAnisotropy
; /**< GL_EXT_texture_filter_anisotropic */
1076 GLboolean CompareFlag
; /**< GL_SGIX_shadow */
1077 GLenum CompareOperator
; /**< GL_SGIX_shadow */
1078 GLfloat ShadowAmbient
;
1079 GLenum CompareMode
; /**< GL_ARB_shadow */
1080 GLenum CompareFunc
; /**< GL_ARB_shadow */
1081 GLenum DepthMode
; /**< GL_ARB_depth_texture */
1082 GLint _MaxLevel
; /**< actual max mipmap level (q in the spec) */
1083 GLfloat _MaxLambda
; /**< = _MaxLevel - BaseLevel (q - b in spec) */
1084 GLboolean GenerateMipmap
; /**< GL_SGIS_generate_mipmap */
1085 GLboolean _IsPowerOfTwo
; /**< Are all image dimensions powers of two? */
1087 struct gl_texture_image
*Image
[MAX_TEXTURE_LEVELS
];
1090 * \name Texture cube faces
1092 * Image[] is alias for *PosX[MAX_TEXTURE_LEVELS];
1095 struct gl_texture_image
*NegX
[MAX_TEXTURE_LEVELS
];
1096 struct gl_texture_image
*PosY
[MAX_TEXTURE_LEVELS
];
1097 struct gl_texture_image
*NegY
[MAX_TEXTURE_LEVELS
];
1098 struct gl_texture_image
*PosZ
[MAX_TEXTURE_LEVELS
];
1099 struct gl_texture_image
*NegZ
[MAX_TEXTURE_LEVELS
];
1102 /** GL_EXT_paletted_texture */
1103 struct gl_color_table Palette
;
1105 GLboolean Complete
; /**< Is texture object complete? */
1106 struct gl_texture_object
*Next
; /**< Next in linked list */
1109 * \name For device driver
1112 void *DriverData
; /**< Arbitrary device driver data */
1118 * Texture unit record
1120 struct gl_texture_unit
{
1121 GLuint Enabled
; /**< bitmask of TEXTURE_*_BIT flags */
1122 GLuint _ReallyEnabled
; /**< 0 or exactly one of TEXTURE_*_BIT flags */
1124 GLenum EnvMode
; /**< GL_MODULATE, GL_DECAL, GL_BLEND, etc. */
1125 GLfloat EnvColor
[4];
1126 GLuint TexGenEnabled
; /**< Bitwise-OR of [STRQ]_BIT values */
1127 /** \name Tex coord generation mode
1128 * Either GL_OBJECT_LINEAR, GL_EYE_LINEAR or GL_SPHERE_MAP. */
1139 GLuint _GenFlags
; /**< bitwise or of GenBit[STRQ] */
1140 GLfloat ObjectPlaneS
[4];
1141 GLfloat ObjectPlaneT
[4];
1142 GLfloat ObjectPlaneR
[4];
1143 GLfloat ObjectPlaneQ
[4];
1144 GLfloat EyePlaneS
[4];
1145 GLfloat EyePlaneT
[4];
1146 GLfloat EyePlaneR
[4];
1147 GLfloat EyePlaneQ
[4];
1148 GLfloat LodBias
; /**< for biasing mipmap levels */
1151 * \name GL_EXT_texture_env_combine
1154 GLenum CombineModeRGB
; /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */
1155 GLenum CombineModeA
; /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */
1156 GLenum CombineSourceRGB
[3]; /**< GL_PRIMARY_COLOR, GL_TEXTURE, etc. */
1157 GLenum CombineSourceA
[3]; /**< GL_PRIMARY_COLOR, GL_TEXTURE, etc. */
1158 GLenum CombineOperandRGB
[3]; /**< SRC_COLOR, ONE_MINUS_SRC_COLOR, etc */
1159 GLenum CombineOperandA
[3]; /**< SRC_ALPHA, ONE_MINUS_SRC_ALPHA, etc */
1160 GLuint CombineScaleShiftRGB
; /**< 0, 1 or 2 */
1161 GLuint CombineScaleShiftA
; /**< 0, 1 or 2 */
1164 struct gl_texture_object
*Current1D
;
1165 struct gl_texture_object
*Current2D
;
1166 struct gl_texture_object
*Current3D
;
1167 struct gl_texture_object
*CurrentCubeMap
; /**< GL_ARB_texture_cube_map */
1168 struct gl_texture_object
*CurrentRect
; /**< GL_NV_texture_rectangle */
1170 struct gl_texture_object
*_Current
; /**< Points to really enabled tex obj */
1172 struct gl_texture_object Saved1D
; /**< only used by glPush/PopAttrib */
1173 struct gl_texture_object Saved2D
;
1174 struct gl_texture_object Saved3D
;
1175 struct gl_texture_object SavedCubeMap
;
1176 struct gl_texture_object SavedRect
;
1178 /* GL_SGI_texture_color_table */
1179 struct gl_color_table ColorTable
;
1180 struct gl_color_table ProxyColorTable
;
1181 GLboolean ColorTableEnabled
;
1186 * Texture attributes
1188 struct gl_texture_attrib
{
1193 GLuint CurrentUnit
; /**< Active texture unit */
1194 GLuint _EnabledUnits
; /**< one bit set for each really-enabled unit */
1195 GLuint _EnabledCoordUnits
; /**< one bit per enabled coordinate unit */
1196 GLuint _GenFlags
; /**< for texgen */
1197 GLuint _TexGenEnabled
;
1198 GLuint _TexMatEnabled
;
1201 struct gl_texture_unit Unit
[MAX_TEXTURE_UNITS
];
1203 struct gl_texture_object
*Proxy1D
;
1204 struct gl_texture_object
*Proxy2D
;
1205 struct gl_texture_object
*Proxy3D
;
1206 struct gl_texture_object
*ProxyCubeMap
;
1207 struct gl_texture_object
*ProxyRect
;
1209 /** GL_EXT_shared_texture_palette */
1210 GLboolean SharedPalette
;
1211 struct gl_color_table Palette
;
1216 * Transformation attributes.
1218 struct gl_transform_attrib
{
1219 GLenum MatrixMode
; /**< Matrix mode */
1220 GLfloat EyeUserPlane
[MAX_CLIP_PLANES
][4]; /**< User clip planes */
1221 GLfloat _ClipUserPlane
[MAX_CLIP_PLANES
][4]; /**< derived */
1222 GLuint ClipPlanesEnabled
; /**< on/off bitmask */
1223 GLboolean Normalize
; /**< Normalize all normals? */
1224 GLboolean RescaleNormals
; /**< GL_EXT_rescale_normal */
1225 GLboolean RasterPositionUnclipped
; /**< GL_IBM_rasterpos_clip */
1230 * Viewport attributes.
1232 struct gl_viewport_attrib
{
1233 GLint X
, Y
; /**< position */
1234 GLsizei Width
, Height
; /**< size */
1235 GLfloat Near
, Far
; /**< Depth buffer range */
1236 GLmatrix _WindowMap
; /**< Mapping transformation as a matrix. */
1241 * Node for the attribute stack
1243 struct gl_attrib_node
{
1246 struct gl_attrib_node
*next
;
1251 * GL_ARB_vertex_buffer_object buffer object
1253 struct gl_buffer_object
{
1258 GLvoid
*Pointer
; /**< Only valid while buffer is mapped */
1259 GLuint Size
; /**< Size of data array in bytes */
1260 GLubyte
*Data
; /**< The storage */
1266 * Client pixel packing/unpacking attributes
1268 struct gl_pixelstore_attrib
{
1273 GLint ImageHeight
; /**< for GL_EXT_texture3D */
1274 GLint SkipImages
; /**< for GL_EXT_texture3D */
1275 GLboolean SwapBytes
;
1277 GLboolean ClientStorage
; /**< GL_APPLE_client_storage */
1278 GLboolean Invert
; /**< GL_MESA_pack_invert */
1282 #define CA_CLIENT_DATA 0x1 /**< Data not allocated by mesa */
1286 * Client vertex array attributes
1288 struct gl_client_array
{
1291 GLsizei Stride
; /**< user-specified stride */
1292 GLsizei StrideB
; /**< actual stride in bytes */
1294 GLuint Enabled
; /**< one of the _NEW_ARRAY_ bits */
1295 GLboolean Normalized
; /**< GL_ARB_vertex_program */
1297 /**< GL_ARB_vertex_buffer_object */
1298 struct gl_buffer_object
*BufferObj
;
1308 struct gl_array_attrib
{
1309 struct gl_client_array Vertex
; /**< client data descriptors */
1310 struct gl_client_array Normal
;
1311 struct gl_client_array Color
;
1312 struct gl_client_array SecondaryColor
;
1313 struct gl_client_array FogCoord
;
1314 struct gl_client_array Index
;
1315 struct gl_client_array TexCoord
[MAX_TEXTURE_COORD_UNITS
];
1316 struct gl_client_array EdgeFlag
;
1318 struct gl_client_array VertexAttrib
[VERT_ATTRIB_MAX
]; /**< GL_NV_vertex_program */
1320 GLint ActiveTexture
; /**< Client Active Texture */
1321 GLuint LockFirst
; /**< GL_EXT_compiled_vertex_array */
1322 GLuint LockCount
; /**< GL_EXT_compiled_vertex_array */
1324 GLuint _Enabled
; /**< _NEW_ARRAY_* - bit set if array enabled */
1325 GLuint NewState
; /**< _NEW_ARRAY_* */
1327 #if FEATURE_ARB_vertex_buffer_object
1328 struct gl_buffer_object
*NullBufferObj
;
1329 struct gl_buffer_object
*ArrayBufferObj
;
1330 struct gl_buffer_object
*ElementArrayBufferObj
;
1332 GLuint _MaxElement
; /* Min of all enabled array's maxes */
1336 struct gl_feedback
{
1338 GLuint _Mask
; /* FB_* bits */
1346 * Selection attributes.
1348 struct gl_selection
{
1349 GLuint
*Buffer
; /**< selection buffer */
1350 GLuint BufferSize
; /**< size of the selection buffer */
1351 GLuint BufferCount
; /**< number of values in the selection buffer */
1352 GLuint Hits
; /**< number of records in the selection buffer */
1353 GLuint NameStackDepth
; /**< name stack depth */
1354 GLuint NameStack
[MAX_NAME_STACK_DEPTH
]; /**< name stack */
1355 GLboolean HitFlag
; /**< hit flag */
1356 GLfloat HitMinZ
; /**< minimum hit depth */
1357 GLfloat HitMaxZ
; /**< maximum hit depth */
1362 * 1-D Evaluator control points
1366 GLuint Order
; /**< Number of control points */
1367 GLfloat u1
, u2
, du
; /**< u1, u2, 1.0/(u2-u1) */
1368 GLfloat
*Points
; /**< Points to contiguous control points */
1373 * 2-D Evaluator control points
1377 GLuint Uorder
; /**< Number of control points in U dimension */
1378 GLuint Vorder
; /**< Number of control points in V dimension */
1381 GLfloat
*Points
; /**< Points to contiguous control points */
1386 * All evaluator control points
1388 struct gl_evaluators
1394 struct gl_1d_map Map1Vertex3
;
1395 struct gl_1d_map Map1Vertex4
;
1396 struct gl_1d_map Map1Index
;
1397 struct gl_1d_map Map1Color4
;
1398 struct gl_1d_map Map1Normal
;
1399 struct gl_1d_map Map1Texture1
;
1400 struct gl_1d_map Map1Texture2
;
1401 struct gl_1d_map Map1Texture3
;
1402 struct gl_1d_map Map1Texture4
;
1403 struct gl_1d_map Map1Attrib
[16]; /**< GL_NV_vertex_program */
1410 struct gl_2d_map Map2Vertex3
;
1411 struct gl_2d_map Map2Vertex4
;
1412 struct gl_2d_map Map2Index
;
1413 struct gl_2d_map Map2Color4
;
1414 struct gl_2d_map Map2Normal
;
1415 struct gl_2d_map Map2Texture1
;
1416 struct gl_2d_map Map2Texture2
;
1417 struct gl_2d_map Map2Texture3
;
1418 struct gl_2d_map Map2Texture4
;
1419 struct gl_2d_map Map2Attrib
[16]; /**< GL_NV_vertex_program */
1425 * NV_fragment_program runtime state
1429 GLfloat Temporaries
[MAX_NV_FRAGMENT_PROGRAM_TEMPS
][4];
1430 GLfloat Inputs
[MAX_NV_FRAGMENT_PROGRAM_INPUTS
][4];
1431 GLfloat Outputs
[MAX_NV_FRAGMENT_PROGRAM_OUTPUTS
][4];
1432 GLuint CondCodes
[4];
1437 * Names of the various vertex/fragment register files
1441 PROGRAM_TEMPORARY
= 10,
1444 PROGRAM_LOCAL_PARAM
,
1446 PROGRAM_NAMED_PARAM
,
1453 /* Vertex and fragment instructions */
1454 struct vp_instruction
;
1455 struct fp_instruction
;
1457 struct program_parameter_list
;
1461 * Base class for any kind of program object
1466 GLubyte
*String
; /* Null-terminated program text */
1468 GLenum Format
; /* String encoding format */
1471 GLfloat LocalParams
[MAX_PROGRAM_LOCAL_PARAMS
][4];
1472 GLuint NumInstructions
; /* GL_ARB_vertex/fragment_program */
1473 GLuint NumTemporaries
;
1474 GLuint NumParameters
;
1475 GLuint NumAttributes
;
1476 GLuint NumAddressRegs
;
1480 /** Vertex program object */
1481 struct vertex_program
1483 struct program Base
; /* base class */
1484 struct vp_instruction
*Instructions
; /* Compiled instructions */
1485 GLboolean IsPositionInvariant
; /* GL_NV_vertex_program1_1 */
1486 GLuint InputsRead
; /* Bitmask of which input regs are read */
1487 GLuint OutputsWritten
; /* Bitmask of which output regs are written to */
1488 struct program_parameter_list
*Parameters
; /**< array [NumParameters] */
1492 /** Fragment program object */
1493 struct fragment_program
1495 struct program Base
; /**< base class */
1496 struct fp_instruction
*Instructions
; /**< Compiled instructions */
1497 GLuint InputsRead
; /**< Bitmask of which input regs are read */
1498 GLuint OutputsWritten
; /**< Bitmask of which output regs are written to */
1499 GLuint TexturesUsed
[MAX_TEXTURE_IMAGE_UNITS
]; /**< TEXTURE_x_INDEX bitmask */
1500 GLuint NumAluInstructions
; /**< GL_ARB_fragment_program */
1501 GLuint NumTexInstructions
;
1502 GLuint NumTexIndirections
;
1503 struct program_parameter_list
*Parameters
; /**< array [NumParameters] */
1508 * State common to vertex and fragment programs.
1510 struct program_state
{
1511 GLint ErrorPos
; /* GL_PROGRAM_ERROR_POSITION_NV */
1512 const char *ErrorString
; /* GL_PROGRAM_ERROR_STRING_NV */
1517 * State vars for GL_NV_vertex_program
1519 struct vertex_program_state
1521 GLboolean Enabled
; /**< GL_VERTEX_PROGRAM_NV */
1522 GLboolean PointSizeEnabled
; /**< GL_VERTEX_PROGRAM_POINT_SIZE_NV */
1523 GLboolean TwoSideEnabled
; /**< GL_VERTEX_PROGRAM_TWO_SIDE_NV */
1524 struct vertex_program
*Current
; /**< ptr to currently bound program */
1526 GLenum TrackMatrix
[MAX_NV_VERTEX_PROGRAM_PARAMS
/ 4];
1527 GLenum TrackMatrixTransform
[MAX_NV_VERTEX_PROGRAM_PARAMS
/ 4];
1529 GLfloat Parameters
[MAX_NV_VERTEX_PROGRAM_PARAMS
][4]; /* Env params */
1530 /* Only used during program execution (may be moved someday): */
1531 GLfloat Temporaries
[MAX_NV_VERTEX_PROGRAM_TEMPS
][4];
1532 GLfloat Inputs
[MAX_NV_VERTEX_PROGRAM_INPUTS
][4];
1533 GLfloat Outputs
[MAX_NV_VERTEX_PROGRAM_OUTPUTS
][4];
1534 GLint AddressReg
[4];
1536 #if FEATURE_MESA_program_debug
1537 GLprogramcallbackMESA Callback
;
1538 GLvoid
*CallbackData
;
1539 GLboolean CallbackEnabled
;
1540 GLuint CurrentPosition
;
1546 * State for GL_ARB/NV_fragment_program
1548 struct fragment_program_state
1550 GLboolean Enabled
; /* GL_VERTEX_PROGRAM_NV */
1551 struct fragment_program
*Current
; /* ptr to currently bound program */
1552 struct fp_machine Machine
; /* machine state */
1553 GLfloat Parameters
[MAX_NV_FRAGMENT_PROGRAM_PARAMS
][4]; /* Env params */
1555 #if FEATURE_MESA_program_debug
1556 GLprogramcallbackMESA Callback
;
1557 GLvoid
*CallbackData
;
1558 GLboolean CallbackEnabled
;
1559 GLuint CurrentPosition
;
1565 * State for GL_ARB_occlusion_query
1567 struct occlusion_state
1570 GLuint CurrentQueryObject
;
1571 GLuint PassedCounter
;
1572 struct _mesa_HashTable
*QueryObjects
;
1577 * State which can be shared by multiple contexts:
1579 struct gl_shared_state
1581 _glthread_Mutex Mutex
; /**< for thread safety */
1582 GLint RefCount
; /**< Reference count */
1583 struct _mesa_HashTable
*DisplayList
; /**< Display lists hash table */
1584 struct _mesa_HashTable
*TexObjects
; /**< Texture objects hash table */
1585 struct gl_texture_object
*TexObjectList
;/**< Linked list of texture objects */
1588 * \name Default texture objects (shared by all multi-texture units)
1591 struct gl_texture_object
*Default1D
;
1592 struct gl_texture_object
*Default2D
;
1593 struct gl_texture_object
*Default3D
;
1594 struct gl_texture_object
*DefaultCubeMap
;
1595 struct gl_texture_object
*DefaultRect
;
1599 * \name GL_NV_vertex/_program
1602 struct _mesa_HashTable
*Programs
;
1603 #if FEATURE_ARB_vertex_program
1604 struct program
*DefaultVertexProgram
;
1606 #if FEATURE_ARB_fragment_program
1607 struct program
*DefaultFragmentProgram
;
1611 #if FEATURE_ARB_vertex_buffer_object
1612 struct _mesa_HashTable
*BufferObjects
;
1615 void *DriverData
; /**< Device driver shared state */
1622 * A "frame buffer" is a color buffer and its optional ancillary buffers:
1623 * depth, accum, stencil, and software-simulated alpha buffers.
1624 * In C++ terms, think of this as a base class from which device drivers
1625 * will make derived classes.
1627 struct gl_frame_buffer
1629 GLvisual Visual
; /**< The corresponding visual */
1631 GLuint Width
, Height
; /**< size of frame buffer in pixels */
1633 GLboolean UseSoftwareDepthBuffer
;
1634 GLboolean UseSoftwareAccumBuffer
;
1635 GLboolean UseSoftwareStencilBuffer
;
1636 GLboolean UseSoftwareAlphaBuffers
;
1638 /** \name Software depth (aka Z) buffer */
1640 GLvoid
*DepthBuffer
; /**< array [Width*Height] of GLushort or GLuint*/
1643 /** \name Software stencil buffer */
1645 GLstencil
*Stencil
; /**< array [Width*Height] of GLstencil values */
1648 /** \name Software accumulation buffer */
1650 GLaccum
*Accum
; /**< array [4*Width*Height] of GLaccum values */
1653 /** \name Software alpha planes */
1655 GLvoid
*FrontLeftAlpha
; /**< array [Width*Height] of GLubyte */
1656 GLvoid
*BackLeftAlpha
; /**< array [Width*Height] of GLubyte */
1657 GLvoid
*FrontRightAlpha
; /**< array [Width*Height] of GLubyte */
1658 GLvoid
*BackRightAlpha
; /**< array [Width*Height] of GLubyte */
1662 * \name Drawing bounds
1664 * Intersection of window size and scissor box
1667 GLint _Xmin
; /**< inclusive */
1668 GLint _Ymin
; /**< inclusive */
1669 GLint _Xmax
; /**< exclusive */
1670 GLint _Ymax
; /**< exclusive */
1676 * Constants which may be overridden by device driver during context creation
1677 * but are never changed after that.
1681 GLint MaxTextureLevels
; /**< Maximum number of allowed mipmap levels. */
1682 GLint Max3DTextureLevels
; /**< Maximum number of allowed mipmap levels for 3D texture targets. */
1683 GLint MaxCubeTextureLevels
; /**< Maximum number of allowed mipmap levels for GL_ARB_texture_cube_map */
1684 GLint MaxTextureRectSize
; /* GL_NV_texture_rectangle */
1685 GLuint MaxTextureCoordUnits
;
1686 GLuint MaxTextureImageUnits
;
1687 GLuint MaxTextureUnits
; /* = MAX(CoordUnits, ImageUnits) */
1688 GLfloat MaxTextureMaxAnisotropy
; /* GL_EXT_texture_filter_anisotropic */
1689 GLfloat MaxTextureLodBias
; /* GL_EXT_texture_lod_bias */
1690 GLuint MaxArrayLockSize
;
1692 GLfloat MinPointSize
, MaxPointSize
; /* aliased */
1693 GLfloat MinPointSizeAA
, MaxPointSizeAA
; /* antialiased */
1694 GLfloat PointSizeGranularity
;
1695 GLfloat MinLineWidth
, MaxLineWidth
; /* aliased */
1696 GLfloat MinLineWidthAA
, MaxLineWidthAA
; /* antialiased */
1697 GLfloat LineWidthGranularity
;
1698 GLuint NumAuxBuffers
;
1699 GLuint MaxColorTableSize
;
1700 GLuint MaxConvolutionWidth
;
1701 GLuint MaxConvolutionHeight
;
1702 GLuint MaxClipPlanes
;
1704 GLfloat MaxShininess
; /* GL_NV_light_max_exponent */
1705 GLfloat MaxSpotExponent
; /* GL_NV_light_max_exponent */
1706 /* GL_ARB_vertex_program */
1707 GLuint MaxVertexProgramInstructions
;
1708 GLuint MaxVertexProgramAttribs
;
1709 GLuint MaxVertexProgramTemps
;
1710 GLuint MaxVertexProgramLocalParams
;
1711 GLuint MaxVertexProgramEnvParams
;
1712 GLuint MaxVertexProgramAddressRegs
;
1713 /* GL_ARB_fragment_program */
1714 GLuint MaxFragmentProgramInstructions
;
1715 GLuint MaxFragmentProgramAttribs
;
1716 GLuint MaxFragmentProgramTemps
;
1717 GLuint MaxFragmentProgramLocalParams
;
1718 GLuint MaxFragmentProgramEnvParams
;
1719 GLuint MaxFragmentProgramAddressRegs
;
1720 GLuint MaxFragmentProgramAluInstructions
;
1721 GLuint MaxFragmentProgramTexInstructions
;
1722 GLuint MaxFragmentProgramTexIndirections
;
1723 /* vertex or fragment program */
1724 GLuint MaxProgramMatrices
;
1725 GLuint MaxProgramMatrixStackDepth
;
1726 /* vertex array / buffer object bounds checking */
1727 GLboolean CheckArrayBounds
;
1732 * List of extensions.
1734 struct gl_extensions
1737 * \name Flags to quickly test if certain extensions are available.
1739 * Not every extension needs to have such a flag, but it's encouraged.
1742 GLboolean dummy
; /* don't remove this! */
1743 GLboolean ARB_depth_texture
;
1744 GLboolean ARB_fragment_program
;
1745 GLboolean ARB_imaging
;
1746 GLboolean ARB_multisample
;
1747 GLboolean ARB_multitexture
;
1748 GLboolean ARB_occlusion_query
;
1749 GLboolean ARB_point_sprite
;
1750 GLboolean ARB_shadow
;
1751 GLboolean ARB_texture_border_clamp
;
1752 GLboolean ARB_texture_compression
;
1753 GLboolean ARB_texture_cube_map
;
1754 GLboolean ARB_texture_env_combine
;
1755 GLboolean ARB_texture_env_crossbar
;
1756 GLboolean ARB_texture_env_dot3
;
1757 GLboolean ARB_texture_mirrored_repeat
;
1758 GLboolean ARB_texture_non_power_of_two
;
1759 GLboolean ARB_vertex_buffer_object
;
1760 GLboolean ARB_vertex_program
;
1761 GLboolean ARB_window_pos
;
1762 GLboolean ATI_texture_mirror_once
;
1763 GLboolean ATI_texture_env_combine3
;
1764 GLboolean EXT_blend_color
;
1765 GLboolean EXT_blend_func_separate
;
1766 GLboolean EXT_blend_logic_op
;
1767 GLboolean EXT_blend_minmax
;
1768 GLboolean EXT_blend_subtract
;
1769 GLboolean EXT_convolution
;
1770 GLboolean EXT_compiled_vertex_array
;
1771 GLboolean EXT_depth_bounds_test
;
1772 GLboolean EXT_fog_coord
;
1773 GLboolean EXT_histogram
;
1774 GLboolean EXT_multi_draw_arrays
;
1775 GLboolean EXT_paletted_texture
;
1776 GLboolean EXT_point_parameters
;
1777 GLboolean EXT_shadow_funcs
;
1778 GLboolean EXT_secondary_color
;
1779 GLboolean EXT_shared_texture_palette
;
1780 GLboolean EXT_stencil_wrap
;
1781 GLboolean EXT_stencil_two_side
;
1782 GLboolean EXT_texture3D
;
1783 GLboolean EXT_texture_compression_s3tc
;
1784 GLboolean EXT_texture_env_add
;
1785 GLboolean EXT_texture_env_combine
;
1786 GLboolean EXT_texture_env_dot3
;
1787 GLboolean EXT_texture_filter_anisotropic
;
1788 GLboolean EXT_texture_lod_bias
;
1789 GLboolean EXT_texture_mirror_clamp
;
1790 GLboolean EXT_vertex_array_set
;
1791 GLboolean HP_occlusion_test
;
1792 GLboolean IBM_rasterpos_clip
;
1793 GLboolean IBM_multimode_draw_arrays
;
1794 GLboolean MESA_pack_invert
;
1795 GLboolean MESA_packed_depth_stencil
;
1796 GLboolean MESA_program_debug
;
1797 GLboolean MESA_resize_buffers
;
1798 GLboolean MESA_ycbcr_texture
;
1799 GLboolean NV_blend_square
;
1800 GLboolean NV_fragment_program
;
1801 GLboolean NV_point_sprite
;
1802 GLboolean NV_texture_rectangle
;
1803 GLboolean NV_vertex_program
;
1804 GLboolean NV_vertex_program1_1
;
1805 GLboolean SGI_color_matrix
;
1806 GLboolean SGI_color_table
;
1807 GLboolean SGI_texture_color_table
;
1808 GLboolean SGIS_generate_mipmap
;
1809 GLboolean SGIS_pixel_texture
;
1810 GLboolean SGIS_texture_edge_clamp
;
1811 GLboolean SGIX_depth_texture
;
1812 GLboolean SGIX_pixel_texture
;
1813 GLboolean SGIX_shadow
;
1814 GLboolean SGIX_shadow_ambient
; /* or GL_ARB_shadow_ambient */
1815 GLboolean TDFX_texture_compression_FXT1
;
1816 GLboolean APPLE_client_storage
;
1819 /* The extension string */
1820 const GLubyte
*String
;
1825 * A stack of matrices (projection, modelview, color, texture, etc).
1829 GLmatrix
*Top
; /**< points into Stack */
1830 GLmatrix
*Stack
; /**< array [MaxDepth] of GLmatrix */
1831 GLuint Depth
; /**< 0 <= Depth < MaxDepth */
1832 GLuint MaxDepth
; /**< size of Stack[] array */
1833 GLuint DirtyFlag
; /**< _NEW_MODELVIEW or _NEW_PROJECTION, for example */
1838 * \name Bits for image transfer operations
1840 * \sa __GLcontextRec::ImageTransferState.
1843 #define IMAGE_SCALE_BIAS_BIT 0x1
1844 #define IMAGE_SHIFT_OFFSET_BIT 0x2
1845 #define IMAGE_MAP_COLOR_BIT 0x4
1846 #define IMAGE_COLOR_TABLE_BIT 0x8
1847 #define IMAGE_CONVOLUTION_BIT 0x10
1848 #define IMAGE_POST_CONVOLUTION_SCALE_BIAS 0x20
1849 #define IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT 0x40
1850 #define IMAGE_COLOR_MATRIX_BIT 0x80
1851 #define IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT 0x100
1852 #define IMAGE_HISTOGRAM_BIT 0x200
1853 #define IMAGE_MIN_MAX_BIT 0x400
1855 /** Transfer ops up to convolution */
1856 #define IMAGE_PRE_CONVOLUTION_BITS (IMAGE_SCALE_BIAS_BIT | \
1857 IMAGE_SHIFT_OFFSET_BIT | \
1858 IMAGE_MAP_COLOR_BIT | \
1859 IMAGE_COLOR_TABLE_BIT)
1861 /** Transfer ops after convolution */
1862 #define IMAGE_POST_CONVOLUTION_BITS (IMAGE_POST_CONVOLUTION_SCALE_BIAS | \
1863 IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT | \
1864 IMAGE_COLOR_MATRIX_BIT | \
1865 IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT |\
1866 IMAGE_HISTOGRAM_BIT | \
1872 * \name Bits to indicate what state has changed.
1877 #define _NEW_MODELVIEW 0x1 /**< __GLcontextRec::ModelView */
1878 #define _NEW_PROJECTION 0x2 /**< __GLcontextRec::Projection */
1879 #define _NEW_TEXTURE_MATRIX 0x4 /**< __GLcontextRec::TextureMatrix */
1880 #define _NEW_COLOR_MATRIX 0x8 /**< __GLcontextRec::ColorMatrix */
1881 #define _NEW_ACCUM 0x10 /**< __GLcontextRec::Accum */
1882 #define _NEW_COLOR 0x20 /**< __GLcontextRec::Color */
1883 #define _NEW_DEPTH 0x40 /**< __GLcontextRec::Depth */
1884 #define _NEW_EVAL 0x80 /**< __GLcontextRec::Eval, __GLcontextRec::EvalMap */
1885 #define _NEW_FOG 0x100 /**< __GLcontextRec::Fog */
1886 #define _NEW_HINT 0x200 /**< __GLcontextRec::Hint */
1887 #define _NEW_LIGHT 0x400 /**< __GLcontextRec::Light */
1888 #define _NEW_LINE 0x800 /**< __GLcontextRec::Line */
1889 #define _NEW_PIXEL 0x1000 /**< __GLcontextRec::Pixel */
1890 #define _NEW_POINT 0x2000 /**< __GLcontextRec::Point */
1891 #define _NEW_POLYGON 0x4000 /**< __GLcontextRec::Polygon */
1892 #define _NEW_POLYGONSTIPPLE 0x8000 /**< __GLcontextRec::PolygonStipple */
1893 #define _NEW_SCISSOR 0x10000 /**< __GLcontextRec::Scissor */
1894 #define _NEW_STENCIL 0x20000 /**< __GLcontextRec::Stencil */
1895 #define _NEW_TEXTURE 0x40000 /**< __GLcontextRec::Texture */
1896 #define _NEW_TRANSFORM 0x80000 /**< __GLcontextRec::Transform */
1897 #define _NEW_VIEWPORT 0x100000 /**< __GLcontextRec::Viewport */
1898 #define _NEW_PACKUNPACK 0x200000 /**< __GLcontextRec::Pack, __GLcontextRec::Unpack */
1899 #define _NEW_ARRAY 0x400000 /**< __GLcontextRec::Array */
1900 #define _NEW_RENDERMODE 0x800000 /**< __GLcontextRec::RenderMode, __GLcontextRec::Feedback, __GLcontextRec::Select */
1901 #define _NEW_BUFFERS 0x1000000 /**< __GLcontextRec::Visual, __GLcontextRec::DrawBuffer, */
1902 #define _NEW_MULTISAMPLE 0x2000000 /**< __GLcontextRec::Multisample */
1903 #define _NEW_TRACK_MATRIX 0x4000000 /**< __GLcontextRec::VertexProgram */
1904 #define _NEW_PROGRAM 0x8000000 /**< __GLcontextRec::VertexProgram */
1910 * \name Bits to track array state changes
1912 * Also used to summarize array enabled.
1915 #define _NEW_ARRAY_VERTEX VERT_BIT_POS
1916 #define _NEW_ARRAY_WEIGHT VERT_BIT_WEIGHT
1917 #define _NEW_ARRAY_NORMAL VERT_BIT_NORMAL
1918 #define _NEW_ARRAY_COLOR0 VERT_BIT_COLOR0
1919 #define _NEW_ARRAY_COLOR1 VERT_BIT_COLOR1
1920 #define _NEW_ARRAY_FOGCOORD VERT_BIT_FOG
1921 #define _NEW_ARRAY_INDEX VERT_BIT_SIX
1922 #define _NEW_ARRAY_EDGEFLAG VERT_BIT_SEVEN
1923 #define _NEW_ARRAY_TEXCOORD_0 VERT_BIT_TEX0
1924 #define _NEW_ARRAY_TEXCOORD_1 VERT_BIT_TEX1
1925 #define _NEW_ARRAY_TEXCOORD_2 VERT_BIT_TEX2
1926 #define _NEW_ARRAY_TEXCOORD_3 VERT_BIT_TEX3
1927 #define _NEW_ARRAY_TEXCOORD_4 VERT_BIT_TEX4
1928 #define _NEW_ARRAY_TEXCOORD_5 VERT_BIT_TEX5
1929 #define _NEW_ARRAY_TEXCOORD_6 VERT_BIT_TEX6
1930 #define _NEW_ARRAY_TEXCOORD_7 VERT_BIT_TEX7
1931 #define _NEW_ARRAY_ATTRIB_0 0x10000 /* start at bit 16 */
1932 #define _NEW_ARRAY_ALL 0xffffffff
1935 #define _NEW_ARRAY_TEXCOORD(i) (_NEW_ARRAY_TEXCOORD_0 << (i))
1936 #define _NEW_ARRAY_ATTRIB(i) (_NEW_ARRAY_ATTRIB_0 << (i))
1941 * \name A bunch of flags that we think might be useful to drivers.
1943 * Set in the __GLcontextRec::_TriangleCaps bitfield.
1946 #define DD_FLATSHADE 0x1
1947 #define DD_SEPARATE_SPECULAR 0x2
1948 #define DD_TRI_CULL_FRONT_BACK 0x4 /* special case on some hw */
1949 #define DD_TRI_LIGHT_TWOSIDE 0x8
1950 #define DD_TRI_UNFILLED 0x10
1951 #define DD_TRI_SMOOTH 0x20
1952 #define DD_TRI_STIPPLE 0x40
1953 #define DD_TRI_OFFSET 0x80
1954 #define DD_LINE_SMOOTH 0x100
1955 #define DD_LINE_STIPPLE 0x200
1956 #define DD_LINE_WIDTH 0x400
1957 #define DD_POINT_SMOOTH 0x800
1958 #define DD_POINT_SIZE 0x1000
1959 #define DD_POINT_ATTEN 0x2000
1964 * \name Define the state changes under which each of these bits might change
1967 #define _DD_NEW_FLATSHADE _NEW_LIGHT
1968 #define _DD_NEW_SEPARATE_SPECULAR (_NEW_LIGHT | _NEW_FOG)
1969 #define _DD_NEW_TRI_CULL_FRONT_BACK _NEW_POLYGON
1970 #define _DD_NEW_TRI_LIGHT_TWOSIDE _NEW_LIGHT
1971 #define _DD_NEW_TRI_UNFILLED _NEW_POLYGON
1972 #define _DD_NEW_TRI_SMOOTH _NEW_POLYGON
1973 #define _DD_NEW_TRI_STIPPLE _NEW_POLYGON
1974 #define _DD_NEW_TRI_OFFSET _NEW_POLYGON
1975 #define _DD_NEW_LINE_SMOOTH _NEW_LINE
1976 #define _DD_NEW_LINE_STIPPLE _NEW_LINE
1977 #define _DD_NEW_LINE_WIDTH _NEW_LINE
1978 #define _DD_NEW_POINT_SMOOTH _NEW_POINT
1979 #define _DD_NEW_POINT_SIZE _NEW_POINT
1980 #define _DD_NEW_POINT_ATTEN _NEW_POINT
1984 #define _MESA_NEW_NEED_EYE_COORDS (_NEW_LIGHT | \
1989 #define _MESA_NEW_NEED_NORMALS (_NEW_LIGHT | \
1992 #define _IMAGE_NEW_TRANSFER_STATE (_NEW_PIXEL | _NEW_COLOR_MATRIX)
1998 * Forward declaration of display list data types:
2001 typedef union node Node
;
2004 /* This has to be included here. */
2008 #define NUM_VERTEX_FORMAT_ENTRIES (sizeof(GLvertexformat) / sizeof(void *))
2011 * Core Mesa's support for tnl modules:
2013 struct gl_tnl_module
{
2015 * Vertex format to be lazily swapped into current dispatch.
2017 GLvertexformat
*Current
;
2020 * \name Record of functions swapped out.
2021 * On restore, only need to swap these functions back in.
2024 void *Swapped
[NUM_VERTEX_FORMAT_ENTRIES
][2];
2029 struct mesa_list_state
{
2030 GLuint CallDepth
; /**< Current recursion calling depth */
2031 Node
*CurrentListPtr
; /**< Head of list being compiled */
2032 GLuint CurrentListNum
; /**< Number of the list being compiled */
2033 Node
*CurrentBlock
; /**< Pointer to current block of nodes */
2034 GLuint CurrentPos
; /**< Index into current block of nodes */
2035 GLvertexformat ListVtxfmt
;
2037 GLubyte ActiveAttribSize
[VERT_ATTRIB_MAX
];
2038 GLfloat CurrentAttrib
[VERT_ATTRIB_MAX
][4];
2040 GLubyte ActiveMaterialSize
[MAT_ATTRIB_MAX
];
2041 GLfloat CurrentMaterial
[MAT_ATTRIB_MAX
][4];
2043 GLubyte ActiveIndex
;
2044 GLfloat CurrentIndex
;
2046 GLubyte ActiveEdgeFlag
;
2047 GLboolean CurrentEdgeFlag
;
2054 * This is the central context data structure for Mesa. Almost all
2055 * OpenGL state is contained in this structure.
2056 * Think of this as a base class from which device drivers will derive
2059 struct __GLcontextRec
{
2061 * \name OS related interfaces.
2063 * These \b must be the first members of this structure, because they are
2064 * exposed to the outside world (i.e. GLX extension).
2067 __GLimports imports
;
2068 __GLexports exports
;
2071 /** State possibly shared with other contexts in the address space */
2072 struct gl_shared_state
*Shared
;
2074 /** \name API function pointer tables */
2076 struct _glapi_table
*Save
; /**< Display list save functions */
2077 struct _glapi_table
*Exec
; /**< Execute functions */
2078 struct _glapi_table
*CurrentDispatch
; /**< == Save or Exec !! */
2082 GLframebuffer
*DrawBuffer
; /**< buffer for writing */
2083 GLframebuffer
*ReadBuffer
; /**< buffer for reading */
2086 * Device driver function pointer table
2088 struct dd_function_table Driver
;
2090 void *DriverCtx
; /**< Points to device driver context/state */
2091 void *DriverMgrCtx
; /**< Points to device driver manager (optional)*/
2093 /** Core/Driver constants */
2094 struct gl_constants Const
;
2096 /** \name The various 4x4 matrix stacks */
2098 struct matrix_stack ModelviewMatrixStack
;
2099 struct matrix_stack ProjectionMatrixStack
;
2100 struct matrix_stack ColorMatrixStack
;
2101 struct matrix_stack TextureMatrixStack
[MAX_TEXTURE_COORD_UNITS
];
2102 struct matrix_stack ProgramMatrixStack
[MAX_PROGRAM_MATRICES
];
2103 struct matrix_stack
*CurrentStack
; /**< Points to one of the above stacks */
2106 /** Combined modelview and projection matrix */
2107 GLmatrix _ModelProjectMatrix
;
2109 /** \name Display lists */
2110 struct mesa_list_state ListState
;
2112 GLboolean ExecuteFlag
; /**< Execute GL commands? */
2113 GLboolean CompileFlag
; /**< Compile GL commands into display list? */
2116 struct gl_extensions Extensions
;
2118 /** \name Renderer attribute stack */
2120 GLuint AttribStackDepth
;
2121 struct gl_attrib_node
*AttribStack
[MAX_ATTRIB_STACK_DEPTH
];
2124 /** \name Renderer attribute groups
2126 * We define a struct for each attribute group to make pushing and popping
2127 * attributes easy. Also it's a good organization.
2130 struct gl_accum_attrib Accum
; /**< Accumulation buffer attributes */
2131 struct gl_colorbuffer_attrib Color
; /**< Color buffers attributes */
2132 struct gl_current_attrib Current
; /**< Current attributes */
2133 struct gl_depthbuffer_attrib Depth
; /**< Depth buffer attributes */
2134 struct gl_eval_attrib Eval
; /**< Eval attributes */
2135 struct gl_fog_attrib Fog
; /**< Fog attributes */
2136 struct gl_hint_attrib Hint
; /**< Hint attributes */
2137 struct gl_light_attrib Light
; /**< Light attributes */
2138 struct gl_line_attrib Line
; /**< Line attributes */
2139 struct gl_list_attrib List
; /**< List attributes */
2140 struct gl_multisample_attrib Multisample
;
2141 struct gl_pixel_attrib Pixel
; /**< Pixel attributes */
2142 struct gl_point_attrib Point
; /**< Point attributes */
2143 struct gl_polygon_attrib Polygon
; /**< Polygon attributes */
2144 GLuint PolygonStipple
[32]; /**< Polygon stipple */
2145 struct gl_scissor_attrib Scissor
; /**< Scissor attributes */
2146 struct gl_stencil_attrib Stencil
; /**< Stencil buffer attributes */
2147 struct gl_texture_attrib Texture
; /**< Texture attributes */
2148 struct gl_transform_attrib Transform
; /**< Transformation attributes */
2149 struct gl_viewport_attrib Viewport
; /**< Viewport attributes */
2152 /** \name Other attribute groups */
2154 struct gl_histogram_attrib Histogram
;
2155 struct gl_minmax_attrib MinMax
;
2156 struct gl_convolution_attrib Convolution1D
;
2157 struct gl_convolution_attrib Convolution2D
;
2158 struct gl_convolution_attrib Separable2D
;
2161 /** \name Client attribute stack */
2163 GLuint ClientAttribStackDepth
;
2164 struct gl_attrib_node
*ClientAttribStack
[MAX_CLIENT_ATTRIB_STACK_DEPTH
];
2167 /** \name Client attribute groups */
2169 struct gl_array_attrib Array
; /**< Vertex arrays */
2170 struct gl_pixelstore_attrib Pack
; /**< Pixel packing */
2171 struct gl_pixelstore_attrib Unpack
; /**< Pixel unpacking */
2173 struct gl_evaluators EvalMap
; /**< All evaluators */
2174 struct gl_feedback Feedback
; /**< Feedback */
2175 struct gl_selection Select
; /**< Selection */
2177 struct gl_color_table ColorTable
; /**< Pre-convolution */
2178 struct gl_color_table ProxyColorTable
; /**< Pre-convolution */
2179 struct gl_color_table PostConvolutionColorTable
;
2180 struct gl_color_table ProxyPostConvolutionColorTable
;
2181 struct gl_color_table PostColorMatrixColorTable
;
2182 struct gl_color_table ProxyPostColorMatrixColorTable
;
2184 struct program_state Program
; /**< for vertex or fragment progs */
2185 struct vertex_program_state VertexProgram
; /**< GL_NV_vertex_program */
2186 struct fragment_program_state FragmentProgram
; /**< GL_NV_fragment_program */
2188 struct occlusion_state Occlusion
; /**< GL_ARB_occlusion_query */
2190 GLenum ErrorValue
; /**< Last error code */
2191 GLenum RenderMode
; /**< either GL_RENDER, GL_SELECT, GL_FEEDBACK */
2192 GLuint NewState
; /**< bitwise-or of _NEW_* flags */
2195 /** \name Derived */
2197 GLuint _TriangleCaps
; /**< bitwise-or of DD_* flags */
2198 GLuint _ImageTransferState
;/**< bitwise-or of IMAGE_*_BIT flags */
2199 GLfloat _EyeZDir
[3];
2200 GLfloat _ModelViewInvScale
;
2201 GLuint _NeedEyeCoords
;
2202 GLuint _ForceEyeCoords
;
2203 GLboolean _RotateMode
;
2204 GLenum _CurrentProgram
; /* currently executing program */
2206 struct gl_shine_tab
*_ShineTable
[2]; /**< Active shine tables */
2207 struct gl_shine_tab
*_ShineTabList
; /**< MRU list of inactive shine tables */
2210 struct gl_list_extensions listext
; /**< driver dlist extensions */
2213 GLboolean OcclusionResult
; /**< for GL_HP_occlusion_test */
2214 GLboolean OcclusionResultSaved
; /**< for GL_HP_occlusion_test */
2215 GLuint _Facing
; /**< This is a hack for 2-sided stencil test.
2217 * We don't have a better way to communicate this value from
2218 * swrast_setup to swrast. */
2221 /** \name Z buffer stuff */
2223 GLuint DepthMax
; /**< Max depth buffer value */
2224 GLfloat DepthMaxF
; /**< Float max depth buffer value */
2225 GLfloat MRD
; /**< minimum resolvable difference in Z values */
2228 /** Should 3Dfx Glide driver catch signals? */
2229 GLboolean CatchSignals
;
2231 /** \name For debugging/development only */
2233 GLboolean FirstTimeCurrent
;
2236 /** Dither disable via MESA_NO_DITHER env var */
2239 /** Core tnl module support */
2240 struct gl_tnl_module TnlModule
;
2243 * \name Hooks for module contexts.
2245 * These will eventually live in the driver or elsewhere.
2248 void *swrast_context
;
2249 void *swsetup_context
;
2250 void *swtnl_context
;
2252 void *acache_context
;
2258 /** The string names for GL_POINT, GL_LINE_LOOP, etc */
2259 extern const char *_mesa_prim_name
[GL_POLYGON
+4];
2263 extern int MESA_VERBOSE
;
2264 extern int MESA_DEBUG_FLAGS
;
2265 # define MESA_FUNCTION __FUNCTION__
2267 # define MESA_VERBOSE 0
2268 # define MESA_DEBUG_FLAGS 0
2269 # define MESA_FUNCTION "a function"
2277 VERBOSE_VARRAY
= 0x0001,
2278 VERBOSE_TEXTURE
= 0x0002,
2279 VERBOSE_IMMEDIATE
= 0x0004,
2280 VERBOSE_PIPELINE
= 0x0008,
2281 VERBOSE_DRIVER
= 0x0010,
2282 VERBOSE_STATE
= 0x0020,
2283 VERBOSE_API
= 0x0040,
2284 VERBOSE_DISPLAY_LIST
= 0x0100,
2285 VERBOSE_LIGHTING
= 0x0200,
2286 VERBOSE_PRIMS
= 0x0400,
2287 VERBOSE_VERTS
= 0x0800
2292 DEBUG_ALWAYS_FLUSH
= 0x1
2297 #define Elements(x) sizeof(x)/sizeof(*(x))
2300 #endif /* TYPES_H */