1 /* $Id: mtypes.h,v 1.27 2001/03/18 08:53:49 gareth 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 /* This is a macro on IRIX */
50 /* Please try to mark derived values with a leading underscore ('_').
54 * Color channel data type:
57 typedef GLubyte GLchan
;
59 #define CHAN_MAXF 255.0F
60 #define CHAN_TYPE GL_UNSIGNED_BYTE
62 typedef GLushort GLchan
;
63 #define CHAN_MAX 65535
64 #define CHAN_MAXF 65535.0F
65 #define CHAN_TYPE GL_UNSIGNED_SHORT
67 typedef GLfloat GLchan
;
69 #define CHAN_MAXF 1.0F
70 #define CHAN_TYPE GL_FLOAT
72 #error illegal number of color channel bits
77 * Accumulation buffer data type:
80 typedef GLbyte GLaccum
;
82 typedef GLshort GLaccum
;
84 # error "illegal number of accumulation bits"
89 * Stencil buffer data type:
92 typedef GLubyte GLstencil
;
93 # define STENCIL_MAX 0xff
94 #elif STENCIL_BITS==16
95 typedef GLushort GLstencil
;
96 # define STENCIL_MAX 0xffff
98 # error "illegal number of stencil bits"
103 * Depth buffer data type:
105 typedef GLuint GLdepth
; /* Must be 32-bits! */
109 * Fixed point data type:
116 * Some forward type declarations
118 struct _mesa_HashTable
;
119 struct gl_texture_image
;
120 struct gl_texture_object
;
121 typedef struct __GLcontextRec GLcontext
;
122 typedef struct __GLcontextModesRec GLvisual
;
123 typedef struct gl_frame_buffer GLframebuffer
;
127 /* Maximum number of temporary vertices required for clipping. (Used
128 * in array_cache and tnl modules).
130 #define MAX_CLIPPED_VERTICES ((2 * (6 + MAX_CLIP_PLANES))+1)
133 /* Data structure for color tables */
134 struct gl_color_table
{
135 GLenum Format
; /* GL_ALPHA, GL_RGB, GL_RGB, etc */
137 GLuint Size
; /* number of entries (rows) in table */
138 GLvoid
*Table
; /* either GLfloat * or GLchan * */
139 GLboolean FloatTable
; /* are entries stored as floats? */
144 GLubyte LuminanceSize
;
145 GLubyte IntensitySize
;
150 * Bit flags used for updating material values.
152 #define FRONT_AMBIENT_BIT 0x1
153 #define BACK_AMBIENT_BIT 0x2
154 #define FRONT_DIFFUSE_BIT 0x4
155 #define BACK_DIFFUSE_BIT 0x8
156 #define FRONT_SPECULAR_BIT 0x10
157 #define BACK_SPECULAR_BIT 0x20
158 #define FRONT_EMISSION_BIT 0x40
159 #define BACK_EMISSION_BIT 0x80
160 #define FRONT_SHININESS_BIT 0x100
161 #define BACK_SHININESS_BIT 0x200
162 #define FRONT_INDEXES_BIT 0x400
163 #define BACK_INDEXES_BIT 0x800
165 #define FRONT_MATERIAL_BITS (FRONT_EMISSION_BIT | FRONT_AMBIENT_BIT | \
166 FRONT_DIFFUSE_BIT | FRONT_SPECULAR_BIT | \
167 FRONT_SHININESS_BIT | FRONT_INDEXES_BIT)
169 #define BACK_MATERIAL_BITS (BACK_EMISSION_BIT | BACK_AMBIENT_BIT | \
170 BACK_DIFFUSE_BIT | BACK_SPECULAR_BIT | \
171 BACK_SHININESS_BIT | BACK_INDEXES_BIT)
173 #define ALL_MATERIAL_BITS (FRONT_MATERIAL_BITS | BACK_MATERIAL_BITS)
178 * Specular exponent and material shininess lookup table sizes:
180 #define EXP_TABLE_SIZE 512
181 #define SHINE_TABLE_SIZE 256
183 struct gl_shine_tab
{
184 struct gl_shine_tab
*next
, *prev
;
185 GLfloat tab
[SHINE_TABLE_SIZE
+1];
192 struct gl_light
*next
; /* double linked list with sentinel */
193 struct gl_light
*prev
;
195 GLfloat Ambient
[4]; /* ambient color */
196 GLfloat Diffuse
[4]; /* diffuse color */
197 GLfloat Specular
[4]; /* specular color */
198 GLfloat EyePosition
[4]; /* position in eye coordinates */
199 GLfloat EyeDirection
[4]; /* spotlight dir in eye coordinates */
200 GLfloat SpotExponent
;
201 GLfloat SpotCutoff
; /* in degress */
202 GLfloat _CosCutoff
; /* = MAX(0, cos(SpotCutoff)) */
203 GLfloat ConstantAttenuation
;
204 GLfloat LinearAttenuation
;
205 GLfloat QuadraticAttenuation
;
206 GLboolean Enabled
; /* On/off flag */
209 GLuint _Flags
; /* State */
211 GLfloat _Position
[4]; /* position in eye/obj coordinates */
212 GLfloat _VP_inf_norm
[3]; /* Norm direction to infinite light */
213 GLfloat _h_inf_norm
[3]; /* Norm( _VP_inf_norm + <0,0,1> ) */
214 GLfloat _NormDirection
[4]; /* normalized spotlight direction */
215 GLfloat _VP_inf_spot_attenuation
;
217 GLfloat _SpotExpTable
[EXP_TABLE_SIZE
][2]; /* to replace a pow() call */
218 GLfloat _MatAmbient
[2][3]; /* material ambient * light ambient */
219 GLfloat _MatDiffuse
[2][3]; /* material diffuse * light diffuse */
220 GLfloat _MatSpecular
[2][3]; /* material spec * light specular */
221 GLfloat _dli
; /* CI diffuse light intensity */
222 GLfloat _sli
; /* CI specular light intensity */
226 struct gl_lightmodel
{
227 GLfloat Ambient
[4]; /* ambient color */
228 GLboolean LocalViewer
; /* Local (or infinite) view point? */
229 GLboolean TwoSide
; /* Two (or one) sided lighting? */
230 GLenum ColorControl
; /* either GL_SINGLE_COLOR */
231 /* or GL_SEPARATE_SPECULAR_COLOR */
242 GLfloat AmbientIndex
; /* for color index lighting */
243 GLfloat DiffuseIndex
; /* for color index lighting */
244 GLfloat SpecularIndex
; /* for color index lighting */
249 * Attribute structures:
250 * We define a struct for each attribute group to make pushing and
251 * popping attributes easy. Also it's a good organization.
253 struct gl_accum_attrib
{
254 GLfloat ClearColor
[4]; /* Accumulation buffer clear color */
259 * Used in DrawDestMask below
261 #define FRONT_LEFT_BIT 1
262 #define FRONT_RIGHT_BIT 2
263 #define BACK_LEFT_BIT 4
264 #define BACK_RIGHT_BIT 8
267 struct gl_colorbuffer_attrib
{
268 GLuint ClearIndex
; /* Index to use for glClear */
269 GLchan ClearColor
[4]; /* Color to use for glClear */
271 GLuint IndexMask
; /* Color index write mask */
272 GLubyte ColorMask
[4]; /* Each flag is 0xff or 0x0 */
274 GLenum DrawBuffer
; /* Which buffer to draw into */
275 GLenum DriverDrawBuffer
; /* Current device driver dest buffer */
276 GLboolean MultiDrawBuffer
; /* Drawing to mutliple buffers? */
277 GLubyte DrawDestMask
; /* bitwise-OR of bitflags above */
280 GLboolean AlphaEnabled
; /* Alpha test enabled flag */
281 GLenum AlphaFunc
; /* Alpha test function */
282 GLchan AlphaRef
; /* Alpha ref value as GLchan */
285 GLboolean BlendEnabled
; /* Blending enabled flag */
286 GLenum BlendSrcRGB
; /* Blending source operator */
287 GLenum BlendDstRGB
; /* Blending destination operator */
288 GLenum BlendSrcA
; /* GL_INGR_blend_func_separate */
289 GLenum BlendDstA
; /* GL_INGR_blend_func_separate */
290 GLenum BlendEquation
;
291 GLfloat BlendColor
[4];
294 GLenum LogicOp
; /* Logic operator */
295 GLboolean IndexLogicOpEnabled
; /* Color index logic op enabled flag */
296 GLboolean ColorLogicOpEnabled
; /* RGBA logic op enabled flag */
298 GLboolean DitherFlag
; /* Dither enable flag */
302 struct gl_current_attrib
{
303 /* These values valid only when FLUSH_VERTICES has been called.
305 GLfloat Normal
[3]; /* Current vertex normal */
306 GLchan Color
[4]; /* Current RGBA color */
307 GLchan SecondaryColor
[4]; /* Current secondary color */
308 GLfloat FogCoord
; /* Current Fog coord */
309 GLuint Index
; /* Current color index */
310 GLboolean EdgeFlag
; /* Current edge flag */
311 GLfloat Texcoord
[MAX_TEXTURE_UNITS
][4]; /* Current texture coords */
313 /* These values are always valid.
315 GLfloat RasterPos
[4]; /* Current raster position */
316 GLfloat RasterDistance
; /* Current raster distance */
317 GLfloat RasterColor
[4]; /* Current raster color */
318 GLuint RasterIndex
; /* Current raster index */
319 GLfloat
*RasterTexCoord
; /* Current raster texcoord*/
320 GLfloat RasterMultiTexCoord
[MAX_TEXTURE_UNITS
][4];
321 GLboolean RasterPosValid
; /* Raster po valid flag */
325 struct gl_depthbuffer_attrib
{
326 GLenum Func
; /* Function for depth buffer compare */
327 GLfloat Clear
; /* Value to clear depth buffer to */
328 GLboolean Test
; /* Depth buffering enabled flag */
329 GLboolean Mask
; /* Depth buffer writable? */
330 GLboolean OcclusionTest
; /* GL_HP_occlusion_test */
334 struct gl_enable_attrib
{
336 GLboolean AutoNormal
;
338 GLboolean ClipPlane
[MAX_CLIP_PLANES
];
339 GLboolean ColorMaterial
;
340 GLboolean Convolution1D
;
341 GLboolean Convolution2D
;
342 GLboolean Separable2D
;
348 GLboolean Light
[MAX_LIGHTS
];
350 GLboolean LineSmooth
;
351 GLboolean LineStipple
;
352 GLboolean IndexLogicOp
;
353 GLboolean ColorLogicOp
;
354 GLboolean Map1Color4
;
356 GLboolean Map1Normal
;
357 GLboolean Map1TextureCoord1
;
358 GLboolean Map1TextureCoord2
;
359 GLboolean Map1TextureCoord3
;
360 GLboolean Map1TextureCoord4
;
361 GLboolean Map1Vertex3
;
362 GLboolean Map1Vertex4
;
363 GLboolean Map2Color4
;
365 GLboolean Map2Normal
;
366 GLboolean Map2TextureCoord1
;
367 GLboolean Map2TextureCoord2
;
368 GLboolean Map2TextureCoord3
;
369 GLboolean Map2TextureCoord4
;
370 GLboolean Map2Vertex3
;
371 GLboolean Map2Vertex4
;
374 GLboolean PixelTexture
;
375 GLboolean PointSmooth
;
376 GLboolean PolygonOffsetPoint
;
377 GLboolean PolygonOffsetLine
;
378 GLboolean PolygonOffsetFill
;
379 GLboolean PolygonSmooth
;
380 GLboolean PolygonStipple
;
381 GLboolean RescaleNormals
;
384 GLuint Texture
[MAX_TEXTURE_UNITS
];
385 GLuint TexGen
[MAX_TEXTURE_UNITS
];
389 struct gl_eval_attrib
{
391 GLboolean Map1Color4
;
393 GLboolean Map1Normal
;
394 GLboolean Map1TextureCoord1
;
395 GLboolean Map1TextureCoord2
;
396 GLboolean Map1TextureCoord3
;
397 GLboolean Map1TextureCoord4
;
398 GLboolean Map1Vertex3
;
399 GLboolean Map1Vertex4
;
400 GLboolean Map2Color4
;
402 GLboolean Map2Normal
;
403 GLboolean Map2TextureCoord1
;
404 GLboolean Map2TextureCoord2
;
405 GLboolean Map2TextureCoord3
;
406 GLboolean Map2TextureCoord4
;
407 GLboolean Map2Vertex3
;
408 GLboolean Map2Vertex4
;
409 GLboolean AutoNormal
;
410 /* Map Grid endpoints and divisions and calculated du values */
412 GLfloat MapGrid1u1
, MapGrid1u2
, MapGrid1du
;
413 GLint MapGrid2un
, MapGrid2vn
;
414 GLfloat MapGrid2u1
, MapGrid2u2
, MapGrid2du
;
415 GLfloat MapGrid2v1
, MapGrid2v2
, MapGrid2dv
;
419 struct gl_fog_attrib
{
420 GLboolean Enabled
; /* Fog enabled flag */
421 GLfloat Color
[4]; /* Fog color */
422 GLfloat Density
; /* Density >= 0.0 */
423 GLfloat Start
; /* Start distance in eye coords */
424 GLfloat End
; /* End distance in eye coords */
425 GLfloat Index
; /* Fog index */
426 GLenum Mode
; /* Fog mode */
427 GLboolean ColorSumEnabled
;
428 GLenum FogCoordinateSource
;
432 struct gl_hint_attrib
{
433 /* always one of GL_FASTEST, GL_NICEST, or GL_DONT_CARE */
434 GLenum PerspectiveCorrection
;
437 GLenum PolygonSmooth
;
440 /* GL_EXT_clip_volume_hint */
441 GLenum ClipVolumeClipping
;
443 /* GL_ARB_texture_compression */
444 GLenum TextureCompression
;
448 struct gl_histogram_attrib
{
449 GLuint Width
; /* number of table entries */
450 GLint Format
; /* GL_ALPHA, GL_RGB, etc */
451 GLuint Count
[HISTOGRAM_TABLE_SIZE
][4]; /* the histogram */
452 GLboolean Sink
; /* terminate image transfer? */
453 GLubyte RedSize
; /* Bits per counter */
457 GLubyte LuminanceSize
;
461 struct gl_minmax_attrib
{
464 GLfloat Min
[4], Max
[4]; /* RGBA */
468 struct gl_convolution_attrib
{
470 GLenum InternalFormat
;
473 GLfloat Filter
[MAX_CONVOLUTION_WIDTH
* MAX_CONVOLUTION_HEIGHT
* 4];
477 struct gl_light_attrib
{
478 struct gl_light Light
[MAX_LIGHTS
]; /* Array of lights */
479 struct gl_lightmodel Model
; /* Lighting model */
481 /* Must flush FLUSH_VERTICES before referencing:
483 struct gl_material Material
[2]; /* Material 0=front, 1=back */
485 GLboolean Enabled
; /* Lighting enabled flag */
486 GLenum ShadeModel
; /* GL_FLAT or GL_SMOOTH */
487 GLenum ColorMaterialFace
; /* GL_FRONT, BACK or FRONT_AND_BACK */
488 GLenum ColorMaterialMode
; /* GL_AMBIENT, GL_DIFFUSE, etc */
489 GLuint ColorMaterialBitmask
; /* bitmask formed from Face and Mode */
490 GLboolean ColorMaterialEnabled
;
492 struct gl_light EnabledList
; /* List sentinel */
494 /* Derived for optimizations: */
495 GLboolean _NeedVertices
; /* Use fast shader? */
496 GLuint _Flags
; /* LIGHT_* flags, see below */
497 GLfloat _BaseColor
[2][3];
498 GLchan _BaseAlpha
[2];
502 #define LIGHT_SPOT 0x1
503 #define LIGHT_LOCAL_VIEWER 0x2
504 #define LIGHT_POSITIONAL 0x4
506 #define LIGHT_NEED_VERTICES (LIGHT_POSITIONAL|LIGHT_LOCAL_VIEWER)
508 struct gl_line_attrib
{
509 GLboolean SmoothFlag
; /* GL_LINE_SMOOTH enabled? */
510 GLboolean StippleFlag
; /* GL_LINE_STIPPLE enabled? */
511 GLushort StipplePattern
; /* Stipple pattern */
512 GLint StippleFactor
; /* Stipple repeat factor */
513 GLfloat Width
; /* Line width */
514 GLfloat _Width
; /* Clamped Line width */
518 struct gl_list_attrib
{
522 struct gl_list_opcode
{
524 void (*execute
)( GLcontext
*ctx
, void *data
);
525 void (*destroy
)( GLcontext
*ctx
, void *data
);
526 void (*print
)( GLcontext
*ctx
, void *data
);
529 #define GL_MAX_EXT_OPCODES 16
531 struct gl_list_extensions
{
532 struct gl_list_opcode opcode
[GL_MAX_EXT_OPCODES
];
536 struct gl_pixel_attrib
{
537 GLenum ReadBuffer
; /* src buffer for glRead/CopyPixels */
538 GLenum DriverReadBuffer
; /* Driver's current source buffer */
539 GLfloat RedBias
, RedScale
;
540 GLfloat GreenBias
, GreenScale
;
541 GLfloat BlueBias
, BlueScale
;
542 GLfloat AlphaBias
, AlphaScale
;
543 GLfloat DepthBias
, DepthScale
;
544 GLint IndexShift
, IndexOffset
;
545 GLboolean MapColorFlag
;
546 GLboolean MapStencilFlag
;
547 GLfloat ZoomX
, ZoomY
;
548 GLint MapStoSsize
; /* Size of each pixel map */
558 GLint MapStoS
[MAX_PIXEL_MAP_TABLE
]; /* Pixel map tables */
559 GLint MapItoI
[MAX_PIXEL_MAP_TABLE
];
560 GLfloat MapItoR
[MAX_PIXEL_MAP_TABLE
];
561 GLfloat MapItoG
[MAX_PIXEL_MAP_TABLE
];
562 GLfloat MapItoB
[MAX_PIXEL_MAP_TABLE
];
563 GLfloat MapItoA
[MAX_PIXEL_MAP_TABLE
];
564 GLubyte MapItoR8
[MAX_PIXEL_MAP_TABLE
]; /* converted to 8-bit color */
565 GLubyte MapItoG8
[MAX_PIXEL_MAP_TABLE
];
566 GLubyte MapItoB8
[MAX_PIXEL_MAP_TABLE
];
567 GLubyte MapItoA8
[MAX_PIXEL_MAP_TABLE
];
568 GLfloat MapRtoR
[MAX_PIXEL_MAP_TABLE
];
569 GLfloat MapGtoG
[MAX_PIXEL_MAP_TABLE
];
570 GLfloat MapBtoB
[MAX_PIXEL_MAP_TABLE
];
571 GLfloat MapAtoA
[MAX_PIXEL_MAP_TABLE
];
572 /* GL_EXT_histogram */
573 GLboolean HistogramEnabled
;
574 GLboolean MinMaxEnabled
;
575 /* GL_SGIS_pixel_texture */
576 GLboolean PixelTextureEnabled
;
577 GLenum FragmentRgbSource
;
578 GLenum FragmentAlphaSource
;
579 /* GL_SGI_color_matrix */
580 GLfloat PostColorMatrixScale
[4]; /* RGBA */
581 GLfloat PostColorMatrixBias
[4]; /* RGBA */
582 /* GL_SGI_color_table */
583 GLfloat ColorTableScale
[4];
584 GLfloat ColorTableBias
[4];
585 GLboolean ColorTableEnabled
;
586 GLfloat PCCTscale
[4];
588 GLboolean PostConvolutionColorTableEnabled
;
589 GLfloat PCMCTscale
[4];
590 GLfloat PCMCTbias
[4];
591 GLboolean PostColorMatrixColorTableEnabled
;
593 GLboolean Convolution1DEnabled
;
594 GLboolean Convolution2DEnabled
;
595 GLboolean Separable2DEnabled
;
596 GLfloat ConvolutionBorderColor
[3][4];
597 GLenum ConvolutionBorderMode
[3];
598 GLfloat ConvolutionFilterScale
[3][4];
599 GLfloat ConvolutionFilterBias
[3][4];
600 GLfloat PostConvolutionScale
[4]; /* RGBA */
601 GLfloat PostConvolutionBias
[4]; /* RGBA */
605 struct gl_point_attrib
{
606 GLboolean SmoothFlag
; /* True if GL_POINT_SMOOTH is enabled */
607 GLboolean SpriteMode
; /* GL_MESA_sprite_point extension */
608 GLfloat Size
; /* User-specified point size */
609 GLfloat _Size
; /* Size clamped to Const.Min/MaxPointSize */
610 GLfloat Params
[3]; /* GL_EXT_point_parameters */
611 GLfloat MinSize
, MaxSize
; /* GL_EXT_point_parameters */
612 GLfloat Threshold
; /* GL_EXT_point_parameters */
613 GLboolean _Attenuated
; /* True if Params != [1, 0, 0] */
617 struct gl_polygon_attrib
{
618 GLenum FrontFace
; /* Either GL_CW or GL_CCW */
619 GLenum FrontMode
; /* Either GL_POINT, GL_LINE or GL_FILL */
620 GLenum BackMode
; /* Either GL_POINT, GL_LINE or GL_FILL */
621 GLboolean _FrontBit
; /* */
622 GLboolean CullFlag
; /* Culling on/off flag */
623 GLboolean SmoothFlag
; /* True if GL_POLYGON_SMOOTH is enabled */
624 GLboolean StippleFlag
; /* True if GL_POLYGON_STIPPLE is enabled */
625 GLenum CullFaceMode
; /* Culling mode GL_FRONT or GL_BACK */
626 GLfloat OffsetFactor
; /* Polygon offset factor, from user */
627 GLfloat OffsetUnits
; /* Polygon offset units, from user */
628 GLfloat OffsetMRD
; /* = OffsetUnits * visual->MRD */
629 GLboolean OffsetPoint
; /* Offset in GL_POINT mode */
630 GLboolean OffsetLine
; /* Offset in GL_LINE mode */
631 GLboolean OffsetFill
; /* Offset in GL_FILL mode */
632 GLboolean _OffsetAny
;
636 struct gl_scissor_attrib
{
637 GLboolean Enabled
; /* Scissor test enabled? */
638 GLint X
, Y
; /* Lower left corner of box */
639 GLsizei Width
, Height
; /* Size of box */
643 struct gl_stencil_attrib
{
644 GLboolean Enabled
; /* Enabled flag */
645 GLenum Function
; /* Stencil function */
646 GLenum FailFunc
; /* Fail function */
647 GLenum ZPassFunc
; /* Depth buffer pass function */
648 GLenum ZFailFunc
; /* Depth buffer fail function */
649 GLstencil Ref
; /* Reference value */
650 GLstencil ValueMask
; /* Value mask */
651 GLstencil Clear
; /* Clear value */
652 GLstencil WriteMask
; /* Write mask */
656 /* TexGenEnabled flags */
662 /* Texture Enabled flags */
663 #define TEXTURE0_1D 0x1 /* Texture unit 0 (default) */
664 #define TEXTURE0_2D 0x2
665 #define TEXTURE0_3D 0x4
666 #define TEXTURE0_CUBE 0x8
667 #define TEXTURE0_ANY (TEXTURE0_1D | TEXTURE0_2D | TEXTURE0_3D | TEXTURE0_CUBE)
668 #define TEXTURE1_1D (TEXTURE0_1D << 4) /* Texture unit 1 */
669 #define TEXTURE1_2D (TEXTURE0_2D << 4)
670 #define TEXTURE1_3D (TEXTURE0_3D << 4)
671 #define TEXTURE1_CUBE (TEXTURE0_CUBE << 4)
672 #define TEXTURE1_ANY (TEXTURE1_1D | TEXTURE1_2D | TEXTURE1_3D | TEXTURE1_CUBE)
673 #define TEXTURE2_1D (TEXTURE0_1D << 8) /* Texture unit 2 */
674 #define TEXTURE2_2D (TEXTURE0_2D << 8)
675 #define TEXTURE2_3D (TEXTURE0_3D << 8)
676 #define TEXTURE2_CUBE (TEXTURE0_CUBE << 8)
677 #define TEXTURE2_ANY (TEXTURE2_1D | TEXTURE2_2D | TEXTURE2_3D | TEXTURE2_CUBE)
678 #define TEXTURE3_1D (TEXTURE0_1D << 12) /* Texture unit 3 */
679 #define TEXTURE3_2D (TEXTURE0_2D << 12)
680 #define TEXTURE3_3D (TEXTURE0_3D << 12)
681 #define TEXTURE3_CUBE (TEXTURE0_CUBE << 12)
682 #define TEXTURE3_ANY (TEXTURE3_1D | TEXTURE3_2D | TEXTURE3_3D | TEXTURE3_CUBE)
683 #define TEXTURE4_1D (TEXTURE0_1D << 16) /* Texture unit 3 */
684 #define TEXTURE4_2D (TEXTURE0_2D << 16)
685 #define TEXTURE4_3D (TEXTURE0_3D << 16)
686 #define TEXTURE4_CUBE (TEXTURE0_CUBE << 16)
687 #define TEXTURE5_ANY (TEXTURE3_1D | TEXTURE3_2D | TEXTURE3_3D | TEXTURE3_CUBE)
688 #define TEXTURE5_1D (TEXTURE0_1D << 20) /* Texture unit 3 */
689 #define TEXTURE5_2D (TEXTURE0_2D << 20)
690 #define TEXTURE5_3D (TEXTURE0_3D << 20)
691 #define TEXTURE5_CUBE (TEXTURE0_CUBE << 20)
692 #define TEXTURE5_ANY (TEXTURE3_1D | TEXTURE3_2D | TEXTURE3_3D | TEXTURE3_CUBE)
693 #define TEXTURE6_1D (TEXTURE0_1D << 24) /* Texture unit 3 */
694 #define TEXTURE6_2D (TEXTURE0_2D << 24)
695 #define TEXTURE6_3D (TEXTURE0_3D << 24)
696 #define TEXTURE6_CUBE (TEXTURE0_CUBE << 24)
697 #define TEXTURE6_ANY (TEXTURE3_1D | TEXTURE3_2D | TEXTURE3_3D | TEXTURE3_CUBE)
698 #define TEXTURE7_1D (TEXTURE0_1D << 28) /* Texture unit 3 */
699 #define TEXTURE7_2D (TEXTURE0_2D << 28)
700 #define TEXTURE7_3D (TEXTURE0_3D << 28)
701 #define TEXTURE7_CUBE (TEXTURE0_CUBE << 28)
702 #define TEXTURE7_ANY (TEXTURE3_1D | TEXTURE3_2D | TEXTURE3_3D | TEXTURE3_CUBE)
704 /* Bitmap versions of the GL_ constants.
706 #define TEXGEN_SPHERE_MAP 0x1
707 #define TEXGEN_OBJ_LINEAR 0x2
708 #define TEXGEN_EYE_LINEAR 0x4
709 #define TEXGEN_REFLECTION_MAP_NV 0x8
710 #define TEXGEN_NORMAL_MAP_NV 0x10
712 #define TEXGEN_NEED_M (TEXGEN_SPHERE_MAP)
713 #define TEXGEN_NEED_F (TEXGEN_SPHERE_MAP | \
714 TEXGEN_REFLECTION_MAP_NV)
715 #define TEXGEN_NEED_NORMALS (TEXGEN_SPHERE_MAP | \
716 TEXGEN_REFLECTION_MAP_NV | \
717 TEXGEN_NORMAL_MAP_NV)
718 #define TEXGEN_NEED_VERTICES (TEXGEN_OBJ_LINEAR | \
719 TEXGEN_EYE_LINEAR | \
720 TEXGEN_REFLECTION_MAP_NV | \
722 #define TEXGEN_NEED_EYE_COORD (TEXGEN_SPHERE_MAP | \
723 TEXGEN_REFLECTION_MAP_NV | \
724 TEXGEN_NORMAL_MAP_NV | \
729 /* A selection of state flags to make driver and module's lives easier.
731 #define ENABLE_TEXGEN0 0x1
732 #define ENABLE_TEXGEN1 0x2
733 #define ENABLE_TEXGEN2 0x4
734 #define ENABLE_TEXGEN3 0x8
735 #define ENABLE_TEXGEN4 0x10
736 #define ENABLE_TEXGEN5 0x20
737 #define ENABLE_TEXGEN6 0x40
738 #define ENABLE_TEXGEN7 0x80
739 #define ENABLE_TEXMAT0 0x100 /* Ie. not the identity matrix */
740 #define ENABLE_TEXMAT1 0x200
741 #define ENABLE_TEXMAT2 0x400
742 #define ENABLE_TEXMAT3 0x800
743 #define ENABLE_TEXMAT4 0x1000
744 #define ENABLE_TEXMAT5 0x2000
745 #define ENABLE_TEXMAT6 0x4000
746 #define ENABLE_TEXMAT7 0x8000
747 #define ENABLE_LIGHT 0x10000
748 #define ENABLE_FOG 0x20000
749 #define ENABLE_USERCLIP 0x40000
750 #define ENABLE_NORMALIZE 0x100000
751 #define ENABLE_RESCALE 0x200000
752 #define ENABLE_POINT_ATTEN 0x400000
755 #define ENABLE_TEXGEN_ANY (ENABLE_TEXGEN0 | ENABLE_TEXGEN1 | \
756 ENABLE_TEXGEN2 | ENABLE_TEXGEN3 | \
757 ENABLE_TEXGEN4 | ENABLE_TEXGEN5 | \
758 ENABLE_TEXGEN6 | ENABLE_TEXGEN7)
760 #define ENABLE_TEXMAT_ANY (ENABLE_TEXMAT0 | ENABLE_TEXMAT1 | \
761 ENABLE_TEXMAT2 | ENABLE_TEXMAT3 | \
762 ENABLE_TEXMAT4 | ENABLE_TEXMAT5 | \
763 ENABLE_TEXMAT6 | ENABLE_TEXMAT7)
765 #define ENABLE_TEXGEN(i) (ENABLE_TEXGEN0 << (i))
766 #define ENABLE_TEXMAT(i) (ENABLE_TEXMAT0 << (i))
770 * If teximage is color-index, texelOut returns GLchan[1].
771 * If teximage is depth, texelOut returns GLfloat[1].
772 * Otherwise, texelOut returns GLchan[4].
774 typedef void (*FetchTexelFunc
)( const struct gl_texture_image
*texImage
,
775 GLint col
, GLint row
, GLint img
,
778 /* Texture format record */
779 struct gl_texture_format
{
780 GLint IntFormat
; /* One of the MESA_FORMAT_* values */
782 GLubyte RedBits
; /* Bits per texel component */
786 GLubyte LuminanceBits
;
787 GLubyte IntensityBits
;
793 FetchTexelFunc FetchTexel1D
; /* Texel fetch function pointers */
794 FetchTexelFunc FetchTexel2D
;
795 FetchTexelFunc FetchTexel3D
;
798 /* Texture image record */
799 struct gl_texture_image
{
800 GLenum Format
; /* GL_ALPHA, GL_LUMINANCE, GL_LUMINANCE_ALPHA,
801 * GL_INTENSITY, GL_RGB, GL_RGBA, or
802 * GL_COLOR_INDEX only
804 GLenum Type
; /* Texel type: GL_UNSIGNED_BYTE, etc. */
805 GLenum IntFormat
; /* Internal format as given by the user */
806 GLuint Border
; /* 0 or 1 */
807 GLuint Width
; /* = 2^WidthLog2 + 2*Border */
808 GLuint Height
; /* = 2^HeightLog2 + 2*Border */
809 GLuint Depth
; /* = 2^DepthLog2 + 2*Border */
810 GLuint Width2
; /* = Width - 2*Border */
811 GLuint Height2
; /* = Height - 2*Border */
812 GLuint Depth2
; /* = Depth - 2*Border */
813 GLuint WidthLog2
; /* = log2(Width2) */
814 GLuint HeightLog2
; /* = log2(Height2) */
815 GLuint DepthLog2
; /* = log2(Depth2) */
816 GLuint MaxLog2
; /* = MAX(WidthLog2, HeightLog2) */
817 GLvoid
*Data
; /* Image data, accessed via FetchTexel() */
819 const struct gl_texture_format
*TexFormat
;
821 FetchTexelFunc FetchTexel
; /* Texel fetch function pointer */
823 GLboolean IsCompressed
; /* GL_ARB_texture_compression */
824 GLuint CompressedSize
; /* GL_ARB_texture_compression */
826 /* For device driver: */
827 void *DriverData
; /* Arbitrary device driver data */
831 /* Texture object record */
832 struct gl_texture_object
{
833 _glthread_Mutex Mutex
; /* for thread safety */
834 GLint RefCount
; /* reference count */
835 GLuint Name
; /* an unsigned integer */
836 GLuint Dimensions
; /* 1 or 2 or 3 or 6 (cube map) */
837 GLfloat Priority
; /* in [0,1] */
838 GLchan BorderColor
[4];
839 GLenum WrapS
; /* GL_CLAMP, REPEAT or CLAMP_TO_EDGE */
840 GLenum WrapT
; /* GL_CLAMP, REPEAT or CLAMP_TO_EDGE */
841 GLenum WrapR
; /* GL_CLAMP, REPEAT or CLAMP_TO_EDGE */
842 GLenum MinFilter
; /* minification filter */
843 GLenum MagFilter
; /* magnification filter */
844 GLfloat MinLod
; /* min lambda, OpenGL 1.2 */
845 GLfloat MaxLod
; /* max lambda, OpenGL 1.2 */
846 GLint BaseLevel
; /* min mipmap level, OpenGL 1.2 */
847 GLint MaxLevel
; /* max mipmap level, OpenGL 1.2 */
848 GLfloat MaxAnisotropy
; /* GL_EXT_texture_filter_anisotropic */
849 GLboolean CompareFlag
; /* GL_SGIX_shadow */
850 GLenum CompareOperator
; /* GL_SGIX_shadow */
851 GLchan ShadowAmbient
; /* GL_SGIX_shadow_ambient */
852 GLint _MaxLevel
; /* actual max mipmap level (q in the spec) */
853 GLfloat _MaxLambda
; /* = _MaxLevel - BaseLevel (q - b in spec) */
854 struct gl_texture_image
*Image
[MAX_TEXTURE_LEVELS
];
856 /* Texture cube faces */
857 /* Image[] is alias for *PosX[MAX_TEXTURE_LEVELS]; */
858 struct gl_texture_image
*NegX
[MAX_TEXTURE_LEVELS
];
859 struct gl_texture_image
*PosY
[MAX_TEXTURE_LEVELS
];
860 struct gl_texture_image
*NegY
[MAX_TEXTURE_LEVELS
];
861 struct gl_texture_image
*PosZ
[MAX_TEXTURE_LEVELS
];
862 struct gl_texture_image
*NegZ
[MAX_TEXTURE_LEVELS
];
864 /* GL_EXT_paletted_texture */
865 struct gl_color_table Palette
;
867 GLboolean Complete
; /* Is texture object complete? */
868 struct gl_texture_object
*Next
; /* Next in linked list */
870 /* For device driver: */
871 void *DriverData
; /* Arbitrary device driver data */
877 * Texture units are new with the multitexture extension.
879 struct gl_texture_unit
{
880 GLuint Enabled
; /* bitmask of TEXTURE0_1D, _2D, _3D, _CUBE */
881 GLuint _ReallyEnabled
; /* 0 or one of TEXTURE0_1D, _2D, _3D, _CUBE */
883 GLenum EnvMode
; /* GL_MODULATE, GL_DECAL, GL_BLEND, etc. */
885 GLuint TexGenEnabled
; /* Bitwise-OR of [STRQ]_BIT values */
886 GLenum GenModeS
; /* Tex coord generation mode, either */
887 GLenum GenModeT
; /* GL_OBJECT_LINEAR, or */
888 GLenum GenModeR
; /* GL_EYE_LINEAR, or */
889 GLenum GenModeQ
; /* GL_SPHERE_MAP */
894 GLuint _GenFlags
; /* bitwise or of GenBit[STRQ] */
895 GLfloat ObjectPlaneS
[4];
896 GLfloat ObjectPlaneT
[4];
897 GLfloat ObjectPlaneR
[4];
898 GLfloat ObjectPlaneQ
[4];
899 GLfloat EyePlaneS
[4];
900 GLfloat EyePlaneT
[4];
901 GLfloat EyePlaneR
[4];
902 GLfloat EyePlaneQ
[4];
903 GLfloat LodBias
; /* for biasing mipmap levels */
905 /* GL_EXT_texture_env_combine */
906 GLenum CombineModeRGB
; /* GL_REPLACE, GL_DECAL, GL_ADD, etc. */
907 GLenum CombineModeA
; /* GL_REPLACE, GL_DECAL, GL_ADD, etc. */
908 GLenum CombineSourceRGB
[3]; /* GL_PRIMARY_COLOR, GL_TEXTURE, etc. */
909 GLenum CombineSourceA
[3]; /* GL_PRIMARY_COLOR, GL_TEXTURE, etc. */
910 GLenum CombineOperandRGB
[3]; /* SRC_COLOR, ONE_MINUS_SRC_COLOR, etc */
911 GLenum CombineOperandA
[3]; /* SRC_ALPHA, ONE_MINUS_SRC_ALPHA, etc */
912 GLuint CombineScaleShiftRGB
; /* 0, 1 or 2 */
913 GLuint CombineScaleShiftA
; /* 0, 1 or 2 */
915 struct gl_texture_object
*Current1D
;
916 struct gl_texture_object
*Current2D
;
917 struct gl_texture_object
*Current3D
;
918 struct gl_texture_object
*CurrentCubeMap
; /* GL_ARB_texture_cube_map */
920 struct gl_texture_object
*_Current
; /* Points to really enabled tex obj */
922 struct gl_texture_object Saved1D
; /* only used by glPush/PopAttrib */
923 struct gl_texture_object Saved2D
;
924 struct gl_texture_object Saved3D
;
925 struct gl_texture_object SavedCubeMap
;
929 struct gl_texture_attrib
{
931 GLuint CurrentUnit
; /* Active texture unit */
932 GLuint CurrentTransformUnit
; /* Client active texture xform unit */
934 GLuint _ReallyEnabled
; /* enables for all texture units: */
935 /* = (Unit[0]._ReallyEnabled << 0) | */
936 /* (Unit[1]._ReallyEnabled << 4) | */
937 /* (Unit[2]._ReallyEnabled << 8) | etc... */
938 GLuint _GenFlags
; /* for texgen */
940 struct gl_texture_unit Unit
[MAX_TEXTURE_UNITS
];
942 struct gl_texture_object
*Proxy1D
;
943 struct gl_texture_object
*Proxy2D
;
944 struct gl_texture_object
*Proxy3D
;
945 struct gl_texture_object
*ProxyCubeMap
;
947 /* GL_EXT_shared_texture_palette */
948 GLboolean SharedPalette
;
949 struct gl_color_table Palette
;
953 struct gl_transform_attrib
{
954 GLenum MatrixMode
; /* Matrix mode */
955 GLfloat EyeUserPlane
[MAX_CLIP_PLANES
][4];
956 GLfloat _ClipUserPlane
[MAX_CLIP_PLANES
][4]; /* derived */
957 GLboolean ClipEnabled
[MAX_CLIP_PLANES
];
958 GLubyte _AnyClip
; /* How many ClipEnabled? */
959 GLboolean Normalize
; /* Normalize all normals? */
960 GLboolean RescaleNormals
; /* GL_EXT_rescale_normal */
964 struct gl_viewport_attrib
{
965 GLint X
, Y
; /* position */
966 GLsizei Width
, Height
; /* size */
967 GLfloat Near
, Far
; /* Depth buffer range */
968 GLmatrix _WindowMap
; /* Mapping transformation as a matrix. */
972 /* For the attribute stack: */
973 struct gl_attrib_node
{
976 struct gl_attrib_node
*next
;
982 * Client pixel packing/unpacking attributes
984 struct gl_pixelstore_attrib
{
989 GLint ImageHeight
; /* for GL_EXT_texture3D */
990 GLint SkipImages
; /* for GL_EXT_texture3D */
997 * Client vertex array attributes
999 struct gl_client_array
{
1002 GLsizei Stride
; /* user-specified stride */
1003 GLsizei StrideB
; /* actual stride in bytes */
1011 struct gl_array_attrib
{
1012 struct gl_client_array Vertex
; /* client data descriptors */
1013 struct gl_client_array Normal
;
1014 struct gl_client_array Color
;
1015 struct gl_client_array SecondaryColor
;
1016 struct gl_client_array FogCoord
;
1017 struct gl_client_array Index
;
1018 struct gl_client_array TexCoord
[MAX_TEXTURE_UNITS
];
1019 struct gl_client_array EdgeFlag
;
1021 GLint TexCoordInterleaveFactor
;
1022 GLint ActiveTexture
; /* Client Active Texture */
1026 GLuint _Enabled
; /* _NEW_ARRAY_* - bit set if array enabled */
1027 GLuint NewState
; /* _NEW_ARRAY_* */
1033 struct gl_feedback
{
1035 GLuint _Mask
; /* FB_* bits */
1043 struct gl_selection
{
1045 GLuint BufferSize
; /* size of SelectBuffer */
1046 GLuint BufferCount
; /* number of values in SelectBuffer */
1047 GLuint Hits
; /* number of records in SelectBuffer */
1048 GLuint NameStackDepth
;
1049 GLuint NameStack
[MAX_NAME_STACK_DEPTH
];
1051 GLfloat HitMinZ
, HitMaxZ
;
1057 * 1-D Evaluator control points
1060 GLuint Order
; /* Number of control points */
1061 GLfloat u1
, u2
, du
; /* u1, u2, 1.0/(u2-u1) */
1062 GLfloat
*Points
; /* Points to contiguous control points */
1067 * 2-D Evaluator control points
1070 GLuint Uorder
; /* Number of control points in U dimension */
1071 GLuint Vorder
; /* Number of control points in V dimension */
1074 GLfloat
*Points
; /* Points to contiguous control points */
1079 * All evalutator control points
1081 struct gl_evaluators
{
1083 struct gl_1d_map Map1Vertex3
;
1084 struct gl_1d_map Map1Vertex4
;
1085 struct gl_1d_map Map1Index
;
1086 struct gl_1d_map Map1Color4
;
1087 struct gl_1d_map Map1Normal
;
1088 struct gl_1d_map Map1Texture1
;
1089 struct gl_1d_map Map1Texture2
;
1090 struct gl_1d_map Map1Texture3
;
1091 struct gl_1d_map Map1Texture4
;
1094 struct gl_2d_map Map2Vertex3
;
1095 struct gl_2d_map Map2Vertex4
;
1096 struct gl_2d_map Map2Index
;
1097 struct gl_2d_map Map2Color4
;
1098 struct gl_2d_map Map2Normal
;
1099 struct gl_2d_map Map2Texture1
;
1100 struct gl_2d_map Map2Texture2
;
1101 struct gl_2d_map Map2Texture3
;
1102 struct gl_2d_map Map2Texture4
;
1108 * State which can be shared by multiple contexts:
1110 struct gl_shared_state
{
1111 _glthread_Mutex Mutex
; /* for thread safety */
1112 GLint RefCount
; /* Reference count */
1113 struct _mesa_HashTable
*DisplayList
; /* Display lists hash table */
1114 struct _mesa_HashTable
*TexObjects
; /* Texture objects hash table */
1115 struct gl_texture_object
*TexObjectList
;/* Linked list of texture objects */
1117 /* Default texture objects (shared by all multi-texture units) */
1118 struct gl_texture_object
*Default1D
;
1119 struct gl_texture_object
*Default2D
;
1120 struct gl_texture_object
*Default3D
;
1121 struct gl_texture_object
*DefaultCubeMap
;
1123 void *DriverData
; /* Device driver shared state */
1129 * A "frame buffer" is a color buffer and its optional ancillary buffers:
1130 * depth, accum, stencil, and software-simulated alpha buffers.
1131 * In C++ terms, think of this as a base class from which device drivers
1132 * will make derived classes.
1134 struct gl_frame_buffer
{
1135 GLvisual Visual
; /* The corresponding visual */
1137 GLint Width
, Height
; /* size of frame buffer in pixels */
1139 GLboolean UseSoftwareDepthBuffer
;
1140 GLboolean UseSoftwareAccumBuffer
;
1141 GLboolean UseSoftwareStencilBuffer
;
1142 GLboolean UseSoftwareAlphaBuffers
;
1144 /* Software depth (aka Z) buffer */
1145 GLvoid
*DepthBuffer
; /* array [Width*Height] of GLushort or GLuint*/
1147 /* Software stencil buffer */
1148 GLstencil
*Stencil
; /* array [Width*Height] of GLstencil values */
1150 /* Software accumulation buffer */
1151 GLaccum
*Accum
; /* array [4*Width*Height] of GLaccum values */
1153 /* Software alpha planes */
1154 GLchan
*FrontLeftAlpha
; /* array [Width*Height] of GLubyte */
1155 GLchan
*BackLeftAlpha
; /* array [Width*Height] of GLubyte */
1156 GLchan
*FrontRightAlpha
; /* array [Width*Height] of GLubyte */
1157 GLchan
*BackRightAlpha
; /* array [Width*Height] of GLubyte */
1158 GLchan
*Alpha
; /* Points to current alpha buffer */
1160 /* Drawing bounds: intersection of window size and scissor box */
1161 GLint _Xmin
, _Ymin
; /* inclusive */
1162 GLint _Xmax
, _Ymax
; /* exclusive */
1167 * Constants which may be overriden by device driver.
1169 struct gl_constants
{
1170 GLint MaxTextureSize
;
1171 GLint MaxCubeTextureSize
;
1172 GLint MaxTextureLevels
;
1173 GLuint MaxTextureUnits
;
1174 GLfloat MaxTextureMaxAnisotropy
; /* GL_EXT_texture_filter_anisotropic */
1175 GLuint MaxArrayLockSize
;
1177 GLfloat MinPointSize
, MaxPointSize
; /* aliased */
1178 GLfloat MinPointSizeAA
, MaxPointSizeAA
; /* antialiased */
1179 GLfloat PointSizeGranularity
;
1180 GLfloat MinLineWidth
, MaxLineWidth
; /* aliased */
1181 GLfloat MinLineWidthAA
, MaxLineWidthAA
; /* antialiased */
1182 GLfloat LineWidthGranularity
;
1183 GLuint NumAuxBuffers
;
1184 GLuint MaxColorTableSize
;
1185 GLuint MaxConvolutionWidth
;
1186 GLuint MaxConvolutionHeight
;
1187 GLuint NumCompressedTextureFormats
; /* GL_ARB_texture_compression */
1188 GLenum CompressedTextureFormats
[MAX_COMPRESSED_TEXTURE_FORMATS
];
1189 GLuint MaxClipPlanes
;
1195 * List of extensions.
1198 struct gl_extensions
{
1200 struct extension
*ext_list
;
1201 /* Flags to quickly test if certain extensions are available.
1202 * Not every extension needs to have such a flag, but it's encouraged.
1204 GLboolean ARB_imaging
;
1205 GLboolean ARB_multitexture
;
1206 GLboolean ARB_texture_compression
;
1207 GLboolean ARB_texture_cube_map
;
1208 GLboolean EXT_blend_color
;
1209 GLboolean EXT_blend_func_separate
;
1210 GLboolean EXT_blend_logic_op
;
1211 GLboolean EXT_blend_minmax
;
1212 GLboolean EXT_blend_subtract
;
1213 GLboolean EXT_clip_volume_hint
;
1214 GLboolean EXT_convolution
;
1215 GLboolean EXT_compiled_vertex_array
;
1216 GLboolean EXT_fog_coord
;
1217 GLboolean EXT_histogram
;
1218 GLboolean EXT_packed_pixels
;
1219 GLboolean EXT_paletted_texture
;
1220 GLboolean EXT_point_parameters
;
1221 GLboolean EXT_polygon_offset
;
1222 GLboolean EXT_rescale_normal
;
1223 GLboolean EXT_secondary_color
;
1224 GLboolean EXT_shared_texture_palette
;
1225 GLboolean EXT_stencil_wrap
;
1226 GLboolean EXT_texture3D
;
1227 GLboolean EXT_texture_compression_s3tc
;
1228 GLboolean EXT_texture_env_add
;
1229 GLboolean EXT_texture_env_combine
;
1230 GLboolean EXT_texture_env_dot3
;
1231 GLboolean EXT_texture_filter_anisotropic
;
1232 GLboolean EXT_texture_object
;
1233 GLboolean EXT_texture_lod_bias
;
1234 GLboolean EXT_vertex_array_set
;
1235 GLboolean HP_occlusion_test
;
1236 GLboolean INGR_blend_func_separate
;
1237 GLboolean MESA_window_pos
;
1238 GLboolean MESA_resize_buffers
;
1239 GLboolean MESA_sprite_point
;
1240 GLboolean NV_blend_square
;
1241 GLboolean NV_texgen_reflection
;
1242 GLboolean SGI_color_matrix
;
1243 GLboolean SGI_color_table
;
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_400 0x400 /* */
1299 #define _NEW_LIGHT 0x800 /* ctx->Light */
1300 #define _NEW_1000 0x1000 /* */
1301 #define _NEW_LINE 0x2000 /* ctx->Line */
1302 #define _NEW_4000 0x4000 /* */
1303 #define _NEW_PIXEL 0x8000 /* ctx->Pixel */
1304 #define _NEW_POINT 0x10000 /* ctx->Point */
1305 #define _NEW_POLYGON 0x20000 /* ctx->Polygon */
1306 #define _NEW_POLYGONSTIPPLE 0x40000 /* ctx->PolygonStipple */
1307 #define _NEW_SCISSOR 0x80000 /* ctx->Scissor */
1308 #define _NEW_STENCIL 0x100000 /* ctx->Stencil */
1309 #define _NEW_TEXTURE 0x200000 /* ctx->Texture */
1310 #define _NEW_TRANSFORM 0x400000 /* ctx->Transform */
1311 #define _NEW_VIEWPORT 0x800000 /* ctx->Viewport */
1312 #define _NEW_PACKUNPACK 0x1000000 /* ctx->Pack, ctx->Unpack */
1313 #define _NEW_ARRAY 0x2000000 /* ctx->Array */
1314 #define _NEW_COLORTABLE 0x4000000 /* ctx->{*}ColorTable */
1315 #define _NEW_RENDERMODE 0x8000000 /* RenderMode, Feedback, Select */
1316 #define _NEW_BUFFERS 0x10000000 /* ctx->Visual, ctx->DrawBuffer, */
1322 /* Bits to track array state changes (also used to summarize array enabled)
1324 #define _NEW_ARRAY_VERTEX 0x1
1325 #define _NEW_ARRAY_COLOR 0x2
1326 #define _NEW_ARRAY_NORMAL 0x4
1327 #define _NEW_ARRAY_INDEX 0x8
1328 #define _NEW_ARRAY_EDGEFLAG 0x10
1329 #define _NEW_ARRAY_SECONDARYCOLOR 0x20
1330 #define _NEW_ARRAY_FOGCOORD 0x40
1331 #define _NEW_ARRAY_TEXCOORD_0 0x80
1332 #define _NEW_ARRAY_TEXCOORD_1 0x100
1333 #define _NEW_ARRAY_TEXCOORD_2 0x200
1334 #define _NEW_ARRAY_TEXCOORD_3 0x400
1335 #define _NEW_ARRAY_TEXCOORD_4 0x800
1336 #define _NEW_ARRAY_TEXCOORD_5 0x1000
1337 #define _NEW_ARRAY_TEXCOORD_6 0x2000
1338 #define _NEW_ARRAY_TEXCOORD_7 0x4000
1339 #define _NEW_ARRAY_ALL 0x7fff
1341 #define _NEW_ARRAY_TEXCOORD(i) (_NEW_ARRAY_TEXCOORD_0<<(i))
1343 /* A bunch of flags that we think might be useful to drivers.
1345 #define DD_FEEDBACK 0x1
1346 #define DD_SELECT 0x2
1347 #define DD_FLATSHADE 0x4
1348 #define DD_SEPERATE_SPECULAR 0x10
1349 #define DD_TRI_LIGHT_TWOSIDE 0x20
1350 #define DD_TRI_UNFILLED 0x40
1351 #define DD_TRI_SMOOTH 0x80
1352 #define DD_TRI_STIPPLE 0x100
1353 #define DD_TRI_OFFSET 0x200
1354 #define DD_LINE_SMOOTH 0x800
1355 #define DD_LINE_STIPPLE 0x1000
1356 #define DD_LINE_WIDTH 0x2000
1357 #define DD_POINT_SMOOTH 0x4000
1358 #define DD_POINT_SIZE 0x8000
1359 #define DD_POINT_ATTEN 0x10000
1360 #define DD_TRI_CULL_FRONT_BACK 0x400000 /* special case on some hw */
1361 #define DD_Z_NEVER 0x800000 /* special case on some hw */
1362 #define DD_STENCIL 0x1000000
1364 /* Define the state changes under which each of these bits might change
1366 #define _DD_NEW_FEEDBACK _NEW_RENDERMODE
1367 #define _DD_NEW_SELECT _NEW_RENDERMODE
1368 #define _DD_NEW_FLATSHADE _NEW_LIGHT
1369 #define _DD_NEW_MULTIDRAW _NEW_COLOR
1370 #define _DD_NEW_SEPERATE_SPECULAR (_NEW_LIGHT|_NEW_FOG)
1371 #define _DD_NEW_TRI_LIGHT_TWOSIDE _NEW_LIGHT
1372 #define _DD_NEW_TRI_UNFILLED _NEW_POLYGON
1373 #define _DD_NEW_TRI_SMOOTH _NEW_POLYGON
1374 #define _DD_NEW_TRI_STIPPLE _NEW_POLYGON
1375 #define _DD_NEW_TRI_OFFSET _NEW_POLYGON
1376 #define _DD_NEW_LINE_SMOOTH _NEW_LINE
1377 #define _DD_NEW_LINE_STIPPLE _NEW_LINE
1378 #define _DD_NEW_LINE_WIDTH _NEW_LINE
1379 #define _DD_NEW_POINT_SMOOTH _NEW_POINT
1380 #define _DD_NEW_POINT_SIZE _NEW_POINT
1381 #define _DD_NEW_POINT_ATTEN _NEW_POINT
1382 #define _DD_NEW_TRI_CULL_FRONT_BACK _NEW_POLYGON
1383 #define _DD_NEW_Z_NEVER _NEW_DEPTH
1384 #define _DD_NEW_STENCIL _NEW_STENCIL
1387 #define _MESA_NEW_NEED_EYE_COORDS (_NEW_LIGHT| \
1392 #define _MESA_NEW_NEED_NORMALS (_NEW_LIGHT| \
1394 #define _IMAGE_NEW_TRANSFER_STATE (_NEW_PIXEL|_NEW_COLOR_MATRIX)
1397 #define NEED_NORMALS_TEXGEN 0x1
1398 #define NEED_NORMALS_LIGHT 0x2
1400 #define NEED_EYE_TEXGEN 0x1
1401 #define NEED_EYE_LIGHT 0x2
1402 #define NEED_EYE_LIGHT_MODELVIEW 0x4
1403 #define NEED_EYE_POINT_ATTEN 0x8
1408 * Forward declaration of display list datatypes:
1411 typedef union node Node
;
1416 /* This has to be included here. */
1423 * Core Mesa's support for tnl modules:
1425 #define NUM_VERTEX_FORMAT_ENTRIES (sizeof(GLvertexformat) / sizeof(void *))
1427 struct gl_tnl_module
{
1428 /* Vertex format to be lazily swapped into current dispatch.
1430 GLvertexformat
*Current
;
1432 /* Record of functions swapped out. On restore, only need to swap
1433 * these functions back in.
1435 void *Swapped
[NUM_VERTEX_FORMAT_ENTRIES
][2];
1441 * The library context:
1443 struct __GLcontextRec
{
1445 ** Os related interfaces; these *must* be the first members of this
1446 ** structure, because they are exposed to the outside world (i.e. GLX
1449 __GLimports imports
;
1450 __GLexports exports
;
1452 /* State possibly shared with other contexts in the address space */
1453 struct gl_shared_state
*Shared
;
1455 /* API function pointer tables */
1456 struct _glapi_table
*Save
; /* Display list save funcs */
1457 struct _glapi_table
*Exec
; /* Execute funcs */
1458 struct _glapi_table
*CurrentDispatch
; /* == Save or Exec !! */
1460 GLboolean ExecPrefersFloat
; /* What preference for color conversion? */
1461 GLboolean SavePrefersFloat
;
1464 GLframebuffer
*DrawBuffer
; /* buffer for writing */
1465 GLframebuffer
*ReadBuffer
; /* buffer for reading */
1467 /* Driver function pointer table */
1468 struct dd_function_table Driver
;
1470 void *DriverCtx
; /* Points to device driver context/state */
1471 void *DriverMgrCtx
; /* Points to device driver manager (optional)*/
1473 /* Core/Driver constants */
1474 struct gl_constants Const
;
1476 /* Modelview matrix and stack */
1477 GLmatrix ModelView
; /* current matrix, not stored on stack */
1478 GLuint ModelViewStackDepth
;
1479 GLmatrix ModelViewStack
[MAX_MODELVIEW_STACK_DEPTH
- 1];
1481 /* Projection matrix and stack */
1482 GLmatrix ProjectionMatrix
; /* current matrix, not stored on stack */
1483 GLuint ProjectionStackDepth
;
1484 GLmatrix ProjectionStack
[MAX_PROJECTION_STACK_DEPTH
- 1];
1486 /* Combined modelview and projection matrix */
1487 GLmatrix _ModelProjectMatrix
;
1489 /* Texture matrix and stack */
1490 GLmatrix TextureMatrix
[MAX_TEXTURE_UNITS
];
1491 GLuint TextureStackDepth
[MAX_TEXTURE_UNITS
];
1492 GLmatrix TextureStack
[MAX_TEXTURE_UNITS
][MAX_TEXTURE_STACK_DEPTH
- 1];
1494 /* Color matrix and stack */
1495 GLmatrix ColorMatrix
;
1496 GLuint ColorStackDepth
;
1497 GLmatrix ColorStack
[MAX_COLOR_STACK_DEPTH
- 1];
1500 GLuint CallDepth
; /* Current recursion calling depth */
1501 GLboolean ExecuteFlag
; /* Execute GL commands? */
1502 GLboolean CompileFlag
; /* Compile GL commands into display list? */
1503 Node
*CurrentListPtr
; /* Head of list being compiled */
1504 GLuint CurrentListNum
; /* Number of the list being compiled */
1505 Node
*CurrentBlock
; /* Pointer to current block of nodes */
1506 GLuint CurrentPos
; /* Index into current block of nodes */
1509 struct gl_extensions Extensions
;
1511 /* Renderer attribute stack */
1512 GLuint AttribStackDepth
;
1513 struct gl_attrib_node
*AttribStack
[MAX_ATTRIB_STACK_DEPTH
];
1515 /* Renderer attribute groups */
1516 struct gl_accum_attrib Accum
;
1517 struct gl_colorbuffer_attrib Color
;
1518 struct gl_current_attrib Current
;
1519 struct gl_depthbuffer_attrib Depth
;
1520 struct gl_eval_attrib Eval
;
1521 struct gl_fog_attrib Fog
;
1522 struct gl_hint_attrib Hint
;
1523 struct gl_light_attrib Light
;
1524 struct gl_line_attrib Line
;
1525 struct gl_list_attrib List
;
1526 struct gl_pixel_attrib Pixel
;
1527 struct gl_point_attrib Point
;
1528 struct gl_polygon_attrib Polygon
;
1529 GLuint PolygonStipple
[32];
1530 struct gl_scissor_attrib Scissor
;
1531 struct gl_stencil_attrib Stencil
;
1532 struct gl_texture_attrib Texture
;
1533 struct gl_transform_attrib Transform
;
1534 struct gl_viewport_attrib Viewport
;
1536 /* Other attribute groups */
1537 struct gl_histogram_attrib Histogram
;
1538 struct gl_minmax_attrib MinMax
;
1539 struct gl_convolution_attrib Convolution1D
;
1540 struct gl_convolution_attrib Convolution2D
;
1541 struct gl_convolution_attrib Separable2D
;
1543 /* Client attribute stack */
1544 GLuint ClientAttribStackDepth
;
1545 struct gl_attrib_node
*ClientAttribStack
[MAX_CLIENT_ATTRIB_STACK_DEPTH
];
1547 /* Client attribute groups */
1548 struct gl_array_attrib Array
; /* Vertex arrays */
1549 struct gl_pixelstore_attrib Pack
; /* Pixel packing */
1550 struct gl_pixelstore_attrib Unpack
; /* Pixel unpacking */
1552 struct gl_evaluators EvalMap
; /* All evaluators */
1553 struct gl_feedback Feedback
; /* Feedback */
1554 struct gl_selection Select
; /* Selection */
1556 struct gl_color_table ColorTable
; /* Pre-convolution */
1557 struct gl_color_table ProxyColorTable
; /* Pre-convolution */
1558 struct gl_color_table PostConvolutionColorTable
;
1559 struct gl_color_table ProxyPostConvolutionColorTable
;
1560 struct gl_color_table PostColorMatrixColorTable
;
1561 struct gl_color_table ProxyPostColorMatrixColorTable
;
1563 GLenum ErrorValue
; /* Last error code */
1564 GLenum RenderMode
; /* either GL_RENDER, GL_SELECT, GL_FEEDBACK */
1565 GLuint NewState
; /* bitwise-or of _NEW_* flags */
1568 GLuint _Enabled
; /* bitwise-or of ENABLE_* flags */
1569 GLuint _TriangleCaps
; /* bitwise-or of DD_* flags */
1570 GLuint _ImageTransferState
;/* bitwise-or of IMAGE_*_BIT flags */
1571 GLfloat _EyeZDir
[3];
1572 GLfloat _ModelViewInvScale
;
1573 GLuint _NeedEyeCoords
;
1574 GLuint _NeedNormals
; /* Are vertex normal vectors needed? */
1576 struct gl_shine_tab
*_ShineTable
[2]; /* Active shine tables */
1577 struct gl_shine_tab
*_ShineTabList
; /* Mru list of inactive shine tables */
1579 struct gl_list_extensions listext
; /* driver dlist extensions */
1582 GLboolean OcclusionResult
; /* GL_HP_occlusion_test */
1583 GLboolean OcclusionResultSaved
; /* GL_HP_occlusion_test */
1585 /* Z buffer stuff */
1586 GLuint DepthMax
; /* Max depth buffer value */
1587 GLfloat DepthMaxF
; /* Float max depth buffer value */
1588 GLfloat MRD
; /* minimum resolvable difference in Z values */
1590 /* Should 3Dfx Glide driver catch signals? */
1591 GLboolean CatchSignals
;
1593 /* For debugging/development only */
1595 GLboolean FirstTimeCurrent
;
1597 /* Dither disable via MESA_NO_DITHER env var */
1600 GLboolean Rendering
;
1602 #if defined(MESA_TRACE)
1603 struct _glapi_table
*TraceDispatch
;
1604 trace_context_t
*TraceCtx
;
1606 void *TraceDispatch
;
1610 /* Core tnl module support */
1611 struct gl_tnl_module TnlModule
;
1613 /* Hooks for module contexts. These will eventually live
1614 * in the driver or elsewhere.
1616 void *swrast_context
;
1617 void *swsetup_context
;
1618 void *swtnl_context
;
1620 void *acache_context
;
1625 /* The string names for GL_POINT, GL_LINE_LOOP, etc */
1626 extern const char *_mesa_prim_name
[GL_POLYGON
+4];
1627 extern GLenum gl_reduce_prim
[];
1631 extern int MESA_VERBOSE
;
1632 extern int MESA_DEBUG_FLAGS
;
1634 # define MESA_VERBOSE 0
1635 # define MESA_DEBUG_FLAGS 0
1643 VERBOSE_VARRAY
= 0x1,
1644 VERBOSE_TEXTURE
= 0x2,
1645 VERBOSE_IMMEDIATE
= 0x4,
1646 VERBOSE_PIPELINE
= 0x8,
1647 VERBOSE_DRIVER
= 0x10,
1648 VERBOSE_STATE
= 0x20,
1650 VERBOSE_DISPLAY_LIST
= 0x200,
1651 VERBOSE_LIGHTING
= 0x400
1656 DEBUG_ALWAYS_FLUSH
= 0x1
1661 #define Elements(x) sizeof(x)/sizeof(*(x))
1665 /* Eventually let the driver specify what statechanges require a flush:
1667 #define FLUSH_VERTICES(ctx, newstate) \
1669 if (ctx->Driver.NeedFlush & FLUSH_STORED_VERTICES) \
1670 ctx->Driver.FlushVertices(ctx, FLUSH_STORED_VERTICES); \
1671 ctx->NewState |= newstate; \
1674 #define FLUSH_CURRENT(ctx, newstate) \
1676 if (ctx->Driver.NeedFlush & FLUSH_UPDATE_CURRENT) \
1677 ctx->Driver.FlushVertices(ctx, FLUSH_UPDATE_CURRENT); \
1678 ctx->NewState |= newstate; \
1681 #define ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, retval) \
1683 if (ctx->Driver.CurrentExecPrimitive != GL_POLYGON+1) { \
1684 _mesa_error( ctx, GL_INVALID_OPERATION, "begin/end" ); \
1689 #define ASSERT_OUTSIDE_BEGIN_END(ctx) \
1690 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx,)
1692 #define ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx) \
1694 ASSERT_OUTSIDE_BEGIN_END(ctx); \
1695 FLUSH_VERTICES(ctx, 0); \
1698 #define ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH_WITH_RETVAL(ctx, retval) \
1700 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, retval); \
1701 FLUSH_VERTICES(ctx, 0); \
1707 #define RENDER_START(CTX) \
1709 assert(!(CTX)->Rendering); \
1710 (CTX)->Rendering = GL_TRUE; \
1711 if ((CTX)->Driver.RenderStart) { \
1712 (*(CTX)->Driver.RenderStart)(CTX); \
1716 #define RENDER_FINISH(CTX) \
1718 assert((CTX)->Rendering); \
1719 (CTX)->Rendering = GL_FALSE; \
1720 if ((CTX)->Driver.RenderFinish) { \
1721 (*(CTX)->Driver.RenderFinish)(CTX); \
1727 #define RENDER_START(CTX) \
1729 if ((CTX)->Driver.RenderStart) { \
1730 (*(CTX)->Driver.RenderStart)(CTX); \
1734 #define RENDER_FINISH(CTX) \
1736 if ((CTX)->Driver.RenderFinish) { \
1737 (*(CTX)->Driver.RenderFinish)(CTX); \
1744 #endif /* TYPES_H */