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 */
435 GLboolean DitherFlag
; /**< Dither enable flag */
440 * Current attributes.
442 struct gl_current_attrib
{
444 * \name Values valid only when FLUSH_VERTICES has been called.
447 GLfloat Attrib
[VERT_ATTRIB_MAX
][4]; /**< Current vertex attributes
448 * indexed by VERT_ATTRIB_* */
449 GLuint Index
; /**< Current color index */
450 GLboolean EdgeFlag
; /**< Current edge flag */
454 * \name Values are always valid.
456 * \note BTW, note how similar this set of attributes is to the SWvertex data type
457 * in the software rasterizer...
460 GLfloat RasterPos
[4]; /**< Current raster position */
461 GLfloat RasterDistance
; /**< Current raster distance */
462 GLfloat RasterColor
[4]; /**< Current raster color */
463 GLfloat RasterSecondaryColor
[4]; /**< Current raster secondary color */
464 GLuint RasterIndex
; /**< Current raster index */
465 GLfloat RasterTexCoords
[MAX_TEXTURE_UNITS
][4];/**< Current raster texcoords */
466 GLboolean RasterPosValid
; /**< Raster pos valid flag */
472 * Depth buffer attributes.
474 struct gl_depthbuffer_attrib
{
475 GLenum Func
; /**< Function for depth buffer compare */
476 GLclampd Clear
; /**< Value to clear depth buffer to */
477 GLboolean Test
; /**< Depth buffering enabled flag */
478 GLboolean Mask
; /**< Depth buffer writable? */
479 GLboolean OcclusionTest
; /**< GL_HP_occlusion_test */
480 GLboolean BoundsTest
; /**< GL_EXT_depth_bounds_test */
481 GLfloat BoundsMin
, BoundsMax
;/**< GL_EXT_depth_bounds_test */
486 * glEnable()/glDisable() attributes.
488 struct gl_enable_attrib
{
490 GLboolean AutoNormal
;
493 GLboolean ColorMaterial
;
494 GLboolean ColorTable
; /* SGI_color_table */
495 GLboolean PostColorMatrixColorTable
; /* SGI_color_table */
496 GLboolean PostConvolutionColorTable
; /* SGI_color_table */
497 GLboolean Convolution1D
;
498 GLboolean Convolution2D
;
499 GLboolean Separable2D
;
505 GLboolean Light
[MAX_LIGHTS
];
507 GLboolean LineSmooth
;
508 GLboolean LineStipple
;
509 GLboolean IndexLogicOp
;
510 GLboolean ColorLogicOp
;
511 GLboolean Map1Color4
;
513 GLboolean Map1Normal
;
514 GLboolean Map1TextureCoord1
;
515 GLboolean Map1TextureCoord2
;
516 GLboolean Map1TextureCoord3
;
517 GLboolean Map1TextureCoord4
;
518 GLboolean Map1Vertex3
;
519 GLboolean Map1Vertex4
;
520 GLboolean Map1Attrib
[16]; /* GL_NV_vertex_program */
521 GLboolean Map2Color4
;
523 GLboolean Map2Normal
;
524 GLboolean Map2TextureCoord1
;
525 GLboolean Map2TextureCoord2
;
526 GLboolean Map2TextureCoord3
;
527 GLboolean Map2TextureCoord4
;
528 GLboolean Map2Vertex3
;
529 GLboolean Map2Vertex4
;
530 GLboolean Map2Attrib
[16]; /* GL_NV_vertex_program */
533 GLboolean PixelTexture
;
534 GLboolean PointSmooth
;
535 GLboolean PolygonOffsetPoint
;
536 GLboolean PolygonOffsetLine
;
537 GLboolean PolygonOffsetFill
;
538 GLboolean PolygonSmooth
;
539 GLboolean PolygonStipple
;
540 GLboolean RescaleNormals
;
543 GLboolean MultisampleEnabled
; /* GL_ARB_multisample */
544 GLboolean SampleAlphaToCoverage
; /* GL_ARB_multisample */
545 GLboolean SampleAlphaToOne
; /* GL_ARB_multisample */
546 GLboolean SampleCoverage
; /* GL_ARB_multisample */
547 GLboolean SampleCoverageInvert
; /* GL_ARB_multisample */
548 GLboolean RasterPositionUnclipped
; /* GL_IBM_rasterpos_clip */
549 GLuint Texture
[MAX_TEXTURE_IMAGE_UNITS
];
550 GLuint TexGen
[MAX_TEXTURE_COORD_UNITS
];
551 /* SGI_texture_color_table */
552 GLboolean TextureColorTable
[MAX_TEXTURE_IMAGE_UNITS
];
553 /* GL_NV_vertex_program */
554 GLboolean VertexProgram
;
555 GLboolean VertexProgramPointSize
;
556 GLboolean VertexProgramTwoSide
;
557 /* GL_ARB_point_sprite / GL_NV_point_sprite */
558 GLboolean PointSprite
;
565 struct gl_eval_attrib
{
570 GLboolean Map1Color4
;
572 GLboolean Map1Normal
;
573 GLboolean Map1TextureCoord1
;
574 GLboolean Map1TextureCoord2
;
575 GLboolean Map1TextureCoord3
;
576 GLboolean Map1TextureCoord4
;
577 GLboolean Map1Vertex3
;
578 GLboolean Map1Vertex4
;
579 GLboolean Map1Attrib
[16]; /* GL_NV_vertex_program */
580 GLboolean Map2Color4
;
582 GLboolean Map2Normal
;
583 GLboolean Map2TextureCoord1
;
584 GLboolean Map2TextureCoord2
;
585 GLboolean Map2TextureCoord3
;
586 GLboolean Map2TextureCoord4
;
587 GLboolean Map2Vertex3
;
588 GLboolean Map2Vertex4
;
589 GLboolean Map2Attrib
[16]; /* GL_NV_vertex_program */
590 GLboolean AutoNormal
;
594 * \name Map Grid endpoints and divisions and calculated du values
598 GLfloat MapGrid1u1
, MapGrid1u2
, MapGrid1du
;
599 GLint MapGrid2un
, MapGrid2vn
;
600 GLfloat MapGrid2u1
, MapGrid2u2
, MapGrid2du
;
601 GLfloat MapGrid2v1
, MapGrid2v2
, MapGrid2dv
;
609 struct gl_fog_attrib
{
610 GLboolean Enabled
; /**< Fog enabled flag */
611 GLfloat Color
[4]; /**< Fog color */
612 GLfloat Density
; /**< Density >= 0.0 */
613 GLfloat Start
; /**< Start distance in eye coords */
614 GLfloat End
; /**< End distance in eye coords */
615 GLfloat Index
; /**< Fog index */
616 GLenum Mode
; /**< Fog mode */
617 GLboolean ColorSumEnabled
;
618 GLenum FogCoordinateSource
; /**< GL_EXT_fog_coord */
625 * Values are always one of GL_FASTEST, GL_NICEST, or GL_DONT_CARE.
627 struct gl_hint_attrib
{
628 GLenum PerspectiveCorrection
;
631 GLenum PolygonSmooth
;
633 GLenum ClipVolumeClipping
; /**< GL_EXT_clip_volume_hint */
634 GLenum TextureCompression
; /**< GL_ARB_texture_compression */
635 GLenum GenerateMipmap
; /**< GL_SGIS_generate_mipmap */
640 * Histogram attributes.
642 struct gl_histogram_attrib
{
643 GLuint Width
; /**< number of table entries */
644 GLint Format
; /**< GL_ALPHA, GL_RGB, etc */
645 GLuint Count
[HISTOGRAM_TABLE_SIZE
][4]; /**< the histogram */
646 GLboolean Sink
; /**< terminate image transfer? */
647 GLubyte RedSize
; /**< Bits per counter */
651 GLubyte LuminanceSize
;
655 struct gl_minmax_attrib
{
658 GLfloat Min
[4], Max
[4]; /**< RGBA */
662 struct gl_convolution_attrib
{
664 GLenum InternalFormat
;
667 GLfloat Filter
[MAX_CONVOLUTION_WIDTH
* MAX_CONVOLUTION_HEIGHT
* 4];
671 #define LIGHT_SPOT 0x1
672 #define LIGHT_LOCAL_VIEWER 0x2
673 #define LIGHT_POSITIONAL 0x4
674 #define LIGHT_NEED_VERTICES (LIGHT_POSITIONAL|LIGHT_LOCAL_VIEWER)
677 * Lighting attributes.
679 struct gl_light_attrib
{
680 struct gl_light Light
[MAX_LIGHTS
]; /**< Array of lights */
681 struct gl_lightmodel Model
; /**< Lighting model */
684 * Must flush FLUSH_VERTICES before referencing:
687 struct gl_material Material
; /**< Includes front & back values */
690 GLboolean Enabled
; /**< Lighting enabled flag */
691 GLenum ShadeModel
; /**< GL_FLAT or GL_SMOOTH */
692 GLenum ColorMaterialFace
; /**< GL_FRONT, BACK or FRONT_AND_BACK */
693 GLenum ColorMaterialMode
; /**< GL_AMBIENT, GL_DIFFUSE, etc */
694 GLuint ColorMaterialBitmask
; /**< bitmask formed from Face and Mode */
695 GLboolean ColorMaterialEnabled
;
697 struct gl_light EnabledList
; /**< List sentinel */
700 * Derived for optimizations:
703 GLboolean _NeedEyeCoords
;
704 GLboolean _NeedVertices
; /**< Use fast shader? */
705 GLuint _Flags
; /**< LIGHT_* flags, see above */
706 GLfloat _BaseColor
[2][3];
714 struct gl_line_attrib
{
715 GLboolean SmoothFlag
; /**< GL_LINE_SMOOTH enabled? */
716 GLboolean StippleFlag
; /**< GL_LINE_STIPPLE enabled? */
717 GLushort StipplePattern
; /**< Stipple pattern */
718 GLint StippleFactor
; /**< Stipple repeat factor */
719 GLfloat Width
; /**< Line width */
720 GLfloat _Width
; /**< Clamped Line width */
724 struct gl_list_attrib
{
729 struct gl_list_opcode
{
731 void (*execute
)( GLcontext
*ctx
, void *data
);
732 void (*destroy
)( GLcontext
*ctx
, void *data
);
733 void (*print
)( GLcontext
*ctx
, void *data
);
736 #define GL_MAX_EXT_OPCODES 16
738 struct gl_list_extensions
{
739 struct gl_list_opcode opcode
[GL_MAX_EXT_OPCODES
];
744 struct gl_multisample_attrib
{
746 GLboolean SampleAlphaToCoverage
;
747 GLboolean SampleAlphaToOne
;
748 GLboolean SampleCoverage
;
749 GLfloat SampleCoverageValue
;
750 GLboolean SampleCoverageInvert
;
757 struct gl_pixel_attrib
{
758 GLenum ReadBuffer
; /**< source buffer for glReadPixels()/glCopyPixels() */
759 GLubyte _ReadSrcMask
; /**< Not really a mask, but like _DrawDestMask
761 * May be: FRONT_LEFT_BIT, BACK_LEFT_BIT,
762 * FRONT_RIGHT_BIT or BACK_RIGHT_BIT. */
763 GLfloat RedBias
, RedScale
;
764 GLfloat GreenBias
, GreenScale
;
765 GLfloat BlueBias
, BlueScale
;
766 GLfloat AlphaBias
, AlphaScale
;
767 GLfloat DepthBias
, DepthScale
;
768 GLint IndexShift
, IndexOffset
;
769 GLboolean MapColorFlag
;
770 GLboolean MapStencilFlag
;
771 GLfloat ZoomX
, ZoomY
;
772 /* XXX move these out of gl_pixel_attrib */
773 GLint MapStoSsize
; /**< Size of each pixel map */
783 GLint MapStoS
[MAX_PIXEL_MAP_TABLE
]; /**< Pixel map tables */
784 GLint MapItoI
[MAX_PIXEL_MAP_TABLE
];
785 GLfloat MapItoR
[MAX_PIXEL_MAP_TABLE
];
786 GLfloat MapItoG
[MAX_PIXEL_MAP_TABLE
];
787 GLfloat MapItoB
[MAX_PIXEL_MAP_TABLE
];
788 GLfloat MapItoA
[MAX_PIXEL_MAP_TABLE
];
789 GLubyte MapItoR8
[MAX_PIXEL_MAP_TABLE
]; /**< converted to 8-bit color */
790 GLubyte MapItoG8
[MAX_PIXEL_MAP_TABLE
];
791 GLubyte MapItoB8
[MAX_PIXEL_MAP_TABLE
];
792 GLubyte MapItoA8
[MAX_PIXEL_MAP_TABLE
];
793 GLfloat MapRtoR
[MAX_PIXEL_MAP_TABLE
];
794 GLfloat MapGtoG
[MAX_PIXEL_MAP_TABLE
];
795 GLfloat MapBtoB
[MAX_PIXEL_MAP_TABLE
];
796 GLfloat MapAtoA
[MAX_PIXEL_MAP_TABLE
];
797 /** GL_EXT_histogram */
798 GLboolean HistogramEnabled
;
799 GLboolean MinMaxEnabled
;
800 /** GL_SGIS_pixel_texture */
801 GLboolean PixelTextureEnabled
;
802 GLenum FragmentRgbSource
;
803 GLenum FragmentAlphaSource
;
804 /** GL_SGI_color_matrix */
805 GLfloat PostColorMatrixScale
[4]; /**< RGBA */
806 GLfloat PostColorMatrixBias
[4]; /**< RGBA */
807 /** GL_SGI_color_table */
808 GLfloat ColorTableScale
[4];
809 GLfloat ColorTableBias
[4];
810 GLboolean ColorTableEnabled
;
811 GLfloat PCCTscale
[4];
813 GLboolean PostConvolutionColorTableEnabled
;
814 GLfloat PCMCTscale
[4];
815 GLfloat PCMCTbias
[4];
816 GLboolean PostColorMatrixColorTableEnabled
;
817 /** GL_SGI_texture_color_table */
818 GLfloat TextureColorTableScale
[4];
819 GLfloat TextureColorTableBias
[4];
821 GLboolean Convolution1DEnabled
;
822 GLboolean Convolution2DEnabled
;
823 GLboolean Separable2DEnabled
;
824 GLfloat ConvolutionBorderColor
[3][4];
825 GLenum ConvolutionBorderMode
[3];
826 GLfloat ConvolutionFilterScale
[3][4];
827 GLfloat ConvolutionFilterBias
[3][4];
828 GLfloat PostConvolutionScale
[4]; /**< RGBA */
829 GLfloat PostConvolutionBias
[4]; /**< RGBA */
836 struct gl_point_attrib
{
837 GLboolean SmoothFlag
; /**< True if GL_POINT_SMOOTH is enabled */
838 GLfloat Size
; /**< User-specified point size */
839 GLfloat _Size
; /**< Size clamped to Const.Min/MaxPointSize */
840 GLfloat Params
[3]; /**< GL_EXT_point_parameters */
841 GLfloat MinSize
, MaxSize
; /**< GL_EXT_point_parameters */
842 GLfloat Threshold
; /**< GL_EXT_point_parameters */
843 GLboolean _Attenuated
; /**< True if Params != [1, 0, 0] */
844 GLboolean PointSprite
; /**< GL_NV_point_sprite / GL_NV_point_sprite */
845 GLboolean CoordReplace
[MAX_TEXTURE_UNITS
]; /**< GL_NV_point_sprite / GL_NV_point_sprite */
846 GLenum SpriteRMode
; /**< GL_NV_point_sprite (only!) */
851 * Polygon attributes.
853 struct gl_polygon_attrib
{
854 GLenum FrontFace
; /**< Either GL_CW or GL_CCW */
855 GLenum FrontMode
; /**< Either GL_POINT, GL_LINE or GL_FILL */
856 GLenum BackMode
; /**< Either GL_POINT, GL_LINE or GL_FILL */
857 GLboolean _FrontBit
; /**< 0=GL_CCW, 1=GL_CW */
858 GLboolean CullFlag
; /**< Culling on/off flag */
859 GLboolean SmoothFlag
; /**< True if GL_POLYGON_SMOOTH is enabled */
860 GLboolean StippleFlag
; /**< True if GL_POLYGON_STIPPLE is enabled */
861 GLenum CullFaceMode
; /**< Culling mode GL_FRONT or GL_BACK */
862 GLfloat OffsetFactor
; /**< Polygon offset factor, from user */
863 GLfloat OffsetUnits
; /**< Polygon offset units, from user */
864 GLboolean OffsetPoint
; /**< Offset in GL_POINT mode */
865 GLboolean OffsetLine
; /**< Offset in GL_LINE mode */
866 GLboolean OffsetFill
; /**< Offset in GL_FILL mode */
871 * Scissor attributes.
873 struct gl_scissor_attrib
{
874 GLboolean Enabled
; /**< Scissor test enabled? */
875 GLint X
, Y
; /**< Lower left corner of box */
876 GLsizei Width
, Height
; /**< Size of box */
881 * Stencil attributes.
883 struct gl_stencil_attrib
{
884 GLboolean Enabled
; /**< Enabled flag */
885 GLboolean TestTwoSide
; /**< GL_EXT_stencil_two_side */
886 GLubyte ActiveFace
; /**< GL_EXT_stencil_two_side (0 or 1) */
887 GLenum Function
[2]; /**< Stencil function */
888 GLenum FailFunc
[2]; /**< Fail function */
889 GLenum ZPassFunc
[2]; /**< Depth buffer pass function */
890 GLenum ZFailFunc
[2]; /**< Depth buffer fail function */
891 GLstencil Ref
[2]; /**< Reference value */
892 GLstencil ValueMask
[2]; /**< Value mask */
893 GLstencil WriteMask
[2]; /**< Write mask */
894 GLstencil Clear
; /**< Clear value */
898 #define NUM_TEXTURE_TARGETS 5 /* 1D, 2D, 3D, CUBE and RECT */
900 #define TEXTURE_1D_INDEX 0
901 #define TEXTURE_2D_INDEX 1
902 #define TEXTURE_3D_INDEX 2
903 #define TEXTURE_CUBE_INDEX 3
904 #define TEXTURE_RECT_INDEX 4
906 /* Texture.Unit[]._ReallyEnabled flags: */
907 #define TEXTURE_1D_BIT (1 << TEXTURE_1D_INDEX)
908 #define TEXTURE_2D_BIT (1 << TEXTURE_2D_INDEX)
909 #define TEXTURE_3D_BIT (1 << TEXTURE_3D_INDEX)
910 #define TEXTURE_CUBE_BIT (1 << TEXTURE_CUBE_INDEX)
911 #define TEXTURE_RECT_BIT (1 << TEXTURE_RECT_INDEX)
914 /* TexGenEnabled flags */
920 /* Bitmap versions of the GL_ constants. */
921 #define TEXGEN_SPHERE_MAP 0x1
922 #define TEXGEN_OBJ_LINEAR 0x2
923 #define TEXGEN_EYE_LINEAR 0x4
924 #define TEXGEN_REFLECTION_MAP_NV 0x8
925 #define TEXGEN_NORMAL_MAP_NV 0x10
927 #define TEXGEN_NEED_NORMALS (TEXGEN_SPHERE_MAP | \
928 TEXGEN_REFLECTION_MAP_NV | \
929 TEXGEN_NORMAL_MAP_NV)
930 #define TEXGEN_NEED_EYE_COORD (TEXGEN_SPHERE_MAP | \
931 TEXGEN_REFLECTION_MAP_NV | \
932 TEXGEN_NORMAL_MAP_NV | \
935 /* A selection of state flags to make driver and module's lives easier. */
936 #define ENABLE_TEXGEN0 0x1
937 #define ENABLE_TEXGEN1 0x2
938 #define ENABLE_TEXGEN2 0x4
939 #define ENABLE_TEXGEN3 0x8
940 #define ENABLE_TEXGEN4 0x10
941 #define ENABLE_TEXGEN5 0x20
942 #define ENABLE_TEXGEN6 0x40
943 #define ENABLE_TEXGEN7 0x80
945 #define ENABLE_TEXMAT0 0x1 /* Ie. not the identity matrix */
946 #define ENABLE_TEXMAT1 0x2
947 #define ENABLE_TEXMAT2 0x4
948 #define ENABLE_TEXMAT3 0x8
949 #define ENABLE_TEXMAT4 0x10
950 #define ENABLE_TEXMAT5 0x20
951 #define ENABLE_TEXMAT6 0x40
952 #define ENABLE_TEXMAT7 0x80
954 #define ENABLE_TEXGEN(i) (ENABLE_TEXGEN0 << (i))
955 #define ENABLE_TEXMAT(i) (ENABLE_TEXMAT0 << (i))
958 * Texel fetch function prototype.
960 * \param texImage texture image.
961 * \param col texel column.
962 * \param row texel row.
963 * \param img texel level.
964 * \param texelOut output texel. If \p texImage is color-index, \p texelOut
965 * returns <tt>GLchan[1]</tt>. If \p texImage is depth, \p texelOut returns
966 * <tt>GLfloat[1]</tt>. Otherwise, \p texelOut returns <tt>GLchan[4]</tt>.
968 typedef void (*FetchTexelFunc
)( const struct gl_texture_image
*texImage
,
969 GLint col
, GLint row
, GLint img
,
973 * Texture format record
975 struct gl_texture_format
{
976 GLint MesaFormat
; /**< One of the MESA_FORMAT_* values */
978 GLenum BaseFormat
; /**< Either GL_ALPHA, GL_INTENSITY, GL_LUMINANCE,
979 * GL_LUMINANCE_ALPHA, GL_RGB, GL_RGBA,
980 * GL_COLOR_INDEX or GL_DEPTH_COMPONENT.
982 GLubyte RedBits
; /**< Bits per texel component */
983 GLubyte GreenBits
; /**< These are just rough approximations for */
984 GLubyte BlueBits
; /**< compressed texture formats. */
986 GLubyte LuminanceBits
;
987 GLubyte IntensityBits
;
991 GLint TexelBytes
; /**< Bytes per texel (0 for compressed formats */
994 * \name Texel fetch function pointers
997 FetchTexelFunc FetchTexel1D
;
998 FetchTexelFunc FetchTexel2D
;
999 FetchTexelFunc FetchTexel3D
;
1005 * Texture image record
1007 struct gl_texture_image
{
1008 GLenum Format
; /**< GL_ALPHA, GL_LUMINANCE, GL_LUMINANCE_ALPHA,
1009 * GL_INTENSITY, GL_RGB, GL_RGBA,
1010 * GL_COLOR_INDEX or GL_DEPTH_COMPONENT only.
1011 * Used for choosing TexEnv arithmetic.
1013 GLint IntFormat
; /**< Internal format as given by the user */
1014 GLuint Border
; /**< 0 or 1 */
1015 GLuint Width
; /**< = 2^WidthLog2 + 2*Border */
1016 GLuint Height
; /**< = 2^HeightLog2 + 2*Border */
1017 GLuint Depth
; /**< = 2^DepthLog2 + 2*Border */
1018 GLuint RowStride
; /**< == Width unless IsClientData and padded */
1019 GLuint Width2
; /**< = Width - 2*Border */
1020 GLuint Height2
; /**< = Height - 2*Border */
1021 GLuint Depth2
; /**< = Depth - 2*Border */
1022 GLuint WidthLog2
; /**< = log2(Width2) */
1023 GLuint HeightLog2
; /**< = log2(Height2) */
1024 GLuint DepthLog2
; /**< = log2(Depth2) */
1025 GLuint MaxLog2
; /**< = MAX(WidthLog2, HeightLog2) */
1026 GLfloat WidthScale
; /**< used for mipmap LOD computation */
1027 GLfloat HeightScale
; /**< used for mipmap LOD computation */
1028 GLfloat DepthScale
; /**< used for mipmap LOD computation */
1029 GLvoid
*Data
; /**< Image data, accessed via FetchTexel() */
1030 GLboolean IsClientData
; /**< Data owned by client? */
1031 GLboolean _IsPowerOfTwo
; /**< Are all dimensions powers of two? */
1033 const struct gl_texture_format
*TexFormat
;
1035 FetchTexelFunc FetchTexel
; /**< Texel fetch function pointer */
1037 GLboolean IsCompressed
; /**< GL_ARB_texture_compression */
1038 GLuint CompressedSize
; /**< GL_ARB_texture_compression */
1041 * \name For device driver:
1044 void *DriverData
; /**< Arbitrary device driver data */
1050 * Texture object record
1052 struct gl_texture_object
{
1053 _glthread_Mutex Mutex
; /**< for thread safety */
1054 GLint RefCount
; /**< reference count */
1055 GLuint Name
; /**< an unsigned integer */
1056 GLenum Target
; /**< GL_TEXTURE_1D, GL_TEXTURE_2D, etc. */
1057 GLfloat Priority
; /**< in [0,1] */
1058 GLfloat BorderColor
[4]; /**< unclamped */
1059 GLchan _BorderChan
[4]; /**< clamped, as GLchan */
1060 /** \name Wrap modes
1061 * Are GL_CLAMP, REPEAT, GL_CLAMP_TO_EDGE, and GL_CLAMP_TO_BORDER_ARB. */
1067 GLenum MinFilter
; /**< minification filter */
1068 GLenum MagFilter
; /**< magnification filter */
1069 GLfloat MinLod
; /**< min lambda, OpenGL 1.2 */
1070 GLfloat MaxLod
; /**< max lambda, OpenGL 1.2 */
1071 GLfloat LodBias
; /**< OpenGL 1.4 */
1072 GLint BaseLevel
; /**< min mipmap level, OpenGL 1.2 */
1073 GLint MaxLevel
; /**< max mipmap level, OpenGL 1.2 */
1074 GLfloat MaxAnisotropy
; /**< GL_EXT_texture_filter_anisotropic */
1075 GLboolean CompareFlag
; /**< GL_SGIX_shadow */
1076 GLenum CompareOperator
; /**< GL_SGIX_shadow */
1077 GLfloat ShadowAmbient
;
1078 GLenum CompareMode
; /**< GL_ARB_shadow */
1079 GLenum CompareFunc
; /**< GL_ARB_shadow */
1080 GLenum DepthMode
; /**< GL_ARB_depth_texture */
1081 GLint _MaxLevel
; /**< actual max mipmap level (q in the spec) */
1082 GLfloat _MaxLambda
; /**< = _MaxLevel - BaseLevel (q - b in spec) */
1083 GLboolean GenerateMipmap
; /**< GL_SGIS_generate_mipmap */
1084 GLboolean _IsPowerOfTwo
; /**< Are all image dimensions powers of two? */
1086 struct gl_texture_image
*Image
[MAX_TEXTURE_LEVELS
];
1089 * \name Texture cube faces
1091 * Image[] is alias for *PosX[MAX_TEXTURE_LEVELS];
1094 struct gl_texture_image
*NegX
[MAX_TEXTURE_LEVELS
];
1095 struct gl_texture_image
*PosY
[MAX_TEXTURE_LEVELS
];
1096 struct gl_texture_image
*NegY
[MAX_TEXTURE_LEVELS
];
1097 struct gl_texture_image
*PosZ
[MAX_TEXTURE_LEVELS
];
1098 struct gl_texture_image
*NegZ
[MAX_TEXTURE_LEVELS
];
1101 /** GL_EXT_paletted_texture */
1102 struct gl_color_table Palette
;
1104 GLboolean Complete
; /**< Is texture object complete? */
1105 struct gl_texture_object
*Next
; /**< Next in linked list */
1108 * \name For device driver
1111 void *DriverData
; /**< Arbitrary device driver data */
1117 * Texture unit record
1119 struct gl_texture_unit
{
1120 GLuint Enabled
; /**< bitmask of TEXTURE_*_BIT flags */
1121 GLuint _ReallyEnabled
; /**< 0 or exactly one of TEXTURE_*_BIT flags */
1123 GLenum EnvMode
; /**< GL_MODULATE, GL_DECAL, GL_BLEND, etc. */
1124 GLfloat EnvColor
[4];
1125 GLuint TexGenEnabled
; /**< Bitwise-OR of [STRQ]_BIT values */
1126 /** \name Tex coord generation mode
1127 * Either GL_OBJECT_LINEAR, GL_EYE_LINEAR or GL_SPHERE_MAP. */
1138 GLuint _GenFlags
; /**< bitwise or of GenBit[STRQ] */
1139 GLfloat ObjectPlaneS
[4];
1140 GLfloat ObjectPlaneT
[4];
1141 GLfloat ObjectPlaneR
[4];
1142 GLfloat ObjectPlaneQ
[4];
1143 GLfloat EyePlaneS
[4];
1144 GLfloat EyePlaneT
[4];
1145 GLfloat EyePlaneR
[4];
1146 GLfloat EyePlaneQ
[4];
1147 GLfloat LodBias
; /**< for biasing mipmap levels */
1150 * \name GL_EXT_texture_env_combine
1153 GLenum CombineModeRGB
; /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */
1154 GLenum CombineModeA
; /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */
1155 GLenum CombineSourceRGB
[3]; /**< GL_PRIMARY_COLOR, GL_TEXTURE, etc. */
1156 GLenum CombineSourceA
[3]; /**< GL_PRIMARY_COLOR, GL_TEXTURE, etc. */
1157 GLenum CombineOperandRGB
[3]; /**< SRC_COLOR, ONE_MINUS_SRC_COLOR, etc */
1158 GLenum CombineOperandA
[3]; /**< SRC_ALPHA, ONE_MINUS_SRC_ALPHA, etc */
1159 GLuint CombineScaleShiftRGB
; /**< 0, 1 or 2 */
1160 GLuint CombineScaleShiftA
; /**< 0, 1 or 2 */
1163 struct gl_texture_object
*Current1D
;
1164 struct gl_texture_object
*Current2D
;
1165 struct gl_texture_object
*Current3D
;
1166 struct gl_texture_object
*CurrentCubeMap
; /**< GL_ARB_texture_cube_map */
1167 struct gl_texture_object
*CurrentRect
; /**< GL_NV_texture_rectangle */
1169 struct gl_texture_object
*_Current
; /**< Points to really enabled tex obj */
1171 struct gl_texture_object Saved1D
; /**< only used by glPush/PopAttrib */
1172 struct gl_texture_object Saved2D
;
1173 struct gl_texture_object Saved3D
;
1174 struct gl_texture_object SavedCubeMap
;
1175 struct gl_texture_object SavedRect
;
1177 /* GL_SGI_texture_color_table */
1178 struct gl_color_table ColorTable
;
1179 struct gl_color_table ProxyColorTable
;
1180 GLboolean ColorTableEnabled
;
1185 * Texture attributes
1187 struct gl_texture_attrib
{
1192 GLuint CurrentUnit
; /**< Active texture unit */
1193 GLuint _EnabledUnits
; /**< one bit set for each really-enabled unit */
1194 GLuint _EnabledCoordUnits
; /**< one bit per enabled coordinate unit */
1195 GLuint _GenFlags
; /**< for texgen */
1196 GLuint _TexGenEnabled
;
1197 GLuint _TexMatEnabled
;
1200 struct gl_texture_unit Unit
[MAX_TEXTURE_UNITS
];
1202 struct gl_texture_object
*Proxy1D
;
1203 struct gl_texture_object
*Proxy2D
;
1204 struct gl_texture_object
*Proxy3D
;
1205 struct gl_texture_object
*ProxyCubeMap
;
1206 struct gl_texture_object
*ProxyRect
;
1208 /** GL_EXT_shared_texture_palette */
1209 GLboolean SharedPalette
;
1210 struct gl_color_table Palette
;
1215 * Transformation attributes.
1217 struct gl_transform_attrib
{
1218 GLenum MatrixMode
; /**< Matrix mode */
1219 GLfloat EyeUserPlane
[MAX_CLIP_PLANES
][4]; /**< User clip planes */
1220 GLfloat _ClipUserPlane
[MAX_CLIP_PLANES
][4]; /**< derived */
1221 GLuint ClipPlanesEnabled
; /**< on/off bitmask */
1222 GLboolean Normalize
; /**< Normalize all normals? */
1223 GLboolean RescaleNormals
; /**< GL_EXT_rescale_normal */
1224 GLboolean RasterPositionUnclipped
; /**< GL_IBM_rasterpos_clip */
1229 * Viewport attributes.
1231 struct gl_viewport_attrib
{
1232 GLint X
, Y
; /**< position */
1233 GLsizei Width
, Height
; /**< size */
1234 GLfloat Near
, Far
; /**< Depth buffer range */
1235 GLmatrix _WindowMap
; /**< Mapping transformation as a matrix. */
1240 * Node for the attribute stack
1242 struct gl_attrib_node
{
1245 struct gl_attrib_node
*next
;
1250 * GL_ARB_vertex_buffer_object buffer object
1252 struct gl_buffer_object
{
1257 GLvoid
*Pointer
; /**< Only valid while buffer is mapped */
1258 GLuint Size
; /**< Size of data array in bytes */
1259 GLubyte
*Data
; /**< The storage */
1265 * Client pixel packing/unpacking attributes
1267 struct gl_pixelstore_attrib
{
1272 GLint ImageHeight
; /**< for GL_EXT_texture3D */
1273 GLint SkipImages
; /**< for GL_EXT_texture3D */
1274 GLboolean SwapBytes
;
1276 GLboolean ClientStorage
; /**< GL_APPLE_client_storage */
1277 GLboolean Invert
; /**< GL_MESA_pack_invert */
1281 #define CA_CLIENT_DATA 0x1 /**< Data not allocated by mesa */
1285 * Client vertex array attributes
1287 struct gl_client_array
{
1290 GLsizei Stride
; /**< user-specified stride */
1291 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
;
1305 struct gl_array_attrib
{
1306 struct gl_client_array Vertex
; /**< client data descriptors */
1307 struct gl_client_array Normal
;
1308 struct gl_client_array Color
;
1309 struct gl_client_array SecondaryColor
;
1310 struct gl_client_array FogCoord
;
1311 struct gl_client_array Index
;
1312 struct gl_client_array TexCoord
[MAX_TEXTURE_COORD_UNITS
];
1313 struct gl_client_array EdgeFlag
;
1315 struct gl_client_array VertexAttrib
[VERT_ATTRIB_MAX
]; /**< GL_NV_vertex_program */
1317 GLint TexCoordInterleaveFactor
;
1318 GLint ActiveTexture
; /**< Client Active Texture */
1319 GLuint LockFirst
; /**< GL_EXT_compiled_vertex_array */
1320 GLuint LockCount
; /**< GL_EXT_compiled_vertex_array */
1322 GLuint _Enabled
; /**< _NEW_ARRAY_* - bit set if array enabled */
1323 GLuint NewState
; /**< _NEW_ARRAY_* */
1325 #if FEATURE_ARB_vertex_buffer_object
1326 struct gl_buffer_object
*NullBufferObj
;
1327 struct gl_buffer_object
*ArrayBufferObj
;
1328 struct gl_buffer_object
*ElementArrayBufferObj
;
1333 struct gl_feedback
{
1335 GLuint _Mask
; /* FB_* bits */
1343 * Selection attributes.
1345 struct gl_selection
{
1346 GLuint
*Buffer
; /**< selection buffer */
1347 GLuint BufferSize
; /**< size of the selection buffer */
1348 GLuint BufferCount
; /**< number of values in the selection buffer */
1349 GLuint Hits
; /**< number of records in the selection buffer */
1350 GLuint NameStackDepth
; /**< name stack depth */
1351 GLuint NameStack
[MAX_NAME_STACK_DEPTH
]; /**< name stack */
1352 GLboolean HitFlag
; /**< hit flag */
1353 GLfloat HitMinZ
; /**< minimum hit depth */
1354 GLfloat HitMaxZ
; /**< maximum hit depth */
1359 * 1-D Evaluator control points
1363 GLuint Order
; /**< Number of control points */
1364 GLfloat u1
, u2
, du
; /**< u1, u2, 1.0/(u2-u1) */
1365 GLfloat
*Points
; /**< Points to contiguous control points */
1370 * 2-D Evaluator control points
1374 GLuint Uorder
; /**< Number of control points in U dimension */
1375 GLuint Vorder
; /**< Number of control points in V dimension */
1378 GLfloat
*Points
; /**< Points to contiguous control points */
1383 * All evaluator control points
1385 struct gl_evaluators
1391 struct gl_1d_map Map1Vertex3
;
1392 struct gl_1d_map Map1Vertex4
;
1393 struct gl_1d_map Map1Index
;
1394 struct gl_1d_map Map1Color4
;
1395 struct gl_1d_map Map1Normal
;
1396 struct gl_1d_map Map1Texture1
;
1397 struct gl_1d_map Map1Texture2
;
1398 struct gl_1d_map Map1Texture3
;
1399 struct gl_1d_map Map1Texture4
;
1400 struct gl_1d_map Map1Attrib
[16]; /**< GL_NV_vertex_program */
1407 struct gl_2d_map Map2Vertex3
;
1408 struct gl_2d_map Map2Vertex4
;
1409 struct gl_2d_map Map2Index
;
1410 struct gl_2d_map Map2Color4
;
1411 struct gl_2d_map Map2Normal
;
1412 struct gl_2d_map Map2Texture1
;
1413 struct gl_2d_map Map2Texture2
;
1414 struct gl_2d_map Map2Texture3
;
1415 struct gl_2d_map Map2Texture4
;
1416 struct gl_2d_map Map2Attrib
[16]; /**< GL_NV_vertex_program */
1422 * NV_fragment_program runtime state
1426 GLfloat Temporaries
[MAX_NV_FRAGMENT_PROGRAM_TEMPS
][4];
1427 GLfloat Inputs
[MAX_NV_FRAGMENT_PROGRAM_INPUTS
][4];
1428 GLfloat Outputs
[MAX_NV_FRAGMENT_PROGRAM_OUTPUTS
][4];
1429 GLuint CondCodes
[4];
1434 * Names of the various vertex/fragment register files
1438 PROGRAM_TEMPORARY
= 10,
1441 PROGRAM_LOCAL_PARAM
,
1443 PROGRAM_NAMED_PARAM
,
1449 /* Vertex and fragment instructions */
1450 struct vp_instruction
;
1451 struct fp_instruction
;
1453 struct program_parameter_list
;
1457 * Base class for any kind of program object
1462 GLubyte
*String
; /* Null-terminated program text */
1464 GLenum Format
; /* String encoding format */
1467 GLfloat LocalParams
[MAX_PROGRAM_LOCAL_PARAMS
][4];
1468 GLuint NumInstructions
; /* GL_ARB_vertex/fragment_program */
1469 GLuint NumTemporaries
;
1470 GLuint NumParameters
;
1471 GLuint NumAttributes
;
1472 GLuint NumAddressRegs
;
1476 /** Vertex program object */
1477 struct vertex_program
1479 struct program Base
; /* base class */
1480 struct vp_instruction
*Instructions
; /* Compiled instructions */
1481 GLboolean IsPositionInvariant
; /* GL_NV_vertex_program1_1 */
1482 GLuint InputsRead
; /* Bitmask of which input regs are read */
1483 GLuint OutputsWritten
; /* Bitmask of which output regs are written to */
1487 /** Fragment program object */
1488 struct fragment_program
1490 struct program Base
; /**< base class */
1491 struct fp_instruction
*Instructions
; /**< Compiled instructions */
1492 GLuint InputsRead
; /**< Bitmask of which input regs are read */
1493 GLuint OutputsWritten
; /**< Bitmask of which output regs are written to */
1494 GLuint TexturesUsed
[MAX_TEXTURE_IMAGE_UNITS
]; /**< TEXTURE_x_INDEX bitmask */
1495 GLuint NumAluInstructions
; /**< GL_ARB_fragment_program */
1496 GLuint NumTexInstructions
;
1497 GLuint NumTexIndirections
;
1498 struct program_parameter_list
*Parameters
; /**< array [NumParameters] */
1503 * State common to vertex and fragment programs.
1505 struct program_state
{
1506 GLint ErrorPos
; /* GL_PROGRAM_ERROR_POSITION_NV */
1507 const char *ErrorString
; /* GL_PROGRAM_ERROR_STRING_NV */
1512 * State vars for GL_NV_vertex_program
1514 struct vertex_program_state
1516 GLboolean Enabled
; /**< GL_VERTEX_PROGRAM_NV */
1517 GLboolean PointSizeEnabled
; /**< GL_VERTEX_PROGRAM_POINT_SIZE_NV */
1518 GLboolean TwoSideEnabled
; /**< GL_VERTEX_PROGRAM_TWO_SIDE_NV */
1519 struct vertex_program
*Current
; /**< ptr to currently bound program */
1521 GLenum TrackMatrix
[MAX_NV_VERTEX_PROGRAM_PARAMS
/ 4];
1522 GLenum TrackMatrixTransform
[MAX_NV_VERTEX_PROGRAM_PARAMS
/ 4];
1524 GLfloat Parameters
[MAX_NV_VERTEX_PROGRAM_PARAMS
][4]; /* Env params */
1525 /* Only used during program execution (may be moved someday): */
1526 GLfloat Temporaries
[MAX_NV_VERTEX_PROGRAM_TEMPS
][4];
1527 GLfloat Inputs
[MAX_NV_VERTEX_PROGRAM_INPUTS
][4];
1528 GLfloat Outputs
[MAX_NV_VERTEX_PROGRAM_OUTPUTS
][4];
1529 GLint AddressReg
[4];
1531 #if FEATURE_MESA_program_debug
1532 GLprogramcallbackMESA Callback
;
1533 GLvoid
*CallbackData
;
1534 GLboolean CallbackEnabled
;
1535 GLuint CurrentPosition
;
1541 * State for GL_ARB/NV_fragment_program
1543 struct fragment_program_state
1545 GLboolean Enabled
; /* GL_VERTEX_PROGRAM_NV */
1546 struct fragment_program
*Current
; /* ptr to currently bound program */
1547 struct fp_machine Machine
; /* machine state */
1548 GLfloat Parameters
[MAX_NV_FRAGMENT_PROGRAM_PARAMS
][4]; /* Env params */
1550 #if FEATURE_MESA_program_debug
1551 GLprogramcallbackMESA Callback
;
1552 GLvoid
*CallbackData
;
1553 GLboolean CallbackEnabled
;
1554 GLuint CurrentPosition
;
1560 * State for GL_ARB_occlusion_query
1562 struct occlusion_state
1565 GLuint CurrentQueryObject
;
1566 GLuint PassedCounter
;
1567 struct _mesa_HashTable
*QueryObjects
;
1572 * State which can be shared by multiple contexts:
1574 struct gl_shared_state
1576 _glthread_Mutex Mutex
; /**< for thread safety */
1577 GLint RefCount
; /**< Reference count */
1578 struct _mesa_HashTable
*DisplayList
; /**< Display lists hash table */
1579 struct _mesa_HashTable
*TexObjects
; /**< Texture objects hash table */
1580 struct gl_texture_object
*TexObjectList
;/**< Linked list of texture objects */
1583 * \name Default texture objects (shared by all multi-texture units)
1586 struct gl_texture_object
*Default1D
;
1587 struct gl_texture_object
*Default2D
;
1588 struct gl_texture_object
*Default3D
;
1589 struct gl_texture_object
*DefaultCubeMap
;
1590 struct gl_texture_object
*DefaultRect
;
1594 * \name GL_NV_vertex/_program
1597 struct _mesa_HashTable
*Programs
;
1598 #if FEATURE_ARB_vertex_program
1599 struct program
*DefaultVertexProgram
;
1601 #if FEATURE_ARB_fragment_program
1602 struct program
*DefaultFragmentProgram
;
1606 #if FEATURE_ARB_vertex_buffer_object
1607 struct _mesa_HashTable
*BufferObjects
;
1610 void *DriverData
; /**< Device driver shared state */
1617 * A "frame buffer" is a color buffer and its optional ancillary buffers:
1618 * depth, accum, stencil, and software-simulated alpha buffers.
1619 * In C++ terms, think of this as a base class from which device drivers
1620 * will make derived classes.
1622 struct gl_frame_buffer
1624 GLvisual Visual
; /**< The corresponding visual */
1626 GLuint Width
, Height
; /**< size of frame buffer in pixels */
1628 GLboolean UseSoftwareDepthBuffer
;
1629 GLboolean UseSoftwareAccumBuffer
;
1630 GLboolean UseSoftwareStencilBuffer
;
1631 GLboolean UseSoftwareAlphaBuffers
;
1633 /** \name Software depth (aka Z) buffer */
1635 GLvoid
*DepthBuffer
; /**< array [Width*Height] of GLushort or GLuint*/
1638 /** \name Software stencil buffer */
1640 GLstencil
*Stencil
; /**< array [Width*Height] of GLstencil values */
1643 /** \name Software accumulation buffer */
1645 GLaccum
*Accum
; /**< array [4*Width*Height] of GLaccum values */
1648 /** \name Software alpha planes */
1650 GLvoid
*FrontLeftAlpha
; /**< array [Width*Height] of GLubyte */
1651 GLvoid
*BackLeftAlpha
; /**< array [Width*Height] of GLubyte */
1652 GLvoid
*FrontRightAlpha
; /**< array [Width*Height] of GLubyte */
1653 GLvoid
*BackRightAlpha
; /**< array [Width*Height] of GLubyte */
1657 * \name Drawing bounds
1659 * Intersection of window size and scissor box
1662 GLint _Xmin
; /**< inclusive */
1663 GLint _Ymin
; /**< inclusive */
1664 GLint _Xmax
; /**< exclusive */
1665 GLint _Ymax
; /**< exclusive */
1671 * Constants which may be overridden by device driver during context creation
1672 * but are never changed after that.
1676 GLint MaxTextureLevels
; /**< Maximum number of allowed mipmap levels. */
1677 GLint Max3DTextureLevels
; /**< Maximum number of allowed mipmap levels for 3D texture targets. */
1678 GLint MaxCubeTextureLevels
; /**< Maximum number of allowed mipmap levels for GL_ARB_texture_cube_map */
1679 GLint MaxTextureRectSize
; /* GL_NV_texture_rectangle */
1680 GLuint MaxTextureCoordUnits
;
1681 GLuint MaxTextureImageUnits
;
1682 GLuint MaxTextureUnits
; /* = MAX(CoordUnits, ImageUnits) */
1683 GLfloat MaxTextureMaxAnisotropy
; /* GL_EXT_texture_filter_anisotropic */
1684 GLfloat MaxTextureLodBias
; /* GL_EXT_texture_lod_bias */
1685 GLuint MaxArrayLockSize
;
1687 GLfloat MinPointSize
, MaxPointSize
; /* aliased */
1688 GLfloat MinPointSizeAA
, MaxPointSizeAA
; /* antialiased */
1689 GLfloat PointSizeGranularity
;
1690 GLfloat MinLineWidth
, MaxLineWidth
; /* aliased */
1691 GLfloat MinLineWidthAA
, MaxLineWidthAA
; /* antialiased */
1692 GLfloat LineWidthGranularity
;
1693 GLuint NumAuxBuffers
;
1694 GLuint MaxColorTableSize
;
1695 GLuint MaxConvolutionWidth
;
1696 GLuint MaxConvolutionHeight
;
1697 GLuint MaxClipPlanes
;
1699 GLfloat MaxShininess
; /* GL_NV_light_max_exponent */
1700 GLfloat MaxSpotExponent
; /* GL_NV_light_max_exponent */
1701 /* GL_ARB_vertex_program */
1702 GLuint MaxVertexProgramInstructions
;
1703 GLuint MaxVertexProgramAttribs
;
1704 GLuint MaxVertexProgramTemps
;
1705 GLuint MaxVertexProgramLocalParams
;
1706 GLuint MaxVertexProgramEnvParams
;
1707 GLuint MaxVertexProgramAddressRegs
;
1708 /* GL_ARB_fragment_program */
1709 GLuint MaxFragmentProgramInstructions
;
1710 GLuint MaxFragmentProgramAttribs
;
1711 GLuint MaxFragmentProgramTemps
;
1712 GLuint MaxFragmentProgramLocalParams
;
1713 GLuint MaxFragmentProgramEnvParams
;
1714 GLuint MaxFragmentProgramAddressRegs
;
1715 GLuint MaxFragmentProgramAluInstructions
;
1716 GLuint MaxFragmentProgramTexInstructions
;
1717 GLuint MaxFragmentProgramTexIndirections
;
1718 /* vertex or fragment program */
1719 GLuint MaxProgramMatrices
;
1720 GLuint MaxProgramMatrixStackDepth
;
1725 * List of extensions.
1727 struct gl_extensions
1730 * \name Flags to quickly test if certain extensions are available.
1732 * Not every extension needs to have such a flag, but it's encouraged.
1735 GLboolean dummy
; /* don't remove this! */
1736 GLboolean ARB_depth_texture
;
1737 GLboolean ARB_fragment_program
;
1738 GLboolean ARB_imaging
;
1739 GLboolean ARB_multisample
;
1740 GLboolean ARB_multitexture
;
1741 GLboolean ARB_occlusion_query
;
1742 GLboolean ARB_point_sprite
;
1743 GLboolean ARB_shadow
;
1744 GLboolean ARB_texture_border_clamp
;
1745 GLboolean ARB_texture_compression
;
1746 GLboolean ARB_texture_cube_map
;
1747 GLboolean ARB_texture_env_combine
;
1748 GLboolean ARB_texture_env_crossbar
;
1749 GLboolean ARB_texture_env_dot3
;
1750 GLboolean ARB_texture_mirrored_repeat
;
1751 GLboolean ARB_texture_non_power_of_two
;
1752 GLboolean ARB_vertex_buffer_object
;
1753 GLboolean ARB_vertex_program
;
1754 GLboolean ARB_window_pos
;
1755 GLboolean ATI_texture_mirror_once
;
1756 GLboolean ATI_texture_env_combine3
;
1757 GLboolean EXT_blend_color
;
1758 GLboolean EXT_blend_func_separate
;
1759 GLboolean EXT_blend_logic_op
;
1760 GLboolean EXT_blend_minmax
;
1761 GLboolean EXT_blend_subtract
;
1762 GLboolean EXT_convolution
;
1763 GLboolean EXT_compiled_vertex_array
;
1764 GLboolean EXT_depth_bounds_test
;
1765 GLboolean EXT_fog_coord
;
1766 GLboolean EXT_histogram
;
1767 GLboolean EXT_multi_draw_arrays
;
1768 GLboolean EXT_paletted_texture
;
1769 GLboolean EXT_point_parameters
;
1770 GLboolean EXT_shadow_funcs
;
1771 GLboolean EXT_secondary_color
;
1772 GLboolean EXT_shared_texture_palette
;
1773 GLboolean EXT_stencil_wrap
;
1774 GLboolean EXT_stencil_two_side
;
1775 GLboolean EXT_texture3D
;
1776 GLboolean EXT_texture_compression_s3tc
;
1777 GLboolean EXT_texture_env_add
;
1778 GLboolean EXT_texture_env_combine
;
1779 GLboolean EXT_texture_env_dot3
;
1780 GLboolean EXT_texture_filter_anisotropic
;
1781 GLboolean EXT_texture_lod_bias
;
1782 GLboolean EXT_texture_mirror_clamp
;
1783 GLboolean EXT_vertex_array_set
;
1784 GLboolean HP_occlusion_test
;
1785 GLboolean IBM_rasterpos_clip
;
1786 GLboolean IBM_multimode_draw_arrays
;
1787 GLboolean MESA_pack_invert
;
1788 GLboolean MESA_packed_depth_stencil
;
1789 GLboolean MESA_program_debug
;
1790 GLboolean MESA_resize_buffers
;
1791 GLboolean MESA_ycbcr_texture
;
1792 GLboolean NV_blend_square
;
1793 GLboolean NV_fragment_program
;
1794 GLboolean NV_point_sprite
;
1795 GLboolean NV_texture_rectangle
;
1796 GLboolean NV_vertex_program
;
1797 GLboolean NV_vertex_program1_1
;
1798 GLboolean SGI_color_matrix
;
1799 GLboolean SGI_color_table
;
1800 GLboolean SGI_texture_color_table
;
1801 GLboolean SGIS_generate_mipmap
;
1802 GLboolean SGIS_pixel_texture
;
1803 GLboolean SGIS_texture_edge_clamp
;
1804 GLboolean SGIX_depth_texture
;
1805 GLboolean SGIX_pixel_texture
;
1806 GLboolean SGIX_shadow
;
1807 GLboolean SGIX_shadow_ambient
; /* or GL_ARB_shadow_ambient */
1808 GLboolean TDFX_texture_compression_FXT1
;
1809 GLboolean APPLE_client_storage
;
1811 /* The extension string */
1812 const GLubyte
*String
;
1817 * A stack of matrices (projection, modelview, color, texture, etc).
1821 GLmatrix
*Top
; /**< points into Stack */
1822 GLmatrix
*Stack
; /**< array [MaxDepth] of GLmatrix */
1823 GLuint Depth
; /**< 0 <= Depth < MaxDepth */
1824 GLuint MaxDepth
; /**< size of Stack[] array */
1825 GLuint DirtyFlag
; /**< _NEW_MODELVIEW or _NEW_PROJECTION, for example */
1830 * \name Bits for image transfer operations
1832 * \sa __GLcontextRec::ImageTransferState.
1835 #define IMAGE_SCALE_BIAS_BIT 0x1
1836 #define IMAGE_SHIFT_OFFSET_BIT 0x2
1837 #define IMAGE_MAP_COLOR_BIT 0x4
1838 #define IMAGE_COLOR_TABLE_BIT 0x8
1839 #define IMAGE_CONVOLUTION_BIT 0x10
1840 #define IMAGE_POST_CONVOLUTION_SCALE_BIAS 0x20
1841 #define IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT 0x40
1842 #define IMAGE_COLOR_MATRIX_BIT 0x80
1843 #define IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT 0x100
1844 #define IMAGE_HISTOGRAM_BIT 0x200
1845 #define IMAGE_MIN_MAX_BIT 0x400
1847 /** Transfer ops up to convolution */
1848 #define IMAGE_PRE_CONVOLUTION_BITS (IMAGE_SCALE_BIAS_BIT | \
1849 IMAGE_SHIFT_OFFSET_BIT | \
1850 IMAGE_MAP_COLOR_BIT | \
1851 IMAGE_COLOR_TABLE_BIT)
1853 /** Transfer ops after convolution */
1854 #define IMAGE_POST_CONVOLUTION_BITS (IMAGE_POST_CONVOLUTION_SCALE_BIAS | \
1855 IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT | \
1856 IMAGE_COLOR_MATRIX_BIT | \
1857 IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT |\
1858 IMAGE_HISTOGRAM_BIT | \
1864 * \name Bits to indicate what state has changed.
1869 #define _NEW_MODELVIEW 0x1 /**< __GLcontextRec::ModelView */
1870 #define _NEW_PROJECTION 0x2 /**< __GLcontextRec::Projection */
1871 #define _NEW_TEXTURE_MATRIX 0x4 /**< __GLcontextRec::TextureMatrix */
1872 #define _NEW_COLOR_MATRIX 0x8 /**< __GLcontextRec::ColorMatrix */
1873 #define _NEW_ACCUM 0x10 /**< __GLcontextRec::Accum */
1874 #define _NEW_COLOR 0x20 /**< __GLcontextRec::Color */
1875 #define _NEW_DEPTH 0x40 /**< __GLcontextRec::Depth */
1876 #define _NEW_EVAL 0x80 /**< __GLcontextRec::Eval, __GLcontextRec::EvalMap */
1877 #define _NEW_FOG 0x100 /**< __GLcontextRec::Fog */
1878 #define _NEW_HINT 0x200 /**< __GLcontextRec::Hint */
1879 #define _NEW_LIGHT 0x400 /**< __GLcontextRec::Light */
1880 #define _NEW_LINE 0x800 /**< __GLcontextRec::Line */
1881 #define _NEW_PIXEL 0x1000 /**< __GLcontextRec::Pixel */
1882 #define _NEW_POINT 0x2000 /**< __GLcontextRec::Point */
1883 #define _NEW_POLYGON 0x4000 /**< __GLcontextRec::Polygon */
1884 #define _NEW_POLYGONSTIPPLE 0x8000 /**< __GLcontextRec::PolygonStipple */
1885 #define _NEW_SCISSOR 0x10000 /**< __GLcontextRec::Scissor */
1886 #define _NEW_STENCIL 0x20000 /**< __GLcontextRec::Stencil */
1887 #define _NEW_TEXTURE 0x40000 /**< __GLcontextRec::Texture */
1888 #define _NEW_TRANSFORM 0x80000 /**< __GLcontextRec::Transform */
1889 #define _NEW_VIEWPORT 0x100000 /**< __GLcontextRec::Viewport */
1890 #define _NEW_PACKUNPACK 0x200000 /**< __GLcontextRec::Pack, __GLcontextRec::Unpack */
1891 #define _NEW_ARRAY 0x400000 /**< __GLcontextRec::Array */
1892 #define _NEW_RENDERMODE 0x800000 /**< __GLcontextRec::RenderMode, __GLcontextRec::Feedback, __GLcontextRec::Select */
1893 #define _NEW_BUFFERS 0x1000000 /**< __GLcontextRec::Visual, __GLcontextRec::DrawBuffer, */
1894 #define _NEW_MULTISAMPLE 0x2000000 /**< __GLcontextRec::Multisample */
1895 #define _NEW_TRACK_MATRIX 0x4000000 /**< __GLcontextRec::VertexProgram */
1896 #define _NEW_PROGRAM 0x8000000 /**< __GLcontextRec::VertexProgram */
1902 * \name Bits to track array state changes
1904 * Also used to summarize array enabled.
1907 #define _NEW_ARRAY_VERTEX VERT_BIT_POS
1908 #define _NEW_ARRAY_WEIGHT VERT_BIT_WEIGHT
1909 #define _NEW_ARRAY_NORMAL VERT_BIT_NORMAL
1910 #define _NEW_ARRAY_COLOR0 VERT_BIT_COLOR0
1911 #define _NEW_ARRAY_COLOR1 VERT_BIT_COLOR1
1912 #define _NEW_ARRAY_FOGCOORD VERT_BIT_FOG
1913 #define _NEW_ARRAY_INDEX VERT_BIT_SIX
1914 #define _NEW_ARRAY_EDGEFLAG VERT_BIT_SEVEN
1915 #define _NEW_ARRAY_TEXCOORD_0 VERT_BIT_TEX0
1916 #define _NEW_ARRAY_TEXCOORD_1 VERT_BIT_TEX1
1917 #define _NEW_ARRAY_TEXCOORD_2 VERT_BIT_TEX2
1918 #define _NEW_ARRAY_TEXCOORD_3 VERT_BIT_TEX3
1919 #define _NEW_ARRAY_TEXCOORD_4 VERT_BIT_TEX4
1920 #define _NEW_ARRAY_TEXCOORD_5 VERT_BIT_TEX5
1921 #define _NEW_ARRAY_TEXCOORD_6 VERT_BIT_TEX6
1922 #define _NEW_ARRAY_TEXCOORD_7 VERT_BIT_TEX7
1923 #define _NEW_ARRAY_ATTRIB_0 0x1 /* alias conventional arrays */
1924 #define _NEW_ARRAY_ALL 0xffffffff
1927 #define _NEW_ARRAY_TEXCOORD(i) (_NEW_ARRAY_TEXCOORD_0 << (i))
1928 #define _NEW_ARRAY_ATTRIB(i) (_NEW_ARRAY_ATTRIB_0 << (i))
1933 * \name A bunch of flags that we think might be useful to drivers.
1935 * Set in the __GLcontextRec::_TriangleCaps bitfield.
1938 #define DD_FLATSHADE 0x1
1939 #define DD_SEPARATE_SPECULAR 0x2
1940 #define DD_TRI_CULL_FRONT_BACK 0x4 /* special case on some hw */
1941 #define DD_TRI_LIGHT_TWOSIDE 0x8
1942 #define DD_TRI_UNFILLED 0x10
1943 #define DD_TRI_SMOOTH 0x20
1944 #define DD_TRI_STIPPLE 0x40
1945 #define DD_TRI_OFFSET 0x80
1946 #define DD_LINE_SMOOTH 0x100
1947 #define DD_LINE_STIPPLE 0x200
1948 #define DD_LINE_WIDTH 0x400
1949 #define DD_POINT_SMOOTH 0x800
1950 #define DD_POINT_SIZE 0x1000
1951 #define DD_POINT_ATTEN 0x2000
1956 * \name Define the state changes under which each of these bits might change
1959 #define _DD_NEW_FLATSHADE _NEW_LIGHT
1960 #define _DD_NEW_SEPARATE_SPECULAR (_NEW_LIGHT | _NEW_FOG)
1961 #define _DD_NEW_TRI_CULL_FRONT_BACK _NEW_POLYGON
1962 #define _DD_NEW_TRI_LIGHT_TWOSIDE _NEW_LIGHT
1963 #define _DD_NEW_TRI_UNFILLED _NEW_POLYGON
1964 #define _DD_NEW_TRI_SMOOTH _NEW_POLYGON
1965 #define _DD_NEW_TRI_STIPPLE _NEW_POLYGON
1966 #define _DD_NEW_TRI_OFFSET _NEW_POLYGON
1967 #define _DD_NEW_LINE_SMOOTH _NEW_LINE
1968 #define _DD_NEW_LINE_STIPPLE _NEW_LINE
1969 #define _DD_NEW_LINE_WIDTH _NEW_LINE
1970 #define _DD_NEW_POINT_SMOOTH _NEW_POINT
1971 #define _DD_NEW_POINT_SIZE _NEW_POINT
1972 #define _DD_NEW_POINT_ATTEN _NEW_POINT
1976 #define _MESA_NEW_NEED_EYE_COORDS (_NEW_LIGHT | \
1981 #define _MESA_NEW_NEED_NORMALS (_NEW_LIGHT | \
1984 #define _IMAGE_NEW_TRANSFER_STATE (_NEW_PIXEL | _NEW_COLOR_MATRIX)
1990 * Forward declaration of display list data types:
1993 typedef union node Node
;
1996 /* This has to be included here. */
2000 #define NUM_VERTEX_FORMAT_ENTRIES (sizeof(GLvertexformat) / sizeof(void *))
2003 * Core Mesa's support for tnl modules:
2005 struct gl_tnl_module
{
2007 * Vertex format to be lazily swapped into current dispatch.
2009 GLvertexformat
*Current
;
2012 * \name Record of functions swapped out.
2013 * On restore, only need to swap these functions back in.
2016 void *Swapped
[NUM_VERTEX_FORMAT_ENTRIES
][2];
2025 * This is the central context data structure for Mesa. Almost all
2026 * OpenGL state is contained in this structure.
2027 * Think of this as a base class from which device drivers will derive
2030 struct __GLcontextRec
{
2032 * \name OS related interfaces.
2034 * These \b must be the first members of this structure, because they are
2035 * exposed to the outside world (i.e. GLX extension).
2038 __GLimports imports
;
2039 __GLexports exports
;
2042 /** State possibly shared with other contexts in the address space */
2043 struct gl_shared_state
*Shared
;
2045 /** \name API function pointer tables */
2047 struct _glapi_table
*Save
; /**< Display list save functions */
2048 struct _glapi_table
*Exec
; /**< Execute functions */
2049 struct _glapi_table
*CurrentDispatch
; /**< == Save or Exec !! */
2052 GLboolean ExecPrefersFloat
; /**< What preference for color conversion? */
2053 GLboolean SavePrefersFloat
;
2056 GLframebuffer
*DrawBuffer
; /**< buffer for writing */
2057 GLframebuffer
*ReadBuffer
; /**< buffer for reading */
2060 * Device driver function pointer table
2062 struct dd_function_table Driver
;
2064 void *DriverCtx
; /**< Points to device driver context/state */
2065 void *DriverMgrCtx
; /**< Points to device driver manager (optional)*/
2067 /** Core/Driver constants */
2068 struct gl_constants Const
;
2070 /** \name The various 4x4 matrix stacks */
2072 struct matrix_stack ModelviewMatrixStack
;
2073 struct matrix_stack ProjectionMatrixStack
;
2074 struct matrix_stack ColorMatrixStack
;
2075 struct matrix_stack TextureMatrixStack
[MAX_TEXTURE_COORD_UNITS
];
2076 struct matrix_stack ProgramMatrixStack
[MAX_PROGRAM_MATRICES
];
2077 struct matrix_stack
*CurrentStack
; /**< Points to one of the above stacks */
2080 /** Combined modelview and projection matrix */
2081 GLmatrix _ModelProjectMatrix
;
2083 /** \name Display lists */
2085 GLuint CallDepth
; /**< Current recursion calling depth */
2086 GLboolean ExecuteFlag
; /**< Execute GL commands? */
2087 GLboolean CompileFlag
; /**< Compile GL commands into display list? */
2088 Node
*CurrentListPtr
; /**< Head of list being compiled */
2089 GLuint CurrentListNum
; /**< Number of the list being compiled */
2090 Node
*CurrentBlock
; /**< Pointer to current block of nodes */
2091 GLuint CurrentPos
; /**< Index into current block of nodes */
2095 struct gl_extensions Extensions
;
2097 /** \name Renderer attribute stack */
2099 GLuint AttribStackDepth
;
2100 struct gl_attrib_node
*AttribStack
[MAX_ATTRIB_STACK_DEPTH
];
2103 /** \name Renderer attribute groups
2105 * We define a struct for each attribute group to make pushing and popping
2106 * attributes easy. Also it's a good organization.
2109 struct gl_accum_attrib Accum
; /**< Accumulation buffer attributes */
2110 struct gl_colorbuffer_attrib Color
; /**< Color buffers attributes */
2111 struct gl_current_attrib Current
; /**< Current attributes */
2112 struct gl_depthbuffer_attrib Depth
; /**< Depth buffer attributes */
2113 struct gl_eval_attrib Eval
; /**< Eval attributes */
2114 struct gl_fog_attrib Fog
; /**< Fog attributes */
2115 struct gl_hint_attrib Hint
; /**< Hint attributes */
2116 struct gl_light_attrib Light
; /**< Light attributes */
2117 struct gl_line_attrib Line
; /**< Line attributes */
2118 struct gl_list_attrib List
; /**< List attributes */
2119 struct gl_multisample_attrib Multisample
;
2120 struct gl_pixel_attrib Pixel
; /**< Pixel attributes */
2121 struct gl_point_attrib Point
; /**< Point attributes */
2122 struct gl_polygon_attrib Polygon
; /**< Polygon attributes */
2123 GLuint PolygonStipple
[32]; /**< Polygon stipple */
2124 struct gl_scissor_attrib Scissor
; /**< Scissor attributes */
2125 struct gl_stencil_attrib Stencil
; /**< Stencil buffer attributes */
2126 struct gl_texture_attrib Texture
; /**< Texture attributes */
2127 struct gl_transform_attrib Transform
; /**< Transformation attributes */
2128 struct gl_viewport_attrib Viewport
; /**< Viewport attributes */
2131 /** \name Other attribute groups */
2133 struct gl_histogram_attrib Histogram
;
2134 struct gl_minmax_attrib MinMax
;
2135 struct gl_convolution_attrib Convolution1D
;
2136 struct gl_convolution_attrib Convolution2D
;
2137 struct gl_convolution_attrib Separable2D
;
2140 /** \name Client attribute stack */
2142 GLuint ClientAttribStackDepth
;
2143 struct gl_attrib_node
*ClientAttribStack
[MAX_CLIENT_ATTRIB_STACK_DEPTH
];
2146 /** \name Client attribute groups */
2148 struct gl_array_attrib Array
; /**< Vertex arrays */
2149 struct gl_pixelstore_attrib Pack
; /**< Pixel packing */
2150 struct gl_pixelstore_attrib Unpack
; /**< Pixel unpacking */
2152 struct gl_evaluators EvalMap
; /**< All evaluators */
2153 struct gl_feedback Feedback
; /**< Feedback */
2154 struct gl_selection Select
; /**< Selection */
2156 struct gl_color_table ColorTable
; /**< Pre-convolution */
2157 struct gl_color_table ProxyColorTable
; /**< Pre-convolution */
2158 struct gl_color_table PostConvolutionColorTable
;
2159 struct gl_color_table ProxyPostConvolutionColorTable
;
2160 struct gl_color_table PostColorMatrixColorTable
;
2161 struct gl_color_table ProxyPostColorMatrixColorTable
;
2163 struct program_state Program
; /**< for vertex or fragment progs */
2164 struct vertex_program_state VertexProgram
; /**< GL_NV_vertex_program */
2165 struct fragment_program_state FragmentProgram
; /**< GL_NV_fragment_program */
2167 struct occlusion_state Occlusion
; /**< GL_ARB_occlusion_query */
2169 GLenum ErrorValue
; /**< Last error code */
2170 GLenum RenderMode
; /**< either GL_RENDER, GL_SELECT, GL_FEEDBACK */
2171 GLuint NewState
; /**< bitwise-or of _NEW_* flags */
2174 /** \name Derived */
2176 GLuint _TriangleCaps
; /**< bitwise-or of DD_* flags */
2177 GLuint _ImageTransferState
;/**< bitwise-or of IMAGE_*_BIT flags */
2178 GLfloat _EyeZDir
[3];
2179 GLfloat _ModelViewInvScale
;
2180 GLuint _NeedEyeCoords
;
2181 GLuint _ForceEyeCoords
;
2182 GLboolean _RotateMode
;
2183 GLenum _CurrentProgram
; /* currently executing program */
2185 struct gl_shine_tab
*_ShineTable
[2]; /**< Active shine tables */
2186 struct gl_shine_tab
*_ShineTabList
; /**< MRU list of inactive shine tables */
2189 struct gl_list_extensions listext
; /**< driver dlist extensions */
2192 GLboolean OcclusionResult
; /**< for GL_HP_occlusion_test */
2193 GLboolean OcclusionResultSaved
; /**< for GL_HP_occlusion_test */
2194 GLuint _Facing
; /**< This is a hack for 2-sided stencil test.
2196 * We don't have a better way to communicate this value from
2197 * swrast_setup to swrast. */
2200 /** \name Z buffer stuff */
2202 GLuint DepthMax
; /**< Max depth buffer value */
2203 GLfloat DepthMaxF
; /**< Float max depth buffer value */
2204 GLfloat MRD
; /**< minimum resolvable difference in Z values */
2207 /** Should 3Dfx Glide driver catch signals? */
2208 GLboolean CatchSignals
;
2210 /** \name For debugging/development only */
2212 GLboolean FirstTimeCurrent
;
2215 /** Dither disable via MESA_NO_DITHER env var */
2218 /** Core tnl module support */
2219 struct gl_tnl_module TnlModule
;
2222 * \name Hooks for module contexts.
2224 * These will eventually live in the driver or elsewhere.
2227 void *swrast_context
;
2228 void *swsetup_context
;
2229 void *swtnl_context
;
2231 void *acache_context
;
2237 /** The string names for GL_POINT, GL_LINE_LOOP, etc */
2238 extern const char *_mesa_prim_name
[GL_POLYGON
+4];
2242 extern int MESA_VERBOSE
;
2243 extern int MESA_DEBUG_FLAGS
;
2245 # define MESA_VERBOSE 0
2246 # define MESA_DEBUG_FLAGS 0
2254 VERBOSE_VARRAY
= 0x0001,
2255 VERBOSE_TEXTURE
= 0x0002,
2256 VERBOSE_IMMEDIATE
= 0x0004,
2257 VERBOSE_PIPELINE
= 0x0008,
2258 VERBOSE_DRIVER
= 0x0010,
2259 VERBOSE_STATE
= 0x0020,
2260 VERBOSE_API
= 0x0040,
2261 VERBOSE_DISPLAY_LIST
= 0x0100,
2262 VERBOSE_LIGHTING
= 0x0200,
2263 VERBOSE_PRIMS
= 0x0400,
2264 VERBOSE_VERTS
= 0x0800
2269 DEBUG_ALWAYS_FLUSH
= 0x1
2274 #define Elements(x) sizeof(x)/sizeof(*(x))
2277 #endif /* TYPES_H */