1 /* $Id: mtypes.h,v 1.14 2001/01/23 23:39:36 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 /* 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_object
;
120 typedef struct __GLcontextRec GLcontext
;
121 typedef struct __GLcontextModesRec GLvisual
;
122 typedef struct gl_frame_buffer GLframebuffer
;
126 /* Maximum number of temporary vertices required for clipping. (Used
127 * in array_cache and tnl modules).
129 #define MAX_CLIPPED_VERTICES ((2 * (6 + MAX_CLIP_PLANES))+1)
132 /* Data structure for color tables */
133 struct gl_color_table
{
135 GLboolean FloatTable
; /* entries stored as floats? (or GLchan type) */
136 GLuint Size
; /* number of entries (rows) in table */
149 * Bit flags used for updating material values.
151 #define FRONT_AMBIENT_BIT 0x1
152 #define BACK_AMBIENT_BIT 0x2
153 #define FRONT_DIFFUSE_BIT 0x4
154 #define BACK_DIFFUSE_BIT 0x8
155 #define FRONT_SPECULAR_BIT 0x10
156 #define BACK_SPECULAR_BIT 0x20
157 #define FRONT_EMISSION_BIT 0x40
158 #define BACK_EMISSION_BIT 0x80
159 #define FRONT_SHININESS_BIT 0x100
160 #define BACK_SHININESS_BIT 0x200
161 #define FRONT_INDEXES_BIT 0x400
162 #define BACK_INDEXES_BIT 0x800
164 #define FRONT_MATERIAL_BITS (FRONT_EMISSION_BIT | FRONT_AMBIENT_BIT | \
165 FRONT_DIFFUSE_BIT | FRONT_SPECULAR_BIT | \
166 FRONT_SHININESS_BIT | FRONT_INDEXES_BIT)
168 #define BACK_MATERIAL_BITS (BACK_EMISSION_BIT | BACK_AMBIENT_BIT | \
169 BACK_DIFFUSE_BIT | BACK_SPECULAR_BIT | \
170 BACK_SHININESS_BIT | BACK_INDEXES_BIT)
172 #define ALL_MATERIAL_BITS (FRONT_MATERIAL_BITS | BACK_MATERIAL_BITS)
177 * Specular exponent and material shininess lookup table sizes:
179 #define EXP_TABLE_SIZE 512
180 #define SHINE_TABLE_SIZE 256
182 struct gl_shine_tab
{
183 struct gl_shine_tab
*next
, *prev
;
184 GLfloat tab
[SHINE_TABLE_SIZE
+1];
191 struct gl_light
*next
; /* double linked list with sentinel */
192 struct gl_light
*prev
;
194 GLfloat Ambient
[4]; /* ambient color */
195 GLfloat Diffuse
[4]; /* diffuse color */
196 GLfloat Specular
[4]; /* specular color */
197 GLfloat EyePosition
[4]; /* position in eye coordinates */
198 GLfloat EyeDirection
[4]; /* spotlight dir in eye coordinates */
199 GLfloat SpotExponent
;
200 GLfloat SpotCutoff
; /* in degress */
201 GLfloat _CosCutoff
; /* = MAX(0, cos(SpotCutoff)) */
202 GLfloat ConstantAttenuation
;
203 GLfloat LinearAttenuation
;
204 GLfloat QuadraticAttenuation
;
205 GLboolean Enabled
; /* On/off flag */
208 GLuint _Flags
; /* State */
210 GLfloat _Position
[4]; /* position in eye/obj coordinates */
211 GLfloat _VP_inf_norm
[3]; /* Norm direction to infinite light */
212 GLfloat _h_inf_norm
[3]; /* Norm( _VP_inf_norm + <0,0,1> ) */
213 GLfloat _NormDirection
[4]; /* normalized spotlight direction */
214 GLfloat _VP_inf_spot_attenuation
;
216 GLfloat _SpotExpTable
[EXP_TABLE_SIZE
][2]; /* to replace a pow() call */
217 GLfloat _MatAmbient
[2][3]; /* material ambient * light ambient */
218 GLfloat _MatDiffuse
[2][3]; /* material diffuse * light diffuse */
219 GLfloat _MatSpecular
[2][3]; /* material spec * light specular */
220 GLfloat _dli
; /* CI diffuse light intensity */
221 GLfloat _sli
; /* CI specular light intensity */
225 struct gl_lightmodel
{
226 GLfloat Ambient
[4]; /* ambient color */
227 GLboolean LocalViewer
; /* Local (or infinite) view point? */
228 GLboolean TwoSide
; /* Two (or one) sided lighting? */
229 GLenum ColorControl
; /* either GL_SINGLE_COLOR */
230 /* or GL_SEPARATE_SPECULAR_COLOR */
241 GLfloat AmbientIndex
; /* for color index lighting */
242 GLfloat DiffuseIndex
; /* for color index lighting */
243 GLfloat SpecularIndex
; /* for color index lighting */
248 * Attribute structures:
249 * We define a struct for each attribute group to make pushing and
250 * popping attributes easy. Also it's a good organization.
252 struct gl_accum_attrib
{
253 GLfloat ClearColor
[4]; /* Accumulation buffer clear color */
258 * Used in DrawDestMask below
260 #define FRONT_LEFT_BIT 1
261 #define FRONT_RIGHT_BIT 2
262 #define BACK_LEFT_BIT 4
263 #define BACK_RIGHT_BIT 8
266 struct gl_colorbuffer_attrib
{
267 GLuint ClearIndex
; /* Index to use for glClear */
268 GLfloat ClearColor
[4]; /* Color to use for glClear */
270 GLuint IndexMask
; /* Color index write mask */
271 GLubyte ColorMask
[4]; /* Each flag is 0xff or 0x0 */
273 GLenum DrawBuffer
; /* Which buffer to draw into */
274 GLenum DriverDrawBuffer
; /* Current device driver dest buffer */
275 GLboolean MultiDrawBuffer
; /* Drawing to mutliple buffers? */
276 GLubyte DrawDestMask
; /* bitwise-OR of bitflags above */
279 GLboolean AlphaEnabled
; /* Alpha test enabled flag */
280 GLenum AlphaFunc
; /* Alpha test function */
281 GLchan AlphaRef
; /* Alpha ref value as GLchan */
284 GLboolean BlendEnabled
; /* Blending enabled flag */
285 GLenum BlendSrcRGB
; /* Blending source operator */
286 GLenum BlendDstRGB
; /* Blending destination operator */
287 GLenum BlendSrcA
; /* GL_INGR_blend_func_separate */
288 GLenum BlendDstA
; /* GL_INGR_blend_func_separate */
289 GLenum BlendEquation
;
290 GLfloat BlendColor
[4];
293 GLenum LogicOp
; /* Logic operator */
294 GLboolean IndexLogicOpEnabled
; /* Color index logic op enabled flag */
295 GLboolean ColorLogicOpEnabled
; /* RGBA logic op enabled flag */
297 GLboolean DitherFlag
; /* Dither enable flag */
301 struct gl_current_attrib
{
302 /* These values valid only when FLUSH_VERTICES has been called.
304 GLfloat Normal
[3]; /* Current vertex normal */
305 GLchan Color
[4]; /* Current RGBA color */
306 GLchan SecondaryColor
[4]; /* Current secondary color */
307 GLfloat FogCoord
; /* Current Fog coord */
308 GLuint Index
; /* Current color index */
309 GLboolean EdgeFlag
; /* Current edge flag */
310 GLfloat Texcoord
[MAX_TEXTURE_UNITS
][4]; /* Current texture coords */
312 /* These values are always valid.
314 GLfloat RasterPos
[4]; /* Current raster position */
315 GLfloat RasterDistance
; /* Current raster distance */
316 GLfloat RasterColor
[4]; /* Current raster color */
317 GLuint RasterIndex
; /* Current raster index */
318 GLfloat
*RasterTexCoord
; /* Current raster texcoord*/
319 GLfloat RasterMultiTexCoord
[MAX_TEXTURE_UNITS
][4];
320 GLboolean RasterPosValid
; /* Raster po valid flag */
324 struct gl_depthbuffer_attrib
{
325 GLenum Func
; /* Function for depth buffer compare */
326 GLfloat Clear
; /* Value to clear depth buffer to */
327 GLboolean Test
; /* Depth buffering enabled flag */
328 GLboolean Mask
; /* Depth buffer writable? */
329 GLboolean OcclusionTest
; /* GL_HP_occlusion_test */
333 struct gl_enable_attrib
{
335 GLboolean AutoNormal
;
337 GLboolean ClipPlane
[MAX_CLIP_PLANES
];
338 GLboolean ColorMaterial
;
339 GLboolean Convolution1D
;
340 GLboolean Convolution2D
;
341 GLboolean Separable2D
;
347 GLboolean Light
[MAX_LIGHTS
];
349 GLboolean LineSmooth
;
350 GLboolean LineStipple
;
351 GLboolean IndexLogicOp
;
352 GLboolean ColorLogicOp
;
353 GLboolean Map1Color4
;
355 GLboolean Map1Normal
;
356 GLboolean Map1TextureCoord1
;
357 GLboolean Map1TextureCoord2
;
358 GLboolean Map1TextureCoord3
;
359 GLboolean Map1TextureCoord4
;
360 GLboolean Map1Vertex3
;
361 GLboolean Map1Vertex4
;
362 GLboolean Map2Color4
;
364 GLboolean Map2Normal
;
365 GLboolean Map2TextureCoord1
;
366 GLboolean Map2TextureCoord2
;
367 GLboolean Map2TextureCoord3
;
368 GLboolean Map2TextureCoord4
;
369 GLboolean Map2Vertex3
;
370 GLboolean Map2Vertex4
;
373 GLboolean PixelTexture
;
374 GLboolean PointSmooth
;
375 GLboolean PolygonOffsetPoint
;
376 GLboolean PolygonOffsetLine
;
377 GLboolean PolygonOffsetFill
;
378 GLboolean PolygonSmooth
;
379 GLboolean PolygonStipple
;
380 GLboolean RescaleNormals
;
383 GLuint Texture
[MAX_TEXTURE_UNITS
];
384 GLuint TexGen
[MAX_TEXTURE_UNITS
];
388 struct gl_eval_attrib
{
390 GLboolean Map1Color4
;
392 GLboolean Map1Normal
;
393 GLboolean Map1TextureCoord1
;
394 GLboolean Map1TextureCoord2
;
395 GLboolean Map1TextureCoord3
;
396 GLboolean Map1TextureCoord4
;
397 GLboolean Map1Vertex3
;
398 GLboolean Map1Vertex4
;
399 GLboolean Map2Color4
;
401 GLboolean Map2Normal
;
402 GLboolean Map2TextureCoord1
;
403 GLboolean Map2TextureCoord2
;
404 GLboolean Map2TextureCoord3
;
405 GLboolean Map2TextureCoord4
;
406 GLboolean Map2Vertex3
;
407 GLboolean Map2Vertex4
;
408 GLboolean AutoNormal
;
409 /* Map Grid endpoints and divisions and calculated du values */
411 GLfloat MapGrid1u1
, MapGrid1u2
, MapGrid1du
;
412 GLint MapGrid2un
, MapGrid2vn
;
413 GLfloat MapGrid2u1
, MapGrid2u2
, MapGrid2du
;
414 GLfloat MapGrid2v1
, MapGrid2v2
, MapGrid2dv
;
418 struct gl_fog_attrib
{
419 GLboolean Enabled
; /* Fog enabled flag */
420 GLfloat Color
[4]; /* Fog color */
421 GLfloat Density
; /* Density >= 0.0 */
422 GLfloat Start
; /* Start distance in eye coords */
423 GLfloat End
; /* End distance in eye coords */
424 GLfloat Index
; /* Fog index */
425 GLenum Mode
; /* Fog mode */
426 GLboolean ColorSumEnabled
;
427 GLenum FogCoordinateSource
;
431 struct gl_hint_attrib
{
432 /* always one of GL_FASTEST, GL_NICEST, or GL_DONT_CARE */
433 GLenum PerspectiveCorrection
;
436 GLenum PolygonSmooth
;
439 /* GL_PGI_misc_hints */
443 GLenum StrictLighting
;
445 /* GL_EXT_clip_volume_hint */
446 GLenum ClipVolumeClipping
;
448 /* GL_ARB_texture_compression */
449 GLenum TextureCompression
;
453 struct gl_histogram_attrib
{
461 GLuint LuminanceSize
;
462 GLuint Count
[HISTOGRAM_TABLE_SIZE
][4];
466 struct gl_minmax_attrib
{
469 GLfloat Min
[4], Max
[4]; /* RGBA */
473 struct gl_convolution_attrib
{
475 GLenum InternalFormat
;
478 GLfloat Filter
[MAX_CONVOLUTION_WIDTH
* MAX_CONVOLUTION_HEIGHT
* 4];
482 struct gl_light_attrib
{
483 struct gl_light Light
[MAX_LIGHTS
]; /* Array of lights */
484 struct gl_lightmodel Model
; /* Lighting model */
486 /* Must flush FLUSH_VERTICES before referencing:
488 struct gl_material Material
[2]; /* Material 0=front, 1=back */
490 GLboolean Enabled
; /* Lighting enabled flag */
491 GLenum ShadeModel
; /* GL_FLAT or GL_SMOOTH */
492 GLenum ColorMaterialFace
; /* GL_FRONT, BACK or FRONT_AND_BACK */
493 GLenum ColorMaterialMode
; /* GL_AMBIENT, GL_DIFFUSE, etc */
494 GLuint ColorMaterialBitmask
; /* bitmask formed from Face and Mode */
495 GLboolean ColorMaterialEnabled
;
497 struct gl_light EnabledList
; /* List sentinel */
499 /* Derived for optimizations: */
500 GLboolean _NeedVertices
; /* Use fast shader? */
501 GLuint _Flags
; /* LIGHT_* flags, see below */
502 GLfloat _BaseColor
[2][3];
503 GLchan _BaseAlpha
[2];
507 #define LIGHT_POSITIONAL 0x4
508 #define LIGHT_SPOT 0x10
509 #define LIGHT_LOCAL_VIEWER 0x20
511 #define LIGHT_NEED_VERTICES (LIGHT_POSITIONAL|LIGHT_LOCAL_VIEWER)
513 struct gl_line_attrib
{
514 GLboolean SmoothFlag
; /* GL_LINE_SMOOTH enabled? */
515 GLboolean StippleFlag
; /* GL_LINE_STIPPLE enabled? */
516 GLushort StipplePattern
; /* Stipple pattern */
517 GLint StippleFactor
; /* Stipple repeat factor */
518 GLfloat Width
; /* Line width */
519 GLfloat _Width
; /* Clamped Line width */
523 struct gl_list_attrib
{
527 struct gl_list_opcode
{
529 void (*execute
)( GLcontext
*ctx
, void *data
);
530 void (*destroy
)( GLcontext
*ctx
, void *data
);
531 void (*print
)( GLcontext
*ctx
, void *data
);
534 #define GL_MAX_EXT_OPCODES 16
536 struct gl_list_extensions
{
537 struct gl_list_opcode opcode
[GL_MAX_EXT_OPCODES
];
541 struct gl_pixel_attrib
{
542 GLenum ReadBuffer
; /* src buffer for glRead/CopyPixels */
543 GLenum DriverReadBuffer
; /* Driver's current source buffer */
544 GLfloat RedBias
, RedScale
;
545 GLfloat GreenBias
, GreenScale
;
546 GLfloat BlueBias
, BlueScale
;
547 GLfloat AlphaBias
, AlphaScale
;
548 GLfloat DepthBias
, DepthScale
;
549 GLint IndexShift
, IndexOffset
;
550 GLboolean MapColorFlag
;
551 GLboolean MapStencilFlag
;
552 GLfloat ZoomX
, ZoomY
;
553 GLint MapStoSsize
; /* Size of each pixel map */
563 GLint MapStoS
[MAX_PIXEL_MAP_TABLE
]; /* Pixel map tables */
564 GLint MapItoI
[MAX_PIXEL_MAP_TABLE
];
565 GLfloat MapItoR
[MAX_PIXEL_MAP_TABLE
];
566 GLfloat MapItoG
[MAX_PIXEL_MAP_TABLE
];
567 GLfloat MapItoB
[MAX_PIXEL_MAP_TABLE
];
568 GLfloat MapItoA
[MAX_PIXEL_MAP_TABLE
];
569 GLubyte MapItoR8
[MAX_PIXEL_MAP_TABLE
]; /* converted to 8-bit color */
570 GLubyte MapItoG8
[MAX_PIXEL_MAP_TABLE
];
571 GLubyte MapItoB8
[MAX_PIXEL_MAP_TABLE
];
572 GLubyte MapItoA8
[MAX_PIXEL_MAP_TABLE
];
573 GLfloat MapRtoR
[MAX_PIXEL_MAP_TABLE
];
574 GLfloat MapGtoG
[MAX_PIXEL_MAP_TABLE
];
575 GLfloat MapBtoB
[MAX_PIXEL_MAP_TABLE
];
576 GLfloat MapAtoA
[MAX_PIXEL_MAP_TABLE
];
577 /* GL_EXT_histogram */
578 GLboolean HistogramEnabled
;
579 GLboolean MinMaxEnabled
;
580 /* GL_SGIS_pixel_texture */
581 GLboolean PixelTextureEnabled
;
582 GLenum FragmentRgbSource
;
583 GLenum FragmentAlphaSource
;
584 /* GL_SGI_color_matrix */
585 GLfloat PostColorMatrixScale
[4]; /* RGBA */
586 GLfloat PostColorMatrixBias
[4]; /* RGBA */
587 /* GL_SGI_color_table */
588 GLfloat ColorTableScale
[4];
589 GLfloat ColorTableBias
[4];
590 GLboolean ColorTableEnabled
;
591 GLfloat PCCTscale
[4];
593 GLboolean PostConvolutionColorTableEnabled
;
594 GLfloat PCMCTscale
[4];
595 GLfloat PCMCTbias
[4];
596 GLboolean PostColorMatrixColorTableEnabled
;
598 GLboolean Convolution1DEnabled
;
599 GLboolean Convolution2DEnabled
;
600 GLboolean Separable2DEnabled
;
601 GLfloat ConvolutionBorderColor
[3][4];
602 GLenum ConvolutionBorderMode
[3];
603 GLfloat ConvolutionFilterScale
[3][4];
604 GLfloat ConvolutionFilterBias
[3][4];
605 GLfloat PostConvolutionScale
[4]; /* RGBA */
606 GLfloat PostConvolutionBias
[4]; /* RGBA */
610 struct gl_point_attrib
{
611 GLboolean SmoothFlag
; /* True if GL_POINT_SMOOTH is enabled */
612 GLboolean SpriteMode
; /* GL_MESA_sprite_point extension */
613 GLfloat Size
; /* User-specified point size */
614 GLfloat _Size
; /* Size clamped to Const.Min/MaxPointSize */
615 GLfloat Params
[3]; /* GL_EXT_point_parameters */
616 GLfloat MinSize
, MaxSize
; /* GL_EXT_point_parameters */
617 GLfloat Threshold
; /* GL_EXT_point_parameters */
618 GLboolean _Attenuated
; /* True if Params != [1, 0, 0] */
622 struct gl_polygon_attrib
{
623 GLenum FrontFace
; /* Either GL_CW or GL_CCW */
624 GLenum FrontMode
; /* Either GL_POINT, GL_LINE or GL_FILL */
625 GLenum BackMode
; /* Either GL_POINT, GL_LINE or GL_FILL */
626 GLboolean _FrontBit
; /* */
627 GLboolean CullFlag
; /* Culling on/off flag */
628 GLboolean SmoothFlag
; /* True if GL_POLYGON_SMOOTH is enabled */
629 GLboolean StippleFlag
; /* True if GL_POLYGON_STIPPLE is enabled */
630 GLenum CullFaceMode
; /* Culling mode GL_FRONT or GL_BACK */
631 GLfloat OffsetFactor
; /* Polygon offset factor, from user */
632 GLfloat OffsetUnits
; /* Polygon offset units, from user */
633 GLfloat OffsetMRD
; /* = OffsetUnits * visual->MRD */
634 GLboolean OffsetPoint
; /* Offset in GL_POINT mode */
635 GLboolean OffsetLine
; /* Offset in GL_LINE mode */
636 GLboolean OffsetFill
; /* Offset in GL_FILL mode */
637 GLboolean _OffsetAny
;
641 struct gl_scissor_attrib
{
642 GLboolean Enabled
; /* Scissor test enabled? */
643 GLint X
, Y
; /* Lower left corner of box */
644 GLsizei Width
, Height
; /* Size of box */
648 struct gl_stencil_attrib
{
649 GLboolean Enabled
; /* Enabled flag */
650 GLenum Function
; /* Stencil function */
651 GLenum FailFunc
; /* Fail function */
652 GLenum ZPassFunc
; /* Depth buffer pass function */
653 GLenum ZFailFunc
; /* Depth buffer fail function */
654 GLstencil Ref
; /* Reference value */
655 GLstencil ValueMask
; /* Value mask */
656 GLstencil Clear
; /* Clear value */
657 GLstencil WriteMask
; /* Write mask */
661 /* TexGenEnabled flags */
667 /* Texture Enabled flags */
668 #define TEXTURE0_1D 0x1 /* Texture unit 0 (default) */
669 #define TEXTURE0_2D 0x2
670 #define TEXTURE0_3D 0x4
671 #define TEXTURE0_CUBE 0x8
672 #define TEXTURE0_ANY (TEXTURE0_1D | TEXTURE0_2D | TEXTURE0_3D | TEXTURE0_CUBE)
673 #define TEXTURE1_1D (TEXTURE0_1D << 4) /* Texture unit 1 */
674 #define TEXTURE1_2D (TEXTURE0_2D << 4)
675 #define TEXTURE1_3D (TEXTURE0_3D << 4)
676 #define TEXTURE1_CUBE (TEXTURE0_CUBE << 4)
677 #define TEXTURE1_ANY (TEXTURE1_1D | TEXTURE1_2D | TEXTURE1_3D | TEXTURE1_CUBE)
678 #define TEXTURE2_1D (TEXTURE0_1D << 8) /* Texture unit 2 */
679 #define TEXTURE2_2D (TEXTURE0_2D << 8)
680 #define TEXTURE2_3D (TEXTURE0_3D << 8)
681 #define TEXTURE2_CUBE (TEXTURE0_CUBE << 8)
682 #define TEXTURE2_ANY (TEXTURE2_1D | TEXTURE2_2D | TEXTURE2_3D | TEXTURE2_CUBE)
683 #define TEXTURE3_1D (TEXTURE0_1D << 12) /* Texture unit 3 */
684 #define TEXTURE3_2D (TEXTURE0_2D << 12)
685 #define TEXTURE3_3D (TEXTURE0_3D << 12)
686 #define TEXTURE3_CUBE (TEXTURE0_CUBE << 12)
687 #define TEXTURE3_ANY (TEXTURE3_1D | TEXTURE3_2D | TEXTURE3_3D | TEXTURE3_CUBE)
688 #define TEXTURE4_1D (TEXTURE0_1D << 16) /* Texture unit 3 */
689 #define TEXTURE4_2D (TEXTURE0_2D << 16)
690 #define TEXTURE4_3D (TEXTURE0_3D << 16)
691 #define TEXTURE4_CUBE (TEXTURE0_CUBE << 16)
692 #define TEXTURE5_ANY (TEXTURE3_1D | TEXTURE3_2D | TEXTURE3_3D | TEXTURE3_CUBE)
693 #define TEXTURE5_1D (TEXTURE0_1D << 20) /* Texture unit 3 */
694 #define TEXTURE5_2D (TEXTURE0_2D << 20)
695 #define TEXTURE5_3D (TEXTURE0_3D << 20)
696 #define TEXTURE5_CUBE (TEXTURE0_CUBE << 20)
697 #define TEXTURE5_ANY (TEXTURE3_1D | TEXTURE3_2D | TEXTURE3_3D | TEXTURE3_CUBE)
698 #define TEXTURE6_1D (TEXTURE0_1D << 24) /* Texture unit 3 */
699 #define TEXTURE6_2D (TEXTURE0_2D << 24)
700 #define TEXTURE6_3D (TEXTURE0_3D << 24)
701 #define TEXTURE6_CUBE (TEXTURE0_CUBE << 24)
702 #define TEXTURE6_ANY (TEXTURE3_1D | TEXTURE3_2D | TEXTURE3_3D | TEXTURE3_CUBE)
703 #define TEXTURE7_1D (TEXTURE0_1D << 28) /* Texture unit 3 */
704 #define TEXTURE7_2D (TEXTURE0_2D << 28)
705 #define TEXTURE7_3D (TEXTURE0_3D << 28)
706 #define TEXTURE7_CUBE (TEXTURE0_CUBE << 28)
707 #define TEXTURE7_ANY (TEXTURE3_1D | TEXTURE3_2D | TEXTURE3_3D | TEXTURE3_CUBE)
709 /* Bitmap versions of the GL_ constants.
711 #define TEXGEN_SPHERE_MAP 0x1
712 #define TEXGEN_OBJ_LINEAR 0x2
713 #define TEXGEN_EYE_LINEAR 0x4
714 #define TEXGEN_REFLECTION_MAP_NV 0x8
715 #define TEXGEN_NORMAL_MAP_NV 0x10
717 #define TEXGEN_NEED_M (TEXGEN_SPHERE_MAP)
718 #define TEXGEN_NEED_F (TEXGEN_SPHERE_MAP | \
719 TEXGEN_REFLECTION_MAP_NV)
720 #define TEXGEN_NEED_NORMALS (TEXGEN_SPHERE_MAP | \
721 TEXGEN_REFLECTION_MAP_NV | \
722 TEXGEN_NORMAL_MAP_NV)
723 #define TEXGEN_NEED_VERTICES (TEXGEN_OBJ_LINEAR | \
724 TEXGEN_EYE_LINEAR | \
725 TEXGEN_REFLECTION_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
744 #define ENABLE_TEXMAT0 0x100 /* Ie. not the identity matrix */
745 #define ENABLE_TEXMAT1 0x200
746 #define ENABLE_TEXMAT2 0x400
747 #define ENABLE_TEXMAT3 0x800
748 #define ENABLE_TEXMAT4 0x1000
749 #define ENABLE_TEXMAT5 0x2000
750 #define ENABLE_TEXMAT6 0x4000
751 #define ENABLE_TEXMAT7 0x8000
752 #define ENABLE_LIGHT 0x10000
753 #define ENABLE_FOG 0x20000
754 #define ENABLE_USERCLIP 0x40000
755 #define ENABLE_NORMALIZE 0x100000
756 #define ENABLE_RESCALE 0x200000
757 #define ENABLE_POINT_ATTEN 0x400000
760 #define ENABLE_TEXGEN_ANY (ENABLE_TEXGEN0 | ENABLE_TEXGEN1 | \
761 ENABLE_TEXGEN2 | ENABLE_TEXGEN3 | \
762 ENABLE_TEXGEN4 | ENABLE_TEXGEN5 | \
763 ENABLE_TEXGEN6 | ENABLE_TEXGEN7)
765 #define ENABLE_TEXMAT_ANY (ENABLE_TEXMAT0 | ENABLE_TEXMAT1 | \
766 ENABLE_TEXMAT2 | ENABLE_TEXMAT3 | \
767 ENABLE_TEXMAT4 | ENABLE_TEXMAT5 | \
768 ENABLE_TEXMAT6 | ENABLE_TEXMAT7)
770 #define ENABLE_TEXGEN(i) (ENABLE_TEXGEN0 << (i))
771 #define ENABLE_TEXMAT(i) (ENABLE_TEXMAT0 << (i))
773 /* Texture image record */
774 struct gl_texture_image
{
775 GLenum Format
; /* GL_ALPHA, GL_LUMINANCE, GL_LUMINANCE_ALPHA,
776 * GL_INTENSITY, GL_RGB, GL_RGBA, or
777 * GL_COLOR_INDEX only
779 GLenum IntFormat
; /* Internal format as given by the user */
780 GLubyte RedBits
; /* Bits per texel component */
781 GLubyte GreenBits
; /* These are initialized by Mesa but */
782 GLubyte BlueBits
; /* may be reassigned by the device */
783 GLubyte AlphaBits
; /* driver to indicate the true texture */
784 GLubyte IntensityBits
; /* color resolution. */
785 GLubyte LuminanceBits
;
787 GLuint Border
; /* 0 or 1 */
788 GLuint Width
; /* = 2^WidthLog2 + 2*Border */
789 GLuint Height
; /* = 2^HeightLog2 + 2*Border */
790 GLuint Depth
; /* = 2^DepthLog2 + 2*Border */
791 GLuint Width2
; /* = Width - 2*Border */
792 GLuint Height2
; /* = Height - 2*Border */
793 GLuint Depth2
; /* = Depth - 2*Border */
794 GLuint WidthLog2
; /* = log2(Width2) */
795 GLuint HeightLog2
; /* = log2(Height2) */
796 GLuint DepthLog2
; /* = log2(Depth2) */
797 GLuint MaxLog2
; /* = MAX(WidthLog2, HeightLog2) */
798 GLchan
*Data
; /* Image data as GLchan's */
800 GLboolean IsCompressed
; /* GL_ARB_texture_compression */
801 GLuint CompressedSize
; /* GL_ARB_texture_compression */
803 /* For device driver: */
804 void *DriverData
; /* Arbitrary device driver data */
808 /* Texture object record */
809 struct gl_texture_object
{
810 _glthread_Mutex Mutex
; /* for thread safety */
811 GLint RefCount
; /* reference count */
812 GLuint Name
; /* an unsigned integer */
813 GLuint Dimensions
; /* 1 or 2 or 3 */
814 GLfloat Priority
; /* in [0,1] */
815 GLchan BorderColor
[4]; /* as integers */
816 GLenum WrapS
; /* GL_CLAMP, REPEAT or CLAMP_TO_EDGE */
817 GLenum WrapT
; /* GL_CLAMP, REPEAT or CLAMP_TO_EDGE */
818 GLenum WrapR
; /* GL_CLAMP, REPEAT or CLAMP_TO_EDGE */
819 GLenum MinFilter
; /* minification filter */
820 GLenum MagFilter
; /* magnification filter */
821 GLfloat MinLod
; /* OpenGL 1.2 */
822 GLfloat MaxLod
; /* OpenGL 1.2 */
823 GLint BaseLevel
; /* user-specified, OpenGL 1.2 */
824 GLint MaxLevel
; /* user-specified, OpenGL 1.2 */
825 GLint _MaxLevel
; /* actual max mipmap level (q in the spec) */
826 GLfloat _MaxLambda
; /* = _MaxLevel - BaseLevel (q - b in spec) */
827 struct gl_texture_image
*Image
[MAX_TEXTURE_LEVELS
];
829 /* Texture cube faces */
830 /* Image[] is alias for *PosX[MAX_TEXTURE_LEVELS]; */
831 struct gl_texture_image
*NegX
[MAX_TEXTURE_LEVELS
];
832 struct gl_texture_image
*PosY
[MAX_TEXTURE_LEVELS
];
833 struct gl_texture_image
*NegY
[MAX_TEXTURE_LEVELS
];
834 struct gl_texture_image
*PosZ
[MAX_TEXTURE_LEVELS
];
835 struct gl_texture_image
*NegZ
[MAX_TEXTURE_LEVELS
];
837 /* GL_EXT_paletted_texture */
838 struct gl_color_table Palette
;
840 GLboolean Complete
; /* Is texture object complete? */
841 struct gl_texture_object
*Next
; /* Next in linked list */
843 /* For device driver: */
844 void *DriverData
; /* Arbitrary device driver data */
850 * Texture units are new with the multitexture extension.
852 struct gl_texture_unit
{
853 GLuint Enabled
; /* bitmask of TEXTURE0_1D, _2D, _3D, _CUBE */
854 GLuint _ReallyEnabled
; /* 0 or one of TEXTURE0_1D, _2D, _3D, _CUBE */
856 GLenum EnvMode
; /* GL_MODULATE, GL_DECAL, GL_BLEND, etc. */
858 GLuint TexGenEnabled
; /* Bitwise-OR of [STRQ]_BIT values */
859 GLenum GenModeS
; /* Tex coord generation mode, either */
860 GLenum GenModeT
; /* GL_OBJECT_LINEAR, or */
861 GLenum GenModeR
; /* GL_EYE_LINEAR, or */
862 GLenum GenModeQ
; /* GL_SPHERE_MAP */
867 GLuint _GenFlags
; /* bitwise or of GenBit[STRQ] */
868 GLfloat ObjectPlaneS
[4];
869 GLfloat ObjectPlaneT
[4];
870 GLfloat ObjectPlaneR
[4];
871 GLfloat ObjectPlaneQ
[4];
872 GLfloat EyePlaneS
[4];
873 GLfloat EyePlaneT
[4];
874 GLfloat EyePlaneR
[4];
875 GLfloat EyePlaneQ
[4];
876 GLfloat LodBias
; /* for biasing mipmap levels */
878 /* GL_EXT_texture_env_combine */
879 GLenum CombineModeRGB
; /* GL_REPLACE, GL_DECAL, GL_ADD, etc. */
880 GLenum CombineModeA
; /* GL_REPLACE, GL_DECAL, GL_ADD, etc. */
881 GLenum CombineSourceRGB
[3]; /* GL_PRIMARY_COLOR, GL_TEXTURE, etc. */
882 GLenum CombineSourceA
[3]; /* GL_PRIMARY_COLOR, GL_TEXTURE, etc. */
883 GLenum CombineOperandRGB
[3]; /* SRC_COLOR, ONE_MINUS_SRC_COLOR, etc */
884 GLenum CombineOperandA
[3]; /* SRC_ALPHA, ONE_MINUS_SRC_ALPHA, etc */
885 GLuint CombineScaleShiftRGB
; /* 0, 1 or 2 */
886 GLuint CombineScaleShiftA
; /* 0, 1 or 2 */
888 struct gl_texture_object
*Current1D
;
889 struct gl_texture_object
*Current2D
;
890 struct gl_texture_object
*Current3D
;
891 struct gl_texture_object
*CurrentCubeMap
; /* GL_ARB_texture_cube_map */
893 struct gl_texture_object
*_Current
; /* Points to really enabled tex obj */
895 struct gl_texture_object Saved1D
; /* only used by glPush/PopAttrib */
896 struct gl_texture_object Saved2D
;
897 struct gl_texture_object Saved3D
;
898 struct gl_texture_object SavedCubeMap
;
902 struct gl_texture_attrib
{
904 GLuint CurrentUnit
; /* Active texture unit */
905 GLuint CurrentTransformUnit
; /* Client active texture xform unit */
907 GLuint _ReallyEnabled
; /* enables for all texture units: */
908 /* = (Unit[0]._ReallyEnabled << 0) | */
909 /* (Unit[1]._ReallyEnabled << 4) | */
910 /* (Unit[2]._ReallyEnabled << 8) | etc... */
911 GLuint _GenFlags
; /* for texgen */
913 struct gl_texture_unit Unit
[MAX_TEXTURE_UNITS
];
915 struct gl_texture_object
*Proxy1D
;
916 struct gl_texture_object
*Proxy2D
;
917 struct gl_texture_object
*Proxy3D
;
918 struct gl_texture_object
*ProxyCubeMap
;
920 /* GL_EXT_shared_texture_palette */
921 GLboolean SharedPalette
;
922 struct gl_color_table Palette
;
926 struct gl_transform_attrib
{
927 GLenum MatrixMode
; /* Matrix mode */
928 GLfloat EyeUserPlane
[MAX_CLIP_PLANES
][4];
929 GLfloat _ClipUserPlane
[MAX_CLIP_PLANES
][4]; /* derived */
930 GLboolean ClipEnabled
[MAX_CLIP_PLANES
];
931 GLubyte _AnyClip
; /* How many ClipEnabled? */
932 GLboolean Normalize
; /* Normalize all normals? */
933 GLboolean RescaleNormals
; /* GL_EXT_rescale_normal */
937 struct gl_viewport_attrib
{
938 GLint X
, Y
; /* position */
939 GLsizei Width
, Height
; /* size */
940 GLfloat Near
, Far
; /* Depth buffer range */
941 GLmatrix _WindowMap
; /* Mapping transformation as a matrix. */
945 /* For the attribute stack: */
946 struct gl_attrib_node
{
949 struct gl_attrib_node
*next
;
955 * Client pixel packing/unpacking attributes
957 struct gl_pixelstore_attrib
{
962 GLint ImageHeight
; /* for GL_EXT_texture3D */
963 GLint SkipImages
; /* for GL_EXT_texture3D */
970 * Client vertex array attributes
972 struct gl_client_array
{
975 GLsizei Stride
; /* user-specified stride */
976 GLsizei StrideB
; /* actual stride in bytes */
984 struct gl_array_attrib
{
985 struct gl_client_array Vertex
; /* client data descriptors */
986 struct gl_client_array Normal
;
987 struct gl_client_array Color
;
988 struct gl_client_array SecondaryColor
;
989 struct gl_client_array FogCoord
;
990 struct gl_client_array Index
;
991 struct gl_client_array TexCoord
[MAX_TEXTURE_UNITS
];
992 struct gl_client_array EdgeFlag
;
994 GLint TexCoordInterleaveFactor
;
995 GLint ActiveTexture
; /* Client Active Texture */
999 GLuint _Enabled
; /* _NEW_ARRAY_* - bit set if array enabled */
1000 GLuint NewState
; /* _NEW_ARRAY_* */
1006 struct gl_feedback
{
1008 GLuint _Mask
; /* FB_* bits */
1016 struct gl_selection
{
1018 GLuint BufferSize
; /* size of SelectBuffer */
1019 GLuint BufferCount
; /* number of values in SelectBuffer */
1020 GLuint Hits
; /* number of records in SelectBuffer */
1021 GLuint NameStackDepth
;
1022 GLuint NameStack
[MAX_NAME_STACK_DEPTH
];
1024 GLfloat HitMinZ
, HitMaxZ
;
1030 * 1-D Evaluator control points
1033 GLuint Order
; /* Number of control points */
1034 GLfloat u1
, u2
, du
; /* u1, u2, 1.0/(u2-u1) */
1035 GLfloat
*Points
; /* Points to contiguous control points */
1040 * 2-D Evaluator control points
1043 GLuint Uorder
; /* Number of control points in U dimension */
1044 GLuint Vorder
; /* Number of control points in V dimension */
1047 GLfloat
*Points
; /* Points to contiguous control points */
1052 * All evalutator control points
1054 struct gl_evaluators
{
1056 struct gl_1d_map Map1Vertex3
;
1057 struct gl_1d_map Map1Vertex4
;
1058 struct gl_1d_map Map1Index
;
1059 struct gl_1d_map Map1Color4
;
1060 struct gl_1d_map Map1Normal
;
1061 struct gl_1d_map Map1Texture1
;
1062 struct gl_1d_map Map1Texture2
;
1063 struct gl_1d_map Map1Texture3
;
1064 struct gl_1d_map Map1Texture4
;
1067 struct gl_2d_map Map2Vertex3
;
1068 struct gl_2d_map Map2Vertex4
;
1069 struct gl_2d_map Map2Index
;
1070 struct gl_2d_map Map2Color4
;
1071 struct gl_2d_map Map2Normal
;
1072 struct gl_2d_map Map2Texture1
;
1073 struct gl_2d_map Map2Texture2
;
1074 struct gl_2d_map Map2Texture3
;
1075 struct gl_2d_map Map2Texture4
;
1081 * State which can be shared by multiple contexts:
1083 struct gl_shared_state
{
1084 _glthread_Mutex Mutex
; /* for thread safety */
1085 GLint RefCount
; /* Reference count */
1086 struct _mesa_HashTable
*DisplayList
; /* Display lists hash table */
1087 struct _mesa_HashTable
*TexObjects
; /* Texture objects hash table */
1088 struct gl_texture_object
*TexObjectList
;/* Linked list of texture objects */
1090 /* Default texture objects (shared by all multi-texture units) */
1091 struct gl_texture_object
*Default1D
;
1092 struct gl_texture_object
*Default2D
;
1093 struct gl_texture_object
*Default3D
;
1094 struct gl_texture_object
*DefaultCubeMap
;
1096 void *DriverData
; /* Device driver shared state */
1102 * A "frame buffer" is a color buffer and its optional ancillary buffers:
1103 * depth, accum, stencil, and software-simulated alpha buffers.
1104 * In C++ terms, think of this as a base class from which device drivers
1105 * will make derived classes.
1107 struct gl_frame_buffer
{
1108 GLvisual
*Visual
; /* The corresponding visual */
1110 GLint Width
, Height
; /* size of frame buffer in pixels */
1112 GLboolean UseSoftwareDepthBuffer
;
1113 GLboolean UseSoftwareAccumBuffer
;
1114 GLboolean UseSoftwareStencilBuffer
;
1115 GLboolean UseSoftwareAlphaBuffers
;
1117 /* Software depth (aka Z) buffer */
1118 GLvoid
*DepthBuffer
; /* array [Width*Height] of GLushort or GLuint*/
1120 /* Software stencil buffer */
1121 GLstencil
*Stencil
; /* array [Width*Height] of GLstencil values */
1123 /* Software accumulation buffer */
1124 GLaccum
*Accum
; /* array [4*Width*Height] of GLaccum values */
1126 /* Software alpha planes */
1127 GLchan
*FrontLeftAlpha
; /* array [Width*Height] of GLubyte */
1128 GLchan
*BackLeftAlpha
; /* array [Width*Height] of GLubyte */
1129 GLchan
*FrontRightAlpha
; /* array [Width*Height] of GLubyte */
1130 GLchan
*BackRightAlpha
; /* array [Width*Height] of GLubyte */
1131 GLchan
*Alpha
; /* Points to current alpha buffer */
1133 /* Drawing bounds: intersection of window size and scissor box */
1134 GLint _Xmin
, _Ymin
; /* inclusive */
1135 GLint _Xmax
, _Ymax
; /* exclusive */
1140 * Constants which may be overriden by device driver.
1142 struct gl_constants
{
1143 GLint MaxTextureSize
;
1144 GLint MaxCubeTextureSize
;
1145 GLint MaxTextureLevels
;
1146 GLuint MaxTextureUnits
;
1147 GLuint MaxArrayLockSize
;
1149 GLfloat MinPointSize
, MaxPointSize
; /* aliased */
1150 GLfloat MinPointSizeAA
, MaxPointSizeAA
; /* antialiased */
1151 GLfloat PointSizeGranularity
;
1152 GLfloat MinLineWidth
, MaxLineWidth
; /* aliased */
1153 GLfloat MinLineWidthAA
, MaxLineWidthAA
; /* antialiased */
1154 GLfloat LineWidthGranularity
;
1155 GLuint NumAuxBuffers
;
1156 GLuint MaxColorTableSize
;
1157 GLuint MaxConvolutionWidth
;
1158 GLuint MaxConvolutionHeight
;
1159 GLuint NumCompressedTextureFormats
; /* GL_ARB_texture_compression */
1160 GLenum CompressedTextureFormats
[MAX_COMPRESSED_TEXTURE_FORMATS
];
1161 GLuint MaxClipPlanes
;
1167 * List of extensions.
1170 struct gl_extensions
{
1172 struct extension
*ext_list
;
1173 /* Flags to quickly test if certain extensions are available.
1174 * Not every extension needs to have such a flag, but it's encouraged.
1176 GLboolean ARB_imaging
;
1177 GLboolean ARB_multitexture
;
1178 GLboolean ARB_texture_compression
;
1179 GLboolean ARB_texture_cube_map
;
1180 GLboolean ARB_texture_env_add
;
1181 GLboolean EXT_blend_color
;
1182 GLboolean EXT_blend_func_separate
;
1183 GLboolean EXT_blend_logic_op
;
1184 GLboolean EXT_blend_minmax
;
1185 GLboolean EXT_blend_subtract
;
1186 GLboolean EXT_clip_volume_hint
;
1187 GLboolean EXT_convolution
;
1188 GLboolean EXT_compiled_vertex_array
;
1189 GLboolean EXT_fog_coord
;
1190 GLboolean EXT_histogram
;
1191 GLboolean EXT_packed_pixels
;
1192 GLboolean EXT_paletted_texture
;
1193 GLboolean EXT_point_parameters
;
1194 GLboolean EXT_polygon_offset
;
1195 GLboolean EXT_rescale_normal
;
1196 GLboolean EXT_secondary_color
;
1197 GLboolean EXT_shared_texture_palette
;
1198 GLboolean EXT_stencil_wrap
;
1199 GLboolean EXT_texture3D
;
1200 GLboolean EXT_texture_compression_s3tc
;
1201 GLboolean EXT_texture_env_add
;
1202 GLboolean EXT_texture_env_combine
;
1203 GLboolean EXT_texture_env_dot3
;
1204 GLboolean EXT_texture_object
;
1205 GLboolean EXT_texture_lod_bias
;
1206 GLboolean EXT_vertex_array_set
;
1207 GLboolean HP_occlusion_test
;
1208 GLboolean INGR_blend_func_separate
;
1209 GLboolean MESA_window_pos
;
1210 GLboolean MESA_resize_buffers
;
1211 GLboolean MESA_sprite_point
;
1212 GLboolean NV_blend_square
;
1213 GLboolean NV_texgen_reflection
;
1214 GLboolean PGI_misc_hints
;
1215 GLboolean SGI_color_matrix
;
1216 GLboolean SGI_color_table
;
1217 GLboolean SGIS_pixel_texture
;
1218 GLboolean SGIS_texture_edge_clamp
;
1219 GLboolean SGIX_pixel_texture
;
1220 GLboolean _3DFX_texture_compression_FXT1
;
1226 * Bits for image transfer operations (ctx->ImageTransferState).
1228 #define IMAGE_SCALE_BIAS_BIT 0x1
1229 #define IMAGE_SHIFT_OFFSET_BIT 0x2
1230 #define IMAGE_MAP_COLOR_BIT 0x4
1231 #define IMAGE_COLOR_TABLE_BIT 0x8
1232 #define IMAGE_CONVOLUTION_BIT 0x10
1233 #define IMAGE_POST_CONVOLUTION_SCALE_BIAS 0x20
1234 #define IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT 0x40
1235 #define IMAGE_COLOR_MATRIX_BIT 0x80
1236 #define IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT 0x100
1237 #define IMAGE_HISTOGRAM_BIT 0x200
1238 #define IMAGE_MIN_MAX_BIT 0x400
1240 /* transfer ops up to convolution: */
1241 #define IMAGE_PRE_CONVOLUTION_BITS (IMAGE_SCALE_BIAS_BIT | \
1242 IMAGE_SHIFT_OFFSET_BIT | \
1243 IMAGE_MAP_COLOR_BIT | \
1244 IMAGE_COLOR_TABLE_BIT)
1246 /* transfer ops after convolution: */
1247 #define IMAGE_POST_CONVOLUTION_BITS (IMAGE_POST_CONVOLUTION_SCALE_BIAS | \
1248 IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT | \
1249 IMAGE_COLOR_MATRIX_BIT | \
1250 IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT |\
1251 IMAGE_HISTOGRAM_BIT | \
1256 * Bits to indicate what state has changed. 6 unused flags.
1258 #define _NEW_MODELVIEW 0x1 /* ctx->ModelView */
1259 #define _NEW_PROJECTION 0x2 /* ctx->Projection */
1260 #define _NEW_TEXTURE_MATRIX 0x4 /* ctx->TextureMatrix */
1261 #define _NEW_COLOR_MATRIX 0x8 /* ctx->ColorMatrix */
1262 #define _NEW_ACCUM 0x10 /* ctx->Accum */
1263 #define _NEW_COLOR 0x20 /* ctx->Color */
1264 #define _NEW_DEPTH 0x40 /* ctx->Depth */
1265 #define _NEW_EVAL 0x80 /* ctx->Eval, ctx->EvalMap */
1266 #define _NEW_FOG 0x100 /* ctx->Fog */
1267 #define _NEW_HINT 0x200 /* ctx->Hint */
1268 #define _NEW_400 0x400 /* */
1269 #define _NEW_LIGHT 0x800 /* ctx->Light */
1270 #define _NEW_1000 0x1000 /* */
1271 #define _NEW_LINE 0x2000 /* ctx->Line */
1272 #define _NEW_4000 0x4000 /* */
1273 #define _NEW_PIXEL 0x8000 /* ctx->Pixel */
1274 #define _NEW_POINT 0x10000 /* ctx->Point */
1275 #define _NEW_POLYGON 0x20000 /* ctx->Polygon */
1276 #define _NEW_POLYGONSTIPPLE 0x40000 /* ctx->PolygonStipple */
1277 #define _NEW_SCISSOR 0x80000 /* ctx->Scissor */
1278 #define _NEW_STENCIL 0x100000 /* ctx->Stencil */
1279 #define _NEW_TEXTURE 0x200000 /* ctx->Texture */
1280 #define _NEW_TRANSFORM 0x400000 /* ctx->Transform */
1281 #define _NEW_VIEWPORT 0x800000 /* ctx->Viewport */
1282 #define _NEW_PACKUNPACK 0x1000000 /* ctx->Pack, ctx->Unpack */
1283 #define _NEW_ARRAY 0x2000000 /* ctx->Array */
1284 #define _NEW_COLORTABLE 0x4000000 /* ctx->{*}ColorTable */
1285 #define _NEW_RENDERMODE 0x8000000 /* RenderMode, Feedback, Select */
1286 #define _NEW_BUFFERS 0x10000000 /* ctx->Visual, ctx->DrawBuffer, */
1292 /* Bits to track array state changes (also used to summarize array enabled)
1294 #define _NEW_ARRAY_VERTEX 0x1
1295 #define _NEW_ARRAY_COLOR 0x2
1296 #define _NEW_ARRAY_NORMAL 0x4
1297 #define _NEW_ARRAY_INDEX 0x8
1298 #define _NEW_ARRAY_EDGEFLAG 0x10
1299 #define _NEW_ARRAY_SECONDARYCOLOR 0x20
1300 #define _NEW_ARRAY_FOGCOORD 0x40
1301 #define _NEW_ARRAY_TEXCOORD_0 0x80
1302 #define _NEW_ARRAY_TEXCOORD_1 0x100
1303 #define _NEW_ARRAY_TEXCOORD_2 0x200
1304 #define _NEW_ARRAY_TEXCOORD_3 0x400
1305 #define _NEW_ARRAY_TEXCOORD_4 0x800
1306 #define _NEW_ARRAY_TEXCOORD_5 0x1000
1307 #define _NEW_ARRAY_TEXCOORD_6 0x2000
1308 #define _NEW_ARRAY_TEXCOORD_7 0x4000
1309 #define _NEW_ARRAY_ALL 0x7fff
1311 #define _NEW_ARRAY_TEXCOORD(i) (_NEW_ARRAY_TEXCOORD_0<<(i))
1313 /* A bunch of flags that we think might be useful to drivers.
1315 #define DD_FEEDBACK 0x1
1316 #define DD_SELECT 0x2
1317 #define DD_FLATSHADE 0x4
1318 #define DD_SEPERATE_SPECULAR 0x10
1319 #define DD_TRI_LIGHT_TWOSIDE 0x20
1320 #define DD_TRI_UNFILLED 0x40
1321 #define DD_TRI_SMOOTH 0x80
1322 #define DD_TRI_STIPPLE 0x100
1323 #define DD_TRI_OFFSET 0x200
1324 #define DD_LINE_SMOOTH 0x800
1325 #define DD_LINE_STIPPLE 0x1000
1326 #define DD_LINE_WIDTH 0x2000
1327 #define DD_POINT_SMOOTH 0x4000
1328 #define DD_POINT_SIZE 0x8000
1329 #define DD_POINT_ATTEN 0x10000
1330 #define DD_TRI_CULL_FRONT_BACK 0x400000 /* special case on some hw */
1331 #define DD_Z_NEVER 0x800000 /* special case on some hw */
1332 #define DD_STENCIL 0x1000000
1334 /* Define the state changes under which each of these bits might change
1336 #define _DD_NEW_FEEDBACK _NEW_RENDERMODE
1337 #define _DD_NEW_SELECT _NEW_RENDERMODE
1338 #define _DD_NEW_FLATSHADE _NEW_LIGHT
1339 #define _DD_NEW_MULTIDRAW _NEW_COLOR
1340 #define _DD_NEW_SEPERATE_SPECULAR (_NEW_LIGHT|_NEW_FOG)
1341 #define _DD_NEW_TRI_LIGHT_TWOSIDE _NEW_LIGHT
1342 #define _DD_NEW_TRI_UNFILLED _NEW_POLYGON
1343 #define _DD_NEW_TRI_SMOOTH _NEW_POLYGON
1344 #define _DD_NEW_TRI_STIPPLE _NEW_POLYGON
1345 #define _DD_NEW_TRI_OFFSET _NEW_POLYGON
1346 #define _DD_NEW_LINE_SMOOTH _NEW_LINE
1347 #define _DD_NEW_LINE_STIPPLE _NEW_LINE
1348 #define _DD_NEW_LINE_WIDTH _NEW_LINE
1349 #define _DD_NEW_POINT_SMOOTH _NEW_POINT
1350 #define _DD_NEW_POINT_SIZE _NEW_POINT
1351 #define _DD_NEW_POINT_ATTEN _NEW_POINT
1352 #define _DD_NEW_LIGHTING_CULL _NEW_LIGHT
1353 #define _DD_NEW_TRI_CULL_FRONT_BACK _NEW_POLYGON
1354 #define _DD_NEW_Z_NEVER _NEW_DEPTH
1355 #define _DD_NEW_STENCIL _NEW_STENCIL
1358 #define _MESA_NEW_NEED_EYE_COORDS (_NEW_LIGHT| \
1363 #define _MESA_NEW_NEED_NORMALS (_NEW_LIGHT| \
1365 #define _IMAGE_NEW_TRANSFER_STATE (_NEW_PIXEL|_NEW_COLOR_MATRIX)
1368 #define NEED_NORMALS_TEXGEN 0x1
1369 #define NEED_NORMALS_LIGHT 0x2
1371 #define NEED_EYE_TEXGEN 0x1
1372 #define NEED_EYE_LIGHT 0x2
1373 #define NEED_EYE_LIGHT_MODELVIEW 0x4
1374 #define NEED_EYE_POINT_ATTEN 0x8
1379 * Forward declaration of display list datatypes:
1382 typedef union node Node
;
1388 /* This has to be included here. */
1393 * The library context:
1395 struct __GLcontextRec
{
1397 ** Os related interfaces; these *must* be the first members of this
1398 ** structure, because they are exposed to the outside world (i.e. GLX
1401 __GLimports imports
;
1402 __GLexports exports
;
1404 /* State possibly shared with other contexts in the address space */
1405 struct gl_shared_state
*Shared
;
1407 /* API function pointer tables */
1408 struct _glapi_table
*Save
; /* Display list save funcs */
1409 struct _glapi_table
*Exec
; /* Execute funcs */
1410 struct _glapi_table
*CurrentDispatch
; /* == Save or Exec !! */
1412 GLboolean ExecPrefersFloat
; /* What preference for color conversion? */
1413 GLboolean SavePrefersFloat
;
1416 GLframebuffer
*DrawBuffer
; /* buffer for writing */
1417 GLframebuffer
*ReadBuffer
; /* buffer for reading */
1419 /* Driver function pointer table */
1420 struct dd_function_table Driver
;
1422 void *DriverCtx
; /* Points to device driver context/state */
1423 void *DriverMgrCtx
; /* Points to device driver manager (optional)*/
1425 /* Core/Driver constants */
1426 struct gl_constants Const
;
1428 /* Modelview matrix and stack */
1429 GLmatrix ModelView
; /* current matrix, not stored on stack */
1430 GLuint ModelViewStackDepth
;
1431 GLmatrix ModelViewStack
[MAX_MODELVIEW_STACK_DEPTH
- 1];
1433 /* Projection matrix and stack */
1434 GLmatrix ProjectionMatrix
; /* current matrix, not stored on stack */
1435 GLuint ProjectionStackDepth
;
1436 GLmatrix ProjectionStack
[MAX_PROJECTION_STACK_DEPTH
- 1];
1438 /* Combined modelview and projection matrix */
1439 GLmatrix _ModelProjectMatrix
;
1441 /* Texture matrix and stack */
1442 GLmatrix TextureMatrix
[MAX_TEXTURE_UNITS
];
1443 GLuint TextureStackDepth
[MAX_TEXTURE_UNITS
];
1444 GLmatrix TextureStack
[MAX_TEXTURE_UNITS
][MAX_TEXTURE_STACK_DEPTH
- 1];
1446 /* Color matrix and stack */
1447 GLmatrix ColorMatrix
;
1448 GLuint ColorStackDepth
;
1449 GLmatrix ColorStack
[MAX_COLOR_STACK_DEPTH
- 1];
1452 GLuint CallDepth
; /* Current recursion calling depth */
1453 GLboolean ExecuteFlag
; /* Execute GL commands? */
1454 GLboolean CompileFlag
; /* Compile GL commands into display list? */
1455 Node
*CurrentListPtr
; /* Head of list being compiled */
1456 GLuint CurrentListNum
; /* Number of the list being compiled */
1457 Node
*CurrentBlock
; /* Pointer to current block of nodes */
1458 GLuint CurrentPos
; /* Index into current block of nodes */
1461 struct gl_extensions Extensions
;
1463 /* Renderer attribute stack */
1464 GLuint AttribStackDepth
;
1465 struct gl_attrib_node
*AttribStack
[MAX_ATTRIB_STACK_DEPTH
];
1467 /* Renderer attribute groups */
1468 struct gl_accum_attrib Accum
;
1469 struct gl_colorbuffer_attrib Color
;
1470 struct gl_current_attrib Current
;
1471 struct gl_depthbuffer_attrib Depth
;
1472 struct gl_eval_attrib Eval
;
1473 struct gl_fog_attrib Fog
;
1474 struct gl_hint_attrib Hint
;
1475 struct gl_light_attrib Light
;
1476 struct gl_line_attrib Line
;
1477 struct gl_list_attrib List
;
1478 struct gl_pixel_attrib Pixel
;
1479 struct gl_point_attrib Point
;
1480 struct gl_polygon_attrib Polygon
;
1481 GLuint PolygonStipple
[32];
1482 struct gl_scissor_attrib Scissor
;
1483 struct gl_stencil_attrib Stencil
;
1484 struct gl_texture_attrib Texture
;
1485 struct gl_transform_attrib Transform
;
1486 struct gl_viewport_attrib Viewport
;
1488 /* Other attribute groups */
1489 struct gl_histogram_attrib Histogram
;
1490 struct gl_minmax_attrib MinMax
;
1491 struct gl_convolution_attrib Convolution1D
;
1492 struct gl_convolution_attrib Convolution2D
;
1493 struct gl_convolution_attrib Separable2D
;
1495 /* Client attribute stack */
1496 GLuint ClientAttribStackDepth
;
1497 struct gl_attrib_node
*ClientAttribStack
[MAX_CLIENT_ATTRIB_STACK_DEPTH
];
1499 /* Client attribute groups */
1500 struct gl_array_attrib Array
; /* Vertex arrays */
1501 struct gl_pixelstore_attrib Pack
; /* Pixel packing */
1502 struct gl_pixelstore_attrib Unpack
; /* Pixel unpacking */
1504 struct gl_evaluators EvalMap
; /* All evaluators */
1505 struct gl_feedback Feedback
; /* Feedback */
1506 struct gl_selection Select
; /* Selection */
1508 struct gl_color_table ColorTable
; /* Pre-convolution */
1509 struct gl_color_table ProxyColorTable
; /* Pre-convolution */
1510 struct gl_color_table PostConvolutionColorTable
;
1511 struct gl_color_table ProxyPostConvolutionColorTable
;
1512 struct gl_color_table PostColorMatrixColorTable
;
1513 struct gl_color_table ProxyPostColorMatrixColorTable
;
1515 GLenum ErrorValue
; /* Last error code */
1516 GLenum RenderMode
; /* either GL_RENDER, GL_SELECT, GL_FEEDBACK */
1517 GLuint NewState
; /* bitwise-or of _NEW_* flags */
1520 GLuint _Enabled
; /* bitwise-or of ENABLE_* flags */
1521 GLuint _TriangleCaps
; /* bitwise-or of DD_* flags */
1522 GLuint _ImageTransferState
;/* bitwise-or of IMAGE_*_BIT flags */
1523 GLfloat _EyeZDir
[3];
1524 GLfloat _ModelViewInvScale
;
1525 GLuint _NeedEyeCoords
;
1526 GLuint _NeedNormals
; /* Are vertex normal vectors needed? */
1528 struct gl_shine_tab
*_ShineTable
[2]; /* Active shine tables */
1529 struct gl_shine_tab
*_ShineTabList
; /* Mru list of inactive shine tables */
1531 struct gl_list_extensions listext
; /* driver dlist extensions */
1534 GLboolean OcclusionResult
; /* GL_HP_occlusion_test */
1535 GLboolean OcclusionResultSaved
; /* GL_HP_occlusion_test */
1537 /* Z buffer stuff */
1538 GLuint DepthMax
; /* Max depth buffer value */
1539 GLfloat DepthMaxF
; /* Float max depth buffer value */
1540 GLfloat MRD
; /* minimum resolvable difference in Z values */
1542 /* Should 3Dfx Glide driver catch signals? */
1543 GLboolean CatchSignals
;
1545 /* For debugging/development only */
1547 GLboolean FirstTimeCurrent
;
1549 /* Dither disable via MESA_NO_DITHER env var */
1552 GLboolean Rendering
;
1554 #if defined(MESA_TRACE)
1555 struct _glapi_table
*TraceDispatch
;
1556 trace_context_t
*TraceCtx
;
1558 void *TraceDispatch
;
1562 /* Hooks for module contexts. These will eventually live
1563 * in the driver or elsewhere.
1565 void *swrast_context
;
1566 void *swsetup_context
;
1567 void *swtnl_context
;
1569 void *acache_context
;
1574 /* The string names for GL_POINT, GL_LINE_LOOP, etc */
1575 extern const char *_mesa_prim_name
[GL_POLYGON
+4];
1576 extern GLenum gl_reduce_prim
[];
1580 extern int MESA_VERBOSE
;
1581 extern int MESA_DEBUG_FLAGS
;
1583 # define MESA_VERBOSE 0
1584 # define MESA_DEBUG_FLAGS 0
1592 VERBOSE_VARRAY
= 0x1,
1593 VERBOSE_TEXTURE
= 0x2,
1594 VERBOSE_IMMEDIATE
= 0x4,
1595 VERBOSE_PIPELINE
= 0x8,
1596 VERBOSE_DRIVER
= 0x10,
1597 VERBOSE_STATE
= 0x20,
1599 VERBOSE_DISPLAY_LIST
= 0x200,
1600 VERBOSE_LIGHTING
= 0x400
1605 DEBUG_ALWAYS_FLUSH
= 0x1
1610 #define Elements(x) sizeof(x)/sizeof(*(x))
1614 /* Eventually let the driver specify what statechanges require a flush:
1616 #define FLUSH_VERTICES(ctx, newstate) \
1618 if (ctx->Driver.NeedFlush & FLUSH_STORED_VERTICES) \
1619 ctx->Driver.FlushVertices(ctx, FLUSH_STORED_VERTICES); \
1620 ctx->NewState |= newstate; \
1623 #define FLUSH_CURRENT(ctx, newstate) \
1625 if (ctx->Driver.NeedFlush & FLUSH_UPDATE_CURRENT) \
1626 ctx->Driver.FlushVertices(ctx, FLUSH_UPDATE_CURRENT); \
1627 ctx->NewState |= newstate; \
1630 #define ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, retval) \
1632 if (ctx->Driver.CurrentExecPrimitive != GL_POLYGON+1) { \
1633 gl_error( ctx, GL_INVALID_OPERATION, "begin/end" ); \
1638 #define ASSERT_OUTSIDE_BEGIN_END(ctx) \
1639 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx,)
1641 #define ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx) \
1643 ASSERT_OUTSIDE_BEGIN_END(ctx); \
1644 FLUSH_VERTICES(ctx, 0); \
1647 #define ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH_WITH_RETVAL(ctx, retval) \
1649 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, retval); \
1650 FLUSH_VERTICES(ctx, 0); \
1656 #define RENDER_START(CTX) \
1658 assert(!(CTX)->Rendering); \
1659 (CTX)->Rendering = GL_TRUE; \
1660 if ((CTX)->Driver.RenderStart) { \
1661 (*(CTX)->Driver.RenderStart)(CTX); \
1665 #define RENDER_FINISH(CTX) \
1667 assert((CTX)->Rendering); \
1668 (CTX)->Rendering = GL_FALSE; \
1669 if ((CTX)->Driver.RenderFinish) { \
1670 (*(CTX)->Driver.RenderFinish)(CTX); \
1676 #define RENDER_START(CTX) \
1678 if ((CTX)->Driver.RenderStart) { \
1679 (*(CTX)->Driver.RenderStart)(CTX); \
1683 #define RENDER_FINISH(CTX) \
1685 if ((CTX)->Driver.RenderFinish) { \
1686 (*(CTX)->Driver.RenderFinish)(CTX); \
1693 #endif /* TYPES_H */