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-2004 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"
42 #include "math/m_matrix.h" /* GLmatrix */
46 * Color channel data type.
49 typedef GLubyte GLchan
;
51 #define CHAN_MAXF 255.0F
52 #define CHAN_TYPE GL_UNSIGNED_BYTE
54 typedef GLushort GLchan
;
55 #define CHAN_MAX 65535
56 #define CHAN_MAXF 65535.0F
57 #define CHAN_TYPE GL_UNSIGNED_SHORT
59 typedef GLfloat GLchan
;
61 #define CHAN_MAXF 1.0F
62 #define CHAN_TYPE GL_FLOAT
64 #error "illegal number of color channel bits"
69 * Accumulation buffer data type.
72 typedef GLbyte GLaccum
;
74 typedef GLshort GLaccum
;
76 typedef GLfloat GLaccum
;
78 # error "illegal number of accumulation bits"
83 * Stencil buffer data type.
86 typedef GLubyte GLstencil
;
87 # define STENCIL_MAX 0xff
88 #elif STENCIL_BITS==16
89 typedef GLushort GLstencil
;
90 # define STENCIL_MAX 0xffff
92 # error "illegal number of stencil bits"
97 * Depth buffer data type.
99 * \note Must be 32-bits!
101 typedef GLuint GLdepth
;
105 * Fixed point data type.
109 * Fixed point arithmetic macros
111 #ifndef FIXED_FRAC_BITS
112 #define FIXED_FRAC_BITS 11
115 #define FIXED_SHIFT FIXED_FRAC_BITS
116 #define FIXED_ONE (1 << FIXED_SHIFT)
117 #define FIXED_HALF (1 << (FIXED_SHIFT-1))
118 #define FIXED_FRAC_MASK (FIXED_ONE - 1)
119 #define FIXED_INT_MASK (~FIXED_FRAC_MASK)
120 #define FIXED_EPSILON 1
121 #define FIXED_SCALE ((float) FIXED_ONE)
122 #define FIXED_DBL_SCALE ((double) FIXED_ONE)
123 #define FloatToFixed(X) (IROUND((X) * FIXED_SCALE))
124 #define FixedToDouble(X) ((X) * (1.0 / FIXED_DBL_SCALE))
125 #define IntToFixed(I) ((I) << FIXED_SHIFT)
126 #define FixedToInt(X) ((X) >> FIXED_SHIFT)
127 #define FixedToUns(X) (((unsigned int)(X)) >> FIXED_SHIFT)
128 #define FixedCeil(X) (((X) + FIXED_ONE - FIXED_EPSILON) & FIXED_INT_MASK)
129 #define FixedFloor(X) ((X) & FIXED_INT_MASK)
130 #define FixedToFloat(X) ((X) * (1.0F / FIXED_SCALE))
131 #define PosFloatToFixed(X) FloatToFixed(X)
132 #define SignedFloatToFixed(X) FloatToFixed(X)
137 * \name Some forward type declarations
140 struct _mesa_HashTable
;
141 struct gl_texture_image
;
142 struct gl_texture_object
;
143 typedef struct __GLcontextRec GLcontext
;
144 typedef struct __GLcontextModesRec GLvisual
;
145 typedef struct gl_frame_buffer GLframebuffer
;
146 struct gl_pixelstore_attrib
;
147 struct gl_texture_format
;
153 * These define the aliases between numbered vertex attributes and
154 * conventional OpenGL vertex attributes. We use these values in
155 * quite a few places.
161 VERT_ATTRIB_WEIGHT
= 1,
162 VERT_ATTRIB_NORMAL
= 2,
163 VERT_ATTRIB_COLOR0
= 3,
164 VERT_ATTRIB_COLOR1
= 4,
167 VERT_ATTRIB_SEVEN
= 7,
168 VERT_ATTRIB_TEX0
= 8,
169 VERT_ATTRIB_TEX1
= 9,
170 VERT_ATTRIB_TEX2
= 10,
171 VERT_ATTRIB_TEX3
= 11,
172 VERT_ATTRIB_TEX4
= 12,
173 VERT_ATTRIB_TEX5
= 13,
174 VERT_ATTRIB_TEX6
= 14,
175 VERT_ATTRIB_TEX7
= 15,
179 /* These are used in bitfields in many places */
180 #define VERT_BIT_POS (1 << VERT_ATTRIB_POS)
181 #define VERT_BIT_WEIGHT (1 << VERT_ATTRIB_WEIGHT)
182 #define VERT_BIT_NORMAL (1 << VERT_ATTRIB_NORMAL)
183 #define VERT_BIT_COLOR0 (1 << VERT_ATTRIB_COLOR0)
184 #define VERT_BIT_COLOR1 (1 << VERT_ATTRIB_COLOR1)
185 #define VERT_BIT_FOG (1 << VERT_ATTRIB_FOG)
186 #define VERT_BIT_SIX (1 << VERT_ATTRIB_SIX)
187 #define VERT_BIT_SEVEN (1 << VERT_ATTRIB_SEVEN)
188 #define VERT_BIT_TEX0 (1 << VERT_ATTRIB_TEX0)
189 #define VERT_BIT_TEX1 (1 << VERT_ATTRIB_TEX1)
190 #define VERT_BIT_TEX2 (1 << VERT_ATTRIB_TEX2)
191 #define VERT_BIT_TEX3 (1 << VERT_ATTRIB_TEX3)
192 #define VERT_BIT_TEX4 (1 << VERT_ATTRIB_TEX4)
193 #define VERT_BIT_TEX5 (1 << VERT_ATTRIB_TEX5)
194 #define VERT_BIT_TEX6 (1 << VERT_ATTRIB_TEX6)
195 #define VERT_BIT_TEX7 (1 << VERT_ATTRIB_TEX7)
197 #define VERT_BIT_TEX(u) (1 << (VERT_ATTRIB_TEX0 + (u)))
200 /* Fragment programs use a different but related set of attributes:
203 /* Fragment input registers / attributes */
204 #define FRAG_ATTRIB_WPOS 0
205 #define FRAG_ATTRIB_COL0 1
206 #define FRAG_ATTRIB_COL1 2
207 #define FRAG_ATTRIB_FOGC 3
208 #define FRAG_ATTRIB_TEX0 4
209 #define FRAG_ATTRIB_TEX1 5
210 #define FRAG_ATTRIB_TEX2 6
211 #define FRAG_ATTRIB_TEX3 7
212 #define FRAG_ATTRIB_TEX4 8
213 #define FRAG_ATTRIB_TEX5 9
214 #define FRAG_ATTRIB_TEX6 10
215 #define FRAG_ATTRIB_TEX7 11
217 /* Bitmasks for the above */
218 #define FRAG_BIT_WPOS (1 << FRAG_ATTRIB_WPOS)
219 #define FRAG_BIT_COL0 (1 << FRAG_ATTRIB_COL0)
220 #define FRAG_BIT_COL1 (1 << FRAG_ATTRIB_COL1)
221 #define FRAG_BIT_FOGC (1 << FRAG_ATTRIB_FOGC)
222 #define FRAG_BIT_TEX0 (1 << FRAG_ATTRIB_TEX0)
223 #define FRAG_BIT_TEX1 (1 << FRAG_ATTRIB_TEX1)
224 #define FRAG_BIT_TEX2 (1 << FRAG_ATTRIB_TEX2)
225 #define FRAG_BIT_TEX3 (1 << FRAG_ATTRIB_TEX3)
226 #define FRAG_BIT_TEX4 (1 << FRAG_ATTRIB_TEX4)
227 #define FRAG_BIT_TEX5 (1 << FRAG_ATTRIB_TEX5)
228 #define FRAG_BIT_TEX6 (1 << FRAG_ATTRIB_TEX6)
229 #define FRAG_BIT_TEX7 (1 << FRAG_ATTRIB_TEX7)
231 #define FRAG_BITS_TEX_ANY (FRAG_BIT_TEX0| \
242 * Bits for each basic buffer in a complete framebuffer.
243 * When glDrawBuffer(GL_FRONT_AND_BACK) is called (non-stereo),
244 * _DrawDestMask will be set to (DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT),
245 * for example. Also passed to ctx->Driver.Clear() to indicate which
249 #define DD_FRONT_LEFT_BIT 0x1
250 #define DD_FRONT_RIGHT_BIT 0x2
251 #define DD_BACK_LEFT_BIT 0x4
252 #define DD_BACK_RIGHT_BIT 0x8
253 #define DD_AUX0_BIT 0x10
254 #define DD_AUX1_BIT 0x20
255 #define DD_AUX2_BIT 0x40
256 #define DD_AUX3_BIT 0x80
257 #define DD_DEPTH_BIT GL_DEPTH_BUFFER_BIT /* 0x00000100 */
258 #define DD_ACCUM_BIT GL_ACCUM_BUFFER_BIT /* 0x00000200 */
259 #define DD_STENCIL_BIT GL_STENCIL_BUFFER_BIT /* 0x00000400 */
264 * Maximum number of temporary vertices required for clipping.
266 * Used in array_cache and tnl modules.
268 #define MAX_CLIPPED_VERTICES ((2 * (6 + MAX_CLIP_PLANES))+1)
272 * Data structure for color tables
274 struct gl_color_table
{
275 GLenum Format
; /**< GL_ALPHA, GL_RGB, GL_RGB, etc */
277 GLuint Size
; /**< number of entries (rows) in table */
278 GLvoid
*Table
; /**< points to data of <Type> */
279 GLenum Type
; /**< GL_UNSIGNED_BYTE or GL_FLOAT */
284 GLubyte LuminanceSize
;
285 GLubyte IntensitySize
;
290 * \name Bit flags used for updating material values.
293 #define MAT_ATTRIB_FRONT_AMBIENT 0
294 #define MAT_ATTRIB_BACK_AMBIENT 1
295 #define MAT_ATTRIB_FRONT_DIFFUSE 2
296 #define MAT_ATTRIB_BACK_DIFFUSE 3
297 #define MAT_ATTRIB_FRONT_SPECULAR 4
298 #define MAT_ATTRIB_BACK_SPECULAR 5
299 #define MAT_ATTRIB_FRONT_EMISSION 6
300 #define MAT_ATTRIB_BACK_EMISSION 7
301 #define MAT_ATTRIB_FRONT_SHININESS 8
302 #define MAT_ATTRIB_BACK_SHININESS 9
303 #define MAT_ATTRIB_FRONT_INDEXES 10
304 #define MAT_ATTRIB_BACK_INDEXES 11
305 #define MAT_ATTRIB_MAX 12
307 #define MAT_ATTRIB_AMBIENT(f) (MAT_ATTRIB_FRONT_AMBIENT+(f))
308 #define MAT_ATTRIB_DIFFUSE(f) (MAT_ATTRIB_FRONT_DIFFUSE+(f))
309 #define MAT_ATTRIB_SPECULAR(f) (MAT_ATTRIB_FRONT_SPECULAR+(f))
310 #define MAT_ATTRIB_EMISSION(f) (MAT_ATTRIB_FRONT_EMISSION+(f))
311 #define MAT_ATTRIB_SHININESS(f)(MAT_ATTRIB_FRONT_SHININESS+(f))
312 #define MAT_ATTRIB_INDEXES(f) (MAT_ATTRIB_FRONT_INDEXES+(f))
314 #define MAT_INDEX_AMBIENT 0
315 #define MAT_INDEX_DIFFUSE 1
316 #define MAT_INDEX_SPECULAR 2
318 #define MAT_BIT_FRONT_AMBIENT (1<<MAT_ATTRIB_FRONT_AMBIENT)
319 #define MAT_BIT_BACK_AMBIENT (1<<MAT_ATTRIB_BACK_AMBIENT)
320 #define MAT_BIT_FRONT_DIFFUSE (1<<MAT_ATTRIB_FRONT_DIFFUSE)
321 #define MAT_BIT_BACK_DIFFUSE (1<<MAT_ATTRIB_BACK_DIFFUSE)
322 #define MAT_BIT_FRONT_SPECULAR (1<<MAT_ATTRIB_FRONT_SPECULAR)
323 #define MAT_BIT_BACK_SPECULAR (1<<MAT_ATTRIB_BACK_SPECULAR)
324 #define MAT_BIT_FRONT_EMISSION (1<<MAT_ATTRIB_FRONT_EMISSION)
325 #define MAT_BIT_BACK_EMISSION (1<<MAT_ATTRIB_BACK_EMISSION)
326 #define MAT_BIT_FRONT_SHININESS (1<<MAT_ATTRIB_FRONT_SHININESS)
327 #define MAT_BIT_BACK_SHININESS (1<<MAT_ATTRIB_BACK_SHININESS)
328 #define MAT_BIT_FRONT_INDEXES (1<<MAT_ATTRIB_FRONT_INDEXES)
329 #define MAT_BIT_BACK_INDEXES (1<<MAT_ATTRIB_BACK_INDEXES)
332 #define FRONT_MATERIAL_BITS (MAT_BIT_FRONT_EMISSION | \
333 MAT_BIT_FRONT_AMBIENT | \
334 MAT_BIT_FRONT_DIFFUSE | \
335 MAT_BIT_FRONT_SPECULAR | \
336 MAT_BIT_FRONT_SHININESS | \
337 MAT_BIT_FRONT_INDEXES)
339 #define BACK_MATERIAL_BITS (MAT_BIT_BACK_EMISSION | \
340 MAT_BIT_BACK_AMBIENT | \
341 MAT_BIT_BACK_DIFFUSE | \
342 MAT_BIT_BACK_SPECULAR | \
343 MAT_BIT_BACK_SHININESS | \
344 MAT_BIT_BACK_INDEXES)
346 #define ALL_MATERIAL_BITS (FRONT_MATERIAL_BITS | BACK_MATERIAL_BITS)
350 #define EXP_TABLE_SIZE 512 /**< Specular exponent lookup table sizes */
351 #define SHINE_TABLE_SIZE 256 /**< Material shininess lookup table sizes */
354 * Material shininess lookup table.
356 struct gl_shine_tab
{
357 struct gl_shine_tab
*next
, *prev
;
358 GLfloat tab
[SHINE_TABLE_SIZE
+1];
368 struct gl_light
*next
; /**< double linked list with sentinel */
369 struct gl_light
*prev
;
371 GLfloat Ambient
[4]; /**< ambient color */
372 GLfloat Diffuse
[4]; /**< diffuse color */
373 GLfloat Specular
[4]; /**< specular color */
374 GLfloat EyePosition
[4]; /**< position in eye coordinates */
375 GLfloat EyeDirection
[4]; /**< spotlight dir in eye coordinates */
376 GLfloat SpotExponent
;
377 GLfloat SpotCutoff
; /**< in degrees */
378 GLfloat _CosCutoff
; /**< = MAX(0, cos(SpotCutoff)) */
379 GLfloat ConstantAttenuation
;
380 GLfloat LinearAttenuation
;
381 GLfloat QuadraticAttenuation
;
382 GLboolean Enabled
; /**< On/off flag */
385 * \name Derived fields
388 GLuint _Flags
; /**< State */
390 GLfloat _Position
[4]; /**< position in eye/obj coordinates */
391 GLfloat _VP_inf_norm
[3]; /**< Norm direction to infinite light */
392 GLfloat _h_inf_norm
[3]; /**< Norm( _VP_inf_norm + <0,0,1> ) */
393 GLfloat _NormDirection
[4]; /**< normalized spotlight direction */
394 GLfloat _VP_inf_spot_attenuation
;
396 GLfloat _SpotExpTable
[EXP_TABLE_SIZE
][2]; /**< to replace a pow() call */
397 GLfloat _MatAmbient
[2][3]; /**< material ambient * light ambient */
398 GLfloat _MatDiffuse
[2][3]; /**< material diffuse * light diffuse */
399 GLfloat _MatSpecular
[2][3]; /**< material spec * light specular */
400 GLfloat _dli
; /**< CI diffuse light intensity */
401 GLfloat _sli
; /**< CI specular light intensity */
409 struct gl_lightmodel
{
410 GLfloat Ambient
[4]; /**< ambient color */
411 GLboolean LocalViewer
; /**< Local (or infinite) view point? */
412 GLboolean TwoSide
; /**< Two (or one) sided lighting? */
413 GLenum ColorControl
; /**< either GL_SINGLE_COLOR
414 * or GL_SEPARATE_SPECULAR_COLOR */
423 GLfloat Attrib
[MAT_ATTRIB_MAX
][4];
428 * Accumulation buffer attributes.
430 struct gl_accum_attrib
{
431 GLfloat ClearColor
[4]; /**< Accumulation buffer clear color */
436 * Color buffers attributes.
438 struct gl_colorbuffer_attrib
{
439 GLuint ClearIndex
; /**< Index to use for glClear */
440 GLclampf ClearColor
[4]; /**< Color to use for glClear */
442 GLuint IndexMask
; /**< Color index write mask */
443 GLubyte ColorMask
[4]; /**< Each flag is 0xff or 0x0 */
445 GLenum DrawBuffer
; /**< Which buffer to draw into */
446 GLbitfield _DrawDestMask
; /**< bitmask of DD_*_BIT bits */
449 * \name alpha testing
452 GLboolean AlphaEnabled
; /**< Alpha test enabled flag */
453 GLenum AlphaFunc
; /**< Alpha test function */
454 GLclampf AlphaRef
; /**< Alpha reference value */
461 GLboolean BlendEnabled
; /**< Blending enabled flag */
462 GLenum BlendSrcRGB
; /**< Blending source operator */
463 GLenum BlendDstRGB
; /**< Blending destination operator */
464 GLenum BlendSrcA
; /**< GL_INGR_blend_func_separate */
465 GLenum BlendDstA
; /**< GL_INGR_blend_func_separate */
466 GLenum BlendEquationRGB
; /**< Blending equation */
467 GLenum BlendEquationA
; /**< GL_EXT_blend_equation_separate */
468 GLfloat BlendColor
[4]; /**< Blending color */
475 GLenum LogicOp
; /**< Logic operator */
476 GLboolean IndexLogicOpEnabled
; /**< Color index logic op enabled flag */
477 GLboolean ColorLogicOpEnabled
; /**< RGBA logic op enabled flag */
478 GLboolean _LogicOpEnabled
; /**< RGBA logic op + EXT_blend_logic_op enabled flag */
481 GLboolean DitherFlag
; /**< Dither enable flag */
486 * Current attributes.
488 struct gl_current_attrib
{
490 * \name Values valid only when FLUSH_VERTICES has been called.
493 GLfloat Attrib
[VERT_ATTRIB_MAX
][4]; /**< Current vertex attributes
494 * indexed by VERT_ATTRIB_* */
495 GLfloat Index
; /**< Current color index */
496 GLboolean EdgeFlag
; /**< Current edge flag */
500 * \name Values are always valid.
502 * \note BTW, note how similar this set of attributes is to the SWvertex
503 * data type in the software rasterizer...
506 GLfloat RasterPos
[4]; /**< Current raster position */
507 GLfloat RasterDistance
; /**< Current raster distance */
508 GLfloat RasterColor
[4]; /**< Current raster color */
509 GLfloat RasterSecondaryColor
[4]; /**< Current raster secondary color */
510 GLfloat RasterIndex
; /**< Current raster index */
511 GLfloat RasterTexCoords
[MAX_TEXTURE_UNITS
][4];/**< Current raster texcoords */
512 GLboolean RasterPosValid
; /**< Raster pos valid flag */
518 * Depth buffer attributes.
520 struct gl_depthbuffer_attrib
{
521 GLenum Func
; /**< Function for depth buffer compare */
522 GLclampd Clear
; /**< Value to clear depth buffer to */
523 GLboolean Test
; /**< Depth buffering enabled flag */
524 GLboolean Mask
; /**< Depth buffer writable? */
525 GLboolean OcclusionTest
; /**< GL_HP_occlusion_test */
526 GLboolean BoundsTest
; /**< GL_EXT_depth_bounds_test */
527 GLfloat BoundsMin
, BoundsMax
;/**< GL_EXT_depth_bounds_test */
532 * glEnable()/glDisable() attributes.
534 struct gl_enable_attrib
{
536 GLboolean AutoNormal
;
539 GLboolean ColorMaterial
;
540 GLboolean ColorTable
; /* SGI_color_table */
541 GLboolean PostColorMatrixColorTable
; /* SGI_color_table */
542 GLboolean PostConvolutionColorTable
; /* SGI_color_table */
543 GLboolean Convolution1D
;
544 GLboolean Convolution2D
;
545 GLboolean Separable2D
;
551 GLboolean Light
[MAX_LIGHTS
];
553 GLboolean LineSmooth
;
554 GLboolean LineStipple
;
555 GLboolean IndexLogicOp
;
556 GLboolean ColorLogicOp
;
557 GLboolean Map1Color4
;
559 GLboolean Map1Normal
;
560 GLboolean Map1TextureCoord1
;
561 GLboolean Map1TextureCoord2
;
562 GLboolean Map1TextureCoord3
;
563 GLboolean Map1TextureCoord4
;
564 GLboolean Map1Vertex3
;
565 GLboolean Map1Vertex4
;
566 GLboolean Map1Attrib
[16]; /* GL_NV_vertex_program */
567 GLboolean Map2Color4
;
569 GLboolean Map2Normal
;
570 GLboolean Map2TextureCoord1
;
571 GLboolean Map2TextureCoord2
;
572 GLboolean Map2TextureCoord3
;
573 GLboolean Map2TextureCoord4
;
574 GLboolean Map2Vertex3
;
575 GLboolean Map2Vertex4
;
576 GLboolean Map2Attrib
[16]; /* GL_NV_vertex_program */
579 GLboolean PixelTexture
;
580 GLboolean PointSmooth
;
581 GLboolean PolygonOffsetPoint
;
582 GLboolean PolygonOffsetLine
;
583 GLboolean PolygonOffsetFill
;
584 GLboolean PolygonSmooth
;
585 GLboolean PolygonStipple
;
586 GLboolean RescaleNormals
;
589 GLboolean MultisampleEnabled
; /* GL_ARB_multisample */
590 GLboolean SampleAlphaToCoverage
; /* GL_ARB_multisample */
591 GLboolean SampleAlphaToOne
; /* GL_ARB_multisample */
592 GLboolean SampleCoverage
; /* GL_ARB_multisample */
593 GLboolean SampleCoverageInvert
; /* GL_ARB_multisample */
594 GLboolean RasterPositionUnclipped
; /* GL_IBM_rasterpos_clip */
595 GLuint Texture
[MAX_TEXTURE_IMAGE_UNITS
];
596 GLuint TexGen
[MAX_TEXTURE_COORD_UNITS
];
597 /* SGI_texture_color_table */
598 GLboolean TextureColorTable
[MAX_TEXTURE_IMAGE_UNITS
];
599 /* GL_NV_vertex_program */
600 GLboolean VertexProgram
;
601 GLboolean VertexProgramPointSize
;
602 GLboolean VertexProgramTwoSide
;
603 /* GL_ARB_point_sprite / GL_NV_point_sprite */
604 GLboolean PointSprite
;
611 struct gl_eval_attrib
{
616 GLboolean Map1Color4
;
618 GLboolean Map1Normal
;
619 GLboolean Map1TextureCoord1
;
620 GLboolean Map1TextureCoord2
;
621 GLboolean Map1TextureCoord3
;
622 GLboolean Map1TextureCoord4
;
623 GLboolean Map1Vertex3
;
624 GLboolean Map1Vertex4
;
625 GLboolean Map1Attrib
[16]; /* GL_NV_vertex_program */
626 GLboolean Map2Color4
;
628 GLboolean Map2Normal
;
629 GLboolean Map2TextureCoord1
;
630 GLboolean Map2TextureCoord2
;
631 GLboolean Map2TextureCoord3
;
632 GLboolean Map2TextureCoord4
;
633 GLboolean Map2Vertex3
;
634 GLboolean Map2Vertex4
;
635 GLboolean Map2Attrib
[16]; /* GL_NV_vertex_program */
636 GLboolean AutoNormal
;
640 * \name Map Grid endpoints and divisions and calculated du values
644 GLfloat MapGrid1u1
, MapGrid1u2
, MapGrid1du
;
645 GLint MapGrid2un
, MapGrid2vn
;
646 GLfloat MapGrid2u1
, MapGrid2u2
, MapGrid2du
;
647 GLfloat MapGrid2v1
, MapGrid2v2
, MapGrid2dv
;
655 struct gl_fog_attrib
{
656 GLboolean Enabled
; /**< Fog enabled flag */
657 GLfloat Color
[4]; /**< Fog color */
658 GLfloat Density
; /**< Density >= 0.0 */
659 GLfloat Start
; /**< Start distance in eye coords */
660 GLfloat End
; /**< End distance in eye coords */
661 GLfloat Index
; /**< Fog index */
662 GLenum Mode
; /**< Fog mode */
663 GLboolean ColorSumEnabled
;
664 GLenum FogCoordinateSource
; /**< GL_EXT_fog_coord */
671 * Values are always one of GL_FASTEST, GL_NICEST, or GL_DONT_CARE.
673 struct gl_hint_attrib
{
674 GLenum PerspectiveCorrection
;
677 GLenum PolygonSmooth
;
679 GLenum ClipVolumeClipping
; /**< GL_EXT_clip_volume_hint */
680 GLenum TextureCompression
; /**< GL_ARB_texture_compression */
681 GLenum GenerateMipmap
; /**< GL_SGIS_generate_mipmap */
686 * Histogram attributes.
688 struct gl_histogram_attrib
{
689 GLuint Width
; /**< number of table entries */
690 GLint Format
; /**< GL_ALPHA, GL_RGB, etc */
691 GLuint Count
[HISTOGRAM_TABLE_SIZE
][4]; /**< the histogram */
692 GLboolean Sink
; /**< terminate image transfer? */
693 GLubyte RedSize
; /**< Bits per counter */
697 GLubyte LuminanceSize
;
701 struct gl_minmax_attrib
{
704 GLfloat Min
[4], Max
[4]; /**< RGBA */
708 struct gl_convolution_attrib
{
710 GLenum InternalFormat
;
713 GLfloat Filter
[MAX_CONVOLUTION_WIDTH
* MAX_CONVOLUTION_HEIGHT
* 4];
717 #define LIGHT_SPOT 0x1
718 #define LIGHT_LOCAL_VIEWER 0x2
719 #define LIGHT_POSITIONAL 0x4
720 #define LIGHT_NEED_VERTICES (LIGHT_POSITIONAL|LIGHT_LOCAL_VIEWER)
723 * Lighting attributes.
725 struct gl_light_attrib
{
726 struct gl_light Light
[MAX_LIGHTS
]; /**< Array of lights */
727 struct gl_lightmodel Model
; /**< Lighting model */
730 * Must flush FLUSH_VERTICES before referencing:
733 struct gl_material Material
; /**< Includes front & back values */
736 GLboolean Enabled
; /**< Lighting enabled flag */
737 GLenum ShadeModel
; /**< GL_FLAT or GL_SMOOTH */
738 GLenum ColorMaterialFace
; /**< GL_FRONT, BACK or FRONT_AND_BACK */
739 GLenum ColorMaterialMode
; /**< GL_AMBIENT, GL_DIFFUSE, etc */
740 GLuint ColorMaterialBitmask
; /**< bitmask formed from Face and Mode */
741 GLboolean ColorMaterialEnabled
;
743 struct gl_light EnabledList
; /**< List sentinel */
746 * Derived for optimizations:
749 GLboolean _NeedEyeCoords
;
750 GLboolean _NeedVertices
; /**< Use fast shader? */
751 GLuint _Flags
; /**< LIGHT_* flags, see above */
752 GLfloat _BaseColor
[2][3];
760 struct gl_line_attrib
{
761 GLboolean SmoothFlag
; /**< GL_LINE_SMOOTH enabled? */
762 GLboolean StippleFlag
; /**< GL_LINE_STIPPLE enabled? */
763 GLushort StipplePattern
; /**< Stipple pattern */
764 GLint StippleFactor
; /**< Stipple repeat factor */
765 GLfloat Width
; /**< Line width */
766 GLfloat _Width
; /**< Clamped Line width */
770 struct gl_list_attrib
{
775 struct gl_list_instruction
{
777 void (*Execute
)( GLcontext
*ctx
, void *data
);
778 void (*Destroy
)( GLcontext
*ctx
, void *data
);
779 void (*Print
)( GLcontext
*ctx
, void *data
);
782 #define MAX_DLIST_EXT_OPCODES 16
784 struct gl_list_extensions
{
785 struct gl_list_instruction Opcode
[MAX_DLIST_EXT_OPCODES
];
790 struct gl_multisample_attrib
{
792 GLboolean SampleAlphaToCoverage
;
793 GLboolean SampleAlphaToOne
;
794 GLboolean SampleCoverage
;
795 GLfloat SampleCoverageValue
;
796 GLboolean SampleCoverageInvert
;
803 struct gl_pixel_attrib
{
804 GLenum ReadBuffer
; /**< source buffer for glReadPixels()/glCopyPixels() */
805 GLubyte _ReadSrcMask
; /**< Not really a mask, but like _DrawDestMask
807 * May be: FRONT_LEFT_BIT, BACK_LEFT_BIT,
808 * FRONT_RIGHT_BIT or BACK_RIGHT_BIT. */
809 GLfloat RedBias
, RedScale
;
810 GLfloat GreenBias
, GreenScale
;
811 GLfloat BlueBias
, BlueScale
;
812 GLfloat AlphaBias
, AlphaScale
;
813 GLfloat DepthBias
, DepthScale
;
814 GLint IndexShift
, IndexOffset
;
815 GLboolean MapColorFlag
;
816 GLboolean MapStencilFlag
;
817 GLfloat ZoomX
, ZoomY
;
818 /* XXX move these out of gl_pixel_attrib */
819 GLint MapStoSsize
; /**< Size of each pixel map */
829 GLint MapStoS
[MAX_PIXEL_MAP_TABLE
]; /**< Pixel map tables */
830 GLint MapItoI
[MAX_PIXEL_MAP_TABLE
];
831 GLfloat MapItoR
[MAX_PIXEL_MAP_TABLE
];
832 GLfloat MapItoG
[MAX_PIXEL_MAP_TABLE
];
833 GLfloat MapItoB
[MAX_PIXEL_MAP_TABLE
];
834 GLfloat MapItoA
[MAX_PIXEL_MAP_TABLE
];
835 GLubyte MapItoR8
[MAX_PIXEL_MAP_TABLE
]; /**< converted to 8-bit color */
836 GLubyte MapItoG8
[MAX_PIXEL_MAP_TABLE
];
837 GLubyte MapItoB8
[MAX_PIXEL_MAP_TABLE
];
838 GLubyte MapItoA8
[MAX_PIXEL_MAP_TABLE
];
839 GLfloat MapRtoR
[MAX_PIXEL_MAP_TABLE
];
840 GLfloat MapGtoG
[MAX_PIXEL_MAP_TABLE
];
841 GLfloat MapBtoB
[MAX_PIXEL_MAP_TABLE
];
842 GLfloat MapAtoA
[MAX_PIXEL_MAP_TABLE
];
843 /** GL_EXT_histogram */
844 GLboolean HistogramEnabled
;
845 GLboolean MinMaxEnabled
;
846 /** GL_SGIS_pixel_texture */
847 GLboolean PixelTextureEnabled
;
848 GLenum FragmentRgbSource
;
849 GLenum FragmentAlphaSource
;
850 /** GL_SGI_color_matrix */
851 GLfloat PostColorMatrixScale
[4]; /**< RGBA */
852 GLfloat PostColorMatrixBias
[4]; /**< RGBA */
853 /** GL_SGI_color_table */
854 GLfloat ColorTableScale
[4];
855 GLfloat ColorTableBias
[4];
856 GLboolean ColorTableEnabled
;
857 GLfloat PCCTscale
[4];
859 GLboolean PostConvolutionColorTableEnabled
;
860 GLfloat PCMCTscale
[4];
861 GLfloat PCMCTbias
[4];
862 GLboolean PostColorMatrixColorTableEnabled
;
863 /** GL_SGI_texture_color_table */
864 GLfloat TextureColorTableScale
[4];
865 GLfloat TextureColorTableBias
[4];
867 GLboolean Convolution1DEnabled
;
868 GLboolean Convolution2DEnabled
;
869 GLboolean Separable2DEnabled
;
870 GLfloat ConvolutionBorderColor
[3][4];
871 GLenum ConvolutionBorderMode
[3];
872 GLfloat ConvolutionFilterScale
[3][4];
873 GLfloat ConvolutionFilterBias
[3][4];
874 GLfloat PostConvolutionScale
[4]; /**< RGBA */
875 GLfloat PostConvolutionBias
[4]; /**< RGBA */
882 struct gl_point_attrib
{
883 GLboolean SmoothFlag
; /**< True if GL_POINT_SMOOTH is enabled */
884 GLfloat Size
; /**< User-specified point size */
885 GLfloat _Size
; /**< Size clamped to Const.Min/MaxPointSize */
886 GLfloat Params
[3]; /**< GL_EXT_point_parameters */
887 GLfloat MinSize
, MaxSize
; /**< GL_EXT_point_parameters */
888 GLfloat Threshold
; /**< GL_EXT_point_parameters */
889 GLboolean _Attenuated
; /**< True if Params != [1, 0, 0] */
890 GLboolean PointSprite
; /**< GL_NV_point_sprite / GL_NV_point_sprite */
891 GLboolean CoordReplace
[MAX_TEXTURE_UNITS
]; /**< GL_NV_point_sprite / GL_NV_point_sprite */
892 GLenum SpriteRMode
; /**< GL_NV_point_sprite (only!) */
897 * Polygon attributes.
899 struct gl_polygon_attrib
{
900 GLenum FrontFace
; /**< Either GL_CW or GL_CCW */
901 GLenum FrontMode
; /**< Either GL_POINT, GL_LINE or GL_FILL */
902 GLenum BackMode
; /**< Either GL_POINT, GL_LINE or GL_FILL */
903 GLboolean _FrontBit
; /**< 0=GL_CCW, 1=GL_CW */
904 GLboolean CullFlag
; /**< Culling on/off flag */
905 GLboolean SmoothFlag
; /**< True if GL_POLYGON_SMOOTH is enabled */
906 GLboolean StippleFlag
; /**< True if GL_POLYGON_STIPPLE is enabled */
907 GLenum CullFaceMode
; /**< Culling mode GL_FRONT or GL_BACK */
908 GLfloat OffsetFactor
; /**< Polygon offset factor, from user */
909 GLfloat OffsetUnits
; /**< Polygon offset units, from user */
910 GLboolean OffsetPoint
; /**< Offset in GL_POINT mode */
911 GLboolean OffsetLine
; /**< Offset in GL_LINE mode */
912 GLboolean OffsetFill
; /**< Offset in GL_FILL mode */
917 * Scissor attributes.
919 struct gl_scissor_attrib
{
920 GLboolean Enabled
; /**< Scissor test enabled? */
921 GLint X
, Y
; /**< Lower left corner of box */
922 GLsizei Width
, Height
; /**< Size of box */
927 * Stencil attributes.
929 struct gl_stencil_attrib
{
930 GLboolean Enabled
; /**< Enabled flag */
931 GLboolean TestTwoSide
; /**< GL_EXT_stencil_two_side */
932 GLubyte ActiveFace
; /**< GL_EXT_stencil_two_side (0 or 1) */
933 GLenum Function
[2]; /**< Stencil function */
934 GLenum FailFunc
[2]; /**< Fail function */
935 GLenum ZPassFunc
[2]; /**< Depth buffer pass function */
936 GLenum ZFailFunc
[2]; /**< Depth buffer fail function */
937 GLstencil Ref
[2]; /**< Reference value */
938 GLstencil ValueMask
[2]; /**< Value mask */
939 GLstencil WriteMask
[2]; /**< Write mask */
940 GLstencil Clear
; /**< Clear value */
944 #define NUM_TEXTURE_TARGETS 5 /* 1D, 2D, 3D, CUBE and RECT */
946 #define TEXTURE_1D_INDEX 0
947 #define TEXTURE_2D_INDEX 1
948 #define TEXTURE_3D_INDEX 2
949 #define TEXTURE_CUBE_INDEX 3
950 #define TEXTURE_RECT_INDEX 4
952 /* Texture.Unit[]._ReallyEnabled flags: */
953 #define TEXTURE_1D_BIT (1 << TEXTURE_1D_INDEX)
954 #define TEXTURE_2D_BIT (1 << TEXTURE_2D_INDEX)
955 #define TEXTURE_3D_BIT (1 << TEXTURE_3D_INDEX)
956 #define TEXTURE_CUBE_BIT (1 << TEXTURE_CUBE_INDEX)
957 #define TEXTURE_RECT_BIT (1 << TEXTURE_RECT_INDEX)
960 /* TexGenEnabled flags */
966 /* Bitmap versions of the GL_ constants. */
967 #define TEXGEN_SPHERE_MAP 0x1
968 #define TEXGEN_OBJ_LINEAR 0x2
969 #define TEXGEN_EYE_LINEAR 0x4
970 #define TEXGEN_REFLECTION_MAP_NV 0x8
971 #define TEXGEN_NORMAL_MAP_NV 0x10
973 #define TEXGEN_NEED_NORMALS (TEXGEN_SPHERE_MAP | \
974 TEXGEN_REFLECTION_MAP_NV | \
975 TEXGEN_NORMAL_MAP_NV)
976 #define TEXGEN_NEED_EYE_COORD (TEXGEN_SPHERE_MAP | \
977 TEXGEN_REFLECTION_MAP_NV | \
978 TEXGEN_NORMAL_MAP_NV | \
981 /* A selection of state flags to make driver and module's lives easier. */
982 #define ENABLE_TEXGEN0 0x1
983 #define ENABLE_TEXGEN1 0x2
984 #define ENABLE_TEXGEN2 0x4
985 #define ENABLE_TEXGEN3 0x8
986 #define ENABLE_TEXGEN4 0x10
987 #define ENABLE_TEXGEN5 0x20
988 #define ENABLE_TEXGEN6 0x40
989 #define ENABLE_TEXGEN7 0x80
991 #define ENABLE_TEXMAT0 0x1 /* Ie. not the identity matrix */
992 #define ENABLE_TEXMAT1 0x2
993 #define ENABLE_TEXMAT2 0x4
994 #define ENABLE_TEXMAT3 0x8
995 #define ENABLE_TEXMAT4 0x10
996 #define ENABLE_TEXMAT5 0x20
997 #define ENABLE_TEXMAT6 0x40
998 #define ENABLE_TEXMAT7 0x80
1000 #define ENABLE_TEXGEN(i) (ENABLE_TEXGEN0 << (i))
1001 #define ENABLE_TEXMAT(i) (ENABLE_TEXMAT0 << (i))
1005 * Texel fetch function prototype. We use texel fetch functions to
1006 * extract RGBA, color indexes and depth components out of 1D, 2D and 3D
1007 * texture images. These functions help to isolate us from the gritty
1008 * details of all the various texture image encodings.
1010 * \param texImage texture image.
1011 * \param col texel column.
1012 * \param row texel row.
1013 * \param img texel image level/layer.
1014 * \param texelOut output texel (up to 4 GLchans)
1016 typedef void (*FetchTexelFuncC
)( const struct gl_texture_image
*texImage
,
1017 GLint col
, GLint row
, GLint img
,
1021 * As above, but returns floats.
1022 * Used for depth component images and for upcoming signed/float
1025 typedef void (*FetchTexelFuncF
)( const struct gl_texture_image
*texImage
,
1026 GLint col
, GLint row
, GLint img
,
1027 GLfloat
*texelOut
);
1031 * TexImage store function. This is called by the glTex[Sub]Image
1032 * functions and is responsible for converting the user-specified texture
1033 * image into a specific (hardware) image format.
1035 typedef GLboolean (*StoreTexImageFunc
)(GLcontext
*ctx
, GLuint dims
,
1036 GLenum baseInternalFormat
,
1037 const struct gl_texture_format
*dstFormat
,
1039 GLint dstXoffset
, GLint dstYoffset
, GLint dstZoffset
,
1040 GLint dstRowStride
, GLint dstImageStride
,
1041 GLint srcWidth
, GLint srcHeight
, GLint srcDepth
,
1042 GLenum srcFormat
, GLenum srcType
,
1043 const GLvoid
*srcAddr
,
1044 const struct gl_pixelstore_attrib
*srcPacking
);
1049 * Texture format record
1051 struct gl_texture_format
{
1052 GLint MesaFormat
; /**< One of the MESA_FORMAT_* values */
1054 GLenum BaseFormat
; /**< Either GL_RGB, GL_RGBA, GL_ALPHA,
1055 * GL_LUMINANCE, GL_LUMINANCE_ALPHA,
1056 * GL_INTENSITY, GL_COLOR_INDEX or
1057 * GL_DEPTH_COMPONENT.
1059 GLenum DataType
; /**< GL_FLOAT or GL_UNSIGNED_NORMALIZED_ARB */
1060 GLubyte RedBits
; /**< Bits per texel component */
1061 GLubyte GreenBits
; /**< These are just rough approximations for */
1062 GLubyte BlueBits
; /**< compressed texture formats. */
1064 GLubyte LuminanceBits
;
1065 GLubyte IntensityBits
;
1069 GLuint TexelBytes
; /**< Bytes per texel, 0 if compressed format */
1071 StoreTexImageFunc StoreImage
;
1074 * \name Texel fetch function pointers
1077 FetchTexelFuncC FetchTexel1D
;
1078 FetchTexelFuncC FetchTexel2D
;
1079 FetchTexelFuncC FetchTexel3D
;
1080 FetchTexelFuncF FetchTexel1Df
;
1081 FetchTexelFuncF FetchTexel2Df
;
1082 FetchTexelFuncF FetchTexel3Df
;
1088 * Texture image record
1090 struct gl_texture_image
{
1091 GLenum Format
; /**< Either GL_RGB, GL_RGBA, GL_ALPHA,
1092 * GL_LUMINANCE, GL_LUMINANCE_ALPHA,
1093 * GL_INTENSITY, GL_COLOR_INDEX or
1094 * GL_DEPTH_COMPONENT only.
1095 * Used for choosing TexEnv arithmetic.
1097 GLint IntFormat
; /**< Internal format as given by the user */
1098 GLuint Border
; /**< 0 or 1 */
1099 GLuint Width
; /**< = 2^WidthLog2 + 2*Border */
1100 GLuint Height
; /**< = 2^HeightLog2 + 2*Border */
1101 GLuint Depth
; /**< = 2^DepthLog2 + 2*Border */
1102 GLuint RowStride
; /**< == Width unless IsClientData and padded */
1103 GLuint Width2
; /**< = Width - 2*Border */
1104 GLuint Height2
; /**< = Height - 2*Border */
1105 GLuint Depth2
; /**< = Depth - 2*Border */
1106 GLuint WidthLog2
; /**< = log2(Width2) */
1107 GLuint HeightLog2
; /**< = log2(Height2) */
1108 GLuint DepthLog2
; /**< = log2(Depth2) */
1109 GLuint MaxLog2
; /**< = MAX(WidthLog2, HeightLog2) */
1110 GLfloat WidthScale
; /**< used for mipmap LOD computation */
1111 GLfloat HeightScale
; /**< used for mipmap LOD computation */
1112 GLfloat DepthScale
; /**< used for mipmap LOD computation */
1113 GLvoid
*Data
; /**< Image data, accessed via FetchTexel() */
1114 GLboolean IsClientData
; /**< Data owned by client? */
1115 GLboolean _IsPowerOfTwo
; /**< Are all dimensions powers of two? */
1117 const struct gl_texture_format
*TexFormat
;
1119 FetchTexelFuncC FetchTexelc
; /**< GLchan texel fetch function pointer */
1120 FetchTexelFuncF FetchTexelf
; /**< Float texel fetch function pointer */
1122 GLboolean IsCompressed
; /**< GL_ARB_texture_compression */
1123 GLuint CompressedSize
; /**< GL_ARB_texture_compression */
1126 * \name For device driver:
1129 void *DriverData
; /**< Arbitrary device driver data */
1133 #define FACE_POS_X 0
1134 #define FACE_NEG_X 1
1135 #define FACE_POS_Y 2
1136 #define FACE_NEG_Y 3
1137 #define FACE_POS_Z 4
1138 #define FACE_NEG_Z 5
1142 * Texture object record
1144 struct gl_texture_object
{
1145 _glthread_Mutex Mutex
; /**< for thread safety */
1146 GLint RefCount
; /**< reference count */
1147 GLuint Name
; /**< an unsigned integer */
1148 GLenum Target
; /**< GL_TEXTURE_1D, GL_TEXTURE_2D, etc. */
1149 GLfloat Priority
; /**< in [0,1] */
1150 GLfloat BorderColor
[4]; /**< unclamped */
1151 GLchan _BorderChan
[4]; /**< clamped, as GLchan */
1152 /** \name Wrap modes
1153 * Are GL_CLAMP, REPEAT, GL_CLAMP_TO_EDGE, and GL_CLAMP_TO_BORDER_ARB. */
1159 GLenum MinFilter
; /**< minification filter */
1160 GLenum MagFilter
; /**< magnification filter */
1161 GLfloat MinLod
; /**< min lambda, OpenGL 1.2 */
1162 GLfloat MaxLod
; /**< max lambda, OpenGL 1.2 */
1163 GLfloat LodBias
; /**< OpenGL 1.4 */
1164 GLint BaseLevel
; /**< min mipmap level, OpenGL 1.2 */
1165 GLint MaxLevel
; /**< max mipmap level, OpenGL 1.2 */
1166 GLfloat MaxAnisotropy
; /**< GL_EXT_texture_filter_anisotropic */
1167 GLboolean CompareFlag
; /**< GL_SGIX_shadow */
1168 GLenum CompareOperator
; /**< GL_SGIX_shadow */
1169 GLfloat ShadowAmbient
;
1170 GLenum CompareMode
; /**< GL_ARB_shadow */
1171 GLenum CompareFunc
; /**< GL_ARB_shadow */
1172 GLenum DepthMode
; /**< GL_ARB_depth_texture */
1173 GLint _MaxLevel
; /**< actual max mipmap level (q in the spec) */
1174 GLfloat _MaxLambda
; /**< = _MaxLevel - BaseLevel (q - b in spec) */
1175 GLboolean GenerateMipmap
; /**< GL_SGIS_generate_mipmap */
1176 GLboolean _IsPowerOfTwo
; /**< Are all image dimensions powers of two? */
1178 struct gl_texture_image
*Image
[MAX_FACES
][MAX_TEXTURE_LEVELS
];
1180 /** GL_EXT_paletted_texture */
1181 struct gl_color_table Palette
;
1183 GLboolean Complete
; /**< Is texture object complete? */
1184 struct gl_texture_object
*Next
; /**< Next in linked list */
1187 * \name For device driver
1190 void *DriverData
; /**< Arbitrary device driver data */
1195 * Texture combine environment state.
1198 * If GL_NV_texture_env_combine4 is ever supported, the arrays in this
1199 * structure will need to be expanded for 4 elements.
1201 struct gl_tex_env_combine_state
{
1202 GLenum ModeRGB
; /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */
1203 GLenum ModeA
; /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */
1204 GLenum SourceRGB
[3]; /**< GL_PRIMARY_COLOR, GL_TEXTURE, etc. */
1205 GLenum SourceA
[3]; /**< GL_PRIMARY_COLOR, GL_TEXTURE, etc. */
1206 GLenum OperandRGB
[3]; /**< SRC_COLOR, ONE_MINUS_SRC_COLOR, etc */
1207 GLenum OperandA
[3]; /**< SRC_ALPHA, ONE_MINUS_SRC_ALPHA, etc */
1208 GLuint ScaleShiftRGB
; /**< 0, 1 or 2 */
1209 GLuint ScaleShiftA
; /**< 0, 1 or 2 */
1210 GLuint _NumArgsRGB
; /**< Number of inputs used for the combine mode. */
1211 GLuint _NumArgsA
; /**< Number of inputs used for the combine mode. */
1215 * Texture unit record
1217 struct gl_texture_unit
{
1218 GLuint Enabled
; /**< bitmask of TEXTURE_*_BIT flags */
1219 GLuint _ReallyEnabled
; /**< 0 or exactly one of TEXTURE_*_BIT flags */
1221 GLenum EnvMode
; /**< GL_MODULATE, GL_DECAL, GL_BLEND, etc. */
1222 GLfloat EnvColor
[4];
1223 GLuint TexGenEnabled
; /**< Bitwise-OR of [STRQ]_BIT values */
1224 /** \name Tex coord generation mode
1225 * Either GL_OBJECT_LINEAR, GL_EYE_LINEAR or GL_SPHERE_MAP. */
1236 GLuint _GenFlags
; /**< bitwise or of GenBit[STRQ] */
1237 GLfloat ObjectPlaneS
[4];
1238 GLfloat ObjectPlaneT
[4];
1239 GLfloat ObjectPlaneR
[4];
1240 GLfloat ObjectPlaneQ
[4];
1241 GLfloat EyePlaneS
[4];
1242 GLfloat EyePlaneT
[4];
1243 GLfloat EyePlaneR
[4];
1244 GLfloat EyePlaneQ
[4];
1245 GLfloat LodBias
; /**< for biasing mipmap levels */
1248 * \name GL_EXT_texture_env_combine
1250 struct gl_tex_env_combine_state Combine
;
1253 * Derived state based on \c EnvMode and the \c BaseFormat of the
1254 * currently enabled texture.
1256 struct gl_tex_env_combine_state _EnvMode
;
1259 * Currently enabled combiner state. This will point to either
1260 * \c Combine or \c _EnvMode.
1262 struct gl_tex_env_combine_state
*_CurrentCombine
;
1264 struct gl_texture_object
*Current1D
;
1265 struct gl_texture_object
*Current2D
;
1266 struct gl_texture_object
*Current3D
;
1267 struct gl_texture_object
*CurrentCubeMap
; /**< GL_ARB_texture_cube_map */
1268 struct gl_texture_object
*CurrentRect
; /**< GL_NV_texture_rectangle */
1270 struct gl_texture_object
*_Current
; /**< Points to really enabled tex obj */
1272 struct gl_texture_object Saved1D
; /**< only used by glPush/PopAttrib */
1273 struct gl_texture_object Saved2D
;
1274 struct gl_texture_object Saved3D
;
1275 struct gl_texture_object SavedCubeMap
;
1276 struct gl_texture_object SavedRect
;
1278 /* GL_SGI_texture_color_table */
1279 struct gl_color_table ColorTable
;
1280 struct gl_color_table ProxyColorTable
;
1281 GLboolean ColorTableEnabled
;
1286 * Texture attributes
1288 struct gl_texture_attrib
{
1293 GLuint CurrentUnit
; /**< Active texture unit */
1294 GLuint _EnabledUnits
; /**< one bit set for each really-enabled unit */
1295 GLuint _EnabledCoordUnits
; /**< one bit per enabled coordinate unit */
1296 GLuint _GenFlags
; /**< for texgen */
1297 GLuint _TexGenEnabled
;
1298 GLuint _TexMatEnabled
;
1301 struct gl_texture_unit Unit
[MAX_TEXTURE_UNITS
];
1303 struct gl_texture_object
*Proxy1D
;
1304 struct gl_texture_object
*Proxy2D
;
1305 struct gl_texture_object
*Proxy3D
;
1306 struct gl_texture_object
*ProxyCubeMap
;
1307 struct gl_texture_object
*ProxyRect
;
1309 /** GL_EXT_shared_texture_palette */
1310 GLboolean SharedPalette
;
1311 struct gl_color_table Palette
;
1316 * Transformation attributes.
1318 struct gl_transform_attrib
{
1319 GLenum MatrixMode
; /**< Matrix mode */
1320 GLfloat EyeUserPlane
[MAX_CLIP_PLANES
][4]; /**< User clip planes */
1321 GLfloat _ClipUserPlane
[MAX_CLIP_PLANES
][4]; /**< derived */
1322 GLuint ClipPlanesEnabled
; /**< on/off bitmask */
1323 GLboolean Normalize
; /**< Normalize all normals? */
1324 GLboolean RescaleNormals
; /**< GL_EXT_rescale_normal */
1325 GLboolean RasterPositionUnclipped
; /**< GL_IBM_rasterpos_clip */
1330 * Viewport attributes.
1332 struct gl_viewport_attrib
{
1333 GLint X
, Y
; /**< position */
1334 GLsizei Width
, Height
; /**< size */
1335 GLfloat Near
, Far
; /**< Depth buffer range */
1336 GLmatrix _WindowMap
; /**< Mapping transformation as a matrix. */
1341 * Node for the attribute stack
1343 struct gl_attrib_node
{
1346 struct gl_attrib_node
*next
;
1351 * GL_ARB_vertex/pixel_buffer_object buffer object
1353 struct gl_buffer_object
{
1358 GLvoid
*Pointer
; /**< Only valid while buffer is mapped */
1359 GLuint Size
; /**< Size of storage in bytes */
1360 GLubyte
*Data
; /**< Location of storage either in RAM or VRAM. */
1361 GLboolean OnCard
; /**< Is buffer in VRAM? (hardware drivers) */
1362 GLboolean DeletePending
; /**< Deleted by user but RefCount > 0? */
1368 * Client pixel packing/unpacking attributes
1370 struct gl_pixelstore_attrib
{
1375 GLint ImageHeight
; /**< for GL_EXT_texture3D */
1376 GLint SkipImages
; /**< for GL_EXT_texture3D */
1377 GLboolean SwapBytes
;
1379 GLboolean ClientStorage
; /**< GL_APPLE_client_storage */
1380 GLboolean Invert
; /**< GL_MESA_pack_invert */
1381 struct gl_buffer_object
*BufferObj
; /**< GL_ARB_pixel_buffer_object */
1385 #define CA_CLIENT_DATA 0x1 /**< Data not allocated by mesa */
1389 * Client vertex array attributes
1391 struct gl_client_array
{
1394 GLsizei Stride
; /**< user-specified stride */
1395 GLsizei StrideB
; /**< actual stride in bytes */
1397 GLuint Enabled
; /**< one of the _NEW_ARRAY_ bits */
1398 GLboolean Normalized
; /**< GL_ARB_vertex_program */
1400 /**< GL_ARB_vertex_buffer_object */
1401 struct gl_buffer_object
*BufferObj
;
1411 struct gl_array_attrib
{
1412 struct gl_client_array Vertex
; /**< client data descriptors */
1413 struct gl_client_array Normal
;
1414 struct gl_client_array Color
;
1415 struct gl_client_array SecondaryColor
;
1416 struct gl_client_array FogCoord
;
1417 struct gl_client_array Index
;
1418 struct gl_client_array TexCoord
[MAX_TEXTURE_COORD_UNITS
];
1419 struct gl_client_array EdgeFlag
;
1421 struct gl_client_array VertexAttrib
[VERT_ATTRIB_MAX
]; /**< GL_NV_vertex_program */
1423 GLint ActiveTexture
; /**< Client Active Texture */
1424 GLuint LockFirst
; /**< GL_EXT_compiled_vertex_array */
1425 GLuint LockCount
; /**< GL_EXT_compiled_vertex_array */
1427 GLuint _Enabled
; /**< _NEW_ARRAY_* - bit set if array enabled */
1428 GLuint NewState
; /**< _NEW_ARRAY_* */
1430 #if FEATURE_ARB_vertex_buffer_object
1431 struct gl_buffer_object
*NullBufferObj
;
1432 struct gl_buffer_object
*ArrayBufferObj
;
1433 struct gl_buffer_object
*ElementArrayBufferObj
;
1435 GLuint _MaxElement
; /* Min of all enabled array's maxes */
1439 struct gl_feedback
{
1441 GLuint _Mask
; /* FB_* bits */
1449 * Selection attributes.
1451 struct gl_selection
{
1452 GLuint
*Buffer
; /**< selection buffer */
1453 GLuint BufferSize
; /**< size of the selection buffer */
1454 GLuint BufferCount
; /**< number of values in the selection buffer */
1455 GLuint Hits
; /**< number of records in the selection buffer */
1456 GLuint NameStackDepth
; /**< name stack depth */
1457 GLuint NameStack
[MAX_NAME_STACK_DEPTH
]; /**< name stack */
1458 GLboolean HitFlag
; /**< hit flag */
1459 GLfloat HitMinZ
; /**< minimum hit depth */
1460 GLfloat HitMaxZ
; /**< maximum hit depth */
1465 * 1-D Evaluator control points
1469 GLuint Order
; /**< Number of control points */
1470 GLfloat u1
, u2
, du
; /**< u1, u2, 1.0/(u2-u1) */
1471 GLfloat
*Points
; /**< Points to contiguous control points */
1476 * 2-D Evaluator control points
1480 GLuint Uorder
; /**< Number of control points in U dimension */
1481 GLuint Vorder
; /**< Number of control points in V dimension */
1484 GLfloat
*Points
; /**< Points to contiguous control points */
1489 * All evaluator control points
1491 struct gl_evaluators
1497 struct gl_1d_map Map1Vertex3
;
1498 struct gl_1d_map Map1Vertex4
;
1499 struct gl_1d_map Map1Index
;
1500 struct gl_1d_map Map1Color4
;
1501 struct gl_1d_map Map1Normal
;
1502 struct gl_1d_map Map1Texture1
;
1503 struct gl_1d_map Map1Texture2
;
1504 struct gl_1d_map Map1Texture3
;
1505 struct gl_1d_map Map1Texture4
;
1506 struct gl_1d_map Map1Attrib
[16]; /**< GL_NV_vertex_program */
1513 struct gl_2d_map Map2Vertex3
;
1514 struct gl_2d_map Map2Vertex4
;
1515 struct gl_2d_map Map2Index
;
1516 struct gl_2d_map Map2Color4
;
1517 struct gl_2d_map Map2Normal
;
1518 struct gl_2d_map Map2Texture1
;
1519 struct gl_2d_map Map2Texture2
;
1520 struct gl_2d_map Map2Texture3
;
1521 struct gl_2d_map Map2Texture4
;
1522 struct gl_2d_map Map2Attrib
[16]; /**< GL_NV_vertex_program */
1528 * NV_fragment_program runtime state
1532 GLfloat Temporaries
[MAX_NV_FRAGMENT_PROGRAM_TEMPS
][4];
1533 GLfloat Inputs
[MAX_NV_FRAGMENT_PROGRAM_INPUTS
][4];
1534 GLfloat Outputs
[MAX_NV_FRAGMENT_PROGRAM_OUTPUTS
][4];
1535 GLuint CondCodes
[4];
1540 * Names of the various vertex/fragment register files
1544 PROGRAM_TEMPORARY
= 10,
1547 PROGRAM_LOCAL_PARAM
,
1549 PROGRAM_NAMED_PARAM
,
1556 /* Vertex and fragment instructions */
1557 struct vp_instruction
;
1558 struct fp_instruction
;
1560 struct program_parameter_list
;
1564 * Base class for any kind of program object
1569 GLubyte
*String
; /* Null-terminated program text */
1571 GLenum Format
; /* String encoding format */
1574 GLfloat LocalParams
[MAX_PROGRAM_LOCAL_PARAMS
][4];
1575 GLuint NumInstructions
; /* GL_ARB_vertex/fragment_program */
1576 GLuint NumTemporaries
;
1577 GLuint NumParameters
;
1578 GLuint NumAttributes
;
1579 GLuint NumAddressRegs
;
1583 /** Vertex program object */
1584 struct vertex_program
1586 struct program Base
; /* base class */
1587 struct vp_instruction
*Instructions
; /* Compiled instructions */
1588 GLboolean IsNVProgram
; /* GL_NV_vertex_program ? */
1589 GLboolean IsPositionInvariant
; /* GL_NV_vertex_program1_1 */
1590 GLuint InputsRead
; /* Bitmask of which input regs are read */
1591 GLuint OutputsWritten
; /* Bitmask of which output regs are written to */
1592 struct program_parameter_list
*Parameters
; /**< array [NumParameters] */
1596 /** Fragment program object */
1597 struct fragment_program
1599 struct program Base
; /**< base class */
1600 struct fp_instruction
*Instructions
; /**< Compiled instructions */
1601 GLuint InputsRead
; /**< Bitmask of which input regs are read */
1602 GLuint OutputsWritten
; /**< Bitmask of which output regs are written to */
1603 GLuint TexturesUsed
[MAX_TEXTURE_IMAGE_UNITS
]; /**< TEXTURE_x_INDEX bitmask */
1604 GLuint NumAluInstructions
; /**< GL_ARB_fragment_program */
1605 GLuint NumTexInstructions
;
1606 GLuint NumTexIndirections
;
1608 struct program_parameter_list
*Parameters
; /**< array [NumParameters] */
1611 char c_str
[4096]; /* experimental... */
1618 * State common to vertex and fragment programs.
1620 struct program_state
{
1621 GLint ErrorPos
; /* GL_PROGRAM_ERROR_POSITION_NV */
1622 const char *ErrorString
; /* GL_PROGRAM_ERROR_STRING_NV */
1627 * State vars for GL_NV_vertex_program
1629 struct vertex_program_state
1631 GLboolean Enabled
; /**< GL_VERTEX_PROGRAM_NV */
1632 GLboolean _Enabled
; /**< Really enabled? */
1633 GLboolean PointSizeEnabled
; /**< GL_VERTEX_PROGRAM_POINT_SIZE_NV */
1634 GLboolean TwoSideEnabled
; /**< GL_VERTEX_PROGRAM_TWO_SIDE_NV */
1635 struct vertex_program
*Current
; /**< ptr to currently bound program */
1637 GLenum TrackMatrix
[MAX_NV_VERTEX_PROGRAM_PARAMS
/ 4];
1638 GLenum TrackMatrixTransform
[MAX_NV_VERTEX_PROGRAM_PARAMS
/ 4];
1640 GLfloat Parameters
[MAX_NV_VERTEX_PROGRAM_PARAMS
][4]; /* Env params */
1641 /* Only used during program execution (may be moved someday): */
1642 GLfloat Temporaries
[MAX_NV_VERTEX_PROGRAM_TEMPS
][4];
1643 GLfloat Inputs
[MAX_NV_VERTEX_PROGRAM_INPUTS
][4];
1644 GLfloat Outputs
[MAX_NV_VERTEX_PROGRAM_OUTPUTS
][4];
1645 GLint AddressReg
[4];
1647 #if FEATURE_MESA_program_debug
1648 GLprogramcallbackMESA Callback
;
1649 GLvoid
*CallbackData
;
1650 GLboolean CallbackEnabled
;
1651 GLuint CurrentPosition
;
1657 * State for GL_ARB/NV_fragment_program
1659 struct fragment_program_state
1661 GLboolean Enabled
; /* GL_VERTEX_PROGRAM_NV */
1662 GLboolean _Enabled
; /* Really enabled? */
1663 struct fragment_program
*Current
; /* ptr to currently bound program */
1664 struct fp_machine Machine
; /* machine state */
1665 GLfloat Parameters
[MAX_NV_FRAGMENT_PROGRAM_PARAMS
][4]; /* Env params */
1667 #if FEATURE_MESA_program_debug
1668 GLprogramcallbackMESA Callback
;
1669 GLvoid
*CallbackData
;
1670 GLboolean CallbackEnabled
;
1671 GLuint CurrentPosition
;
1677 * State for GL_ARB_occlusion_query
1679 struct occlusion_state
1682 GLuint CurrentQueryObject
;
1683 GLuint PassedCounter
;
1684 struct _mesa_HashTable
*QueryObjects
;
1689 * State which can be shared by multiple contexts:
1691 struct gl_shared_state
1693 _glthread_Mutex Mutex
; /**< for thread safety */
1694 GLint RefCount
; /**< Reference count */
1695 struct _mesa_HashTable
*DisplayList
; /**< Display lists hash table */
1696 struct _mesa_HashTable
*TexObjects
; /**< Texture objects hash table */
1697 struct gl_texture_object
*TexObjectList
;/**< Linked list of texture objects */
1700 * \name Default texture objects (shared by all multi-texture units)
1703 struct gl_texture_object
*Default1D
;
1704 struct gl_texture_object
*Default2D
;
1705 struct gl_texture_object
*Default3D
;
1706 struct gl_texture_object
*DefaultCubeMap
;
1707 struct gl_texture_object
*DefaultRect
;
1711 * \name GL_NV_vertex/_program
1714 struct _mesa_HashTable
*Programs
;
1715 #if FEATURE_ARB_vertex_program
1716 struct program
*DefaultVertexProgram
;
1718 #if FEATURE_ARB_fragment_program
1719 struct program
*DefaultFragmentProgram
;
1723 #if FEATURE_ARB_vertex_buffer_object
1724 struct _mesa_HashTable
*BufferObjects
;
1727 void *DriverData
; /**< Device driver shared state */
1734 * A "frame buffer" is a color buffer and its optional ancillary buffers:
1735 * depth, accum, stencil, and software-simulated alpha buffers.
1736 * In C++ terms, think of this as a base class from which device drivers
1737 * will make derived classes.
1739 struct gl_frame_buffer
1741 GLvisual Visual
; /**< The corresponding visual */
1743 GLuint Width
, Height
; /**< size of frame buffer in pixels */
1745 GLboolean UseSoftwareDepthBuffer
;
1746 GLboolean UseSoftwareAccumBuffer
;
1747 GLboolean UseSoftwareStencilBuffer
;
1748 GLboolean UseSoftwareAlphaBuffers
;
1749 GLboolean UseSoftwareAuxBuffers
;
1751 /** \name Software depth (aka Z) buffer */
1753 GLvoid
*DepthBuffer
; /**< array [Width*Height] of GLushort or GLuint*/
1756 /** \name Software stencil buffer */
1758 GLstencil
*Stencil
; /**< array [Width*Height] of GLstencil values */
1761 /** \name Software accumulation buffer */
1763 GLaccum
*Accum
; /**< array [4*Width*Height] of GLaccum values */
1766 /** \name Software alpha planes */
1768 GLchan
*FrontLeftAlpha
; /**< array [Width*Height] of GLchan */
1769 GLchan
*BackLeftAlpha
; /**< array [Width*Height] of GLchan */
1770 GLchan
*FrontRightAlpha
; /**< array [Width*Height] of GLchan */
1771 GLchan
*BackRightAlpha
; /**< array [Width*Height] of GLchan */
1774 GLchan
*AuxBuffers
[MAX_AUX_BUFFERS
];
1777 * \name Drawing bounds
1779 * Intersection of window size and scissor box
1782 GLint _Xmin
; /**< inclusive */
1783 GLint _Ymin
; /**< inclusive */
1784 GLint _Xmax
; /**< exclusive */
1785 GLint _Ymax
; /**< exclusive */
1791 * Constants which may be overridden by device driver during context creation
1792 * but are never changed after that.
1796 GLint MaxTextureLevels
; /**< Maximum number of allowed mipmap levels. */
1797 GLint Max3DTextureLevels
; /**< Maximum number of allowed mipmap levels for 3D texture targets. */
1798 GLint MaxCubeTextureLevels
; /**< Maximum number of allowed mipmap levels for GL_ARB_texture_cube_map */
1799 GLint MaxTextureRectSize
; /* GL_NV_texture_rectangle */
1800 GLuint MaxTextureCoordUnits
;
1801 GLuint MaxTextureImageUnits
;
1802 GLuint MaxTextureUnits
; /* = MAX(CoordUnits, ImageUnits) */
1803 GLfloat MaxTextureMaxAnisotropy
; /* GL_EXT_texture_filter_anisotropic */
1804 GLfloat MaxTextureLodBias
; /* GL_EXT_texture_lod_bias */
1805 GLuint MaxArrayLockSize
;
1807 GLfloat MinPointSize
, MaxPointSize
; /* aliased */
1808 GLfloat MinPointSizeAA
, MaxPointSizeAA
; /* antialiased */
1809 GLfloat PointSizeGranularity
;
1810 GLfloat MinLineWidth
, MaxLineWidth
; /* aliased */
1811 GLfloat MinLineWidthAA
, MaxLineWidthAA
; /* antialiased */
1812 GLfloat LineWidthGranularity
;
1813 GLuint MaxColorTableSize
;
1814 GLuint MaxConvolutionWidth
;
1815 GLuint MaxConvolutionHeight
;
1816 GLuint MaxClipPlanes
;
1818 GLfloat MaxShininess
; /* GL_NV_light_max_exponent */
1819 GLfloat MaxSpotExponent
; /* GL_NV_light_max_exponent */
1820 /* GL_ARB_vertex_program */
1821 GLuint MaxVertexProgramInstructions
;
1822 GLuint MaxVertexProgramAttribs
;
1823 GLuint MaxVertexProgramTemps
;
1824 GLuint MaxVertexProgramLocalParams
;
1825 GLuint MaxVertexProgramEnvParams
;
1826 GLuint MaxVertexProgramAddressRegs
;
1827 /* GL_ARB_fragment_program */
1828 GLuint MaxFragmentProgramInstructions
;
1829 GLuint MaxFragmentProgramAttribs
;
1830 GLuint MaxFragmentProgramTemps
;
1831 GLuint MaxFragmentProgramLocalParams
;
1832 GLuint MaxFragmentProgramEnvParams
;
1833 GLuint MaxFragmentProgramAddressRegs
;
1834 GLuint MaxFragmentProgramAluInstructions
;
1835 GLuint MaxFragmentProgramTexInstructions
;
1836 GLuint MaxFragmentProgramTexIndirections
;
1837 /* vertex or fragment program */
1838 GLuint MaxProgramMatrices
;
1839 GLuint MaxProgramMatrixStackDepth
;
1840 /* vertex array / buffer object bounds checking */
1841 GLboolean CheckArrayBounds
;
1846 * List of extensions.
1848 struct gl_extensions
1851 * \name Flags to quickly test if certain extensions are available.
1853 * Not every extension needs to have such a flag, but it's encouraged.
1856 GLboolean dummy
; /* don't remove this! */
1857 GLboolean ARB_depth_texture
;
1858 GLboolean ARB_fragment_program
;
1859 GLboolean ARB_half_float_pixel
;
1860 GLboolean ARB_imaging
;
1861 GLboolean ARB_multisample
;
1862 GLboolean ARB_multitexture
;
1863 GLboolean ARB_occlusion_query
;
1864 GLboolean ARB_point_sprite
;
1865 GLboolean ARB_shadow
;
1866 GLboolean ARB_texture_border_clamp
;
1867 GLboolean ARB_texture_compression
;
1868 GLboolean ARB_texture_cube_map
;
1869 GLboolean ARB_texture_env_combine
;
1870 GLboolean ARB_texture_env_crossbar
;
1871 GLboolean ARB_texture_env_dot3
;
1872 GLboolean ARB_texture_float
;
1873 GLboolean ARB_texture_mirrored_repeat
;
1874 GLboolean ARB_texture_non_power_of_two
;
1875 GLboolean ARB_transpose_matrix
;
1876 GLboolean ARB_vertex_buffer_object
;
1877 GLboolean ARB_vertex_program
;
1878 GLboolean ARB_window_pos
;
1881 GLboolean EXT_blend_color
;
1882 GLboolean EXT_blend_equation_separate
;
1883 GLboolean EXT_blend_func_separate
;
1884 GLboolean EXT_blend_logic_op
;
1885 GLboolean EXT_blend_minmax
;
1886 GLboolean EXT_blend_subtract
;
1887 GLboolean EXT_clip_volume_hint
;
1888 GLboolean EXT_convolution
;
1889 GLboolean EXT_compiled_vertex_array
;
1890 GLboolean EXT_copy_texture
;
1891 GLboolean EXT_depth_bounds_test
;
1892 GLboolean EXT_draw_range_elements
;
1893 GLboolean EXT_fog_coord
;
1894 GLboolean EXT_histogram
;
1895 GLboolean EXT_multi_draw_arrays
;
1896 GLboolean EXT_paletted_texture
;
1897 GLboolean EXT_packed_pixels
;
1898 GLboolean EXT_pixel_buffer_object
;
1899 GLboolean EXT_point_parameters
;
1900 GLboolean EXT_polygon_offset
;
1901 GLboolean EXT_rescale_normal
;
1902 GLboolean EXT_shadow_funcs
;
1903 GLboolean EXT_secondary_color
;
1904 GLboolean EXT_separate_specular_color
;
1905 GLboolean EXT_shared_texture_palette
;
1906 GLboolean EXT_stencil_wrap
;
1907 GLboolean EXT_stencil_two_side
;
1908 GLboolean EXT_subtexture
;
1909 GLboolean EXT_texture
;
1910 GLboolean EXT_texture_object
;
1911 GLboolean EXT_texture3D
;
1912 GLboolean EXT_texture_compression_s3tc
;
1913 GLboolean EXT_texture_env_add
;
1914 GLboolean EXT_texture_env_combine
;
1915 GLboolean EXT_texture_env_dot3
;
1916 GLboolean EXT_texture_filter_anisotropic
;
1917 GLboolean EXT_texture_lod_bias
;
1918 GLboolean EXT_texture_mirror_clamp
;
1919 GLboolean EXT_vertex_array
;
1920 GLboolean EXT_vertex_array_set
;
1921 /* vendor extensions */
1922 GLboolean APPLE_client_storage
;
1923 GLboolean APPLE_packed_pixels
;
1924 GLboolean ATI_texture_mirror_once
;
1925 GLboolean ATI_texture_env_combine3
;
1926 GLboolean HP_occlusion_test
;
1927 GLboolean IBM_rasterpos_clip
;
1928 GLboolean IBM_multimode_draw_arrays
;
1929 GLboolean MESA_pack_invert
;
1930 GLboolean MESA_packed_depth_stencil
;
1931 GLboolean MESA_program_debug
;
1932 GLboolean MESA_resize_buffers
;
1933 GLboolean MESA_ycbcr_texture
;
1934 GLboolean NV_blend_square
;
1935 GLboolean NV_fragment_program
;
1936 GLboolean NV_light_max_exponent
;
1937 GLboolean NV_point_sprite
;
1938 GLboolean NV_texgen_reflection
;
1939 GLboolean NV_texture_rectangle
;
1940 GLboolean NV_vertex_program
;
1941 GLboolean NV_vertex_program1_1
;
1942 GLboolean SGI_color_matrix
;
1943 GLboolean SGI_color_table
;
1944 GLboolean SGI_texture_color_table
;
1945 GLboolean SGIS_generate_mipmap
;
1946 GLboolean SGIS_pixel_texture
;
1947 GLboolean SGIS_texture_edge_clamp
;
1948 GLboolean SGIS_texture_lod
;
1949 GLboolean SGIX_depth_texture
;
1950 GLboolean SGIX_pixel_texture
;
1951 GLboolean SGIX_shadow
;
1952 GLboolean SGIX_shadow_ambient
; /* or GL_ARB_shadow_ambient */
1953 GLboolean TDFX_texture_compression_FXT1
;
1956 /* The extension string */
1957 const GLubyte
*String
;
1962 * A stack of matrices (projection, modelview, color, texture, etc).
1966 GLmatrix
*Top
; /**< points into Stack */
1967 GLmatrix
*Stack
; /**< array [MaxDepth] of GLmatrix */
1968 GLuint Depth
; /**< 0 <= Depth < MaxDepth */
1969 GLuint MaxDepth
; /**< size of Stack[] array */
1970 GLuint DirtyFlag
; /**< _NEW_MODELVIEW or _NEW_PROJECTION, for example */
1975 * \name Bits for image transfer operations
1977 * \sa __GLcontextRec::ImageTransferState.
1980 #define IMAGE_SCALE_BIAS_BIT 0x1
1981 #define IMAGE_SHIFT_OFFSET_BIT 0x2
1982 #define IMAGE_MAP_COLOR_BIT 0x4
1983 #define IMAGE_COLOR_TABLE_BIT 0x8
1984 #define IMAGE_CONVOLUTION_BIT 0x10
1985 #define IMAGE_POST_CONVOLUTION_SCALE_BIAS 0x20
1986 #define IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT 0x40
1987 #define IMAGE_COLOR_MATRIX_BIT 0x80
1988 #define IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT 0x100
1989 #define IMAGE_HISTOGRAM_BIT 0x200
1990 #define IMAGE_MIN_MAX_BIT 0x400
1991 #define IMAGE_CLAMP_BIT 0x800 /* extra */
1994 /** Transfer ops up to convolution */
1995 #define IMAGE_PRE_CONVOLUTION_BITS (IMAGE_SCALE_BIAS_BIT | \
1996 IMAGE_SHIFT_OFFSET_BIT | \
1997 IMAGE_MAP_COLOR_BIT | \
1998 IMAGE_COLOR_TABLE_BIT)
2000 /** Transfer ops after convolution */
2001 #define IMAGE_POST_CONVOLUTION_BITS (IMAGE_POST_CONVOLUTION_SCALE_BIAS | \
2002 IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT | \
2003 IMAGE_COLOR_MATRIX_BIT | \
2004 IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT |\
2005 IMAGE_HISTOGRAM_BIT | \
2011 * \name Bits to indicate what state has changed.
2016 #define _NEW_MODELVIEW 0x1 /**< __GLcontextRec::ModelView */
2017 #define _NEW_PROJECTION 0x2 /**< __GLcontextRec::Projection */
2018 #define _NEW_TEXTURE_MATRIX 0x4 /**< __GLcontextRec::TextureMatrix */
2019 #define _NEW_COLOR_MATRIX 0x8 /**< __GLcontextRec::ColorMatrix */
2020 #define _NEW_ACCUM 0x10 /**< __GLcontextRec::Accum */
2021 #define _NEW_COLOR 0x20 /**< __GLcontextRec::Color */
2022 #define _NEW_DEPTH 0x40 /**< __GLcontextRec::Depth */
2023 #define _NEW_EVAL 0x80 /**< __GLcontextRec::Eval, __GLcontextRec::EvalMap */
2024 #define _NEW_FOG 0x100 /**< __GLcontextRec::Fog */
2025 #define _NEW_HINT 0x200 /**< __GLcontextRec::Hint */
2026 #define _NEW_LIGHT 0x400 /**< __GLcontextRec::Light */
2027 #define _NEW_LINE 0x800 /**< __GLcontextRec::Line */
2028 #define _NEW_PIXEL 0x1000 /**< __GLcontextRec::Pixel */
2029 #define _NEW_POINT 0x2000 /**< __GLcontextRec::Point */
2030 #define _NEW_POLYGON 0x4000 /**< __GLcontextRec::Polygon */
2031 #define _NEW_POLYGONSTIPPLE 0x8000 /**< __GLcontextRec::PolygonStipple */
2032 #define _NEW_SCISSOR 0x10000 /**< __GLcontextRec::Scissor */
2033 #define _NEW_STENCIL 0x20000 /**< __GLcontextRec::Stencil */
2034 #define _NEW_TEXTURE 0x40000 /**< __GLcontextRec::Texture */
2035 #define _NEW_TRANSFORM 0x80000 /**< __GLcontextRec::Transform */
2036 #define _NEW_VIEWPORT 0x100000 /**< __GLcontextRec::Viewport */
2037 #define _NEW_PACKUNPACK 0x200000 /**< __GLcontextRec::Pack, __GLcontextRec::Unpack */
2038 #define _NEW_ARRAY 0x400000 /**< __GLcontextRec::Array */
2039 #define _NEW_RENDERMODE 0x800000 /**< __GLcontextRec::RenderMode, __GLcontextRec::Feedback, __GLcontextRec::Select */
2040 #define _NEW_BUFFERS 0x1000000 /**< __GLcontextRec::Visual, __GLcontextRec::DrawBuffer, */
2041 #define _NEW_MULTISAMPLE 0x2000000 /**< __GLcontextRec::Multisample */
2042 #define _NEW_TRACK_MATRIX 0x4000000 /**< __GLcontextRec::VertexProgram */
2043 #define _NEW_PROGRAM 0x8000000 /**< __GLcontextRec::VertexProgram */
2049 * \name Bits to track array state changes
2051 * Also used to summarize array enabled.
2054 #define _NEW_ARRAY_VERTEX VERT_BIT_POS
2055 #define _NEW_ARRAY_WEIGHT VERT_BIT_WEIGHT
2056 #define _NEW_ARRAY_NORMAL VERT_BIT_NORMAL
2057 #define _NEW_ARRAY_COLOR0 VERT_BIT_COLOR0
2058 #define _NEW_ARRAY_COLOR1 VERT_BIT_COLOR1
2059 #define _NEW_ARRAY_FOGCOORD VERT_BIT_FOG
2060 #define _NEW_ARRAY_INDEX VERT_BIT_SIX
2061 #define _NEW_ARRAY_EDGEFLAG VERT_BIT_SEVEN
2062 #define _NEW_ARRAY_TEXCOORD_0 VERT_BIT_TEX0
2063 #define _NEW_ARRAY_TEXCOORD_1 VERT_BIT_TEX1
2064 #define _NEW_ARRAY_TEXCOORD_2 VERT_BIT_TEX2
2065 #define _NEW_ARRAY_TEXCOORD_3 VERT_BIT_TEX3
2066 #define _NEW_ARRAY_TEXCOORD_4 VERT_BIT_TEX4
2067 #define _NEW_ARRAY_TEXCOORD_5 VERT_BIT_TEX5
2068 #define _NEW_ARRAY_TEXCOORD_6 VERT_BIT_TEX6
2069 #define _NEW_ARRAY_TEXCOORD_7 VERT_BIT_TEX7
2070 #define _NEW_ARRAY_ATTRIB_0 0x10000 /* start at bit 16 */
2071 #define _NEW_ARRAY_ALL 0xffffffff
2074 #define _NEW_ARRAY_TEXCOORD(i) (_NEW_ARRAY_TEXCOORD_0 << (i))
2075 #define _NEW_ARRAY_ATTRIB(i) (_NEW_ARRAY_ATTRIB_0 << (i))
2080 * \name A bunch of flags that we think might be useful to drivers.
2082 * Set in the __GLcontextRec::_TriangleCaps bitfield.
2085 #define DD_FLATSHADE 0x1
2086 #define DD_SEPARATE_SPECULAR 0x2
2087 #define DD_TRI_CULL_FRONT_BACK 0x4 /* special case on some hw */
2088 #define DD_TRI_LIGHT_TWOSIDE 0x8
2089 #define DD_TRI_UNFILLED 0x10
2090 #define DD_TRI_SMOOTH 0x20
2091 #define DD_TRI_STIPPLE 0x40
2092 #define DD_TRI_OFFSET 0x80
2093 #define DD_LINE_SMOOTH 0x100
2094 #define DD_LINE_STIPPLE 0x200
2095 #define DD_LINE_WIDTH 0x400
2096 #define DD_POINT_SMOOTH 0x800
2097 #define DD_POINT_SIZE 0x1000
2098 #define DD_POINT_ATTEN 0x2000
2103 * \name Define the state changes under which each of these bits might change
2106 #define _DD_NEW_FLATSHADE _NEW_LIGHT
2107 #define _DD_NEW_SEPARATE_SPECULAR (_NEW_LIGHT | _NEW_FOG | _NEW_PROGRAM)
2108 #define _DD_NEW_TRI_CULL_FRONT_BACK _NEW_POLYGON
2109 #define _DD_NEW_TRI_LIGHT_TWOSIDE _NEW_LIGHT
2110 #define _DD_NEW_TRI_UNFILLED _NEW_POLYGON
2111 #define _DD_NEW_TRI_SMOOTH _NEW_POLYGON
2112 #define _DD_NEW_TRI_STIPPLE _NEW_POLYGON
2113 #define _DD_NEW_TRI_OFFSET _NEW_POLYGON
2114 #define _DD_NEW_LINE_SMOOTH _NEW_LINE
2115 #define _DD_NEW_LINE_STIPPLE _NEW_LINE
2116 #define _DD_NEW_LINE_WIDTH _NEW_LINE
2117 #define _DD_NEW_POINT_SMOOTH _NEW_POINT
2118 #define _DD_NEW_POINT_SIZE _NEW_POINT
2119 #define _DD_NEW_POINT_ATTEN _NEW_POINT
2123 #define _MESA_NEW_NEED_EYE_COORDS (_NEW_LIGHT | \
2128 #define _MESA_NEW_NEED_NORMALS (_NEW_LIGHT | \
2131 #define _IMAGE_NEW_TRANSFER_STATE (_NEW_PIXEL | _NEW_COLOR_MATRIX)
2137 * Forward declaration of display list data types:
2140 typedef union node Node
;
2143 /* This has to be included here. */
2147 #define NUM_VERTEX_FORMAT_ENTRIES (sizeof(GLvertexformat) / sizeof(void *))
2150 * Core Mesa's support for tnl modules:
2152 struct gl_tnl_module
{
2154 * Vertex format to be lazily swapped into current dispatch.
2156 const GLvertexformat
*Current
;
2159 * \name Record of functions swapped out.
2160 * On restore, only need to swap these functions back in.
2163 void *Swapped
[NUM_VERTEX_FORMAT_ENTRIES
][2];
2168 struct mesa_list_state
{
2169 GLuint CallDepth
; /**< Current recursion calling depth */
2170 Node
*CurrentListPtr
; /**< Head of list being compiled */
2171 GLuint CurrentListNum
; /**< Number of the list being compiled */
2172 Node
*CurrentBlock
; /**< Pointer to current block of nodes */
2173 GLuint CurrentPos
; /**< Index into current block of nodes */
2174 GLvertexformat ListVtxfmt
;
2176 GLubyte ActiveAttribSize
[VERT_ATTRIB_MAX
];
2177 GLfloat CurrentAttrib
[VERT_ATTRIB_MAX
][4];
2179 GLubyte ActiveMaterialSize
[MAT_ATTRIB_MAX
];
2180 GLfloat CurrentMaterial
[MAT_ATTRIB_MAX
][4];
2182 GLubyte ActiveIndex
;
2183 GLfloat CurrentIndex
;
2185 GLubyte ActiveEdgeFlag
;
2186 GLboolean CurrentEdgeFlag
;
2193 * This is the central context data structure for Mesa. Almost all
2194 * OpenGL state is contained in this structure.
2195 * Think of this as a base class from which device drivers will derive
2198 struct __GLcontextRec
{
2200 * \name OS related interfaces.
2202 * These \b must be the first members of this structure, because they are
2203 * exposed to the outside world (i.e. GLX extension).
2206 __GLimports imports
;
2207 __GLexports exports
;
2210 /** State possibly shared with other contexts in the address space */
2211 struct gl_shared_state
*Shared
;
2213 /** \name API function pointer tables */
2215 struct _glapi_table
*Save
; /**< Display list save functions */
2216 struct _glapi_table
*Exec
; /**< Execute functions */
2217 struct _glapi_table
*CurrentDispatch
; /**< == Save or Exec !! */
2221 GLframebuffer
*DrawBuffer
; /**< buffer for writing */
2222 GLframebuffer
*ReadBuffer
; /**< buffer for reading */
2225 * Device driver function pointer table
2227 struct dd_function_table Driver
;
2229 void *DriverCtx
; /**< Points to device driver context/state */
2230 void *DriverMgrCtx
; /**< Points to device driver manager (optional)*/
2232 /** Core/Driver constants */
2233 struct gl_constants Const
;
2235 /** \name The various 4x4 matrix stacks */
2237 struct matrix_stack ModelviewMatrixStack
;
2238 struct matrix_stack ProjectionMatrixStack
;
2239 struct matrix_stack ColorMatrixStack
;
2240 struct matrix_stack TextureMatrixStack
[MAX_TEXTURE_COORD_UNITS
];
2241 struct matrix_stack ProgramMatrixStack
[MAX_PROGRAM_MATRICES
];
2242 struct matrix_stack
*CurrentStack
; /**< Points to one of the above stacks */
2245 /** Combined modelview and projection matrix */
2246 GLmatrix _ModelProjectMatrix
;
2248 /** \name Display lists */
2249 struct mesa_list_state ListState
;
2251 GLboolean ExecuteFlag
; /**< Execute GL commands? */
2252 GLboolean CompileFlag
; /**< Compile GL commands into display list? */
2255 struct gl_extensions Extensions
;
2257 /** \name Renderer attribute stack */
2259 GLuint AttribStackDepth
;
2260 struct gl_attrib_node
*AttribStack
[MAX_ATTRIB_STACK_DEPTH
];
2263 /** \name Renderer attribute groups
2265 * We define a struct for each attribute group to make pushing and popping
2266 * attributes easy. Also it's a good organization.
2269 struct gl_accum_attrib Accum
; /**< Accumulation buffer attributes */
2270 struct gl_colorbuffer_attrib Color
; /**< Color buffers attributes */
2271 struct gl_current_attrib Current
; /**< Current attributes */
2272 struct gl_depthbuffer_attrib Depth
; /**< Depth buffer attributes */
2273 struct gl_eval_attrib Eval
; /**< Eval attributes */
2274 struct gl_fog_attrib Fog
; /**< Fog attributes */
2275 struct gl_hint_attrib Hint
; /**< Hint attributes */
2276 struct gl_light_attrib Light
; /**< Light attributes */
2277 struct gl_line_attrib Line
; /**< Line attributes */
2278 struct gl_list_attrib List
; /**< List attributes */
2279 struct gl_multisample_attrib Multisample
;
2280 struct gl_pixel_attrib Pixel
; /**< Pixel attributes */
2281 struct gl_point_attrib Point
; /**< Point attributes */
2282 struct gl_polygon_attrib Polygon
; /**< Polygon attributes */
2283 GLuint PolygonStipple
[32]; /**< Polygon stipple */
2284 struct gl_scissor_attrib Scissor
; /**< Scissor attributes */
2285 struct gl_stencil_attrib Stencil
; /**< Stencil buffer attributes */
2286 struct gl_texture_attrib Texture
; /**< Texture attributes */
2287 struct gl_transform_attrib Transform
; /**< Transformation attributes */
2288 struct gl_viewport_attrib Viewport
; /**< Viewport attributes */
2291 /** \name Other attribute groups */
2293 struct gl_histogram_attrib Histogram
;
2294 struct gl_minmax_attrib MinMax
;
2295 struct gl_convolution_attrib Convolution1D
;
2296 struct gl_convolution_attrib Convolution2D
;
2297 struct gl_convolution_attrib Separable2D
;
2300 /** \name Client attribute stack */
2302 GLuint ClientAttribStackDepth
;
2303 struct gl_attrib_node
*ClientAttribStack
[MAX_CLIENT_ATTRIB_STACK_DEPTH
];
2306 /** \name Client attribute groups */
2308 struct gl_array_attrib Array
; /**< Vertex arrays */
2309 struct gl_pixelstore_attrib Pack
; /**< Pixel packing */
2310 struct gl_pixelstore_attrib Unpack
; /**< Pixel unpacking */
2311 struct gl_pixelstore_attrib DefaultPacking
; /**< Default params */
2313 struct gl_evaluators EvalMap
; /**< All evaluators */
2314 struct gl_feedback Feedback
; /**< Feedback */
2315 struct gl_selection Select
; /**< Selection */
2317 struct gl_color_table ColorTable
; /**< Pre-convolution */
2318 struct gl_color_table ProxyColorTable
; /**< Pre-convolution */
2319 struct gl_color_table PostConvolutionColorTable
;
2320 struct gl_color_table ProxyPostConvolutionColorTable
;
2321 struct gl_color_table PostColorMatrixColorTable
;
2322 struct gl_color_table ProxyPostColorMatrixColorTable
;
2324 struct program_state Program
; /**< for vertex or fragment progs */
2325 struct vertex_program_state VertexProgram
; /**< GL_NV_vertex_program */
2326 struct fragment_program_state FragmentProgram
; /**< GL_NV_fragment_program */
2328 struct occlusion_state Occlusion
; /**< GL_ARB_occlusion_query */
2330 GLenum ErrorValue
; /**< Last error code */
2331 GLenum RenderMode
; /**< either GL_RENDER, GL_SELECT, GL_FEEDBACK */
2332 GLuint NewState
; /**< bitwise-or of _NEW_* flags */
2335 /** \name Derived */
2337 GLuint _TriangleCaps
; /**< bitwise-or of DD_* flags */
2338 GLuint _ImageTransferState
;/**< bitwise-or of IMAGE_*_BIT flags */
2339 GLfloat _EyeZDir
[3];
2340 GLfloat _ModelViewInvScale
;
2341 GLuint _NeedEyeCoords
;
2342 GLuint _ForceEyeCoords
;
2343 GLboolean _RotateMode
;
2344 GLenum _CurrentProgram
; /* currently executing program */
2346 struct gl_shine_tab
*_ShineTable
[2]; /**< Active shine tables */
2347 struct gl_shine_tab
*_ShineTabList
; /**< MRU list of inactive shine tables */
2350 struct gl_list_extensions ListExt
; /**< driver dlist extensions */
2353 GLboolean OcclusionResult
; /**< for GL_HP_occlusion_test */
2354 GLboolean OcclusionResultSaved
; /**< for GL_HP_occlusion_test */
2355 GLuint _Facing
; /**< This is a hack for 2-sided stencil test.
2357 * We don't have a better way to communicate this value from
2358 * swrast_setup to swrast. */
2361 /** \name Z buffer stuff */
2363 GLuint DepthMax
; /**< Max depth buffer value */
2364 GLfloat DepthMaxF
; /**< Float max depth buffer value */
2365 GLfloat MRD
; /**< minimum resolvable difference in Z values */
2368 /** \name Color clamping (tentative part of GL_ARB_color_clamp_control) */
2370 GLboolean ClampFragmentColors
;
2371 GLboolean ClampVertexColors
;
2374 /** Should 3Dfx Glide driver catch signals? */
2375 GLboolean CatchSignals
;
2377 /** \name For debugging/development only */
2379 GLboolean FirstTimeCurrent
;
2382 /** Dither disable via MESA_NO_DITHER env var */
2385 /** Core tnl module support */
2386 struct gl_tnl_module TnlModule
;
2389 * \name Hooks for module contexts.
2391 * These will eventually live in the driver or elsewhere.
2394 void *swrast_context
;
2395 void *swsetup_context
;
2396 void *swtnl_context
;
2398 void *acache_context
;
2404 /** The string names for GL_POINT, GL_LINE_LOOP, etc */
2405 extern const char *_mesa_prim_name
[GL_POLYGON
+4];
2409 extern int MESA_VERBOSE
;
2410 extern int MESA_DEBUG_FLAGS
;
2411 # define MESA_FUNCTION __FUNCTION__
2413 # define MESA_VERBOSE 0
2414 # define MESA_DEBUG_FLAGS 0
2415 # define MESA_FUNCTION "a function"
2423 VERBOSE_VARRAY
= 0x0001,
2424 VERBOSE_TEXTURE
= 0x0002,
2425 VERBOSE_IMMEDIATE
= 0x0004,
2426 VERBOSE_PIPELINE
= 0x0008,
2427 VERBOSE_DRIVER
= 0x0010,
2428 VERBOSE_STATE
= 0x0020,
2429 VERBOSE_API
= 0x0040,
2430 VERBOSE_DISPLAY_LIST
= 0x0100,
2431 VERBOSE_LIGHTING
= 0x0200,
2432 VERBOSE_PRIMS
= 0x0400,
2433 VERBOSE_VERTS
= 0x0800
2438 DEBUG_ALWAYS_FLUSH
= 0x1
2443 #define Elements(x) sizeof(x)/sizeof(*(x))
2446 #endif /* TYPES_H */