1 /* $Id: mtypes.h,v 1.5 2000/12/08 00:20:15 brianp Exp $ */
4 * Mesa 3-D graphics library
7 * Copyright (C) 1999-2000 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 "fixed.h" /* GLfixed */
35 #include "glapitable.h"
38 #include "math/m_matrix.h" /* GLmatrix */
39 #include "math/m_translate.h" /* trans_XXX_func */
41 #if defined(MESA_TRACE)
42 #include "Trace/tr_context.h"
46 /* This is a macro on IRIX */
52 /* Please try to mark derived values with a leading underscore ('_').
56 * Color channel data type:
59 typedef GLubyte GLchan
;
61 #define CHAN_MAXF 255.0F
62 #define CHAN_TYPE GL_UNSIGNED_BYTE
64 typedef GLushort GLchan
;
65 #define CHAN_MAX 65535
66 #define CHAN_MAXF 65535.0F
67 #define CHAN_TYPE GL_UNSIGNED_SHORT
69 typedef GLfloat GLchan
;
71 #define CHAN_MAXF 1.0F
72 #define CHAN_TYPE GL_FLOAT
74 #error illegal number of color channel bits
79 * Accumulation buffer data type:
82 typedef GLbyte GLaccum
;
84 typedef GLshort GLaccum
;
86 # error "illegal number of accumulation bits"
91 * Stencil buffer data type:
94 typedef GLubyte GLstencil
;
95 # define STENCIL_MAX 0xff
96 #elif STENCIL_BITS==16
97 typedef GLushort GLstencil
;
98 # define STENCIL_MAX 0xffff
100 # error "illegal number of stencil bits"
105 * Depth buffer data type:
107 typedef GLuint GLdepth
; /* Must be 32-bits! */
111 * Some forward type declarations
113 struct _mesa_HashTable
;
114 struct gl_texture_object
;
115 typedef struct gl_visual GLvisual
;
116 typedef struct gl_frame_buffer GLframebuffer
;
117 typedef struct __GLcontextRec GLcontext
;
121 /* Data structure for color tables */
122 struct gl_color_table
{
124 GLboolean FloatTable
; /* entries stored as floats? (or GLchan type) */
125 GLuint Size
; /* number of entries (rows) in table */
138 * Bit flags used for updating material values.
140 #define FRONT_AMBIENT_BIT 0x1
141 #define BACK_AMBIENT_BIT 0x2
142 #define FRONT_DIFFUSE_BIT 0x4
143 #define BACK_DIFFUSE_BIT 0x8
144 #define FRONT_SPECULAR_BIT 0x10
145 #define BACK_SPECULAR_BIT 0x20
146 #define FRONT_EMISSION_BIT 0x40
147 #define BACK_EMISSION_BIT 0x80
148 #define FRONT_SHININESS_BIT 0x100
149 #define BACK_SHININESS_BIT 0x200
150 #define FRONT_INDEXES_BIT 0x400
151 #define BACK_INDEXES_BIT 0x800
153 #define FRONT_MATERIAL_BITS (FRONT_EMISSION_BIT | FRONT_AMBIENT_BIT | \
154 FRONT_DIFFUSE_BIT | FRONT_SPECULAR_BIT | \
155 FRONT_SHININESS_BIT | FRONT_INDEXES_BIT)
157 #define BACK_MATERIAL_BITS (BACK_EMISSION_BIT | BACK_AMBIENT_BIT | \
158 BACK_DIFFUSE_BIT | BACK_SPECULAR_BIT | \
159 BACK_SHININESS_BIT | BACK_INDEXES_BIT)
161 #define ALL_MATERIAL_BITS (FRONT_MATERIAL_BITS | BACK_MATERIAL_BITS)
166 * Specular exponent and material shininess lookup table sizes:
168 #define EXP_TABLE_SIZE 512
169 #define SHINE_TABLE_SIZE 256
171 struct gl_shine_tab
{
172 struct gl_shine_tab
*next
, *prev
;
173 GLfloat tab
[SHINE_TABLE_SIZE
+1];
180 struct gl_light
*next
; /* double linked list with sentinel */
181 struct gl_light
*prev
;
183 GLfloat Ambient
[4]; /* ambient color */
184 GLfloat Diffuse
[4]; /* diffuse color */
185 GLfloat Specular
[4]; /* specular color */
186 GLfloat EyePosition
[4]; /* position in eye coordinates */
187 GLfloat EyeDirection
[4]; /* spotlight dir in eye coordinates */
188 GLfloat SpotExponent
;
189 GLfloat SpotCutoff
; /* in degress */
190 GLfloat _CosCutoff
; /* = MAX(0, cos(SpotCutoff)) */
191 GLfloat ConstantAttenuation
;
192 GLfloat LinearAttenuation
;
193 GLfloat QuadraticAttenuation
;
194 GLboolean Enabled
; /* On/off flag */
197 GLuint _Flags
; /* State */
199 GLfloat _Position
[4]; /* position in eye/obj coordinates */
200 GLfloat _VP_inf_norm
[3]; /* Norm direction to infinite light */
201 GLfloat _h_inf_norm
[3]; /* Norm( _VP_inf_norm + <0,0,1> ) */
202 GLfloat _NormDirection
[4]; /* normalized spotlight direction */
203 GLfloat _VP_inf_spot_attenuation
;
205 GLfloat _SpotExpTable
[EXP_TABLE_SIZE
][2]; /* to replace a pow() call */
206 GLfloat _MatAmbient
[2][3]; /* material ambient * light ambient */
207 GLfloat _MatDiffuse
[2][3]; /* material diffuse * light diffuse */
208 GLfloat _MatSpecular
[2][3]; /* material spec * light specular */
209 GLfloat _dli
; /* CI diffuse light intensity */
210 GLfloat _sli
; /* CI specular light intensity */
214 struct gl_lightmodel
{
215 GLfloat Ambient
[4]; /* ambient color */
216 GLboolean LocalViewer
; /* Local (or infinite) view point? */
217 GLboolean TwoSide
; /* Two (or one) sided lighting? */
218 GLenum ColorControl
; /* either GL_SINGLE_COLOR */
219 /* or GL_SEPARATE_SPECULAR_COLOR */
223 /* Move to using pointers to this struct in the immediate structs -
224 * this is too big to keep 94 unused copies (7K) lying around in
234 GLfloat AmbientIndex
; /* for color index lighting */
235 GLfloat DiffuseIndex
; /* for color index lighting */
236 GLfloat SpecularIndex
; /* for color index lighting */
244 * Attribute structures:
245 * We define a struct for each attribute group to make pushing and
246 * popping attributes easy. Also it's a good organization.
249 struct gl_accum_attrib
{
250 GLfloat ClearColor
[4]; /* Accumulation buffer clear color */
255 * Used in DrawDestMask below
257 #define FRONT_LEFT_BIT 1
258 #define FRONT_RIGHT_BIT 2
259 #define BACK_LEFT_BIT 4
260 #define BACK_RIGHT_BIT 8
263 struct gl_colorbuffer_attrib
{
264 GLuint ClearIndex
; /* Index to use for glClear */
265 GLfloat ClearColor
[4]; /* Color to use for glClear */
267 GLuint IndexMask
; /* Color index write mask */
268 GLubyte ColorMask
[4]; /* Each flag is 0xff or 0x0 */
270 GLenum DrawBuffer
; /* Which buffer to draw into */
271 GLenum DriverDrawBuffer
; /* Current device driver dest buffer */
272 GLboolean MultiDrawBuffer
; /* Drawing to mutliple buffers? */
273 GLubyte DrawDestMask
; /* bitwise-OR of bitflags above */
276 GLboolean AlphaEnabled
; /* Alpha test enabled flag */
277 GLenum AlphaFunc
; /* Alpha test function */
278 GLchan AlphaRef
; /* Alpha ref value as GLchan */
281 GLboolean BlendEnabled
; /* Blending enabled flag */
282 GLenum BlendSrcRGB
; /* Blending source operator */
283 GLenum BlendDstRGB
; /* Blending destination operator */
284 GLenum BlendSrcA
; /* GL_INGR_blend_func_separate */
285 GLenum BlendDstA
; /* GL_INGR_blend_func_separate */
286 GLenum BlendEquation
;
287 GLfloat BlendColor
[4];
290 GLenum LogicOp
; /* Logic operator */
291 GLboolean IndexLogicOpEnabled
; /* Color index logic op enabled flag */
292 GLboolean ColorLogicOpEnabled
; /* RGBA logic op enabled flag */
294 GLboolean DitherFlag
; /* Dither enable flag */
298 struct gl_current_attrib
{
299 /* These values valid only when FLUSH_TNL( FLUSH_UPDATE_CURRENT )
302 GLfloat Normal
[3]; /* Current vertex normal */
303 GLchan Color
[4]; /* Current RGBA color */
304 GLchan SecondaryColor
[4]; /* Current secondary color */
305 GLfloat FogCoord
; /* Current Fog coord */
306 GLuint Index
; /* Current color index */
307 GLboolean EdgeFlag
; /* Current edge flag */
308 GLfloat Texcoord
[MAX_TEXTURE_UNITS
][4]; /* Current texture coords */
310 /* These values are always valid.
312 GLfloat RasterPos
[4]; /* Current raster position */
313 GLfloat RasterDistance
; /* Current raster distance */
314 GLfloat RasterColor
[4]; /* Current raster color */
315 GLuint RasterIndex
; /* Current raster index */
316 GLfloat
*RasterTexCoord
; /* Current raster texcoord*/
317 GLfloat RasterMultiTexCoord
[MAX_TEXTURE_UNITS
][4];
318 GLboolean RasterPosValid
; /* Raster po valid flag */
322 struct gl_depthbuffer_attrib
{
323 GLenum Func
; /* Function for depth buffer compare */
324 GLfloat Clear
; /* Value to clear depth buffer to */
325 GLboolean Test
; /* Depth buffering enabled flag */
326 GLboolean Mask
; /* Depth buffer writable? */
327 GLboolean OcclusionTest
; /* GL_HP_occlusion_test */
331 struct gl_enable_attrib
{
333 GLboolean AutoNormal
;
335 GLboolean ClipPlane
[MAX_CLIP_PLANES
];
336 GLboolean ColorMaterial
;
337 GLboolean Convolution1D
;
338 GLboolean Convolution2D
;
339 GLboolean Separable2D
;
345 GLboolean Light
[MAX_LIGHTS
];
347 GLboolean LineSmooth
;
348 GLboolean LineStipple
;
349 GLboolean IndexLogicOp
;
350 GLboolean ColorLogicOp
;
351 GLboolean Map1Color4
;
353 GLboolean Map1Normal
;
354 GLboolean Map1TextureCoord1
;
355 GLboolean Map1TextureCoord2
;
356 GLboolean Map1TextureCoord3
;
357 GLboolean Map1TextureCoord4
;
358 GLboolean Map1Vertex3
;
359 GLboolean Map1Vertex4
;
360 GLboolean Map2Color4
;
362 GLboolean Map2Normal
;
363 GLboolean Map2TextureCoord1
;
364 GLboolean Map2TextureCoord2
;
365 GLboolean Map2TextureCoord3
;
366 GLboolean Map2TextureCoord4
;
367 GLboolean Map2Vertex3
;
368 GLboolean Map2Vertex4
;
371 GLboolean PixelTexture
;
372 GLboolean PointSmooth
;
373 GLboolean PolygonOffsetPoint
;
374 GLboolean PolygonOffsetLine
;
375 GLboolean PolygonOffsetFill
;
376 GLboolean PolygonSmooth
;
377 GLboolean PolygonStipple
;
378 GLboolean RescaleNormals
;
381 GLuint Texture
[MAX_TEXTURE_UNITS
];
382 GLuint TexGen
[MAX_TEXTURE_UNITS
];
386 struct gl_eval_attrib
{
388 GLboolean Map1Color4
;
390 GLboolean Map1Normal
;
391 GLboolean Map1TextureCoord1
;
392 GLboolean Map1TextureCoord2
;
393 GLboolean Map1TextureCoord3
;
394 GLboolean Map1TextureCoord4
;
395 GLboolean Map1Vertex3
;
396 GLboolean Map1Vertex4
;
397 GLboolean Map2Color4
;
399 GLboolean Map2Normal
;
400 GLboolean Map2TextureCoord1
;
401 GLboolean Map2TextureCoord2
;
402 GLboolean Map2TextureCoord3
;
403 GLboolean Map2TextureCoord4
;
404 GLboolean Map2Vertex3
;
405 GLboolean Map2Vertex4
;
406 GLboolean AutoNormal
;
407 /* Map Grid endpoints and divisions and calculated du values */
409 GLfloat MapGrid1u1
, MapGrid1u2
, MapGrid1du
;
410 GLint MapGrid2un
, MapGrid2vn
;
411 GLfloat MapGrid2u1
, MapGrid2u2
, MapGrid2du
;
412 GLfloat MapGrid2v1
, MapGrid2v2
, MapGrid2dv
;
416 struct gl_fog_attrib
{
417 GLboolean Enabled
; /* Fog enabled flag */
418 GLfloat Color
[4]; /* Fog color */
419 GLfloat Density
; /* Density >= 0.0 */
420 GLfloat Start
; /* Start distance in eye coords */
421 GLfloat End
; /* End distance in eye coords */
422 GLfloat Index
; /* Fog index */
423 GLenum Mode
; /* Fog mode */
424 GLboolean ColorSumEnabled
;
425 GLenum FogCoordinateSource
;
429 struct gl_hint_attrib
{
430 /* always one of GL_FASTEST, GL_NICEST, or GL_DONT_CARE */
431 GLenum PerspectiveCorrection
;
434 GLenum PolygonSmooth
;
437 /* GL_PGI_misc_hints */
441 GLenum StrictLighting
;
443 /* GL_EXT_clip_volume_hint */
444 GLenum ClipVolumeClipping
;
446 /* GL_ARB_texture_compression */
447 GLenum TextureCompression
;
451 struct gl_histogram_attrib
{
459 GLuint LuminanceSize
;
460 GLuint Count
[HISTOGRAM_TABLE_SIZE
][4];
464 struct gl_minmax_attrib
{
467 GLfloat Min
[4], Max
[4]; /* RGBA */
471 struct gl_convolution_attrib
{
473 GLenum InternalFormat
;
476 GLfloat Filter
[MAX_CONVOLUTION_WIDTH
* MAX_CONVOLUTION_HEIGHT
* 4];
480 struct gl_light_attrib
{
481 struct gl_light Light
[MAX_LIGHTS
]; /* Array of lights */
482 struct gl_lightmodel Model
; /* Lighting model */
483 struct gl_material Material
[2]; /* Material 0=front, 1=back */
484 GLboolean Enabled
; /* Lighting enabled flag */
485 GLenum ShadeModel
; /* GL_FLAT or GL_SMOOTH */
486 GLenum ColorMaterialFace
; /* GL_FRONT, BACK or FRONT_AND_BACK */
487 GLenum ColorMaterialMode
; /* GL_AMBIENT, GL_DIFFUSE, etc */
488 GLuint ColorMaterialBitmask
; /* bitmask formed from Face and Mode */
489 GLboolean ColorMaterialEnabled
;
491 struct gl_light EnabledList
; /* List sentinel */
493 /* Derived for optimizations: */
494 GLboolean _NeedVertices
; /* Use fast shader? */
495 GLuint _Flags
; /* State, see below */
496 GLfloat _BaseColor
[2][3];
497 GLchan _BaseAlpha
[2];
501 #define LIGHT_POSITIONAL 0x4
502 #define LIGHT_SPOT 0x10
503 #define LIGHT_LOCAL_VIEWER 0x20
505 #define LIGHT_NEED_VERTICES (LIGHT_POSITIONAL|LIGHT_LOCAL_VIEWER)
507 struct gl_line_attrib
{
508 GLboolean SmoothFlag
; /* GL_LINE_SMOOTH enabled? */
509 GLboolean StippleFlag
; /* GL_LINE_STIPPLE enabled? */
510 GLushort StipplePattern
; /* Stipple pattern */
511 GLint StippleFactor
; /* Stipple repeat factor */
512 GLfloat Width
; /* Line width */
516 struct gl_list_attrib
{
520 struct gl_list_opcode
{
522 void (*execute
)( GLcontext
*ctx
, void *data
);
523 void (*destroy
)( GLcontext
*ctx
, void *data
);
524 void (*print
)( GLcontext
*ctx
, void *data
);
527 #define GL_MAX_EXT_OPCODES 16
529 struct gl_list_extensions
{
530 struct gl_list_opcode opcode
[GL_MAX_EXT_OPCODES
];
534 struct gl_pixel_attrib
{
535 GLenum ReadBuffer
; /* src buffer for glRead/CopyPixels */
536 GLenum DriverReadBuffer
; /* Driver's current source buffer */
537 GLfloat RedBias
, RedScale
;
538 GLfloat GreenBias
, GreenScale
;
539 GLfloat BlueBias
, BlueScale
;
540 GLfloat AlphaBias
, AlphaScale
;
541 GLfloat DepthBias
, DepthScale
;
542 GLint IndexShift
, IndexOffset
;
543 GLboolean MapColorFlag
;
544 GLboolean MapStencilFlag
;
545 GLfloat ZoomX
, ZoomY
;
546 GLint MapStoSsize
; /* Size of each pixel map */
556 GLint MapStoS
[MAX_PIXEL_MAP_TABLE
]; /* Pixel map tables */
557 GLint MapItoI
[MAX_PIXEL_MAP_TABLE
];
558 GLfloat MapItoR
[MAX_PIXEL_MAP_TABLE
];
559 GLfloat MapItoG
[MAX_PIXEL_MAP_TABLE
];
560 GLfloat MapItoB
[MAX_PIXEL_MAP_TABLE
];
561 GLfloat MapItoA
[MAX_PIXEL_MAP_TABLE
];
562 GLubyte MapItoR8
[MAX_PIXEL_MAP_TABLE
]; /* converted to 8-bit color */
563 GLubyte MapItoG8
[MAX_PIXEL_MAP_TABLE
];
564 GLubyte MapItoB8
[MAX_PIXEL_MAP_TABLE
];
565 GLubyte MapItoA8
[MAX_PIXEL_MAP_TABLE
];
566 GLfloat MapRtoR
[MAX_PIXEL_MAP_TABLE
];
567 GLfloat MapGtoG
[MAX_PIXEL_MAP_TABLE
];
568 GLfloat MapBtoB
[MAX_PIXEL_MAP_TABLE
];
569 GLfloat MapAtoA
[MAX_PIXEL_MAP_TABLE
];
570 /* GL_EXT_histogram */
571 GLboolean HistogramEnabled
;
572 GLboolean MinMaxEnabled
;
573 /* GL_SGIS_pixel_texture */
574 GLboolean PixelTextureEnabled
;
575 GLenum FragmentRgbSource
;
576 GLenum FragmentAlphaSource
;
577 /* GL_SGI_color_matrix */
578 GLfloat PostColorMatrixScale
[4]; /* RGBA */
579 GLfloat PostColorMatrixBias
[4]; /* RGBA */
580 /* GL_SGI_color_table */
581 GLfloat ColorTableScale
[4];
582 GLfloat ColorTableBias
[4];
583 GLboolean ColorTableEnabled
;
584 GLfloat PCCTscale
[4];
586 GLboolean PostConvolutionColorTableEnabled
;
587 GLfloat PCMCTscale
[4];
588 GLfloat PCMCTbias
[4];
589 GLboolean PostColorMatrixColorTableEnabled
;
591 GLboolean Convolution1DEnabled
;
592 GLboolean Convolution2DEnabled
;
593 GLboolean Separable2DEnabled
;
594 GLfloat ConvolutionBorderColor
[3][4];
595 GLenum ConvolutionBorderMode
[3];
596 GLfloat ConvolutionFilterScale
[3][4];
597 GLfloat ConvolutionFilterBias
[3][4];
598 GLfloat PostConvolutionScale
[4]; /* RGBA */
599 GLfloat PostConvolutionBias
[4]; /* RGBA */
603 struct gl_point_attrib
{
604 GLboolean SmoothFlag
; /* True if GL_POINT_SMOOTH is enabled */
605 GLboolean SpriteMode
; /* GL_MESA_sprite_point extension */
606 GLfloat Size
; /* User-specified point size */
607 GLfloat _Size
; /* Size clamped to Const.Min/MaxPointSize */
608 GLfloat Params
[3]; /* GL_EXT_point_parameters */
609 GLfloat MinSize
, MaxSize
; /* GL_EXT_point_parameters */
610 GLfloat Threshold
; /* GL_EXT_point_parameters */
611 GLboolean _Attenuated
; /* True if Params != [1, 0, 0] */
615 struct gl_polygon_attrib
{
616 GLenum FrontFace
; /* Either GL_CW or GL_CCW */
617 GLenum FrontMode
; /* Either GL_POINT, GL_LINE or GL_FILL */
618 GLenum BackMode
; /* Either GL_POINT, GL_LINE or GL_FILL */
619 GLboolean FrontBit
; /* */
620 GLboolean _Unfilled
; /* True if back or front mode is not GL_FILL */
621 GLboolean CullFlag
; /* Culling on/off flag */
622 GLubyte _CullBits
; /* Used for cull testing */
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)
684 /* Bitmap versions of the GL_ constants.
686 #define TEXGEN_SPHERE_MAP 0x1
687 #define TEXGEN_OBJ_LINEAR 0x2
688 #define TEXGEN_EYE_LINEAR 0x4
689 #define TEXGEN_REFLECTION_MAP_NV 0x8
690 #define TEXGEN_NORMAL_MAP_NV 0x10
692 #define TEXGEN_NEED_M (TEXGEN_SPHERE_MAP)
693 #define TEXGEN_NEED_F (TEXGEN_SPHERE_MAP | \
694 TEXGEN_REFLECTION_MAP_NV)
695 #define TEXGEN_NEED_NORMALS (TEXGEN_SPHERE_MAP | \
696 TEXGEN_REFLECTION_MAP_NV | \
697 TEXGEN_NORMAL_MAP_NV)
698 #define TEXGEN_NEED_VERTICES (TEXGEN_OBJ_LINEAR | \
699 TEXGEN_EYE_LINEAR | \
700 TEXGEN_REFLECTION_MAP_NV | \
702 #define TEXGEN_NEED_EYE_COORD (TEXGEN_SPHERE_MAP | \
703 TEXGEN_REFLECTION_MAP_NV | \
704 TEXGEN_NORMAL_MAP_NV | \
709 /* A selection of state flags to make driver and module's lives easier.
711 #define ENABLE_TEX0 0x000f /* TEXTURE0_ANY */
712 #define ENABLE_TEX1 0x00f0 /* TEXTURE1_ANY */
713 #define ENABLE_TEX2 0x0f00 /* TEXTURE2_ANY */
714 #define ENABLE_TEX3 0xf000 /* TEXTURE3_ANY */
715 #define ENABLE_TEXGEN0 0x10000
716 #define ENABLE_TEXGEN1 0x20000
717 #define ENABLE_TEXGEN2 0x40000
718 #define ENABLE_TEXGEN3 0x80000
719 #define ENABLE_TEXMAT0 0x100000 /* Ie. not the identity matrix */
720 #define ENABLE_TEXMAT1 0x200000
721 #define ENABLE_TEXMAT2 0x400000
722 #define ENABLE_TEXMAT3 0x800000
723 #define ENABLE_LIGHT 0x1000000
724 #define ENABLE_FOG 0x2000000
725 #define ENABLE_USERCLIP 0x4000000
726 #define ENABLE_NORMALIZE 0x10000000
727 #define ENABLE_RESCALE 0x20000000
728 #define ENABLE_POINT_ATTEN 0x40000000
731 #define ENABLE_TEX_ANY (ENABLE_TEX0 | ENABLE_TEX1 | \
732 ENABLE_TEX2 | ENABLE_TEX3)
733 #define ENABLE_TEXGEN_ANY (ENABLE_TEXGEN0 | ENABLE_TEXGEN1 | \
734 ENABLE_TEXGEN2 | ENABLE_TEXGEN3)
735 #define ENABLE_TEXMAT_ANY (ENABLE_TEXMAT0 | ENABLE_TEXMAT1 | \
736 ENABLE_TEXMAT2 | ENABLE_TEXMAT3)
739 /* Texture image record */
740 struct gl_texture_image
{
741 GLenum Format
; /* GL_ALPHA, GL_LUMINANCE, GL_LUMINANCE_ALPHA,
742 * GL_INTENSITY, GL_RGB, GL_RGBA, or
743 * GL_COLOR_INDEX only
745 GLenum IntFormat
; /* Internal format as given by the user */
746 GLubyte RedBits
; /* Bits per texel component */
747 GLubyte GreenBits
; /* These are initialized by Mesa but */
748 GLubyte BlueBits
; /* may be reassigned by the device */
749 GLubyte AlphaBits
; /* driver to indicate the true texture */
750 GLubyte IntensityBits
; /* color resolution. */
751 GLubyte LuminanceBits
;
753 GLuint Border
; /* 0 or 1 */
754 GLuint Width
; /* = 2^WidthLog2 + 2*Border */
755 GLuint Height
; /* = 2^HeightLog2 + 2*Border */
756 GLuint Depth
; /* = 2^DepthLog2 + 2*Border */
757 GLuint Width2
; /* = Width - 2*Border */
758 GLuint Height2
; /* = Height - 2*Border */
759 GLuint Depth2
; /* = Depth - 2*Border */
760 GLuint WidthLog2
; /* = log2(Width2) */
761 GLuint HeightLog2
; /* = log2(Height2) */
762 GLuint DepthLog2
; /* = log2(Depth2) */
763 GLuint MaxLog2
; /* = MAX(WidthLog2, HeightLog2) */
764 GLchan
*Data
; /* Image data as GLchan's */
766 GLboolean IsCompressed
; /* GL_ARB_texture_compression */
767 GLuint CompressedSize
; /* GL_ARB_texture_compression */
769 /* For device driver: */
770 void *DriverData
; /* Arbitrary device driver data */
774 /* Texture object record */
775 struct gl_texture_object
{
776 _glthread_Mutex Mutex
; /* for thread safety */
777 GLint RefCount
; /* reference count */
778 GLuint Name
; /* an unsigned integer */
779 GLuint Dimensions
; /* 1 or 2 or 3 */
780 GLfloat Priority
; /* in [0,1] */
781 GLchan BorderColor
[4]; /* as integers */
782 GLenum WrapS
; /* GL_CLAMP, REPEAT or CLAMP_TO_EDGE */
783 GLenum WrapT
; /* GL_CLAMP, REPEAT or CLAMP_TO_EDGE */
784 GLenum WrapR
; /* GL_CLAMP, REPEAT or CLAMP_TO_EDGE */
785 GLenum MinFilter
; /* minification filter */
786 GLenum MagFilter
; /* magnification filter */
787 GLfloat MinLod
; /* OpenGL 1.2 */
788 GLfloat MaxLod
; /* OpenGL 1.2 */
789 GLint BaseLevel
; /* OpenGL 1.2 */
790 GLint MaxLevel
; /* OpenGL 1.2 */
791 GLint _P
; /* Highest mipmap level */
792 GLfloat _M
; /* = MIN(MaxLevel, P) - BaseLevel */
793 struct gl_texture_image
*Image
[MAX_TEXTURE_LEVELS
];
795 /* Texture cube faces */
796 /* Image[] is alias for *PosX[MAX_TEXTURE_LEVELS]; */
797 struct gl_texture_image
*NegX
[MAX_TEXTURE_LEVELS
];
798 struct gl_texture_image
*PosY
[MAX_TEXTURE_LEVELS
];
799 struct gl_texture_image
*NegY
[MAX_TEXTURE_LEVELS
];
800 struct gl_texture_image
*PosZ
[MAX_TEXTURE_LEVELS
];
801 struct gl_texture_image
*NegZ
[MAX_TEXTURE_LEVELS
];
803 /* GL_EXT_paletted_texture */
804 struct gl_color_table Palette
;
806 GLboolean Complete
; /* Is texture object complete? */
807 struct gl_texture_object
*Next
; /* Next in linked list */
809 /* For device driver: */
810 void *DriverData
; /* Arbitrary device driver data */
816 * Texture units are new with the multitexture extension.
818 struct gl_texture_unit
{
819 GLuint Enabled
; /* bitmask of TEXTURE0_1D, _2D, _3D, _CUBE */
820 GLuint _ReallyEnabled
; /* 0 or one of TEXTURE0_1D, _2D, _3D, _CUBE */
822 GLenum EnvMode
; /* GL_MODULATE, GL_DECAL, GL_BLEND, etc. */
824 GLuint TexGenEnabled
; /* Bitwise-OR of [STRQ]_BIT values */
825 GLenum GenModeS
; /* Tex coord generation mode, either */
826 GLenum GenModeT
; /* GL_OBJECT_LINEAR, or */
827 GLenum GenModeR
; /* GL_EYE_LINEAR, or */
828 GLenum GenModeQ
; /* GL_SPHERE_MAP */
833 GLuint _GenFlags
; /* bitwise or of GenBit[STRQ] */
834 GLfloat ObjectPlaneS
[4];
835 GLfloat ObjectPlaneT
[4];
836 GLfloat ObjectPlaneR
[4];
837 GLfloat ObjectPlaneQ
[4];
838 GLfloat EyePlaneS
[4];
839 GLfloat EyePlaneT
[4];
840 GLfloat EyePlaneR
[4];
841 GLfloat EyePlaneQ
[4];
842 GLfloat LodBias
; /* for biasing mipmap levels */
844 /* GL_EXT_texture_env_combine */
845 GLenum CombineModeRGB
; /* GL_REPLACE, GL_DECAL, GL_ADD, etc. */
846 GLenum CombineModeA
; /* GL_REPLACE, GL_DECAL, GL_ADD, etc. */
847 GLenum CombineSourceRGB
[3]; /* GL_PRIMARY_COLOR, GL_TEXTURE, etc. */
848 GLenum CombineSourceA
[3]; /* GL_PRIMARY_COLOR, GL_TEXTURE, etc. */
849 GLenum CombineOperandRGB
[3]; /* SRC_COLOR, ONE_MINUS_SRC_COLOR, etc */
850 GLenum CombineOperandA
[3]; /* SRC_ALPHA, ONE_MINUS_SRC_ALPHA, etc */
851 GLuint CombineScaleShiftRGB
; /* 0, 1 or 2 */
852 GLuint CombineScaleShiftA
; /* 0, 1 or 2 */
854 struct gl_texture_object
*Current1D
;
855 struct gl_texture_object
*Current2D
;
856 struct gl_texture_object
*Current3D
;
857 struct gl_texture_object
*CurrentCubeMap
; /* GL_ARB_texture_cube_map */
859 struct gl_texture_object
*_Current
; /* Points to really enabled tex obj */
861 struct gl_texture_object Saved1D
; /* only used by glPush/PopAttrib */
862 struct gl_texture_object Saved2D
;
863 struct gl_texture_object Saved3D
;
864 struct gl_texture_object SavedCubeMap
;
868 struct gl_texture_attrib
{
870 GLuint CurrentUnit
; /* Active texture unit */
871 GLuint CurrentTransformUnit
; /* Client active texture xform unit */
873 GLuint _ReallyEnabled
; /* enables for all texture units: */
874 /* = (Unit[0]._ReallyEnabled << 0) | */
875 /* (Unit[1]._ReallyEnabled << 4) | */
876 /* (Unit[2]._ReallyEnabled << 8) | etc... */
877 GLuint _GenFlags
; /* for texgen */
879 struct gl_texture_unit Unit
[MAX_TEXTURE_UNITS
];
881 struct gl_texture_object
*Proxy1D
;
882 struct gl_texture_object
*Proxy2D
;
883 struct gl_texture_object
*Proxy3D
;
884 struct gl_texture_object
*ProxyCubeMap
;
886 /* GL_EXT_shared_texture_palette */
887 GLboolean SharedPalette
;
888 struct gl_color_table Palette
;
893 /* KW: Renamed ClipEquation to avoid having 'ClipClipEquation'
895 struct gl_transform_attrib
{
896 GLenum MatrixMode
; /* Matrix mode */
897 GLfloat EyeUserPlane
[MAX_CLIP_PLANES
][4];
898 GLfloat _ClipUserPlane
[MAX_CLIP_PLANES
][4]; /* derived */
899 GLboolean ClipEnabled
[MAX_CLIP_PLANES
];
900 GLubyte _AnyClip
; /* How many ClipEnabled? */
901 GLboolean Normalize
; /* Normalize all normals? */
902 GLboolean RescaleNormals
; /* GL_EXT_rescale_normal */
906 struct gl_viewport_attrib
{
907 GLint X
, Y
; /* position */
908 GLsizei Width
, Height
; /* size */
909 GLfloat Near
, Far
; /* Depth buffer range */
910 GLmatrix _WindowMap
; /* Mapping transformation as a matrix. */
914 /* For the attribute stack: */
915 struct gl_attrib_node
{
918 struct gl_attrib_node
*next
;
924 * Client pixel packing/unpacking attributes
926 struct gl_pixelstore_attrib
{
931 GLint ImageHeight
; /* for GL_EXT_texture3D */
932 GLint SkipImages
; /* for GL_EXT_texture3D */
939 * Client vertex array attributes
941 struct gl_client_array
{
944 GLsizei Stride
; /* user-specified stride */
945 GLsizei StrideB
; /* actual stride in bytes */
953 struct gl_array_attrib
{
954 struct gl_client_array Vertex
; /* client data descriptors */
955 struct gl_client_array Normal
;
956 struct gl_client_array Color
;
957 struct gl_client_array SecondaryColor
;
958 struct gl_client_array FogCoord
;
959 struct gl_client_array Index
;
960 struct gl_client_array TexCoord
[MAX_TEXTURE_UNITS
];
961 struct gl_client_array EdgeFlag
;
963 trans_4f_func _VertexFunc
; /* conversion functions */
964 trans_3f_func _NormalFunc
;
965 trans_4ub_func _ColorFunc
;
966 trans_1ui_func _IndexFunc
;
967 trans_1f_func _FogCoordFunc
;
968 trans_4ub_func _SecondaryColorFunc
;
969 trans_4f_func _TexCoordFunc
[MAX_TEXTURE_UNITS
];
970 trans_1ub_func _EdgeFlagFunc
;
972 GLint TexCoordInterleaveFactor
;
973 GLint ActiveTexture
; /* Client Active Texture */
992 struct gl_selection
{
994 GLuint BufferSize
; /* size of SelectBuffer */
995 GLuint BufferCount
; /* number of values in SelectBuffer */
996 GLuint Hits
; /* number of records in SelectBuffer */
997 GLuint NameStackDepth
;
998 GLuint NameStack
[MAX_NAME_STACK_DEPTH
];
1000 GLfloat HitMinZ
, HitMaxZ
;
1006 * 1-D Evaluator control points
1009 GLuint Order
; /* Number of control points */
1010 GLfloat u1
, u2
, du
; /* u1, u2, 1.0/(u2-u1) */
1011 GLfloat
*Points
; /* Points to contiguous control points */
1016 * 2-D Evaluator control points
1019 GLuint Uorder
; /* Number of control points in U dimension */
1020 GLuint Vorder
; /* Number of control points in V dimension */
1023 GLfloat
*Points
; /* Points to contiguous control points */
1028 * All evalutator control points
1030 struct gl_evaluators
{
1032 struct gl_1d_map Map1Vertex3
;
1033 struct gl_1d_map Map1Vertex4
;
1034 struct gl_1d_map Map1Index
;
1035 struct gl_1d_map Map1Color4
;
1036 struct gl_1d_map Map1Normal
;
1037 struct gl_1d_map Map1Texture1
;
1038 struct gl_1d_map Map1Texture2
;
1039 struct gl_1d_map Map1Texture3
;
1040 struct gl_1d_map Map1Texture4
;
1043 struct gl_2d_map Map2Vertex3
;
1044 struct gl_2d_map Map2Vertex4
;
1045 struct gl_2d_map Map2Index
;
1046 struct gl_2d_map Map2Color4
;
1047 struct gl_2d_map Map2Normal
;
1048 struct gl_2d_map Map2Texture1
;
1049 struct gl_2d_map Map2Texture2
;
1050 struct gl_2d_map Map2Texture3
;
1051 struct gl_2d_map Map2Texture4
;
1057 * State which can be shared by multiple contexts:
1059 struct gl_shared_state
{
1060 _glthread_Mutex Mutex
; /* for thread safety */
1061 GLint RefCount
; /* Reference count */
1062 struct _mesa_HashTable
*DisplayList
; /* Display lists hash table */
1063 struct _mesa_HashTable
*TexObjects
; /* Texture objects hash table */
1064 struct gl_texture_object
*TexObjectList
;/* Linked list of texture objects */
1066 /* Default texture objects (shared by all multi-texture units) */
1067 struct gl_texture_object
*Default1D
;
1068 struct gl_texture_object
*Default2D
;
1069 struct gl_texture_object
*Default3D
;
1070 struct gl_texture_object
*DefaultCubeMap
;
1072 void *DriverData
; /* Device driver shared state */
1078 * Describes the color, depth, stencil and accum buffer parameters.
1079 * In C++ terms, think of this as a base class from which device drivers
1080 * will make derived classes.
1083 GLboolean RGBAflag
; /* Is frame buffer in RGBA mode, not CI? */
1084 GLboolean DBflag
; /* Is color buffer double buffered? */
1085 GLboolean StereoFlag
; /* stereo buffer? */
1087 GLint RedBits
; /* Bits per color component */
1092 GLint IndexBits
; /* Bits/pixel if in color index mode */
1094 GLint AccumRedBits
; /* Number of bits in red accum channel */
1095 GLint AccumGreenBits
; /* Number of bits in green accum channel */
1096 GLint AccumBlueBits
; /* Number of bits in blue accum channel */
1097 GLint AccumAlphaBits
; /* Number of bits in alpha accum channel */
1098 GLint DepthBits
; /* Number of bits in depth buffer, or 0 */
1099 GLint StencilBits
; /* Number of bits in stencil buffer, or 0 */
1100 GLint NumSamples
; /* Samples/pixel for multisampling */
1102 GLuint DepthMax
; /* Max depth buffer value */
1103 GLfloat DepthMaxF
; /* Float max depth buffer value */
1104 GLfloat MRD
; /* minimum resolvable difference in Z values */
1110 * A "frame buffer" is a color buffer and its optional ancillary buffers:
1111 * depth, accum, stencil, and software-simulated alpha buffers.
1112 * In C++ terms, think of this as a base class from which device drivers
1113 * will make derived classes.
1115 struct gl_frame_buffer
{
1116 GLvisual
*Visual
; /* The corresponding visual */
1118 GLint Width
, Height
; /* size of frame buffer in pixels */
1120 GLboolean UseSoftwareDepthBuffer
;
1121 GLboolean UseSoftwareAccumBuffer
;
1122 GLboolean UseSoftwareStencilBuffer
;
1123 GLboolean UseSoftwareAlphaBuffers
;
1125 /* Software depth (aka Z) buffer */
1126 GLvoid
*DepthBuffer
; /* array [Width*Height] of GLushort or GLuint*/
1128 /* Software stencil buffer */
1129 GLstencil
*Stencil
; /* array [Width*Height] of GLstencil values */
1131 /* Software accumulation buffer */
1132 GLaccum
*Accum
; /* array [4*Width*Height] of GLaccum values */
1134 /* Software alpha planes */
1135 GLchan
*FrontLeftAlpha
; /* array [Width*Height] of GLubyte */
1136 GLchan
*BackLeftAlpha
; /* array [Width*Height] of GLubyte */
1137 GLchan
*FrontRightAlpha
; /* array [Width*Height] of GLubyte */
1138 GLchan
*BackRightAlpha
; /* array [Width*Height] of GLubyte */
1139 GLchan
*Alpha
; /* Points to current alpha buffer */
1141 /* Drawing bounds: intersection of window size and scissor box */
1142 GLint _Xmin
, _Ymin
; /* inclusive */
1143 GLint _Xmax
, _Ymax
; /* exclusive */
1148 * Constants which may be overriden by device driver.
1150 struct gl_constants
{
1151 GLint MaxTextureSize
;
1152 GLint MaxCubeTextureSize
;
1153 GLint MaxTextureLevels
;
1154 GLuint MaxTextureUnits
;
1155 GLuint MaxArrayLockSize
;
1157 GLfloat MinPointSize
, MaxPointSize
; /* aliased */
1158 GLfloat MinPointSizeAA
, MaxPointSizeAA
; /* antialiased */
1159 GLfloat PointSizeGranularity
;
1160 GLfloat MinLineWidth
, MaxLineWidth
; /* aliased */
1161 GLfloat MinLineWidthAA
, MaxLineWidthAA
; /* antialiased */
1162 GLfloat LineWidthGranularity
;
1163 GLuint NumAuxBuffers
;
1164 GLuint MaxColorTableSize
;
1165 GLuint MaxConvolutionWidth
;
1166 GLuint MaxConvolutionHeight
;
1167 GLuint NumCompressedTextureFormats
; /* GL_ARB_texture_compression */
1168 GLenum CompressedTextureFormats
[MAX_COMPRESSED_TEXTURE_FORMATS
];
1169 GLuint MaxClipPlanes
;
1175 * List of extensions.
1178 struct gl_extensions
{
1180 struct extension
*ext_list
;
1181 /* Flags to quickly test if certain extensions are available.
1182 * Not every extension needs to have such a flag, but it's encouraged.
1184 GLboolean ARB_imaging
;
1185 GLboolean ARB_multitexture
;
1186 GLboolean ARB_texture_compression
;
1187 GLboolean ARB_texture_cube_map
;
1188 GLboolean ARB_texture_env_add
;
1189 GLboolean EXT_blend_color
;
1190 GLboolean EXT_blend_func_separate
;
1191 GLboolean EXT_blend_logic_op
;
1192 GLboolean EXT_blend_minmax
;
1193 GLboolean EXT_blend_subtract
;
1194 GLboolean EXT_clip_volume_hint
;
1195 GLboolean EXT_convolution
;
1196 GLboolean EXT_compiled_vertex_array
;
1197 GLboolean EXT_fog_coord
;
1198 GLboolean EXT_histogram
;
1199 GLboolean EXT_packed_pixels
;
1200 GLboolean EXT_paletted_texture
;
1201 GLboolean EXT_point_parameters
;
1202 GLboolean EXT_polygon_offset
;
1203 GLboolean EXT_rescale_normal
;
1204 GLboolean EXT_secondary_color
;
1205 GLboolean EXT_shared_texture_palette
;
1206 GLboolean EXT_stencil_wrap
;
1207 GLboolean EXT_texture3D
;
1208 GLboolean EXT_texture_compression_s3tc
;
1209 GLboolean EXT_texture_env_add
;
1210 GLboolean EXT_texture_env_combine
;
1211 GLboolean EXT_texture_object
;
1212 GLboolean EXT_texture_lod_bias
;
1213 GLboolean EXT_vertex_array_set
;
1214 GLboolean HP_occlusion_test
;
1215 GLboolean INGR_blend_func_separate
;
1216 GLboolean MESA_window_pos
;
1217 GLboolean MESA_resize_buffers
;
1218 GLboolean MESA_sprite_point
;
1219 GLboolean NV_blend_square
;
1220 GLboolean NV_texgen_reflection
;
1221 GLboolean PGI_misc_hints
;
1222 GLboolean SGI_color_matrix
;
1223 GLboolean SGI_color_table
;
1224 GLboolean SGIS_pixel_texture
;
1225 GLboolean SGIS_texture_edge_clamp
;
1226 GLboolean SGIX_pixel_texture
;
1227 GLboolean _3DFX_texture_compression_FXT1
;
1233 * Bits for image transfer operations (ctx->ImageTransferState).
1235 #define IMAGE_SCALE_BIAS_BIT 0x1
1236 #define IMAGE_SHIFT_OFFSET_BIT 0x2
1237 #define IMAGE_MAP_COLOR_BIT 0x4
1238 #define IMAGE_COLOR_TABLE_BIT 0x8
1239 #define IMAGE_CONVOLUTION_BIT 0x10
1240 #define IMAGE_POST_CONVOLUTION_SCALE_BIAS 0x20
1241 #define IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT 0x40
1242 #define IMAGE_COLOR_MATRIX_BIT 0x80
1243 #define IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT 0x100
1244 #define IMAGE_HISTOGRAM_BIT 0x200
1245 #define IMAGE_MIN_MAX_BIT 0x400
1247 /* transfer ops up to convolution: */
1248 #define IMAGE_PRE_CONVOLUTION_BITS (IMAGE_SCALE_BIAS_BIT | \
1249 IMAGE_SHIFT_OFFSET_BIT | \
1250 IMAGE_MAP_COLOR_BIT | \
1251 IMAGE_COLOR_TABLE_BIT)
1253 /* transfer ops after convolution: */
1254 #define IMAGE_POST_CONVOLUTION_BITS (IMAGE_POST_CONVOLUTION_SCALE_BIAS | \
1255 IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT | \
1256 IMAGE_COLOR_MATRIX_BIT | \
1257 IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT |\
1258 IMAGE_HISTOGRAM_BIT | \
1263 * Bits to indicate what state has changed.
1265 #define _NEW_MODELVIEW 0x1 /* ctx->ModelView */
1266 #define _NEW_PROJECTION 0x2 /* ctx->Projection */
1267 #define _NEW_TEXTURE_MATRIX 0x4 /* ctx->TextureMatrix */
1268 #define _NEW_COLOR_MATRIX 0x8 /* ctx->ColorMatrix */
1269 #define _NEW_ACCUM 0x10 /* ctx->Accum */
1270 #define _NEW_COLOR 0x20 /* ctx->Color */
1271 #define _NEW_DEPTH 0x40 /* ctx->Depth */
1272 #define _NEW_EVAL 0x80 /* ctx->Eval, ctx->EvalMap */
1273 #define _NEW_FOG 0x100 /* ctx->Fog */
1274 #define _NEW_HINT 0x200 /* ctx->Hint */
1275 #define _NEW_400 0x400 /* unused */
1276 #define _NEW_LIGHT 0x800 /* ctx->Light */
1277 #define _NEW_1000 0x1000 /* unused */
1278 #define _NEW_LINE 0x2000 /* ctx->Line */
1279 #define _NEW_FEEDBACK_SELECT 0x4000 /* ctx->Feedback, ctx->Select */
1280 #define _NEW_PIXEL 0x8000 /* ctx->Pixel */
1281 #define _NEW_POINT 0x10000 /* ctx->Point */
1282 #define _NEW_POLYGON 0x20000 /* ctx->Polygon */
1283 #define _NEW_POLYGONSTIPPLE 0x40000 /* ctx->PolygonStipple */
1284 #define _NEW_SCISSOR 0x80000 /* ctx->Scissor */
1285 #define _NEW_STENCIL 0x100000 /* ctx->Stencil */
1286 #define _NEW_TEXTURE 0x200000 /* ctx->Texture */
1287 #define _NEW_TRANSFORM 0x400000 /* ctx->Transform */
1288 #define _NEW_VIEWPORT 0x800000 /* ctx->Viewport */
1289 #define _NEW_PACKUNPACK 0x1000000 /* ctx->Pack, ctx->Unpack */
1290 #define _NEW_ARRAY 0x2000000 /* ctx->Array */
1291 #define _NEW_COLORTABLE 0x4000000 /* ctx->{*}ColorTable */
1292 #define _NEW_RENDERMODE 0x8000000 /* ctx->RenderMode */
1293 #define _NEW_BUFFERS 0x10000000 /* ctx->Visual, ctx->DrawBuffer, */
1299 /* What can the driver do, what requires us to call render_triangle or
1300 * a non-driver rasterize function?
1302 #define DD_FEEDBACK 0x1
1303 #define DD_SELECT 0x2
1304 #define DD_FLATSHADE 0x4
1305 #define DD_MULTIDRAW 0x8
1306 #define DD_SEPERATE_SPECULAR 0x10
1307 #define DD_TRI_LIGHT_TWOSIDE 0x20
1308 #define DD_TRI_UNFILLED 0x40
1309 #define DD_TRI_SMOOTH 0x80
1310 #define DD_TRI_STIPPLE 0x100
1311 #define DD_TRI_OFFSET 0x200
1312 #define DD_TRI_CULL 0x400
1313 #define DD_LINE_SMOOTH 0x800
1314 #define DD_LINE_STIPPLE 0x1000
1315 #define DD_LINE_WIDTH 0x2000
1316 #define DD_POINT_SMOOTH 0x4000
1317 #define DD_POINT_SIZE 0x8000
1318 #define DD_POINT_ATTEN 0x10000
1319 #define DD_LIGHTING_CULL 0x20000
1320 #define DD_TRI_CULL_FRONT_BACK 0x400000 /* not supported by most drivers */
1321 #define DD_Z_NEVER 0x800000
1322 #define DD_STENCIL 0x1000000
1324 /* Define the state changes under which each of these bits might change
1326 #define _DD_NEW_FEEDBACK _NEW_RENDERMODE
1327 #define _DD_NEW_SELECT _NEW_RENDERMODE
1328 #define _DD_NEW_FLATSHADE _NEW_LIGHT
1329 #define _DD_NEW_MULTIDRAW _NEW_COLOR
1330 #define _DD_NEW_SEPERATE_SPECULAR (_NEW_LIGHT|_NEW_FOG)
1331 #define _DD_NEW_TRI_LIGHT_TWOSIDE _NEW_LIGHT
1332 #define _DD_NEW_TRI_UNFILLED _NEW_POLYGON
1333 #define _DD_NEW_TRI_SMOOTH _NEW_POLYGON
1334 #define _DD_NEW_TRI_STIPPLE _NEW_POLYGON
1335 #define _DD_NEW_TRI_OFFSET _NEW_POLYGON
1336 #define _DD_NEW_TRI_CULL _NEW_POLYGON
1337 #define _DD_NEW_LINE_SMOOTH _NEW_LINE
1338 #define _DD_NEW_LINE_STIPPLE _NEW_LINE
1339 #define _DD_NEW_LINE_WIDTH _NEW_LINE
1340 #define _DD_NEW_POINT_SMOOTH _NEW_POINT
1341 #define _DD_NEW_POINT_SIZE _NEW_POINT
1342 #define _DD_NEW_POINT_ATTEN _NEW_POINT
1343 #define _DD_NEW_LIGHTING_CULL _NEW_LIGHT
1344 #define _DD_NEW_TRI_CULL_FRONT_BACK _NEW_POLYGON
1345 #define _DD_NEW_Z_NEVER _NEW_DEPTH
1346 #define _DD_NEW_STENCIL _NEW_STENCIL
1348 #define _TNL_NEW_RENDERFLAGS (_NEW_TEXTURE | \
1349 _DD_NEW_SEPERATE_SPECULAR | \
1354 #define _TNL_NEW_NEED_EYE_COORDS (_NEW_LIGHT| \
1359 #define _TNL_NEW_NEED_NORMALS (_NEW_LIGHT| \
1362 #define _TNL_NEW_NORMAL_TRANSFORM (_NEW_MODELVIEW|_NEW_TRANSFORM| \
1363 _TNL_NEW_NEED_NORMALS)
1365 #define _TNL_NEW_SPACES (_TNL_NEW_NEED_NORMALS | \
1366 _TNL_NEW_NEED_EYE_COORDS )
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
1378 #define DD_ANY_CULL (DD_TRI_CULL_FRONT_BACK| \
1388 * Forward declaration of display list datatypes:
1391 typedef union node Node
;
1397 /* This has to be included here. */
1402 * The library context:
1404 struct __GLcontextRec
{
1406 ** Os related interfaces; these *must* be the first members of this
1407 ** structure, because they are exposed to the outside world (i.e. GLX
1410 __GLimports imports
;
1411 __GLexports exports
;
1413 /* State possibly shared with other contexts in the address space */
1414 struct gl_shared_state
*Shared
;
1416 /* API function pointer tables */
1417 struct _glapi_table
*Save
; /* Display list save funcs */
1418 struct _glapi_table
*Exec
; /* Execute funcs */
1419 struct _glapi_table
*CurrentDispatch
; /* == Save or Exec !! */
1421 GLboolean ExecPrefersFloat
; /* What preference for color conversion? */
1422 GLboolean SavePrefersFloat
;
1425 GLframebuffer
*DrawBuffer
; /* buffer for writing */
1426 GLframebuffer
*ReadBuffer
; /* buffer for reading */
1428 /* Driver function pointer table */
1429 struct dd_function_table Driver
;
1431 void *DriverCtx
; /* Points to device driver context/state */
1432 void *DriverMgrCtx
; /* Points to device driver manager (optional)*/
1434 /* Core/Driver constants */
1435 struct gl_constants Const
;
1437 /* Modelview matrix and stack */
1438 GLmatrix ModelView
; /* current matrix, not stored on stack */
1439 GLuint ModelViewStackDepth
;
1440 GLmatrix ModelViewStack
[MAX_MODELVIEW_STACK_DEPTH
- 1];
1442 /* Projection matrix and stack */
1443 GLmatrix ProjectionMatrix
; /* current matrix, not stored on stack */
1444 GLuint ProjectionStackDepth
;
1445 GLmatrix ProjectionStack
[MAX_PROJECTION_STACK_DEPTH
- 1];
1447 /* Combined modelview and projection matrix */
1448 GLmatrix _ModelProjectMatrix
;
1450 /* Texture matrix and stack */
1451 GLmatrix TextureMatrix
[MAX_TEXTURE_UNITS
];
1452 GLuint TextureStackDepth
[MAX_TEXTURE_UNITS
];
1453 GLmatrix TextureStack
[MAX_TEXTURE_UNITS
][MAX_TEXTURE_STACK_DEPTH
- 1];
1455 /* Color matrix and stack */
1456 GLmatrix ColorMatrix
;
1457 GLuint ColorStackDepth
;
1458 GLmatrix ColorStack
[MAX_COLOR_STACK_DEPTH
- 1];
1461 GLuint CallDepth
; /* Current recursion calling depth */
1462 GLboolean ExecuteFlag
; /* Execute GL commands? */
1463 GLboolean CompileFlag
; /* Compile GL commands into display list? */
1464 Node
*CurrentListPtr
; /* Head of list being compiled */
1465 GLuint CurrentListNum
; /* Number of the list being compiled */
1466 Node
*CurrentBlock
; /* Pointer to current block of nodes */
1467 GLuint CurrentPos
; /* Index into current block of nodes */
1470 struct gl_extensions Extensions
;
1472 /* Renderer attribute stack */
1473 GLuint AttribStackDepth
;
1474 struct gl_attrib_node
*AttribStack
[MAX_ATTRIB_STACK_DEPTH
];
1476 /* Renderer attribute groups */
1477 struct gl_accum_attrib Accum
;
1478 struct gl_colorbuffer_attrib Color
;
1479 struct gl_current_attrib Current
;
1480 struct gl_depthbuffer_attrib Depth
;
1481 struct gl_eval_attrib Eval
;
1482 struct gl_fog_attrib Fog
;
1483 struct gl_hint_attrib Hint
;
1484 struct gl_light_attrib Light
;
1485 struct gl_line_attrib Line
;
1486 struct gl_list_attrib List
;
1487 struct gl_pixel_attrib Pixel
;
1488 struct gl_point_attrib Point
;
1489 struct gl_polygon_attrib Polygon
;
1490 GLuint PolygonStipple
[32];
1491 struct gl_scissor_attrib Scissor
;
1492 struct gl_stencil_attrib Stencil
;
1493 struct gl_texture_attrib Texture
;
1494 struct gl_transform_attrib Transform
;
1495 struct gl_viewport_attrib Viewport
;
1497 /* Other attribute groups */
1498 struct gl_histogram_attrib Histogram
;
1499 struct gl_minmax_attrib MinMax
;
1500 struct gl_convolution_attrib Convolution1D
;
1501 struct gl_convolution_attrib Convolution2D
;
1502 struct gl_convolution_attrib Separable2D
;
1504 /* Client attribute stack */
1505 GLuint ClientAttribStackDepth
;
1506 struct gl_attrib_node
*ClientAttribStack
[MAX_CLIENT_ATTRIB_STACK_DEPTH
];
1508 /* Client attribute groups */
1509 struct gl_array_attrib Array
; /* Vertex arrays */
1510 struct gl_pixelstore_attrib Pack
; /* Pixel packing */
1511 struct gl_pixelstore_attrib Unpack
; /* Pixel unpacking */
1513 struct gl_evaluators EvalMap
; /* All evaluators */
1514 struct gl_feedback Feedback
; /* Feedback */
1515 struct gl_selection Select
; /* Selection */
1517 struct gl_color_table ColorTable
; /* Pre-convolution */
1518 struct gl_color_table ProxyColorTable
; /* Pre-convolution */
1519 struct gl_color_table PostConvolutionColorTable
;
1520 struct gl_color_table ProxyPostConvolutionColorTable
;
1521 struct gl_color_table PostColorMatrixColorTable
;
1522 struct gl_color_table ProxyPostColorMatrixColorTable
;
1524 GLenum ErrorValue
; /* Last error code */
1525 GLenum RenderMode
; /* either GL_RENDER, GL_SELECT, GL_FEEDBACK */
1526 GLuint NewState
; /* bitwise-or of _NEW_* flags */
1529 GLuint _Enabled
; /* bitwise-or of ENABLE_* flags */
1530 GLuint _TriangleCaps
; /* bitwise-or of DD_* flags */
1531 GLuint _ImageTransferState
;/* bitwise-or of IMAGE_*_BIT flags */
1532 GLfloat _EyeZDir
[3];
1533 GLfloat _ModelViewInvScale
;
1534 GLuint _NeedEyeCoords
;
1535 GLuint _NeedNormals
; /* Are vertex normal vectors needed? */
1537 struct gl_shine_tab
*_ShineTable
[4]; /* Active shine tables */
1538 struct gl_shine_tab
*_ShineTabList
; /* Mru list of inactive shine tables */
1540 struct gl_list_extensions listext
; /* driver dlist extensions */
1543 GLboolean OcclusionResult
; /* GL_HP_occlusion_test */
1544 GLboolean OcclusionResultSaved
; /* GL_HP_occlusion_test */
1546 /* Should 3Dfx Glide driver catch signals? */
1547 GLboolean CatchSignals
;
1549 /* For debugging/development only */
1551 GLboolean FirstTimeCurrent
;
1553 /* Dither disable via MESA_NO_DITHER env var */
1557 GLboolean Rendering
;
1560 #if defined(MESA_TRACE)
1561 struct _glapi_table
*TraceDispatch
;
1562 trace_context_t
*TraceCtx
;
1565 /* Hooks for module contexts. These will eventually live
1566 * in the driver or elsewhere.
1568 void *swrast_context
;
1569 void *swsetup_context
;
1570 void *swtnl_context
;
1576 /* The string names for GL_POINT, GL_LINE_LOOP, etc */
1577 extern const char *_mesa_prim_name
[GL_POLYGON
+2];
1578 extern GLenum gl_reduce_prim
[];
1582 extern int MESA_VERBOSE
;
1583 extern int MESA_DEBUG_FLAGS
;
1585 # define MESA_VERBOSE 0
1586 # define MESA_DEBUG_FLAGS 0
1594 VERBOSE_VARRAY
= 0x1,
1595 VERBOSE_TEXTURE
= 0x2,
1596 VERBOSE_IMMEDIATE
= 0x4,
1597 VERBOSE_PIPELINE
= 0x8,
1598 VERBOSE_DRIVER
= 0x10,
1599 VERBOSE_STATE
= 0x20,
1601 VERBOSE_TRIANGLE_CHECKS
= 0x80,
1602 VERBOSE_CULL
= 0x100,
1603 VERBOSE_DISPLAY_LIST
= 0x200,
1604 VERBOSE_LIGHTING
= 0x400
1609 DEBUG_ALWAYS_FLUSH
= 0x1
1614 #define Elements(x) sizeof(x)/sizeof(*(x))
1617 #define FLUSH_TNL( ctx, flags ) \
1619 if (ctx->Driver.NeedFlush & flags) \
1620 ctx->Driver.FlushVertices( ctx, flags ); \
1623 #define FLUSH_TNL_RETURN( ctx, flags, where ) \
1625 if (ctx->Driver.NeedFlush & flags) { \
1626 if (!ctx->Driver.FlushVertices( ctx, flags )) { \
1627 gl_error( ctx, GL_INVALID_OPERATION, where ); \
1633 #define FLUSH_TNL_RETVAL( ctx, flags, where, what ) \
1635 if (ctx->Driver.NeedFlush & flags) { \
1636 if (!ctx->Driver.FlushVertices( ctx, flags )) { \
1637 gl_error( ctx, GL_INVALID_OPERATION, where ); \
1644 #define ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL( ctx, where, what ) \
1645 FLUSH_TNL_RETVAL( ctx, \
1646 (FLUSH_INSIDE_BEGIN_END| \
1647 FLUSH_STORED_VERTICES), \
1650 #define ASSERT_OUTSIDE_BEGIN_END( ctx, where ) \
1651 FLUSH_TNL_RETURN( ctx, \
1652 (FLUSH_INSIDE_BEGIN_END| \
1653 FLUSH_STORED_VERTICES), \
1656 #define ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH( ctx, where ) \
1657 ASSERT_OUTSIDE_BEGIN_END( ctx, where );
1659 #define ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH_WITH_RETVAL( ctx, where, what ) \
1660 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL( ctx, where, what );
1665 #define RENDER_START(CTX) \
1667 assert(!(CTX)->Rendering); \
1668 (CTX)->Rendering = GL_TRUE; \
1669 if ((CTX)->Driver.RenderStart) { \
1670 (*(CTX)->Driver.RenderStart)(CTX); \
1674 #define RENDER_FINISH(CTX) \
1676 assert((CTX)->Rendering); \
1677 (CTX)->Rendering = GL_FALSE; \
1678 if ((CTX)->Driver.RenderFinish) { \
1679 (*(CTX)->Driver.RenderFinish)(CTX); \
1685 #define RENDER_START(CTX) \
1687 if ((CTX)->Driver.RenderStart) { \
1688 (*(CTX)->Driver.RenderStart)(CTX); \
1692 #define RENDER_FINISH(CTX) \
1694 if ((CTX)->Driver.RenderFinish) { \
1695 (*(CTX)->Driver.RenderFinish)(CTX); \
1702 #endif /* TYPES_H */