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