1 /* $Id: mtypes.h,v 1.48 2001/06/26 21:15:35 brianp Exp $ */
4 * Mesa 3-D graphics library
7 * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
9 * Permission is hereby granted, free of charge, to any person obtaining a
10 * copy of this software and associated documentation files (the "Software"),
11 * to deal in the Software without restriction, including without limitation
12 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 * and/or sell copies of the Software, and to permit persons to whom the
14 * Software is furnished to do so, subject to the following conditions:
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
23 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33 #include "config.h" /* Hardwired parameters */
34 #include "glapitable.h"
37 #include "math/m_matrix.h" /* GLmatrix */
39 #if defined(MESA_TRACE)
40 #include "Trace/tr_context.h"
44 /* Please try to mark derived values with a leading underscore ('_').
48 * Color channel data type:
51 typedef GLubyte GLchan
;
53 #define CHAN_MAXF 255.0F
54 #define CHAN_TYPE GL_UNSIGNED_BYTE
56 typedef GLushort GLchan
;
57 #define CHAN_MAX 65535
58 #define CHAN_MAXF 65535.0F
59 #define CHAN_TYPE GL_UNSIGNED_SHORT
61 typedef GLfloat GLchan
;
63 #define CHAN_MAXF 1.0F
64 #define CHAN_TYPE GL_FLOAT
66 #error illegal number of color channel bits
71 * Accumulation buffer data type:
74 typedef GLbyte GLaccum
;
76 typedef GLshort 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 typedef GLuint GLdepth
; /* Must be 32-bits! */
103 * Fixed point data type:
110 * Some forward type declarations
112 struct _mesa_HashTable
;
113 struct gl_texture_image
;
114 struct gl_texture_object
;
115 typedef struct __GLcontextRec GLcontext
;
116 typedef struct __GLcontextModesRec GLvisual
;
117 typedef struct gl_frame_buffer GLframebuffer
;
121 /* Maximum number of temporary vertices required for clipping. (Used
122 * in array_cache and tnl modules).
124 #define MAX_CLIPPED_VERTICES ((2 * (6 + MAX_CLIP_PLANES))+1)
127 /* Data structure for color tables */
128 struct gl_color_table
{
129 GLenum Format
; /* GL_ALPHA, GL_RGB, GL_RGB, etc */
131 GLuint Size
; /* number of entries (rows) in table */
132 GLvoid
*Table
; /* either GLfloat * or GLchan * */
133 GLboolean FloatTable
; /* are entries stored as floats? */
138 GLubyte LuminanceSize
;
139 GLubyte IntensitySize
;
144 * Bit flags used for updating material values.
146 #define FRONT_AMBIENT_BIT 0x1
147 #define BACK_AMBIENT_BIT 0x2
148 #define FRONT_DIFFUSE_BIT 0x4
149 #define BACK_DIFFUSE_BIT 0x8
150 #define FRONT_SPECULAR_BIT 0x10
151 #define BACK_SPECULAR_BIT 0x20
152 #define FRONT_EMISSION_BIT 0x40
153 #define BACK_EMISSION_BIT 0x80
154 #define FRONT_SHININESS_BIT 0x100
155 #define BACK_SHININESS_BIT 0x200
156 #define FRONT_INDEXES_BIT 0x400
157 #define BACK_INDEXES_BIT 0x800
159 #define FRONT_MATERIAL_BITS (FRONT_EMISSION_BIT | FRONT_AMBIENT_BIT | \
160 FRONT_DIFFUSE_BIT | FRONT_SPECULAR_BIT | \
161 FRONT_SHININESS_BIT | FRONT_INDEXES_BIT)
163 #define BACK_MATERIAL_BITS (BACK_EMISSION_BIT | BACK_AMBIENT_BIT | \
164 BACK_DIFFUSE_BIT | BACK_SPECULAR_BIT | \
165 BACK_SHININESS_BIT | BACK_INDEXES_BIT)
167 #define ALL_MATERIAL_BITS (FRONT_MATERIAL_BITS | BACK_MATERIAL_BITS)
172 * Specular exponent and material shininess lookup table sizes:
174 #define EXP_TABLE_SIZE 512
175 #define SHINE_TABLE_SIZE 256
177 struct gl_shine_tab
{
178 struct gl_shine_tab
*next
, *prev
;
179 GLfloat tab
[SHINE_TABLE_SIZE
+1];
186 struct gl_light
*next
; /* double linked list with sentinel */
187 struct gl_light
*prev
;
189 GLfloat Ambient
[4]; /* ambient color */
190 GLfloat Diffuse
[4]; /* diffuse color */
191 GLfloat Specular
[4]; /* specular color */
192 GLfloat EyePosition
[4]; /* position in eye coordinates */
193 GLfloat EyeDirection
[4]; /* spotlight dir in eye coordinates */
194 GLfloat SpotExponent
;
195 GLfloat SpotCutoff
; /* in degress */
196 GLfloat _CosCutoff
; /* = MAX(0, cos(SpotCutoff)) */
197 GLfloat ConstantAttenuation
;
198 GLfloat LinearAttenuation
;
199 GLfloat QuadraticAttenuation
;
200 GLboolean Enabled
; /* On/off flag */
203 GLuint _Flags
; /* State */
205 GLfloat _Position
[4]; /* position in eye/obj coordinates */
206 GLfloat _VP_inf_norm
[3]; /* Norm direction to infinite light */
207 GLfloat _h_inf_norm
[3]; /* Norm( _VP_inf_norm + <0,0,1> ) */
208 GLfloat _NormDirection
[4]; /* normalized spotlight direction */
209 GLfloat _VP_inf_spot_attenuation
;
211 GLfloat _SpotExpTable
[EXP_TABLE_SIZE
][2]; /* to replace a pow() call */
212 GLfloat _MatAmbient
[2][3]; /* material ambient * light ambient */
213 GLfloat _MatDiffuse
[2][3]; /* material diffuse * light diffuse */
214 GLfloat _MatSpecular
[2][3]; /* material spec * light specular */
215 GLfloat _dli
; /* CI diffuse light intensity */
216 GLfloat _sli
; /* CI specular light intensity */
220 struct gl_lightmodel
{
221 GLfloat Ambient
[4]; /* ambient color */
222 GLboolean LocalViewer
; /* Local (or infinite) view point? */
223 GLboolean TwoSide
; /* Two (or one) sided lighting? */
224 GLenum ColorControl
; /* either GL_SINGLE_COLOR */
225 /* or GL_SEPARATE_SPECULAR_COLOR */
236 GLfloat AmbientIndex
; /* for color index lighting */
237 GLfloat DiffuseIndex
; /* for color index lighting */
238 GLfloat SpecularIndex
; /* for color index lighting */
243 * Attribute structures:
244 * We define a struct for each attribute group to make pushing and
245 * popping attributes easy. Also it's a good organization.
247 struct gl_accum_attrib
{
248 GLfloat ClearColor
[4]; /* Accumulation buffer clear color */
253 * Used in DrawDestMask below
255 #define FRONT_LEFT_BIT 1
256 #define FRONT_RIGHT_BIT 2
257 #define BACK_LEFT_BIT 4
258 #define BACK_RIGHT_BIT 8
261 struct gl_colorbuffer_attrib
{
262 GLuint ClearIndex
; /* Index to use for glClear */
263 GLchan ClearColor
[4]; /* Color to use for glClear */
265 GLuint IndexMask
; /* Color index write mask */
266 GLubyte ColorMask
[4]; /* Each flag is 0xff or 0x0 */
268 GLenum DrawBuffer
; /* Which buffer to draw into */
269 GLenum DriverDrawBuffer
; /* Current device driver dest buffer */
270 GLboolean MultiDrawBuffer
; /* Drawing to mutliple buffers? */
271 GLubyte DrawDestMask
; /* bitwise-OR of bitflags above */
274 GLboolean AlphaEnabled
; /* Alpha test enabled flag */
275 GLenum AlphaFunc
; /* Alpha test function */
276 GLchan AlphaRef
; /* Alpha ref value as GLchan */
279 GLboolean BlendEnabled
; /* Blending enabled flag */
280 GLenum BlendSrcRGB
; /* Blending source operator */
281 GLenum BlendDstRGB
; /* Blending destination operator */
282 GLenum BlendSrcA
; /* GL_INGR_blend_func_separate */
283 GLenum BlendDstA
; /* GL_INGR_blend_func_separate */
284 GLenum BlendEquation
;
285 GLfloat BlendColor
[4];
288 GLenum LogicOp
; /* Logic operator */
289 GLboolean IndexLogicOpEnabled
; /* Color index logic op enabled flag */
290 GLboolean ColorLogicOpEnabled
; /* RGBA logic op enabled flag */
292 GLboolean DitherFlag
; /* Dither enable flag */
296 struct gl_current_attrib
{
297 /* These values valid only when FLUSH_VERTICES has been called.
299 GLfloat Normal
[3]; /* Current vertex normal */
300 GLfloat Color
[4]; /* Current RGBA color */
301 GLfloat SecondaryColor
[4]; /* Current secondary color */
302 GLfloat FogCoord
; /* Current Fog coord */
303 GLuint Index
; /* Current color index */
304 GLboolean EdgeFlag
; /* Current edge flag */
305 GLfloat Texcoord
[MAX_TEXTURE_UNITS
][4]; /* Current texture coords */
307 /* These values are always valid.
309 GLfloat RasterPos
[4]; /* Current raster position */
310 GLfloat RasterDistance
; /* Current raster distance */
311 GLfloat RasterColor
[4]; /* Current raster color */
312 GLfloat RasterSecondaryColor
[4]; /* Current rast 2ndary color */
313 GLuint RasterIndex
; /* Current raster index */
314 GLfloat
*RasterTexCoord
; /* Current raster texcoord*/
315 GLfloat RasterMultiTexCoord
[MAX_TEXTURE_UNITS
][4];
316 GLfloat RasterFogCoord
;
317 GLboolean RasterPosValid
; /* Raster po valid flag */
321 struct gl_depthbuffer_attrib
{
322 GLenum Func
; /* Function for depth buffer compare */
323 GLfloat Clear
; /* Value to clear depth buffer to */
324 GLboolean Test
; /* Depth buffering enabled flag */
325 GLboolean Mask
; /* Depth buffer writable? */
326 GLboolean OcclusionTest
; /* GL_HP_occlusion_test */
330 struct gl_enable_attrib
{
332 GLboolean AutoNormal
;
334 GLboolean ClipPlane
[MAX_CLIP_PLANES
];
335 GLboolean ColorMaterial
;
336 GLboolean Convolution1D
;
337 GLboolean Convolution2D
;
338 GLboolean Separable2D
;
344 GLboolean Light
[MAX_LIGHTS
];
346 GLboolean LineSmooth
;
347 GLboolean LineStipple
;
348 GLboolean IndexLogicOp
;
349 GLboolean ColorLogicOp
;
350 GLboolean Map1Color4
;
352 GLboolean Map1Normal
;
353 GLboolean Map1TextureCoord1
;
354 GLboolean Map1TextureCoord2
;
355 GLboolean Map1TextureCoord3
;
356 GLboolean Map1TextureCoord4
;
357 GLboolean Map1Vertex3
;
358 GLboolean Map1Vertex4
;
359 GLboolean Map2Color4
;
361 GLboolean Map2Normal
;
362 GLboolean Map2TextureCoord1
;
363 GLboolean Map2TextureCoord2
;
364 GLboolean Map2TextureCoord3
;
365 GLboolean Map2TextureCoord4
;
366 GLboolean Map2Vertex3
;
367 GLboolean Map2Vertex4
;
370 GLboolean PixelTexture
;
371 GLboolean PointSmooth
;
372 GLboolean PolygonOffsetPoint
;
373 GLboolean PolygonOffsetLine
;
374 GLboolean PolygonOffsetFill
;
375 GLboolean PolygonSmooth
;
376 GLboolean PolygonStipple
;
377 GLboolean RescaleNormals
;
380 GLboolean MultisampleEnabled
; /* GL_ARB_multisample */
381 GLboolean SampleAlphaToCoverage
; /* GL_ARB_multisample */
382 GLboolean SampleAlphaToOne
; /* GL_ARB_multisample */
383 GLboolean SampleCoverage
; /* GL_ARB_multisample */
384 GLboolean SampleCoverageInvert
; /* GL_ARB_multisample */
385 GLboolean RasterPositionUnclipped
; /* GL_IBM_rasterpos_clip */
386 GLuint Texture
[MAX_TEXTURE_UNITS
];
387 GLuint TexGen
[MAX_TEXTURE_UNITS
];
391 struct gl_eval_attrib
{
393 GLboolean Map1Color4
;
395 GLboolean Map1Normal
;
396 GLboolean Map1TextureCoord1
;
397 GLboolean Map1TextureCoord2
;
398 GLboolean Map1TextureCoord3
;
399 GLboolean Map1TextureCoord4
;
400 GLboolean Map1Vertex3
;
401 GLboolean Map1Vertex4
;
402 GLboolean Map2Color4
;
404 GLboolean Map2Normal
;
405 GLboolean Map2TextureCoord1
;
406 GLboolean Map2TextureCoord2
;
407 GLboolean Map2TextureCoord3
;
408 GLboolean Map2TextureCoord4
;
409 GLboolean Map2Vertex3
;
410 GLboolean Map2Vertex4
;
411 GLboolean AutoNormal
;
412 /* Map Grid endpoints and divisions and calculated du values */
414 GLfloat MapGrid1u1
, MapGrid1u2
, MapGrid1du
;
415 GLint MapGrid2un
, MapGrid2vn
;
416 GLfloat MapGrid2u1
, MapGrid2u2
, MapGrid2du
;
417 GLfloat MapGrid2v1
, MapGrid2v2
, MapGrid2dv
;
421 struct gl_fog_attrib
{
422 GLboolean Enabled
; /* Fog enabled flag */
423 GLfloat Color
[4]; /* Fog color */
424 GLfloat Density
; /* Density >= 0.0 */
425 GLfloat Start
; /* Start distance in eye coords */
426 GLfloat End
; /* End distance in eye coords */
427 GLfloat Index
; /* Fog index */
428 GLenum Mode
; /* Fog mode */
429 GLboolean ColorSumEnabled
;
430 GLenum FogCoordinateSource
; /* GL_EXT_fog_coord */
434 struct gl_hint_attrib
{
435 /* always one of GL_FASTEST, GL_NICEST, or GL_DONT_CARE */
436 GLenum PerspectiveCorrection
;
439 GLenum PolygonSmooth
;
441 GLenum ClipVolumeClipping
; /* GL_EXT_clip_volume_hint */
442 GLenum TextureCompression
; /* GL_ARB_texture_compression */
443 GLenum GenerateMipmap
; /* GL_SGIS_generate_mipmap */
447 struct gl_histogram_attrib
{
448 GLuint Width
; /* number of table entries */
449 GLint Format
; /* GL_ALPHA, GL_RGB, etc */
450 GLuint Count
[HISTOGRAM_TABLE_SIZE
][4]; /* the histogram */
451 GLboolean Sink
; /* terminate image transfer? */
452 GLubyte RedSize
; /* Bits per counter */
456 GLubyte LuminanceSize
;
460 struct gl_minmax_attrib
{
463 GLfloat Min
[4], Max
[4]; /* RGBA */
467 struct gl_convolution_attrib
{
469 GLenum InternalFormat
;
472 GLfloat Filter
[MAX_CONVOLUTION_WIDTH
* MAX_CONVOLUTION_HEIGHT
* 4];
476 struct gl_light_attrib
{
477 struct gl_light Light
[MAX_LIGHTS
]; /* Array of lights */
478 struct gl_lightmodel Model
; /* Lighting model */
480 /* Must flush FLUSH_VERTICES before referencing:
482 struct gl_material Material
[2]; /* Material 0=front, 1=back */
484 GLboolean Enabled
; /* Lighting enabled flag */
485 GLenum ShadeModel
; /* GL_FLAT or GL_SMOOTH */
486 GLenum ColorMaterialFace
; /* GL_FRONT, BACK or FRONT_AND_BACK */
487 GLenum ColorMaterialMode
; /* GL_AMBIENT, GL_DIFFUSE, etc */
488 GLuint ColorMaterialBitmask
; /* bitmask formed from Face and Mode */
489 GLboolean ColorMaterialEnabled
;
491 struct gl_light EnabledList
; /* List sentinel */
493 /* Derived for optimizations: */
494 GLboolean _NeedVertices
; /* Use fast shader? */
495 GLuint _Flags
; /* LIGHT_* flags, see below */
496 GLfloat _BaseColor
[2][3];
497 GLfloat _BaseAlpha
[2];
501 #define LIGHT_SPOT 0x1
502 #define LIGHT_LOCAL_VIEWER 0x2
503 #define LIGHT_POSITIONAL 0x4
505 #define LIGHT_NEED_VERTICES (LIGHT_POSITIONAL|LIGHT_LOCAL_VIEWER)
507 struct gl_line_attrib
{
508 GLboolean SmoothFlag
; /* GL_LINE_SMOOTH enabled? */
509 GLboolean StippleFlag
; /* GL_LINE_STIPPLE enabled? */
510 GLushort StipplePattern
; /* Stipple pattern */
511 GLint StippleFactor
; /* Stipple repeat factor */
512 GLfloat Width
; /* Line width */
513 GLfloat _Width
; /* Clamped Line width */
517 struct gl_list_attrib
{
521 struct gl_list_opcode
{
523 void (*execute
)( GLcontext
*ctx
, void *data
);
524 void (*destroy
)( GLcontext
*ctx
, void *data
);
525 void (*print
)( GLcontext
*ctx
, void *data
);
528 #define GL_MAX_EXT_OPCODES 16
530 struct gl_list_extensions
{
531 struct gl_list_opcode opcode
[GL_MAX_EXT_OPCODES
];
536 struct gl_multisample_attrib
{
538 GLboolean SampleAlphaToCoverage
;
539 GLboolean SampleAlphaToOne
;
540 GLboolean SampleCoverage
;
541 GLfloat SampleCoverageValue
;
542 GLboolean SampleCoverageInvert
;
546 struct gl_pixel_attrib
{
547 GLenum ReadBuffer
; /* src buffer for glRead/CopyPixels */
548 GLenum DriverReadBuffer
; /* Driver's current source buffer */
549 GLfloat RedBias
, RedScale
;
550 GLfloat GreenBias
, GreenScale
;
551 GLfloat BlueBias
, BlueScale
;
552 GLfloat AlphaBias
, AlphaScale
;
553 GLfloat DepthBias
, DepthScale
;
554 GLint IndexShift
, IndexOffset
;
555 GLboolean MapColorFlag
;
556 GLboolean MapStencilFlag
;
557 GLfloat ZoomX
, ZoomY
;
558 GLint MapStoSsize
; /* Size of each pixel map */
568 GLint MapStoS
[MAX_PIXEL_MAP_TABLE
]; /* Pixel map tables */
569 GLint MapItoI
[MAX_PIXEL_MAP_TABLE
];
570 GLfloat MapItoR
[MAX_PIXEL_MAP_TABLE
];
571 GLfloat MapItoG
[MAX_PIXEL_MAP_TABLE
];
572 GLfloat MapItoB
[MAX_PIXEL_MAP_TABLE
];
573 GLfloat MapItoA
[MAX_PIXEL_MAP_TABLE
];
574 GLubyte MapItoR8
[MAX_PIXEL_MAP_TABLE
]; /* converted to 8-bit color */
575 GLubyte MapItoG8
[MAX_PIXEL_MAP_TABLE
];
576 GLubyte MapItoB8
[MAX_PIXEL_MAP_TABLE
];
577 GLubyte MapItoA8
[MAX_PIXEL_MAP_TABLE
];
578 GLfloat MapRtoR
[MAX_PIXEL_MAP_TABLE
];
579 GLfloat MapGtoG
[MAX_PIXEL_MAP_TABLE
];
580 GLfloat MapBtoB
[MAX_PIXEL_MAP_TABLE
];
581 GLfloat MapAtoA
[MAX_PIXEL_MAP_TABLE
];
582 /* GL_EXT_histogram */
583 GLboolean HistogramEnabled
;
584 GLboolean MinMaxEnabled
;
585 /* GL_SGIS_pixel_texture */
586 GLboolean PixelTextureEnabled
;
587 GLenum FragmentRgbSource
;
588 GLenum FragmentAlphaSource
;
589 /* GL_SGI_color_matrix */
590 GLfloat PostColorMatrixScale
[4]; /* RGBA */
591 GLfloat PostColorMatrixBias
[4]; /* RGBA */
592 /* GL_SGI_color_table */
593 GLfloat ColorTableScale
[4];
594 GLfloat ColorTableBias
[4];
595 GLboolean ColorTableEnabled
;
596 GLfloat PCCTscale
[4];
598 GLboolean PostConvolutionColorTableEnabled
;
599 GLfloat PCMCTscale
[4];
600 GLfloat PCMCTbias
[4];
601 GLboolean PostColorMatrixColorTableEnabled
;
603 GLboolean Convolution1DEnabled
;
604 GLboolean Convolution2DEnabled
;
605 GLboolean Separable2DEnabled
;
606 GLfloat ConvolutionBorderColor
[3][4];
607 GLenum ConvolutionBorderMode
[3];
608 GLfloat ConvolutionFilterScale
[3][4];
609 GLfloat ConvolutionFilterBias
[3][4];
610 GLfloat PostConvolutionScale
[4]; /* RGBA */
611 GLfloat PostConvolutionBias
[4]; /* RGBA */
615 struct gl_point_attrib
{
616 GLboolean SmoothFlag
; /* True if GL_POINT_SMOOTH is enabled */
617 GLboolean SpriteMode
; /* GL_MESA_sprite_point extension */
618 GLfloat Size
; /* User-specified point size */
619 GLfloat _Size
; /* Size clamped to Const.Min/MaxPointSize */
620 GLfloat Params
[3]; /* GL_EXT_point_parameters */
621 GLfloat MinSize
, MaxSize
; /* GL_EXT_point_parameters */
622 GLfloat Threshold
; /* GL_EXT_point_parameters */
623 GLboolean _Attenuated
; /* True if Params != [1, 0, 0] */
627 struct gl_polygon_attrib
{
628 GLenum FrontFace
; /* Either GL_CW or GL_CCW */
629 GLenum FrontMode
; /* Either GL_POINT, GL_LINE or GL_FILL */
630 GLenum BackMode
; /* Either GL_POINT, GL_LINE or GL_FILL */
631 GLboolean _FrontBit
; /* */
632 GLboolean CullFlag
; /* Culling on/off flag */
633 GLboolean SmoothFlag
; /* True if GL_POLYGON_SMOOTH is enabled */
634 GLboolean StippleFlag
; /* True if GL_POLYGON_STIPPLE is enabled */
635 GLenum CullFaceMode
; /* Culling mode GL_FRONT or GL_BACK */
636 GLfloat OffsetFactor
; /* Polygon offset factor, from user */
637 GLfloat OffsetUnits
; /* Polygon offset units, from user */
638 GLfloat OffsetMRD
; /* = OffsetUnits * visual->MRD */
639 GLboolean OffsetPoint
; /* Offset in GL_POINT mode */
640 GLboolean OffsetLine
; /* Offset in GL_LINE mode */
641 GLboolean OffsetFill
; /* Offset in GL_FILL mode */
642 GLboolean _OffsetAny
;
646 struct gl_scissor_attrib
{
647 GLboolean Enabled
; /* Scissor test enabled? */
648 GLint X
, Y
; /* Lower left corner of box */
649 GLsizei Width
, Height
; /* Size of box */
653 struct gl_stencil_attrib
{
654 GLboolean Enabled
; /* Enabled flag */
655 GLenum Function
; /* Stencil function */
656 GLenum FailFunc
; /* Fail function */
657 GLenum ZPassFunc
; /* Depth buffer pass function */
658 GLenum ZFailFunc
; /* Depth buffer fail function */
659 GLstencil Ref
; /* Reference value */
660 GLstencil ValueMask
; /* Value mask */
661 GLstencil Clear
; /* Clear value */
662 GLstencil WriteMask
; /* Write mask */
666 /* TexGenEnabled flags */
672 /* Texture Enabled flags */
673 #define TEXTURE0_1D 0x1 /* Texture unit 0 (default) */
674 #define TEXTURE0_2D 0x2
675 #define TEXTURE0_3D 0x4
676 #define TEXTURE0_CUBE 0x8
677 #define TEXTURE0_ANY (TEXTURE0_1D | TEXTURE0_2D | TEXTURE0_3D | TEXTURE0_CUBE)
678 #define TEXTURE1_1D (TEXTURE0_1D << 4) /* Texture unit 1 */
679 #define TEXTURE1_2D (TEXTURE0_2D << 4)
680 #define TEXTURE1_3D (TEXTURE0_3D << 4)
681 #define TEXTURE1_CUBE (TEXTURE0_CUBE << 4)
682 #define TEXTURE1_ANY (TEXTURE1_1D | TEXTURE1_2D | TEXTURE1_3D | TEXTURE1_CUBE)
683 #define TEXTURE2_1D (TEXTURE0_1D << 8) /* Texture unit 2 */
684 #define TEXTURE2_2D (TEXTURE0_2D << 8)
685 #define TEXTURE2_3D (TEXTURE0_3D << 8)
686 #define TEXTURE2_CUBE (TEXTURE0_CUBE << 8)
687 #define TEXTURE2_ANY (TEXTURE2_1D | TEXTURE2_2D | TEXTURE2_3D | TEXTURE2_CUBE)
688 #define TEXTURE3_1D (TEXTURE0_1D << 12) /* Texture unit 3 */
689 #define TEXTURE3_2D (TEXTURE0_2D << 12)
690 #define TEXTURE3_3D (TEXTURE0_3D << 12)
691 #define TEXTURE3_CUBE (TEXTURE0_CUBE << 12)
692 #define TEXTURE3_ANY (TEXTURE3_1D | TEXTURE3_2D | TEXTURE3_3D | TEXTURE3_CUBE)
693 #define TEXTURE4_1D (TEXTURE0_1D << 16) /* Texture unit 4 */
694 #define TEXTURE4_2D (TEXTURE0_2D << 16)
695 #define TEXTURE4_3D (TEXTURE0_3D << 16)
696 #define TEXTURE4_CUBE (TEXTURE0_CUBE << 16)
697 #define TEXTURE5_ANY (TEXTURE3_1D | TEXTURE3_2D | TEXTURE3_3D | TEXTURE3_CUBE)
698 #define TEXTURE5_1D (TEXTURE0_1D << 20) /* Texture unit 5 */
699 #define TEXTURE5_2D (TEXTURE0_2D << 20)
700 #define TEXTURE5_3D (TEXTURE0_3D << 20)
701 #define TEXTURE5_CUBE (TEXTURE0_CUBE << 20)
702 #define TEXTURE5_ANY (TEXTURE3_1D | TEXTURE3_2D | TEXTURE3_3D | TEXTURE3_CUBE)
703 #define TEXTURE6_1D (TEXTURE0_1D << 24) /* Texture unit 6 */
704 #define TEXTURE6_2D (TEXTURE0_2D << 24)
705 #define TEXTURE6_3D (TEXTURE0_3D << 24)
706 #define TEXTURE6_CUBE (TEXTURE0_CUBE << 24)
707 #define TEXTURE6_ANY (TEXTURE3_1D | TEXTURE3_2D | TEXTURE3_3D | TEXTURE3_CUBE)
708 #define TEXTURE7_1D (TEXTURE0_1D << 28) /* Texture unit 7 */
709 #define TEXTURE7_2D (TEXTURE0_2D << 28)
710 #define TEXTURE7_3D (TEXTURE0_3D << 28)
711 #define TEXTURE7_CUBE (TEXTURE0_CUBE << 28)
712 #define TEXTURE7_ANY (TEXTURE3_1D | TEXTURE3_2D | TEXTURE3_3D | TEXTURE3_CUBE)
714 /* Bitmap versions of the GL_ constants.
716 #define TEXGEN_SPHERE_MAP 0x1
717 #define TEXGEN_OBJ_LINEAR 0x2
718 #define TEXGEN_EYE_LINEAR 0x4
719 #define TEXGEN_REFLECTION_MAP_NV 0x8
720 #define TEXGEN_NORMAL_MAP_NV 0x10
722 #define TEXGEN_NEED_NORMALS (TEXGEN_SPHERE_MAP | \
723 TEXGEN_REFLECTION_MAP_NV | \
724 TEXGEN_NORMAL_MAP_NV)
725 #define TEXGEN_NEED_EYE_COORD (TEXGEN_SPHERE_MAP | \
726 TEXGEN_REFLECTION_MAP_NV | \
727 TEXGEN_NORMAL_MAP_NV | \
732 /* A selection of state flags to make driver and module's lives easier.
734 #define ENABLE_TEXGEN0 0x1
735 #define ENABLE_TEXGEN1 0x2
736 #define ENABLE_TEXGEN2 0x4
737 #define ENABLE_TEXGEN3 0x8
738 #define ENABLE_TEXGEN4 0x10
739 #define ENABLE_TEXGEN5 0x20
740 #define ENABLE_TEXGEN6 0x40
741 #define ENABLE_TEXGEN7 0x80
743 #define ENABLE_TEXMAT0 0x1 /* Ie. not the identity matrix */
744 #define ENABLE_TEXMAT1 0x2
745 #define ENABLE_TEXMAT2 0x4
746 #define ENABLE_TEXMAT3 0x8
747 #define ENABLE_TEXMAT4 0x10
748 #define ENABLE_TEXMAT5 0x20
749 #define ENABLE_TEXMAT6 0x40
750 #define ENABLE_TEXMAT7 0x80
752 #define ENABLE_TEXGEN(i) (ENABLE_TEXGEN0 << (i))
753 #define ENABLE_TEXMAT(i) (ENABLE_TEXMAT0 << (i))
756 * If teximage is color-index, texelOut returns GLchan[1].
757 * If teximage is depth, texelOut returns GLfloat[1].
758 * Otherwise, texelOut returns GLchan[4].
760 typedef void (*FetchTexelFunc
)( const struct gl_texture_image
*texImage
,
761 GLint col
, GLint row
, GLint img
,
764 /* Texture format record */
765 struct gl_texture_format
{
766 GLint MesaFormat
; /* One of the MESA_FORMAT_* values */
768 GLenum BaseFormat
; /* Either GL_ALPHA, GL_INTENSITY, GL_LUMINANCE,
769 * GL_LUMINANCE_ALPHA, GL_RGB, GL_RGBA,
770 * GL_COLOR_INDEX or GL_DEPTH_COMPONENT.
772 GLenum Type
; /* Internal type as GL enum value */
774 GLubyte RedBits
; /* Bits per texel component */
778 GLubyte LuminanceBits
;
779 GLubyte IntensityBits
;
785 FetchTexelFunc FetchTexel1D
; /* Texel fetch function pointers */
786 FetchTexelFunc FetchTexel2D
;
787 FetchTexelFunc FetchTexel3D
;
790 /* Texture image record */
791 struct gl_texture_image
{
792 GLenum Format
; /* GL_ALPHA, GL_LUMINANCE, GL_LUMINANCE_ALPHA,
793 * GL_INTENSITY, GL_RGB, GL_RGBA,
794 * GL_COLOR_INDEX or GL_DEPTH_COMPONENT only.
796 GLint IntFormat
; /* Internal format as given by the user */
797 GLuint Border
; /* 0 or 1 */
798 GLuint Width
; /* = 2^WidthLog2 + 2*Border */
799 GLuint Height
; /* = 2^HeightLog2 + 2*Border */
800 GLuint Depth
; /* = 2^DepthLog2 + 2*Border */
801 GLuint Width2
; /* = Width - 2*Border */
802 GLuint Height2
; /* = Height - 2*Border */
803 GLuint Depth2
; /* = Depth - 2*Border */
804 GLuint WidthLog2
; /* = log2(Width2) */
805 GLuint HeightLog2
; /* = log2(Height2) */
806 GLuint DepthLog2
; /* = log2(Depth2) */
807 GLuint MaxLog2
; /* = MAX(WidthLog2, HeightLog2) */
808 GLvoid
*Data
; /* Image data, accessed via FetchTexel() */
810 const struct gl_texture_format
*TexFormat
;
812 FetchTexelFunc FetchTexel
; /* Texel fetch function pointer */
814 GLboolean IsCompressed
; /* GL_ARB_texture_compression */
815 GLuint CompressedSize
; /* GL_ARB_texture_compression */
817 /* For device driver: */
818 void *DriverData
; /* Arbitrary device driver data */
822 /* Texture object record */
823 struct gl_texture_object
{
824 _glthread_Mutex Mutex
; /* for thread safety */
825 GLint RefCount
; /* reference count */
826 GLuint Name
; /* an unsigned integer */
827 GLuint Dimensions
; /* 1 or 2 or 3 or 6 (cube map) */
828 GLfloat Priority
; /* in [0,1] */
829 GLchan BorderColor
[4];
830 GLenum WrapS
; /* Wrap modes are: GL_CLAMP, REPEAT */
831 GLenum WrapT
; /* GL_CLAMP_TO_EDGE, and */
832 GLenum WrapR
; /* GL_CLAMP_TO_BORDER_ARB */
833 GLenum MinFilter
; /* minification filter */
834 GLenum MagFilter
; /* magnification filter */
835 GLfloat MinLod
; /* min lambda, OpenGL 1.2 */
836 GLfloat MaxLod
; /* max lambda, OpenGL 1.2 */
837 GLint BaseLevel
; /* min mipmap level, OpenGL 1.2 */
838 GLint MaxLevel
; /* max mipmap level, OpenGL 1.2 */
839 GLfloat MaxAnisotropy
; /* GL_EXT_texture_filter_anisotropic */
840 GLboolean CompareFlag
; /* GL_SGIX_shadow */
841 GLenum CompareOperator
; /* GL_SGIX_shadow */
842 GLchan ShadowAmbient
; /* GL_SGIX_shadow_ambient */
843 GLint _MaxLevel
; /* actual max mipmap level (q in the spec) */
844 GLfloat _MaxLambda
; /* = _MaxLevel - BaseLevel (q - b in spec) */
845 GLboolean GenerateMipmap
; /* GL_SGIS_generate_mipmap */
847 struct gl_texture_image
*Image
[MAX_TEXTURE_LEVELS
];
849 /* Texture cube faces */
850 /* Image[] is alias for *PosX[MAX_TEXTURE_LEVELS]; */
851 struct gl_texture_image
*NegX
[MAX_TEXTURE_LEVELS
];
852 struct gl_texture_image
*PosY
[MAX_TEXTURE_LEVELS
];
853 struct gl_texture_image
*NegY
[MAX_TEXTURE_LEVELS
];
854 struct gl_texture_image
*PosZ
[MAX_TEXTURE_LEVELS
];
855 struct gl_texture_image
*NegZ
[MAX_TEXTURE_LEVELS
];
857 /* GL_EXT_paletted_texture */
858 struct gl_color_table Palette
;
860 GLboolean Complete
; /* Is texture object complete? */
861 struct gl_texture_object
*Next
; /* Next in linked list */
863 /* For device driver: */
864 void *DriverData
; /* Arbitrary device driver data */
870 * Texture units are new with the multitexture extension.
872 struct gl_texture_unit
{
873 GLuint Enabled
; /* bitmask of TEXTURE0_1D, _2D, _3D, _CUBE */
874 GLuint _ReallyEnabled
; /* 0 or one of TEXTURE0_1D, _2D, _3D, _CUBE */
876 GLenum EnvMode
; /* GL_MODULATE, GL_DECAL, GL_BLEND, etc. */
878 GLuint TexGenEnabled
; /* Bitwise-OR of [STRQ]_BIT values */
879 GLenum GenModeS
; /* Tex coord generation mode, either */
880 GLenum GenModeT
; /* GL_OBJECT_LINEAR, or */
881 GLenum GenModeR
; /* GL_EYE_LINEAR, or */
882 GLenum GenModeQ
; /* GL_SPHERE_MAP */
887 GLuint _GenFlags
; /* bitwise or of GenBit[STRQ] */
888 GLfloat ObjectPlaneS
[4];
889 GLfloat ObjectPlaneT
[4];
890 GLfloat ObjectPlaneR
[4];
891 GLfloat ObjectPlaneQ
[4];
892 GLfloat EyePlaneS
[4];
893 GLfloat EyePlaneT
[4];
894 GLfloat EyePlaneR
[4];
895 GLfloat EyePlaneQ
[4];
896 GLfloat LodBias
; /* for biasing mipmap levels */
898 /* GL_EXT_texture_env_combine */
899 GLenum CombineModeRGB
; /* GL_REPLACE, GL_DECAL, GL_ADD, etc. */
900 GLenum CombineModeA
; /* GL_REPLACE, GL_DECAL, GL_ADD, etc. */
901 GLenum CombineSourceRGB
[3]; /* GL_PRIMARY_COLOR, GL_TEXTURE, etc. */
902 GLenum CombineSourceA
[3]; /* GL_PRIMARY_COLOR, GL_TEXTURE, etc. */
903 GLenum CombineOperandRGB
[3]; /* SRC_COLOR, ONE_MINUS_SRC_COLOR, etc */
904 GLenum CombineOperandA
[3]; /* SRC_ALPHA, ONE_MINUS_SRC_ALPHA, etc */
905 GLuint CombineScaleShiftRGB
; /* 0, 1 or 2 */
906 GLuint CombineScaleShiftA
; /* 0, 1 or 2 */
908 struct gl_texture_object
*Current1D
;
909 struct gl_texture_object
*Current2D
;
910 struct gl_texture_object
*Current3D
;
911 struct gl_texture_object
*CurrentCubeMap
; /* GL_ARB_texture_cube_map */
913 struct gl_texture_object
*_Current
; /* Points to really enabled tex obj */
915 struct gl_texture_object Saved1D
; /* only used by glPush/PopAttrib */
916 struct gl_texture_object Saved2D
;
917 struct gl_texture_object Saved3D
;
918 struct gl_texture_object SavedCubeMap
;
922 struct gl_texture_attrib
{
924 GLuint CurrentUnit
; /* Active texture unit */
926 GLuint _ReallyEnabled
; /* enables for all texture units: */
927 /* = (Unit[0]._ReallyEnabled << 0) | */
928 /* (Unit[1]._ReallyEnabled << 4) | */
929 /* (Unit[2]._ReallyEnabled << 8) | etc... */
931 GLuint _GenFlags
; /* for texgen */
932 GLuint _TexGenEnabled
;
933 GLuint _TexMatEnabled
;
935 struct gl_texture_unit Unit
[MAX_TEXTURE_UNITS
];
937 struct gl_texture_object
*Proxy1D
;
938 struct gl_texture_object
*Proxy2D
;
939 struct gl_texture_object
*Proxy3D
;
940 struct gl_texture_object
*ProxyCubeMap
;
942 /* GL_EXT_shared_texture_palette */
943 GLboolean SharedPalette
;
944 struct gl_color_table Palette
;
948 struct gl_transform_attrib
{
949 GLenum MatrixMode
; /* Matrix mode */
950 GLfloat EyeUserPlane
[MAX_CLIP_PLANES
][4];
951 GLfloat _ClipUserPlane
[MAX_CLIP_PLANES
][4]; /* derived */
952 GLboolean ClipEnabled
[MAX_CLIP_PLANES
];
953 GLubyte _AnyClip
; /* How many ClipEnabled? */
954 GLboolean Normalize
; /* Normalize all normals? */
955 GLboolean RescaleNormals
; /* GL_EXT_rescale_normal */
956 GLboolean RasterPositionUnclipped
; /* GL_IBM_rasterpos_clip */
960 struct gl_viewport_attrib
{
961 GLint X
, Y
; /* position */
962 GLsizei Width
, Height
; /* size */
963 GLfloat Near
, Far
; /* Depth buffer range */
964 GLmatrix _WindowMap
; /* Mapping transformation as a matrix. */
968 /* For the attribute stack: */
969 struct gl_attrib_node
{
972 struct gl_attrib_node
*next
;
977 * Client pixel packing/unpacking attributes
979 struct gl_pixelstore_attrib
{
984 GLint ImageHeight
; /* for GL_EXT_texture3D */
985 GLint SkipImages
; /* for GL_EXT_texture3D */
991 #define CA_CLIENT_DATA 0x1 /* Data not alloced by mesa */
995 * Client vertex array attributes
997 struct gl_client_array
{
1000 GLsizei Stride
; /* user-specified stride */
1001 GLsizei StrideB
; /* actual stride in bytes */
1008 struct gl_array_attrib
{
1009 struct gl_client_array Vertex
; /* client data descriptors */
1010 struct gl_client_array Normal
;
1011 struct gl_client_array Color
;
1012 struct gl_client_array SecondaryColor
;
1013 struct gl_client_array FogCoord
;
1014 struct gl_client_array Index
;
1015 struct gl_client_array TexCoord
[MAX_TEXTURE_UNITS
];
1016 struct gl_client_array EdgeFlag
;
1018 GLint TexCoordInterleaveFactor
;
1019 GLint ActiveTexture
; /* Client Active Texture */
1023 GLuint _Enabled
; /* _NEW_ARRAY_* - bit set if array enabled */
1024 GLuint NewState
; /* _NEW_ARRAY_* */
1028 struct gl_feedback
{
1030 GLuint _Mask
; /* FB_* bits */
1037 struct gl_selection
{
1039 GLuint BufferSize
; /* size of SelectBuffer */
1040 GLuint BufferCount
; /* number of values in SelectBuffer */
1041 GLuint Hits
; /* number of records in SelectBuffer */
1042 GLuint NameStackDepth
;
1043 GLuint NameStack
[MAX_NAME_STACK_DEPTH
];
1045 GLfloat HitMinZ
, HitMaxZ
;
1050 * 1-D Evaluator control points
1053 GLuint Order
; /* Number of control points */
1054 GLfloat u1
, u2
, du
; /* u1, u2, 1.0/(u2-u1) */
1055 GLfloat
*Points
; /* Points to contiguous control points */
1060 * 2-D Evaluator control points
1063 GLuint Uorder
; /* Number of control points in U dimension */
1064 GLuint Vorder
; /* Number of control points in V dimension */
1067 GLfloat
*Points
; /* Points to contiguous control points */
1072 * All evalutator control points
1074 struct gl_evaluators
{
1076 struct gl_1d_map Map1Vertex3
;
1077 struct gl_1d_map Map1Vertex4
;
1078 struct gl_1d_map Map1Index
;
1079 struct gl_1d_map Map1Color4
;
1080 struct gl_1d_map Map1Normal
;
1081 struct gl_1d_map Map1Texture1
;
1082 struct gl_1d_map Map1Texture2
;
1083 struct gl_1d_map Map1Texture3
;
1084 struct gl_1d_map Map1Texture4
;
1087 struct gl_2d_map Map2Vertex3
;
1088 struct gl_2d_map Map2Vertex4
;
1089 struct gl_2d_map Map2Index
;
1090 struct gl_2d_map Map2Color4
;
1091 struct gl_2d_map Map2Normal
;
1092 struct gl_2d_map Map2Texture1
;
1093 struct gl_2d_map Map2Texture2
;
1094 struct gl_2d_map Map2Texture3
;
1095 struct gl_2d_map Map2Texture4
;
1100 * State which can be shared by multiple contexts:
1102 struct gl_shared_state
{
1103 _glthread_Mutex Mutex
; /* for thread safety */
1104 GLint RefCount
; /* Reference count */
1105 struct _mesa_HashTable
*DisplayList
; /* Display lists hash table */
1106 struct _mesa_HashTable
*TexObjects
; /* Texture objects hash table */
1107 struct gl_texture_object
*TexObjectList
;/* Linked list of texture objects */
1109 /* Default texture objects (shared by all multi-texture units) */
1110 struct gl_texture_object
*Default1D
;
1111 struct gl_texture_object
*Default2D
;
1112 struct gl_texture_object
*Default3D
;
1113 struct gl_texture_object
*DefaultCubeMap
;
1115 void *DriverData
; /* Device driver shared state */
1120 * A "frame buffer" is a color buffer and its optional ancillary buffers:
1121 * depth, accum, stencil, and software-simulated alpha buffers.
1122 * In C++ terms, think of this as a base class from which device drivers
1123 * will make derived classes.
1125 struct gl_frame_buffer
{
1126 GLvisual Visual
; /* The corresponding visual */
1128 GLint Width
, Height
; /* size of frame buffer in pixels */
1130 GLboolean UseSoftwareDepthBuffer
;
1131 GLboolean UseSoftwareAccumBuffer
;
1132 GLboolean UseSoftwareStencilBuffer
;
1133 GLboolean UseSoftwareAlphaBuffers
;
1135 /* Software depth (aka Z) buffer */
1136 GLvoid
*DepthBuffer
; /* array [Width*Height] of GLushort or GLuint*/
1138 /* Software stencil buffer */
1139 GLstencil
*Stencil
; /* array [Width*Height] of GLstencil values */
1141 /* Software accumulation buffer */
1142 GLaccum
*Accum
; /* array [4*Width*Height] of GLaccum values */
1144 /* Software alpha planes */
1145 GLchan
*FrontLeftAlpha
; /* array [Width*Height] of GLubyte */
1146 GLchan
*BackLeftAlpha
; /* array [Width*Height] of GLubyte */
1147 GLchan
*FrontRightAlpha
; /* array [Width*Height] of GLubyte */
1148 GLchan
*BackRightAlpha
; /* array [Width*Height] of GLubyte */
1149 GLchan
*Alpha
; /* Points to current alpha buffer */
1151 /* Drawing bounds: intersection of window size and scissor box */
1152 GLint _Xmin
, _Ymin
; /* inclusive */
1153 GLint _Xmax
, _Ymax
; /* exclusive */
1158 * Constants which may be overriden by device driver during context creation
1159 * but are never changed after that.
1161 struct gl_constants
{
1162 GLint MaxTextureLevels
;
1163 GLint Max3DTextureLevels
;
1164 GLint MaxCubeTextureLevels
;
1165 GLuint MaxTextureUnits
;
1166 GLfloat MaxTextureMaxAnisotropy
; /* GL_EXT_texture_filter_anisotropic */
1167 GLuint MaxArrayLockSize
;
1169 GLfloat MinPointSize
, MaxPointSize
; /* aliased */
1170 GLfloat MinPointSizeAA
, MaxPointSizeAA
; /* antialiased */
1171 GLfloat PointSizeGranularity
;
1172 GLfloat MinLineWidth
, MaxLineWidth
; /* aliased */
1173 GLfloat MinLineWidthAA
, MaxLineWidthAA
; /* antialiased */
1174 GLfloat LineWidthGranularity
;
1175 GLuint NumAuxBuffers
;
1176 GLuint MaxColorTableSize
;
1177 GLuint MaxConvolutionWidth
;
1178 GLuint MaxConvolutionHeight
;
1179 GLuint NumCompressedTextureFormats
; /* GL_ARB_texture_compression */
1180 GLenum CompressedTextureFormats
[MAX_COMPRESSED_TEXTURE_FORMATS
];
1181 GLuint MaxClipPlanes
;
1187 * List of extensions.
1190 struct gl_extensions
{
1192 struct extension
*ext_list
;
1193 /* Flags to quickly test if certain extensions are available.
1194 * Not every extension needs to have such a flag, but it's encouraged.
1196 GLboolean ARB_imaging
;
1197 GLboolean ARB_multisample
;
1198 GLboolean ARB_multitexture
;
1199 GLboolean ARB_texture_border_clamp
;
1200 GLboolean ARB_texture_compression
;
1201 GLboolean ARB_texture_cube_map
;
1202 GLboolean ARB_texture_env_combine
;
1203 GLboolean ARB_texture_env_dot3
;
1204 GLboolean EXT_blend_color
;
1205 GLboolean EXT_blend_func_separate
;
1206 GLboolean EXT_blend_logic_op
;
1207 GLboolean EXT_blend_minmax
;
1208 GLboolean EXT_blend_subtract
;
1209 GLboolean EXT_clip_volume_hint
;
1210 GLboolean EXT_convolution
;
1211 GLboolean EXT_compiled_vertex_array
;
1212 GLboolean EXT_fog_coord
;
1213 GLboolean EXT_histogram
;
1214 GLboolean EXT_packed_pixels
;
1215 GLboolean EXT_paletted_texture
;
1216 GLboolean EXT_point_parameters
;
1217 GLboolean EXT_polygon_offset
;
1218 GLboolean EXT_rescale_normal
;
1219 GLboolean EXT_secondary_color
;
1220 GLboolean EXT_shared_texture_palette
;
1221 GLboolean EXT_stencil_wrap
;
1222 GLboolean EXT_texture3D
;
1223 GLboolean EXT_texture_compression_s3tc
;
1224 GLboolean EXT_texture_env_add
;
1225 GLboolean EXT_texture_env_combine
;
1226 GLboolean EXT_texture_env_dot3
;
1227 GLboolean EXT_texture_filter_anisotropic
;
1228 GLboolean EXT_texture_object
;
1229 GLboolean EXT_texture_lod_bias
;
1230 GLboolean EXT_vertex_array_set
;
1231 GLboolean HP_occlusion_test
;
1232 GLboolean IBM_rasterpos_clip
;
1233 GLboolean INGR_blend_func_separate
;
1234 GLboolean MESA_window_pos
;
1235 GLboolean MESA_resize_buffers
;
1236 GLboolean MESA_sprite_point
;
1237 GLboolean NV_blend_square
;
1238 GLboolean NV_texgen_reflection
;
1239 GLboolean SGI_color_matrix
;
1240 GLboolean SGI_color_table
;
1241 GLboolean SGIS_generate_mipmap
;
1242 GLboolean SGIS_pixel_texture
;
1243 GLboolean SGIS_texture_edge_clamp
;
1244 GLboolean SGIX_depth_texture
;
1245 GLboolean SGIX_pixel_texture
;
1246 GLboolean SGIX_shadow
;
1247 GLboolean SGIX_shadow_ambient
;
1248 GLboolean _3DFX_texture_compression_FXT1
;
1254 * Bits for image transfer operations (ctx->ImageTransferState).
1256 #define IMAGE_SCALE_BIAS_BIT 0x1
1257 #define IMAGE_SHIFT_OFFSET_BIT 0x2
1258 #define IMAGE_MAP_COLOR_BIT 0x4
1259 #define IMAGE_COLOR_TABLE_BIT 0x8
1260 #define IMAGE_CONVOLUTION_BIT 0x10
1261 #define IMAGE_POST_CONVOLUTION_SCALE_BIAS 0x20
1262 #define IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT 0x40
1263 #define IMAGE_COLOR_MATRIX_BIT 0x80
1264 #define IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT 0x100
1265 #define IMAGE_HISTOGRAM_BIT 0x200
1266 #define IMAGE_MIN_MAX_BIT 0x400
1268 /* transfer ops up to convolution: */
1269 #define IMAGE_PRE_CONVOLUTION_BITS (IMAGE_SCALE_BIAS_BIT | \
1270 IMAGE_SHIFT_OFFSET_BIT | \
1271 IMAGE_MAP_COLOR_BIT | \
1272 IMAGE_COLOR_TABLE_BIT)
1274 /* transfer ops after convolution: */
1275 #define IMAGE_POST_CONVOLUTION_BITS (IMAGE_POST_CONVOLUTION_SCALE_BIAS | \
1276 IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT | \
1277 IMAGE_COLOR_MATRIX_BIT | \
1278 IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT |\
1279 IMAGE_HISTOGRAM_BIT | \
1284 * Bits to indicate what state has changed. 6 unused flags.
1286 #define _NEW_MODELVIEW 0x1 /* ctx->ModelView */
1287 #define _NEW_PROJECTION 0x2 /* ctx->Projection */
1288 #define _NEW_TEXTURE_MATRIX 0x4 /* ctx->TextureMatrix */
1289 #define _NEW_COLOR_MATRIX 0x8 /* ctx->ColorMatrix */
1290 #define _NEW_ACCUM 0x10 /* ctx->Accum */
1291 #define _NEW_COLOR 0x20 /* ctx->Color */
1292 #define _NEW_DEPTH 0x40 /* ctx->Depth */
1293 #define _NEW_EVAL 0x80 /* ctx->Eval, ctx->EvalMap */
1294 #define _NEW_FOG 0x100 /* ctx->Fog */
1295 #define _NEW_HINT 0x200 /* ctx->Hint */
1296 #define _NEW_LIGHT 0x400 /* ctx->Light */
1297 #define _NEW_LINE 0x800 /* ctx->Line */
1298 #define _NEW_PIXEL 0x1000 /* ctx->Pixel */
1299 #define _NEW_POINT 0x2000 /* ctx->Point */
1300 #define _NEW_POLYGON 0x4000 /* ctx->Polygon */
1301 #define _NEW_POLYGONSTIPPLE 0x8000 /* ctx->PolygonStipple */
1302 #define _NEW_SCISSOR 0x10000 /* ctx->Scissor */
1303 #define _NEW_STENCIL 0x20000 /* ctx->Stencil */
1304 #define _NEW_TEXTURE 0x40000 /* ctx->Texture */
1305 #define _NEW_TRANSFORM 0x80000 /* ctx->Transform */
1306 #define _NEW_VIEWPORT 0x100000 /* ctx->Viewport */
1307 #define _NEW_PACKUNPACK 0x200000 /* ctx->Pack, ctx->Unpack */
1308 #define _NEW_ARRAY 0x400000 /* ctx->Array */
1309 #define _NEW_RENDERMODE 0x800000 /* RenderMode, Feedback, Select */
1310 #define _NEW_BUFFERS 0x1000000 /* ctx->Visual, ctx->DrawBuffer, */
1311 #define _NEW_MULTISAMPLE 0x2000000 /* ctx->Multisample */
1316 /* Bits to track array state changes (also used to summarize array enabled)
1318 #define _NEW_ARRAY_VERTEX 0x1
1319 #define _NEW_ARRAY_COLOR 0x2
1320 #define _NEW_ARRAY_NORMAL 0x4
1321 #define _NEW_ARRAY_INDEX 0x8
1322 #define _NEW_ARRAY_EDGEFLAG 0x10
1323 #define _NEW_ARRAY_SECONDARYCOLOR 0x20
1324 #define _NEW_ARRAY_FOGCOORD 0x40
1325 #define _NEW_ARRAY_TEXCOORD_0 0x80
1326 #define _NEW_ARRAY_TEXCOORD_1 0x100
1327 #define _NEW_ARRAY_TEXCOORD_2 0x200
1328 #define _NEW_ARRAY_TEXCOORD_3 0x400
1329 #define _NEW_ARRAY_TEXCOORD_4 0x800
1330 #define _NEW_ARRAY_TEXCOORD_5 0x1000
1331 #define _NEW_ARRAY_TEXCOORD_6 0x2000
1332 #define _NEW_ARRAY_TEXCOORD_7 0x4000
1333 #define _NEW_ARRAY_ALL 0x7fff
1335 #define _NEW_ARRAY_TEXCOORD(i) (_NEW_ARRAY_TEXCOORD_0 << (i))
1337 /* A bunch of flags that we think might be useful to drivers.
1339 #define DD_FLATSHADE 0x1
1340 #define DD_SEPARATE_SPECULAR 0x2
1341 #define DD_TRI_CULL_FRONT_BACK 0x4 /* special case on some hw */
1342 #define DD_TRI_LIGHT_TWOSIDE 0x8
1343 #define DD_TRI_UNFILLED 0x10
1344 #define DD_TRI_SMOOTH 0x20
1345 #define DD_TRI_STIPPLE 0x40
1346 #define DD_TRI_OFFSET 0x80
1347 #define DD_LINE_SMOOTH 0x100
1348 #define DD_LINE_STIPPLE 0x200
1349 #define DD_LINE_WIDTH 0x400
1350 #define DD_POINT_SMOOTH 0x800
1351 #define DD_POINT_SIZE 0x1000
1352 #define DD_POINT_ATTEN 0x2000
1354 /* Define the state changes under which each of these bits might change
1356 #define _DD_NEW_FLATSHADE _NEW_LIGHT
1357 #define _DD_NEW_SEPARATE_SPECULAR (_NEW_LIGHT | _NEW_FOG)
1358 #define _DD_NEW_TRI_CULL_FRONT_BACK _NEW_POLYGON
1359 #define _DD_NEW_TRI_LIGHT_TWOSIDE _NEW_LIGHT
1360 #define _DD_NEW_TRI_UNFILLED _NEW_POLYGON
1361 #define _DD_NEW_TRI_SMOOTH _NEW_POLYGON
1362 #define _DD_NEW_TRI_STIPPLE _NEW_POLYGON
1363 #define _DD_NEW_TRI_OFFSET _NEW_POLYGON
1364 #define _DD_NEW_LINE_SMOOTH _NEW_LINE
1365 #define _DD_NEW_LINE_STIPPLE _NEW_LINE
1366 #define _DD_NEW_LINE_WIDTH _NEW_LINE
1367 #define _DD_NEW_POINT_SMOOTH _NEW_POINT
1368 #define _DD_NEW_POINT_SIZE _NEW_POINT
1369 #define _DD_NEW_POINT_ATTEN _NEW_POINT
1371 #define _MESA_NEW_NEED_EYE_COORDS (_NEW_LIGHT | \
1376 #define _MESA_NEW_NEED_NORMALS (_NEW_LIGHT | \
1379 #define _IMAGE_NEW_TRANSFER_STATE (_NEW_PIXEL | _NEW_COLOR_MATRIX)
1382 #define NEED_NORMALS_TEXGEN 0x1
1383 #define NEED_NORMALS_LIGHT 0x2
1385 #define NEED_EYE_TEXGEN 0x1
1386 #define NEED_EYE_LIGHT 0x2
1387 #define NEED_EYE_LIGHT_MODELVIEW 0x4
1388 #define NEED_EYE_POINT_ATTEN 0x8
1392 * Forward declaration of display list datatypes:
1395 typedef union node Node
;
1398 /* This has to be included here. */
1403 * Core Mesa's support for tnl modules:
1405 #define NUM_VERTEX_FORMAT_ENTRIES (sizeof(GLvertexformat) / sizeof(void *))
1407 struct gl_tnl_module
{
1408 /* Vertex format to be lazily swapped into current dispatch.
1410 GLvertexformat
*Current
;
1412 /* Record of functions swapped out. On restore, only need to swap
1413 * these functions back in.
1415 void *Swapped
[NUM_VERTEX_FORMAT_ENTRIES
][2];
1421 * The library context:
1423 struct __GLcontextRec
{
1425 ** Os related interfaces; these *must* be the first members of this
1426 ** structure, because they are exposed to the outside world (i.e. GLX
1429 __GLimports imports
;
1430 __GLexports exports
;
1432 /* State possibly shared with other contexts in the address space */
1433 struct gl_shared_state
*Shared
;
1435 /* API function pointer tables */
1436 struct _glapi_table
*Save
; /* Display list save funcs */
1437 struct _glapi_table
*Exec
; /* Execute funcs */
1438 struct _glapi_table
*CurrentDispatch
; /* == Save or Exec !! */
1440 GLboolean ExecPrefersFloat
; /* What preference for color conversion? */
1441 GLboolean SavePrefersFloat
;
1444 GLframebuffer
*DrawBuffer
; /* buffer for writing */
1445 GLframebuffer
*ReadBuffer
; /* buffer for reading */
1447 /* Driver function pointer table */
1448 struct dd_function_table Driver
;
1450 void *DriverCtx
; /* Points to device driver context/state */
1451 void *DriverMgrCtx
; /* Points to device driver manager (optional)*/
1453 /* Core/Driver constants */
1454 struct gl_constants Const
;
1456 /* Modelview matrix and stack */
1457 GLmatrix ModelView
; /* current matrix, not stored on stack */
1458 GLuint ModelViewStackDepth
;
1459 GLmatrix ModelViewStack
[MAX_MODELVIEW_STACK_DEPTH
- 1];
1461 /* Projection matrix and stack */
1462 GLmatrix ProjectionMatrix
; /* current matrix, not stored on stack */
1463 GLuint ProjectionStackDepth
;
1464 GLmatrix ProjectionStack
[MAX_PROJECTION_STACK_DEPTH
- 1];
1466 /* Combined modelview and projection matrix */
1467 GLmatrix _ModelProjectMatrix
;
1469 /* Texture matrix and stack */
1470 GLmatrix TextureMatrix
[MAX_TEXTURE_UNITS
];
1471 GLuint TextureStackDepth
[MAX_TEXTURE_UNITS
];
1472 GLmatrix TextureStack
[MAX_TEXTURE_UNITS
][MAX_TEXTURE_STACK_DEPTH
- 1];
1474 /* Color matrix and stack */
1475 GLmatrix ColorMatrix
;
1476 GLuint ColorStackDepth
;
1477 GLmatrix ColorStack
[MAX_COLOR_STACK_DEPTH
- 1];
1480 GLuint CallDepth
; /* Current recursion calling depth */
1481 GLboolean ExecuteFlag
; /* Execute GL commands? */
1482 GLboolean CompileFlag
; /* Compile GL commands into display list? */
1483 Node
*CurrentListPtr
; /* Head of list being compiled */
1484 GLuint CurrentListNum
; /* Number of the list being compiled */
1485 Node
*CurrentBlock
; /* Pointer to current block of nodes */
1486 GLuint CurrentPos
; /* Index into current block of nodes */
1489 struct gl_extensions Extensions
;
1491 /* Renderer attribute stack */
1492 GLuint AttribStackDepth
;
1493 struct gl_attrib_node
*AttribStack
[MAX_ATTRIB_STACK_DEPTH
];
1495 /* Renderer attribute groups */
1496 struct gl_accum_attrib Accum
;
1497 struct gl_colorbuffer_attrib Color
;
1498 struct gl_current_attrib Current
;
1499 struct gl_depthbuffer_attrib Depth
;
1500 struct gl_eval_attrib Eval
;
1501 struct gl_fog_attrib Fog
;
1502 struct gl_hint_attrib Hint
;
1503 struct gl_light_attrib Light
;
1504 struct gl_line_attrib Line
;
1505 struct gl_list_attrib List
;
1506 struct gl_multisample_attrib Multisample
;
1507 struct gl_pixel_attrib Pixel
;
1508 struct gl_point_attrib Point
;
1509 struct gl_polygon_attrib Polygon
;
1510 GLuint PolygonStipple
[32];
1511 struct gl_scissor_attrib Scissor
;
1512 struct gl_stencil_attrib Stencil
;
1513 struct gl_texture_attrib Texture
;
1514 struct gl_transform_attrib Transform
;
1515 struct gl_viewport_attrib Viewport
;
1517 /* Other attribute groups */
1518 struct gl_histogram_attrib Histogram
;
1519 struct gl_minmax_attrib MinMax
;
1520 struct gl_convolution_attrib Convolution1D
;
1521 struct gl_convolution_attrib Convolution2D
;
1522 struct gl_convolution_attrib Separable2D
;
1524 /* Client attribute stack */
1525 GLuint ClientAttribStackDepth
;
1526 struct gl_attrib_node
*ClientAttribStack
[MAX_CLIENT_ATTRIB_STACK_DEPTH
];
1528 /* Client attribute groups */
1529 struct gl_array_attrib Array
; /* Vertex arrays */
1530 struct gl_pixelstore_attrib Pack
; /* Pixel packing */
1531 struct gl_pixelstore_attrib Unpack
; /* Pixel unpacking */
1533 struct gl_evaluators EvalMap
; /* All evaluators */
1534 struct gl_feedback Feedback
; /* Feedback */
1535 struct gl_selection Select
; /* Selection */
1537 struct gl_color_table ColorTable
; /* Pre-convolution */
1538 struct gl_color_table ProxyColorTable
; /* Pre-convolution */
1539 struct gl_color_table PostConvolutionColorTable
;
1540 struct gl_color_table ProxyPostConvolutionColorTable
;
1541 struct gl_color_table PostColorMatrixColorTable
;
1542 struct gl_color_table ProxyPostColorMatrixColorTable
;
1544 GLenum ErrorValue
; /* Last error code */
1545 GLenum RenderMode
; /* either GL_RENDER, GL_SELECT, GL_FEEDBACK */
1546 GLuint NewState
; /* bitwise-or of _NEW_* flags */
1549 GLuint _TriangleCaps
; /* bitwise-or of DD_* flags */
1550 GLuint _ImageTransferState
;/* bitwise-or of IMAGE_*_BIT flags */
1551 GLfloat _EyeZDir
[3];
1552 GLfloat _ModelViewInvScale
;
1553 GLuint _NeedEyeCoords
;
1554 GLuint _NeedNormals
; /* Are vertex normal vectors needed? */
1556 struct gl_shine_tab
*_ShineTable
[2]; /* Active shine tables */
1557 struct gl_shine_tab
*_ShineTabList
; /* Mru list of inactive shine tables */
1559 struct gl_list_extensions listext
; /* driver dlist extensions */
1562 GLboolean OcclusionResult
; /* GL_HP_occlusion_test */
1563 GLboolean OcclusionResultSaved
; /* GL_HP_occlusion_test */
1565 /* Z buffer stuff */
1566 GLuint DepthMax
; /* Max depth buffer value */
1567 GLfloat DepthMaxF
; /* Float max depth buffer value */
1568 GLfloat MRD
; /* minimum resolvable difference in Z values */
1570 /* Should 3Dfx Glide driver catch signals? */
1571 GLboolean CatchSignals
;
1573 /* For debugging/development only */
1575 GLboolean FirstTimeCurrent
;
1577 /* Dither disable via MESA_NO_DITHER env var */
1580 GLboolean Rendering
;
1582 #if defined(MESA_TRACE)
1583 struct _glapi_table
*TraceDispatch
;
1584 trace_context_t
*TraceCtx
;
1586 void *TraceDispatch
;
1590 /* Core tnl module support */
1591 struct gl_tnl_module TnlModule
;
1593 /* Hooks for module contexts. These will eventually live
1594 * in the driver or elsewhere.
1596 void *swrast_context
;
1597 void *swsetup_context
;
1598 void *swtnl_context
;
1600 void *acache_context
;
1605 /* The string names for GL_POINT, GL_LINE_LOOP, etc */
1606 extern const char *_mesa_prim_name
[GL_POLYGON
+4];
1610 extern int MESA_VERBOSE
;
1611 extern int MESA_DEBUG_FLAGS
;
1613 # define MESA_VERBOSE 0
1614 # define MESA_DEBUG_FLAGS 0
1622 VERBOSE_VARRAY
= 0x0001,
1623 VERBOSE_TEXTURE
= 0x0002,
1624 VERBOSE_IMMEDIATE
= 0x0004,
1625 VERBOSE_PIPELINE
= 0x0008,
1626 VERBOSE_DRIVER
= 0x0010,
1627 VERBOSE_STATE
= 0x0020,
1628 VERBOSE_API
= 0x0040,
1629 VERBOSE_DISPLAY_LIST
= 0x0200,
1630 VERBOSE_LIGHTING
= 0x0400
1635 DEBUG_ALWAYS_FLUSH
= 0x1
1640 #define Elements(x) sizeof(x)/sizeof(*(x))
1644 /* Eventually let the driver specify what statechanges require a flush:
1646 #define FLUSH_VERTICES(ctx, newstate) \
1648 if (ctx->Driver.NeedFlush & FLUSH_STORED_VERTICES) \
1649 ctx->Driver.FlushVertices(ctx, FLUSH_STORED_VERTICES); \
1650 ctx->NewState |= newstate; \
1653 #define FLUSH_CURRENT(ctx, newstate) \
1655 if (ctx->Driver.NeedFlush & FLUSH_UPDATE_CURRENT) \
1656 ctx->Driver.FlushVertices(ctx, FLUSH_UPDATE_CURRENT); \
1657 ctx->NewState |= newstate; \
1660 #define ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, retval) \
1662 if (ctx->Driver.CurrentExecPrimitive != PRIM_OUTSIDE_BEGIN_END) { \
1663 _mesa_error( ctx, GL_INVALID_OPERATION, "begin/end" ); \
1668 #define ASSERT_OUTSIDE_BEGIN_END(ctx) \
1670 if (ctx->Driver.CurrentExecPrimitive != PRIM_OUTSIDE_BEGIN_END) { \
1671 _mesa_error( ctx, GL_INVALID_OPERATION, "begin/end" ); \
1676 #define ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx) \
1678 ASSERT_OUTSIDE_BEGIN_END(ctx); \
1679 FLUSH_VERTICES(ctx, 0); \
1682 #define ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH_WITH_RETVAL(ctx, retval) \
1684 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, retval); \
1685 FLUSH_VERTICES(ctx, 0); \
1691 #endif /* TYPES_H */