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-2005 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 /* Software accum done with GLshort at this time */
70 # error "illegal number of accumulation bits"
75 * Stencil buffer data type.
78 typedef GLubyte GLstencil
;
79 # define STENCIL_MAX 0xff
80 #elif STENCIL_BITS==16
81 typedef GLushort GLstencil
;
82 # define STENCIL_MAX 0xffff
84 # error "illegal number of stencil bits"
89 * Used for storing intermediate depth buffer values.
90 * The actual depth/Z buffer might use 16 or 32-bit values.
92 * \note Must be 32-bits!
94 typedef GLuint GLdepth
;
98 * Fixed point data type.
102 * Fixed point arithmetic macros
104 #ifndef FIXED_FRAC_BITS
105 #define FIXED_FRAC_BITS 11
108 #define FIXED_SHIFT FIXED_FRAC_BITS
109 #define FIXED_ONE (1 << FIXED_SHIFT)
110 #define FIXED_HALF (1 << (FIXED_SHIFT-1))
111 #define FIXED_FRAC_MASK (FIXED_ONE - 1)
112 #define FIXED_INT_MASK (~FIXED_FRAC_MASK)
113 #define FIXED_EPSILON 1
114 #define FIXED_SCALE ((float) FIXED_ONE)
115 #define FIXED_DBL_SCALE ((double) FIXED_ONE)
116 #define FloatToFixed(X) (IROUND((X) * FIXED_SCALE))
117 #define FixedToDouble(X) ((X) * (1.0 / FIXED_DBL_SCALE))
118 #define IntToFixed(I) ((I) << FIXED_SHIFT)
119 #define FixedToInt(X) ((X) >> FIXED_SHIFT)
120 #define FixedToUns(X) (((unsigned int)(X)) >> FIXED_SHIFT)
121 #define FixedCeil(X) (((X) + FIXED_ONE - FIXED_EPSILON) & FIXED_INT_MASK)
122 #define FixedFloor(X) ((X) & FIXED_INT_MASK)
123 #define FixedToFloat(X) ((X) * (1.0F / FIXED_SCALE))
124 #define PosFloatToFixed(X) FloatToFixed(X)
125 #define SignedFloatToFixed(X) FloatToFixed(X)
130 * \name Some forward type declarations
133 struct _mesa_HashTable
;
134 struct gl_pixelstore_attrib
;
135 struct gl_texture_format
;
136 struct gl_texture_image
;
137 struct gl_texture_object
;
138 typedef struct __GLcontextRec GLcontext
;
139 typedef struct __GLcontextModesRec GLvisual
;
140 typedef struct gl_framebuffer GLframebuffer
;
146 * Indexes for vertex program attributes.
147 * GL_NV_vertex_program aliases generic attributes over the conventional
148 * attributes. In GL_ARB_vertex_program shader the aliasing is optional.
149 * In GL_ARB_vertex_shader / OpenGL 2.0 the aliasing is disallowed (the
150 * generic attributes are distinct/separate).
155 VERT_ATTRIB_WEIGHT
= 1,
156 VERT_ATTRIB_NORMAL
= 2,
157 VERT_ATTRIB_COLOR0
= 3,
158 VERT_ATTRIB_COLOR1
= 4,
161 VERT_ATTRIB_SEVEN
= 7,
162 VERT_ATTRIB_TEX0
= 8,
163 VERT_ATTRIB_TEX1
= 9,
164 VERT_ATTRIB_TEX2
= 10,
165 VERT_ATTRIB_TEX3
= 11,
166 VERT_ATTRIB_TEX4
= 12,
167 VERT_ATTRIB_TEX5
= 13,
168 VERT_ATTRIB_TEX6
= 14,
169 VERT_ATTRIB_TEX7
= 15,
170 VERT_ATTRIB_GENERIC0
= 16,
171 VERT_ATTRIB_GENERIC1
= 17,
172 VERT_ATTRIB_GENERIC2
= 18,
173 VERT_ATTRIB_GENERIC3
= 19,
178 * Bitflags for vertex attributes.
179 * These are used in bitfields in many places.
182 #define VERT_BIT_POS (1 << VERT_ATTRIB_POS)
183 #define VERT_BIT_WEIGHT (1 << VERT_ATTRIB_WEIGHT)
184 #define VERT_BIT_NORMAL (1 << VERT_ATTRIB_NORMAL)
185 #define VERT_BIT_COLOR0 (1 << VERT_ATTRIB_COLOR0)
186 #define VERT_BIT_COLOR1 (1 << VERT_ATTRIB_COLOR1)
187 #define VERT_BIT_FOG (1 << VERT_ATTRIB_FOG)
188 #define VERT_BIT_SIX (1 << VERT_ATTRIB_SIX)
189 #define VERT_BIT_SEVEN (1 << VERT_ATTRIB_SEVEN)
190 #define VERT_BIT_TEX0 (1 << VERT_ATTRIB_TEX0)
191 #define VERT_BIT_TEX1 (1 << VERT_ATTRIB_TEX1)
192 #define VERT_BIT_TEX2 (1 << VERT_ATTRIB_TEX2)
193 #define VERT_BIT_TEX3 (1 << VERT_ATTRIB_TEX3)
194 #define VERT_BIT_TEX4 (1 << VERT_ATTRIB_TEX4)
195 #define VERT_BIT_TEX5 (1 << VERT_ATTRIB_TEX5)
196 #define VERT_BIT_TEX6 (1 << VERT_ATTRIB_TEX6)
197 #define VERT_BIT_TEX7 (1 << VERT_ATTRIB_TEX7)
198 #define VERT_BIT_GENERIC0 (1 << VERT_ATTRIB_GENERIC0)
199 #define VERT_BIT_GENERIC1 (1 << VERT_ATTRIB_GENERIC1)
200 #define VERT_BIT_GENERIC2 (1 << VERT_ATTRIB_GENERIC2)
201 #define VERT_BIT_GENERIC3 (1 << VERT_ATTRIB_GENERIC3)
203 #define VERT_BIT_TEX(u) (1 << (VERT_ATTRIB_TEX0 + (u)))
204 #define VERT_BIT_GENERIC(g) (1 << (VERT_ATTRIB_GENERIC0 + (g)))
209 * Indexes for vertex program result attributes
211 #define VERT_RESULT_HPOS 0
212 #define VERT_RESULT_COL0 1
213 #define VERT_RESULT_COL1 2
214 #define VERT_RESULT_BFC0 3
215 #define VERT_RESULT_BFC1 4
216 #define VERT_RESULT_FOGC 5
217 #define VERT_RESULT_PSIZ 6
218 #define VERT_RESULT_TEX0 7
219 #define VERT_RESULT_TEX1 8
220 #define VERT_RESULT_TEX2 9
221 #define VERT_RESULT_TEX3 10
222 #define VERT_RESULT_TEX4 11
223 #define VERT_RESULT_TEX5 12
224 #define VERT_RESULT_TEX6 13
225 #define VERT_RESULT_TEX7 14
226 #define VERT_RESULT_MAX 15
230 * Indexes for fragment program input attributes.
234 FRAG_ATTRIB_WPOS
= 0,
235 FRAG_ATTRIB_COL0
= 1,
236 FRAG_ATTRIB_COL1
= 2,
237 FRAG_ATTRIB_FOGC
= 3,
238 FRAG_ATTRIB_TEX0
= 4,
239 FRAG_ATTRIB_TEX1
= 5,
240 FRAG_ATTRIB_TEX2
= 6,
241 FRAG_ATTRIB_TEX3
= 7,
242 FRAG_ATTRIB_TEX4
= 8,
243 FRAG_ATTRIB_TEX5
= 9,
244 FRAG_ATTRIB_TEX6
= 10,
245 FRAG_ATTRIB_TEX7
= 11
249 * Bitflags for fragment attributes.
252 #define FRAG_BIT_WPOS (1 << FRAG_ATTRIB_WPOS)
253 #define FRAG_BIT_COL0 (1 << FRAG_ATTRIB_COL0)
254 #define FRAG_BIT_COL1 (1 << FRAG_ATTRIB_COL1)
255 #define FRAG_BIT_FOGC (1 << FRAG_ATTRIB_FOGC)
256 #define FRAG_BIT_TEX0 (1 << FRAG_ATTRIB_TEX0)
257 #define FRAG_BIT_TEX1 (1 << FRAG_ATTRIB_TEX1)
258 #define FRAG_BIT_TEX2 (1 << FRAG_ATTRIB_TEX2)
259 #define FRAG_BIT_TEX3 (1 << FRAG_ATTRIB_TEX3)
260 #define FRAG_BIT_TEX4 (1 << FRAG_ATTRIB_TEX4)
261 #define FRAG_BIT_TEX5 (1 << FRAG_ATTRIB_TEX5)
262 #define FRAG_BIT_TEX6 (1 << FRAG_ATTRIB_TEX6)
263 #define FRAG_BIT_TEX7 (1 << FRAG_ATTRIB_TEX7)
265 #define FRAG_BITS_TEX_ANY (FRAG_BIT_TEX0| \
277 * Indexes for all renderbuffers
280 BUFFER_FRONT_LEFT
= 0, /* the four standard color buffers */
281 BUFFER_BACK_LEFT
= 1,
282 BUFFER_FRONT_RIGHT
= 2,
283 BUFFER_BACK_RIGHT
= 3,
284 BUFFER_AUX0
= 4, /* optional aux buffer */
291 BUFFER_COLOR0
= 11, /* generic renderbuffers */
303 * Bit flags for all renderbuffers
305 #define BUFFER_BIT_FRONT_LEFT (1 << BUFFER_FRONT_LEFT)
306 #define BUFFER_BIT_BACK_LEFT (1 << BUFFER_BACK_LEFT)
307 #define BUFFER_BIT_FRONT_RIGHT (1 << BUFFER_FRONT_RIGHT)
308 #define BUFFER_BIT_BACK_RIGHT (1 << BUFFER_BACK_RIGHT)
309 #define BUFFER_BIT_AUX0 (1 << BUFFER_AUX0)
310 #define BUFFER_BIT_AUX1 (1 << BUFFER_AUX1)
311 #define BUFFER_BIT_AUX2 (1 << BUFFER_AUX2)
312 #define BUFFER_BIT_AUX3 (1 << BUFFER_AUX3)
313 #define BUFFER_BIT_DEPTH (1 << BUFFER_DEPTH)
314 #define BUFFER_BIT_STENCIL (1 << BUFFER_STENCIL)
315 #define BUFFER_BIT_ACCUM (1 << BUFFER_ACCUM)
316 #define BUFFER_BIT_COLOR0 (1 << BUFFER_COLOR0)
317 #define BUFFER_BIT_COLOR1 (1 << BUFFER_COLOR1)
318 #define BUFFER_BIT_COLOR2 (1 << BUFFER_COLOR2)
319 #define BUFFER_BIT_COLOR3 (1 << BUFFER_COLOR3)
320 #define BUFFER_BIT_COLOR4 (1 << BUFFER_COLOR4)
321 #define BUFFER_BIT_COLOR5 (1 << BUFFER_COLOR5)
322 #define BUFFER_BIT_COLOR6 (1 << BUFFER_COLOR6)
323 #define BUFFER_BIT_COLOR7 (1 << BUFFER_COLOR7)
327 * Data structure for color tables
329 struct gl_color_table
331 GLenum Format
; /**< GL_ALPHA, GL_RGB, GL_RGB, etc */
333 GLuint Size
; /**< number of entries (rows) in table */
334 GLvoid
*Table
; /**< points to data of <Type> */
335 GLenum Type
; /**< GL_UNSIGNED_BYTE or GL_FLOAT */
340 GLubyte LuminanceSize
;
341 GLubyte IntensitySize
;
346 * \name Bit flags used for updating material values.
349 #define MAT_ATTRIB_FRONT_AMBIENT 0
350 #define MAT_ATTRIB_BACK_AMBIENT 1
351 #define MAT_ATTRIB_FRONT_DIFFUSE 2
352 #define MAT_ATTRIB_BACK_DIFFUSE 3
353 #define MAT_ATTRIB_FRONT_SPECULAR 4
354 #define MAT_ATTRIB_BACK_SPECULAR 5
355 #define MAT_ATTRIB_FRONT_EMISSION 6
356 #define MAT_ATTRIB_BACK_EMISSION 7
357 #define MAT_ATTRIB_FRONT_SHININESS 8
358 #define MAT_ATTRIB_BACK_SHININESS 9
359 #define MAT_ATTRIB_FRONT_INDEXES 10
360 #define MAT_ATTRIB_BACK_INDEXES 11
361 #define MAT_ATTRIB_MAX 12
363 #define MAT_ATTRIB_AMBIENT(f) (MAT_ATTRIB_FRONT_AMBIENT+(f))
364 #define MAT_ATTRIB_DIFFUSE(f) (MAT_ATTRIB_FRONT_DIFFUSE+(f))
365 #define MAT_ATTRIB_SPECULAR(f) (MAT_ATTRIB_FRONT_SPECULAR+(f))
366 #define MAT_ATTRIB_EMISSION(f) (MAT_ATTRIB_FRONT_EMISSION+(f))
367 #define MAT_ATTRIB_SHININESS(f)(MAT_ATTRIB_FRONT_SHININESS+(f))
368 #define MAT_ATTRIB_INDEXES(f) (MAT_ATTRIB_FRONT_INDEXES+(f))
370 #define MAT_INDEX_AMBIENT 0
371 #define MAT_INDEX_DIFFUSE 1
372 #define MAT_INDEX_SPECULAR 2
374 #define MAT_BIT_FRONT_AMBIENT (1<<MAT_ATTRIB_FRONT_AMBIENT)
375 #define MAT_BIT_BACK_AMBIENT (1<<MAT_ATTRIB_BACK_AMBIENT)
376 #define MAT_BIT_FRONT_DIFFUSE (1<<MAT_ATTRIB_FRONT_DIFFUSE)
377 #define MAT_BIT_BACK_DIFFUSE (1<<MAT_ATTRIB_BACK_DIFFUSE)
378 #define MAT_BIT_FRONT_SPECULAR (1<<MAT_ATTRIB_FRONT_SPECULAR)
379 #define MAT_BIT_BACK_SPECULAR (1<<MAT_ATTRIB_BACK_SPECULAR)
380 #define MAT_BIT_FRONT_EMISSION (1<<MAT_ATTRIB_FRONT_EMISSION)
381 #define MAT_BIT_BACK_EMISSION (1<<MAT_ATTRIB_BACK_EMISSION)
382 #define MAT_BIT_FRONT_SHININESS (1<<MAT_ATTRIB_FRONT_SHININESS)
383 #define MAT_BIT_BACK_SHININESS (1<<MAT_ATTRIB_BACK_SHININESS)
384 #define MAT_BIT_FRONT_INDEXES (1<<MAT_ATTRIB_FRONT_INDEXES)
385 #define MAT_BIT_BACK_INDEXES (1<<MAT_ATTRIB_BACK_INDEXES)
388 #define FRONT_MATERIAL_BITS (MAT_BIT_FRONT_EMISSION | \
389 MAT_BIT_FRONT_AMBIENT | \
390 MAT_BIT_FRONT_DIFFUSE | \
391 MAT_BIT_FRONT_SPECULAR | \
392 MAT_BIT_FRONT_SHININESS | \
393 MAT_BIT_FRONT_INDEXES)
395 #define BACK_MATERIAL_BITS (MAT_BIT_BACK_EMISSION | \
396 MAT_BIT_BACK_AMBIENT | \
397 MAT_BIT_BACK_DIFFUSE | \
398 MAT_BIT_BACK_SPECULAR | \
399 MAT_BIT_BACK_SHININESS | \
400 MAT_BIT_BACK_INDEXES)
402 #define ALL_MATERIAL_BITS (FRONT_MATERIAL_BITS | BACK_MATERIAL_BITS)
406 #define EXP_TABLE_SIZE 512 /**< Specular exponent lookup table sizes */
407 #define SHINE_TABLE_SIZE 256 /**< Material shininess lookup table sizes */
410 * Material shininess lookup table.
414 struct gl_shine_tab
*next
, *prev
;
415 GLfloat tab
[SHINE_TABLE_SIZE
+1];
422 * Light source state.
426 struct gl_light
*next
; /**< double linked list with sentinel */
427 struct gl_light
*prev
;
429 GLfloat Ambient
[4]; /**< ambient color */
430 GLfloat Diffuse
[4]; /**< diffuse color */
431 GLfloat Specular
[4]; /**< specular color */
432 GLfloat EyePosition
[4]; /**< position in eye coordinates */
433 GLfloat EyeDirection
[4]; /**< spotlight dir in eye coordinates */
434 GLfloat SpotExponent
;
435 GLfloat SpotCutoff
; /**< in degrees */
436 GLfloat _CosCutoff
; /**< = MAX(0, cos(SpotCutoff)) */
437 GLfloat ConstantAttenuation
;
438 GLfloat LinearAttenuation
;
439 GLfloat QuadraticAttenuation
;
440 GLboolean Enabled
; /**< On/off flag */
443 * \name Derived fields
446 GLuint _Flags
; /**< State */
448 GLfloat _Position
[4]; /**< position in eye/obj coordinates */
449 GLfloat _VP_inf_norm
[3]; /**< Norm direction to infinite light */
450 GLfloat _h_inf_norm
[3]; /**< Norm( _VP_inf_norm + <0,0,1> ) */
451 GLfloat _NormDirection
[4]; /**< normalized spotlight direction */
452 GLfloat _VP_inf_spot_attenuation
;
454 GLfloat _SpotExpTable
[EXP_TABLE_SIZE
][2]; /**< to replace a pow() call */
455 GLfloat _MatAmbient
[2][3]; /**< material ambient * light ambient */
456 GLfloat _MatDiffuse
[2][3]; /**< material diffuse * light diffuse */
457 GLfloat _MatSpecular
[2][3]; /**< material spec * light specular */
458 GLfloat _dli
; /**< CI diffuse light intensity */
459 GLfloat _sli
; /**< CI specular light intensity */
469 GLfloat Ambient
[4]; /**< ambient color */
470 GLboolean LocalViewer
; /**< Local (or infinite) view point? */
471 GLboolean TwoSide
; /**< Two (or one) sided lighting? */
472 GLenum ColorControl
; /**< either GL_SINGLE_COLOR
473 * or GL_SEPARATE_SPECULAR_COLOR */
482 GLfloat Attrib
[MAT_ATTRIB_MAX
][4];
487 * Accumulation buffer attribute group (GL_ACCUM_BUFFER_BIT)
489 struct gl_accum_attrib
491 GLfloat ClearColor
[4]; /**< Accumulation buffer clear color */
496 * Color buffer attribute group (GL_COLOR_BUFFER_BIT).
498 struct gl_colorbuffer_attrib
500 GLuint ClearIndex
; /**< Index to use for glClear */
501 GLclampf ClearColor
[4]; /**< Color to use for glClear */
503 GLuint IndexMask
; /**< Color index write mask */
504 GLubyte ColorMask
[4]; /**< Each flag is 0xff or 0x0 */
506 GLenum DrawBuffer
[MAX_DRAW_BUFFERS
]; /**< Which buffer to draw into */
509 * \name alpha testing
512 GLboolean AlphaEnabled
; /**< Alpha test enabled flag */
513 GLenum AlphaFunc
; /**< Alpha test function */
514 GLclampf AlphaRef
; /**< Alpha reference value */
521 GLboolean BlendEnabled
; /**< Blending enabled flag */
522 GLenum BlendSrcRGB
; /**< Blending source operator */
523 GLenum BlendDstRGB
; /**< Blending destination operator */
524 GLenum BlendSrcA
; /**< GL_INGR_blend_func_separate */
525 GLenum BlendDstA
; /**< GL_INGR_blend_func_separate */
526 GLenum BlendEquationRGB
; /**< Blending equation */
527 GLenum BlendEquationA
; /**< GL_EXT_blend_equation_separate */
528 GLfloat BlendColor
[4]; /**< Blending color */
535 GLenum LogicOp
; /**< Logic operator */
536 GLboolean IndexLogicOpEnabled
; /**< Color index logic op enabled flag */
537 GLboolean ColorLogicOpEnabled
; /**< RGBA logic op enabled flag */
538 GLboolean _LogicOpEnabled
; /**< RGBA logic op + EXT_blend_logic_op enabled flag */
541 GLboolean DitherFlag
; /**< Dither enable flag */
546 * Current attribute group (GL_CURRENT_BIT).
548 struct gl_current_attrib
551 * \name Values valid only when FLUSH_VERTICES has been called.
554 GLfloat Attrib
[VERT_ATTRIB_MAX
][4]; /**< Current vertex attributes
555 * indexed by VERT_ATTRIB_* */
556 GLfloat Index
; /**< Current color index */
557 GLboolean EdgeFlag
; /**< Current edge flag */
561 * \name Values are always valid.
563 * \note BTW, note how similar this set of attributes is to the SWvertex
564 * data type in the software rasterizer...
567 GLfloat RasterPos
[4]; /**< Current raster position */
568 GLfloat RasterDistance
; /**< Current raster distance */
569 GLfloat RasterColor
[4]; /**< Current raster color */
570 GLfloat RasterSecondaryColor
[4]; /**< Current raster secondary color */
571 GLfloat RasterIndex
; /**< Current raster index */
572 GLfloat RasterTexCoords
[MAX_TEXTURE_UNITS
][4];/**< Current raster texcoords */
573 GLboolean RasterPosValid
; /**< Raster pos valid flag */
579 * Depth buffer attribute group (GL_DEPTH_BUFFER_BIT).
581 struct gl_depthbuffer_attrib
583 GLenum Func
; /**< Function for depth buffer compare */
584 GLclampd Clear
; /**< Value to clear depth buffer to */
585 GLboolean Test
; /**< Depth buffering enabled flag */
586 GLboolean Mask
; /**< Depth buffer writable? */
587 GLboolean OcclusionTest
; /**< GL_HP_occlusion_test */
588 GLboolean BoundsTest
; /**< GL_EXT_depth_bounds_test */
589 GLfloat BoundsMin
, BoundsMax
;/**< GL_EXT_depth_bounds_test */
594 * glEnable()/glDisable() attribute group (GL_ENABLE_BIT).
596 struct gl_enable_attrib
599 GLboolean AutoNormal
;
602 GLboolean ColorMaterial
;
603 GLboolean ColorTable
; /* SGI_color_table */
604 GLboolean PostColorMatrixColorTable
; /* SGI_color_table */
605 GLboolean PostConvolutionColorTable
; /* SGI_color_table */
606 GLboolean Convolution1D
;
607 GLboolean Convolution2D
;
608 GLboolean Separable2D
;
614 GLboolean Light
[MAX_LIGHTS
];
616 GLboolean LineSmooth
;
617 GLboolean LineStipple
;
618 GLboolean IndexLogicOp
;
619 GLboolean ColorLogicOp
;
620 GLboolean Map1Color4
;
622 GLboolean Map1Normal
;
623 GLboolean Map1TextureCoord1
;
624 GLboolean Map1TextureCoord2
;
625 GLboolean Map1TextureCoord3
;
626 GLboolean Map1TextureCoord4
;
627 GLboolean Map1Vertex3
;
628 GLboolean Map1Vertex4
;
629 GLboolean Map1Attrib
[16]; /* GL_NV_vertex_program */
630 GLboolean Map2Color4
;
632 GLboolean Map2Normal
;
633 GLboolean Map2TextureCoord1
;
634 GLboolean Map2TextureCoord2
;
635 GLboolean Map2TextureCoord3
;
636 GLboolean Map2TextureCoord4
;
637 GLboolean Map2Vertex3
;
638 GLboolean Map2Vertex4
;
639 GLboolean Map2Attrib
[16]; /* GL_NV_vertex_program */
642 GLboolean PixelTexture
;
643 GLboolean PointSmooth
;
644 GLboolean PolygonOffsetPoint
;
645 GLboolean PolygonOffsetLine
;
646 GLboolean PolygonOffsetFill
;
647 GLboolean PolygonSmooth
;
648 GLboolean PolygonStipple
;
649 GLboolean RescaleNormals
;
652 GLboolean StencilTwoSide
; /* GL_EXT_stencil_two_side */
653 GLboolean MultisampleEnabled
; /* GL_ARB_multisample */
654 GLboolean SampleAlphaToCoverage
; /* GL_ARB_multisample */
655 GLboolean SampleAlphaToOne
; /* GL_ARB_multisample */
656 GLboolean SampleCoverage
; /* GL_ARB_multisample */
657 GLboolean SampleCoverageInvert
; /* GL_ARB_multisample */
658 GLboolean RasterPositionUnclipped
; /* GL_IBM_rasterpos_clip */
659 GLuint Texture
[MAX_TEXTURE_IMAGE_UNITS
];
660 GLuint TexGen
[MAX_TEXTURE_COORD_UNITS
];
661 /* SGI_texture_color_table */
662 GLboolean TextureColorTable
[MAX_TEXTURE_IMAGE_UNITS
];
663 /* GL_NV_vertex_program */
664 GLboolean VertexProgram
;
665 GLboolean VertexProgramPointSize
;
666 GLboolean VertexProgramTwoSide
;
667 /* GL_ARB_point_sprite / GL_NV_point_sprite */
668 GLboolean PointSprite
;
669 GLboolean FragmentShaderATI
;
674 * Evaluator attribute group (GL_EVAL_BIT).
676 struct gl_eval_attrib
682 GLboolean Map1Color4
;
684 GLboolean Map1Normal
;
685 GLboolean Map1TextureCoord1
;
686 GLboolean Map1TextureCoord2
;
687 GLboolean Map1TextureCoord3
;
688 GLboolean Map1TextureCoord4
;
689 GLboolean Map1Vertex3
;
690 GLboolean Map1Vertex4
;
691 GLboolean Map1Attrib
[16]; /* GL_NV_vertex_program */
692 GLboolean Map2Color4
;
694 GLboolean Map2Normal
;
695 GLboolean Map2TextureCoord1
;
696 GLboolean Map2TextureCoord2
;
697 GLboolean Map2TextureCoord3
;
698 GLboolean Map2TextureCoord4
;
699 GLboolean Map2Vertex3
;
700 GLboolean Map2Vertex4
;
701 GLboolean Map2Attrib
[16]; /* GL_NV_vertex_program */
702 GLboolean AutoNormal
;
706 * \name Map Grid endpoints and divisions and calculated du values
710 GLfloat MapGrid1u1
, MapGrid1u2
, MapGrid1du
;
711 GLint MapGrid2un
, MapGrid2vn
;
712 GLfloat MapGrid2u1
, MapGrid2u2
, MapGrid2du
;
713 GLfloat MapGrid2v1
, MapGrid2v2
, MapGrid2dv
;
719 * Fog attribute group (GL_FOG_BIT).
723 GLboolean Enabled
; /**< Fog enabled flag */
724 GLfloat Color
[4]; /**< Fog color */
725 GLfloat Density
; /**< Density >= 0.0 */
726 GLfloat Start
; /**< Start distance in eye coords */
727 GLfloat End
; /**< End distance in eye coords */
728 GLfloat Index
; /**< Fog index */
729 GLenum Mode
; /**< Fog mode */
730 GLboolean ColorSumEnabled
;
731 GLenum FogCoordinateSource
; /**< GL_EXT_fog_coord */
736 * Hint attribute group (GL_HINT_BIT).
738 * Values are always one of GL_FASTEST, GL_NICEST, or GL_DONT_CARE.
740 struct gl_hint_attrib
742 GLenum PerspectiveCorrection
;
745 GLenum PolygonSmooth
;
747 GLenum ClipVolumeClipping
; /**< GL_EXT_clip_volume_hint */
748 GLenum TextureCompression
; /**< GL_ARB_texture_compression */
749 GLenum GenerateMipmap
; /**< GL_SGIS_generate_mipmap */
750 GLenum FragmentShaderDerivative
; /**< GL_ARB_fragment_shader */
755 * Histogram attributes.
757 struct gl_histogram_attrib
759 GLuint Width
; /**< number of table entries */
760 GLint Format
; /**< GL_ALPHA, GL_RGB, etc */
761 GLuint Count
[HISTOGRAM_TABLE_SIZE
][4]; /**< the histogram */
762 GLboolean Sink
; /**< terminate image transfer? */
763 GLubyte RedSize
; /**< Bits per counter */
767 GLubyte LuminanceSize
;
772 * Color Min/max state.
774 struct gl_minmax_attrib
778 GLfloat Min
[4], Max
[4]; /**< RGBA */
783 * Image convolution state.
785 struct gl_convolution_attrib
788 GLenum InternalFormat
;
791 GLfloat Filter
[MAX_CONVOLUTION_WIDTH
* MAX_CONVOLUTION_HEIGHT
* 4];
799 #define LIGHT_SPOT 0x1
800 #define LIGHT_LOCAL_VIEWER 0x2
801 #define LIGHT_POSITIONAL 0x4
802 #define LIGHT_NEED_VERTICES (LIGHT_POSITIONAL|LIGHT_LOCAL_VIEWER)
807 * Lighting attribute group (GL_LIGHT_BIT).
809 struct gl_light_attrib
811 struct gl_light Light
[MAX_LIGHTS
]; /**< Array of light sources */
812 struct gl_lightmodel Model
; /**< Lighting model */
815 * Must flush FLUSH_VERTICES before referencing:
818 struct gl_material Material
; /**< Includes front & back values */
821 GLboolean Enabled
; /**< Lighting enabled flag */
822 GLenum ShadeModel
; /**< GL_FLAT or GL_SMOOTH */
823 GLenum ColorMaterialFace
; /**< GL_FRONT, BACK or FRONT_AND_BACK */
824 GLenum ColorMaterialMode
; /**< GL_AMBIENT, GL_DIFFUSE, etc */
825 GLuint ColorMaterialBitmask
; /**< bitmask formed from Face and Mode */
826 GLboolean ColorMaterialEnabled
;
828 struct gl_light EnabledList
; /**< List sentinel */
831 * Derived state for optimizations:
834 GLboolean _NeedEyeCoords
;
835 GLboolean _NeedVertices
; /**< Use fast shader? */
836 GLuint _Flags
; /**< LIGHT_* flags, see above */
837 GLfloat _BaseColor
[2][3];
843 * Line attribute group (GL_LINE_BIT).
845 struct gl_line_attrib
847 GLboolean SmoothFlag
; /**< GL_LINE_SMOOTH enabled? */
848 GLboolean StippleFlag
; /**< GL_LINE_STIPPLE enabled? */
849 GLushort StipplePattern
; /**< Stipple pattern */
850 GLint StippleFactor
; /**< Stipple repeat factor */
851 GLfloat Width
; /**< Line width */
852 GLfloat _Width
; /**< Clamped Line width */
857 * Display list attribute group (GL_LIST_BIT).
859 struct gl_list_attrib
866 * Used by device drivers to hook new commands into display lists.
868 struct gl_list_instruction
871 void (*Execute
)( GLcontext
*ctx
, void *data
);
872 void (*Destroy
)( GLcontext
*ctx
, void *data
);
873 void (*Print
)( GLcontext
*ctx
, void *data
);
876 #define MAX_DLIST_EXT_OPCODES 16
879 * Used by device drivers to hook new commands into display lists.
881 struct gl_list_extensions
883 struct gl_list_instruction Opcode
[MAX_DLIST_EXT_OPCODES
];
889 * Multisample attribute group (GL_MULTISAMPLE_BIT).
891 struct gl_multisample_attrib
894 GLboolean SampleAlphaToCoverage
;
895 GLboolean SampleAlphaToOne
;
896 GLboolean SampleCoverage
;
897 GLfloat SampleCoverageValue
;
898 GLboolean SampleCoverageInvert
;
903 * Pixel attribute group (GL_PIXEL_MODE_BIT).
905 struct gl_pixel_attrib
907 GLenum ReadBuffer
; /**< source buffer for glRead/CopyPixels() */
908 GLfloat RedBias
, RedScale
;
909 GLfloat GreenBias
, GreenScale
;
910 GLfloat BlueBias
, BlueScale
;
911 GLfloat AlphaBias
, AlphaScale
;
912 GLfloat DepthBias
, DepthScale
;
913 GLint IndexShift
, IndexOffset
;
914 GLboolean MapColorFlag
;
915 GLboolean MapStencilFlag
;
916 GLfloat ZoomX
, ZoomY
;
917 /* XXX move these out of gl_pixel_attrib */
918 GLint MapStoSsize
; /**< Size of each pixel map */
928 GLint MapStoS
[MAX_PIXEL_MAP_TABLE
]; /**< Pixel map tables */
929 GLint MapItoI
[MAX_PIXEL_MAP_TABLE
];
930 GLfloat MapItoR
[MAX_PIXEL_MAP_TABLE
];
931 GLfloat MapItoG
[MAX_PIXEL_MAP_TABLE
];
932 GLfloat MapItoB
[MAX_PIXEL_MAP_TABLE
];
933 GLfloat MapItoA
[MAX_PIXEL_MAP_TABLE
];
934 GLubyte MapItoR8
[MAX_PIXEL_MAP_TABLE
]; /**< converted to 8-bit color */
935 GLubyte MapItoG8
[MAX_PIXEL_MAP_TABLE
];
936 GLubyte MapItoB8
[MAX_PIXEL_MAP_TABLE
];
937 GLubyte MapItoA8
[MAX_PIXEL_MAP_TABLE
];
938 GLfloat MapRtoR
[MAX_PIXEL_MAP_TABLE
];
939 GLfloat MapGtoG
[MAX_PIXEL_MAP_TABLE
];
940 GLfloat MapBtoB
[MAX_PIXEL_MAP_TABLE
];
941 GLfloat MapAtoA
[MAX_PIXEL_MAP_TABLE
];
942 /** GL_EXT_histogram */
943 GLboolean HistogramEnabled
;
944 GLboolean MinMaxEnabled
;
945 /** GL_SGIS_pixel_texture */
946 GLboolean PixelTextureEnabled
;
947 GLenum FragmentRgbSource
;
948 GLenum FragmentAlphaSource
;
949 /** GL_SGI_color_matrix */
950 GLfloat PostColorMatrixScale
[4]; /**< RGBA */
951 GLfloat PostColorMatrixBias
[4]; /**< RGBA */
952 /** GL_SGI_color_table */
953 GLfloat ColorTableScale
[4];
954 GLfloat ColorTableBias
[4];
955 GLboolean ColorTableEnabled
;
956 GLfloat PCCTscale
[4];
958 GLboolean PostConvolutionColorTableEnabled
;
959 GLfloat PCMCTscale
[4];
960 GLfloat PCMCTbias
[4];
961 GLboolean PostColorMatrixColorTableEnabled
;
962 /** GL_SGI_texture_color_table */
963 GLfloat TextureColorTableScale
[4];
964 GLfloat TextureColorTableBias
[4];
966 GLboolean Convolution1DEnabled
;
967 GLboolean Convolution2DEnabled
;
968 GLboolean Separable2DEnabled
;
969 GLfloat ConvolutionBorderColor
[3][4];
970 GLenum ConvolutionBorderMode
[3];
971 GLfloat ConvolutionFilterScale
[3][4];
972 GLfloat ConvolutionFilterBias
[3][4];
973 GLfloat PostConvolutionScale
[4]; /**< RGBA */
974 GLfloat PostConvolutionBias
[4]; /**< RGBA */
979 * Point attribute group (GL_POINT_BIT).
981 struct gl_point_attrib
983 GLboolean SmoothFlag
; /**< True if GL_POINT_SMOOTH is enabled */
984 GLfloat Size
; /**< User-specified point size */
985 GLfloat _Size
; /**< Size clamped to Const.Min/MaxPointSize */
986 GLfloat Params
[3]; /**< GL_EXT_point_parameters */
987 GLfloat MinSize
, MaxSize
; /**< GL_EXT_point_parameters */
988 GLfloat Threshold
; /**< GL_EXT_point_parameters */
989 GLboolean _Attenuated
; /**< True if Params != [1, 0, 0] */
990 GLboolean PointSprite
; /**< GL_NV_point_sprite / GL_NV_point_sprite */
991 GLboolean CoordReplace
[MAX_TEXTURE_UNITS
]; /**< GL_NV/ARB_point_sprite */
992 GLenum SpriteRMode
; /**< GL_NV_point_sprite (only!) */
993 GLenum SpriteOrigin
; /**< GL_ARB_point_sprite */
998 * Polygon attribute group (GL_POLYGON_BIT).
1000 struct gl_polygon_attrib
1002 GLenum FrontFace
; /**< Either GL_CW or GL_CCW */
1003 GLenum FrontMode
; /**< Either GL_POINT, GL_LINE or GL_FILL */
1004 GLenum BackMode
; /**< Either GL_POINT, GL_LINE or GL_FILL */
1005 GLboolean _FrontBit
; /**< 0=GL_CCW, 1=GL_CW */
1006 GLboolean CullFlag
; /**< Culling on/off flag */
1007 GLboolean SmoothFlag
; /**< True if GL_POLYGON_SMOOTH is enabled */
1008 GLboolean StippleFlag
; /**< True if GL_POLYGON_STIPPLE is enabled */
1009 GLenum CullFaceMode
; /**< Culling mode GL_FRONT or GL_BACK */
1010 GLfloat OffsetFactor
; /**< Polygon offset factor, from user */
1011 GLfloat OffsetUnits
; /**< Polygon offset units, from user */
1012 GLboolean OffsetPoint
; /**< Offset in GL_POINT mode */
1013 GLboolean OffsetLine
; /**< Offset in GL_LINE mode */
1014 GLboolean OffsetFill
; /**< Offset in GL_FILL mode */
1019 * Scissor attributes (GL_SCISSOR_BIT).
1021 struct gl_scissor_attrib
1023 GLboolean Enabled
; /**< Scissor test enabled? */
1024 GLint X
, Y
; /**< Lower left corner of box */
1025 GLsizei Width
, Height
; /**< Size of box */
1030 * Stencil attribute group (GL_STENCIL_BUFFER_BIT).
1032 struct gl_stencil_attrib
1034 GLboolean Enabled
; /**< Enabled flag */
1035 GLboolean TestTwoSide
; /**< GL_EXT_stencil_two_side */
1036 GLubyte ActiveFace
; /**< GL_EXT_stencil_two_side (0 or 1) */
1037 GLenum Function
[2]; /**< Stencil function */
1038 GLenum FailFunc
[2]; /**< Fail function */
1039 GLenum ZPassFunc
[2]; /**< Depth buffer pass function */
1040 GLenum ZFailFunc
[2]; /**< Depth buffer fail function */
1041 GLstencil Ref
[2]; /**< Reference value */
1042 GLstencil ValueMask
[2]; /**< Value mask */
1043 GLstencil WriteMask
[2]; /**< Write mask */
1044 GLstencil Clear
; /**< Clear value */
1048 #define NUM_TEXTURE_TARGETS 5 /* 1D, 2D, 3D, CUBE and RECT */
1051 * An index for each type of texture object
1054 #define TEXTURE_1D_INDEX 0
1055 #define TEXTURE_2D_INDEX 1
1056 #define TEXTURE_3D_INDEX 2
1057 #define TEXTURE_CUBE_INDEX 3
1058 #define TEXTURE_RECT_INDEX 4
1062 * Bit flags for each type of texture object
1063 * Used for Texture.Unit[]._ReallyEnabled flags.
1066 #define TEXTURE_1D_BIT (1 << TEXTURE_1D_INDEX)
1067 #define TEXTURE_2D_BIT (1 << TEXTURE_2D_INDEX)
1068 #define TEXTURE_3D_BIT (1 << TEXTURE_3D_INDEX)
1069 #define TEXTURE_CUBE_BIT (1 << TEXTURE_CUBE_INDEX)
1070 #define TEXTURE_RECT_BIT (1 << TEXTURE_RECT_INDEX)
1075 * TexGenEnabled flags.
1086 * Bit flag versions of the corresponding GL_ constants.
1089 #define TEXGEN_SPHERE_MAP 0x1
1090 #define TEXGEN_OBJ_LINEAR 0x2
1091 #define TEXGEN_EYE_LINEAR 0x4
1092 #define TEXGEN_REFLECTION_MAP_NV 0x8
1093 #define TEXGEN_NORMAL_MAP_NV 0x10
1095 #define TEXGEN_NEED_NORMALS (TEXGEN_SPHERE_MAP | \
1096 TEXGEN_REFLECTION_MAP_NV | \
1097 TEXGEN_NORMAL_MAP_NV)
1098 #define TEXGEN_NEED_EYE_COORD (TEXGEN_SPHERE_MAP | \
1099 TEXGEN_REFLECTION_MAP_NV | \
1100 TEXGEN_NORMAL_MAP_NV | \
1105 /* A selection of state flags to make driver and module's lives easier. */
1106 #define ENABLE_TEXGEN0 0x1
1107 #define ENABLE_TEXGEN1 0x2
1108 #define ENABLE_TEXGEN2 0x4
1109 #define ENABLE_TEXGEN3 0x8
1110 #define ENABLE_TEXGEN4 0x10
1111 #define ENABLE_TEXGEN5 0x20
1112 #define ENABLE_TEXGEN6 0x40
1113 #define ENABLE_TEXGEN7 0x80
1115 #define ENABLE_TEXMAT0 0x1 /* Ie. not the identity matrix */
1116 #define ENABLE_TEXMAT1 0x2
1117 #define ENABLE_TEXMAT2 0x4
1118 #define ENABLE_TEXMAT3 0x8
1119 #define ENABLE_TEXMAT4 0x10
1120 #define ENABLE_TEXMAT5 0x20
1121 #define ENABLE_TEXMAT6 0x40
1122 #define ENABLE_TEXMAT7 0x80
1124 #define ENABLE_TEXGEN(i) (ENABLE_TEXGEN0 << (i))
1125 #define ENABLE_TEXMAT(i) (ENABLE_TEXMAT0 << (i))
1129 * Texel fetch function prototype. We use texel fetch functions to
1130 * extract RGBA, color indexes and depth components out of 1D, 2D and 3D
1131 * texture images. These functions help to isolate us from the gritty
1132 * details of all the various texture image encodings.
1134 * \param texImage texture image.
1135 * \param col texel column.
1136 * \param row texel row.
1137 * \param img texel image level/layer.
1138 * \param texelOut output texel (up to 4 GLchans)
1140 typedef void (*FetchTexelFuncC
)( const struct gl_texture_image
*texImage
,
1141 GLint col
, GLint row
, GLint img
,
1145 * As above, but returns floats.
1146 * Used for depth component images and for upcoming signed/float
1149 typedef void (*FetchTexelFuncF
)( const struct gl_texture_image
*texImage
,
1150 GLint col
, GLint row
, GLint img
,
1151 GLfloat
*texelOut
);
1154 typedef void (*StoreTexelFunc
)(struct gl_texture_image
*texImage
,
1155 GLint col
, GLint row
, GLint img
,
1159 * TexImage store function. This is called by the glTex[Sub]Image
1160 * functions and is responsible for converting the user-specified texture
1161 * image into a specific (hardware) image format.
1163 typedef GLboolean (*StoreTexImageFunc
)(GLcontext
*ctx
, GLuint dims
,
1164 GLenum baseInternalFormat
,
1165 const struct gl_texture_format
*dstFormat
,
1167 GLint dstXoffset
, GLint dstYoffset
, GLint dstZoffset
,
1168 GLint dstRowStride
, GLint dstImageStride
,
1169 GLint srcWidth
, GLint srcHeight
, GLint srcDepth
,
1170 GLenum srcFormat
, GLenum srcType
,
1171 const GLvoid
*srcAddr
,
1172 const struct gl_pixelstore_attrib
*srcPacking
);
1177 * Texture format record
1179 struct gl_texture_format
1181 GLint MesaFormat
; /**< One of the MESA_FORMAT_* values */
1183 GLenum BaseFormat
; /**< Either GL_RGB, GL_RGBA, GL_ALPHA,
1184 * GL_LUMINANCE, GL_LUMINANCE_ALPHA,
1185 * GL_INTENSITY, GL_COLOR_INDEX or
1186 * GL_DEPTH_COMPONENT.
1188 GLenum DataType
; /**< GL_FLOAT or GL_UNSIGNED_NORMALIZED_ARB */
1189 GLubyte RedBits
; /**< Bits per texel component */
1190 GLubyte GreenBits
; /**< These are just rough approximations for */
1191 GLubyte BlueBits
; /**< compressed texture formats. */
1193 GLubyte LuminanceBits
;
1194 GLubyte IntensityBits
;
1198 GLuint TexelBytes
; /**< Bytes per texel, 0 if compressed format */
1200 StoreTexImageFunc StoreImage
;
1203 * \name Texel fetch function pointers
1206 FetchTexelFuncC FetchTexel1D
;
1207 FetchTexelFuncC FetchTexel2D
;
1208 FetchTexelFuncC FetchTexel3D
;
1209 FetchTexelFuncF FetchTexel1Df
;
1210 FetchTexelFuncF FetchTexel2Df
;
1211 FetchTexelFuncF FetchTexel3Df
;
1214 StoreTexelFunc StoreTexel
;
1219 * Texture image state. Describes the dimensions of a texture image,
1220 * the texel format and pointers to Texel Fetch functions.
1222 struct gl_texture_image
1224 GLenum Format
; /**< Either GL_RGB, GL_RGBA, GL_ALPHA,
1225 * GL_LUMINANCE, GL_LUMINANCE_ALPHA,
1226 * GL_INTENSITY, GL_COLOR_INDEX or
1227 * GL_DEPTH_COMPONENT only.
1228 * Used for choosing TexEnv arithmetic.
1230 GLint IntFormat
; /**< Internal format as given by the user */
1231 GLuint Border
; /**< 0 or 1 */
1232 GLuint Width
; /**< = 2^WidthLog2 + 2*Border */
1233 GLuint Height
; /**< = 2^HeightLog2 + 2*Border */
1234 GLuint Depth
; /**< = 2^DepthLog2 + 2*Border */
1235 GLuint RowStride
; /**< == Width unless IsClientData and padded */
1236 GLuint Width2
; /**< = Width - 2*Border */
1237 GLuint Height2
; /**< = Height - 2*Border */
1238 GLuint Depth2
; /**< = Depth - 2*Border */
1239 GLuint WidthLog2
; /**< = log2(Width2) */
1240 GLuint HeightLog2
; /**< = log2(Height2) */
1241 GLuint DepthLog2
; /**< = log2(Depth2) */
1242 GLuint MaxLog2
; /**< = MAX(WidthLog2, HeightLog2) */
1243 GLfloat WidthScale
; /**< used for mipmap LOD computation */
1244 GLfloat HeightScale
; /**< used for mipmap LOD computation */
1245 GLfloat DepthScale
; /**< used for mipmap LOD computation */
1246 GLvoid
*Data
; /**< Image data, accessed via FetchTexel() */
1247 GLboolean IsClientData
; /**< Data owned by client? */
1248 GLboolean _IsPowerOfTwo
; /**< Are all dimensions powers of two? */
1250 const struct gl_texture_format
*TexFormat
;
1252 struct gl_texture_object
*TexObject
; /**< Pointer back to parent object */
1254 FetchTexelFuncC FetchTexelc
; /**< GLchan texel fetch function pointer */
1255 FetchTexelFuncF FetchTexelf
; /**< Float texel fetch function pointer */
1257 GLboolean IsCompressed
; /**< GL_ARB_texture_compression */
1258 GLuint CompressedSize
; /**< GL_ARB_texture_compression */
1261 * \name For device driver:
1264 void *DriverData
; /**< Arbitrary device driver data */
1270 * Indexes for cube map faces.
1273 #define FACE_POS_X 0
1274 #define FACE_NEG_X 1
1275 #define FACE_POS_Y 2
1276 #define FACE_NEG_Y 3
1277 #define FACE_POS_Z 4
1278 #define FACE_NEG_Z 5
1284 * Texture object state. Contains the array of mipmap images, border color,
1285 * wrap modes, filter modes, shadow/texcompare state, and the per-texture
1288 struct gl_texture_object
1290 _glthread_Mutex Mutex
; /**< for thread safety */
1291 GLint RefCount
; /**< reference count */
1292 GLuint Name
; /**< the user-visible texture object ID */
1293 GLenum Target
; /**< GL_TEXTURE_1D, GL_TEXTURE_2D, etc. */
1294 GLfloat Priority
; /**< in [0,1] */
1295 GLfloat BorderColor
[4]; /**< unclamped */
1296 GLchan _BorderChan
[4]; /**< clamped, as GLchan */
1297 GLenum WrapS
; /**< S-axis texture image wrap mode */
1298 GLenum WrapT
; /**< T-axis texture image wrap mode */
1299 GLenum WrapR
; /**< R-axis texture image wrap mode */
1300 GLenum MinFilter
; /**< minification filter */
1301 GLenum MagFilter
; /**< magnification filter */
1302 GLfloat MinLod
; /**< min lambda, OpenGL 1.2 */
1303 GLfloat MaxLod
; /**< max lambda, OpenGL 1.2 */
1304 GLfloat LodBias
; /**< OpenGL 1.4 */
1305 GLint BaseLevel
; /**< min mipmap level, OpenGL 1.2 */
1306 GLint MaxLevel
; /**< max mipmap level, OpenGL 1.2 */
1307 GLfloat MaxAnisotropy
; /**< GL_EXT_texture_filter_anisotropic */
1308 GLboolean CompareFlag
; /**< GL_SGIX_shadow */
1309 GLenum CompareOperator
; /**< GL_SGIX_shadow */
1310 GLfloat ShadowAmbient
; /**< GL_ARB_shadow_ambient */
1311 GLenum CompareMode
; /**< GL_ARB_shadow */
1312 GLenum CompareFunc
; /**< GL_ARB_shadow */
1313 GLenum DepthMode
; /**< GL_ARB_depth_texture */
1314 GLint _MaxLevel
; /**< actual max mipmap level (q in the spec) */
1315 GLfloat _MaxLambda
; /**< = _MaxLevel - BaseLevel (q - b in spec) */
1316 GLboolean GenerateMipmap
; /**< GL_SGIS_generate_mipmap */
1317 GLboolean _IsPowerOfTwo
; /**< Are all image dimensions powers of two? */
1318 GLboolean Complete
; /**< Is texture object complete? */
1320 /** Actual texture images, indexed by [cube face] and [mipmap level] */
1321 struct gl_texture_image
*Image
[MAX_FACES
][MAX_TEXTURE_LEVELS
];
1323 /** GL_EXT_paletted_texture */
1324 struct gl_color_table Palette
;
1328 * \name For device driver.
1329 * Note: instead of attaching driver data to this pointer, it's preferable
1330 * to instead use this struct as a base class for your own texture object
1331 * class. Driver->NewTextureObject() can be used to implement the
1334 void *DriverData
; /**< Arbitrary device driver data */
1339 * Texture combine environment state.
1342 * If GL_NV_texture_env_combine4 is ever supported, the arrays in this
1343 * structure will need to be expanded for 4 elements.
1345 struct gl_tex_env_combine_state
1347 GLenum ModeRGB
; /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */
1348 GLenum ModeA
; /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */
1349 GLenum SourceRGB
[3]; /**< GL_PRIMARY_COLOR, GL_TEXTURE, etc. */
1350 GLenum SourceA
[3]; /**< GL_PRIMARY_COLOR, GL_TEXTURE, etc. */
1351 GLenum OperandRGB
[3]; /**< SRC_COLOR, ONE_MINUS_SRC_COLOR, etc */
1352 GLenum OperandA
[3]; /**< SRC_ALPHA, ONE_MINUS_SRC_ALPHA, etc */
1353 GLuint ScaleShiftRGB
; /**< 0, 1 or 2 */
1354 GLuint ScaleShiftA
; /**< 0, 1 or 2 */
1355 GLuint _NumArgsRGB
; /**< Number of inputs used for the combine mode. */
1356 GLuint _NumArgsA
; /**< Number of inputs used for the combine mode. */
1361 * Texture unit state. Contains enable flags, texture environment/function/
1362 * combiners, texgen state, pointers to current texture objects and
1363 * post-filter color tables.
1365 struct gl_texture_unit
1367 GLuint Enabled
; /**< bitmask of TEXTURE_*_BIT flags */
1368 GLuint _ReallyEnabled
; /**< 0 or exactly one of TEXTURE_*_BIT flags */
1370 GLenum EnvMode
; /**< GL_MODULATE, GL_DECAL, GL_BLEND, etc. */
1371 GLfloat EnvColor
[4];
1372 GLuint TexGenEnabled
; /**< Bitwise-OR of [STRQ]_BIT values */
1373 /** \name Tex coord generation mode
1374 * Either GL_OBJECT_LINEAR, GL_EYE_LINEAR or GL_SPHERE_MAP. */
1385 GLuint _GenFlags
; /**< bitwise or of GenBit[STRQ] */
1386 GLfloat ObjectPlaneS
[4];
1387 GLfloat ObjectPlaneT
[4];
1388 GLfloat ObjectPlaneR
[4];
1389 GLfloat ObjectPlaneQ
[4];
1390 GLfloat EyePlaneS
[4];
1391 GLfloat EyePlaneT
[4];
1392 GLfloat EyePlaneR
[4];
1393 GLfloat EyePlaneQ
[4];
1394 GLfloat LodBias
; /**< for biasing mipmap levels */
1397 * \name GL_EXT_texture_env_combine
1399 struct gl_tex_env_combine_state Combine
;
1402 * Derived state based on \c EnvMode and the \c BaseFormat of the
1403 * currently enabled texture.
1405 struct gl_tex_env_combine_state _EnvMode
;
1408 * Currently enabled combiner state. This will point to either
1409 * \c Combine or \c _EnvMode.
1411 struct gl_tex_env_combine_state
*_CurrentCombine
;
1413 struct gl_texture_object
*Current1D
;
1414 struct gl_texture_object
*Current2D
;
1415 struct gl_texture_object
*Current3D
;
1416 struct gl_texture_object
*CurrentCubeMap
; /**< GL_ARB_texture_cube_map */
1417 struct gl_texture_object
*CurrentRect
; /**< GL_NV_texture_rectangle */
1419 struct gl_texture_object
*_Current
; /**< Points to really enabled tex obj */
1421 struct gl_texture_object Saved1D
; /**< only used by glPush/PopAttrib */
1422 struct gl_texture_object Saved2D
;
1423 struct gl_texture_object Saved3D
;
1424 struct gl_texture_object SavedCubeMap
;
1425 struct gl_texture_object SavedRect
;
1427 /* GL_SGI_texture_color_table */
1428 struct gl_color_table ColorTable
;
1429 struct gl_color_table ProxyColorTable
;
1430 GLboolean ColorTableEnabled
;
1435 * Texture attribute group (GL_TEXTURE_BIT).
1437 struct gl_texture_attrib
1443 GLuint CurrentUnit
; /**< Active texture unit */
1444 GLuint _EnabledUnits
; /**< one bit set for each really-enabled unit */
1445 GLuint _EnabledCoordUnits
; /**< one bit per enabled coordinate unit */
1446 GLuint _GenFlags
; /**< for texgen */
1447 GLuint _TexGenEnabled
;
1448 GLuint _TexMatEnabled
;
1451 struct gl_texture_unit Unit
[MAX_TEXTURE_UNITS
];
1453 struct gl_texture_object
*Proxy1D
;
1454 struct gl_texture_object
*Proxy2D
;
1455 struct gl_texture_object
*Proxy3D
;
1456 struct gl_texture_object
*ProxyCubeMap
;
1457 struct gl_texture_object
*ProxyRect
;
1459 /** GL_EXT_shared_texture_palette */
1460 GLboolean SharedPalette
;
1461 struct gl_color_table Palette
;
1466 * Transformation attribute group (GL_TRANSFORM_BIT).
1468 struct gl_transform_attrib
1470 GLenum MatrixMode
; /**< Matrix mode */
1471 GLfloat EyeUserPlane
[MAX_CLIP_PLANES
][4]; /**< User clip planes */
1472 GLfloat _ClipUserPlane
[MAX_CLIP_PLANES
][4]; /**< derived */
1473 GLuint ClipPlanesEnabled
; /**< on/off bitmask */
1474 GLboolean Normalize
; /**< Normalize all normals? */
1475 GLboolean RescaleNormals
; /**< GL_EXT_rescale_normal */
1476 GLboolean RasterPositionUnclipped
; /**< GL_IBM_rasterpos_clip */
1478 GLboolean CullVertexFlag
; /**< True if GL_CULL_VERTEX_EXT is enabled */
1479 GLfloat CullEyePos
[4];
1480 GLfloat CullObjPos
[4];
1485 * Viewport attribute group (GL_VIEWPORT_BIT).
1487 struct gl_viewport_attrib
1489 GLint X
, Y
; /**< position */
1490 GLsizei Width
, Height
; /**< size */
1491 GLfloat Near
, Far
; /**< Depth buffer range */
1492 GLmatrix _WindowMap
; /**< Mapping transformation as a matrix. */
1497 * Node for the attribute stack.
1499 struct gl_attrib_node
1503 struct gl_attrib_node
*next
;
1508 * GL_ARB_vertex/pixel_buffer_object buffer object
1510 struct gl_buffer_object
1516 GLvoid
*Pointer
; /**< Only valid while buffer is mapped */
1517 GLsizeiptrARB Size
; /**< Size of storage in bytes */
1518 GLubyte
*Data
; /**< Location of storage either in RAM or VRAM. */
1519 GLboolean OnCard
; /**< Is buffer in VRAM? (hardware drivers) */
1525 * Client pixel packing/unpacking attributes
1527 struct gl_pixelstore_attrib
1533 GLint ImageHeight
; /**< for GL_EXT_texture3D */
1534 GLint SkipImages
; /**< for GL_EXT_texture3D */
1535 GLboolean SwapBytes
;
1537 GLboolean ClientStorage
; /**< GL_APPLE_client_storage */
1538 GLboolean Invert
; /**< GL_MESA_pack_invert */
1539 struct gl_buffer_object
*BufferObj
; /**< GL_ARB_pixel_buffer_object */
1543 #define CA_CLIENT_DATA 0x1 /**< Data not allocated by mesa */
1547 * Client vertex array attributes
1549 struct gl_client_array
1551 GLint Size
; /**< components per element (1,2,3,4) */
1552 GLenum Type
; /**< datatype: GL_FLOAT, GL_INT, etc */
1553 GLsizei Stride
; /**< user-specified stride */
1554 GLsizei StrideB
; /**< actual stride in bytes */
1555 const GLubyte
*Ptr
; /**< Points to array data */
1556 GLuint Enabled
; /**< one of the _NEW_ARRAY_ bits */
1557 GLboolean Normalized
; /**< GL_ARB_vertex_program */
1559 /**< GL_ARB_vertex_buffer_object */
1560 struct gl_buffer_object
*BufferObj
;
1568 * Vertex array state
1570 struct gl_array_attrib
1572 struct gl_client_array Vertex
; /**< client data descriptors */
1573 struct gl_client_array Normal
;
1574 struct gl_client_array Color
;
1575 struct gl_client_array SecondaryColor
;
1576 struct gl_client_array FogCoord
;
1577 struct gl_client_array Index
;
1578 struct gl_client_array TexCoord
[MAX_TEXTURE_COORD_UNITS
];
1579 struct gl_client_array EdgeFlag
;
1581 struct gl_client_array VertexAttrib
[VERT_ATTRIB_MAX
]; /**< GL_NV_vertex_program */
1583 GLint ActiveTexture
; /**< Client Active Texture */
1584 GLuint LockFirst
; /**< GL_EXT_compiled_vertex_array */
1585 GLuint LockCount
; /**< GL_EXT_compiled_vertex_array */
1587 GLuint _Enabled
; /**< _NEW_ARRAY_* - bit set if array enabled */
1588 GLuint NewState
; /**< _NEW_ARRAY_* */
1590 #if FEATURE_ARB_vertex_buffer_object
1591 struct gl_buffer_object
*NullBufferObj
;
1592 struct gl_buffer_object
*ArrayBufferObj
;
1593 struct gl_buffer_object
*ElementArrayBufferObj
;
1595 GLuint _MaxElement
; /* Min of all enabled array's maxes */
1600 * Feedback buffer state
1605 GLuint _Mask
; /* FB_* bits */
1613 * Selection buffer state
1617 GLuint
*Buffer
; /**< selection buffer */
1618 GLuint BufferSize
; /**< size of the selection buffer */
1619 GLuint BufferCount
; /**< number of values in the selection buffer */
1620 GLuint Hits
; /**< number of records in the selection buffer */
1621 GLuint NameStackDepth
; /**< name stack depth */
1622 GLuint NameStack
[MAX_NAME_STACK_DEPTH
]; /**< name stack */
1623 GLboolean HitFlag
; /**< hit flag */
1624 GLfloat HitMinZ
; /**< minimum hit depth */
1625 GLfloat HitMaxZ
; /**< maximum hit depth */
1630 * 1-D Evaluator control points
1634 GLuint Order
; /**< Number of control points */
1635 GLfloat u1
, u2
, du
; /**< u1, u2, 1.0/(u2-u1) */
1636 GLfloat
*Points
; /**< Points to contiguous control points */
1641 * 2-D Evaluator control points
1645 GLuint Uorder
; /**< Number of control points in U dimension */
1646 GLuint Vorder
; /**< Number of control points in V dimension */
1649 GLfloat
*Points
; /**< Points to contiguous control points */
1654 * All evaluator control point state
1656 struct gl_evaluators
1662 struct gl_1d_map Map1Vertex3
;
1663 struct gl_1d_map Map1Vertex4
;
1664 struct gl_1d_map Map1Index
;
1665 struct gl_1d_map Map1Color4
;
1666 struct gl_1d_map Map1Normal
;
1667 struct gl_1d_map Map1Texture1
;
1668 struct gl_1d_map Map1Texture2
;
1669 struct gl_1d_map Map1Texture3
;
1670 struct gl_1d_map Map1Texture4
;
1671 struct gl_1d_map Map1Attrib
[16]; /**< GL_NV_vertex_program */
1678 struct gl_2d_map Map2Vertex3
;
1679 struct gl_2d_map Map2Vertex4
;
1680 struct gl_2d_map Map2Index
;
1681 struct gl_2d_map Map2Color4
;
1682 struct gl_2d_map Map2Normal
;
1683 struct gl_2d_map Map2Texture1
;
1684 struct gl_2d_map Map2Texture2
;
1685 struct gl_2d_map Map2Texture3
;
1686 struct gl_2d_map Map2Texture4
;
1687 struct gl_2d_map Map2Attrib
[16]; /**< GL_NV_vertex_program */
1693 * NV_fragment_program runtime state
1697 GLfloat Temporaries
[MAX_NV_FRAGMENT_PROGRAM_TEMPS
][4];
1698 GLfloat Inputs
[MAX_NV_FRAGMENT_PROGRAM_INPUTS
][4];
1699 GLfloat Outputs
[MAX_NV_FRAGMENT_PROGRAM_OUTPUTS
][4];
1700 GLuint CondCodes
[4];
1704 * ATI_fragment_shader runtime state
1706 #define ATI_FS_INPUT_PRIMARY 0
1707 #define ATI_FS_INPUT_SECONDARY 1
1709 /* 6 register sets - 2 inputs (primary, secondary) */
1710 struct atifs_machine
1712 GLfloat Registers
[6][4];
1713 GLfloat PrevPassRegisters
[6][4];
1714 GLfloat Inputs
[2][4];
1720 * Names of the various vertex/fragment register files
1727 PROGRAM_LOCAL_PARAM
,
1729 PROGRAM_NAMED_PARAM
,
1736 /** Vertex and fragment instructions */
1737 struct vp_instruction
;
1738 struct fp_instruction
;
1739 struct atifs_instruction
;
1740 struct program_parameter_list
;
1744 * Base class for any kind of program object
1749 GLubyte
*String
; /**< Null-terminated program text */
1752 GLenum Format
; /**< String encoding format */
1754 GLfloat LocalParams
[MAX_PROGRAM_LOCAL_PARAMS
][4];
1755 GLuint NumInstructions
; /* GL_ARB_vertex/fragment_program */
1756 GLuint NumTemporaries
;
1757 GLuint NumParameters
;
1758 GLuint NumAttributes
;
1759 GLuint NumAddressRegs
;
1763 /** Vertex program object */
1764 struct vertex_program
1766 struct program Base
; /* base class */
1767 struct vp_instruction
*Instructions
; /* Compiled instructions */
1768 GLboolean IsNVProgram
; /* GL_NV_vertex_program ? */
1769 GLboolean IsPositionInvariant
; /* GL_NV_vertex_program1_1 */
1770 GLuint InputsRead
; /* Bitmask of which input regs are read */
1771 GLuint OutputsWritten
; /* Bitmask of which output regs are written to */
1772 struct program_parameter_list
*Parameters
; /**< array [NumParameters] */
1773 void *TnlData
; /* should probably use Base.DriverData */
1777 /** Fragment program object */
1778 struct fragment_program
1780 struct program Base
; /**< base class */
1781 struct fp_instruction
*Instructions
; /**< Compiled instructions */
1782 GLuint InputsRead
; /**< Bitmask of which input regs are read */
1783 GLuint OutputsWritten
; /**< Bitmask of which output regs are written to */
1784 GLuint TexturesUsed
[MAX_TEXTURE_IMAGE_UNITS
]; /**< TEXTURE_x_INDEX bitmask */
1785 GLuint NumAluInstructions
; /**< GL_ARB_fragment_program */
1786 GLuint NumTexInstructions
;
1787 GLuint NumTexIndirections
;
1789 struct program_parameter_list
*Parameters
; /**< array [NumParameters] */
1792 char c_str
[4096]; /* experimental... */
1797 struct ati_fragment_shader
1799 struct program Base
;
1800 struct atifs_instruction
*Instructions
;
1801 GLfloat Constants
[8][4];
1807 * State common to vertex and fragment programs.
1809 struct gl_program_state
1811 GLint ErrorPos
; /* GL_PROGRAM_ERROR_POSITION_NV */
1812 const char *ErrorString
; /* GL_PROGRAM_ERROR_STRING_NV */
1817 * State vars for GL_ARB/GL_NV_vertex_program
1819 struct gl_vertex_program_state
1821 GLboolean Enabled
; /**< GL_VERTEX_PROGRAM_NV */
1822 GLboolean _Enabled
; /**< Really enabled? */
1823 GLboolean PointSizeEnabled
; /**< GL_VERTEX_PROGRAM_POINT_SIZE_NV */
1824 GLboolean TwoSideEnabled
; /**< GL_VERTEX_PROGRAM_TWO_SIDE_NV */
1825 struct vertex_program
*Current
; /**< ptr to currently bound program */
1827 GLenum TrackMatrix
[MAX_NV_VERTEX_PROGRAM_PARAMS
/ 4];
1828 GLenum TrackMatrixTransform
[MAX_NV_VERTEX_PROGRAM_PARAMS
/ 4];
1830 GLfloat Parameters
[MAX_NV_VERTEX_PROGRAM_PARAMS
][4]; /* Env params */
1831 /* Only used during program execution (may be moved someday): */
1832 GLfloat Temporaries
[MAX_NV_VERTEX_PROGRAM_TEMPS
][4];
1833 GLfloat Inputs
[MAX_NV_VERTEX_PROGRAM_INPUTS
][4];
1834 GLuint InputsSize
[MAX_NV_VERTEX_PROGRAM_INPUTS
];
1835 GLfloat Outputs
[MAX_NV_VERTEX_PROGRAM_OUTPUTS
][4];
1836 GLint AddressReg
[4];
1838 #if FEATURE_MESA_program_debug
1839 GLprogramcallbackMESA Callback
;
1840 GLvoid
*CallbackData
;
1841 GLboolean CallbackEnabled
;
1842 GLuint CurrentPosition
;
1848 * State for GL_ARB/NV_fragment_program
1850 struct gl_fragment_program_state
1852 GLboolean Enabled
; /* GL_VERTEX_PROGRAM_NV */
1853 GLboolean _Enabled
; /* Really enabled? */
1854 GLboolean _Active
; /* Really really enabled? */
1855 struct fragment_program
*Current
; /* ptr to currently bound program */
1856 struct fragment_program
*_Current
; /* ptr to currently active program */
1857 struct fp_machine Machine
; /* machine state */
1858 GLfloat Parameters
[MAX_NV_FRAGMENT_PROGRAM_PARAMS
][4]; /* Env params */
1860 #if FEATURE_MESA_program_debug
1861 GLprogramcallbackMESA Callback
;
1862 GLvoid
*CallbackData
;
1863 GLboolean CallbackEnabled
;
1864 GLuint CurrentPosition
;
1869 * State for GL_fragment_shader
1871 struct gl_ati_fragment_shader_state
1875 GLboolean Compiling
;
1876 struct atifs_machine Machine
; /* machine state */
1877 struct ati_fragment_shader
*Current
;
1881 * State for GL_ARB_occlusion_query
1883 struct gl_occlusion_state
1886 GLuint CurrentQueryObject
;
1887 GLuint PassedCounter
;
1888 struct _mesa_HashTable
*QueryObjects
;
1892 * gl2 unique interface identifier.
1893 * Each gl2 interface has its own interface id used for object queries.
1897 UIID_UNKNOWN
, /* supported by all objects */
1898 UIID_GENERIC
, /* generic object */
1899 UIID_CONTAINER
, /* contains generic objects */
1900 UIID_SHADER
, /* shader object */
1901 UIID_FRAGMENT_SHADER
, /* fragment shader */
1902 UIID_VERTEX_SHADER
, /* vertex shader */
1903 UIID_PROGRAM
, /* program object */
1904 UIID_3DLABS_SHHANDLE
/* encapsulates 3dlabs' ShHandle */
1907 struct gl2_unknown_intf
1909 GLvoid (* AddRef
) (struct gl2_unknown_intf
**);
1910 GLvoid (* Release
) (struct gl2_unknown_intf
**);
1911 struct gl2_unknown_intf
**(* QueryInterface
) (struct gl2_unknown_intf
**, enum gl2_uiid uiid
);
1914 struct gl2_generic_intf
1916 struct gl2_unknown_intf _unknown
;
1917 GLvoid (* Delete
) (struct gl2_generic_intf
**);
1918 GLenum (* GetType
) (struct gl2_generic_intf
**);
1919 GLhandleARB (* GetName
) (struct gl2_generic_intf
**);
1920 GLboolean (* GetDeleteStatus
) (struct gl2_generic_intf
**);
1921 const GLcharARB
*(* GetInfoLog
) (struct gl2_generic_intf
**);
1924 struct gl2_container_intf
1926 struct gl2_generic_intf _generic
;
1927 GLboolean (* Attach
) (struct gl2_container_intf
**, struct gl2_generic_intf
**);
1928 GLboolean (* Detach
) (struct gl2_container_intf
**, struct gl2_generic_intf
**);
1929 GLsizei (* GetAttachedCount
) (struct gl2_container_intf
**);
1930 struct gl2_generic_intf
**(* GetAttached
) (struct gl2_container_intf
**, GLuint
);
1933 struct gl2_shader_intf
1935 struct gl2_generic_intf _generic
;
1936 GLenum (* GetSubType
) (struct gl2_shader_intf
**);
1937 GLboolean (* GetCompileStatus
) (struct gl2_shader_intf
**);
1938 GLvoid (* SetSource
) (struct gl2_shader_intf
**, GLcharARB
*, GLint
*, GLsizei
);
1939 const GLcharARB
*(* GetSource
) (struct gl2_shader_intf
**);
1940 GLvoid (* Compile
) (struct gl2_shader_intf
**);
1943 struct gl2_program_intf
1945 struct gl2_container_intf _container
;
1946 GLboolean (* GetLinkStatus
) (struct gl2_program_intf
**);
1947 GLboolean (* GetValidateStatus
) (struct gl2_program_intf
**);
1948 GLvoid (* Link
) (struct gl2_program_intf
**);
1949 GLvoid (* Validate
) (struct gl2_program_intf
**);
1952 struct gl2_fragment_shader_intf
1954 struct gl2_shader_intf _shader
;
1957 struct gl2_vertex_shader_intf
1959 struct gl2_shader_intf _shader
;
1962 struct gl2_3dlabs_shhandle_intf
1964 struct gl2_unknown_intf _unknown
;
1965 GLvoid
*(* GetShHandle
) (struct gl2_3dlabs_shhandle_intf
**);
1968 struct gl_shader_objects_state
1970 struct gl2_program_intf
**current_program
;
1975 * State which can be shared by multiple contexts:
1977 struct gl_shared_state
1979 _glthread_Mutex Mutex
; /**< for thread safety */
1980 GLint RefCount
; /**< Reference count */
1981 struct _mesa_HashTable
*DisplayList
; /**< Display lists hash table */
1982 struct _mesa_HashTable
*TexObjects
; /**< Texture objects hash table */
1985 * \name Default texture objects (shared by all multi-texture units)
1988 struct gl_texture_object
*Default1D
;
1989 struct gl_texture_object
*Default2D
;
1990 struct gl_texture_object
*Default3D
;
1991 struct gl_texture_object
*DefaultCubeMap
;
1992 struct gl_texture_object
*DefaultRect
;
1996 * \name Vertex/fragment programs
1999 struct _mesa_HashTable
*Programs
;
2000 #if FEATURE_ARB_vertex_program
2001 struct program
*DefaultVertexProgram
;
2003 #if FEATURE_ARB_fragment_program
2004 struct program
*DefaultFragmentProgram
;
2006 #if FEATURE_ATI_fragment_shader
2007 struct program
*DefaultFragmentShader
;
2011 #if FEATURE_ARB_vertex_buffer_object || FEATURE_ARB_pixel_buffer_object
2012 struct _mesa_HashTable
*BufferObjects
;
2015 struct _mesa_HashTable
*GL2Objects
;
2017 #if FEATURE_EXT_framebuffer_object
2018 struct _mesa_HashTable
*RenderBuffers
;
2019 struct _mesa_HashTable
*FrameBuffers
;
2022 void *DriverData
; /**< Device driver shared state */
2029 * A renderbuffer stores colors or depth values or stencil values.
2030 * A framebuffer object will have a collection of these.
2031 * Data are read/written to the buffer with a handful of Get/Put functions.
2033 * Instances of this object are allocated with the Driver's NewRenderbuffer
2034 * hook. Drivers will likely wrap this class inside a driver-specific
2035 * class to simulate inheritance.
2037 struct gl_renderbuffer
2041 GLuint Width
, Height
;
2042 GLenum InternalFormat
; /* The user-specified value */
2043 GLenum _BaseFormat
; /* Either GL_RGB, GL_RGBA, GL_DEPTH_COMPONENT or */
2044 /* GL_STENCIL_INDEX. */
2045 GLenum DataType
; /* Type of values passed to the Get/Put functions */
2046 GLubyte ComponentSizes
[4]; /* bits per component or channel */
2049 /* Delete this renderbuffer */
2050 void (*Delete
)(struct gl_renderbuffer
*rb
);
2052 /* Allocate new storage for this renderbuffer */
2053 GLboolean (*AllocStorage
)(GLcontext
*ctx
, struct gl_renderbuffer
*rb
,
2054 GLenum internalFormat
,
2055 GLuint width
, GLuint height
);
2057 /* Lock/Unlock are called before/after calling the Get/Put functions.
2058 * Not sure this is the right place for these yet.
2059 void (*Lock)(GLcontext *ctx, struct gl_renderbuffer *rb);
2060 void (*Unlock)(GLcontext *ctx, struct gl_renderbuffer *rb);
2063 /* Return a pointer to the element/pixel at (x,y).
2064 * Should return NULL if the buffer memory can't be directly addressed.
2066 void *(*GetPointer
)(GLcontext
*ctx
, struct gl_renderbuffer
*rb
,
2069 /* Get/Read a row of values.
2070 * The values will be of format _BaseFormat and type DataType.
2072 void (*GetRow
)(GLcontext
*ctx
, struct gl_renderbuffer
*rb
, GLuint count
,
2073 GLint x
, GLint y
, void *values
);
2075 /* Get/Read values at arbitrary locations.
2076 * The values will be of format _BaseFormat and type DataType.
2078 void (*GetValues
)(GLcontext
*ctx
, struct gl_renderbuffer
*rb
, GLuint count
,
2079 const GLint x
[], const GLint y
[], void *values
);
2081 /* Put/Write a row of values.
2082 * The values will be of format _BaseFormat and type DataType.
2084 void (*PutRow
)(GLcontext
*ctx
, struct gl_renderbuffer
*rb
, GLuint count
,
2085 GLint x
, GLint y
, const void *values
, const GLubyte
*mask
);
2087 /* Put/Write a row of RGB values. This is a special-case routine that's
2088 * only used for RGBA renderbuffers when the source data is GL_RGB. That's
2089 * a common case for glDrawPixels and some triangle routines.
2090 * The values will be of format GL_RGB and type DataType.
2092 void (*PutRowRGB
)(GLcontext
*ctx
, struct gl_renderbuffer
*rb
, GLuint count
,
2093 GLint x
, GLint y
, const void *values
, const GLubyte
*mask
);
2096 /* Put/Write a row of identical values.
2097 * The values will be of format _BaseFormat and type DataType.
2099 void (*PutMonoRow
)(GLcontext
*ctx
, struct gl_renderbuffer
*rb
, GLuint count
,
2100 GLint x
, GLint y
, const void *value
, const GLubyte
*mask
);
2102 /* Put/Write values at arbitrary locations.
2103 * The values will be of format _BaseFormat and type DataType.
2105 void (*PutValues
)(GLcontext
*ctx
, struct gl_renderbuffer
*rb
, GLuint count
,
2106 const GLint x
[], const GLint y
[], const void *values
,
2107 const GLubyte
*mask
);
2108 /* Put/Write identical values at arbitrary locations.
2109 * The values will be of format _BaseFormat and type DataType.
2111 void (*PutMonoValues
)(GLcontext
*ctx
, struct gl_renderbuffer
*rb
,
2112 GLuint count
, const GLint x
[], const GLint y
[],
2113 const void *value
, const GLubyte
*mask
);
2118 * A renderbuffer attachment point points to either a texture object
2119 * (and specifies a mipmap level, cube face or 3D texture slice) or
2120 * points to a renderbuffer.
2122 struct gl_renderbuffer_attachment
2124 GLenum Type
; /* GL_NONE or GL_TEXTURE or GL_RENDERBUFFER_EXT */
2127 /* IF Type == GL_RENDERBUFFER_EXT: */
2128 struct gl_renderbuffer
*Renderbuffer
;
2130 /* IF Type == GL_TEXTURE: */
2131 struct gl_texture_object
*Texture
;
2132 GLuint TextureLevel
;
2133 GLuint CubeMapFace
; /* 0 .. 5, for cube map textures */
2134 GLuint Zoffset
; /* for 3D textures */
2139 * A framebuffer is a collection of renderbuffers (color, depth, stencil, etc).
2140 * In C++ terms, think of this as a base class from which device drivers
2141 * will make derived classes.
2143 struct gl_framebuffer
2145 GLuint Name
; /* if zero, this is a window system framebuffer */
2148 GLvisual Visual
; /**< The corresponding visual */
2150 GLboolean Initialized
;
2152 GLuint Width
, Height
; /**< size of frame buffer in pixels */
2154 /** \name Drawing bounds (Intersection of buffer size and scissor box) */
2156 GLint _Xmin
, _Xmax
; /**< inclusive */
2157 GLint _Ymin
, _Ymax
; /**< exclusive */
2160 /** \name Derived Z buffer stuff */
2162 GLuint _DepthMax
; /**< Max depth buffer value */
2163 GLfloat _DepthMaxF
; /**< Float max depth buffer value */
2164 GLfloat _MRD
; /**< minimum resolvable difference in Z values */
2167 GLenum _Status
; /* One of the GL_FRAMEBUFFER_(IN)COMPLETE_* tokens */
2169 /* Array of all renderbuffer attachments, indexed by BUFFER_* tokens. */
2170 struct gl_renderbuffer_attachment Attachment
[BUFFER_COUNT
];
2172 /* In unextended OpenGL these vars are part of the GL_COLOR_BUFFER
2173 * attribute group and GL_PIXEL attribute group, respectively.
2175 GLenum ColorDrawBuffer
[MAX_DRAW_BUFFERS
];
2176 GLenum ColorReadBuffer
;
2178 /* These are computed from ColorDrawBuffer and ColorReadBuffer */
2179 GLuint _ColorDrawBufferMask
[MAX_DRAW_BUFFERS
]; /* Mask of BUFFER_BIT_* flags */
2180 GLuint _ColorReadBufferMask
; /* Zero or one of BUFFER_BIT_ flags */
2182 /* These are computed from _Draw/ReadBufferMask, above. */
2183 GLuint _NumColorDrawBuffers
[MAX_DRAW_BUFFERS
];
2184 struct gl_renderbuffer
*_ColorDrawBuffers
[MAX_DRAW_BUFFERS
][4];
2185 struct gl_renderbuffer
*_ColorReadBuffer
;
2187 #if OLD_RENDERBUFFER || NEW_RENDERBUFFER
2188 /* XXX THIS IS TEMPORARY */
2189 GLuint _ColorDrawBit
[MAX_DRAW_BUFFERS
][4];
2192 /** Delete this framebuffer */
2193 void (*Delete
)(struct gl_framebuffer
*fb
);
2198 * Constants which may be overridden by device driver during context creation
2199 * but are never changed after that.
2203 GLint MaxTextureLevels
; /**< Maximum number of allowed mipmap levels. */
2204 GLint Max3DTextureLevels
; /**< Maximum number of allowed mipmap levels for 3D texture targets. */
2205 GLint MaxCubeTextureLevels
; /**< Maximum number of allowed mipmap levels for GL_ARB_texture_cube_map */
2206 GLint MaxTextureRectSize
; /* GL_NV_texture_rectangle */
2207 GLuint MaxTextureCoordUnits
;
2208 GLuint MaxTextureImageUnits
;
2209 GLuint MaxTextureUnits
; /* = MAX(CoordUnits, ImageUnits) */
2210 GLfloat MaxTextureMaxAnisotropy
; /* GL_EXT_texture_filter_anisotropic */
2211 GLfloat MaxTextureLodBias
; /* GL_EXT_texture_lod_bias */
2212 GLuint MaxArrayLockSize
;
2214 GLfloat MinPointSize
, MaxPointSize
; /* aliased */
2215 GLfloat MinPointSizeAA
, MaxPointSizeAA
; /* antialiased */
2216 GLfloat PointSizeGranularity
;
2217 GLfloat MinLineWidth
, MaxLineWidth
; /* aliased */
2218 GLfloat MinLineWidthAA
, MaxLineWidthAA
; /* antialiased */
2219 GLfloat LineWidthGranularity
;
2220 GLuint MaxColorTableSize
;
2221 GLuint MaxConvolutionWidth
;
2222 GLuint MaxConvolutionHeight
;
2223 GLuint MaxClipPlanes
;
2225 GLfloat MaxShininess
; /* GL_NV_light_max_exponent */
2226 GLfloat MaxSpotExponent
; /* GL_NV_light_max_exponent */
2227 GLuint MaxViewportWidth
, MaxViewportHeight
;
2228 /* GL_ARB_vertex_program */
2229 GLuint MaxVertexProgramInstructions
;
2230 GLuint MaxVertexProgramAttribs
;
2231 GLuint MaxVertexProgramTemps
;
2232 GLuint MaxVertexProgramLocalParams
;
2233 GLuint MaxVertexProgramEnvParams
;
2234 GLuint MaxVertexProgramAddressRegs
;
2235 /* GL_ARB_fragment_program */
2236 GLuint MaxFragmentProgramInstructions
;
2237 GLuint MaxFragmentProgramAttribs
;
2238 GLuint MaxFragmentProgramTemps
;
2239 GLuint MaxFragmentProgramLocalParams
;
2240 GLuint MaxFragmentProgramEnvParams
;
2241 GLuint MaxFragmentProgramAddressRegs
;
2242 GLuint MaxFragmentProgramAluInstructions
;
2243 GLuint MaxFragmentProgramTexInstructions
;
2244 GLuint MaxFragmentProgramTexIndirections
;
2245 /* vertex or fragment program */
2246 GLuint MaxProgramMatrices
;
2247 GLuint MaxProgramMatrixStackDepth
;
2248 /* vertex array / buffer object bounds checking */
2249 GLboolean CheckArrayBounds
;
2250 /* GL_ARB_draw_buffers */
2251 GLuint MaxDrawBuffers
;
2252 /* GL_OES_read_format */
2253 GLenum ColorReadFormat
;
2254 GLenum ColorReadType
;
2255 /* GL_EXT_framebuffer_object */
2256 GLuint MaxColorAttachments
;
2257 GLuint MaxRenderbufferSize
;
2262 * Enable flag for each OpenGL extension. Different device drivers will
2263 * enable different extensions at runtime.
2265 struct gl_extensions
2268 * \name Flags to quickly test if certain extensions are available.
2270 * Not every extension needs to have such a flag, but it's encouraged.
2273 GLboolean dummy
; /* don't remove this! */
2274 GLboolean ARB_depth_texture
;
2275 GLboolean ARB_draw_buffers
;
2276 GLboolean ARB_fragment_program
;
2277 GLboolean ARB_fragment_shader
;
2278 GLboolean ARB_half_float_pixel
;
2279 GLboolean ARB_imaging
;
2280 GLboolean ARB_multisample
;
2281 GLboolean ARB_multitexture
;
2282 GLboolean ARB_occlusion_query
;
2283 GLboolean ARB_point_sprite
;
2284 GLboolean ARB_shader_objects
;
2285 GLboolean ARB_shading_language_100
;
2286 GLboolean ARB_shadow
;
2287 GLboolean ARB_texture_border_clamp
;
2288 GLboolean ARB_texture_compression
;
2289 GLboolean ARB_texture_cube_map
;
2290 GLboolean ARB_texture_env_combine
;
2291 GLboolean ARB_texture_env_crossbar
;
2292 GLboolean ARB_texture_env_dot3
;
2293 GLboolean ARB_texture_float
;
2294 GLboolean ARB_texture_mirrored_repeat
;
2295 GLboolean ARB_texture_non_power_of_two
;
2296 GLboolean ARB_transpose_matrix
;
2297 GLboolean ARB_vertex_buffer_object
;
2298 GLboolean ARB_vertex_program
;
2299 GLboolean ARB_vertex_shader
;
2300 GLboolean ARB_window_pos
;
2303 GLboolean EXT_blend_color
;
2304 GLboolean EXT_blend_equation_separate
;
2305 GLboolean EXT_blend_func_separate
;
2306 GLboolean EXT_blend_logic_op
;
2307 GLboolean EXT_blend_minmax
;
2308 GLboolean EXT_blend_subtract
;
2309 GLboolean EXT_clip_volume_hint
;
2310 GLboolean EXT_cull_vertex
;
2311 GLboolean EXT_convolution
;
2312 GLboolean EXT_compiled_vertex_array
;
2313 GLboolean EXT_copy_texture
;
2314 GLboolean EXT_depth_bounds_test
;
2315 GLboolean EXT_draw_range_elements
;
2316 GLboolean EXT_framebuffer_object
;
2317 GLboolean EXT_fog_coord
;
2318 GLboolean EXT_histogram
;
2319 GLboolean EXT_multi_draw_arrays
;
2320 GLboolean EXT_paletted_texture
;
2321 GLboolean EXT_packed_pixels
;
2322 GLboolean EXT_pixel_buffer_object
;
2323 GLboolean EXT_point_parameters
;
2324 GLboolean EXT_polygon_offset
;
2325 GLboolean EXT_rescale_normal
;
2326 GLboolean EXT_shadow_funcs
;
2327 GLboolean EXT_secondary_color
;
2328 GLboolean EXT_separate_specular_color
;
2329 GLboolean EXT_shared_texture_palette
;
2330 GLboolean EXT_stencil_wrap
;
2331 GLboolean EXT_stencil_two_side
;
2332 GLboolean EXT_subtexture
;
2333 GLboolean EXT_texture
;
2334 GLboolean EXT_texture_object
;
2335 GLboolean EXT_texture3D
;
2336 GLboolean EXT_texture_compression_s3tc
;
2337 GLboolean EXT_texture_env_add
;
2338 GLboolean EXT_texture_env_combine
;
2339 GLboolean EXT_texture_env_dot3
;
2340 GLboolean EXT_texture_filter_anisotropic
;
2341 GLboolean EXT_texture_lod_bias
;
2342 GLboolean EXT_texture_mirror_clamp
;
2343 GLboolean EXT_vertex_array
;
2344 GLboolean EXT_vertex_array_set
;
2345 /* vendor extensions */
2346 GLboolean APPLE_client_storage
;
2347 GLboolean APPLE_packed_pixels
;
2348 GLboolean ATI_texture_mirror_once
;
2349 GLboolean ATI_texture_env_combine3
;
2350 GLboolean ATI_fragment_shader
;
2351 GLboolean HP_occlusion_test
;
2352 GLboolean IBM_rasterpos_clip
;
2353 GLboolean IBM_multimode_draw_arrays
;
2354 GLboolean MESA_pack_invert
;
2355 GLboolean MESA_packed_depth_stencil
;
2356 GLboolean MESA_program_debug
;
2357 GLboolean MESA_resize_buffers
;
2358 GLboolean MESA_ycbcr_texture
;
2359 GLboolean NV_blend_square
;
2360 GLboolean NV_fragment_program
;
2361 GLboolean NV_light_max_exponent
;
2362 GLboolean NV_point_sprite
;
2363 GLboolean NV_texgen_reflection
;
2364 GLboolean NV_texture_rectangle
;
2365 GLboolean NV_vertex_program
;
2366 GLboolean NV_vertex_program1_1
;
2367 GLboolean OES_read_format
;
2368 GLboolean SGI_color_matrix
;
2369 GLboolean SGI_color_table
;
2370 GLboolean SGI_texture_color_table
;
2371 GLboolean SGIS_generate_mipmap
;
2372 GLboolean SGIS_pixel_texture
;
2373 GLboolean SGIS_texture_edge_clamp
;
2374 GLboolean SGIS_texture_lod
;
2375 GLboolean SGIX_depth_texture
;
2376 GLboolean SGIX_pixel_texture
;
2377 GLboolean SGIX_shadow
;
2378 GLboolean SGIX_shadow_ambient
; /* or GL_ARB_shadow_ambient */
2379 GLboolean TDFX_texture_compression_FXT1
;
2382 /* The extension string */
2383 const GLubyte
*String
;
2388 * A stack of matrices (projection, modelview, color, texture, etc).
2392 GLmatrix
*Top
; /**< points into Stack */
2393 GLmatrix
*Stack
; /**< array [MaxDepth] of GLmatrix */
2394 GLuint Depth
; /**< 0 <= Depth < MaxDepth */
2395 GLuint MaxDepth
; /**< size of Stack[] array */
2396 GLuint DirtyFlag
; /**< _NEW_MODELVIEW or _NEW_PROJECTION, for example */
2401 * \name Bits for image transfer operations
2403 * \sa __GLcontextRec::ImageTransferState.
2406 #define IMAGE_SCALE_BIAS_BIT 0x1
2407 #define IMAGE_SHIFT_OFFSET_BIT 0x2
2408 #define IMAGE_MAP_COLOR_BIT 0x4
2409 #define IMAGE_COLOR_TABLE_BIT 0x8
2410 #define IMAGE_CONVOLUTION_BIT 0x10
2411 #define IMAGE_POST_CONVOLUTION_SCALE_BIAS 0x20
2412 #define IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT 0x40
2413 #define IMAGE_COLOR_MATRIX_BIT 0x80
2414 #define IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT 0x100
2415 #define IMAGE_HISTOGRAM_BIT 0x200
2416 #define IMAGE_MIN_MAX_BIT 0x400
2417 #define IMAGE_CLAMP_BIT 0x800 /* extra */
2420 /** Pixel Transfer ops up to convolution */
2421 #define IMAGE_PRE_CONVOLUTION_BITS (IMAGE_SCALE_BIAS_BIT | \
2422 IMAGE_SHIFT_OFFSET_BIT | \
2423 IMAGE_MAP_COLOR_BIT | \
2424 IMAGE_COLOR_TABLE_BIT)
2426 /** Pixel transfer ops after convolution */
2427 #define IMAGE_POST_CONVOLUTION_BITS (IMAGE_POST_CONVOLUTION_SCALE_BIAS | \
2428 IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT | \
2429 IMAGE_COLOR_MATRIX_BIT | \
2430 IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT |\
2431 IMAGE_HISTOGRAM_BIT | \
2437 * \name Bits to indicate what state has changed.
2442 #define _NEW_MODELVIEW 0x1 /**< __GLcontextRec::ModelView */
2443 #define _NEW_PROJECTION 0x2 /**< __GLcontextRec::Projection */
2444 #define _NEW_TEXTURE_MATRIX 0x4 /**< __GLcontextRec::TextureMatrix */
2445 #define _NEW_COLOR_MATRIX 0x8 /**< __GLcontextRec::ColorMatrix */
2446 #define _NEW_ACCUM 0x10 /**< __GLcontextRec::Accum */
2447 #define _NEW_COLOR 0x20 /**< __GLcontextRec::Color */
2448 #define _NEW_DEPTH 0x40 /**< __GLcontextRec::Depth */
2449 #define _NEW_EVAL 0x80 /**< __GLcontextRec::Eval, __GLcontextRec::EvalMap */
2450 #define _NEW_FOG 0x100 /**< __GLcontextRec::Fog */
2451 #define _NEW_HINT 0x200 /**< __GLcontextRec::Hint */
2452 #define _NEW_LIGHT 0x400 /**< __GLcontextRec::Light */
2453 #define _NEW_LINE 0x800 /**< __GLcontextRec::Line */
2454 #define _NEW_PIXEL 0x1000 /**< __GLcontextRec::Pixel */
2455 #define _NEW_POINT 0x2000 /**< __GLcontextRec::Point */
2456 #define _NEW_POLYGON 0x4000 /**< __GLcontextRec::Polygon */
2457 #define _NEW_POLYGONSTIPPLE 0x8000 /**< __GLcontextRec::PolygonStipple */
2458 #define _NEW_SCISSOR 0x10000 /**< __GLcontextRec::Scissor */
2459 #define _NEW_STENCIL 0x20000 /**< __GLcontextRec::Stencil */
2460 #define _NEW_TEXTURE 0x40000 /**< __GLcontextRec::Texture */
2461 #define _NEW_TRANSFORM 0x80000 /**< __GLcontextRec::Transform */
2462 #define _NEW_VIEWPORT 0x100000 /**< __GLcontextRec::Viewport */
2463 #define _NEW_PACKUNPACK 0x200000 /**< __GLcontextRec::Pack, __GLcontextRec::Unpack */
2464 #define _NEW_ARRAY 0x400000 /**< __GLcontextRec::Array */
2465 #define _NEW_RENDERMODE 0x800000 /**< __GLcontextRec::RenderMode, __GLcontextRec::Feedback, __GLcontextRec::Select */
2466 #define _NEW_BUFFERS 0x1000000 /**< __GLcontextRec::Visual, __GLcontextRec::DrawBuffer, */
2467 #define _NEW_MULTISAMPLE 0x2000000 /**< __GLcontextRec::Multisample */
2468 #define _NEW_TRACK_MATRIX 0x4000000 /**< __GLcontextRec::VertexProgram */
2469 #define _NEW_PROGRAM 0x8000000 /**< __GLcontextRec::VertexProgram */
2475 * \name Bits to track array state changes
2477 * Also used to summarize array enabled.
2480 #define _NEW_ARRAY_VERTEX VERT_BIT_POS
2481 #define _NEW_ARRAY_WEIGHT VERT_BIT_WEIGHT
2482 #define _NEW_ARRAY_NORMAL VERT_BIT_NORMAL
2483 #define _NEW_ARRAY_COLOR0 VERT_BIT_COLOR0
2484 #define _NEW_ARRAY_COLOR1 VERT_BIT_COLOR1
2485 #define _NEW_ARRAY_FOGCOORD VERT_BIT_FOG
2486 #define _NEW_ARRAY_INDEX VERT_BIT_SIX
2487 #define _NEW_ARRAY_EDGEFLAG VERT_BIT_SEVEN
2488 #define _NEW_ARRAY_TEXCOORD_0 VERT_BIT_TEX0
2489 #define _NEW_ARRAY_TEXCOORD_1 VERT_BIT_TEX1
2490 #define _NEW_ARRAY_TEXCOORD_2 VERT_BIT_TEX2
2491 #define _NEW_ARRAY_TEXCOORD_3 VERT_BIT_TEX3
2492 #define _NEW_ARRAY_TEXCOORD_4 VERT_BIT_TEX4
2493 #define _NEW_ARRAY_TEXCOORD_5 VERT_BIT_TEX5
2494 #define _NEW_ARRAY_TEXCOORD_6 VERT_BIT_TEX6
2495 #define _NEW_ARRAY_TEXCOORD_7 VERT_BIT_TEX7
2496 #define _NEW_ARRAY_ATTRIB_0 0x10000 /* start at bit 16 */
2497 #define _NEW_ARRAY_ALL 0xffffffff
2500 #define _NEW_ARRAY_TEXCOORD(i) (_NEW_ARRAY_TEXCOORD_0 << (i))
2501 #define _NEW_ARRAY_ATTRIB(i) (_NEW_ARRAY_ATTRIB_0 << (i))
2506 * \name A bunch of flags that we think might be useful to drivers.
2508 * Set in the __GLcontextRec::_TriangleCaps bitfield.
2511 #define DD_FLATSHADE 0x1
2512 #define DD_SEPARATE_SPECULAR 0x2
2513 #define DD_TRI_CULL_FRONT_BACK 0x4 /* special case on some hw */
2514 #define DD_TRI_LIGHT_TWOSIDE 0x8
2515 #define DD_TRI_UNFILLED 0x10
2516 #define DD_TRI_SMOOTH 0x20
2517 #define DD_TRI_STIPPLE 0x40
2518 #define DD_TRI_OFFSET 0x80
2519 #define DD_LINE_SMOOTH 0x100
2520 #define DD_LINE_STIPPLE 0x200
2521 #define DD_LINE_WIDTH 0x400
2522 #define DD_POINT_SMOOTH 0x800
2523 #define DD_POINT_SIZE 0x1000
2524 #define DD_POINT_ATTEN 0x2000
2525 #define DD_TRI_TWOSTENCIL 0x4000
2530 * \name Define the state changes under which each of these bits might change
2533 #define _DD_NEW_FLATSHADE _NEW_LIGHT
2534 #define _DD_NEW_SEPARATE_SPECULAR (_NEW_LIGHT | _NEW_FOG | _NEW_PROGRAM)
2535 #define _DD_NEW_TRI_CULL_FRONT_BACK _NEW_POLYGON
2536 #define _DD_NEW_TRI_LIGHT_TWOSIDE _NEW_LIGHT
2537 #define _DD_NEW_TRI_UNFILLED _NEW_POLYGON
2538 #define _DD_NEW_TRI_SMOOTH _NEW_POLYGON
2539 #define _DD_NEW_TRI_STIPPLE _NEW_POLYGON
2540 #define _DD_NEW_TRI_OFFSET _NEW_POLYGON
2541 #define _DD_NEW_LINE_SMOOTH _NEW_LINE
2542 #define _DD_NEW_LINE_STIPPLE _NEW_LINE
2543 #define _DD_NEW_LINE_WIDTH _NEW_LINE
2544 #define _DD_NEW_POINT_SMOOTH _NEW_POINT
2545 #define _DD_NEW_POINT_SIZE _NEW_POINT
2546 #define _DD_NEW_POINT_ATTEN _NEW_POINT
2550 #define _MESA_NEW_NEED_EYE_COORDS (_NEW_LIGHT | \
2555 #define _MESA_NEW_NEED_NORMALS (_NEW_LIGHT | \
2558 #define _IMAGE_NEW_TRANSFER_STATE (_NEW_PIXEL | _NEW_COLOR_MATRIX)
2564 * Forward declaration of display list data types:
2567 typedef union node Node
;
2570 /* This has to be included here. */
2574 #define NUM_VERTEX_FORMAT_ENTRIES (sizeof(GLvertexformat) / sizeof(void *))
2577 * Core Mesa's support for tnl modules:
2579 struct gl_tnl_module
2582 * Vertex format to be lazily swapped into current dispatch.
2584 const GLvertexformat
*Current
;
2587 * \name Record of functions swapped out.
2588 * On restore, only need to swap these functions back in.
2591 void *Swapped
[NUM_VERTEX_FORMAT_ENTRIES
][2];
2596 /* Strictly this is a tnl/ private concept, but it doesn't seem
2597 * worthwhile adding a tnl private structure just to hold this one bit
2600 #define MESA_DLIST_DANGLING_REFS 0x1
2602 /* Provide a location where information about a display list can be
2603 * collected. Could be extended with driverPrivate structures,
2604 * etc. in the future.
2606 struct mesa_display_list
2615 * State used during display list compilation and execution.
2617 struct mesa_list_state
2619 struct mesa_display_list
*CallStack
[MAX_LIST_NESTING
];
2620 GLuint CallDepth
; /**< Current recursion calling depth */
2622 struct mesa_display_list
*CurrentList
;
2623 Node
*CurrentListPtr
; /**< Head of list being compiled */
2624 GLuint CurrentListNum
; /**< Number of the list being compiled */
2625 Node
*CurrentBlock
; /**< Pointer to current block of nodes */
2626 GLuint CurrentPos
; /**< Index into current block of nodes */
2628 GLvertexformat ListVtxfmt
;
2630 GLubyte ActiveAttribSize
[VERT_ATTRIB_MAX
];
2631 GLfloat CurrentAttrib
[VERT_ATTRIB_MAX
][4];
2633 GLubyte ActiveMaterialSize
[MAT_ATTRIB_MAX
];
2634 GLfloat CurrentMaterial
[MAT_ATTRIB_MAX
][4];
2636 GLubyte ActiveIndex
;
2637 GLfloat CurrentIndex
;
2639 GLubyte ActiveEdgeFlag
;
2640 GLboolean CurrentEdgeFlag
;
2645 * Mesa rendering context.
2647 * This is the central context data structure for Mesa. Almost all
2648 * OpenGL state is contained in this structure.
2649 * Think of this as a base class from which device drivers will derive
2652 * The GLcontext typedef names this structure.
2654 struct __GLcontextRec
2657 * \name OS related interfaces.
2659 * These \b must be the first members of this structure, because they are
2660 * exposed to the outside world (i.e. GLX extension).
2663 __GLimports imports
;
2664 __GLexports exports
;
2667 /** State possibly shared with other contexts in the address space */
2668 struct gl_shared_state
*Shared
;
2670 /** \name API function pointer tables */
2672 struct _glapi_table
*Save
; /**< Display list save functions */
2673 struct _glapi_table
*Exec
; /**< Execute functions */
2674 struct _glapi_table
*CurrentDispatch
; /**< == Save or Exec !! */
2678 GLframebuffer
*DrawBuffer
; /**< buffer for writing */
2679 GLframebuffer
*ReadBuffer
; /**< buffer for reading */
2680 GLframebuffer
*WinSysDrawBuffer
; /**< set with MakeCurrent */
2681 GLframebuffer
*WinSysReadBuffer
; /**< set with MakeCurrent */
2684 * Device driver function pointer table
2686 struct dd_function_table Driver
;
2688 void *DriverCtx
; /**< Points to device driver context/state */
2689 void *DriverMgrCtx
; /**< Points to device driver manager (optional)*/
2691 /** Core/Driver constants */
2692 struct gl_constants Const
;
2694 /** \name The various 4x4 matrix stacks */
2696 struct matrix_stack ModelviewMatrixStack
;
2697 struct matrix_stack ProjectionMatrixStack
;
2698 struct matrix_stack ColorMatrixStack
;
2699 struct matrix_stack TextureMatrixStack
[MAX_TEXTURE_COORD_UNITS
];
2700 struct matrix_stack ProgramMatrixStack
[MAX_PROGRAM_MATRICES
];
2701 struct matrix_stack
*CurrentStack
; /**< Points to one of the above stacks */
2704 /** Combined modelview and projection matrix */
2705 GLmatrix _ModelProjectMatrix
;
2707 /** \name Display lists */
2708 struct mesa_list_state ListState
;
2710 GLboolean ExecuteFlag
; /**< Execute GL commands? */
2711 GLboolean CompileFlag
; /**< Compile GL commands into display list? */
2714 struct gl_extensions Extensions
;
2716 /** \name Renderer attribute stack */
2718 GLuint AttribStackDepth
;
2719 struct gl_attrib_node
*AttribStack
[MAX_ATTRIB_STACK_DEPTH
];
2722 /** \name Renderer attribute groups
2724 * We define a struct for each attribute group to make pushing and popping
2725 * attributes easy. Also it's a good organization.
2728 struct gl_accum_attrib Accum
; /**< Accumulation buffer attributes */
2729 struct gl_colorbuffer_attrib Color
; /**< Color buffers attributes */
2730 struct gl_current_attrib Current
; /**< Current attributes */
2731 struct gl_depthbuffer_attrib Depth
; /**< Depth buffer attributes */
2732 struct gl_eval_attrib Eval
; /**< Eval attributes */
2733 struct gl_fog_attrib Fog
; /**< Fog attributes */
2734 struct gl_hint_attrib Hint
; /**< Hint attributes */
2735 struct gl_light_attrib Light
; /**< Light attributes */
2736 struct gl_line_attrib Line
; /**< Line attributes */
2737 struct gl_list_attrib List
; /**< List attributes */
2738 struct gl_multisample_attrib Multisample
;
2739 struct gl_pixel_attrib Pixel
; /**< Pixel attributes */
2740 struct gl_point_attrib Point
; /**< Point attributes */
2741 struct gl_polygon_attrib Polygon
; /**< Polygon attributes */
2742 GLuint PolygonStipple
[32]; /**< Polygon stipple */
2743 struct gl_scissor_attrib Scissor
; /**< Scissor attributes */
2744 struct gl_stencil_attrib Stencil
; /**< Stencil buffer attributes */
2745 struct gl_texture_attrib Texture
; /**< Texture attributes */
2746 struct gl_transform_attrib Transform
; /**< Transformation attributes */
2747 struct gl_viewport_attrib Viewport
; /**< Viewport attributes */
2750 /** \name Client attribute stack */
2752 GLuint ClientAttribStackDepth
;
2753 struct gl_attrib_node
*ClientAttribStack
[MAX_CLIENT_ATTRIB_STACK_DEPTH
];
2756 /** \name Client attribute groups */
2758 struct gl_array_attrib Array
; /**< Vertex arrays */
2759 struct gl_pixelstore_attrib Pack
; /**< Pixel packing */
2760 struct gl_pixelstore_attrib Unpack
; /**< Pixel unpacking */
2761 struct gl_pixelstore_attrib DefaultPacking
; /**< Default params */
2764 /** \name Other assorted state (not pushed/popped on attribute stack) */
2766 struct gl_histogram_attrib Histogram
;
2767 struct gl_minmax_attrib MinMax
;
2768 struct gl_convolution_attrib Convolution1D
;
2769 struct gl_convolution_attrib Convolution2D
;
2770 struct gl_convolution_attrib Separable2D
;
2772 struct gl_evaluators EvalMap
; /**< All evaluators */
2773 struct gl_feedback Feedback
; /**< Feedback */
2774 struct gl_selection Select
; /**< Selection */
2776 struct gl_color_table ColorTable
; /**< Pre-convolution */
2777 struct gl_color_table ProxyColorTable
; /**< Pre-convolution */
2778 struct gl_color_table PostConvolutionColorTable
;
2779 struct gl_color_table ProxyPostConvolutionColorTable
;
2780 struct gl_color_table PostColorMatrixColorTable
;
2781 struct gl_color_table ProxyPostColorMatrixColorTable
;
2783 struct gl_program_state Program
; /**< for vertex or fragment progs */
2784 struct gl_vertex_program_state VertexProgram
; /**< GL_NV_vertex_program */
2785 struct gl_fragment_program_state FragmentProgram
; /**< GL_NV_fragment_program */
2786 struct gl_ati_fragment_shader_state ATIFragmentShader
; /**< GL_ATI_fragment_shader */
2788 struct fragment_program
*_TexEnvProgram
; /**< Texture state as fragment program */
2789 struct vertex_program
*_TnlProgram
; /**< Fixed func TNL state as vertex program */
2791 GLboolean _MaintainTexEnvProgram
;
2792 GLboolean _MaintainTnlProgram
;
2794 struct gl_occlusion_state Occlusion
; /**< GL_ARB_occlusion_query */
2796 struct gl_shader_objects_state ShaderObjects
; /* GL_ARB_shader_objects */
2799 #if FEATURE_EXT_framebuffer_object
2800 /*struct gl_framebuffer *CurrentFramebuffer;*/
2801 struct gl_renderbuffer
*CurrentRenderbuffer
;
2804 GLenum ErrorValue
; /**< Last error code */
2805 GLenum RenderMode
; /**< either GL_RENDER, GL_SELECT, GL_FEEDBACK */
2806 GLuint NewState
; /**< bitwise-or of _NEW_* flags */
2808 /** \name Derived state */
2810 GLuint _TriangleCaps
; /**< bitwise-or of DD_* flags */
2811 GLuint _ImageTransferState
;/**< bitwise-or of IMAGE_*_BIT flags */
2812 GLfloat _EyeZDir
[3];
2813 GLfloat _ModelViewInvScale
;
2814 GLuint _NeedEyeCoords
;
2815 GLuint _ForceEyeCoords
;
2816 GLboolean _RotateMode
;
2817 GLenum _CurrentProgram
; /* currently executing program */
2819 struct gl_shine_tab
*_ShineTable
[2]; /**< Active shine tables */
2820 struct gl_shine_tab
*_ShineTabList
; /**< MRU list of inactive shine tables */
2823 struct gl_list_extensions ListExt
; /**< driver dlist extensions */
2826 GLboolean OcclusionResult
; /**< for GL_HP_occlusion_test */
2827 GLboolean OcclusionResultSaved
; /**< for GL_HP_occlusion_test */
2828 GLuint _Facing
; /**< This is a hack for 2-sided stencil test.
2830 * We don't have a better way to communicate this value from
2831 * swrast_setup to swrast. */
2833 /** \name Color clamping (tentative part of GL_ARB_color_clamp_control) */
2835 GLboolean ClampFragmentColors
;
2836 GLboolean ClampVertexColors
;
2839 /** \name For debugging/development only */
2841 GLboolean FirstTimeCurrent
;
2844 /** Dither disable via MESA_NO_DITHER env var */
2847 /** software compression/decompression supported or not */
2848 GLboolean Mesa_DXTn
;
2850 /** Core tnl module support */
2851 struct gl_tnl_module TnlModule
;
2854 * \name Hooks for module contexts.
2856 * These will eventually live in the driver or elsewhere.
2859 void *swrast_context
;
2860 void *swsetup_context
;
2861 void *swtnl_context
;
2863 void *acache_context
;
2869 /** The string names for GL_POINT, GL_LINE_LOOP, etc */
2870 extern const char *_mesa_prim_name
[GL_POLYGON
+4];
2874 extern int MESA_VERBOSE
;
2875 extern int MESA_DEBUG_FLAGS
;
2876 # define MESA_FUNCTION __FUNCTION__
2878 # define MESA_VERBOSE 0
2879 # define MESA_DEBUG_FLAGS 0
2880 # define MESA_FUNCTION "a function"
2889 VERBOSE_VARRAY
= 0x0001,
2890 VERBOSE_TEXTURE
= 0x0002,
2891 VERBOSE_IMMEDIATE
= 0x0004,
2892 VERBOSE_PIPELINE
= 0x0008,
2893 VERBOSE_DRIVER
= 0x0010,
2894 VERBOSE_STATE
= 0x0020,
2895 VERBOSE_API
= 0x0040,
2896 VERBOSE_DISPLAY_LIST
= 0x0100,
2897 VERBOSE_LIGHTING
= 0x0200,
2898 VERBOSE_PRIMS
= 0x0400,
2899 VERBOSE_VERTS
= 0x0800,
2900 VERBOSE_DISASSEM
= 0x1000
2906 DEBUG_ALWAYS_FLUSH
= 0x1
2911 #define Elements(x) sizeof(x)/sizeof(*(x))
2914 #endif /* TYPES_H */