3 * Main Mesa data structures.
5 * Please try to mark derived values with a leading underscore ('_').
9 * Mesa 3-D graphics library
12 * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
14 * Permission is hereby granted, free of charge, to any person obtaining a
15 * copy of this software and associated documentation files (the "Software"),
16 * to deal in the Software without restriction, including without limitation
17 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
18 * and/or sell copies of the Software, and to permit persons to whom the
19 * Software is furnished to do so, subject to the following conditions:
21 * The above copyright notice and this permission notice shall be included
22 * in all copies or substantial portions of the Software.
24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
25 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
27 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
28 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
39 #include "config.h" /* Hardwired parameters */
40 #include "glapitable.h"
43 #include "math/m_matrix.h" /* GLmatrix */
45 #if defined(MESA_TRACE)
46 #include "Trace/tr_context.h"
51 * Color channel data type.
54 typedef GLubyte GLchan
;
56 #define CHAN_MAXF 255.0F
57 #define CHAN_TYPE GL_UNSIGNED_BYTE
59 typedef GLushort GLchan
;
60 #define CHAN_MAX 65535
61 #define CHAN_MAXF 65535.0F
62 #define CHAN_TYPE GL_UNSIGNED_SHORT
64 typedef GLfloat GLchan
;
66 #define CHAN_MAXF 1.0F
67 #define CHAN_TYPE GL_FLOAT
69 #error "illegal number of color channel bits"
74 * Accumulation buffer data type.
77 typedef GLbyte GLaccum
;
79 typedef GLshort GLaccum
;
81 typedef GLfloat GLaccum
;
83 # error "illegal number of accumulation bits"
88 * Stencil buffer data type.
91 typedef GLubyte GLstencil
;
92 # define STENCIL_MAX 0xff
93 #elif STENCIL_BITS==16
94 typedef GLushort GLstencil
;
95 # define STENCIL_MAX 0xffff
97 # error "illegal number of stencil bits"
102 * Depth buffer data type.
104 * \note Must be 32-bits!
106 typedef GLuint GLdepth
;
110 * Fixed point data type.
114 * Fixed point arithmetic macros
117 #define FIXED_ONE 0x00004000
118 #define FIXED_HALF 0x00002000
119 #define FIXED_FRAC_MASK 0x00003FFF
120 #define FIXED_SCALE 16384.0f
121 #define FIXED_SHIFT 14
123 #define FIXED_ONE 0x00000800
124 #define FIXED_HALF 0x00000400
125 #define FIXED_FRAC_MASK 0x000007FF
126 #define FIXED_SCALE 2048.0f
127 #define FIXED_SHIFT 11
129 #define FIXED_INT_MASK (~FIXED_FRAC_MASK)
130 #define FIXED_EPSILON 1
131 #define FloatToFixed(X) (IROUND((X) * FIXED_SCALE))
132 #define IntToFixed(I) ((I) << FIXED_SHIFT)
133 #define FixedToInt(X) ((X) >> FIXED_SHIFT)
134 #define FixedToUns(X) (((unsigned int)(X)) >> FIXED_SHIFT)
135 #define FixedCeil(X) (((X) + FIXED_ONE - FIXED_EPSILON) & FIXED_INT_MASK)
136 #define FixedFloor(X) ((X) & FIXED_INT_MASK)
137 #define FixedToFloat(X) ((X) * (1.0F / FIXED_SCALE))
138 #define PosFloatToFixed(X) FloatToFixed(X)
139 #define SignedFloatToFixed(X) FloatToFixed(X)
144 * \name Some forward type declarations
147 struct _mesa_HashTable
;
148 struct gl_texture_image
;
149 struct gl_texture_object
;
150 typedef struct __GLcontextRec GLcontext
;
151 typedef struct __GLcontextModesRec GLvisual
;
152 typedef struct gl_frame_buffer GLframebuffer
;
158 * These define the aliases between numbered vertex attributes and
159 * conventional OpenGL vertex attributes. We use these values in
160 * quite a few places.
166 VERT_ATTRIB_WEIGHT
= 1,
167 VERT_ATTRIB_NORMAL
= 2,
168 VERT_ATTRIB_COLOR0
= 3,
169 VERT_ATTRIB_COLOR1
= 4,
172 VERT_ATTRIB_SEVEN
= 7,
173 VERT_ATTRIB_TEX0
= 8,
174 VERT_ATTRIB_TEX1
= 9,
175 VERT_ATTRIB_TEX2
= 10,
176 VERT_ATTRIB_TEX3
= 11,
177 VERT_ATTRIB_TEX4
= 12,
178 VERT_ATTRIB_TEX5
= 13,
179 VERT_ATTRIB_TEX6
= 14,
180 VERT_ATTRIB_TEX7
= 15,
184 /* These are used in bitfields in many places */
185 #define VERT_BIT_POS (1 << VERT_ATTRIB_POS)
186 #define VERT_BIT_WEIGHT (1 << VERT_ATTRIB_WEIGHT)
187 #define VERT_BIT_NORMAL (1 << VERT_ATTRIB_NORMAL)
188 #define VERT_BIT_COLOR0 (1 << VERT_ATTRIB_COLOR0)
189 #define VERT_BIT_COLOR1 (1 << VERT_ATTRIB_COLOR1)
190 #define VERT_BIT_FOG (1 << VERT_ATTRIB_FOG)
191 #define VERT_BIT_SIX (1 << VERT_ATTRIB_SIX)
192 #define VERT_BIT_SEVEN (1 << VERT_ATTRIB_SEVEN)
193 #define VERT_BIT_TEX0 (1 << VERT_ATTRIB_TEX0)
194 #define VERT_BIT_TEX1 (1 << VERT_ATTRIB_TEX1)
195 #define VERT_BIT_TEX2 (1 << VERT_ATTRIB_TEX2)
196 #define VERT_BIT_TEX3 (1 << VERT_ATTRIB_TEX3)
197 #define VERT_BIT_TEX4 (1 << VERT_ATTRIB_TEX4)
198 #define VERT_BIT_TEX5 (1 << VERT_ATTRIB_TEX5)
199 #define VERT_BIT_TEX6 (1 << VERT_ATTRIB_TEX6)
200 #define VERT_BIT_TEX7 (1 << VERT_ATTRIB_TEX7)
202 #define VERT_BIT_TEX(u) (1 << (VERT_ATTRIB_TEX0 + (u)))
207 * Maximum number of temporary vertices required for clipping.
209 * Used in array_cache and tnl modules.
211 #define MAX_CLIPPED_VERTICES ((2 * (6 + MAX_CLIP_PLANES))+1)
215 * Data structure for color tables
217 struct gl_color_table
{
218 GLenum Format
; /**< GL_ALPHA, GL_RGB, GL_RGB, etc */
220 GLuint Size
; /**< number of entries (rows) in table */
221 GLvoid
*Table
; /**< either GLfloat * or GLchan * */
222 GLboolean FloatTable
; /**< are entries stored as floats? */
227 GLubyte LuminanceSize
;
228 GLubyte IntensitySize
;
233 * \name Bit flags used for updating material values.
236 #define MAT_ATTRIB_FRONT_AMBIENT 0
237 #define MAT_ATTRIB_BACK_AMBIENT 1
238 #define MAT_ATTRIB_FRONT_DIFFUSE 2
239 #define MAT_ATTRIB_BACK_DIFFUSE 3
240 #define MAT_ATTRIB_FRONT_SPECULAR 4
241 #define MAT_ATTRIB_BACK_SPECULAR 5
242 #define MAT_ATTRIB_FRONT_EMISSION 6
243 #define MAT_ATTRIB_BACK_EMISSION 7
244 #define MAT_ATTRIB_FRONT_SHININESS 8
245 #define MAT_ATTRIB_BACK_SHININESS 9
246 #define MAT_ATTRIB_FRONT_INDEXES 10
247 #define MAT_ATTRIB_BACK_INDEXES 11
248 #define MAT_ATTRIB_MAX 12
250 #define MAT_ATTRIB_AMBIENT(f) (MAT_ATTRIB_FRONT_AMBIENT+(f))
251 #define MAT_ATTRIB_DIFFUSE(f) (MAT_ATTRIB_FRONT_DIFFUSE+(f))
252 #define MAT_ATTRIB_SPECULAR(f) (MAT_ATTRIB_FRONT_SPECULAR+(f))
253 #define MAT_ATTRIB_EMISSION(f) (MAT_ATTRIB_FRONT_EMISSION+(f))
254 #define MAT_ATTRIB_SHININESS(f)(MAT_ATTRIB_FRONT_SHININESS+(f))
255 #define MAT_ATTRIB_INDEXES(f) (MAT_ATTRIB_FRONT_INDEXES+(f))
257 #define MAT_INDEX_AMBIENT 0
258 #define MAT_INDEX_DIFFUSE 1
259 #define MAT_INDEX_SPECULAR 2
261 #define MAT_BIT_FRONT_AMBIENT (1<<MAT_ATTRIB_FRONT_AMBIENT)
262 #define MAT_BIT_BACK_AMBIENT (1<<MAT_ATTRIB_BACK_AMBIENT)
263 #define MAT_BIT_FRONT_DIFFUSE (1<<MAT_ATTRIB_FRONT_DIFFUSE)
264 #define MAT_BIT_BACK_DIFFUSE (1<<MAT_ATTRIB_BACK_DIFFUSE)
265 #define MAT_BIT_FRONT_SPECULAR (1<<MAT_ATTRIB_FRONT_SPECULAR)
266 #define MAT_BIT_BACK_SPECULAR (1<<MAT_ATTRIB_BACK_SPECULAR)
267 #define MAT_BIT_FRONT_EMISSION (1<<MAT_ATTRIB_FRONT_EMISSION)
268 #define MAT_BIT_BACK_EMISSION (1<<MAT_ATTRIB_BACK_EMISSION)
269 #define MAT_BIT_FRONT_SHININESS (1<<MAT_ATTRIB_FRONT_SHININESS)
270 #define MAT_BIT_BACK_SHININESS (1<<MAT_ATTRIB_BACK_SHININESS)
271 #define MAT_BIT_FRONT_INDEXES (1<<MAT_ATTRIB_FRONT_INDEXES)
272 #define MAT_BIT_BACK_INDEXES (1<<MAT_ATTRIB_BACK_INDEXES)
275 #define FRONT_MATERIAL_BITS (MAT_BIT_FRONT_EMISSION | \
276 MAT_BIT_FRONT_AMBIENT | \
277 MAT_BIT_FRONT_DIFFUSE | \
278 MAT_BIT_FRONT_SPECULAR | \
279 MAT_BIT_FRONT_SHININESS | \
280 MAT_BIT_FRONT_INDEXES)
282 #define BACK_MATERIAL_BITS (MAT_BIT_BACK_EMISSION | \
283 MAT_BIT_BACK_AMBIENT | \
284 MAT_BIT_BACK_DIFFUSE | \
285 MAT_BIT_BACK_SPECULAR | \
286 MAT_BIT_BACK_SHININESS | \
287 MAT_BIT_BACK_INDEXES)
289 #define ALL_MATERIAL_BITS (FRONT_MATERIAL_BITS | BACK_MATERIAL_BITS)
293 #define EXP_TABLE_SIZE 512 /**< Specular exponent lookup table sizes */
294 #define SHINE_TABLE_SIZE 256 /**< Material shininess lookup table sizes */
297 * Material shininess lookup table.
299 struct gl_shine_tab
{
300 struct gl_shine_tab
*next
, *prev
;
301 GLfloat tab
[SHINE_TABLE_SIZE
+1];
311 struct gl_light
*next
; /**< double linked list with sentinel */
312 struct gl_light
*prev
;
314 GLfloat Ambient
[4]; /**< ambient color */
315 GLfloat Diffuse
[4]; /**< diffuse color */
316 GLfloat Specular
[4]; /**< specular color */
317 GLfloat EyePosition
[4]; /**< position in eye coordinates */
318 GLfloat EyeDirection
[4]; /**< spotlight dir in eye coordinates */
319 GLfloat SpotExponent
;
320 GLfloat SpotCutoff
; /**< in degrees */
321 GLfloat _CosCutoff
; /**< = MAX(0, cos(SpotCutoff)) */
322 GLfloat ConstantAttenuation
;
323 GLfloat LinearAttenuation
;
324 GLfloat QuadraticAttenuation
;
325 GLboolean Enabled
; /**< On/off flag */
328 * \name Derived fields
331 GLuint _Flags
; /**< State */
333 GLfloat _Position
[4]; /**< position in eye/obj coordinates */
334 GLfloat _VP_inf_norm
[3]; /**< Norm direction to infinite light */
335 GLfloat _h_inf_norm
[3]; /**< Norm( _VP_inf_norm + <0,0,1> ) */
336 GLfloat _NormDirection
[4]; /**< normalized spotlight direction */
337 GLfloat _VP_inf_spot_attenuation
;
339 GLfloat _SpotExpTable
[EXP_TABLE_SIZE
][2]; /**< to replace a pow() call */
340 GLfloat _MatAmbient
[2][3]; /**< material ambient * light ambient */
341 GLfloat _MatDiffuse
[2][3]; /**< material diffuse * light diffuse */
342 GLfloat _MatSpecular
[2][3]; /**< material spec * light specular */
343 GLfloat _dli
; /**< CI diffuse light intensity */
344 GLfloat _sli
; /**< CI specular light intensity */
352 struct gl_lightmodel
{
353 GLfloat Ambient
[4]; /**< ambient color */
354 GLboolean LocalViewer
; /**< Local (or infinite) view point? */
355 GLboolean TwoSide
; /**< Two (or one) sided lighting? */
356 GLenum ColorControl
; /**< either GL_SINGLE_COLOR
357 * or GL_SEPARATE_SPECULAR_COLOR */
366 GLfloat Attrib
[MAT_ATTRIB_MAX
][4];
371 * Accumulation buffer attributes.
373 struct gl_accum_attrib
{
374 GLfloat ClearColor
[4]; /**< Accumulation buffer clear color */
379 * \name Clipping planes bits
381 * Used in gl_colorbuffer_attrib::_DrawDestMask and
382 * gl_colorbuffer_attrib::_ReadSrcMask below to identify color buffers.
385 #define FRONT_LEFT_BIT 0x1
386 #define FRONT_RIGHT_BIT 0x2
387 #define BACK_LEFT_BIT 0x4
388 #define BACK_RIGHT_BIT 0x8
389 #define AUX0_BIT 0x10
390 #define AUX1_BIT 0x20
391 #define AUX2_BIT 0x40
392 #define AUX3_BIT 0x80
397 * Color buffers attributes.
399 struct gl_colorbuffer_attrib
{
400 GLuint ClearIndex
; /**< Index to use for glClear */
401 GLclampf ClearColor
[4]; /**< Color to use for glClear */
403 GLuint IndexMask
; /**< Color index write mask */
404 GLubyte ColorMask
[4]; /**< Each flag is 0xff or 0x0 */
406 GLenum DrawBuffer
; /**< Which buffer to draw into */
407 GLubyte _DrawDestMask
; /**< bitwise-OR of FRONT/BACK_LEFT/RIGHT_BITs */
410 * \name alpha testing
413 GLboolean AlphaEnabled
; /**< Alpha test enabled flag */
414 GLenum AlphaFunc
; /**< Alpha test function */
415 GLclampf AlphaRef
; /**< Alpha reference value */
422 GLboolean BlendEnabled
; /**< Blending enabled flag */
423 GLenum BlendSrcRGB
; /**< Blending source operator */
424 GLenum BlendDstRGB
; /**< Blending destination operator */
425 GLenum BlendSrcA
; /**< GL_INGR_blend_func_separate */
426 GLenum BlendDstA
; /**< GL_INGR_blend_func_separate */
427 GLenum BlendEquation
; /**< Blending equation */
428 GLfloat BlendColor
[4]; /**< Blending color */
435 GLenum LogicOp
; /**< Logic operator */
436 GLboolean IndexLogicOpEnabled
; /**< Color index logic op enabled flag */
437 GLboolean ColorLogicOpEnabled
; /**< RGBA logic op enabled flag */
440 GLboolean DitherFlag
; /**< Dither enable flag */
445 * Current attributes.
447 struct gl_current_attrib
{
449 * \name Values valid only when FLUSH_VERTICES has been called.
452 GLfloat Attrib
[VERT_ATTRIB_MAX
][4]; /**< Current vertex attributes
453 * indexed by VERT_ATTRIB_* */
454 GLuint Index
; /**< Current color index */
455 GLboolean EdgeFlag
; /**< Current edge flag */
459 * \name Values are always valid.
461 * \note BTW, note how similar this set of attributes is to the SWvertex data type
462 * in the software rasterizer...
465 GLfloat RasterPos
[4]; /**< Current raster position */
466 GLfloat RasterDistance
; /**< Current raster distance */
467 GLfloat RasterColor
[4]; /**< Current raster color */
468 GLfloat RasterSecondaryColor
[4]; /**< Current raster secondary color */
469 GLuint RasterIndex
; /**< Current raster index */
470 GLfloat RasterTexCoords
[MAX_TEXTURE_UNITS
][4];/**< Current raster texcoords */
471 GLboolean RasterPosValid
; /**< Raster pos valid flag */
477 * Depth buffer attributes.
479 struct gl_depthbuffer_attrib
{
480 GLenum Func
; /**< Function for depth buffer compare */
481 GLfloat Clear
; /**< Value to clear depth buffer to */
482 GLboolean Test
; /**< Depth buffering enabled flag */
483 GLboolean Mask
; /**< Depth buffer writable? */
484 GLboolean OcclusionTest
; /**< GL_HP_occlusion_test */
485 GLboolean BoundsTest
; /**< GL_EXT_depth_bounds_test */
486 GLfloat BoundsMin
, BoundsMax
;/**< GL_EXT_depth_bounds_test */
491 * glEnable()/glDisable() attributes.
493 struct gl_enable_attrib
{
495 GLboolean AutoNormal
;
498 GLboolean ColorMaterial
;
499 GLboolean ColorTable
; /* SGI_color_table */
500 GLboolean PostColorMatrixColorTable
; /* SGI_color_table */
501 GLboolean PostConvolutionColorTable
; /* SGI_color_table */
502 GLboolean Convolution1D
;
503 GLboolean Convolution2D
;
504 GLboolean Separable2D
;
510 GLboolean Light
[MAX_LIGHTS
];
512 GLboolean LineSmooth
;
513 GLboolean LineStipple
;
514 GLboolean IndexLogicOp
;
515 GLboolean ColorLogicOp
;
516 GLboolean Map1Color4
;
518 GLboolean Map1Normal
;
519 GLboolean Map1TextureCoord1
;
520 GLboolean Map1TextureCoord2
;
521 GLboolean Map1TextureCoord3
;
522 GLboolean Map1TextureCoord4
;
523 GLboolean Map1Vertex3
;
524 GLboolean Map1Vertex4
;
525 GLboolean Map1Attrib
[16]; /* GL_NV_vertex_program */
526 GLboolean Map2Color4
;
528 GLboolean Map2Normal
;
529 GLboolean Map2TextureCoord1
;
530 GLboolean Map2TextureCoord2
;
531 GLboolean Map2TextureCoord3
;
532 GLboolean Map2TextureCoord4
;
533 GLboolean Map2Vertex3
;
534 GLboolean Map2Vertex4
;
535 GLboolean Map2Attrib
[16]; /* GL_NV_vertex_program */
538 GLboolean PixelTexture
;
539 GLboolean PointSmooth
;
540 GLboolean PolygonOffsetPoint
;
541 GLboolean PolygonOffsetLine
;
542 GLboolean PolygonOffsetFill
;
543 GLboolean PolygonSmooth
;
544 GLboolean PolygonStipple
;
545 GLboolean RescaleNormals
;
548 GLboolean MultisampleEnabled
; /* GL_ARB_multisample */
549 GLboolean SampleAlphaToCoverage
; /* GL_ARB_multisample */
550 GLboolean SampleAlphaToOne
; /* GL_ARB_multisample */
551 GLboolean SampleCoverage
; /* GL_ARB_multisample */
552 GLboolean SampleCoverageInvert
; /* GL_ARB_multisample */
553 GLboolean RasterPositionUnclipped
; /* GL_IBM_rasterpos_clip */
554 GLuint Texture
[MAX_TEXTURE_IMAGE_UNITS
];
555 GLuint TexGen
[MAX_TEXTURE_COORD_UNITS
];
556 /* SGI_texture_color_table */
557 GLboolean TextureColorTable
[MAX_TEXTURE_IMAGE_UNITS
];
558 /* GL_NV_vertex_program */
559 GLboolean VertexProgram
;
560 GLboolean VertexProgramPointSize
;
561 GLboolean VertexProgramTwoSide
;
562 /* GL_ARB_point_sprite / GL_NV_point_sprite */
563 GLboolean PointSprite
;
570 struct gl_eval_attrib
{
575 GLboolean Map1Color4
;
577 GLboolean Map1Normal
;
578 GLboolean Map1TextureCoord1
;
579 GLboolean Map1TextureCoord2
;
580 GLboolean Map1TextureCoord3
;
581 GLboolean Map1TextureCoord4
;
582 GLboolean Map1Vertex3
;
583 GLboolean Map1Vertex4
;
584 GLboolean Map1Attrib
[16]; /* GL_NV_vertex_program */
585 GLboolean Map2Color4
;
587 GLboolean Map2Normal
;
588 GLboolean Map2TextureCoord1
;
589 GLboolean Map2TextureCoord2
;
590 GLboolean Map2TextureCoord3
;
591 GLboolean Map2TextureCoord4
;
592 GLboolean Map2Vertex3
;
593 GLboolean Map2Vertex4
;
594 GLboolean Map2Attrib
[16]; /* GL_NV_vertex_program */
595 GLboolean AutoNormal
;
599 * \name Map Grid endpoints and divisions and calculated du values
603 GLfloat MapGrid1u1
, MapGrid1u2
, MapGrid1du
;
604 GLint MapGrid2un
, MapGrid2vn
;
605 GLfloat MapGrid2u1
, MapGrid2u2
, MapGrid2du
;
606 GLfloat MapGrid2v1
, MapGrid2v2
, MapGrid2dv
;
614 struct gl_fog_attrib
{
615 GLboolean Enabled
; /**< Fog enabled flag */
616 GLfloat Color
[4]; /**< Fog color */
617 GLfloat Density
; /**< Density >= 0.0 */
618 GLfloat Start
; /**< Start distance in eye coords */
619 GLfloat End
; /**< End distance in eye coords */
620 GLfloat Index
; /**< Fog index */
621 GLenum Mode
; /**< Fog mode */
622 GLboolean ColorSumEnabled
;
623 GLenum FogCoordinateSource
; /**< GL_EXT_fog_coord */
630 * Values are always one of GL_FASTEST, GL_NICEST, or GL_DONT_CARE.
632 struct gl_hint_attrib
{
633 GLenum PerspectiveCorrection
;
636 GLenum PolygonSmooth
;
638 GLenum ClipVolumeClipping
; /**< GL_EXT_clip_volume_hint */
639 GLenum TextureCompression
; /**< GL_ARB_texture_compression */
640 GLenum GenerateMipmap
; /**< GL_SGIS_generate_mipmap */
645 * Histogram attributes.
647 struct gl_histogram_attrib
{
648 GLuint Width
; /**< number of table entries */
649 GLint Format
; /**< GL_ALPHA, GL_RGB, etc */
650 GLuint Count
[HISTOGRAM_TABLE_SIZE
][4]; /**< the histogram */
651 GLboolean Sink
; /**< terminate image transfer? */
652 GLubyte RedSize
; /**< Bits per counter */
656 GLubyte LuminanceSize
;
660 struct gl_minmax_attrib
{
663 GLfloat Min
[4], Max
[4]; /**< RGBA */
667 struct gl_convolution_attrib
{
669 GLenum InternalFormat
;
672 GLfloat Filter
[MAX_CONVOLUTION_WIDTH
* MAX_CONVOLUTION_HEIGHT
* 4];
676 #define LIGHT_SPOT 0x1
677 #define LIGHT_LOCAL_VIEWER 0x2
678 #define LIGHT_POSITIONAL 0x4
679 #define LIGHT_NEED_VERTICES (LIGHT_POSITIONAL|LIGHT_LOCAL_VIEWER)
682 * Lighting attributes.
684 struct gl_light_attrib
{
685 struct gl_light Light
[MAX_LIGHTS
]; /**< Array of lights */
686 struct gl_lightmodel Model
; /**< Lighting model */
689 * Must flush FLUSH_VERTICES before referencing:
692 struct gl_material Material
; /**< Includes front & back values */
695 GLboolean Enabled
; /**< Lighting enabled flag */
696 GLenum ShadeModel
; /**< GL_FLAT or GL_SMOOTH */
697 GLenum ColorMaterialFace
; /**< GL_FRONT, BACK or FRONT_AND_BACK */
698 GLenum ColorMaterialMode
; /**< GL_AMBIENT, GL_DIFFUSE, etc */
699 GLuint ColorMaterialBitmask
; /**< bitmask formed from Face and Mode */
700 GLboolean ColorMaterialEnabled
;
702 struct gl_light EnabledList
; /**< List sentinel */
705 * Derived for optimizations:
708 GLboolean _NeedEyeCoords
;
709 GLboolean _NeedVertices
; /**< Use fast shader? */
710 GLuint _Flags
; /**< LIGHT_* flags, see above */
711 GLfloat _BaseColor
[2][3];
719 struct gl_line_attrib
{
720 GLboolean SmoothFlag
; /**< GL_LINE_SMOOTH enabled? */
721 GLboolean StippleFlag
; /**< GL_LINE_STIPPLE enabled? */
722 GLushort StipplePattern
; /**< Stipple pattern */
723 GLint StippleFactor
; /**< Stipple repeat factor */
724 GLfloat Width
; /**< Line width */
725 GLfloat _Width
; /**< Clamped Line width */
729 struct gl_list_attrib
{
734 struct gl_list_opcode
{
736 void (*execute
)( GLcontext
*ctx
, void *data
);
737 void (*destroy
)( GLcontext
*ctx
, void *data
);
738 void (*print
)( GLcontext
*ctx
, void *data
);
741 #define GL_MAX_EXT_OPCODES 16
743 struct gl_list_extensions
{
744 struct gl_list_opcode opcode
[GL_MAX_EXT_OPCODES
];
749 struct gl_multisample_attrib
{
751 GLboolean SampleAlphaToCoverage
;
752 GLboolean SampleAlphaToOne
;
753 GLboolean SampleCoverage
;
754 GLfloat SampleCoverageValue
;
755 GLboolean SampleCoverageInvert
;
762 struct gl_pixel_attrib
{
763 GLenum ReadBuffer
; /**< source buffer for glReadPixels()/glCopyPixels() */
764 GLubyte _ReadSrcMask
; /**< Not really a mask, but like _DrawDestMask
766 * May be: FRONT_LEFT_BIT, BACK_LEFT_BIT,
767 * FRONT_RIGHT_BIT or BACK_RIGHT_BIT. */
768 GLfloat RedBias
, RedScale
;
769 GLfloat GreenBias
, GreenScale
;
770 GLfloat BlueBias
, BlueScale
;
771 GLfloat AlphaBias
, AlphaScale
;
772 GLfloat DepthBias
, DepthScale
;
773 GLint IndexShift
, IndexOffset
;
774 GLboolean MapColorFlag
;
775 GLboolean MapStencilFlag
;
776 GLfloat ZoomX
, ZoomY
;
777 /* XXX move these out of gl_pixel_attrib */
778 GLint MapStoSsize
; /**< Size of each pixel map */
788 GLint MapStoS
[MAX_PIXEL_MAP_TABLE
]; /**< Pixel map tables */
789 GLint MapItoI
[MAX_PIXEL_MAP_TABLE
];
790 GLfloat MapItoR
[MAX_PIXEL_MAP_TABLE
];
791 GLfloat MapItoG
[MAX_PIXEL_MAP_TABLE
];
792 GLfloat MapItoB
[MAX_PIXEL_MAP_TABLE
];
793 GLfloat MapItoA
[MAX_PIXEL_MAP_TABLE
];
794 GLubyte MapItoR8
[MAX_PIXEL_MAP_TABLE
]; /**< converted to 8-bit color */
795 GLubyte MapItoG8
[MAX_PIXEL_MAP_TABLE
];
796 GLubyte MapItoB8
[MAX_PIXEL_MAP_TABLE
];
797 GLubyte MapItoA8
[MAX_PIXEL_MAP_TABLE
];
798 GLfloat MapRtoR
[MAX_PIXEL_MAP_TABLE
];
799 GLfloat MapGtoG
[MAX_PIXEL_MAP_TABLE
];
800 GLfloat MapBtoB
[MAX_PIXEL_MAP_TABLE
];
801 GLfloat MapAtoA
[MAX_PIXEL_MAP_TABLE
];
802 /** GL_EXT_histogram */
803 GLboolean HistogramEnabled
;
804 GLboolean MinMaxEnabled
;
805 /** GL_SGIS_pixel_texture */
806 GLboolean PixelTextureEnabled
;
807 GLenum FragmentRgbSource
;
808 GLenum FragmentAlphaSource
;
809 /** GL_SGI_color_matrix */
810 GLfloat PostColorMatrixScale
[4]; /**< RGBA */
811 GLfloat PostColorMatrixBias
[4]; /**< RGBA */
812 /** GL_SGI_color_table */
813 GLfloat ColorTableScale
[4];
814 GLfloat ColorTableBias
[4];
815 GLboolean ColorTableEnabled
;
816 GLfloat PCCTscale
[4];
818 GLboolean PostConvolutionColorTableEnabled
;
819 GLfloat PCMCTscale
[4];
820 GLfloat PCMCTbias
[4];
821 GLboolean PostColorMatrixColorTableEnabled
;
822 /** GL_SGI_texture_color_table */
823 GLfloat TextureColorTableScale
[4];
824 GLfloat TextureColorTableBias
[4];
826 GLboolean Convolution1DEnabled
;
827 GLboolean Convolution2DEnabled
;
828 GLboolean Separable2DEnabled
;
829 GLfloat ConvolutionBorderColor
[3][4];
830 GLenum ConvolutionBorderMode
[3];
831 GLfloat ConvolutionFilterScale
[3][4];
832 GLfloat ConvolutionFilterBias
[3][4];
833 GLfloat PostConvolutionScale
[4]; /**< RGBA */
834 GLfloat PostConvolutionBias
[4]; /**< RGBA */
841 struct gl_point_attrib
{
842 GLboolean SmoothFlag
; /**< True if GL_POINT_SMOOTH is enabled */
843 GLfloat Size
; /**< User-specified point size */
844 GLfloat _Size
; /**< Size clamped to Const.Min/MaxPointSize */
845 GLfloat Params
[3]; /**< GL_EXT_point_parameters */
846 GLfloat MinSize
, MaxSize
; /**< GL_EXT_point_parameters */
847 GLfloat Threshold
; /**< GL_EXT_point_parameters */
848 GLboolean _Attenuated
; /**< True if Params != [1, 0, 0] */
849 GLboolean PointSprite
; /**< GL_NV_point_sprite / GL_NV_point_sprite */
850 GLboolean CoordReplace
[MAX_TEXTURE_UNITS
]; /**< GL_NV_point_sprite / GL_NV_point_sprite */
851 GLenum SpriteRMode
; /**< GL_NV_point_sprite (only!) */
856 * Polygon attributes.
858 struct gl_polygon_attrib
{
859 GLenum FrontFace
; /**< Either GL_CW or GL_CCW */
860 GLenum FrontMode
; /**< Either GL_POINT, GL_LINE or GL_FILL */
861 GLenum BackMode
; /**< Either GL_POINT, GL_LINE or GL_FILL */
862 GLboolean _FrontBit
; /**< 0=GL_CCW, 1=GL_CW */
863 GLboolean CullFlag
; /**< Culling on/off flag */
864 GLboolean SmoothFlag
; /**< True if GL_POLYGON_SMOOTH is enabled */
865 GLboolean StippleFlag
; /**< True if GL_POLYGON_STIPPLE is enabled */
866 GLenum CullFaceMode
; /**< Culling mode GL_FRONT or GL_BACK */
867 GLfloat OffsetFactor
; /**< Polygon offset factor, from user */
868 GLfloat OffsetUnits
; /**< Polygon offset units, from user */
869 GLboolean OffsetPoint
; /**< Offset in GL_POINT mode */
870 GLboolean OffsetLine
; /**< Offset in GL_LINE mode */
871 GLboolean OffsetFill
; /**< Offset in GL_FILL mode */
876 * Scissor attributes.
878 struct gl_scissor_attrib
{
879 GLboolean Enabled
; /**< Scissor test enabled? */
880 GLint X
, Y
; /**< Lower left corner of box */
881 GLsizei Width
, Height
; /**< Size of box */
886 * Stencil attributes.
888 struct gl_stencil_attrib
{
889 GLboolean Enabled
; /**< Enabled flag */
890 GLboolean TestTwoSide
; /**< GL_EXT_stencil_two_side */
891 GLubyte ActiveFace
; /**< GL_EXT_stencil_two_side (0 or 1) */
892 GLenum Function
[2]; /**< Stencil function */
893 GLenum FailFunc
[2]; /**< Fail function */
894 GLenum ZPassFunc
[2]; /**< Depth buffer pass function */
895 GLenum ZFailFunc
[2]; /**< Depth buffer fail function */
896 GLstencil Ref
[2]; /**< Reference value */
897 GLstencil ValueMask
[2]; /**< Value mask */
898 GLstencil WriteMask
[2]; /**< Write mask */
899 GLstencil Clear
; /**< Clear value */
903 #define NUM_TEXTURE_TARGETS 5 /* 1D, 2D, 3D, CUBE and RECT */
905 #define TEXTURE_1D_INDEX 0
906 #define TEXTURE_2D_INDEX 1
907 #define TEXTURE_3D_INDEX 2
908 #define TEXTURE_CUBE_INDEX 3
909 #define TEXTURE_RECT_INDEX 4
911 /* Texture.Unit[]._ReallyEnabled flags: */
912 #define TEXTURE_1D_BIT (1 << TEXTURE_1D_INDEX)
913 #define TEXTURE_2D_BIT (1 << TEXTURE_2D_INDEX)
914 #define TEXTURE_3D_BIT (1 << TEXTURE_3D_INDEX)
915 #define TEXTURE_CUBE_BIT (1 << TEXTURE_CUBE_INDEX)
916 #define TEXTURE_RECT_BIT (1 << TEXTURE_RECT_INDEX)
919 /* TexGenEnabled flags */
925 /* Bitmap versions of the GL_ constants. */
926 #define TEXGEN_SPHERE_MAP 0x1
927 #define TEXGEN_OBJ_LINEAR 0x2
928 #define TEXGEN_EYE_LINEAR 0x4
929 #define TEXGEN_REFLECTION_MAP_NV 0x8
930 #define TEXGEN_NORMAL_MAP_NV 0x10
932 #define TEXGEN_NEED_NORMALS (TEXGEN_SPHERE_MAP | \
933 TEXGEN_REFLECTION_MAP_NV | \
934 TEXGEN_NORMAL_MAP_NV)
935 #define TEXGEN_NEED_EYE_COORD (TEXGEN_SPHERE_MAP | \
936 TEXGEN_REFLECTION_MAP_NV | \
937 TEXGEN_NORMAL_MAP_NV | \
940 /* A selection of state flags to make driver and module's lives easier. */
941 #define ENABLE_TEXGEN0 0x1
942 #define ENABLE_TEXGEN1 0x2
943 #define ENABLE_TEXGEN2 0x4
944 #define ENABLE_TEXGEN3 0x8
945 #define ENABLE_TEXGEN4 0x10
946 #define ENABLE_TEXGEN5 0x20
947 #define ENABLE_TEXGEN6 0x40
948 #define ENABLE_TEXGEN7 0x80
950 #define ENABLE_TEXMAT0 0x1 /* Ie. not the identity matrix */
951 #define ENABLE_TEXMAT1 0x2
952 #define ENABLE_TEXMAT2 0x4
953 #define ENABLE_TEXMAT3 0x8
954 #define ENABLE_TEXMAT4 0x10
955 #define ENABLE_TEXMAT5 0x20
956 #define ENABLE_TEXMAT6 0x40
957 #define ENABLE_TEXMAT7 0x80
959 #define ENABLE_TEXGEN(i) (ENABLE_TEXGEN0 << (i))
960 #define ENABLE_TEXMAT(i) (ENABLE_TEXMAT0 << (i))
963 * Texel fetch function prototype.
965 * \param texImage texture image.
966 * \param col texel column.
967 * \param row texel row.
968 * \param img texel level.
969 * \param texelOut output texel. If \p texImage is color-index, \p texelOut
970 * returns <tt>GLchan[1]</tt>. If \p texImage is depth, \p texelOut returns
971 * <tt>GLfloat[1]</tt>. Otherwise, \p texelOut returns <tt>GLchan[4]</tt>.
973 typedef void (*FetchTexelFunc
)( const struct gl_texture_image
*texImage
,
974 GLint col
, GLint row
, GLint img
,
978 * Texture format record
980 struct gl_texture_format
{
981 GLint MesaFormat
; /**< One of the MESA_FORMAT_* values */
983 GLenum BaseFormat
; /**< Either GL_ALPHA, GL_INTENSITY, GL_LUMINANCE,
984 * GL_LUMINANCE_ALPHA, GL_RGB, GL_RGBA,
985 * GL_COLOR_INDEX or GL_DEPTH_COMPONENT.
987 GLubyte RedBits
; /**< Bits per texel component */
988 GLubyte GreenBits
; /**< These are just rough approximations for */
989 GLubyte BlueBits
; /**< compressed texture formats. */
991 GLubyte LuminanceBits
;
992 GLubyte IntensityBits
;
996 GLint TexelBytes
; /**< Bytes per texel (0 for compressed formats */
999 * \name Texel fetch function pointers
1002 FetchTexelFunc FetchTexel1D
;
1003 FetchTexelFunc FetchTexel2D
;
1004 FetchTexelFunc FetchTexel3D
;
1010 * Texture image record
1012 struct gl_texture_image
{
1013 GLenum Format
; /**< GL_ALPHA, GL_LUMINANCE, GL_LUMINANCE_ALPHA,
1014 * GL_INTENSITY, GL_RGB, GL_RGBA,
1015 * GL_COLOR_INDEX or GL_DEPTH_COMPONENT only.
1016 * Used for choosing TexEnv arithmetic.
1018 GLint IntFormat
; /**< Internal format as given by the user */
1019 GLuint Border
; /**< 0 or 1 */
1020 GLuint Width
; /**< = 2^WidthLog2 + 2*Border */
1021 GLuint Height
; /**< = 2^HeightLog2 + 2*Border */
1022 GLuint Depth
; /**< = 2^DepthLog2 + 2*Border */
1023 GLuint RowStride
; /**< == Width unless IsClientData and padded */
1024 GLuint Width2
; /**< = Width - 2*Border */
1025 GLuint Height2
; /**< = Height - 2*Border */
1026 GLuint Depth2
; /**< = Depth - 2*Border */
1027 GLuint WidthLog2
; /**< = log2(Width2) */
1028 GLuint HeightLog2
; /**< = log2(Height2) */
1029 GLuint DepthLog2
; /**< = log2(Depth2) */
1030 GLuint MaxLog2
; /**< = MAX(WidthLog2, HeightLog2) */
1031 GLfloat WidthScale
; /**< used for mipmap LOD computation */
1032 GLfloat HeightScale
; /**< used for mipmap LOD computation */
1033 GLfloat DepthScale
; /**< used for mipmap LOD computation */
1034 GLvoid
*Data
; /**< Image data, accessed via FetchTexel() */
1035 GLboolean IsClientData
; /**< Data owned by client? */
1036 GLboolean _IsPowerOfTwo
; /**< Are all dimensions powers of two? */
1038 const struct gl_texture_format
*TexFormat
;
1040 FetchTexelFunc FetchTexel
; /**< Texel fetch function pointer */
1042 GLboolean IsCompressed
; /**< GL_ARB_texture_compression */
1043 GLuint CompressedSize
; /**< GL_ARB_texture_compression */
1046 * \name For device driver:
1049 void *DriverData
; /**< Arbitrary device driver data */
1055 * Texture object record
1057 struct gl_texture_object
{
1058 _glthread_Mutex Mutex
; /**< for thread safety */
1059 GLint RefCount
; /**< reference count */
1060 GLuint Name
; /**< an unsigned integer */
1061 GLenum Target
; /**< GL_TEXTURE_1D, GL_TEXTURE_2D, etc. */
1062 GLfloat Priority
; /**< in [0,1] */
1063 GLfloat BorderColor
[4]; /**< unclamped */
1064 GLchan _BorderChan
[4]; /**< clamped, as GLchan */
1065 /** \name Wrap modes
1066 * Are GL_CLAMP, REPEAT, GL_CLAMP_TO_EDGE, and GL_CLAMP_TO_BORDER_ARB. */
1072 GLenum MinFilter
; /**< minification filter */
1073 GLenum MagFilter
; /**< magnification filter */
1074 GLfloat MinLod
; /**< min lambda, OpenGL 1.2 */
1075 GLfloat MaxLod
; /**< max lambda, OpenGL 1.2 */
1076 GLfloat LodBias
; /**< OpenGL 1.4 */
1077 GLint BaseLevel
; /**< min mipmap level, OpenGL 1.2 */
1078 GLint MaxLevel
; /**< max mipmap level, OpenGL 1.2 */
1079 GLfloat MaxAnisotropy
; /**< GL_EXT_texture_filter_anisotropic */
1080 GLboolean CompareFlag
; /**< GL_SGIX_shadow */
1081 GLenum CompareOperator
; /**< GL_SGIX_shadow */
1082 GLfloat ShadowAmbient
;
1083 GLenum CompareMode
; /**< GL_ARB_shadow */
1084 GLenum CompareFunc
; /**< GL_ARB_shadow */
1085 GLenum DepthMode
; /**< GL_ARB_depth_texture */
1086 GLint _MaxLevel
; /**< actual max mipmap level (q in the spec) */
1087 GLfloat _MaxLambda
; /**< = _MaxLevel - BaseLevel (q - b in spec) */
1088 GLboolean GenerateMipmap
; /**< GL_SGIS_generate_mipmap */
1089 GLboolean _IsPowerOfTwo
; /**< Are all image dimensions powers of two? */
1091 struct gl_texture_image
*Image
[MAX_TEXTURE_LEVELS
];
1094 * \name Texture cube faces
1096 * Image[] is alias for *PosX[MAX_TEXTURE_LEVELS];
1099 struct gl_texture_image
*NegX
[MAX_TEXTURE_LEVELS
];
1100 struct gl_texture_image
*PosY
[MAX_TEXTURE_LEVELS
];
1101 struct gl_texture_image
*NegY
[MAX_TEXTURE_LEVELS
];
1102 struct gl_texture_image
*PosZ
[MAX_TEXTURE_LEVELS
];
1103 struct gl_texture_image
*NegZ
[MAX_TEXTURE_LEVELS
];
1106 /** GL_EXT_paletted_texture */
1107 struct gl_color_table Palette
;
1109 GLboolean Complete
; /**< Is texture object complete? */
1110 struct gl_texture_object
*Next
; /**< Next in linked list */
1113 * \name For device driver
1116 void *DriverData
; /**< Arbitrary device driver data */
1122 * Texture unit record
1124 struct gl_texture_unit
{
1125 GLuint Enabled
; /**< bitmask of TEXTURE_*_BIT flags */
1126 GLuint _ReallyEnabled
; /**< 0 or exactly one of TEXTURE_*_BIT flags */
1128 GLenum EnvMode
; /**< GL_MODULATE, GL_DECAL, GL_BLEND, etc. */
1129 GLfloat EnvColor
[4];
1130 GLuint TexGenEnabled
; /**< Bitwise-OR of [STRQ]_BIT values */
1131 /** \name Tex coord generation mode
1132 * Either GL_OBJECT_LINEAR, GL_EYE_LINEAR or GL_SPHERE_MAP. */
1143 GLuint _GenFlags
; /**< bitwise or of GenBit[STRQ] */
1144 GLfloat ObjectPlaneS
[4];
1145 GLfloat ObjectPlaneT
[4];
1146 GLfloat ObjectPlaneR
[4];
1147 GLfloat ObjectPlaneQ
[4];
1148 GLfloat EyePlaneS
[4];
1149 GLfloat EyePlaneT
[4];
1150 GLfloat EyePlaneR
[4];
1151 GLfloat EyePlaneQ
[4];
1152 GLfloat LodBias
; /**< for biasing mipmap levels */
1155 * \name GL_EXT_texture_env_combine
1158 GLenum CombineModeRGB
; /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */
1159 GLenum CombineModeA
; /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */
1160 GLenum CombineSourceRGB
[3]; /**< GL_PRIMARY_COLOR, GL_TEXTURE, etc. */
1161 GLenum CombineSourceA
[3]; /**< GL_PRIMARY_COLOR, GL_TEXTURE, etc. */
1162 GLenum CombineOperandRGB
[3]; /**< SRC_COLOR, ONE_MINUS_SRC_COLOR, etc */
1163 GLenum CombineOperandA
[3]; /**< SRC_ALPHA, ONE_MINUS_SRC_ALPHA, etc */
1164 GLuint CombineScaleShiftRGB
; /**< 0, 1 or 2 */
1165 GLuint CombineScaleShiftA
; /**< 0, 1 or 2 */
1168 struct gl_texture_object
*Current1D
;
1169 struct gl_texture_object
*Current2D
;
1170 struct gl_texture_object
*Current3D
;
1171 struct gl_texture_object
*CurrentCubeMap
; /**< GL_ARB_texture_cube_map */
1172 struct gl_texture_object
*CurrentRect
; /**< GL_NV_texture_rectangle */
1174 struct gl_texture_object
*_Current
; /**< Points to really enabled tex obj */
1176 struct gl_texture_object Saved1D
; /**< only used by glPush/PopAttrib */
1177 struct gl_texture_object Saved2D
;
1178 struct gl_texture_object Saved3D
;
1179 struct gl_texture_object SavedCubeMap
;
1180 struct gl_texture_object SavedRect
;
1182 /* GL_SGI_texture_color_table */
1183 struct gl_color_table ColorTable
;
1184 struct gl_color_table ProxyColorTable
;
1185 GLboolean ColorTableEnabled
;
1190 * Texture attributes
1192 struct gl_texture_attrib
{
1197 GLuint CurrentUnit
; /**< Active texture unit */
1198 GLuint _EnabledUnits
; /**< one bit set for each really-enabled unit */
1199 GLuint _EnabledCoordUnits
; /**< one bit per enabled coordinate unit */
1200 GLuint _GenFlags
; /**< for texgen */
1201 GLuint _TexGenEnabled
;
1202 GLuint _TexMatEnabled
;
1205 struct gl_texture_unit Unit
[MAX_TEXTURE_UNITS
];
1207 struct gl_texture_object
*Proxy1D
;
1208 struct gl_texture_object
*Proxy2D
;
1209 struct gl_texture_object
*Proxy3D
;
1210 struct gl_texture_object
*ProxyCubeMap
;
1211 struct gl_texture_object
*ProxyRect
;
1213 /** GL_EXT_shared_texture_palette */
1214 GLboolean SharedPalette
;
1215 struct gl_color_table Palette
;
1220 * Transformation attributes.
1222 struct gl_transform_attrib
{
1223 GLenum MatrixMode
; /**< Matrix mode */
1224 GLfloat EyeUserPlane
[MAX_CLIP_PLANES
][4]; /**< User clip planes */
1225 GLfloat _ClipUserPlane
[MAX_CLIP_PLANES
][4]; /**< derived */
1226 GLuint ClipPlanesEnabled
; /**< on/off bitmask */
1227 GLboolean Normalize
; /**< Normalize all normals? */
1228 GLboolean RescaleNormals
; /**< GL_EXT_rescale_normal */
1229 GLboolean RasterPositionUnclipped
; /**< GL_IBM_rasterpos_clip */
1234 * Viewport attributes.
1236 struct gl_viewport_attrib
{
1237 GLint X
, Y
; /**< position */
1238 GLsizei Width
, Height
; /**< size */
1239 GLfloat Near
, Far
; /**< Depth buffer range */
1240 GLmatrix _WindowMap
; /**< Mapping transformation as a matrix. */
1245 * Node for the attribute stack
1247 struct gl_attrib_node
{
1250 struct gl_attrib_node
*next
;
1255 * GL_ARB_vertex_buffer_object buffer object
1257 struct gl_buffer_object
{
1263 GLvoid
*Pointer
; /**< Only valid while buffer is mapped */
1264 GLuint Size
; /**< Size of data array in bytes */
1265 GLubyte
*Data
; /**< The storage */
1271 * Client pixel packing/unpacking attributes
1273 struct gl_pixelstore_attrib
{
1278 GLint ImageHeight
; /**< for GL_EXT_texture3D */
1279 GLint SkipImages
; /**< for GL_EXT_texture3D */
1280 GLboolean SwapBytes
;
1282 GLboolean ClientStorage
; /**< GL_APPLE_client_storage */
1283 GLboolean Invert
; /**< GL_MESA_pack_invert */
1287 #define CA_CLIENT_DATA 0x1 /**< Data not allocated by mesa */
1291 * Client vertex array attributes
1293 struct gl_client_array
{
1296 GLsizei Stride
; /**< user-specified stride */
1297 GLsizei StrideB
; /**< actual stride in bytes */
1300 GLuint Enabled
; /**< one of the _NEW_ARRAY_ bits */
1301 GLboolean Normalized
; /**< GL_ARB_vertex_program */
1303 /**< GL_ARB_vertex_buffer_object */
1304 struct gl_buffer_object
*BufferObj
;
1311 struct gl_array_attrib
{
1312 struct gl_client_array Vertex
; /**< client data descriptors */
1313 struct gl_client_array Normal
;
1314 struct gl_client_array Color
;
1315 struct gl_client_array SecondaryColor
;
1316 struct gl_client_array FogCoord
;
1317 struct gl_client_array Index
;
1318 struct gl_client_array TexCoord
[MAX_TEXTURE_COORD_UNITS
];
1319 struct gl_client_array EdgeFlag
;
1321 struct gl_client_array VertexAttrib
[VERT_ATTRIB_MAX
]; /**< GL_NV_vertex_program */
1323 GLint TexCoordInterleaveFactor
;
1324 GLint ActiveTexture
; /**< Client Active Texture */
1325 GLuint LockFirst
; /**< GL_EXT_compiled_vertex_array */
1326 GLuint LockCount
; /**< GL_EXT_compiled_vertex_array */
1328 GLuint _Enabled
; /**< _NEW_ARRAY_* - bit set if array enabled */
1329 GLuint NewState
; /**< _NEW_ARRAY_* */
1331 #if FEATURE_ARB_vertex_buffer_object
1332 struct gl_buffer_object
*NullBufferObj
;
1333 struct gl_buffer_object
*ArrayBufferObj
;
1334 struct gl_buffer_object
*ElementArrayBufferObj
;
1339 struct gl_feedback
{
1341 GLuint _Mask
; /* FB_* bits */
1349 * Selection attributes.
1351 struct gl_selection
{
1352 GLuint
*Buffer
; /**< selection buffer */
1353 GLuint BufferSize
; /**< size of the selection buffer */
1354 GLuint BufferCount
; /**< number of values in the selection buffer */
1355 GLuint Hits
; /**< number of records in the selection buffer */
1356 GLuint NameStackDepth
; /**< name stack depth */
1357 GLuint NameStack
[MAX_NAME_STACK_DEPTH
]; /**< name stack */
1358 GLboolean HitFlag
; /**< hit flag */
1359 GLfloat HitMinZ
; /**< minimum hit depth */
1360 GLfloat HitMaxZ
; /**< maximum hit depth */
1365 * 1-D Evaluator control points
1369 GLuint Order
; /**< Number of control points */
1370 GLfloat u1
, u2
, du
; /**< u1, u2, 1.0/(u2-u1) */
1371 GLfloat
*Points
; /**< Points to contiguous control points */
1376 * 2-D Evaluator control points
1380 GLuint Uorder
; /**< Number of control points in U dimension */
1381 GLuint Vorder
; /**< Number of control points in V dimension */
1384 GLfloat
*Points
; /**< Points to contiguous control points */
1389 * All evaluator control points
1391 struct gl_evaluators
1397 struct gl_1d_map Map1Vertex3
;
1398 struct gl_1d_map Map1Vertex4
;
1399 struct gl_1d_map Map1Index
;
1400 struct gl_1d_map Map1Color4
;
1401 struct gl_1d_map Map1Normal
;
1402 struct gl_1d_map Map1Texture1
;
1403 struct gl_1d_map Map1Texture2
;
1404 struct gl_1d_map Map1Texture3
;
1405 struct gl_1d_map Map1Texture4
;
1406 struct gl_1d_map Map1Attrib
[16]; /**< GL_NV_vertex_program */
1413 struct gl_2d_map Map2Vertex3
;
1414 struct gl_2d_map Map2Vertex4
;
1415 struct gl_2d_map Map2Index
;
1416 struct gl_2d_map Map2Color4
;
1417 struct gl_2d_map Map2Normal
;
1418 struct gl_2d_map Map2Texture1
;
1419 struct gl_2d_map Map2Texture2
;
1420 struct gl_2d_map Map2Texture3
;
1421 struct gl_2d_map Map2Texture4
;
1422 struct gl_2d_map Map2Attrib
[16]; /**< GL_NV_vertex_program */
1428 * NV_fragment_program runtime state
1432 GLfloat Temporaries
[MAX_NV_FRAGMENT_PROGRAM_TEMPS
][4];
1433 GLfloat Inputs
[MAX_NV_FRAGMENT_PROGRAM_INPUTS
][4];
1434 GLfloat Outputs
[MAX_NV_FRAGMENT_PROGRAM_OUTPUTS
][4];
1435 GLuint CondCodes
[4];
1440 * Names of the various vertex/fragment register files
1444 PROGRAM_TEMPORARY
= 10,
1447 PROGRAM_LOCAL_PARAM
,
1449 PROGRAM_NAMED_PARAM
,
1455 /* Vertex and fragment instructions */
1456 struct vp_instruction
;
1457 struct fp_instruction
;
1459 struct program_parameter_list
;
1463 * Base class for any kind of program object
1468 GLubyte
*String
; /* Null-terminated program text */
1470 GLenum Format
; /* String encoding format */
1473 GLfloat LocalParams
[MAX_PROGRAM_LOCAL_PARAMS
][4];
1474 GLuint NumInstructions
; /* GL_ARB_vertex/fragment_program */
1475 GLuint NumTemporaries
;
1476 GLuint NumParameters
;
1477 GLuint NumAttributes
;
1478 GLuint NumAddressRegs
;
1482 /** Vertex program object */
1483 struct vertex_program
1485 struct program Base
; /* base class */
1486 struct vp_instruction
*Instructions
; /* Compiled instructions */
1487 GLboolean IsPositionInvariant
; /* GL_NV_vertex_program1_1 */
1488 GLuint InputsRead
; /* Bitmask of which input regs are read */
1489 GLuint OutputsWritten
; /* Bitmask of which output regs are written to */
1493 /** Fragment program object */
1494 struct fragment_program
1496 struct program Base
; /**< base class */
1497 struct fp_instruction
*Instructions
; /**< Compiled instructions */
1498 GLuint InputsRead
; /**< Bitmask of which input regs are read */
1499 GLuint OutputsWritten
; /**< Bitmask of which output regs are written to */
1500 GLuint TexturesUsed
[MAX_TEXTURE_IMAGE_UNITS
]; /**< TEXTURE_x_INDEX bitmask */
1501 GLuint NumAluInstructions
; /**< GL_ARB_fragment_program */
1502 GLuint NumTexInstructions
;
1503 GLuint NumTexIndirections
;
1504 struct program_parameter_list
*Parameters
; /**< array [NumParameters] */
1509 * State common to vertex and fragment programs.
1511 struct program_state
{
1512 GLint ErrorPos
; /* GL_PROGRAM_ERROR_POSITION_NV */
1513 const char *ErrorString
; /* GL_PROGRAM_ERROR_STRING_NV */
1518 * State vars for GL_NV_vertex_program
1520 struct vertex_program_state
1522 GLboolean Enabled
; /**< GL_VERTEX_PROGRAM_NV */
1523 GLboolean PointSizeEnabled
; /**< GL_VERTEX_PROGRAM_POINT_SIZE_NV */
1524 GLboolean TwoSideEnabled
; /**< GL_VERTEX_PROGRAM_TWO_SIDE_NV */
1525 struct vertex_program
*Current
; /**< ptr to currently bound program */
1527 GLenum TrackMatrix
[MAX_NV_VERTEX_PROGRAM_PARAMS
/ 4];
1528 GLenum TrackMatrixTransform
[MAX_NV_VERTEX_PROGRAM_PARAMS
/ 4];
1530 GLfloat Parameters
[MAX_NV_VERTEX_PROGRAM_PARAMS
][4]; /* Env params */
1531 /* Only used during program execution (may be moved someday): */
1532 GLfloat Temporaries
[MAX_NV_VERTEX_PROGRAM_TEMPS
][4];
1533 GLfloat Inputs
[MAX_NV_VERTEX_PROGRAM_INPUTS
][4];
1534 GLfloat Outputs
[MAX_NV_VERTEX_PROGRAM_OUTPUTS
][4];
1535 GLint AddressReg
[4];
1537 #if FEATURE_MESA_program_debug
1538 GLprogramcallbackMESA Callback
;
1539 GLvoid
*CallbackData
;
1540 GLboolean CallbackEnabled
;
1541 GLuint CurrentPosition
;
1547 * State for GL_ARB/NV_fragment_program
1549 struct fragment_program_state
1551 GLboolean Enabled
; /* GL_VERTEX_PROGRAM_NV */
1552 struct fragment_program
*Current
; /* ptr to currently bound program */
1553 struct fp_machine Machine
; /* machine state */
1554 GLfloat Parameters
[MAX_NV_FRAGMENT_PROGRAM_PARAMS
][4]; /* Env params */
1556 #if FEATURE_MESA_program_debug
1557 GLprogramcallbackMESA Callback
;
1558 GLvoid
*CallbackData
;
1559 GLboolean CallbackEnabled
;
1560 GLuint CurrentPosition
;
1566 * State for GL_ARB_occlusion_query
1568 struct occlusion_state
1571 GLuint CurrentQueryObject
;
1572 GLuint PassedCounter
;
1573 struct _mesa_HashTable
*QueryObjects
;
1578 * State which can be shared by multiple contexts:
1580 struct gl_shared_state
1582 _glthread_Mutex Mutex
; /**< for thread safety */
1583 GLint RefCount
; /**< Reference count */
1584 struct _mesa_HashTable
*DisplayList
; /**< Display lists hash table */
1585 struct _mesa_HashTable
*TexObjects
; /**< Texture objects hash table */
1586 struct gl_texture_object
*TexObjectList
;/**< Linked list of texture objects */
1589 * \name Default texture objects (shared by all multi-texture units)
1592 struct gl_texture_object
*Default1D
;
1593 struct gl_texture_object
*Default2D
;
1594 struct gl_texture_object
*Default3D
;
1595 struct gl_texture_object
*DefaultCubeMap
;
1596 struct gl_texture_object
*DefaultRect
;
1600 * \name GL_NV_vertex/_program
1603 struct _mesa_HashTable
*Programs
;
1604 #if FEATURE_ARB_vertex_program
1605 struct program
*DefaultVertexProgram
;
1607 #if FEATURE_ARB_fragment_program
1608 struct program
*DefaultFragmentProgram
;
1612 #if FEATURE_ARB_vertex_buffer_object
1613 struct _mesa_HashTable
*BufferObjects
;
1616 void *DriverData
; /**< Device driver shared state */
1623 * A "frame buffer" is a color buffer and its optional ancillary buffers:
1624 * depth, accum, stencil, and software-simulated alpha buffers.
1625 * In C++ terms, think of this as a base class from which device drivers
1626 * will make derived classes.
1628 struct gl_frame_buffer
1630 GLvisual Visual
; /**< The corresponding visual */
1632 GLuint Width
, Height
; /**< size of frame buffer in pixels */
1634 GLboolean UseSoftwareDepthBuffer
;
1635 GLboolean UseSoftwareAccumBuffer
;
1636 GLboolean UseSoftwareStencilBuffer
;
1637 GLboolean UseSoftwareAlphaBuffers
;
1639 /** \name Software depth (aka Z) buffer */
1641 GLvoid
*DepthBuffer
; /**< array [Width*Height] of GLushort or GLuint*/
1644 /** \name Software stencil buffer */
1646 GLstencil
*Stencil
; /**< array [Width*Height] of GLstencil values */
1649 /** \name Software accumulation buffer */
1651 GLaccum
*Accum
; /**< array [4*Width*Height] of GLaccum values */
1654 /** \name Software alpha planes */
1656 GLvoid
*FrontLeftAlpha
; /**< array [Width*Height] of GLubyte */
1657 GLvoid
*BackLeftAlpha
; /**< array [Width*Height] of GLubyte */
1658 GLvoid
*FrontRightAlpha
; /**< array [Width*Height] of GLubyte */
1659 GLvoid
*BackRightAlpha
; /**< array [Width*Height] of GLubyte */
1663 * \name Drawing bounds
1665 * Intersection of window size and scissor box
1668 GLint _Xmin
; /**< inclusive */
1669 GLint _Ymin
; /**< inclusive */
1670 GLint _Xmax
; /**< exclusive */
1671 GLint _Ymax
; /**< exclusive */
1677 * Constants which may be overridden by device driver during context creation
1678 * but are never changed after that.
1682 GLint MaxTextureLevels
; /**< Maximum number of allowed mipmap levels. */
1683 GLint Max3DTextureLevels
; /**< Maximum number of allowed mipmap levels for 3D texture targets. */
1684 GLint MaxCubeTextureLevels
; /**< Maximum number of allowed mipmap levels for GL_ARB_texture_cube_map */
1685 GLint MaxTextureRectSize
; /* GL_NV_texture_rectangle */
1686 GLuint MaxTextureCoordUnits
;
1687 GLuint MaxTextureImageUnits
;
1688 GLuint MaxTextureUnits
; /* = MAX(CoordUnits, ImageUnits) */
1689 GLfloat MaxTextureMaxAnisotropy
; /* GL_EXT_texture_filter_anisotropic */
1690 GLfloat MaxTextureLodBias
; /* GL_EXT_texture_lod_bias */
1691 GLuint MaxArrayLockSize
;
1693 GLfloat MinPointSize
, MaxPointSize
; /* aliased */
1694 GLfloat MinPointSizeAA
, MaxPointSizeAA
; /* antialiased */
1695 GLfloat PointSizeGranularity
;
1696 GLfloat MinLineWidth
, MaxLineWidth
; /* aliased */
1697 GLfloat MinLineWidthAA
, MaxLineWidthAA
; /* antialiased */
1698 GLfloat LineWidthGranularity
;
1699 GLuint NumAuxBuffers
;
1700 GLuint MaxColorTableSize
;
1701 GLuint MaxConvolutionWidth
;
1702 GLuint MaxConvolutionHeight
;
1703 GLuint MaxClipPlanes
;
1705 GLfloat MaxShininess
; /* GL_NV_light_max_exponent */
1706 GLfloat MaxSpotExponent
; /* GL_NV_light_max_exponent */
1707 /* GL_ARB_vertex_program */
1708 GLuint MaxVertexProgramInstructions
;
1709 GLuint MaxVertexProgramAttribs
;
1710 GLuint MaxVertexProgramTemps
;
1711 GLuint MaxVertexProgramLocalParams
;
1712 GLuint MaxVertexProgramEnvParams
;
1713 GLuint MaxVertexProgramAddressRegs
;
1714 /* GL_ARB_fragment_program */
1715 GLuint MaxFragmentProgramInstructions
;
1716 GLuint MaxFragmentProgramAttribs
;
1717 GLuint MaxFragmentProgramTemps
;
1718 GLuint MaxFragmentProgramLocalParams
;
1719 GLuint MaxFragmentProgramEnvParams
;
1720 GLuint MaxFragmentProgramAddressRegs
;
1721 GLuint MaxFragmentProgramAluInstructions
;
1722 GLuint MaxFragmentProgramTexInstructions
;
1723 GLuint MaxFragmentProgramTexIndirections
;
1724 /* vertex or fragment program */
1725 GLuint MaxProgramMatrices
;
1726 GLuint MaxProgramMatrixStackDepth
;
1731 * List of extensions.
1733 struct gl_extensions
1736 * \name Flags to quickly test if certain extensions are available.
1738 * Not every extension needs to have such a flag, but it's encouraged.
1741 GLboolean dummy
; /* don't remove this! */
1742 GLboolean ARB_depth_texture
;
1743 GLboolean ARB_fragment_program
;
1744 GLboolean ARB_imaging
;
1745 GLboolean ARB_multisample
;
1746 GLboolean ARB_multitexture
;
1747 GLboolean ARB_occlusion_query
;
1748 GLboolean ARB_point_sprite
;
1749 GLboolean ARB_shadow
;
1750 GLboolean ARB_texture_border_clamp
;
1751 GLboolean ARB_texture_compression
;
1752 GLboolean ARB_texture_cube_map
;
1753 GLboolean ARB_texture_env_combine
;
1754 GLboolean ARB_texture_env_crossbar
;
1755 GLboolean ARB_texture_env_dot3
;
1756 GLboolean ARB_texture_mirrored_repeat
;
1757 GLboolean ARB_texture_non_power_of_two
;
1758 GLboolean ARB_vertex_buffer_object
;
1759 GLboolean ARB_vertex_program
;
1760 GLboolean ARB_window_pos
;
1761 GLboolean ATI_texture_mirror_once
;
1762 GLboolean ATI_texture_env_combine3
;
1763 GLboolean EXT_blend_color
;
1764 GLboolean EXT_blend_func_separate
;
1765 GLboolean EXT_blend_logic_op
;
1766 GLboolean EXT_blend_minmax
;
1767 GLboolean EXT_blend_subtract
;
1768 GLboolean EXT_convolution
;
1769 GLboolean EXT_compiled_vertex_array
;
1770 GLboolean EXT_depth_bounds_test
;
1771 GLboolean EXT_fog_coord
;
1772 GLboolean EXT_histogram
;
1773 GLboolean EXT_multi_draw_arrays
;
1774 GLboolean EXT_paletted_texture
;
1775 GLboolean EXT_point_parameters
;
1776 GLboolean EXT_shadow_funcs
;
1777 GLboolean EXT_secondary_color
;
1778 GLboolean EXT_shared_texture_palette
;
1779 GLboolean EXT_stencil_wrap
;
1780 GLboolean EXT_stencil_two_side
;
1781 GLboolean EXT_texture3D
;
1782 GLboolean EXT_texture_compression_s3tc
;
1783 GLboolean EXT_texture_env_add
;
1784 GLboolean EXT_texture_env_combine
;
1785 GLboolean EXT_texture_env_dot3
;
1786 GLboolean EXT_texture_filter_anisotropic
;
1787 GLboolean EXT_texture_lod_bias
;
1788 GLboolean EXT_texture_mirror_clamp
;
1789 GLboolean EXT_vertex_array_set
;
1790 GLboolean HP_occlusion_test
;
1791 GLboolean IBM_rasterpos_clip
;
1792 GLboolean IBM_multimode_draw_arrays
;
1793 GLboolean MESA_pack_invert
;
1794 GLboolean MESA_packed_depth_stencil
;
1795 GLboolean MESA_program_debug
;
1796 GLboolean MESA_resize_buffers
;
1797 GLboolean MESA_ycbcr_texture
;
1798 GLboolean NV_blend_square
;
1799 GLboolean NV_fragment_program
;
1800 GLboolean NV_point_sprite
;
1801 GLboolean NV_texture_rectangle
;
1802 GLboolean NV_vertex_program
;
1803 GLboolean NV_vertex_program1_1
;
1804 GLboolean SGI_color_matrix
;
1805 GLboolean SGI_color_table
;
1806 GLboolean SGI_texture_color_table
;
1807 GLboolean SGIS_generate_mipmap
;
1808 GLboolean SGIS_pixel_texture
;
1809 GLboolean SGIS_texture_edge_clamp
;
1810 GLboolean SGIX_depth_texture
;
1811 GLboolean SGIX_pixel_texture
;
1812 GLboolean SGIX_shadow
;
1813 GLboolean SGIX_shadow_ambient
; /* or GL_ARB_shadow_ambient */
1814 GLboolean TDFX_texture_compression_FXT1
;
1815 GLboolean APPLE_client_storage
;
1817 /* The extension string */
1818 const GLubyte
*String
;
1823 * A stack of matrices (projection, modelview, color, texture, etc).
1827 GLmatrix
*Top
; /**< points into Stack */
1828 GLmatrix
*Stack
; /**< array [MaxDepth] of GLmatrix */
1829 GLuint Depth
; /**< 0 <= Depth < MaxDepth */
1830 GLuint MaxDepth
; /**< size of Stack[] array */
1831 GLuint DirtyFlag
; /**< _NEW_MODELVIEW or _NEW_PROJECTION, for example */
1836 * \name Bits for image transfer operations
1838 * \sa __GLcontextRec::ImageTransferState.
1841 #define IMAGE_SCALE_BIAS_BIT 0x1
1842 #define IMAGE_SHIFT_OFFSET_BIT 0x2
1843 #define IMAGE_MAP_COLOR_BIT 0x4
1844 #define IMAGE_COLOR_TABLE_BIT 0x8
1845 #define IMAGE_CONVOLUTION_BIT 0x10
1846 #define IMAGE_POST_CONVOLUTION_SCALE_BIAS 0x20
1847 #define IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT 0x40
1848 #define IMAGE_COLOR_MATRIX_BIT 0x80
1849 #define IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT 0x100
1850 #define IMAGE_HISTOGRAM_BIT 0x200
1851 #define IMAGE_MIN_MAX_BIT 0x400
1853 /** Transfer ops up to convolution */
1854 #define IMAGE_PRE_CONVOLUTION_BITS (IMAGE_SCALE_BIAS_BIT | \
1855 IMAGE_SHIFT_OFFSET_BIT | \
1856 IMAGE_MAP_COLOR_BIT | \
1857 IMAGE_COLOR_TABLE_BIT)
1859 /** Transfer ops after convolution */
1860 #define IMAGE_POST_CONVOLUTION_BITS (IMAGE_POST_CONVOLUTION_SCALE_BIAS | \
1861 IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT | \
1862 IMAGE_COLOR_MATRIX_BIT | \
1863 IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT |\
1864 IMAGE_HISTOGRAM_BIT | \
1870 * \name Bits to indicate what state has changed.
1875 #define _NEW_MODELVIEW 0x1 /**< __GLcontextRec::ModelView */
1876 #define _NEW_PROJECTION 0x2 /**< __GLcontextRec::Projection */
1877 #define _NEW_TEXTURE_MATRIX 0x4 /**< __GLcontextRec::TextureMatrix */
1878 #define _NEW_COLOR_MATRIX 0x8 /**< __GLcontextRec::ColorMatrix */
1879 #define _NEW_ACCUM 0x10 /**< __GLcontextRec::Accum */
1880 #define _NEW_COLOR 0x20 /**< __GLcontextRec::Color */
1881 #define _NEW_DEPTH 0x40 /**< __GLcontextRec::Depth */
1882 #define _NEW_EVAL 0x80 /**< __GLcontextRec::Eval, __GLcontextRec::EvalMap */
1883 #define _NEW_FOG 0x100 /**< __GLcontextRec::Fog */
1884 #define _NEW_HINT 0x200 /**< __GLcontextRec::Hint */
1885 #define _NEW_LIGHT 0x400 /**< __GLcontextRec::Light */
1886 #define _NEW_LINE 0x800 /**< __GLcontextRec::Line */
1887 #define _NEW_PIXEL 0x1000 /**< __GLcontextRec::Pixel */
1888 #define _NEW_POINT 0x2000 /**< __GLcontextRec::Point */
1889 #define _NEW_POLYGON 0x4000 /**< __GLcontextRec::Polygon */
1890 #define _NEW_POLYGONSTIPPLE 0x8000 /**< __GLcontextRec::PolygonStipple */
1891 #define _NEW_SCISSOR 0x10000 /**< __GLcontextRec::Scissor */
1892 #define _NEW_STENCIL 0x20000 /**< __GLcontextRec::Stencil */
1893 #define _NEW_TEXTURE 0x40000 /**< __GLcontextRec::Texture */
1894 #define _NEW_TRANSFORM 0x80000 /**< __GLcontextRec::Transform */
1895 #define _NEW_VIEWPORT 0x100000 /**< __GLcontextRec::Viewport */
1896 #define _NEW_PACKUNPACK 0x200000 /**< __GLcontextRec::Pack, __GLcontextRec::Unpack */
1897 #define _NEW_ARRAY 0x400000 /**< __GLcontextRec::Array */
1898 #define _NEW_RENDERMODE 0x800000 /**< __GLcontextRec::RenderMode, __GLcontextRec::Feedback, __GLcontextRec::Select */
1899 #define _NEW_BUFFERS 0x1000000 /**< __GLcontextRec::Visual, __GLcontextRec::DrawBuffer, */
1900 #define _NEW_MULTISAMPLE 0x2000000 /**< __GLcontextRec::Multisample */
1901 #define _NEW_TRACK_MATRIX 0x4000000 /**< __GLcontextRec::VertexProgram */
1902 #define _NEW_PROGRAM 0x8000000 /**< __GLcontextRec::VertexProgram */
1908 * \name Bits to track array state changes
1910 * Also used to summarize array enabled.
1913 #define _NEW_ARRAY_VERTEX VERT_BIT_POS
1914 #define _NEW_ARRAY_WEIGHT VERT_BIT_WEIGHT
1915 #define _NEW_ARRAY_NORMAL VERT_BIT_NORMAL
1916 #define _NEW_ARRAY_COLOR0 VERT_BIT_COLOR0
1917 #define _NEW_ARRAY_COLOR1 VERT_BIT_COLOR1
1918 #define _NEW_ARRAY_FOGCOORD VERT_BIT_FOG
1919 #define _NEW_ARRAY_INDEX VERT_BIT_SIX
1920 #define _NEW_ARRAY_EDGEFLAG VERT_BIT_SEVEN
1921 #define _NEW_ARRAY_TEXCOORD_0 VERT_BIT_TEX0
1922 #define _NEW_ARRAY_TEXCOORD_1 VERT_BIT_TEX1
1923 #define _NEW_ARRAY_TEXCOORD_2 VERT_BIT_TEX2
1924 #define _NEW_ARRAY_TEXCOORD_3 VERT_BIT_TEX3
1925 #define _NEW_ARRAY_TEXCOORD_4 VERT_BIT_TEX4
1926 #define _NEW_ARRAY_TEXCOORD_5 VERT_BIT_TEX5
1927 #define _NEW_ARRAY_TEXCOORD_6 VERT_BIT_TEX6
1928 #define _NEW_ARRAY_TEXCOORD_7 VERT_BIT_TEX7
1929 #define _NEW_ARRAY_ATTRIB_0 0x1 /* alias conventional arrays */
1930 #define _NEW_ARRAY_ALL 0xffffffff
1933 #define _NEW_ARRAY_TEXCOORD(i) (_NEW_ARRAY_TEXCOORD_0 << (i))
1934 #define _NEW_ARRAY_ATTRIB(i) (_NEW_ARRAY_ATTRIB_0 << (i))
1939 * \name A bunch of flags that we think might be useful to drivers.
1941 * Set in the __GLcontextRec::_TriangleCaps bitfield.
1944 #define DD_FLATSHADE 0x1
1945 #define DD_SEPARATE_SPECULAR 0x2
1946 #define DD_TRI_CULL_FRONT_BACK 0x4 /* special case on some hw */
1947 #define DD_TRI_LIGHT_TWOSIDE 0x8
1948 #define DD_TRI_UNFILLED 0x10
1949 #define DD_TRI_SMOOTH 0x20
1950 #define DD_TRI_STIPPLE 0x40
1951 #define DD_TRI_OFFSET 0x80
1952 #define DD_LINE_SMOOTH 0x100
1953 #define DD_LINE_STIPPLE 0x200
1954 #define DD_LINE_WIDTH 0x400
1955 #define DD_POINT_SMOOTH 0x800
1956 #define DD_POINT_SIZE 0x1000
1957 #define DD_POINT_ATTEN 0x2000
1962 * \name Define the state changes under which each of these bits might change
1965 #define _DD_NEW_FLATSHADE _NEW_LIGHT
1966 #define _DD_NEW_SEPARATE_SPECULAR (_NEW_LIGHT | _NEW_FOG)
1967 #define _DD_NEW_TRI_CULL_FRONT_BACK _NEW_POLYGON
1968 #define _DD_NEW_TRI_LIGHT_TWOSIDE _NEW_LIGHT
1969 #define _DD_NEW_TRI_UNFILLED _NEW_POLYGON
1970 #define _DD_NEW_TRI_SMOOTH _NEW_POLYGON
1971 #define _DD_NEW_TRI_STIPPLE _NEW_POLYGON
1972 #define _DD_NEW_TRI_OFFSET _NEW_POLYGON
1973 #define _DD_NEW_LINE_SMOOTH _NEW_LINE
1974 #define _DD_NEW_LINE_STIPPLE _NEW_LINE
1975 #define _DD_NEW_LINE_WIDTH _NEW_LINE
1976 #define _DD_NEW_POINT_SMOOTH _NEW_POINT
1977 #define _DD_NEW_POINT_SIZE _NEW_POINT
1978 #define _DD_NEW_POINT_ATTEN _NEW_POINT
1982 #define _MESA_NEW_NEED_EYE_COORDS (_NEW_LIGHT | \
1987 #define _MESA_NEW_NEED_NORMALS (_NEW_LIGHT | \
1990 #define _IMAGE_NEW_TRANSFER_STATE (_NEW_PIXEL | _NEW_COLOR_MATRIX)
1996 * Forward declaration of display list data types:
1999 typedef union node Node
;
2002 /* This has to be included here. */
2006 #define NUM_VERTEX_FORMAT_ENTRIES (sizeof(GLvertexformat) / sizeof(void *))
2009 * Core Mesa's support for tnl modules:
2011 struct gl_tnl_module
{
2013 * Vertex format to be lazily swapped into current dispatch.
2015 GLvertexformat
*Current
;
2018 * \name Record of functions swapped out.
2019 * On restore, only need to swap these functions back in.
2022 void *Swapped
[NUM_VERTEX_FORMAT_ENTRIES
][2];
2031 * This is the central context data structure for Mesa. Almost all
2032 * OpenGL state is contained in this structure.
2033 * Think of this as a base class from which device drivers will derive
2036 struct __GLcontextRec
{
2038 * \name OS related interfaces.
2040 * These \b must be the first members of this structure, because they are
2041 * exposed to the outside world (i.e. GLX extension).
2044 __GLimports imports
;
2045 __GLexports exports
;
2048 /** State possibly shared with other contexts in the address space */
2049 struct gl_shared_state
*Shared
;
2051 /** \name API function pointer tables */
2053 struct _glapi_table
*Save
; /**< Display list save functions */
2054 struct _glapi_table
*Exec
; /**< Execute functions */
2055 struct _glapi_table
*CurrentDispatch
; /**< == Save or Exec !! */
2058 GLboolean ExecPrefersFloat
; /**< What preference for color conversion? */
2059 GLboolean SavePrefersFloat
;
2062 GLframebuffer
*DrawBuffer
; /**< buffer for writing */
2063 GLframebuffer
*ReadBuffer
; /**< buffer for reading */
2066 * Device driver function pointer table
2068 struct dd_function_table Driver
;
2070 void *DriverCtx
; /**< Points to device driver context/state */
2071 void *DriverMgrCtx
; /**< Points to device driver manager (optional)*/
2073 /** Core/Driver constants */
2074 struct gl_constants Const
;
2076 /** \name The various 4x4 matrix stacks */
2078 struct matrix_stack ModelviewMatrixStack
;
2079 struct matrix_stack ProjectionMatrixStack
;
2080 struct matrix_stack ColorMatrixStack
;
2081 struct matrix_stack TextureMatrixStack
[MAX_TEXTURE_COORD_UNITS
];
2082 struct matrix_stack ProgramMatrixStack
[MAX_PROGRAM_MATRICES
];
2083 struct matrix_stack
*CurrentStack
; /**< Points to one of the above stacks */
2086 /** Combined modelview and projection matrix */
2087 GLmatrix _ModelProjectMatrix
;
2089 /** \name Display lists */
2091 GLuint CallDepth
; /**< Current recursion calling depth */
2092 GLboolean ExecuteFlag
; /**< Execute GL commands? */
2093 GLboolean CompileFlag
; /**< Compile GL commands into display list? */
2094 Node
*CurrentListPtr
; /**< Head of list being compiled */
2095 GLuint CurrentListNum
; /**< Number of the list being compiled */
2096 Node
*CurrentBlock
; /**< Pointer to current block of nodes */
2097 GLuint CurrentPos
; /**< Index into current block of nodes */
2101 struct gl_extensions Extensions
;
2103 /** \name Renderer attribute stack */
2105 GLuint AttribStackDepth
;
2106 struct gl_attrib_node
*AttribStack
[MAX_ATTRIB_STACK_DEPTH
];
2109 /** \name Renderer attribute groups
2111 * We define a struct for each attribute group to make pushing and popping
2112 * attributes easy. Also it's a good organization.
2115 struct gl_accum_attrib Accum
; /**< Accumulation buffer attributes */
2116 struct gl_colorbuffer_attrib Color
; /**< Color buffers attributes */
2117 struct gl_current_attrib Current
; /**< Current attributes */
2118 struct gl_depthbuffer_attrib Depth
; /**< Depth buffer attributes */
2119 struct gl_eval_attrib Eval
; /**< Eval attributes */
2120 struct gl_fog_attrib Fog
; /**< Fog attributes */
2121 struct gl_hint_attrib Hint
; /**< Hint attributes */
2122 struct gl_light_attrib Light
; /**< Light attributes */
2123 struct gl_line_attrib Line
; /**< Line attributes */
2124 struct gl_list_attrib List
; /**< List attributes */
2125 struct gl_multisample_attrib Multisample
;
2126 struct gl_pixel_attrib Pixel
; /**< Pixel attributes */
2127 struct gl_point_attrib Point
; /**< Point attributes */
2128 struct gl_polygon_attrib Polygon
; /**< Polygon attributes */
2129 GLuint PolygonStipple
[32]; /**< Polygon stipple */
2130 struct gl_scissor_attrib Scissor
; /**< Scissor attributes */
2131 struct gl_stencil_attrib Stencil
; /**< Stencil buffer attributes */
2132 struct gl_texture_attrib Texture
; /**< Texture attributes */
2133 struct gl_transform_attrib Transform
; /**< Transformation attributes */
2134 struct gl_viewport_attrib Viewport
; /**< Viewport attributes */
2137 /** \name Other attribute groups */
2139 struct gl_histogram_attrib Histogram
;
2140 struct gl_minmax_attrib MinMax
;
2141 struct gl_convolution_attrib Convolution1D
;
2142 struct gl_convolution_attrib Convolution2D
;
2143 struct gl_convolution_attrib Separable2D
;
2146 /** \name Client attribute stack */
2148 GLuint ClientAttribStackDepth
;
2149 struct gl_attrib_node
*ClientAttribStack
[MAX_CLIENT_ATTRIB_STACK_DEPTH
];
2152 /** \name Client attribute groups */
2154 struct gl_array_attrib Array
; /**< Vertex arrays */
2155 struct gl_pixelstore_attrib Pack
; /**< Pixel packing */
2156 struct gl_pixelstore_attrib Unpack
; /**< Pixel unpacking */
2158 struct gl_evaluators EvalMap
; /**< All evaluators */
2159 struct gl_feedback Feedback
; /**< Feedback */
2160 struct gl_selection Select
; /**< Selection */
2162 struct gl_color_table ColorTable
; /**< Pre-convolution */
2163 struct gl_color_table ProxyColorTable
; /**< Pre-convolution */
2164 struct gl_color_table PostConvolutionColorTable
;
2165 struct gl_color_table ProxyPostConvolutionColorTable
;
2166 struct gl_color_table PostColorMatrixColorTable
;
2167 struct gl_color_table ProxyPostColorMatrixColorTable
;
2169 struct program_state Program
; /**< for vertex or fragment progs */
2170 struct vertex_program_state VertexProgram
; /**< GL_NV_vertex_program */
2171 struct fragment_program_state FragmentProgram
; /**< GL_NV_fragment_program */
2173 struct occlusion_state Occlusion
; /**< GL_ARB_occlusion_query */
2175 GLenum ErrorValue
; /**< Last error code */
2176 GLenum RenderMode
; /**< either GL_RENDER, GL_SELECT, GL_FEEDBACK */
2177 GLuint NewState
; /**< bitwise-or of _NEW_* flags */
2180 /** \name Derived */
2182 GLuint _TriangleCaps
; /**< bitwise-or of DD_* flags */
2183 GLuint _ImageTransferState
;/**< bitwise-or of IMAGE_*_BIT flags */
2184 GLfloat _EyeZDir
[3];
2185 GLfloat _ModelViewInvScale
;
2186 GLuint _NeedEyeCoords
;
2187 GLuint _ForceEyeCoords
;
2188 GLboolean _RotateMode
;
2189 GLenum _CurrentProgram
; /* currently executing program */
2191 struct gl_shine_tab
*_ShineTable
[2]; /**< Active shine tables */
2192 struct gl_shine_tab
*_ShineTabList
; /**< MRU list of inactive shine tables */
2195 struct gl_list_extensions listext
; /**< driver dlist extensions */
2198 GLboolean OcclusionResult
; /**< for GL_HP_occlusion_test */
2199 GLboolean OcclusionResultSaved
; /**< for GL_HP_occlusion_test */
2200 GLuint _Facing
; /**< This is a hack for 2-sided stencil test.
2202 * We don't have a better way to communicate this value from
2203 * swrast_setup to swrast. */
2206 /** \name Z buffer stuff */
2208 GLuint DepthMax
; /**< Max depth buffer value */
2209 GLfloat DepthMaxF
; /**< Float max depth buffer value */
2210 GLfloat MRD
; /**< minimum resolvable difference in Z values */
2213 /** Should 3Dfx Glide driver catch signals? */
2214 GLboolean CatchSignals
;
2216 /** \name For debugging/development only */
2219 GLboolean FirstTimeCurrent
;
2222 /** Dither disable via MESA_NO_DITHER env var */
2225 GLboolean Rendering
;
2227 #if defined(MESA_TRACE)
2228 struct _glapi_table
*TraceDispatch
;
2229 trace_context_t
*TraceCtx
;
2231 void *TraceDispatch
;
2235 /** Core tnl module support */
2236 struct gl_tnl_module TnlModule
;
2239 * \name Hooks for module contexts.
2241 * These will eventually live in the driver or elsewhere.
2244 void *swrast_context
;
2245 void *swsetup_context
;
2246 void *swtnl_context
;
2248 void *acache_context
;
2254 /** The string names for GL_POINT, GL_LINE_LOOP, etc */
2255 extern const char *_mesa_prim_name
[GL_POLYGON
+4];
2259 extern int MESA_VERBOSE
;
2260 extern int MESA_DEBUG_FLAGS
;
2262 # define MESA_VERBOSE 0
2263 # define MESA_DEBUG_FLAGS 0
2271 VERBOSE_VARRAY
= 0x0001,
2272 VERBOSE_TEXTURE
= 0x0002,
2273 VERBOSE_IMMEDIATE
= 0x0004,
2274 VERBOSE_PIPELINE
= 0x0008,
2275 VERBOSE_DRIVER
= 0x0010,
2276 VERBOSE_STATE
= 0x0020,
2277 VERBOSE_API
= 0x0040,
2278 VERBOSE_DISPLAY_LIST
= 0x0100,
2279 VERBOSE_LIGHTING
= 0x0200,
2280 VERBOSE_PRIMS
= 0x0400,
2281 VERBOSE_VERTS
= 0x0800
2286 DEBUG_ALWAYS_FLUSH
= 0x1
2291 #define Elements(x) sizeof(x)/sizeof(*(x))
2297 * \param ctx GL context.
2298 * \param newstate new state.
2300 * Checks if dd_function_table::NeedFlush is marked to flush stored vertices,
2301 * and calls dd_function_table::FlushVertices if so. Marks
2302 * __GLcontextRec::NewState with \p newstate.
2304 * \todo Eventually let the driver specify what state changes require a flush:
2306 #define FLUSH_VERTICES(ctx, newstate) \
2308 if (MESA_VERBOSE & VERBOSE_STATE) \
2309 _mesa_debug(ctx, "FLUSH_VERTICES in %s\n", __FUNCTION__); \
2310 if (ctx->Driver.NeedFlush & FLUSH_STORED_VERTICES) \
2311 ctx->Driver.FlushVertices(ctx, FLUSH_STORED_VERTICES); \
2312 ctx->NewState |= newstate; \
2316 * Flush current state.
2318 * \param ctx GL context.
2319 * \param newstate new state.
2321 * Checks if dd_function_table::NeedFlush is marked to flush current state,
2322 * and calls dd_function_table::FlushVertices if so. Marks
2323 * __GLcontextRec::NewState with \p newstate.
2325 #define FLUSH_CURRENT(ctx, newstate) \
2327 if (MESA_VERBOSE & VERBOSE_STATE) \
2328 _mesa_debug(ctx, "FLUSH_CURRENT in %s\n", __FUNCTION__); \
2329 if (ctx->Driver.NeedFlush & FLUSH_UPDATE_CURRENT) \
2330 ctx->Driver.FlushVertices(ctx, FLUSH_UPDATE_CURRENT); \
2331 ctx->NewState |= newstate; \
2335 * Macro to assert that the API call was made outside the
2336 * glBegin()/glEnd() pair, with return value.
2338 * \param ctx GL context.
2339 * \param retval value to return value in case the assertion fails.
2341 #define ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, retval) \
2343 if (ctx->Driver.CurrentExecPrimitive != PRIM_OUTSIDE_BEGIN_END) { \
2344 _mesa_error( ctx, GL_INVALID_OPERATION, "begin/end" ); \
2350 * Macro to assert that the API call was made outside the
2351 * glBegin()/glEnd() pair.
2353 * \param ctx GL context.
2355 #define ASSERT_OUTSIDE_BEGIN_END(ctx) \
2357 if (ctx->Driver.CurrentExecPrimitive != PRIM_OUTSIDE_BEGIN_END) { \
2358 _mesa_error( ctx, GL_INVALID_OPERATION, "begin/end" ); \
2364 * Macro to assert that the API call was made outside the
2365 * glBegin()/glEnd() pair and flush the vertices.
2367 * \param ctx GL context.
2369 #define ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx) \
2371 ASSERT_OUTSIDE_BEGIN_END(ctx); \
2372 FLUSH_VERTICES(ctx, 0); \
2376 * Macro to assert that the API call was made outside the
2377 * glBegin()/glEnd() pair and flush the vertices, with return value.
2379 * \param ctx GL context.
2380 * \param retval value to return value in case the assertion fails.
2382 #define ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH_WITH_RETVAL(ctx, retval) \
2384 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, retval); \
2385 FLUSH_VERTICES(ctx, 0); \
2389 #endif /* TYPES_H */