1 /* $Id: mtypes.h,v 1.49 2001/07/13 20:07:37 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 typedef GLfloat GLaccum
;
80 # error "illegal number of accumulation bits"
85 * Stencil buffer data type:
88 typedef GLubyte GLstencil
;
89 # define STENCIL_MAX 0xff
90 #elif STENCIL_BITS==16
91 typedef GLushort GLstencil
;
92 # define STENCIL_MAX 0xffff
94 # error "illegal number of stencil bits"
99 * Depth buffer data type:
101 typedef GLuint GLdepth
; /* Must be 32-bits! */
105 * Fixed point data type:
112 * Some forward type declarations
114 struct _mesa_HashTable
;
115 struct gl_texture_image
;
116 struct gl_texture_object
;
117 typedef struct __GLcontextRec GLcontext
;
118 typedef struct __GLcontextModesRec GLvisual
;
119 typedef struct gl_frame_buffer GLframebuffer
;
123 /* Maximum number of temporary vertices required for clipping. (Used
124 * in array_cache and tnl modules).
126 #define MAX_CLIPPED_VERTICES ((2 * (6 + MAX_CLIP_PLANES))+1)
129 /* Data structure for color tables */
130 struct gl_color_table
{
131 GLenum Format
; /* GL_ALPHA, GL_RGB, GL_RGB, etc */
133 GLuint Size
; /* number of entries (rows) in table */
134 GLvoid
*Table
; /* either GLfloat * or GLchan * */
135 GLboolean FloatTable
; /* are entries stored as floats? */
140 GLubyte LuminanceSize
;
141 GLubyte IntensitySize
;
146 * Bit flags used for updating material values.
148 #define FRONT_AMBIENT_BIT 0x1
149 #define BACK_AMBIENT_BIT 0x2
150 #define FRONT_DIFFUSE_BIT 0x4
151 #define BACK_DIFFUSE_BIT 0x8
152 #define FRONT_SPECULAR_BIT 0x10
153 #define BACK_SPECULAR_BIT 0x20
154 #define FRONT_EMISSION_BIT 0x40
155 #define BACK_EMISSION_BIT 0x80
156 #define FRONT_SHININESS_BIT 0x100
157 #define BACK_SHININESS_BIT 0x200
158 #define FRONT_INDEXES_BIT 0x400
159 #define BACK_INDEXES_BIT 0x800
161 #define FRONT_MATERIAL_BITS (FRONT_EMISSION_BIT | FRONT_AMBIENT_BIT | \
162 FRONT_DIFFUSE_BIT | FRONT_SPECULAR_BIT | \
163 FRONT_SHININESS_BIT | FRONT_INDEXES_BIT)
165 #define BACK_MATERIAL_BITS (BACK_EMISSION_BIT | BACK_AMBIENT_BIT | \
166 BACK_DIFFUSE_BIT | BACK_SPECULAR_BIT | \
167 BACK_SHININESS_BIT | BACK_INDEXES_BIT)
169 #define ALL_MATERIAL_BITS (FRONT_MATERIAL_BITS | BACK_MATERIAL_BITS)
174 * Specular exponent and material shininess lookup table sizes:
176 #define EXP_TABLE_SIZE 512
177 #define SHINE_TABLE_SIZE 256
179 struct gl_shine_tab
{
180 struct gl_shine_tab
*next
, *prev
;
181 GLfloat tab
[SHINE_TABLE_SIZE
+1];
188 struct gl_light
*next
; /* double linked list with sentinel */
189 struct gl_light
*prev
;
191 GLfloat Ambient
[4]; /* ambient color */
192 GLfloat Diffuse
[4]; /* diffuse color */
193 GLfloat Specular
[4]; /* specular color */
194 GLfloat EyePosition
[4]; /* position in eye coordinates */
195 GLfloat EyeDirection
[4]; /* spotlight dir in eye coordinates */
196 GLfloat SpotExponent
;
197 GLfloat SpotCutoff
; /* in degress */
198 GLfloat _CosCutoff
; /* = MAX(0, cos(SpotCutoff)) */
199 GLfloat ConstantAttenuation
;
200 GLfloat LinearAttenuation
;
201 GLfloat QuadraticAttenuation
;
202 GLboolean Enabled
; /* On/off flag */
205 GLuint _Flags
; /* State */
207 GLfloat _Position
[4]; /* position in eye/obj coordinates */
208 GLfloat _VP_inf_norm
[3]; /* Norm direction to infinite light */
209 GLfloat _h_inf_norm
[3]; /* Norm( _VP_inf_norm + <0,0,1> ) */
210 GLfloat _NormDirection
[4]; /* normalized spotlight direction */
211 GLfloat _VP_inf_spot_attenuation
;
213 GLfloat _SpotExpTable
[EXP_TABLE_SIZE
][2]; /* to replace a pow() call */
214 GLfloat _MatAmbient
[2][3]; /* material ambient * light ambient */
215 GLfloat _MatDiffuse
[2][3]; /* material diffuse * light diffuse */
216 GLfloat _MatSpecular
[2][3]; /* material spec * light specular */
217 GLfloat _dli
; /* CI diffuse light intensity */
218 GLfloat _sli
; /* CI specular light intensity */
222 struct gl_lightmodel
{
223 GLfloat Ambient
[4]; /* ambient color */
224 GLboolean LocalViewer
; /* Local (or infinite) view point? */
225 GLboolean TwoSide
; /* Two (or one) sided lighting? */
226 GLenum ColorControl
; /* either GL_SINGLE_COLOR */
227 /* or GL_SEPARATE_SPECULAR_COLOR */
238 GLfloat AmbientIndex
; /* for color index lighting */
239 GLfloat DiffuseIndex
; /* for color index lighting */
240 GLfloat SpecularIndex
; /* for color index lighting */
245 * Attribute structures:
246 * We define a struct for each attribute group to make pushing and
247 * popping attributes easy. Also it's a good organization.
249 struct gl_accum_attrib
{
250 GLfloat ClearColor
[4]; /* Accumulation buffer clear color */
255 * Used in DrawDestMask below
257 #define FRONT_LEFT_BIT 1
258 #define FRONT_RIGHT_BIT 2
259 #define BACK_LEFT_BIT 4
260 #define BACK_RIGHT_BIT 8
263 struct gl_colorbuffer_attrib
{
264 GLuint ClearIndex
; /* Index to use for glClear */
265 GLchan ClearColor
[4]; /* Color to use for glClear */
267 GLuint IndexMask
; /* Color index write mask */
268 GLubyte ColorMask
[4]; /* Each flag is 0xff or 0x0 */
270 GLenum DrawBuffer
; /* Which buffer to draw into */
271 GLenum DriverDrawBuffer
; /* Current device driver dest buffer */
272 GLboolean MultiDrawBuffer
; /* Drawing to mutliple buffers? */
273 GLubyte DrawDestMask
; /* bitwise-OR of bitflags above */
276 GLboolean AlphaEnabled
; /* Alpha test enabled flag */
277 GLenum AlphaFunc
; /* Alpha test function */
278 GLchan AlphaRef
; /* Alpha ref value as GLchan */
281 GLboolean BlendEnabled
; /* Blending enabled flag */
282 GLenum BlendSrcRGB
; /* Blending source operator */
283 GLenum BlendDstRGB
; /* Blending destination operator */
284 GLenum BlendSrcA
; /* GL_INGR_blend_func_separate */
285 GLenum BlendDstA
; /* GL_INGR_blend_func_separate */
286 GLenum BlendEquation
;
287 GLfloat BlendColor
[4];
290 GLenum LogicOp
; /* Logic operator */
291 GLboolean IndexLogicOpEnabled
; /* Color index logic op enabled flag */
292 GLboolean ColorLogicOpEnabled
; /* RGBA logic op enabled flag */
294 GLboolean DitherFlag
; /* Dither enable flag */
298 struct gl_current_attrib
{
299 /* These values valid only when FLUSH_VERTICES has been called.
301 GLfloat Normal
[3]; /* Current vertex normal */
302 GLfloat Color
[4]; /* Current RGBA color */
303 GLfloat SecondaryColor
[4]; /* Current secondary color */
304 GLfloat FogCoord
; /* Current Fog coord */
305 GLuint Index
; /* Current color index */
306 GLboolean EdgeFlag
; /* Current edge flag */
307 GLfloat Texcoord
[MAX_TEXTURE_UNITS
][4]; /* Current texture coords */
309 /* These values are always valid.
311 GLfloat RasterPos
[4]; /* Current raster position */
312 GLfloat RasterDistance
; /* Current raster distance */
313 GLfloat RasterColor
[4]; /* Current raster color */
314 GLfloat RasterSecondaryColor
[4]; /* Current rast 2ndary color */
315 GLuint RasterIndex
; /* Current raster index */
316 GLfloat
*RasterTexCoord
; /* Current raster texcoord*/
317 GLfloat RasterMultiTexCoord
[MAX_TEXTURE_UNITS
][4];
318 GLfloat RasterFogCoord
;
319 GLboolean RasterPosValid
; /* Raster po valid flag */
323 struct gl_depthbuffer_attrib
{
324 GLenum Func
; /* Function for depth buffer compare */
325 GLfloat Clear
; /* Value to clear depth buffer to */
326 GLboolean Test
; /* Depth buffering enabled flag */
327 GLboolean Mask
; /* Depth buffer writable? */
328 GLboolean OcclusionTest
; /* GL_HP_occlusion_test */
332 struct gl_enable_attrib
{
334 GLboolean AutoNormal
;
336 GLboolean ClipPlane
[MAX_CLIP_PLANES
];
337 GLboolean ColorMaterial
;
338 GLboolean Convolution1D
;
339 GLboolean Convolution2D
;
340 GLboolean Separable2D
;
346 GLboolean Light
[MAX_LIGHTS
];
348 GLboolean LineSmooth
;
349 GLboolean LineStipple
;
350 GLboolean IndexLogicOp
;
351 GLboolean ColorLogicOp
;
352 GLboolean Map1Color4
;
354 GLboolean Map1Normal
;
355 GLboolean Map1TextureCoord1
;
356 GLboolean Map1TextureCoord2
;
357 GLboolean Map1TextureCoord3
;
358 GLboolean Map1TextureCoord4
;
359 GLboolean Map1Vertex3
;
360 GLboolean Map1Vertex4
;
361 GLboolean Map2Color4
;
363 GLboolean Map2Normal
;
364 GLboolean Map2TextureCoord1
;
365 GLboolean Map2TextureCoord2
;
366 GLboolean Map2TextureCoord3
;
367 GLboolean Map2TextureCoord4
;
368 GLboolean Map2Vertex3
;
369 GLboolean Map2Vertex4
;
372 GLboolean PixelTexture
;
373 GLboolean PointSmooth
;
374 GLboolean PolygonOffsetPoint
;
375 GLboolean PolygonOffsetLine
;
376 GLboolean PolygonOffsetFill
;
377 GLboolean PolygonSmooth
;
378 GLboolean PolygonStipple
;
379 GLboolean RescaleNormals
;
382 GLboolean MultisampleEnabled
; /* GL_ARB_multisample */
383 GLboolean SampleAlphaToCoverage
; /* GL_ARB_multisample */
384 GLboolean SampleAlphaToOne
; /* GL_ARB_multisample */
385 GLboolean SampleCoverage
; /* GL_ARB_multisample */
386 GLboolean SampleCoverageInvert
; /* GL_ARB_multisample */
387 GLboolean RasterPositionUnclipped
; /* GL_IBM_rasterpos_clip */
388 GLuint Texture
[MAX_TEXTURE_UNITS
];
389 GLuint TexGen
[MAX_TEXTURE_UNITS
];
393 struct gl_eval_attrib
{
395 GLboolean Map1Color4
;
397 GLboolean Map1Normal
;
398 GLboolean Map1TextureCoord1
;
399 GLboolean Map1TextureCoord2
;
400 GLboolean Map1TextureCoord3
;
401 GLboolean Map1TextureCoord4
;
402 GLboolean Map1Vertex3
;
403 GLboolean Map1Vertex4
;
404 GLboolean Map2Color4
;
406 GLboolean Map2Normal
;
407 GLboolean Map2TextureCoord1
;
408 GLboolean Map2TextureCoord2
;
409 GLboolean Map2TextureCoord3
;
410 GLboolean Map2TextureCoord4
;
411 GLboolean Map2Vertex3
;
412 GLboolean Map2Vertex4
;
413 GLboolean AutoNormal
;
414 /* Map Grid endpoints and divisions and calculated du values */
416 GLfloat MapGrid1u1
, MapGrid1u2
, MapGrid1du
;
417 GLint MapGrid2un
, MapGrid2vn
;
418 GLfloat MapGrid2u1
, MapGrid2u2
, MapGrid2du
;
419 GLfloat MapGrid2v1
, MapGrid2v2
, MapGrid2dv
;
423 struct gl_fog_attrib
{
424 GLboolean Enabled
; /* Fog enabled flag */
425 GLfloat Color
[4]; /* Fog color */
426 GLfloat Density
; /* Density >= 0.0 */
427 GLfloat Start
; /* Start distance in eye coords */
428 GLfloat End
; /* End distance in eye coords */
429 GLfloat Index
; /* Fog index */
430 GLenum Mode
; /* Fog mode */
431 GLboolean ColorSumEnabled
;
432 GLenum FogCoordinateSource
; /* GL_EXT_fog_coord */
436 struct gl_hint_attrib
{
437 /* always one of GL_FASTEST, GL_NICEST, or GL_DONT_CARE */
438 GLenum PerspectiveCorrection
;
441 GLenum PolygonSmooth
;
443 GLenum ClipVolumeClipping
; /* GL_EXT_clip_volume_hint */
444 GLenum TextureCompression
; /* GL_ARB_texture_compression */
445 GLenum GenerateMipmap
; /* GL_SGIS_generate_mipmap */
449 struct gl_histogram_attrib
{
450 GLuint Width
; /* number of table entries */
451 GLint Format
; /* GL_ALPHA, GL_RGB, etc */
452 GLuint Count
[HISTOGRAM_TABLE_SIZE
][4]; /* the histogram */
453 GLboolean Sink
; /* terminate image transfer? */
454 GLubyte RedSize
; /* Bits per counter */
458 GLubyte LuminanceSize
;
462 struct gl_minmax_attrib
{
465 GLfloat Min
[4], Max
[4]; /* RGBA */
469 struct gl_convolution_attrib
{
471 GLenum InternalFormat
;
474 GLfloat Filter
[MAX_CONVOLUTION_WIDTH
* MAX_CONVOLUTION_HEIGHT
* 4];
478 struct gl_light_attrib
{
479 struct gl_light Light
[MAX_LIGHTS
]; /* Array of lights */
480 struct gl_lightmodel Model
; /* Lighting model */
482 /* Must flush FLUSH_VERTICES before referencing:
484 struct gl_material Material
[2]; /* Material 0=front, 1=back */
486 GLboolean Enabled
; /* Lighting enabled flag */
487 GLenum ShadeModel
; /* GL_FLAT or GL_SMOOTH */
488 GLenum ColorMaterialFace
; /* GL_FRONT, BACK or FRONT_AND_BACK */
489 GLenum ColorMaterialMode
; /* GL_AMBIENT, GL_DIFFUSE, etc */
490 GLuint ColorMaterialBitmask
; /* bitmask formed from Face and Mode */
491 GLboolean ColorMaterialEnabled
;
493 struct gl_light EnabledList
; /* List sentinel */
495 /* Derived for optimizations: */
496 GLboolean _NeedVertices
; /* Use fast shader? */
497 GLuint _Flags
; /* LIGHT_* flags, see below */
498 GLfloat _BaseColor
[2][3];
499 GLfloat _BaseAlpha
[2];
503 #define LIGHT_SPOT 0x1
504 #define LIGHT_LOCAL_VIEWER 0x2
505 #define LIGHT_POSITIONAL 0x4
507 #define LIGHT_NEED_VERTICES (LIGHT_POSITIONAL|LIGHT_LOCAL_VIEWER)
509 struct gl_line_attrib
{
510 GLboolean SmoothFlag
; /* GL_LINE_SMOOTH enabled? */
511 GLboolean StippleFlag
; /* GL_LINE_STIPPLE enabled? */
512 GLushort StipplePattern
; /* Stipple pattern */
513 GLint StippleFactor
; /* Stipple repeat factor */
514 GLfloat Width
; /* Line width */
515 GLfloat _Width
; /* Clamped Line width */
519 struct gl_list_attrib
{
523 struct gl_list_opcode
{
525 void (*execute
)( GLcontext
*ctx
, void *data
);
526 void (*destroy
)( GLcontext
*ctx
, void *data
);
527 void (*print
)( GLcontext
*ctx
, void *data
);
530 #define GL_MAX_EXT_OPCODES 16
532 struct gl_list_extensions
{
533 struct gl_list_opcode opcode
[GL_MAX_EXT_OPCODES
];
538 struct gl_multisample_attrib
{
540 GLboolean SampleAlphaToCoverage
;
541 GLboolean SampleAlphaToOne
;
542 GLboolean SampleCoverage
;
543 GLfloat SampleCoverageValue
;
544 GLboolean SampleCoverageInvert
;
548 struct gl_pixel_attrib
{
549 GLenum ReadBuffer
; /* src buffer for glRead/CopyPixels */
550 GLenum DriverReadBuffer
; /* Driver's current source buffer */
551 GLfloat RedBias
, RedScale
;
552 GLfloat GreenBias
, GreenScale
;
553 GLfloat BlueBias
, BlueScale
;
554 GLfloat AlphaBias
, AlphaScale
;
555 GLfloat DepthBias
, DepthScale
;
556 GLint IndexShift
, IndexOffset
;
557 GLboolean MapColorFlag
;
558 GLboolean MapStencilFlag
;
559 GLfloat ZoomX
, ZoomY
;
560 GLint MapStoSsize
; /* Size of each pixel map */
570 GLint MapStoS
[MAX_PIXEL_MAP_TABLE
]; /* Pixel map tables */
571 GLint MapItoI
[MAX_PIXEL_MAP_TABLE
];
572 GLfloat MapItoR
[MAX_PIXEL_MAP_TABLE
];
573 GLfloat MapItoG
[MAX_PIXEL_MAP_TABLE
];
574 GLfloat MapItoB
[MAX_PIXEL_MAP_TABLE
];
575 GLfloat MapItoA
[MAX_PIXEL_MAP_TABLE
];
576 GLubyte MapItoR8
[MAX_PIXEL_MAP_TABLE
]; /* converted to 8-bit color */
577 GLubyte MapItoG8
[MAX_PIXEL_MAP_TABLE
];
578 GLubyte MapItoB8
[MAX_PIXEL_MAP_TABLE
];
579 GLubyte MapItoA8
[MAX_PIXEL_MAP_TABLE
];
580 GLfloat MapRtoR
[MAX_PIXEL_MAP_TABLE
];
581 GLfloat MapGtoG
[MAX_PIXEL_MAP_TABLE
];
582 GLfloat MapBtoB
[MAX_PIXEL_MAP_TABLE
];
583 GLfloat MapAtoA
[MAX_PIXEL_MAP_TABLE
];
584 /* GL_EXT_histogram */
585 GLboolean HistogramEnabled
;
586 GLboolean MinMaxEnabled
;
587 /* GL_SGIS_pixel_texture */
588 GLboolean PixelTextureEnabled
;
589 GLenum FragmentRgbSource
;
590 GLenum FragmentAlphaSource
;
591 /* GL_SGI_color_matrix */
592 GLfloat PostColorMatrixScale
[4]; /* RGBA */
593 GLfloat PostColorMatrixBias
[4]; /* RGBA */
594 /* GL_SGI_color_table */
595 GLfloat ColorTableScale
[4];
596 GLfloat ColorTableBias
[4];
597 GLboolean ColorTableEnabled
;
598 GLfloat PCCTscale
[4];
600 GLboolean PostConvolutionColorTableEnabled
;
601 GLfloat PCMCTscale
[4];
602 GLfloat PCMCTbias
[4];
603 GLboolean PostColorMatrixColorTableEnabled
;
605 GLboolean Convolution1DEnabled
;
606 GLboolean Convolution2DEnabled
;
607 GLboolean Separable2DEnabled
;
608 GLfloat ConvolutionBorderColor
[3][4];
609 GLenum ConvolutionBorderMode
[3];
610 GLfloat ConvolutionFilterScale
[3][4];
611 GLfloat ConvolutionFilterBias
[3][4];
612 GLfloat PostConvolutionScale
[4]; /* RGBA */
613 GLfloat PostConvolutionBias
[4]; /* RGBA */
617 struct gl_point_attrib
{
618 GLboolean SmoothFlag
; /* True if GL_POINT_SMOOTH is enabled */
619 GLboolean SpriteMode
; /* GL_MESA_sprite_point extension */
620 GLfloat Size
; /* User-specified point size */
621 GLfloat _Size
; /* Size clamped to Const.Min/MaxPointSize */
622 GLfloat Params
[3]; /* GL_EXT_point_parameters */
623 GLfloat MinSize
, MaxSize
; /* GL_EXT_point_parameters */
624 GLfloat Threshold
; /* GL_EXT_point_parameters */
625 GLboolean _Attenuated
; /* True if Params != [1, 0, 0] */
629 struct gl_polygon_attrib
{
630 GLenum FrontFace
; /* Either GL_CW or GL_CCW */
631 GLenum FrontMode
; /* Either GL_POINT, GL_LINE or GL_FILL */
632 GLenum BackMode
; /* Either GL_POINT, GL_LINE or GL_FILL */
633 GLboolean _FrontBit
; /* */
634 GLboolean CullFlag
; /* Culling on/off flag */
635 GLboolean SmoothFlag
; /* True if GL_POLYGON_SMOOTH is enabled */
636 GLboolean StippleFlag
; /* True if GL_POLYGON_STIPPLE is enabled */
637 GLenum CullFaceMode
; /* Culling mode GL_FRONT or GL_BACK */
638 GLfloat OffsetFactor
; /* Polygon offset factor, from user */
639 GLfloat OffsetUnits
; /* Polygon offset units, from user */
640 GLfloat OffsetMRD
; /* = OffsetUnits * visual->MRD */
641 GLboolean OffsetPoint
; /* Offset in GL_POINT mode */
642 GLboolean OffsetLine
; /* Offset in GL_LINE mode */
643 GLboolean OffsetFill
; /* Offset in GL_FILL mode */
644 GLboolean _OffsetAny
;
648 struct gl_scissor_attrib
{
649 GLboolean Enabled
; /* Scissor test enabled? */
650 GLint X
, Y
; /* Lower left corner of box */
651 GLsizei Width
, Height
; /* Size of box */
655 struct gl_stencil_attrib
{
656 GLboolean Enabled
; /* Enabled flag */
657 GLenum Function
; /* Stencil function */
658 GLenum FailFunc
; /* Fail function */
659 GLenum ZPassFunc
; /* Depth buffer pass function */
660 GLenum ZFailFunc
; /* Depth buffer fail function */
661 GLstencil Ref
; /* Reference value */
662 GLstencil ValueMask
; /* Value mask */
663 GLstencil Clear
; /* Clear value */
664 GLstencil WriteMask
; /* Write mask */
668 /* TexGenEnabled flags */
674 /* Texture Enabled flags */
675 #define TEXTURE0_1D 0x1 /* Texture unit 0 (default) */
676 #define TEXTURE0_2D 0x2
677 #define TEXTURE0_3D 0x4
678 #define TEXTURE0_CUBE 0x8
679 #define TEXTURE0_ANY (TEXTURE0_1D | TEXTURE0_2D | TEXTURE0_3D | TEXTURE0_CUBE)
680 #define TEXTURE1_1D (TEXTURE0_1D << 4) /* Texture unit 1 */
681 #define TEXTURE1_2D (TEXTURE0_2D << 4)
682 #define TEXTURE1_3D (TEXTURE0_3D << 4)
683 #define TEXTURE1_CUBE (TEXTURE0_CUBE << 4)
684 #define TEXTURE1_ANY (TEXTURE1_1D | TEXTURE1_2D | TEXTURE1_3D | TEXTURE1_CUBE)
685 #define TEXTURE2_1D (TEXTURE0_1D << 8) /* Texture unit 2 */
686 #define TEXTURE2_2D (TEXTURE0_2D << 8)
687 #define TEXTURE2_3D (TEXTURE0_3D << 8)
688 #define TEXTURE2_CUBE (TEXTURE0_CUBE << 8)
689 #define TEXTURE2_ANY (TEXTURE2_1D | TEXTURE2_2D | TEXTURE2_3D | TEXTURE2_CUBE)
690 #define TEXTURE3_1D (TEXTURE0_1D << 12) /* Texture unit 3 */
691 #define TEXTURE3_2D (TEXTURE0_2D << 12)
692 #define TEXTURE3_3D (TEXTURE0_3D << 12)
693 #define TEXTURE3_CUBE (TEXTURE0_CUBE << 12)
694 #define TEXTURE3_ANY (TEXTURE3_1D | TEXTURE3_2D | TEXTURE3_3D | TEXTURE3_CUBE)
695 #define TEXTURE4_1D (TEXTURE0_1D << 16) /* Texture unit 4 */
696 #define TEXTURE4_2D (TEXTURE0_2D << 16)
697 #define TEXTURE4_3D (TEXTURE0_3D << 16)
698 #define TEXTURE4_CUBE (TEXTURE0_CUBE << 16)
699 #define TEXTURE5_ANY (TEXTURE3_1D | TEXTURE3_2D | TEXTURE3_3D | TEXTURE3_CUBE)
700 #define TEXTURE5_1D (TEXTURE0_1D << 20) /* Texture unit 5 */
701 #define TEXTURE5_2D (TEXTURE0_2D << 20)
702 #define TEXTURE5_3D (TEXTURE0_3D << 20)
703 #define TEXTURE5_CUBE (TEXTURE0_CUBE << 20)
704 #define TEXTURE5_ANY (TEXTURE3_1D | TEXTURE3_2D | TEXTURE3_3D | TEXTURE3_CUBE)
705 #define TEXTURE6_1D (TEXTURE0_1D << 24) /* Texture unit 6 */
706 #define TEXTURE6_2D (TEXTURE0_2D << 24)
707 #define TEXTURE6_3D (TEXTURE0_3D << 24)
708 #define TEXTURE6_CUBE (TEXTURE0_CUBE << 24)
709 #define TEXTURE6_ANY (TEXTURE3_1D | TEXTURE3_2D | TEXTURE3_3D | TEXTURE3_CUBE)
710 #define TEXTURE7_1D (TEXTURE0_1D << 28) /* Texture unit 7 */
711 #define TEXTURE7_2D (TEXTURE0_2D << 28)
712 #define TEXTURE7_3D (TEXTURE0_3D << 28)
713 #define TEXTURE7_CUBE (TEXTURE0_CUBE << 28)
714 #define TEXTURE7_ANY (TEXTURE3_1D | TEXTURE3_2D | TEXTURE3_3D | TEXTURE3_CUBE)
716 /* Bitmap versions of the GL_ constants.
718 #define TEXGEN_SPHERE_MAP 0x1
719 #define TEXGEN_OBJ_LINEAR 0x2
720 #define TEXGEN_EYE_LINEAR 0x4
721 #define TEXGEN_REFLECTION_MAP_NV 0x8
722 #define TEXGEN_NORMAL_MAP_NV 0x10
724 #define TEXGEN_NEED_NORMALS (TEXGEN_SPHERE_MAP | \
725 TEXGEN_REFLECTION_MAP_NV | \
726 TEXGEN_NORMAL_MAP_NV)
727 #define TEXGEN_NEED_EYE_COORD (TEXGEN_SPHERE_MAP | \
728 TEXGEN_REFLECTION_MAP_NV | \
729 TEXGEN_NORMAL_MAP_NV | \
734 /* A selection of state flags to make driver and module's lives easier.
736 #define ENABLE_TEXGEN0 0x1
737 #define ENABLE_TEXGEN1 0x2
738 #define ENABLE_TEXGEN2 0x4
739 #define ENABLE_TEXGEN3 0x8
740 #define ENABLE_TEXGEN4 0x10
741 #define ENABLE_TEXGEN5 0x20
742 #define ENABLE_TEXGEN6 0x40
743 #define ENABLE_TEXGEN7 0x80
745 #define ENABLE_TEXMAT0 0x1 /* Ie. not the identity matrix */
746 #define ENABLE_TEXMAT1 0x2
747 #define ENABLE_TEXMAT2 0x4
748 #define ENABLE_TEXMAT3 0x8
749 #define ENABLE_TEXMAT4 0x10
750 #define ENABLE_TEXMAT5 0x20
751 #define ENABLE_TEXMAT6 0x40
752 #define ENABLE_TEXMAT7 0x80
754 #define ENABLE_TEXGEN(i) (ENABLE_TEXGEN0 << (i))
755 #define ENABLE_TEXMAT(i) (ENABLE_TEXMAT0 << (i))
758 * If teximage is color-index, texelOut returns GLchan[1].
759 * If teximage is depth, texelOut returns GLfloat[1].
760 * Otherwise, texelOut returns GLchan[4].
762 typedef void (*FetchTexelFunc
)( const struct gl_texture_image
*texImage
,
763 GLint col
, GLint row
, GLint img
,
766 /* Texture format record */
767 struct gl_texture_format
{
768 GLint MesaFormat
; /* One of the MESA_FORMAT_* values */
770 GLenum BaseFormat
; /* Either GL_ALPHA, GL_INTENSITY, GL_LUMINANCE,
771 * GL_LUMINANCE_ALPHA, GL_RGB, GL_RGBA,
772 * GL_COLOR_INDEX or GL_DEPTH_COMPONENT.
774 GLenum Type
; /* Internal type as GL enum value */
776 GLubyte RedBits
; /* Bits per texel component */
780 GLubyte LuminanceBits
;
781 GLubyte IntensityBits
;
787 FetchTexelFunc FetchTexel1D
; /* Texel fetch function pointers */
788 FetchTexelFunc FetchTexel2D
;
789 FetchTexelFunc FetchTexel3D
;
792 /* Texture image record */
793 struct gl_texture_image
{
794 GLenum Format
; /* GL_ALPHA, GL_LUMINANCE, GL_LUMINANCE_ALPHA,
795 * GL_INTENSITY, GL_RGB, GL_RGBA,
796 * GL_COLOR_INDEX or GL_DEPTH_COMPONENT only.
798 GLint IntFormat
; /* Internal format as given by the user */
799 GLuint Border
; /* 0 or 1 */
800 GLuint Width
; /* = 2^WidthLog2 + 2*Border */
801 GLuint Height
; /* = 2^HeightLog2 + 2*Border */
802 GLuint Depth
; /* = 2^DepthLog2 + 2*Border */
803 GLuint Width2
; /* = Width - 2*Border */
804 GLuint Height2
; /* = Height - 2*Border */
805 GLuint Depth2
; /* = Depth - 2*Border */
806 GLuint WidthLog2
; /* = log2(Width2) */
807 GLuint HeightLog2
; /* = log2(Height2) */
808 GLuint DepthLog2
; /* = log2(Depth2) */
809 GLuint MaxLog2
; /* = MAX(WidthLog2, HeightLog2) */
810 GLvoid
*Data
; /* Image data, accessed via FetchTexel() */
812 const struct gl_texture_format
*TexFormat
;
814 FetchTexelFunc FetchTexel
; /* Texel fetch function pointer */
816 GLboolean IsCompressed
; /* GL_ARB_texture_compression */
817 GLuint CompressedSize
; /* GL_ARB_texture_compression */
819 /* For device driver: */
820 void *DriverData
; /* Arbitrary device driver data */
824 /* Texture object record */
825 struct gl_texture_object
{
826 _glthread_Mutex Mutex
; /* for thread safety */
827 GLint RefCount
; /* reference count */
828 GLuint Name
; /* an unsigned integer */
829 GLuint Dimensions
; /* 1 or 2 or 3 or 6 (cube map) */
830 GLfloat Priority
; /* in [0,1] */
831 GLchan BorderColor
[4];
832 GLenum WrapS
; /* Wrap modes are: GL_CLAMP, REPEAT */
833 GLenum WrapT
; /* GL_CLAMP_TO_EDGE, and */
834 GLenum WrapR
; /* GL_CLAMP_TO_BORDER_ARB */
835 GLenum MinFilter
; /* minification filter */
836 GLenum MagFilter
; /* magnification filter */
837 GLfloat MinLod
; /* min lambda, OpenGL 1.2 */
838 GLfloat MaxLod
; /* max lambda, OpenGL 1.2 */
839 GLint BaseLevel
; /* min mipmap level, OpenGL 1.2 */
840 GLint MaxLevel
; /* max mipmap level, OpenGL 1.2 */
841 GLfloat MaxAnisotropy
; /* GL_EXT_texture_filter_anisotropic */
842 GLboolean CompareFlag
; /* GL_SGIX_shadow */
843 GLenum CompareOperator
; /* GL_SGIX_shadow */
844 GLchan ShadowAmbient
; /* GL_SGIX_shadow_ambient */
845 GLint _MaxLevel
; /* actual max mipmap level (q in the spec) */
846 GLfloat _MaxLambda
; /* = _MaxLevel - BaseLevel (q - b in spec) */
847 GLboolean GenerateMipmap
; /* GL_SGIS_generate_mipmap */
849 struct gl_texture_image
*Image
[MAX_TEXTURE_LEVELS
];
851 /* Texture cube faces */
852 /* Image[] is alias for *PosX[MAX_TEXTURE_LEVELS]; */
853 struct gl_texture_image
*NegX
[MAX_TEXTURE_LEVELS
];
854 struct gl_texture_image
*PosY
[MAX_TEXTURE_LEVELS
];
855 struct gl_texture_image
*NegY
[MAX_TEXTURE_LEVELS
];
856 struct gl_texture_image
*PosZ
[MAX_TEXTURE_LEVELS
];
857 struct gl_texture_image
*NegZ
[MAX_TEXTURE_LEVELS
];
859 /* GL_EXT_paletted_texture */
860 struct gl_color_table Palette
;
862 GLboolean Complete
; /* Is texture object complete? */
863 struct gl_texture_object
*Next
; /* Next in linked list */
865 /* For device driver: */
866 void *DriverData
; /* Arbitrary device driver data */
872 * Texture units are new with the multitexture extension.
874 struct gl_texture_unit
{
875 GLuint Enabled
; /* bitmask of TEXTURE0_1D, _2D, _3D, _CUBE */
876 GLuint _ReallyEnabled
; /* 0 or one of TEXTURE0_1D, _2D, _3D, _CUBE */
878 GLenum EnvMode
; /* GL_MODULATE, GL_DECAL, GL_BLEND, etc. */
880 GLuint TexGenEnabled
; /* Bitwise-OR of [STRQ]_BIT values */
881 GLenum GenModeS
; /* Tex coord generation mode, either */
882 GLenum GenModeT
; /* GL_OBJECT_LINEAR, or */
883 GLenum GenModeR
; /* GL_EYE_LINEAR, or */
884 GLenum GenModeQ
; /* GL_SPHERE_MAP */
889 GLuint _GenFlags
; /* bitwise or of GenBit[STRQ] */
890 GLfloat ObjectPlaneS
[4];
891 GLfloat ObjectPlaneT
[4];
892 GLfloat ObjectPlaneR
[4];
893 GLfloat ObjectPlaneQ
[4];
894 GLfloat EyePlaneS
[4];
895 GLfloat EyePlaneT
[4];
896 GLfloat EyePlaneR
[4];
897 GLfloat EyePlaneQ
[4];
898 GLfloat LodBias
; /* for biasing mipmap levels */
900 /* GL_EXT_texture_env_combine */
901 GLenum CombineModeRGB
; /* GL_REPLACE, GL_DECAL, GL_ADD, etc. */
902 GLenum CombineModeA
; /* GL_REPLACE, GL_DECAL, GL_ADD, etc. */
903 GLenum CombineSourceRGB
[3]; /* GL_PRIMARY_COLOR, GL_TEXTURE, etc. */
904 GLenum CombineSourceA
[3]; /* GL_PRIMARY_COLOR, GL_TEXTURE, etc. */
905 GLenum CombineOperandRGB
[3]; /* SRC_COLOR, ONE_MINUS_SRC_COLOR, etc */
906 GLenum CombineOperandA
[3]; /* SRC_ALPHA, ONE_MINUS_SRC_ALPHA, etc */
907 GLuint CombineScaleShiftRGB
; /* 0, 1 or 2 */
908 GLuint CombineScaleShiftA
; /* 0, 1 or 2 */
910 struct gl_texture_object
*Current1D
;
911 struct gl_texture_object
*Current2D
;
912 struct gl_texture_object
*Current3D
;
913 struct gl_texture_object
*CurrentCubeMap
; /* GL_ARB_texture_cube_map */
915 struct gl_texture_object
*_Current
; /* Points to really enabled tex obj */
917 struct gl_texture_object Saved1D
; /* only used by glPush/PopAttrib */
918 struct gl_texture_object Saved2D
;
919 struct gl_texture_object Saved3D
;
920 struct gl_texture_object SavedCubeMap
;
924 struct gl_texture_attrib
{
926 GLuint CurrentUnit
; /* Active texture unit */
928 GLuint _ReallyEnabled
; /* enables for all texture units: */
929 /* = (Unit[0]._ReallyEnabled << 0) | */
930 /* (Unit[1]._ReallyEnabled << 4) | */
931 /* (Unit[2]._ReallyEnabled << 8) | etc... */
933 GLuint _GenFlags
; /* for texgen */
934 GLuint _TexGenEnabled
;
935 GLuint _TexMatEnabled
;
937 struct gl_texture_unit Unit
[MAX_TEXTURE_UNITS
];
939 struct gl_texture_object
*Proxy1D
;
940 struct gl_texture_object
*Proxy2D
;
941 struct gl_texture_object
*Proxy3D
;
942 struct gl_texture_object
*ProxyCubeMap
;
944 /* GL_EXT_shared_texture_palette */
945 GLboolean SharedPalette
;
946 struct gl_color_table Palette
;
950 struct gl_transform_attrib
{
951 GLenum MatrixMode
; /* Matrix mode */
952 GLfloat EyeUserPlane
[MAX_CLIP_PLANES
][4];
953 GLfloat _ClipUserPlane
[MAX_CLIP_PLANES
][4]; /* derived */
954 GLboolean ClipEnabled
[MAX_CLIP_PLANES
];
955 GLubyte _AnyClip
; /* How many ClipEnabled? */
956 GLboolean Normalize
; /* Normalize all normals? */
957 GLboolean RescaleNormals
; /* GL_EXT_rescale_normal */
958 GLboolean RasterPositionUnclipped
; /* GL_IBM_rasterpos_clip */
962 struct gl_viewport_attrib
{
963 GLint X
, Y
; /* position */
964 GLsizei Width
, Height
; /* size */
965 GLfloat Near
, Far
; /* Depth buffer range */
966 GLmatrix _WindowMap
; /* Mapping transformation as a matrix. */
970 /* For the attribute stack: */
971 struct gl_attrib_node
{
974 struct gl_attrib_node
*next
;
979 * Client pixel packing/unpacking attributes
981 struct gl_pixelstore_attrib
{
986 GLint ImageHeight
; /* for GL_EXT_texture3D */
987 GLint SkipImages
; /* for GL_EXT_texture3D */
993 #define CA_CLIENT_DATA 0x1 /* Data not alloced by mesa */
997 * Client vertex array attributes
999 struct gl_client_array
{
1002 GLsizei Stride
; /* user-specified stride */
1003 GLsizei StrideB
; /* actual stride in bytes */
1010 struct gl_array_attrib
{
1011 struct gl_client_array Vertex
; /* client data descriptors */
1012 struct gl_client_array Normal
;
1013 struct gl_client_array Color
;
1014 struct gl_client_array SecondaryColor
;
1015 struct gl_client_array FogCoord
;
1016 struct gl_client_array Index
;
1017 struct gl_client_array TexCoord
[MAX_TEXTURE_UNITS
];
1018 struct gl_client_array EdgeFlag
;
1020 GLint TexCoordInterleaveFactor
;
1021 GLint ActiveTexture
; /* Client Active Texture */
1025 GLuint _Enabled
; /* _NEW_ARRAY_* - bit set if array enabled */
1026 GLuint NewState
; /* _NEW_ARRAY_* */
1030 struct gl_feedback
{
1032 GLuint _Mask
; /* FB_* bits */
1039 struct gl_selection
{
1041 GLuint BufferSize
; /* size of SelectBuffer */
1042 GLuint BufferCount
; /* number of values in SelectBuffer */
1043 GLuint Hits
; /* number of records in SelectBuffer */
1044 GLuint NameStackDepth
;
1045 GLuint NameStack
[MAX_NAME_STACK_DEPTH
];
1047 GLfloat HitMinZ
, HitMaxZ
;
1052 * 1-D Evaluator control points
1055 GLuint Order
; /* Number of control points */
1056 GLfloat u1
, u2
, du
; /* u1, u2, 1.0/(u2-u1) */
1057 GLfloat
*Points
; /* Points to contiguous control points */
1062 * 2-D Evaluator control points
1065 GLuint Uorder
; /* Number of control points in U dimension */
1066 GLuint Vorder
; /* Number of control points in V dimension */
1069 GLfloat
*Points
; /* Points to contiguous control points */
1074 * All evalutator control points
1076 struct gl_evaluators
{
1078 struct gl_1d_map Map1Vertex3
;
1079 struct gl_1d_map Map1Vertex4
;
1080 struct gl_1d_map Map1Index
;
1081 struct gl_1d_map Map1Color4
;
1082 struct gl_1d_map Map1Normal
;
1083 struct gl_1d_map Map1Texture1
;
1084 struct gl_1d_map Map1Texture2
;
1085 struct gl_1d_map Map1Texture3
;
1086 struct gl_1d_map Map1Texture4
;
1089 struct gl_2d_map Map2Vertex3
;
1090 struct gl_2d_map Map2Vertex4
;
1091 struct gl_2d_map Map2Index
;
1092 struct gl_2d_map Map2Color4
;
1093 struct gl_2d_map Map2Normal
;
1094 struct gl_2d_map Map2Texture1
;
1095 struct gl_2d_map Map2Texture2
;
1096 struct gl_2d_map Map2Texture3
;
1097 struct gl_2d_map Map2Texture4
;
1102 * State which can be shared by multiple contexts:
1104 struct gl_shared_state
{
1105 _glthread_Mutex Mutex
; /* for thread safety */
1106 GLint RefCount
; /* Reference count */
1107 struct _mesa_HashTable
*DisplayList
; /* Display lists hash table */
1108 struct _mesa_HashTable
*TexObjects
; /* Texture objects hash table */
1109 struct gl_texture_object
*TexObjectList
;/* Linked list of texture objects */
1111 /* Default texture objects (shared by all multi-texture units) */
1112 struct gl_texture_object
*Default1D
;
1113 struct gl_texture_object
*Default2D
;
1114 struct gl_texture_object
*Default3D
;
1115 struct gl_texture_object
*DefaultCubeMap
;
1117 void *DriverData
; /* Device driver shared state */
1122 * A "frame buffer" is a color buffer and its optional ancillary buffers:
1123 * depth, accum, stencil, and software-simulated alpha buffers.
1124 * In C++ terms, think of this as a base class from which device drivers
1125 * will make derived classes.
1127 struct gl_frame_buffer
{
1128 GLvisual Visual
; /* The corresponding visual */
1130 GLint Width
, Height
; /* size of frame buffer in pixels */
1132 GLboolean UseSoftwareDepthBuffer
;
1133 GLboolean UseSoftwareAccumBuffer
;
1134 GLboolean UseSoftwareStencilBuffer
;
1135 GLboolean UseSoftwareAlphaBuffers
;
1137 /* Software depth (aka Z) buffer */
1138 GLvoid
*DepthBuffer
; /* array [Width*Height] of GLushort or GLuint*/
1140 /* Software stencil buffer */
1141 GLstencil
*Stencil
; /* array [Width*Height] of GLstencil values */
1143 /* Software accumulation buffer */
1144 GLaccum
*Accum
; /* array [4*Width*Height] of GLaccum values */
1146 /* Software alpha planes */
1147 GLchan
*FrontLeftAlpha
; /* array [Width*Height] of GLubyte */
1148 GLchan
*BackLeftAlpha
; /* array [Width*Height] of GLubyte */
1149 GLchan
*FrontRightAlpha
; /* array [Width*Height] of GLubyte */
1150 GLchan
*BackRightAlpha
; /* array [Width*Height] of GLubyte */
1151 GLchan
*Alpha
; /* Points to current alpha buffer */
1153 /* Drawing bounds: intersection of window size and scissor box */
1154 GLint _Xmin
, _Ymin
; /* inclusive */
1155 GLint _Xmax
, _Ymax
; /* exclusive */
1160 * Constants which may be overriden by device driver during context creation
1161 * but are never changed after that.
1163 struct gl_constants
{
1164 GLint MaxTextureLevels
;
1165 GLint Max3DTextureLevels
;
1166 GLint MaxCubeTextureLevels
;
1167 GLuint MaxTextureUnits
;
1168 GLfloat MaxTextureMaxAnisotropy
; /* GL_EXT_texture_filter_anisotropic */
1169 GLuint MaxArrayLockSize
;
1171 GLfloat MinPointSize
, MaxPointSize
; /* aliased */
1172 GLfloat MinPointSizeAA
, MaxPointSizeAA
; /* antialiased */
1173 GLfloat PointSizeGranularity
;
1174 GLfloat MinLineWidth
, MaxLineWidth
; /* aliased */
1175 GLfloat MinLineWidthAA
, MaxLineWidthAA
; /* antialiased */
1176 GLfloat LineWidthGranularity
;
1177 GLuint NumAuxBuffers
;
1178 GLuint MaxColorTableSize
;
1179 GLuint MaxConvolutionWidth
;
1180 GLuint MaxConvolutionHeight
;
1181 GLuint NumCompressedTextureFormats
; /* GL_ARB_texture_compression */
1182 GLenum CompressedTextureFormats
[MAX_COMPRESSED_TEXTURE_FORMATS
];
1183 GLuint MaxClipPlanes
;
1189 * List of extensions.
1192 struct gl_extensions
{
1194 struct extension
*ext_list
;
1195 /* Flags to quickly test if certain extensions are available.
1196 * Not every extension needs to have such a flag, but it's encouraged.
1198 GLboolean ARB_imaging
;
1199 GLboolean ARB_multisample
;
1200 GLboolean ARB_multitexture
;
1201 GLboolean ARB_texture_border_clamp
;
1202 GLboolean ARB_texture_compression
;
1203 GLboolean ARB_texture_cube_map
;
1204 GLboolean ARB_texture_env_combine
;
1205 GLboolean ARB_texture_env_dot3
;
1206 GLboolean EXT_blend_color
;
1207 GLboolean EXT_blend_func_separate
;
1208 GLboolean EXT_blend_logic_op
;
1209 GLboolean EXT_blend_minmax
;
1210 GLboolean EXT_blend_subtract
;
1211 GLboolean EXT_clip_volume_hint
;
1212 GLboolean EXT_convolution
;
1213 GLboolean EXT_compiled_vertex_array
;
1214 GLboolean EXT_fog_coord
;
1215 GLboolean EXT_histogram
;
1216 GLboolean EXT_packed_pixels
;
1217 GLboolean EXT_paletted_texture
;
1218 GLboolean EXT_point_parameters
;
1219 GLboolean EXT_polygon_offset
;
1220 GLboolean EXT_rescale_normal
;
1221 GLboolean EXT_secondary_color
;
1222 GLboolean EXT_shared_texture_palette
;
1223 GLboolean EXT_stencil_wrap
;
1224 GLboolean EXT_texture3D
;
1225 GLboolean EXT_texture_compression_s3tc
;
1226 GLboolean EXT_texture_env_add
;
1227 GLboolean EXT_texture_env_combine
;
1228 GLboolean EXT_texture_env_dot3
;
1229 GLboolean EXT_texture_filter_anisotropic
;
1230 GLboolean EXT_texture_object
;
1231 GLboolean EXT_texture_lod_bias
;
1232 GLboolean EXT_vertex_array_set
;
1233 GLboolean HP_occlusion_test
;
1234 GLboolean IBM_rasterpos_clip
;
1235 GLboolean INGR_blend_func_separate
;
1236 GLboolean MESA_window_pos
;
1237 GLboolean MESA_resize_buffers
;
1238 GLboolean MESA_sprite_point
;
1239 GLboolean NV_blend_square
;
1240 GLboolean NV_texgen_reflection
;
1241 GLboolean SGI_color_matrix
;
1242 GLboolean SGI_color_table
;
1243 GLboolean SGIS_generate_mipmap
;
1244 GLboolean SGIS_pixel_texture
;
1245 GLboolean SGIS_texture_edge_clamp
;
1246 GLboolean SGIX_depth_texture
;
1247 GLboolean SGIX_pixel_texture
;
1248 GLboolean SGIX_shadow
;
1249 GLboolean SGIX_shadow_ambient
;
1250 GLboolean _3DFX_texture_compression_FXT1
;
1256 * Bits for image transfer operations (ctx->ImageTransferState).
1258 #define IMAGE_SCALE_BIAS_BIT 0x1
1259 #define IMAGE_SHIFT_OFFSET_BIT 0x2
1260 #define IMAGE_MAP_COLOR_BIT 0x4
1261 #define IMAGE_COLOR_TABLE_BIT 0x8
1262 #define IMAGE_CONVOLUTION_BIT 0x10
1263 #define IMAGE_POST_CONVOLUTION_SCALE_BIAS 0x20
1264 #define IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT 0x40
1265 #define IMAGE_COLOR_MATRIX_BIT 0x80
1266 #define IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT 0x100
1267 #define IMAGE_HISTOGRAM_BIT 0x200
1268 #define IMAGE_MIN_MAX_BIT 0x400
1270 /* transfer ops up to convolution: */
1271 #define IMAGE_PRE_CONVOLUTION_BITS (IMAGE_SCALE_BIAS_BIT | \
1272 IMAGE_SHIFT_OFFSET_BIT | \
1273 IMAGE_MAP_COLOR_BIT | \
1274 IMAGE_COLOR_TABLE_BIT)
1276 /* transfer ops after convolution: */
1277 #define IMAGE_POST_CONVOLUTION_BITS (IMAGE_POST_CONVOLUTION_SCALE_BIAS | \
1278 IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT | \
1279 IMAGE_COLOR_MATRIX_BIT | \
1280 IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT |\
1281 IMAGE_HISTOGRAM_BIT | \
1286 * Bits to indicate what state has changed. 6 unused flags.
1288 #define _NEW_MODELVIEW 0x1 /* ctx->ModelView */
1289 #define _NEW_PROJECTION 0x2 /* ctx->Projection */
1290 #define _NEW_TEXTURE_MATRIX 0x4 /* ctx->TextureMatrix */
1291 #define _NEW_COLOR_MATRIX 0x8 /* ctx->ColorMatrix */
1292 #define _NEW_ACCUM 0x10 /* ctx->Accum */
1293 #define _NEW_COLOR 0x20 /* ctx->Color */
1294 #define _NEW_DEPTH 0x40 /* ctx->Depth */
1295 #define _NEW_EVAL 0x80 /* ctx->Eval, ctx->EvalMap */
1296 #define _NEW_FOG 0x100 /* ctx->Fog */
1297 #define _NEW_HINT 0x200 /* ctx->Hint */
1298 #define _NEW_LIGHT 0x400 /* ctx->Light */
1299 #define _NEW_LINE 0x800 /* ctx->Line */
1300 #define _NEW_PIXEL 0x1000 /* ctx->Pixel */
1301 #define _NEW_POINT 0x2000 /* ctx->Point */
1302 #define _NEW_POLYGON 0x4000 /* ctx->Polygon */
1303 #define _NEW_POLYGONSTIPPLE 0x8000 /* ctx->PolygonStipple */
1304 #define _NEW_SCISSOR 0x10000 /* ctx->Scissor */
1305 #define _NEW_STENCIL 0x20000 /* ctx->Stencil */
1306 #define _NEW_TEXTURE 0x40000 /* ctx->Texture */
1307 #define _NEW_TRANSFORM 0x80000 /* ctx->Transform */
1308 #define _NEW_VIEWPORT 0x100000 /* ctx->Viewport */
1309 #define _NEW_PACKUNPACK 0x200000 /* ctx->Pack, ctx->Unpack */
1310 #define _NEW_ARRAY 0x400000 /* ctx->Array */
1311 #define _NEW_RENDERMODE 0x800000 /* RenderMode, Feedback, Select */
1312 #define _NEW_BUFFERS 0x1000000 /* ctx->Visual, ctx->DrawBuffer, */
1313 #define _NEW_MULTISAMPLE 0x2000000 /* ctx->Multisample */
1318 /* Bits to track array state changes (also used to summarize array enabled)
1320 #define _NEW_ARRAY_VERTEX 0x1
1321 #define _NEW_ARRAY_COLOR 0x2
1322 #define _NEW_ARRAY_NORMAL 0x4
1323 #define _NEW_ARRAY_INDEX 0x8
1324 #define _NEW_ARRAY_EDGEFLAG 0x10
1325 #define _NEW_ARRAY_SECONDARYCOLOR 0x20
1326 #define _NEW_ARRAY_FOGCOORD 0x40
1327 #define _NEW_ARRAY_TEXCOORD_0 0x80
1328 #define _NEW_ARRAY_TEXCOORD_1 0x100
1329 #define _NEW_ARRAY_TEXCOORD_2 0x200
1330 #define _NEW_ARRAY_TEXCOORD_3 0x400
1331 #define _NEW_ARRAY_TEXCOORD_4 0x800
1332 #define _NEW_ARRAY_TEXCOORD_5 0x1000
1333 #define _NEW_ARRAY_TEXCOORD_6 0x2000
1334 #define _NEW_ARRAY_TEXCOORD_7 0x4000
1335 #define _NEW_ARRAY_ALL 0x7fff
1337 #define _NEW_ARRAY_TEXCOORD(i) (_NEW_ARRAY_TEXCOORD_0 << (i))
1339 /* A bunch of flags that we think might be useful to drivers.
1341 #define DD_FLATSHADE 0x1
1342 #define DD_SEPARATE_SPECULAR 0x2
1343 #define DD_TRI_CULL_FRONT_BACK 0x4 /* special case on some hw */
1344 #define DD_TRI_LIGHT_TWOSIDE 0x8
1345 #define DD_TRI_UNFILLED 0x10
1346 #define DD_TRI_SMOOTH 0x20
1347 #define DD_TRI_STIPPLE 0x40
1348 #define DD_TRI_OFFSET 0x80
1349 #define DD_LINE_SMOOTH 0x100
1350 #define DD_LINE_STIPPLE 0x200
1351 #define DD_LINE_WIDTH 0x400
1352 #define DD_POINT_SMOOTH 0x800
1353 #define DD_POINT_SIZE 0x1000
1354 #define DD_POINT_ATTEN 0x2000
1356 /* Define the state changes under which each of these bits might change
1358 #define _DD_NEW_FLATSHADE _NEW_LIGHT
1359 #define _DD_NEW_SEPARATE_SPECULAR (_NEW_LIGHT | _NEW_FOG)
1360 #define _DD_NEW_TRI_CULL_FRONT_BACK _NEW_POLYGON
1361 #define _DD_NEW_TRI_LIGHT_TWOSIDE _NEW_LIGHT
1362 #define _DD_NEW_TRI_UNFILLED _NEW_POLYGON
1363 #define _DD_NEW_TRI_SMOOTH _NEW_POLYGON
1364 #define _DD_NEW_TRI_STIPPLE _NEW_POLYGON
1365 #define _DD_NEW_TRI_OFFSET _NEW_POLYGON
1366 #define _DD_NEW_LINE_SMOOTH _NEW_LINE
1367 #define _DD_NEW_LINE_STIPPLE _NEW_LINE
1368 #define _DD_NEW_LINE_WIDTH _NEW_LINE
1369 #define _DD_NEW_POINT_SMOOTH _NEW_POINT
1370 #define _DD_NEW_POINT_SIZE _NEW_POINT
1371 #define _DD_NEW_POINT_ATTEN _NEW_POINT
1373 #define _MESA_NEW_NEED_EYE_COORDS (_NEW_LIGHT | \
1378 #define _MESA_NEW_NEED_NORMALS (_NEW_LIGHT | \
1381 #define _IMAGE_NEW_TRANSFER_STATE (_NEW_PIXEL | _NEW_COLOR_MATRIX)
1384 #define NEED_NORMALS_TEXGEN 0x1
1385 #define NEED_NORMALS_LIGHT 0x2
1387 #define NEED_EYE_TEXGEN 0x1
1388 #define NEED_EYE_LIGHT 0x2
1389 #define NEED_EYE_LIGHT_MODELVIEW 0x4
1390 #define NEED_EYE_POINT_ATTEN 0x8
1394 * Forward declaration of display list datatypes:
1397 typedef union node Node
;
1400 /* This has to be included here. */
1405 * Core Mesa's support for tnl modules:
1407 #define NUM_VERTEX_FORMAT_ENTRIES (sizeof(GLvertexformat) / sizeof(void *))
1409 struct gl_tnl_module
{
1410 /* Vertex format to be lazily swapped into current dispatch.
1412 GLvertexformat
*Current
;
1414 /* Record of functions swapped out. On restore, only need to swap
1415 * these functions back in.
1417 void *Swapped
[NUM_VERTEX_FORMAT_ENTRIES
][2];
1423 * The library context:
1425 struct __GLcontextRec
{
1427 ** Os related interfaces; these *must* be the first members of this
1428 ** structure, because they are exposed to the outside world (i.e. GLX
1431 __GLimports imports
;
1432 __GLexports exports
;
1434 /* State possibly shared with other contexts in the address space */
1435 struct gl_shared_state
*Shared
;
1437 /* API function pointer tables */
1438 struct _glapi_table
*Save
; /* Display list save funcs */
1439 struct _glapi_table
*Exec
; /* Execute funcs */
1440 struct _glapi_table
*CurrentDispatch
; /* == Save or Exec !! */
1442 GLboolean ExecPrefersFloat
; /* What preference for color conversion? */
1443 GLboolean SavePrefersFloat
;
1446 GLframebuffer
*DrawBuffer
; /* buffer for writing */
1447 GLframebuffer
*ReadBuffer
; /* buffer for reading */
1449 /* Driver function pointer table */
1450 struct dd_function_table Driver
;
1452 void *DriverCtx
; /* Points to device driver context/state */
1453 void *DriverMgrCtx
; /* Points to device driver manager (optional)*/
1455 /* Core/Driver constants */
1456 struct gl_constants Const
;
1458 /* Modelview matrix and stack */
1459 GLmatrix ModelView
; /* current matrix, not stored on stack */
1460 GLuint ModelViewStackDepth
;
1461 GLmatrix ModelViewStack
[MAX_MODELVIEW_STACK_DEPTH
- 1];
1463 /* Projection matrix and stack */
1464 GLmatrix ProjectionMatrix
; /* current matrix, not stored on stack */
1465 GLuint ProjectionStackDepth
;
1466 GLmatrix ProjectionStack
[MAX_PROJECTION_STACK_DEPTH
- 1];
1468 /* Combined modelview and projection matrix */
1469 GLmatrix _ModelProjectMatrix
;
1471 /* Texture matrix and stack */
1472 GLmatrix TextureMatrix
[MAX_TEXTURE_UNITS
];
1473 GLuint TextureStackDepth
[MAX_TEXTURE_UNITS
];
1474 GLmatrix TextureStack
[MAX_TEXTURE_UNITS
][MAX_TEXTURE_STACK_DEPTH
- 1];
1476 /* Color matrix and stack */
1477 GLmatrix ColorMatrix
;
1478 GLuint ColorStackDepth
;
1479 GLmatrix ColorStack
[MAX_COLOR_STACK_DEPTH
- 1];
1482 GLuint CallDepth
; /* Current recursion calling depth */
1483 GLboolean ExecuteFlag
; /* Execute GL commands? */
1484 GLboolean CompileFlag
; /* Compile GL commands into display list? */
1485 Node
*CurrentListPtr
; /* Head of list being compiled */
1486 GLuint CurrentListNum
; /* Number of the list being compiled */
1487 Node
*CurrentBlock
; /* Pointer to current block of nodes */
1488 GLuint CurrentPos
; /* Index into current block of nodes */
1491 struct gl_extensions Extensions
;
1493 /* Renderer attribute stack */
1494 GLuint AttribStackDepth
;
1495 struct gl_attrib_node
*AttribStack
[MAX_ATTRIB_STACK_DEPTH
];
1497 /* Renderer attribute groups */
1498 struct gl_accum_attrib Accum
;
1499 struct gl_colorbuffer_attrib Color
;
1500 struct gl_current_attrib Current
;
1501 struct gl_depthbuffer_attrib Depth
;
1502 struct gl_eval_attrib Eval
;
1503 struct gl_fog_attrib Fog
;
1504 struct gl_hint_attrib Hint
;
1505 struct gl_light_attrib Light
;
1506 struct gl_line_attrib Line
;
1507 struct gl_list_attrib List
;
1508 struct gl_multisample_attrib Multisample
;
1509 struct gl_pixel_attrib Pixel
;
1510 struct gl_point_attrib Point
;
1511 struct gl_polygon_attrib Polygon
;
1512 GLuint PolygonStipple
[32];
1513 struct gl_scissor_attrib Scissor
;
1514 struct gl_stencil_attrib Stencil
;
1515 struct gl_texture_attrib Texture
;
1516 struct gl_transform_attrib Transform
;
1517 struct gl_viewport_attrib Viewport
;
1519 /* Other attribute groups */
1520 struct gl_histogram_attrib Histogram
;
1521 struct gl_minmax_attrib MinMax
;
1522 struct gl_convolution_attrib Convolution1D
;
1523 struct gl_convolution_attrib Convolution2D
;
1524 struct gl_convolution_attrib Separable2D
;
1526 /* Client attribute stack */
1527 GLuint ClientAttribStackDepth
;
1528 struct gl_attrib_node
*ClientAttribStack
[MAX_CLIENT_ATTRIB_STACK_DEPTH
];
1530 /* Client attribute groups */
1531 struct gl_array_attrib Array
; /* Vertex arrays */
1532 struct gl_pixelstore_attrib Pack
; /* Pixel packing */
1533 struct gl_pixelstore_attrib Unpack
; /* Pixel unpacking */
1535 struct gl_evaluators EvalMap
; /* All evaluators */
1536 struct gl_feedback Feedback
; /* Feedback */
1537 struct gl_selection Select
; /* Selection */
1539 struct gl_color_table ColorTable
; /* Pre-convolution */
1540 struct gl_color_table ProxyColorTable
; /* Pre-convolution */
1541 struct gl_color_table PostConvolutionColorTable
;
1542 struct gl_color_table ProxyPostConvolutionColorTable
;
1543 struct gl_color_table PostColorMatrixColorTable
;
1544 struct gl_color_table ProxyPostColorMatrixColorTable
;
1546 GLenum ErrorValue
; /* Last error code */
1547 GLenum RenderMode
; /* either GL_RENDER, GL_SELECT, GL_FEEDBACK */
1548 GLuint NewState
; /* bitwise-or of _NEW_* flags */
1551 GLuint _TriangleCaps
; /* bitwise-or of DD_* flags */
1552 GLuint _ImageTransferState
;/* bitwise-or of IMAGE_*_BIT flags */
1553 GLfloat _EyeZDir
[3];
1554 GLfloat _ModelViewInvScale
;
1555 GLuint _NeedEyeCoords
;
1556 GLuint _NeedNormals
; /* Are vertex normal vectors needed? */
1558 struct gl_shine_tab
*_ShineTable
[2]; /* Active shine tables */
1559 struct gl_shine_tab
*_ShineTabList
; /* Mru list of inactive shine tables */
1561 struct gl_list_extensions listext
; /* driver dlist extensions */
1564 GLboolean OcclusionResult
; /* GL_HP_occlusion_test */
1565 GLboolean OcclusionResultSaved
; /* GL_HP_occlusion_test */
1567 /* Z buffer stuff */
1568 GLuint DepthMax
; /* Max depth buffer value */
1569 GLfloat DepthMaxF
; /* Float max depth buffer value */
1570 GLfloat MRD
; /* minimum resolvable difference in Z values */
1572 /* Should 3Dfx Glide driver catch signals? */
1573 GLboolean CatchSignals
;
1575 /* For debugging/development only */
1577 GLboolean FirstTimeCurrent
;
1579 /* Dither disable via MESA_NO_DITHER env var */
1582 GLboolean Rendering
;
1584 #if defined(MESA_TRACE)
1585 struct _glapi_table
*TraceDispatch
;
1586 trace_context_t
*TraceCtx
;
1588 void *TraceDispatch
;
1592 /* Core tnl module support */
1593 struct gl_tnl_module TnlModule
;
1595 /* Hooks for module contexts. These will eventually live
1596 * in the driver or elsewhere.
1598 void *swrast_context
;
1599 void *swsetup_context
;
1600 void *swtnl_context
;
1602 void *acache_context
;
1607 /* The string names for GL_POINT, GL_LINE_LOOP, etc */
1608 extern const char *_mesa_prim_name
[GL_POLYGON
+4];
1612 extern int MESA_VERBOSE
;
1613 extern int MESA_DEBUG_FLAGS
;
1615 # define MESA_VERBOSE 0
1616 # define MESA_DEBUG_FLAGS 0
1624 VERBOSE_VARRAY
= 0x0001,
1625 VERBOSE_TEXTURE
= 0x0002,
1626 VERBOSE_IMMEDIATE
= 0x0004,
1627 VERBOSE_PIPELINE
= 0x0008,
1628 VERBOSE_DRIVER
= 0x0010,
1629 VERBOSE_STATE
= 0x0020,
1630 VERBOSE_API
= 0x0040,
1631 VERBOSE_DISPLAY_LIST
= 0x0200,
1632 VERBOSE_LIGHTING
= 0x0400
1637 DEBUG_ALWAYS_FLUSH
= 0x1
1642 #define Elements(x) sizeof(x)/sizeof(*(x))
1646 /* Eventually let the driver specify what statechanges require a flush:
1648 #define FLUSH_VERTICES(ctx, newstate) \
1650 if (ctx->Driver.NeedFlush & FLUSH_STORED_VERTICES) \
1651 ctx->Driver.FlushVertices(ctx, FLUSH_STORED_VERTICES); \
1652 ctx->NewState |= newstate; \
1655 #define FLUSH_CURRENT(ctx, newstate) \
1657 if (ctx->Driver.NeedFlush & FLUSH_UPDATE_CURRENT) \
1658 ctx->Driver.FlushVertices(ctx, FLUSH_UPDATE_CURRENT); \
1659 ctx->NewState |= newstate; \
1662 #define ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, retval) \
1664 if (ctx->Driver.CurrentExecPrimitive != PRIM_OUTSIDE_BEGIN_END) { \
1665 _mesa_error( ctx, GL_INVALID_OPERATION, "begin/end" ); \
1670 #define ASSERT_OUTSIDE_BEGIN_END(ctx) \
1672 if (ctx->Driver.CurrentExecPrimitive != PRIM_OUTSIDE_BEGIN_END) { \
1673 _mesa_error( ctx, GL_INVALID_OPERATION, "begin/end" ); \
1678 #define ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx) \
1680 ASSERT_OUTSIDE_BEGIN_END(ctx); \
1681 FLUSH_VERTICES(ctx, 0); \
1684 #define ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH_WITH_RETVAL(ctx, retval) \
1686 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, retval); \
1687 FLUSH_VERTICES(ctx, 0); \
1693 #endif /* TYPES_H */