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 <GL/internal/glcore.h> /* GLimports/GLexports/GLcontextModes */
40 #include "config.h" /* Hardwired parameters */
41 #include "glapitable.h"
43 #include "math/m_matrix.h" /* GLmatrix */
47 * Color channel data type.
50 typedef GLubyte GLchan
;
52 #define CHAN_MAXF 255.0F
53 #define CHAN_TYPE GL_UNSIGNED_BYTE
55 typedef GLushort GLchan
;
56 #define CHAN_MAX 65535
57 #define CHAN_MAXF 65535.0F
58 #define CHAN_TYPE GL_UNSIGNED_SHORT
60 typedef GLfloat GLchan
;
62 #define CHAN_MAXF 1.0F
63 #define CHAN_TYPE GL_FLOAT
65 #error "illegal number of color channel bits"
70 /* Software accum done with GLshort at this time */
71 # error "illegal number of accumulation bits"
76 * Stencil buffer data type.
79 typedef GLubyte GLstencil
;
80 #elif STENCIL_BITS==16
81 typedef GLushort GLstencil
;
83 # error "illegal number of stencil bits"
88 * Used for storing intermediate depth buffer values.
89 * The actual depth/Z buffer might use 16 or 32-bit values.
91 * \note Must be 32-bits!
93 typedef GLuint GLdepth
;
97 * Fixed point data type.
101 * Fixed point arithmetic macros
103 #ifndef FIXED_FRAC_BITS
104 #define FIXED_FRAC_BITS 11
107 #define FIXED_SHIFT FIXED_FRAC_BITS
108 #define FIXED_ONE (1 << FIXED_SHIFT)
109 #define FIXED_HALF (1 << (FIXED_SHIFT-1))
110 #define FIXED_FRAC_MASK (FIXED_ONE - 1)
111 #define FIXED_INT_MASK (~FIXED_FRAC_MASK)
112 #define FIXED_EPSILON 1
113 #define FIXED_SCALE ((float) FIXED_ONE)
114 #define FIXED_DBL_SCALE ((double) FIXED_ONE)
115 #define FloatToFixed(X) (IROUND((X) * FIXED_SCALE))
116 #define FixedToDouble(X) ((X) * (1.0 / FIXED_DBL_SCALE))
117 #define IntToFixed(I) ((I) << FIXED_SHIFT)
118 #define FixedToInt(X) ((X) >> FIXED_SHIFT)
119 #define FixedToUns(X) (((unsigned int)(X)) >> FIXED_SHIFT)
120 #define FixedCeil(X) (((X) + FIXED_ONE - FIXED_EPSILON) & FIXED_INT_MASK)
121 #define FixedFloor(X) ((X) & FIXED_INT_MASK)
122 #define FixedToFloat(X) ((X) * (1.0F / FIXED_SCALE))
123 #define PosFloatToFixed(X) FloatToFixed(X)
124 #define SignedFloatToFixed(X) FloatToFixed(X)
129 * \name Some forward type declarations
132 struct _mesa_HashTable
;
133 struct gl_pixelstore_attrib
;
134 struct gl_texture_format
;
135 struct gl_texture_image
;
136 struct gl_texture_object
;
137 typedef struct __GLcontextRec GLcontext
;
138 typedef struct __GLcontextModesRec GLvisual
;
139 typedef struct gl_framebuffer GLframebuffer
;
145 * Indexes for vertex program attributes.
146 * GL_NV_vertex_program aliases generic attributes over the conventional
147 * attributes. In GL_ARB_vertex_program shader the aliasing is optional.
148 * In GL_ARB_vertex_shader / OpenGL 2.0 the aliasing is disallowed (the
149 * generic attributes are distinct/separate).
154 VERT_ATTRIB_WEIGHT
= 1,
155 VERT_ATTRIB_NORMAL
= 2,
156 VERT_ATTRIB_COLOR0
= 3,
157 VERT_ATTRIB_COLOR1
= 4,
160 VERT_ATTRIB_SEVEN
= 7,
161 VERT_ATTRIB_TEX0
= 8,
162 VERT_ATTRIB_TEX1
= 9,
163 VERT_ATTRIB_TEX2
= 10,
164 VERT_ATTRIB_TEX3
= 11,
165 VERT_ATTRIB_TEX4
= 12,
166 VERT_ATTRIB_TEX5
= 13,
167 VERT_ATTRIB_TEX6
= 14,
168 VERT_ATTRIB_TEX7
= 15,
169 VERT_ATTRIB_GENERIC0
= 16,
170 VERT_ATTRIB_GENERIC1
= 17,
171 VERT_ATTRIB_GENERIC2
= 18,
172 VERT_ATTRIB_GENERIC3
= 19,
177 * Bitflags for vertex attributes.
178 * These are used in bitfields in many places.
181 #define VERT_BIT_POS (1 << VERT_ATTRIB_POS)
182 #define VERT_BIT_WEIGHT (1 << VERT_ATTRIB_WEIGHT)
183 #define VERT_BIT_NORMAL (1 << VERT_ATTRIB_NORMAL)
184 #define VERT_BIT_COLOR0 (1 << VERT_ATTRIB_COLOR0)
185 #define VERT_BIT_COLOR1 (1 << VERT_ATTRIB_COLOR1)
186 #define VERT_BIT_FOG (1 << VERT_ATTRIB_FOG)
187 #define VERT_BIT_SIX (1 << VERT_ATTRIB_SIX)
188 #define VERT_BIT_SEVEN (1 << VERT_ATTRIB_SEVEN)
189 #define VERT_BIT_TEX0 (1 << VERT_ATTRIB_TEX0)
190 #define VERT_BIT_TEX1 (1 << VERT_ATTRIB_TEX1)
191 #define VERT_BIT_TEX2 (1 << VERT_ATTRIB_TEX2)
192 #define VERT_BIT_TEX3 (1 << VERT_ATTRIB_TEX3)
193 #define VERT_BIT_TEX4 (1 << VERT_ATTRIB_TEX4)
194 #define VERT_BIT_TEX5 (1 << VERT_ATTRIB_TEX5)
195 #define VERT_BIT_TEX6 (1 << VERT_ATTRIB_TEX6)
196 #define VERT_BIT_TEX7 (1 << VERT_ATTRIB_TEX7)
197 #define VERT_BIT_GENERIC0 (1 << VERT_ATTRIB_GENERIC0)
198 #define VERT_BIT_GENERIC1 (1 << VERT_ATTRIB_GENERIC1)
199 #define VERT_BIT_GENERIC2 (1 << VERT_ATTRIB_GENERIC2)
200 #define VERT_BIT_GENERIC3 (1 << VERT_ATTRIB_GENERIC3)
202 #define VERT_BIT_TEX(u) (1 << (VERT_ATTRIB_TEX0 + (u)))
203 #define VERT_BIT_GENERIC(g) (1 << (VERT_ATTRIB_GENERIC0 + (g)))
208 * Indexes for vertex program result attributes
210 #define VERT_RESULT_HPOS 0
211 #define VERT_RESULT_COL0 1
212 #define VERT_RESULT_COL1 2
213 #define VERT_RESULT_BFC0 3
214 #define VERT_RESULT_BFC1 4
215 #define VERT_RESULT_FOGC 5
216 #define VERT_RESULT_PSIZ 6
217 #define VERT_RESULT_TEX0 7
218 #define VERT_RESULT_TEX1 8
219 #define VERT_RESULT_TEX2 9
220 #define VERT_RESULT_TEX3 10
221 #define VERT_RESULT_TEX4 11
222 #define VERT_RESULT_TEX5 12
223 #define VERT_RESULT_TEX6 13
224 #define VERT_RESULT_TEX7 14
225 #define VERT_RESULT_MAX 15
229 * Indexes for fragment program input attributes.
233 FRAG_ATTRIB_WPOS
= 0,
234 FRAG_ATTRIB_COL0
= 1,
235 FRAG_ATTRIB_COL1
= 2,
236 FRAG_ATTRIB_FOGC
= 3,
237 FRAG_ATTRIB_TEX0
= 4,
238 FRAG_ATTRIB_TEX1
= 5,
239 FRAG_ATTRIB_TEX2
= 6,
240 FRAG_ATTRIB_TEX3
= 7,
241 FRAG_ATTRIB_TEX4
= 8,
242 FRAG_ATTRIB_TEX5
= 9,
243 FRAG_ATTRIB_TEX6
= 10,
244 FRAG_ATTRIB_TEX7
= 11
248 * Bitflags for fragment attributes.
251 #define FRAG_BIT_WPOS (1 << FRAG_ATTRIB_WPOS)
252 #define FRAG_BIT_COL0 (1 << FRAG_ATTRIB_COL0)
253 #define FRAG_BIT_COL1 (1 << FRAG_ATTRIB_COL1)
254 #define FRAG_BIT_FOGC (1 << FRAG_ATTRIB_FOGC)
255 #define FRAG_BIT_TEX0 (1 << FRAG_ATTRIB_TEX0)
256 #define FRAG_BIT_TEX1 (1 << FRAG_ATTRIB_TEX1)
257 #define FRAG_BIT_TEX2 (1 << FRAG_ATTRIB_TEX2)
258 #define FRAG_BIT_TEX3 (1 << FRAG_ATTRIB_TEX3)
259 #define FRAG_BIT_TEX4 (1 << FRAG_ATTRIB_TEX4)
260 #define FRAG_BIT_TEX5 (1 << FRAG_ATTRIB_TEX5)
261 #define FRAG_BIT_TEX6 (1 << FRAG_ATTRIB_TEX6)
262 #define FRAG_BIT_TEX7 (1 << FRAG_ATTRIB_TEX7)
264 #define FRAG_BITS_TEX_ANY (FRAG_BIT_TEX0| \
276 * Indexes for all renderbuffers
279 BUFFER_FRONT_LEFT
= 0, /* the four standard color buffers */
280 BUFFER_BACK_LEFT
= 1,
281 BUFFER_FRONT_RIGHT
= 2,
282 BUFFER_BACK_RIGHT
= 3,
283 BUFFER_AUX0
= 4, /* optional aux buffer */
290 BUFFER_COLOR0
= 11, /* generic renderbuffers */
302 * Bit flags for all renderbuffers
304 #define BUFFER_BIT_FRONT_LEFT (1 << BUFFER_FRONT_LEFT)
305 #define BUFFER_BIT_BACK_LEFT (1 << BUFFER_BACK_LEFT)
306 #define BUFFER_BIT_FRONT_RIGHT (1 << BUFFER_FRONT_RIGHT)
307 #define BUFFER_BIT_BACK_RIGHT (1 << BUFFER_BACK_RIGHT)
308 #define BUFFER_BIT_AUX0 (1 << BUFFER_AUX0)
309 #define BUFFER_BIT_AUX1 (1 << BUFFER_AUX1)
310 #define BUFFER_BIT_AUX2 (1 << BUFFER_AUX2)
311 #define BUFFER_BIT_AUX3 (1 << BUFFER_AUX3)
312 #define BUFFER_BIT_DEPTH (1 << BUFFER_DEPTH)
313 #define BUFFER_BIT_STENCIL (1 << BUFFER_STENCIL)
314 #define BUFFER_BIT_ACCUM (1 << BUFFER_ACCUM)
315 #define BUFFER_BIT_COLOR0 (1 << BUFFER_COLOR0)
316 #define BUFFER_BIT_COLOR1 (1 << BUFFER_COLOR1)
317 #define BUFFER_BIT_COLOR2 (1 << BUFFER_COLOR2)
318 #define BUFFER_BIT_COLOR3 (1 << BUFFER_COLOR3)
319 #define BUFFER_BIT_COLOR4 (1 << BUFFER_COLOR4)
320 #define BUFFER_BIT_COLOR5 (1 << BUFFER_COLOR5)
321 #define BUFFER_BIT_COLOR6 (1 << BUFFER_COLOR6)
322 #define BUFFER_BIT_COLOR7 (1 << BUFFER_COLOR7)
326 * Data structure for color tables
328 struct gl_color_table
330 GLenum Format
; /**< GL_ALPHA, GL_RGB, GL_RGB, etc */
332 GLuint Size
; /**< number of entries (rows) in table */
333 GLvoid
*Table
; /**< points to data of <Type> */
334 GLenum Type
; /**< GL_UNSIGNED_BYTE or GL_FLOAT */
339 GLubyte LuminanceSize
;
340 GLubyte IntensitySize
;
345 * \name Bit flags used for updating material values.
348 #define MAT_ATTRIB_FRONT_AMBIENT 0
349 #define MAT_ATTRIB_BACK_AMBIENT 1
350 #define MAT_ATTRIB_FRONT_DIFFUSE 2
351 #define MAT_ATTRIB_BACK_DIFFUSE 3
352 #define MAT_ATTRIB_FRONT_SPECULAR 4
353 #define MAT_ATTRIB_BACK_SPECULAR 5
354 #define MAT_ATTRIB_FRONT_EMISSION 6
355 #define MAT_ATTRIB_BACK_EMISSION 7
356 #define MAT_ATTRIB_FRONT_SHININESS 8
357 #define MAT_ATTRIB_BACK_SHININESS 9
358 #define MAT_ATTRIB_FRONT_INDEXES 10
359 #define MAT_ATTRIB_BACK_INDEXES 11
360 #define MAT_ATTRIB_MAX 12
362 #define MAT_ATTRIB_AMBIENT(f) (MAT_ATTRIB_FRONT_AMBIENT+(f))
363 #define MAT_ATTRIB_DIFFUSE(f) (MAT_ATTRIB_FRONT_DIFFUSE+(f))
364 #define MAT_ATTRIB_SPECULAR(f) (MAT_ATTRIB_FRONT_SPECULAR+(f))
365 #define MAT_ATTRIB_EMISSION(f) (MAT_ATTRIB_FRONT_EMISSION+(f))
366 #define MAT_ATTRIB_SHININESS(f)(MAT_ATTRIB_FRONT_SHININESS+(f))
367 #define MAT_ATTRIB_INDEXES(f) (MAT_ATTRIB_FRONT_INDEXES+(f))
369 #define MAT_INDEX_AMBIENT 0
370 #define MAT_INDEX_DIFFUSE 1
371 #define MAT_INDEX_SPECULAR 2
373 #define MAT_BIT_FRONT_AMBIENT (1<<MAT_ATTRIB_FRONT_AMBIENT)
374 #define MAT_BIT_BACK_AMBIENT (1<<MAT_ATTRIB_BACK_AMBIENT)
375 #define MAT_BIT_FRONT_DIFFUSE (1<<MAT_ATTRIB_FRONT_DIFFUSE)
376 #define MAT_BIT_BACK_DIFFUSE (1<<MAT_ATTRIB_BACK_DIFFUSE)
377 #define MAT_BIT_FRONT_SPECULAR (1<<MAT_ATTRIB_FRONT_SPECULAR)
378 #define MAT_BIT_BACK_SPECULAR (1<<MAT_ATTRIB_BACK_SPECULAR)
379 #define MAT_BIT_FRONT_EMISSION (1<<MAT_ATTRIB_FRONT_EMISSION)
380 #define MAT_BIT_BACK_EMISSION (1<<MAT_ATTRIB_BACK_EMISSION)
381 #define MAT_BIT_FRONT_SHININESS (1<<MAT_ATTRIB_FRONT_SHININESS)
382 #define MAT_BIT_BACK_SHININESS (1<<MAT_ATTRIB_BACK_SHININESS)
383 #define MAT_BIT_FRONT_INDEXES (1<<MAT_ATTRIB_FRONT_INDEXES)
384 #define MAT_BIT_BACK_INDEXES (1<<MAT_ATTRIB_BACK_INDEXES)
387 #define FRONT_MATERIAL_BITS (MAT_BIT_FRONT_EMISSION | \
388 MAT_BIT_FRONT_AMBIENT | \
389 MAT_BIT_FRONT_DIFFUSE | \
390 MAT_BIT_FRONT_SPECULAR | \
391 MAT_BIT_FRONT_SHININESS | \
392 MAT_BIT_FRONT_INDEXES)
394 #define BACK_MATERIAL_BITS (MAT_BIT_BACK_EMISSION | \
395 MAT_BIT_BACK_AMBIENT | \
396 MAT_BIT_BACK_DIFFUSE | \
397 MAT_BIT_BACK_SPECULAR | \
398 MAT_BIT_BACK_SHININESS | \
399 MAT_BIT_BACK_INDEXES)
401 #define ALL_MATERIAL_BITS (FRONT_MATERIAL_BITS | BACK_MATERIAL_BITS)
405 #define EXP_TABLE_SIZE 512 /**< Specular exponent lookup table sizes */
406 #define SHINE_TABLE_SIZE 256 /**< Material shininess lookup table sizes */
409 * Material shininess lookup table.
413 struct gl_shine_tab
*next
, *prev
;
414 GLfloat tab
[SHINE_TABLE_SIZE
+1];
421 * Light source state.
425 struct gl_light
*next
; /**< double linked list with sentinel */
426 struct gl_light
*prev
;
428 GLfloat Ambient
[4]; /**< ambient color */
429 GLfloat Diffuse
[4]; /**< diffuse color */
430 GLfloat Specular
[4]; /**< specular color */
431 GLfloat EyePosition
[4]; /**< position in eye coordinates */
432 GLfloat EyeDirection
[4]; /**< spotlight dir in eye coordinates */
433 GLfloat SpotExponent
;
434 GLfloat SpotCutoff
; /**< in degrees */
435 GLfloat _CosCutoff
; /**< = MAX(0, cos(SpotCutoff)) */
436 GLfloat ConstantAttenuation
;
437 GLfloat LinearAttenuation
;
438 GLfloat QuadraticAttenuation
;
439 GLboolean Enabled
; /**< On/off flag */
442 * \name Derived fields
445 GLbitfield _Flags
; /**< State */
447 GLfloat _Position
[4]; /**< position in eye/obj coordinates */
448 GLfloat _VP_inf_norm
[3]; /**< Norm direction to infinite light */
449 GLfloat _h_inf_norm
[3]; /**< Norm( _VP_inf_norm + <0,0,1> ) */
450 GLfloat _NormDirection
[4]; /**< normalized spotlight direction */
451 GLfloat _VP_inf_spot_attenuation
;
453 GLfloat _SpotExpTable
[EXP_TABLE_SIZE
][2]; /**< to replace a pow() call */
454 GLfloat _MatAmbient
[2][3]; /**< material ambient * light ambient */
455 GLfloat _MatDiffuse
[2][3]; /**< material diffuse * light diffuse */
456 GLfloat _MatSpecular
[2][3]; /**< material spec * light specular */
457 GLfloat _dli
; /**< CI diffuse light intensity */
458 GLfloat _sli
; /**< CI specular light intensity */
468 GLfloat Ambient
[4]; /**< ambient color */
469 GLboolean LocalViewer
; /**< Local (or infinite) view point? */
470 GLboolean TwoSide
; /**< Two (or one) sided lighting? */
471 GLenum ColorControl
; /**< either GL_SINGLE_COLOR
472 * or GL_SEPARATE_SPECULAR_COLOR */
481 GLfloat Attrib
[MAT_ATTRIB_MAX
][4];
486 * Accumulation buffer attribute group (GL_ACCUM_BUFFER_BIT)
488 struct gl_accum_attrib
490 GLfloat ClearColor
[4]; /**< Accumulation buffer clear color */
495 * Color buffer attribute group (GL_COLOR_BUFFER_BIT).
497 struct gl_colorbuffer_attrib
499 GLuint ClearIndex
; /**< Index to use for glClear */
500 GLclampf ClearColor
[4]; /**< Color to use for glClear */
502 GLuint IndexMask
; /**< Color index write mask */
503 GLubyte ColorMask
[4]; /**< Each flag is 0xff or 0x0 */
505 GLenum DrawBuffer
[MAX_DRAW_BUFFERS
]; /**< Which buffer to draw into */
508 * \name alpha testing
511 GLboolean AlphaEnabled
; /**< Alpha test enabled flag */
512 GLenum AlphaFunc
; /**< Alpha test function */
513 GLclampf AlphaRef
; /**< Alpha reference value */
520 GLboolean BlendEnabled
; /**< Blending enabled flag */
521 GLenum BlendSrcRGB
; /**< Blending source operator */
522 GLenum BlendDstRGB
; /**< Blending destination operator */
523 GLenum BlendSrcA
; /**< GL_INGR_blend_func_separate */
524 GLenum BlendDstA
; /**< GL_INGR_blend_func_separate */
525 GLenum BlendEquationRGB
; /**< Blending equation */
526 GLenum BlendEquationA
; /**< GL_EXT_blend_equation_separate */
527 GLfloat BlendColor
[4]; /**< Blending color */
534 GLenum LogicOp
; /**< Logic operator */
535 GLboolean IndexLogicOpEnabled
; /**< Color index logic op enabled flag */
536 GLboolean ColorLogicOpEnabled
; /**< RGBA logic op enabled flag */
537 GLboolean _LogicOpEnabled
; /**< RGBA logic op + EXT_blend_logic_op enabled flag */
540 GLboolean DitherFlag
; /**< Dither enable flag */
545 * Current attribute group (GL_CURRENT_BIT).
547 struct gl_current_attrib
550 * \name Values valid only when FLUSH_VERTICES has been called.
553 GLfloat Attrib
[VERT_ATTRIB_MAX
][4]; /**< Current vertex attributes
554 * indexed by VERT_ATTRIB_* */
555 GLfloat Index
; /**< Current color index */
556 GLboolean EdgeFlag
; /**< Current edge flag */
560 * \name Values are always valid.
562 * \note BTW, note how similar this set of attributes is to the SWvertex
563 * data type in the software rasterizer...
566 GLfloat RasterPos
[4]; /**< Current raster position */
567 GLfloat RasterDistance
; /**< Current raster distance */
568 GLfloat RasterColor
[4]; /**< Current raster color */
569 GLfloat RasterSecondaryColor
[4]; /**< Current raster secondary color */
570 GLfloat RasterIndex
; /**< Current raster index */
571 GLfloat RasterTexCoords
[MAX_TEXTURE_UNITS
][4];/**< Current raster texcoords */
572 GLboolean RasterPosValid
; /**< Raster pos valid flag */
578 * Depth buffer attribute group (GL_DEPTH_BUFFER_BIT).
580 struct gl_depthbuffer_attrib
582 GLenum Func
; /**< Function for depth buffer compare */
583 GLclampd Clear
; /**< Value to clear depth buffer to */
584 GLboolean Test
; /**< Depth buffering enabled flag */
585 GLboolean Mask
; /**< Depth buffer writable? */
586 GLboolean BoundsTest
; /**< GL_EXT_depth_bounds_test */
587 GLfloat BoundsMin
, BoundsMax
;/**< GL_EXT_depth_bounds_test */
592 * glEnable()/glDisable() attribute group (GL_ENABLE_BIT).
594 struct gl_enable_attrib
597 GLboolean AutoNormal
;
599 GLbitfield ClipPlanes
;
600 GLboolean ColorMaterial
;
601 GLboolean ColorTable
; /* SGI_color_table */
602 GLboolean PostColorMatrixColorTable
; /* SGI_color_table */
603 GLboolean PostConvolutionColorTable
; /* SGI_color_table */
604 GLboolean Convolution1D
;
605 GLboolean Convolution2D
;
606 GLboolean Separable2D
;
612 GLboolean Light
[MAX_LIGHTS
];
614 GLboolean LineSmooth
;
615 GLboolean LineStipple
;
616 GLboolean IndexLogicOp
;
617 GLboolean ColorLogicOp
;
618 GLboolean Map1Color4
;
620 GLboolean Map1Normal
;
621 GLboolean Map1TextureCoord1
;
622 GLboolean Map1TextureCoord2
;
623 GLboolean Map1TextureCoord3
;
624 GLboolean Map1TextureCoord4
;
625 GLboolean Map1Vertex3
;
626 GLboolean Map1Vertex4
;
627 GLboolean Map1Attrib
[16]; /* GL_NV_vertex_program */
628 GLboolean Map2Color4
;
630 GLboolean Map2Normal
;
631 GLboolean Map2TextureCoord1
;
632 GLboolean Map2TextureCoord2
;
633 GLboolean Map2TextureCoord3
;
634 GLboolean Map2TextureCoord4
;
635 GLboolean Map2Vertex3
;
636 GLboolean Map2Vertex4
;
637 GLboolean Map2Attrib
[16]; /* GL_NV_vertex_program */
640 GLboolean PixelTexture
;
641 GLboolean PointSmooth
;
642 GLboolean PolygonOffsetPoint
;
643 GLboolean PolygonOffsetLine
;
644 GLboolean PolygonOffsetFill
;
645 GLboolean PolygonSmooth
;
646 GLboolean PolygonStipple
;
647 GLboolean RescaleNormals
;
650 GLboolean StencilTwoSide
; /* GL_EXT_stencil_two_side */
651 GLboolean MultisampleEnabled
; /* GL_ARB_multisample */
652 GLboolean SampleAlphaToCoverage
; /* GL_ARB_multisample */
653 GLboolean SampleAlphaToOne
; /* GL_ARB_multisample */
654 GLboolean SampleCoverage
; /* GL_ARB_multisample */
655 GLboolean SampleCoverageInvert
; /* GL_ARB_multisample */
656 GLboolean RasterPositionUnclipped
; /* GL_IBM_rasterpos_clip */
657 GLuint Texture
[MAX_TEXTURE_IMAGE_UNITS
];
658 GLuint TexGen
[MAX_TEXTURE_COORD_UNITS
];
659 /* SGI_texture_color_table */
660 GLboolean TextureColorTable
[MAX_TEXTURE_IMAGE_UNITS
];
661 /* GL_NV_vertex_program */
662 GLboolean VertexProgram
;
663 GLboolean VertexProgramPointSize
;
664 GLboolean VertexProgramTwoSide
;
665 /* GL_ARB_point_sprite / GL_NV_point_sprite */
666 GLboolean PointSprite
;
667 GLboolean FragmentShaderATI
;
672 * Evaluator attribute group (GL_EVAL_BIT).
674 struct gl_eval_attrib
680 GLboolean Map1Color4
;
682 GLboolean Map1Normal
;
683 GLboolean Map1TextureCoord1
;
684 GLboolean Map1TextureCoord2
;
685 GLboolean Map1TextureCoord3
;
686 GLboolean Map1TextureCoord4
;
687 GLboolean Map1Vertex3
;
688 GLboolean Map1Vertex4
;
689 GLboolean Map1Attrib
[16]; /* GL_NV_vertex_program */
690 GLboolean Map2Color4
;
692 GLboolean Map2Normal
;
693 GLboolean Map2TextureCoord1
;
694 GLboolean Map2TextureCoord2
;
695 GLboolean Map2TextureCoord3
;
696 GLboolean Map2TextureCoord4
;
697 GLboolean Map2Vertex3
;
698 GLboolean Map2Vertex4
;
699 GLboolean Map2Attrib
[16]; /* GL_NV_vertex_program */
700 GLboolean AutoNormal
;
704 * \name Map Grid endpoints and divisions and calculated du values
708 GLfloat MapGrid1u1
, MapGrid1u2
, MapGrid1du
;
709 GLint MapGrid2un
, MapGrid2vn
;
710 GLfloat MapGrid2u1
, MapGrid2u2
, MapGrid2du
;
711 GLfloat MapGrid2v1
, MapGrid2v2
, MapGrid2dv
;
717 * Fog attribute group (GL_FOG_BIT).
721 GLboolean Enabled
; /**< Fog enabled flag */
722 GLfloat Color
[4]; /**< Fog color */
723 GLfloat Density
; /**< Density >= 0.0 */
724 GLfloat Start
; /**< Start distance in eye coords */
725 GLfloat End
; /**< End distance in eye coords */
726 GLfloat Index
; /**< Fog index */
727 GLenum Mode
; /**< Fog mode */
728 GLboolean ColorSumEnabled
;
729 GLenum FogCoordinateSource
; /**< GL_EXT_fog_coord */
734 * Hint attribute group (GL_HINT_BIT).
736 * Values are always one of GL_FASTEST, GL_NICEST, or GL_DONT_CARE.
738 struct gl_hint_attrib
740 GLenum PerspectiveCorrection
;
743 GLenum PolygonSmooth
;
745 GLenum ClipVolumeClipping
; /**< GL_EXT_clip_volume_hint */
746 GLenum TextureCompression
; /**< GL_ARB_texture_compression */
747 GLenum GenerateMipmap
; /**< GL_SGIS_generate_mipmap */
748 GLenum FragmentShaderDerivative
; /**< GL_ARB_fragment_shader */
753 * Histogram attributes.
755 struct gl_histogram_attrib
757 GLuint Width
; /**< number of table entries */
758 GLint Format
; /**< GL_ALPHA, GL_RGB, etc */
759 GLuint Count
[HISTOGRAM_TABLE_SIZE
][4]; /**< the histogram */
760 GLboolean Sink
; /**< terminate image transfer? */
761 GLubyte RedSize
; /**< Bits per counter */
765 GLubyte LuminanceSize
;
770 * Color Min/max state.
772 struct gl_minmax_attrib
776 GLfloat Min
[4], Max
[4]; /**< RGBA */
781 * Image convolution state.
783 struct gl_convolution_attrib
786 GLenum InternalFormat
;
789 GLfloat Filter
[MAX_CONVOLUTION_WIDTH
* MAX_CONVOLUTION_HEIGHT
* 4];
797 #define LIGHT_SPOT 0x1
798 #define LIGHT_LOCAL_VIEWER 0x2
799 #define LIGHT_POSITIONAL 0x4
800 #define LIGHT_NEED_VERTICES (LIGHT_POSITIONAL|LIGHT_LOCAL_VIEWER)
805 * Lighting attribute group (GL_LIGHT_BIT).
807 struct gl_light_attrib
809 struct gl_light Light
[MAX_LIGHTS
]; /**< Array of light sources */
810 struct gl_lightmodel Model
; /**< Lighting model */
813 * Must flush FLUSH_VERTICES before referencing:
816 struct gl_material Material
; /**< Includes front & back values */
819 GLboolean Enabled
; /**< Lighting enabled flag */
820 GLenum ShadeModel
; /**< GL_FLAT or GL_SMOOTH */
821 GLenum ColorMaterialFace
; /**< GL_FRONT, BACK or FRONT_AND_BACK */
822 GLenum ColorMaterialMode
; /**< GL_AMBIENT, GL_DIFFUSE, etc */
823 GLbitfield ColorMaterialBitmask
; /**< bitmask formed from Face and Mode */
824 GLboolean ColorMaterialEnabled
;
826 struct gl_light EnabledList
; /**< List sentinel */
829 * Derived state for optimizations:
832 GLboolean _NeedEyeCoords
;
833 GLboolean _NeedVertices
; /**< Use fast shader? */
834 GLbitfield _Flags
; /**< LIGHT_* flags, see above */
835 GLfloat _BaseColor
[2][3];
841 * Line attribute group (GL_LINE_BIT).
843 struct gl_line_attrib
845 GLboolean SmoothFlag
; /**< GL_LINE_SMOOTH enabled? */
846 GLboolean StippleFlag
; /**< GL_LINE_STIPPLE enabled? */
847 GLushort StipplePattern
; /**< Stipple pattern */
848 GLint StippleFactor
; /**< Stipple repeat factor */
849 GLfloat Width
; /**< Line width */
850 GLfloat _Width
; /**< Clamped Line width */
855 * Display list attribute group (GL_LIST_BIT).
857 struct gl_list_attrib
864 * Used by device drivers to hook new commands into display lists.
866 struct gl_list_instruction
869 void (*Execute
)( GLcontext
*ctx
, void *data
);
870 void (*Destroy
)( GLcontext
*ctx
, void *data
);
871 void (*Print
)( GLcontext
*ctx
, void *data
);
874 #define MAX_DLIST_EXT_OPCODES 16
877 * Used by device drivers to hook new commands into display lists.
879 struct gl_list_extensions
881 struct gl_list_instruction Opcode
[MAX_DLIST_EXT_OPCODES
];
887 * Multisample attribute group (GL_MULTISAMPLE_BIT).
889 struct gl_multisample_attrib
892 GLboolean SampleAlphaToCoverage
;
893 GLboolean SampleAlphaToOne
;
894 GLboolean SampleCoverage
;
895 GLfloat SampleCoverageValue
;
896 GLboolean SampleCoverageInvert
;
901 * Pixel attribute group (GL_PIXEL_MODE_BIT).
903 struct gl_pixel_attrib
905 GLenum ReadBuffer
; /**< source buffer for glRead/CopyPixels() */
906 GLfloat RedBias
, RedScale
;
907 GLfloat GreenBias
, GreenScale
;
908 GLfloat BlueBias
, BlueScale
;
909 GLfloat AlphaBias
, AlphaScale
;
910 GLfloat DepthBias
, DepthScale
;
911 GLint IndexShift
, IndexOffset
;
912 GLboolean MapColorFlag
;
913 GLboolean MapStencilFlag
;
914 GLfloat ZoomX
, ZoomY
;
915 /* XXX move these out of gl_pixel_attrib */
916 GLint MapStoSsize
; /**< Size of each pixel map */
926 GLint MapStoS
[MAX_PIXEL_MAP_TABLE
]; /**< Pixel map tables */
927 GLfloat MapItoI
[MAX_PIXEL_MAP_TABLE
];
928 GLfloat MapItoR
[MAX_PIXEL_MAP_TABLE
];
929 GLfloat MapItoG
[MAX_PIXEL_MAP_TABLE
];
930 GLfloat MapItoB
[MAX_PIXEL_MAP_TABLE
];
931 GLfloat MapItoA
[MAX_PIXEL_MAP_TABLE
];
932 GLubyte MapItoR8
[MAX_PIXEL_MAP_TABLE
]; /**< converted to 8-bit color */
933 GLubyte MapItoG8
[MAX_PIXEL_MAP_TABLE
];
934 GLubyte MapItoB8
[MAX_PIXEL_MAP_TABLE
];
935 GLubyte MapItoA8
[MAX_PIXEL_MAP_TABLE
];
936 GLfloat MapRtoR
[MAX_PIXEL_MAP_TABLE
];
937 GLfloat MapGtoG
[MAX_PIXEL_MAP_TABLE
];
938 GLfloat MapBtoB
[MAX_PIXEL_MAP_TABLE
];
939 GLfloat MapAtoA
[MAX_PIXEL_MAP_TABLE
];
940 /** GL_EXT_histogram */
941 GLboolean HistogramEnabled
;
942 GLboolean MinMaxEnabled
;
943 /** GL_SGIS_pixel_texture */
944 GLboolean PixelTextureEnabled
;
945 GLenum FragmentRgbSource
;
946 GLenum FragmentAlphaSource
;
947 /** GL_SGI_color_matrix */
948 GLfloat PostColorMatrixScale
[4]; /**< RGBA */
949 GLfloat PostColorMatrixBias
[4]; /**< RGBA */
950 /** GL_SGI_color_table */
951 GLfloat ColorTableScale
[4];
952 GLfloat ColorTableBias
[4];
953 GLboolean ColorTableEnabled
;
954 GLfloat PCCTscale
[4];
956 GLboolean PostConvolutionColorTableEnabled
;
957 GLfloat PCMCTscale
[4];
958 GLfloat PCMCTbias
[4];
959 GLboolean PostColorMatrixColorTableEnabled
;
960 /** GL_SGI_texture_color_table */
961 GLfloat TextureColorTableScale
[4];
962 GLfloat TextureColorTableBias
[4];
964 GLboolean Convolution1DEnabled
;
965 GLboolean Convolution2DEnabled
;
966 GLboolean Separable2DEnabled
;
967 GLfloat ConvolutionBorderColor
[3][4];
968 GLenum ConvolutionBorderMode
[3];
969 GLfloat ConvolutionFilterScale
[3][4];
970 GLfloat ConvolutionFilterBias
[3][4];
971 GLfloat PostConvolutionScale
[4]; /**< RGBA */
972 GLfloat PostConvolutionBias
[4]; /**< RGBA */
977 * Point attribute group (GL_POINT_BIT).
979 struct gl_point_attrib
981 GLboolean SmoothFlag
; /**< True if GL_POINT_SMOOTH is enabled */
982 GLfloat Size
; /**< User-specified point size */
983 GLfloat _Size
; /**< Size clamped to Const.Min/MaxPointSize */
984 GLfloat Params
[3]; /**< GL_EXT_point_parameters */
985 GLfloat MinSize
, MaxSize
; /**< GL_EXT_point_parameters */
986 GLfloat Threshold
; /**< GL_EXT_point_parameters */
987 GLboolean _Attenuated
; /**< True if Params != [1, 0, 0] */
988 GLboolean PointSprite
; /**< GL_NV_point_sprite / GL_NV_point_sprite */
989 GLboolean CoordReplace
[MAX_TEXTURE_UNITS
]; /**< GL_NV/ARB_point_sprite */
990 GLenum SpriteRMode
; /**< GL_NV_point_sprite (only!) */
991 GLenum SpriteOrigin
; /**< GL_ARB_point_sprite */
996 * Polygon attribute group (GL_POLYGON_BIT).
998 struct gl_polygon_attrib
1000 GLenum FrontFace
; /**< Either GL_CW or GL_CCW */
1001 GLenum FrontMode
; /**< Either GL_POINT, GL_LINE or GL_FILL */
1002 GLenum BackMode
; /**< Either GL_POINT, GL_LINE or GL_FILL */
1003 GLboolean _FrontBit
; /**< 0=GL_CCW, 1=GL_CW */
1004 GLboolean CullFlag
; /**< Culling on/off flag */
1005 GLboolean SmoothFlag
; /**< True if GL_POLYGON_SMOOTH is enabled */
1006 GLboolean StippleFlag
; /**< True if GL_POLYGON_STIPPLE is enabled */
1007 GLenum CullFaceMode
; /**< Culling mode GL_FRONT or GL_BACK */
1008 GLfloat OffsetFactor
; /**< Polygon offset factor, from user */
1009 GLfloat OffsetUnits
; /**< Polygon offset units, from user */
1010 GLboolean OffsetPoint
; /**< Offset in GL_POINT mode */
1011 GLboolean OffsetLine
; /**< Offset in GL_LINE mode */
1012 GLboolean OffsetFill
; /**< Offset in GL_FILL mode */
1017 * Scissor attributes (GL_SCISSOR_BIT).
1019 struct gl_scissor_attrib
1021 GLboolean Enabled
; /**< Scissor test enabled? */
1022 GLint X
, Y
; /**< Lower left corner of box */
1023 GLsizei Width
, Height
; /**< Size of box */
1028 * Stencil attribute group (GL_STENCIL_BUFFER_BIT).
1030 struct gl_stencil_attrib
1032 GLboolean Enabled
; /**< Enabled flag */
1033 GLboolean TestTwoSide
; /**< GL_EXT_stencil_two_side */
1034 GLubyte ActiveFace
; /**< GL_EXT_stencil_two_side (0 or 1) */
1035 GLboolean _TestTwoSide
;
1036 GLenum Function
[2]; /**< Stencil function */
1037 GLenum FailFunc
[2]; /**< Fail function */
1038 GLenum ZPassFunc
[2]; /**< Depth buffer pass function */
1039 GLenum ZFailFunc
[2]; /**< Depth buffer fail function */
1040 GLint Ref
[2]; /**< Reference value */
1041 GLuint ValueMask
[2]; /**< Value mask */
1042 GLuint WriteMask
[2]; /**< Write mask */
1043 GLuint Clear
; /**< Clear value */
1047 #define NUM_TEXTURE_TARGETS 5 /* 1D, 2D, 3D, CUBE and RECT */
1050 * An index for each type of texture object
1053 #define TEXTURE_1D_INDEX 0
1054 #define TEXTURE_2D_INDEX 1
1055 #define TEXTURE_3D_INDEX 2
1056 #define TEXTURE_CUBE_INDEX 3
1057 #define TEXTURE_RECT_INDEX 4
1061 * Bit flags for each type of texture object
1062 * Used for Texture.Unit[]._ReallyEnabled flags.
1065 #define TEXTURE_1D_BIT (1 << TEXTURE_1D_INDEX)
1066 #define TEXTURE_2D_BIT (1 << TEXTURE_2D_INDEX)
1067 #define TEXTURE_3D_BIT (1 << TEXTURE_3D_INDEX)
1068 #define TEXTURE_CUBE_BIT (1 << TEXTURE_CUBE_INDEX)
1069 #define TEXTURE_RECT_BIT (1 << TEXTURE_RECT_INDEX)
1074 * TexGenEnabled flags.
1085 * Bit flag versions of the corresponding GL_ constants.
1088 #define TEXGEN_SPHERE_MAP 0x1
1089 #define TEXGEN_OBJ_LINEAR 0x2
1090 #define TEXGEN_EYE_LINEAR 0x4
1091 #define TEXGEN_REFLECTION_MAP_NV 0x8
1092 #define TEXGEN_NORMAL_MAP_NV 0x10
1094 #define TEXGEN_NEED_NORMALS (TEXGEN_SPHERE_MAP | \
1095 TEXGEN_REFLECTION_MAP_NV | \
1096 TEXGEN_NORMAL_MAP_NV)
1097 #define TEXGEN_NEED_EYE_COORD (TEXGEN_SPHERE_MAP | \
1098 TEXGEN_REFLECTION_MAP_NV | \
1099 TEXGEN_NORMAL_MAP_NV | \
1104 /* A selection of state flags to make driver and module's lives easier. */
1105 #define ENABLE_TEXGEN0 0x1
1106 #define ENABLE_TEXGEN1 0x2
1107 #define ENABLE_TEXGEN2 0x4
1108 #define ENABLE_TEXGEN3 0x8
1109 #define ENABLE_TEXGEN4 0x10
1110 #define ENABLE_TEXGEN5 0x20
1111 #define ENABLE_TEXGEN6 0x40
1112 #define ENABLE_TEXGEN7 0x80
1114 #define ENABLE_TEXMAT0 0x1 /* Ie. not the identity matrix */
1115 #define ENABLE_TEXMAT1 0x2
1116 #define ENABLE_TEXMAT2 0x4
1117 #define ENABLE_TEXMAT3 0x8
1118 #define ENABLE_TEXMAT4 0x10
1119 #define ENABLE_TEXMAT5 0x20
1120 #define ENABLE_TEXMAT6 0x40
1121 #define ENABLE_TEXMAT7 0x80
1123 #define ENABLE_TEXGEN(i) (ENABLE_TEXGEN0 << (i))
1124 #define ENABLE_TEXMAT(i) (ENABLE_TEXMAT0 << (i))
1128 * Texel fetch function prototype. We use texel fetch functions to
1129 * extract RGBA, color indexes and depth components out of 1D, 2D and 3D
1130 * texture images. These functions help to isolate us from the gritty
1131 * details of all the various texture image encodings.
1133 * \param texImage texture image.
1134 * \param col texel column.
1135 * \param row texel row.
1136 * \param img texel image level/layer.
1137 * \param texelOut output texel (up to 4 GLchans)
1139 typedef void (*FetchTexelFuncC
)( const struct gl_texture_image
*texImage
,
1140 GLint col
, GLint row
, GLint img
,
1144 * As above, but returns floats.
1145 * Used for depth component images and for upcoming signed/float
1148 typedef void (*FetchTexelFuncF
)( const struct gl_texture_image
*texImage
,
1149 GLint col
, GLint row
, GLint img
,
1150 GLfloat
*texelOut
);
1153 typedef void (*StoreTexelFunc
)(struct gl_texture_image
*texImage
,
1154 GLint col
, GLint row
, GLint img
,
1158 * TexImage store function. This is called by the glTex[Sub]Image
1159 * functions and is responsible for converting the user-specified texture
1160 * image into a specific (hardware) image format.
1162 typedef GLboolean (*StoreTexImageFunc
)(GLcontext
*ctx
, GLuint dims
,
1163 GLenum baseInternalFormat
,
1164 const struct gl_texture_format
*dstFormat
,
1166 GLint dstXoffset
, GLint dstYoffset
, GLint dstZoffset
,
1167 GLint dstRowStride
, GLint dstImageStride
,
1168 GLint srcWidth
, GLint srcHeight
, GLint srcDepth
,
1169 GLenum srcFormat
, GLenum srcType
,
1170 const GLvoid
*srcAddr
,
1171 const struct gl_pixelstore_attrib
*srcPacking
);
1176 * Texture format record
1178 struct gl_texture_format
1180 GLint MesaFormat
; /**< One of the MESA_FORMAT_* values */
1182 GLenum BaseFormat
; /**< Either GL_RGB, GL_RGBA, GL_ALPHA,
1183 * GL_LUMINANCE, GL_LUMINANCE_ALPHA,
1184 * GL_INTENSITY, GL_COLOR_INDEX or
1185 * GL_DEPTH_COMPONENT.
1187 GLenum DataType
; /**< GL_FLOAT or GL_UNSIGNED_NORMALIZED_ARB */
1188 GLubyte RedBits
; /**< Bits per texel component */
1189 GLubyte GreenBits
; /**< These are just rough approximations for */
1190 GLubyte BlueBits
; /**< compressed texture formats. */
1192 GLubyte LuminanceBits
;
1193 GLubyte IntensityBits
;
1197 GLuint TexelBytes
; /**< Bytes per texel, 0 if compressed format */
1199 StoreTexImageFunc StoreImage
;
1202 * \name Texel fetch function pointers
1205 FetchTexelFuncC FetchTexel1D
;
1206 FetchTexelFuncC FetchTexel2D
;
1207 FetchTexelFuncC FetchTexel3D
;
1208 FetchTexelFuncF FetchTexel1Df
;
1209 FetchTexelFuncF FetchTexel2Df
;
1210 FetchTexelFuncF FetchTexel3Df
;
1213 StoreTexelFunc StoreTexel
;
1218 * Texture image state. Describes the dimensions of a texture image,
1219 * the texel format and pointers to Texel Fetch functions.
1221 struct gl_texture_image
1223 GLenum Format
; /**< Either GL_RGB, GL_RGBA, GL_ALPHA,
1224 * GL_LUMINANCE, GL_LUMINANCE_ALPHA,
1225 * GL_INTENSITY, GL_COLOR_INDEX or
1226 * GL_DEPTH_COMPONENT only.
1227 * Used for choosing TexEnv arithmetic.
1229 GLint IntFormat
; /**< Internal format as given by the user */
1230 GLuint Border
; /**< 0 or 1 */
1231 GLuint Width
; /**< = 2^WidthLog2 + 2*Border */
1232 GLuint Height
; /**< = 2^HeightLog2 + 2*Border */
1233 GLuint Depth
; /**< = 2^DepthLog2 + 2*Border */
1234 GLuint RowStride
; /**< == Width unless IsClientData and padded */
1235 GLuint Width2
; /**< = Width - 2*Border */
1236 GLuint Height2
; /**< = Height - 2*Border */
1237 GLuint Depth2
; /**< = Depth - 2*Border */
1238 GLuint WidthLog2
; /**< = log2(Width2) */
1239 GLuint HeightLog2
; /**< = log2(Height2) */
1240 GLuint DepthLog2
; /**< = log2(Depth2) */
1241 GLuint MaxLog2
; /**< = MAX(WidthLog2, HeightLog2) */
1242 GLfloat WidthScale
; /**< used for mipmap LOD computation */
1243 GLfloat HeightScale
; /**< used for mipmap LOD computation */
1244 GLfloat DepthScale
; /**< used for mipmap LOD computation */
1245 GLvoid
*Data
; /**< Image data, accessed via FetchTexel() */
1246 GLboolean IsClientData
; /**< Data owned by client? */
1247 GLboolean _IsPowerOfTwo
; /**< Are all dimensions powers of two? */
1249 const struct gl_texture_format
*TexFormat
;
1251 struct gl_texture_object
*TexObject
; /**< Pointer back to parent object */
1253 FetchTexelFuncC FetchTexelc
; /**< GLchan texel fetch function pointer */
1254 FetchTexelFuncF FetchTexelf
; /**< Float texel fetch function pointer */
1256 GLboolean IsCompressed
; /**< GL_ARB_texture_compression */
1257 GLuint CompressedSize
; /**< GL_ARB_texture_compression */
1260 * \name For device driver:
1263 void *DriverData
; /**< Arbitrary device driver data */
1269 * Indexes for cube map faces.
1272 #define FACE_POS_X 0
1273 #define FACE_NEG_X 1
1274 #define FACE_POS_Y 2
1275 #define FACE_NEG_Y 3
1276 #define FACE_POS_Z 4
1277 #define FACE_NEG_Z 5
1283 * Texture object state. Contains the array of mipmap images, border color,
1284 * wrap modes, filter modes, shadow/texcompare state, and the per-texture
1287 struct gl_texture_object
1289 _glthread_Mutex Mutex
; /**< for thread safety */
1290 GLint RefCount
; /**< reference count */
1291 GLuint Name
; /**< the user-visible texture object ID */
1292 GLenum Target
; /**< GL_TEXTURE_1D, GL_TEXTURE_2D, etc. */
1293 GLfloat Priority
; /**< in [0,1] */
1294 GLfloat BorderColor
[4]; /**< unclamped */
1295 GLchan _BorderChan
[4]; /**< clamped, as GLchan */
1296 GLenum WrapS
; /**< S-axis texture image wrap mode */
1297 GLenum WrapT
; /**< T-axis texture image wrap mode */
1298 GLenum WrapR
; /**< R-axis texture image wrap mode */
1299 GLenum MinFilter
; /**< minification filter */
1300 GLenum MagFilter
; /**< magnification filter */
1301 GLfloat MinLod
; /**< min lambda, OpenGL 1.2 */
1302 GLfloat MaxLod
; /**< max lambda, OpenGL 1.2 */
1303 GLfloat LodBias
; /**< OpenGL 1.4 */
1304 GLint BaseLevel
; /**< min mipmap level, OpenGL 1.2 */
1305 GLint MaxLevel
; /**< max mipmap level, OpenGL 1.2 */
1306 GLfloat MaxAnisotropy
; /**< GL_EXT_texture_filter_anisotropic */
1307 GLboolean CompareFlag
; /**< GL_SGIX_shadow */
1308 GLenum CompareOperator
; /**< GL_SGIX_shadow */
1309 GLfloat ShadowAmbient
; /**< GL_ARB_shadow_ambient */
1310 GLenum CompareMode
; /**< GL_ARB_shadow */
1311 GLenum CompareFunc
; /**< GL_ARB_shadow */
1312 GLenum DepthMode
; /**< GL_ARB_depth_texture */
1313 GLint _MaxLevel
; /**< actual max mipmap level (q in the spec) */
1314 GLfloat _MaxLambda
; /**< = _MaxLevel - BaseLevel (q - b in spec) */
1315 GLboolean GenerateMipmap
; /**< GL_SGIS_generate_mipmap */
1316 GLboolean _IsPowerOfTwo
; /**< Are all image dimensions powers of two? */
1317 GLboolean Complete
; /**< Is texture object complete? */
1319 /** Actual texture images, indexed by [cube face] and [mipmap level] */
1320 struct gl_texture_image
*Image
[MAX_FACES
][MAX_TEXTURE_LEVELS
];
1322 /** GL_EXT_paletted_texture */
1323 struct gl_color_table Palette
;
1327 * \name For device driver.
1328 * Note: instead of attaching driver data to this pointer, it's preferable
1329 * to instead use this struct as a base class for your own texture object
1330 * class. Driver->NewTextureObject() can be used to implement the
1333 void *DriverData
; /**< Arbitrary device driver data */
1338 * Texture combine environment state.
1341 * If GL_NV_texture_env_combine4 is ever supported, the arrays in this
1342 * structure will need to be expanded for 4 elements.
1344 struct gl_tex_env_combine_state
1346 GLenum ModeRGB
; /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */
1347 GLenum ModeA
; /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */
1348 GLenum SourceRGB
[3]; /**< GL_PRIMARY_COLOR, GL_TEXTURE, etc. */
1349 GLenum SourceA
[3]; /**< GL_PRIMARY_COLOR, GL_TEXTURE, etc. */
1350 GLenum OperandRGB
[3]; /**< SRC_COLOR, ONE_MINUS_SRC_COLOR, etc */
1351 GLenum OperandA
[3]; /**< SRC_ALPHA, ONE_MINUS_SRC_ALPHA, etc */
1352 GLuint ScaleShiftRGB
; /**< 0, 1 or 2 */
1353 GLuint ScaleShiftA
; /**< 0, 1 or 2 */
1354 GLuint _NumArgsRGB
; /**< Number of inputs used for the combine mode. */
1355 GLuint _NumArgsA
; /**< Number of inputs used for the combine mode. */
1360 * Texture unit state. Contains enable flags, texture environment/function/
1361 * combiners, texgen state, pointers to current texture objects and
1362 * post-filter color tables.
1364 struct gl_texture_unit
1366 GLbitfield Enabled
; /**< bitmask of TEXTURE_*_BIT flags */
1367 GLbitfield _ReallyEnabled
; /**< 0 or exactly one of TEXTURE_*_BIT flags */
1369 GLenum EnvMode
; /**< GL_MODULATE, GL_DECAL, GL_BLEND, etc. */
1370 GLfloat EnvColor
[4];
1371 GLbitfield TexGenEnabled
; /**< Bitwise-OR of [STRQ]_BIT values */
1372 /** \name Tex coord generation mode
1373 * Either GL_OBJECT_LINEAR, GL_EYE_LINEAR or GL_SPHERE_MAP. */
1380 GLbitfield _GenBitS
;
1381 GLbitfield _GenBitT
;
1382 GLbitfield _GenBitR
;
1383 GLbitfield _GenBitQ
;
1384 GLbitfield _GenFlags
; /**< bitwise or of GenBit[STRQ] */
1385 GLfloat ObjectPlaneS
[4];
1386 GLfloat ObjectPlaneT
[4];
1387 GLfloat ObjectPlaneR
[4];
1388 GLfloat ObjectPlaneQ
[4];
1389 GLfloat EyePlaneS
[4];
1390 GLfloat EyePlaneT
[4];
1391 GLfloat EyePlaneR
[4];
1392 GLfloat EyePlaneQ
[4];
1393 GLfloat LodBias
; /**< for biasing mipmap levels */
1396 * \name GL_EXT_texture_env_combine
1398 struct gl_tex_env_combine_state Combine
;
1401 * Derived state based on \c EnvMode and the \c BaseFormat of the
1402 * currently enabled texture.
1404 struct gl_tex_env_combine_state _EnvMode
;
1407 * Currently enabled combiner state. This will point to either
1408 * \c Combine or \c _EnvMode.
1410 struct gl_tex_env_combine_state
*_CurrentCombine
;
1412 struct gl_texture_object
*Current1D
;
1413 struct gl_texture_object
*Current2D
;
1414 struct gl_texture_object
*Current3D
;
1415 struct gl_texture_object
*CurrentCubeMap
; /**< GL_ARB_texture_cube_map */
1416 struct gl_texture_object
*CurrentRect
; /**< GL_NV_texture_rectangle */
1418 struct gl_texture_object
*_Current
; /**< Points to really enabled tex obj */
1420 struct gl_texture_object Saved1D
; /**< only used by glPush/PopAttrib */
1421 struct gl_texture_object Saved2D
;
1422 struct gl_texture_object Saved3D
;
1423 struct gl_texture_object SavedCubeMap
;
1424 struct gl_texture_object SavedRect
;
1426 /* GL_SGI_texture_color_table */
1427 struct gl_color_table ColorTable
;
1428 struct gl_color_table ProxyColorTable
;
1429 GLboolean ColorTableEnabled
;
1432 struct texenvprog_cache
{
1436 struct texenvprog_cache
*next
;
1440 * Texture attribute group (GL_TEXTURE_BIT).
1442 struct gl_texture_attrib
1448 GLuint CurrentUnit
; /**< Active texture unit */
1449 GLbitfield _EnabledUnits
; /**< one bit set for each really-enabled unit */
1450 GLbitfield _EnabledCoordUnits
; /**< one bit per enabled coordinate unit */
1451 GLbitfield _GenFlags
; /**< for texgen */
1452 GLbitfield _TexGenEnabled
;
1453 GLbitfield _TexMatEnabled
;
1456 struct gl_texture_unit Unit
[MAX_TEXTURE_UNITS
];
1458 struct gl_texture_object
*Proxy1D
;
1459 struct gl_texture_object
*Proxy2D
;
1460 struct gl_texture_object
*Proxy3D
;
1461 struct gl_texture_object
*ProxyCubeMap
;
1462 struct gl_texture_object
*ProxyRect
;
1464 /** GL_EXT_shared_texture_palette */
1465 GLboolean SharedPalette
;
1466 struct gl_color_table Palette
;
1468 /** Cached texenv fragment programs */
1469 struct texenvprog_cache
*env_fp_cache
;
1474 * Transformation attribute group (GL_TRANSFORM_BIT).
1476 struct gl_transform_attrib
1478 GLenum MatrixMode
; /**< Matrix mode */
1479 GLfloat EyeUserPlane
[MAX_CLIP_PLANES
][4]; /**< User clip planes */
1480 GLfloat _ClipUserPlane
[MAX_CLIP_PLANES
][4]; /**< derived */
1481 GLbitfield ClipPlanesEnabled
; /**< on/off bitmask */
1482 GLboolean Normalize
; /**< Normalize all normals? */
1483 GLboolean RescaleNormals
; /**< GL_EXT_rescale_normal */
1484 GLboolean RasterPositionUnclipped
; /**< GL_IBM_rasterpos_clip */
1486 GLboolean CullVertexFlag
; /**< True if GL_CULL_VERTEX_EXT is enabled */
1487 GLfloat CullEyePos
[4];
1488 GLfloat CullObjPos
[4];
1493 * Viewport attribute group (GL_VIEWPORT_BIT).
1495 struct gl_viewport_attrib
1497 GLint X
, Y
; /**< position */
1498 GLsizei Width
, Height
; /**< size */
1499 GLfloat Near
, Far
; /**< Depth buffer range */
1500 GLmatrix _WindowMap
; /**< Mapping transformation as a matrix. */
1505 * Node for the attribute stack.
1507 struct gl_attrib_node
1511 struct gl_attrib_node
*next
;
1516 * GL_ARB_vertex/pixel_buffer_object buffer object
1518 struct gl_buffer_object
1524 GLvoid
*Pointer
; /**< Only valid while buffer is mapped */
1525 GLsizeiptrARB Size
; /**< Size of storage in bytes */
1526 GLubyte
*Data
; /**< Location of storage either in RAM or VRAM. */
1527 GLboolean OnCard
; /**< Is buffer in VRAM? (hardware drivers) */
1533 * Client pixel packing/unpacking attributes
1535 struct gl_pixelstore_attrib
1541 GLint ImageHeight
; /**< for GL_EXT_texture3D */
1542 GLint SkipImages
; /**< for GL_EXT_texture3D */
1543 GLboolean SwapBytes
;
1545 GLboolean ClientStorage
; /**< GL_APPLE_client_storage */
1546 GLboolean Invert
; /**< GL_MESA_pack_invert */
1547 struct gl_buffer_object
*BufferObj
; /**< GL_ARB_pixel_buffer_object */
1551 #define CA_CLIENT_DATA 0x1 /**< Data not allocated by mesa */
1555 * Client vertex array attributes
1557 struct gl_client_array
1559 GLint Size
; /**< components per element (1,2,3,4) */
1560 GLenum Type
; /**< datatype: GL_FLOAT, GL_INT, etc */
1561 GLsizei Stride
; /**< user-specified stride */
1562 GLsizei StrideB
; /**< actual stride in bytes */
1563 const GLubyte
*Ptr
; /**< Points to array data */
1564 GLbitfield Enabled
; /**< one of the _NEW_ARRAY_ bits */
1565 GLboolean Normalized
; /**< GL_ARB_vertex_program */
1567 /**< GL_ARB_vertex_buffer_object */
1568 struct gl_buffer_object
*BufferObj
;
1576 * Vertex array state
1578 struct gl_array_attrib
1580 struct gl_client_array Vertex
; /**< client data descriptors */
1581 struct gl_client_array Normal
;
1582 struct gl_client_array Color
;
1583 struct gl_client_array SecondaryColor
;
1584 struct gl_client_array FogCoord
;
1585 struct gl_client_array Index
;
1586 struct gl_client_array TexCoord
[MAX_TEXTURE_COORD_UNITS
];
1587 struct gl_client_array EdgeFlag
;
1589 struct gl_client_array VertexAttrib
[VERT_ATTRIB_MAX
]; /**< GL_NV_vertex_program */
1591 GLint ActiveTexture
; /**< Client Active Texture */
1592 GLuint LockFirst
; /**< GL_EXT_compiled_vertex_array */
1593 GLuint LockCount
; /**< GL_EXT_compiled_vertex_array */
1595 GLbitfield _Enabled
; /**< _NEW_ARRAY_* - bit set if array enabled */
1596 GLbitfield NewState
; /**< _NEW_ARRAY_* */
1598 #if FEATURE_ARB_vertex_buffer_object
1599 struct gl_buffer_object
*NullBufferObj
;
1600 struct gl_buffer_object
*ArrayBufferObj
;
1601 struct gl_buffer_object
*ElementArrayBufferObj
;
1603 GLuint _MaxElement
; /* Min of all enabled array's maxes */
1608 * Feedback buffer state
1613 GLbitfield _Mask
; /* FB_* bits */
1621 * Selection buffer state
1625 GLuint
*Buffer
; /**< selection buffer */
1626 GLuint BufferSize
; /**< size of the selection buffer */
1627 GLuint BufferCount
; /**< number of values in the selection buffer */
1628 GLuint Hits
; /**< number of records in the selection buffer */
1629 GLuint NameStackDepth
; /**< name stack depth */
1630 GLuint NameStack
[MAX_NAME_STACK_DEPTH
]; /**< name stack */
1631 GLboolean HitFlag
; /**< hit flag */
1632 GLfloat HitMinZ
; /**< minimum hit depth */
1633 GLfloat HitMaxZ
; /**< maximum hit depth */
1638 * 1-D Evaluator control points
1642 GLuint Order
; /**< Number of control points */
1643 GLfloat u1
, u2
, du
; /**< u1, u2, 1.0/(u2-u1) */
1644 GLfloat
*Points
; /**< Points to contiguous control points */
1649 * 2-D Evaluator control points
1653 GLuint Uorder
; /**< Number of control points in U dimension */
1654 GLuint Vorder
; /**< Number of control points in V dimension */
1657 GLfloat
*Points
; /**< Points to contiguous control points */
1662 * All evaluator control point state
1664 struct gl_evaluators
1670 struct gl_1d_map Map1Vertex3
;
1671 struct gl_1d_map Map1Vertex4
;
1672 struct gl_1d_map Map1Index
;
1673 struct gl_1d_map Map1Color4
;
1674 struct gl_1d_map Map1Normal
;
1675 struct gl_1d_map Map1Texture1
;
1676 struct gl_1d_map Map1Texture2
;
1677 struct gl_1d_map Map1Texture3
;
1678 struct gl_1d_map Map1Texture4
;
1679 struct gl_1d_map Map1Attrib
[16]; /**< GL_NV_vertex_program */
1686 struct gl_2d_map Map2Vertex3
;
1687 struct gl_2d_map Map2Vertex4
;
1688 struct gl_2d_map Map2Index
;
1689 struct gl_2d_map Map2Color4
;
1690 struct gl_2d_map Map2Normal
;
1691 struct gl_2d_map Map2Texture1
;
1692 struct gl_2d_map Map2Texture2
;
1693 struct gl_2d_map Map2Texture3
;
1694 struct gl_2d_map Map2Texture4
;
1695 struct gl_2d_map Map2Attrib
[16]; /**< GL_NV_vertex_program */
1701 * NV_fragment_program runtime state
1705 GLfloat Temporaries
[MAX_NV_FRAGMENT_PROGRAM_TEMPS
][4];
1706 GLfloat Inputs
[MAX_NV_FRAGMENT_PROGRAM_INPUTS
][4];
1707 GLfloat Outputs
[MAX_NV_FRAGMENT_PROGRAM_OUTPUTS
][4];
1708 GLuint CondCodes
[4];
1712 * ATI_fragment_shader runtime state
1714 #define ATI_FS_INPUT_PRIMARY 0
1715 #define ATI_FS_INPUT_SECONDARY 1
1717 /* 6 register sets - 2 inputs (primary, secondary) */
1718 struct atifs_machine
1720 GLfloat Registers
[6][4];
1721 GLfloat PrevPassRegisters
[6][4];
1722 GLfloat Inputs
[2][4];
1728 * Names of the various vertex/fragment register files
1735 PROGRAM_LOCAL_PARAM
,
1737 PROGRAM_NAMED_PARAM
,
1741 PROGRAM_UNDEFINED
/* invalid value */
1745 /** Vertex and fragment instructions */
1746 struct vp_instruction
;
1747 struct fp_instruction
;
1748 struct atifs_instruction
;
1749 struct atifs_setupinst
;
1750 struct program_parameter_list
;
1754 * Base class for any kind of program object
1759 GLubyte
*String
; /**< Null-terminated program text */
1762 GLenum Format
; /**< String encoding format */
1764 GLfloat LocalParams
[MAX_PROGRAM_LOCAL_PARAMS
][4];
1765 GLuint NumInstructions
; /* GL_ARB_vertex/fragment_program */
1766 GLuint NumTemporaries
;
1767 GLuint NumParameters
;
1768 GLuint NumAttributes
;
1769 GLuint NumAddressRegs
;
1773 /** Vertex program object */
1774 struct vertex_program
1776 struct program Base
; /* base class */
1777 struct vp_instruction
*Instructions
; /* Compiled instructions */
1778 GLboolean IsNVProgram
; /* GL_NV_vertex_program ? */
1779 GLboolean IsPositionInvariant
; /* GL_NV_vertex_program1_1 */
1780 GLbitfield InputsRead
; /* Bitmask of which input regs are read */
1781 GLbitfield OutputsWritten
; /* Bitmask of which output regs are written to */
1782 struct program_parameter_list
*Parameters
; /**< array [NumParameters] */
1783 void *TnlData
; /* should probably use Base.DriverData */
1787 /** Fragment program object */
1788 struct fragment_program
1790 struct program Base
; /**< base class */
1791 struct fp_instruction
*Instructions
; /**< Compiled instructions */
1792 GLbitfield InputsRead
; /**< Bitmask of which input regs are read */
1793 GLbitfield OutputsWritten
; /**< Bitmask of which output regs are written to */
1794 GLbitfield TexturesUsed
[MAX_TEXTURE_IMAGE_UNITS
]; /**< TEXTURE_x_INDEX bitmask */
1795 GLuint NumAluInstructions
; /**< GL_ARB_fragment_program */
1796 GLuint NumTexInstructions
;
1797 GLuint NumTexIndirections
;
1799 struct program_parameter_list
*Parameters
; /**< array [NumParameters] */
1802 char c_str
[4096]; /* experimental... */
1807 struct ati_fragment_shader
1809 struct program Base
;
1810 struct atifs_instruction
*Instructions
[2];
1811 struct atifs_setupinst
*SetupInst
[2];
1812 GLfloat Constants
[8][4];
1813 GLuint localConstDef
;
1814 GLubyte numArithInstr
[2];
1815 GLubyte regsAssigned
[2];
1818 GLubyte last_optype
;
1819 GLboolean interpinp1
;
1825 * State common to vertex and fragment programs.
1827 struct gl_program_state
1829 GLint ErrorPos
; /* GL_PROGRAM_ERROR_POSITION_NV */
1830 const char *ErrorString
; /* GL_PROGRAM_ERROR_STRING_NV */
1835 * State vars for GL_ARB/GL_NV_vertex_program
1837 struct gl_vertex_program_state
1839 GLboolean Enabled
; /**< GL_VERTEX_PROGRAM_NV */
1840 GLboolean _Enabled
; /**< Really enabled? */
1841 GLboolean PointSizeEnabled
; /**< GL_VERTEX_PROGRAM_POINT_SIZE_NV */
1842 GLboolean TwoSideEnabled
; /**< GL_VERTEX_PROGRAM_TWO_SIDE_NV */
1843 struct vertex_program
*Current
; /**< ptr to currently bound program */
1845 GLenum TrackMatrix
[MAX_NV_VERTEX_PROGRAM_PARAMS
/ 4];
1846 GLenum TrackMatrixTransform
[MAX_NV_VERTEX_PROGRAM_PARAMS
/ 4];
1848 GLfloat Parameters
[MAX_NV_VERTEX_PROGRAM_PARAMS
][4]; /* Env params */
1849 /* Only used during program execution (may be moved someday): */
1850 GLfloat Temporaries
[MAX_NV_VERTEX_PROGRAM_TEMPS
][4];
1851 GLfloat Inputs
[MAX_NV_VERTEX_PROGRAM_INPUTS
][4];
1852 GLuint InputsSize
[MAX_NV_VERTEX_PROGRAM_INPUTS
];
1853 GLfloat Outputs
[MAX_NV_VERTEX_PROGRAM_OUTPUTS
][4];
1854 GLint AddressReg
[4];
1856 #if FEATURE_MESA_program_debug
1857 GLprogramcallbackMESA Callback
;
1858 GLvoid
*CallbackData
;
1859 GLboolean CallbackEnabled
;
1860 GLuint CurrentPosition
;
1866 * State for GL_ARB/NV_fragment_program
1868 struct gl_fragment_program_state
1870 GLboolean Enabled
; /* GL_VERTEX_PROGRAM_NV */
1871 GLboolean _Enabled
; /* Really enabled? */
1872 GLboolean _Active
; /* Really really enabled? */
1873 struct fragment_program
*Current
; /* ptr to currently bound program */
1874 struct fragment_program
*_Current
; /* ptr to currently active program */
1875 struct fp_machine Machine
; /* machine state */
1876 GLfloat Parameters
[MAX_NV_FRAGMENT_PROGRAM_PARAMS
][4]; /* Env params */
1878 #if FEATURE_MESA_program_debug
1879 GLprogramcallbackMESA Callback
;
1880 GLvoid
*CallbackData
;
1881 GLboolean CallbackEnabled
;
1882 GLuint CurrentPosition
;
1888 * State for GL_ATI_fragment_shader
1890 struct gl_ati_fragment_shader_state
1894 GLboolean Compiling
;
1895 GLfloat globalConstants
[8][4];
1896 struct atifs_machine Machine
; /* machine state */
1897 struct ati_fragment_shader
*Current
;
1901 struct gl_query_object
1904 GLuint Result
; /* the counter */
1905 GLboolean Active
; /* inside Begin/EndQuery */
1906 GLboolean Ready
; /* result is ready */
1910 struct gl_query_state
1912 struct _mesa_HashTable
*QueryObjects
;
1913 struct gl_query_object
*CurrentOcclusionObject
; /* GL_ARB_occlusion_query */
1914 struct gl_query_object
*CurrentTimerObject
; /* GL_EXT_timer_query */
1919 * gl2 unique interface identifier.
1920 * Each gl2 interface has its own interface id used for object queries.
1924 UIID_UNKNOWN
, /* supported by all objects */
1925 UIID_GENERIC
, /* generic object */
1926 UIID_CONTAINER
, /* contains generic objects */
1927 UIID_SHADER
, /* shader object */
1928 UIID_FRAGMENT_SHADER
, /* fragment shader */
1929 UIID_VERTEX_SHADER
, /* vertex shader */
1930 UIID_PROGRAM
, /* program object */
1931 UIID_3DLABS_SHHANDLE
/* encapsulates 3dlabs' ShHandle */
1934 struct gl2_unknown_intf
1936 GLvoid (* AddRef
) (struct gl2_unknown_intf
**);
1937 GLvoid (* Release
) (struct gl2_unknown_intf
**);
1938 struct gl2_unknown_intf
**(* QueryInterface
) (struct gl2_unknown_intf
**, enum gl2_uiid uiid
);
1941 struct gl2_generic_intf
1943 struct gl2_unknown_intf _unknown
;
1944 GLvoid (* Delete
) (struct gl2_generic_intf
**);
1945 GLenum (* GetType
) (struct gl2_generic_intf
**);
1946 GLhandleARB (* GetName
) (struct gl2_generic_intf
**);
1947 GLboolean (* GetDeleteStatus
) (struct gl2_generic_intf
**);
1948 const GLcharARB
*(* GetInfoLog
) (struct gl2_generic_intf
**);
1951 struct gl2_container_intf
1953 struct gl2_generic_intf _generic
;
1954 GLboolean (* Attach
) (struct gl2_container_intf
**, struct gl2_generic_intf
**);
1955 GLboolean (* Detach
) (struct gl2_container_intf
**, struct gl2_generic_intf
**);
1956 GLsizei (* GetAttachedCount
) (struct gl2_container_intf
**);
1957 struct gl2_generic_intf
**(* GetAttached
) (struct gl2_container_intf
**, GLuint
);
1960 struct gl2_shader_intf
1962 struct gl2_generic_intf _generic
;
1963 GLenum (* GetSubType
) (struct gl2_shader_intf
**);
1964 GLboolean (* GetCompileStatus
) (struct gl2_shader_intf
**);
1965 GLvoid (* SetSource
) (struct gl2_shader_intf
**, GLcharARB
*, GLint
*, GLsizei
);
1966 const GLcharARB
*(* GetSource
) (struct gl2_shader_intf
**);
1967 GLvoid (* Compile
) (struct gl2_shader_intf
**);
1970 struct gl2_program_intf
1972 struct gl2_container_intf _container
;
1973 GLboolean (* GetLinkStatus
) (struct gl2_program_intf
**);
1974 GLboolean (* GetValidateStatus
) (struct gl2_program_intf
**);
1975 GLvoid (* Link
) (struct gl2_program_intf
**);
1976 GLvoid (* Validate
) (struct gl2_program_intf
**);
1979 struct gl2_fragment_shader_intf
1981 struct gl2_shader_intf _shader
;
1984 struct gl2_vertex_shader_intf
1986 struct gl2_shader_intf _shader
;
1989 struct gl2_3dlabs_shhandle_intf
1991 struct gl2_unknown_intf _unknown
;
1992 GLvoid
*(* GetShHandle
) (struct gl2_3dlabs_shhandle_intf
**);
1995 struct gl_shader_objects_state
1997 struct gl2_program_intf
**current_program
;
2002 * State which can be shared by multiple contexts:
2004 struct gl_shared_state
2006 _glthread_Mutex Mutex
; /**< for thread safety */
2007 GLint RefCount
; /**< Reference count */
2008 struct _mesa_HashTable
*DisplayList
; /**< Display lists hash table */
2009 struct _mesa_HashTable
*TexObjects
; /**< Texture objects hash table */
2012 * \name Default texture objects (shared by all multi-texture units)
2015 struct gl_texture_object
*Default1D
;
2016 struct gl_texture_object
*Default2D
;
2017 struct gl_texture_object
*Default3D
;
2018 struct gl_texture_object
*DefaultCubeMap
;
2019 struct gl_texture_object
*DefaultRect
;
2023 * \name Vertex/fragment programs
2026 struct _mesa_HashTable
*Programs
;
2027 #if FEATURE_ARB_vertex_program
2028 struct program
*DefaultVertexProgram
;
2030 #if FEATURE_ARB_fragment_program
2031 struct program
*DefaultFragmentProgram
;
2033 #if FEATURE_ATI_fragment_shader
2034 struct program
*DefaultFragmentShader
;
2038 #if FEATURE_ARB_vertex_buffer_object || FEATURE_ARB_pixel_buffer_object
2039 struct _mesa_HashTable
*BufferObjects
;
2042 struct _mesa_HashTable
*GL2Objects
;
2044 #if FEATURE_EXT_framebuffer_object
2045 struct _mesa_HashTable
*RenderBuffers
;
2046 struct _mesa_HashTable
*FrameBuffers
;
2049 void *DriverData
; /**< Device driver shared state */
2056 * A renderbuffer stores colors or depth values or stencil values.
2057 * A framebuffer object will have a collection of these.
2058 * Data are read/written to the buffer with a handful of Get/Put functions.
2060 * Instances of this object are allocated with the Driver's NewRenderbuffer
2061 * hook. Drivers will likely wrap this class inside a driver-specific
2062 * class to simulate inheritance.
2064 struct gl_renderbuffer
2068 GLuint Width
, Height
;
2069 GLenum InternalFormat
; /* The user-specified value */
2070 GLenum _BaseFormat
; /* Either GL_RGB, GL_RGBA, GL_DEPTH_COMPONENT or */
2071 /* GL_STENCIL_INDEX. */
2072 GLenum DataType
; /* Type of values passed to the Get/Put functions */
2073 GLubyte ComponentSizes
[4]; /* bits per component or channel */
2076 /* Delete this renderbuffer */
2077 void (*Delete
)(struct gl_renderbuffer
*rb
);
2079 /* Allocate new storage for this renderbuffer */
2080 GLboolean (*AllocStorage
)(GLcontext
*ctx
, struct gl_renderbuffer
*rb
,
2081 GLenum internalFormat
,
2082 GLuint width
, GLuint height
);
2084 /* Lock/Unlock are called before/after calling the Get/Put functions.
2085 * Not sure this is the right place for these yet.
2086 void (*Lock)(GLcontext *ctx, struct gl_renderbuffer *rb);
2087 void (*Unlock)(GLcontext *ctx, struct gl_renderbuffer *rb);
2090 /* Return a pointer to the element/pixel at (x,y).
2091 * Should return NULL if the buffer memory can't be directly addressed.
2093 void *(*GetPointer
)(GLcontext
*ctx
, struct gl_renderbuffer
*rb
,
2096 /* Get/Read a row of values.
2097 * The values will be of format _BaseFormat and type DataType.
2099 void (*GetRow
)(GLcontext
*ctx
, struct gl_renderbuffer
*rb
, GLuint count
,
2100 GLint x
, GLint y
, void *values
);
2102 /* Get/Read values at arbitrary locations.
2103 * The values will be of format _BaseFormat and type DataType.
2105 void (*GetValues
)(GLcontext
*ctx
, struct gl_renderbuffer
*rb
, GLuint count
,
2106 const GLint x
[], const GLint y
[], void *values
);
2108 /* Put/Write a row of values.
2109 * The values will be of format _BaseFormat and type DataType.
2111 void (*PutRow
)(GLcontext
*ctx
, struct gl_renderbuffer
*rb
, GLuint count
,
2112 GLint x
, GLint y
, const void *values
, const GLubyte
*mask
);
2114 /* Put/Write a row of RGB values. This is a special-case routine that's
2115 * only used for RGBA renderbuffers when the source data is GL_RGB. That's
2116 * a common case for glDrawPixels and some triangle routines.
2117 * The values will be of format GL_RGB and type DataType.
2119 void (*PutRowRGB
)(GLcontext
*ctx
, struct gl_renderbuffer
*rb
, GLuint count
,
2120 GLint x
, GLint y
, const void *values
, const GLubyte
*mask
);
2123 /* Put/Write a row of identical values.
2124 * The values will be of format _BaseFormat and type DataType.
2126 void (*PutMonoRow
)(GLcontext
*ctx
, struct gl_renderbuffer
*rb
, GLuint count
,
2127 GLint x
, GLint y
, const void *value
, const GLubyte
*mask
);
2129 /* Put/Write values at arbitrary locations.
2130 * The values will be of format _BaseFormat and type DataType.
2132 void (*PutValues
)(GLcontext
*ctx
, struct gl_renderbuffer
*rb
, GLuint count
,
2133 const GLint x
[], const GLint y
[], const void *values
,
2134 const GLubyte
*mask
);
2135 /* Put/Write identical values at arbitrary locations.
2136 * The values will be of format _BaseFormat and type DataType.
2138 void (*PutMonoValues
)(GLcontext
*ctx
, struct gl_renderbuffer
*rb
,
2139 GLuint count
, const GLint x
[], const GLint y
[],
2140 const void *value
, const GLubyte
*mask
);
2145 * A renderbuffer attachment point points to either a texture object
2146 * (and specifies a mipmap level, cube face or 3D texture slice) or
2147 * points to a renderbuffer.
2149 struct gl_renderbuffer_attachment
2151 GLenum Type
; /* GL_NONE or GL_TEXTURE or GL_RENDERBUFFER_EXT */
2154 /* IF Type == GL_RENDERBUFFER_EXT: */
2155 struct gl_renderbuffer
*Renderbuffer
;
2157 /* IF Type == GL_TEXTURE: */
2158 struct gl_texture_object
*Texture
;
2159 GLuint TextureLevel
;
2160 GLuint CubeMapFace
; /* 0 .. 5, for cube map textures */
2161 GLuint Zoffset
; /* for 3D textures */
2166 * A framebuffer is a collection of renderbuffers (color, depth, stencil, etc).
2167 * In C++ terms, think of this as a base class from which device drivers
2168 * will make derived classes.
2170 struct gl_framebuffer
2172 GLuint Name
; /* if zero, this is a window system framebuffer */
2175 GLvisual Visual
; /**< The corresponding visual */
2177 GLboolean Initialized
;
2179 GLuint Width
, Height
; /**< size of frame buffer in pixels */
2181 /** \name Drawing bounds (Intersection of buffer size and scissor box) */
2183 GLint _Xmin
, _Xmax
; /**< inclusive */
2184 GLint _Ymin
, _Ymax
; /**< exclusive */
2187 /** \name Derived Z buffer stuff */
2189 GLuint _DepthMax
; /**< Max depth buffer value */
2190 GLfloat _DepthMaxF
; /**< Float max depth buffer value */
2191 GLfloat _MRD
; /**< minimum resolvable difference in Z values */
2194 GLenum _Status
; /* One of the GL_FRAMEBUFFER_(IN)COMPLETE_* tokens */
2196 /* Array of all renderbuffer attachments, indexed by BUFFER_* tokens. */
2197 struct gl_renderbuffer_attachment Attachment
[BUFFER_COUNT
];
2199 /* In unextended OpenGL these vars are part of the GL_COLOR_BUFFER
2200 * attribute group and GL_PIXEL attribute group, respectively.
2202 GLenum ColorDrawBuffer
[MAX_DRAW_BUFFERS
];
2203 GLenum ColorReadBuffer
;
2205 /* These are computed from ColorDrawBuffer and ColorReadBuffer */
2206 GLbitfield _ColorDrawBufferMask
[MAX_DRAW_BUFFERS
]; /* Mask of BUFFER_BIT_* flags */
2207 GLbitfield _ColorReadBufferMask
; /* Zero or one of BUFFER_BIT_ flags */
2209 /* These are computed from _Draw/ReadBufferMask, above. */
2210 GLuint _NumColorDrawBuffers
[MAX_DRAW_BUFFERS
];
2211 struct gl_renderbuffer
*_ColorDrawBuffers
[MAX_DRAW_BUFFERS
][4];
2212 struct gl_renderbuffer
*_ColorReadBuffer
;
2214 /** Delete this framebuffer */
2215 void (*Delete
)(struct gl_framebuffer
*fb
);
2220 * Constants which may be overridden by device driver during context creation
2221 * but are never changed after that.
2225 GLint MaxTextureLevels
; /**< Maximum number of allowed mipmap levels. */
2226 GLint Max3DTextureLevels
; /**< Maximum number of allowed mipmap levels for 3D texture targets. */
2227 GLint MaxCubeTextureLevels
; /**< Maximum number of allowed mipmap levels for GL_ARB_texture_cube_map */
2228 GLint MaxTextureRectSize
; /* GL_NV_texture_rectangle */
2229 GLuint MaxTextureCoordUnits
;
2230 GLuint MaxTextureImageUnits
;
2231 GLuint MaxTextureUnits
; /* = MAX(CoordUnits, ImageUnits) */
2232 GLfloat MaxTextureMaxAnisotropy
; /* GL_EXT_texture_filter_anisotropic */
2233 GLfloat MaxTextureLodBias
; /* GL_EXT_texture_lod_bias */
2234 GLuint MaxArrayLockSize
;
2236 GLfloat MinPointSize
, MaxPointSize
; /* aliased */
2237 GLfloat MinPointSizeAA
, MaxPointSizeAA
; /* antialiased */
2238 GLfloat PointSizeGranularity
;
2239 GLfloat MinLineWidth
, MaxLineWidth
; /* aliased */
2240 GLfloat MinLineWidthAA
, MaxLineWidthAA
; /* antialiased */
2241 GLfloat LineWidthGranularity
;
2242 GLuint MaxColorTableSize
;
2243 GLuint MaxConvolutionWidth
;
2244 GLuint MaxConvolutionHeight
;
2245 GLuint MaxClipPlanes
;
2247 GLfloat MaxShininess
; /* GL_NV_light_max_exponent */
2248 GLfloat MaxSpotExponent
; /* GL_NV_light_max_exponent */
2249 GLuint MaxViewportWidth
, MaxViewportHeight
;
2250 /* GL_ARB_vertex_program */
2251 GLuint MaxVertexProgramInstructions
;
2252 GLuint MaxVertexProgramAttribs
;
2253 GLuint MaxVertexProgramTemps
;
2254 GLuint MaxVertexProgramLocalParams
;
2255 GLuint MaxVertexProgramEnvParams
;
2256 GLuint MaxVertexProgramAddressRegs
;
2257 /* GL_ARB_fragment_program */
2258 GLuint MaxFragmentProgramInstructions
;
2259 GLuint MaxFragmentProgramAttribs
;
2260 GLuint MaxFragmentProgramTemps
;
2261 GLuint MaxFragmentProgramLocalParams
;
2262 GLuint MaxFragmentProgramEnvParams
;
2263 GLuint MaxFragmentProgramAddressRegs
;
2264 GLuint MaxFragmentProgramAluInstructions
;
2265 GLuint MaxFragmentProgramTexInstructions
;
2266 GLuint MaxFragmentProgramTexIndirections
;
2267 /* vertex or fragment program */
2268 GLuint MaxProgramMatrices
;
2269 GLuint MaxProgramMatrixStackDepth
;
2270 /* vertex array / buffer object bounds checking */
2271 GLboolean CheckArrayBounds
;
2272 /* GL_ARB_draw_buffers */
2273 GLuint MaxDrawBuffers
;
2274 /* GL_OES_read_format */
2275 GLenum ColorReadFormat
;
2276 GLenum ColorReadType
;
2277 /* GL_EXT_framebuffer_object */
2278 GLuint MaxColorAttachments
;
2279 GLuint MaxRenderbufferSize
;
2284 * Enable flag for each OpenGL extension. Different device drivers will
2285 * enable different extensions at runtime.
2287 struct gl_extensions
2290 * \name Flags to quickly test if certain extensions are available.
2292 * Not every extension needs to have such a flag, but it's encouraged.
2295 GLboolean dummy
; /* don't remove this! */
2296 GLboolean ARB_depth_texture
;
2297 GLboolean ARB_draw_buffers
;
2298 GLboolean ARB_fragment_program
;
2299 GLboolean ARB_fragment_shader
;
2300 GLboolean ARB_half_float_pixel
;
2301 GLboolean ARB_imaging
;
2302 GLboolean ARB_multisample
;
2303 GLboolean ARB_multitexture
;
2304 GLboolean ARB_occlusion_query
;
2305 GLboolean ARB_point_sprite
;
2306 GLboolean ARB_shader_objects
;
2307 GLboolean ARB_shading_language_100
;
2308 GLboolean ARB_shadow
;
2309 GLboolean ARB_texture_border_clamp
;
2310 GLboolean ARB_texture_compression
;
2311 GLboolean ARB_texture_cube_map
;
2312 GLboolean ARB_texture_env_combine
;
2313 GLboolean ARB_texture_env_crossbar
;
2314 GLboolean ARB_texture_env_dot3
;
2315 GLboolean ARB_texture_float
;
2316 GLboolean ARB_texture_mirrored_repeat
;
2317 GLboolean ARB_texture_non_power_of_two
;
2318 GLboolean ARB_transpose_matrix
;
2319 GLboolean ARB_vertex_buffer_object
;
2320 GLboolean ARB_vertex_program
;
2321 GLboolean ARB_vertex_shader
;
2322 GLboolean ARB_window_pos
;
2325 GLboolean EXT_blend_color
;
2326 GLboolean EXT_blend_equation_separate
;
2327 GLboolean EXT_blend_func_separate
;
2328 GLboolean EXT_blend_logic_op
;
2329 GLboolean EXT_blend_minmax
;
2330 GLboolean EXT_blend_subtract
;
2331 GLboolean EXT_clip_volume_hint
;
2332 GLboolean EXT_cull_vertex
;
2333 GLboolean EXT_convolution
;
2334 GLboolean EXT_compiled_vertex_array
;
2335 GLboolean EXT_copy_texture
;
2336 GLboolean EXT_depth_bounds_test
;
2337 GLboolean EXT_draw_range_elements
;
2338 GLboolean EXT_framebuffer_object
;
2339 GLboolean EXT_fog_coord
;
2340 GLboolean EXT_histogram
;
2341 GLboolean EXT_multi_draw_arrays
;
2342 GLboolean EXT_paletted_texture
;
2343 GLboolean EXT_packed_pixels
;
2344 GLboolean EXT_pixel_buffer_object
;
2345 GLboolean EXT_point_parameters
;
2346 GLboolean EXT_polygon_offset
;
2347 GLboolean EXT_rescale_normal
;
2348 GLboolean EXT_shadow_funcs
;
2349 GLboolean EXT_secondary_color
;
2350 GLboolean EXT_separate_specular_color
;
2351 GLboolean EXT_shared_texture_palette
;
2352 GLboolean EXT_stencil_wrap
;
2353 GLboolean EXT_stencil_two_side
;
2354 GLboolean EXT_subtexture
;
2355 GLboolean EXT_texture
;
2356 GLboolean EXT_texture_object
;
2357 GLboolean EXT_texture3D
;
2358 GLboolean EXT_texture_compression_s3tc
;
2359 GLboolean EXT_texture_env_add
;
2360 GLboolean EXT_texture_env_combine
;
2361 GLboolean EXT_texture_env_dot3
;
2362 GLboolean EXT_texture_filter_anisotropic
;
2363 GLboolean EXT_texture_lod_bias
;
2364 GLboolean EXT_texture_mirror_clamp
;
2365 GLboolean EXT_timer_query
;
2366 GLboolean EXT_vertex_array
;
2367 GLboolean EXT_vertex_array_set
;
2368 /* vendor extensions */
2369 GLboolean APPLE_client_storage
;
2370 GLboolean APPLE_packed_pixels
;
2371 GLboolean ATI_texture_mirror_once
;
2372 GLboolean ATI_texture_env_combine3
;
2373 GLboolean ATI_fragment_shader
;
2374 GLboolean IBM_rasterpos_clip
;
2375 GLboolean IBM_multimode_draw_arrays
;
2376 GLboolean MESA_pack_invert
;
2377 GLboolean MESA_packed_depth_stencil
;
2378 GLboolean MESA_program_debug
;
2379 GLboolean MESA_resize_buffers
;
2380 GLboolean MESA_ycbcr_texture
;
2381 GLboolean NV_blend_square
;
2382 GLboolean NV_fragment_program
;
2383 GLboolean NV_light_max_exponent
;
2384 GLboolean NV_point_sprite
;
2385 GLboolean NV_texgen_reflection
;
2386 GLboolean NV_texture_rectangle
;
2387 GLboolean NV_vertex_program
;
2388 GLboolean NV_vertex_program1_1
;
2389 GLboolean OES_read_format
;
2390 GLboolean SGI_color_matrix
;
2391 GLboolean SGI_color_table
;
2392 GLboolean SGI_texture_color_table
;
2393 GLboolean SGIS_generate_mipmap
;
2394 GLboolean SGIS_pixel_texture
;
2395 GLboolean SGIS_texture_edge_clamp
;
2396 GLboolean SGIS_texture_lod
;
2397 GLboolean SGIX_depth_texture
;
2398 GLboolean SGIX_pixel_texture
;
2399 GLboolean SGIX_shadow
;
2400 GLboolean SGIX_shadow_ambient
; /* or GL_ARB_shadow_ambient */
2401 GLboolean TDFX_texture_compression_FXT1
;
2404 /* The extension string */
2405 const GLubyte
*String
;
2410 * A stack of matrices (projection, modelview, color, texture, etc).
2414 GLmatrix
*Top
; /**< points into Stack */
2415 GLmatrix
*Stack
; /**< array [MaxDepth] of GLmatrix */
2416 GLuint Depth
; /**< 0 <= Depth < MaxDepth */
2417 GLuint MaxDepth
; /**< size of Stack[] array */
2418 GLuint DirtyFlag
; /**< _NEW_MODELVIEW or _NEW_PROJECTION, for example */
2423 * \name Bits for image transfer operations
2425 * \sa __GLcontextRec::ImageTransferState.
2428 #define IMAGE_SCALE_BIAS_BIT 0x1
2429 #define IMAGE_SHIFT_OFFSET_BIT 0x2
2430 #define IMAGE_MAP_COLOR_BIT 0x4
2431 #define IMAGE_COLOR_TABLE_BIT 0x8
2432 #define IMAGE_CONVOLUTION_BIT 0x10
2433 #define IMAGE_POST_CONVOLUTION_SCALE_BIAS 0x20
2434 #define IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT 0x40
2435 #define IMAGE_COLOR_MATRIX_BIT 0x80
2436 #define IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT 0x100
2437 #define IMAGE_HISTOGRAM_BIT 0x200
2438 #define IMAGE_MIN_MAX_BIT 0x400
2439 #define IMAGE_CLAMP_BIT 0x800 /* extra */
2442 /** Pixel Transfer ops up to convolution */
2443 #define IMAGE_PRE_CONVOLUTION_BITS (IMAGE_SCALE_BIAS_BIT | \
2444 IMAGE_SHIFT_OFFSET_BIT | \
2445 IMAGE_MAP_COLOR_BIT | \
2446 IMAGE_COLOR_TABLE_BIT)
2448 /** Pixel transfer ops after convolution */
2449 #define IMAGE_POST_CONVOLUTION_BITS (IMAGE_POST_CONVOLUTION_SCALE_BIAS | \
2450 IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT | \
2451 IMAGE_COLOR_MATRIX_BIT | \
2452 IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT |\
2453 IMAGE_HISTOGRAM_BIT | \
2459 * \name Bits to indicate what state has changed.
2464 #define _NEW_MODELVIEW 0x1 /**< __GLcontextRec::ModelView */
2465 #define _NEW_PROJECTION 0x2 /**< __GLcontextRec::Projection */
2466 #define _NEW_TEXTURE_MATRIX 0x4 /**< __GLcontextRec::TextureMatrix */
2467 #define _NEW_COLOR_MATRIX 0x8 /**< __GLcontextRec::ColorMatrix */
2468 #define _NEW_ACCUM 0x10 /**< __GLcontextRec::Accum */
2469 #define _NEW_COLOR 0x20 /**< __GLcontextRec::Color */
2470 #define _NEW_DEPTH 0x40 /**< __GLcontextRec::Depth */
2471 #define _NEW_EVAL 0x80 /**< __GLcontextRec::Eval, __GLcontextRec::EvalMap */
2472 #define _NEW_FOG 0x100 /**< __GLcontextRec::Fog */
2473 #define _NEW_HINT 0x200 /**< __GLcontextRec::Hint */
2474 #define _NEW_LIGHT 0x400 /**< __GLcontextRec::Light */
2475 #define _NEW_LINE 0x800 /**< __GLcontextRec::Line */
2476 #define _NEW_PIXEL 0x1000 /**< __GLcontextRec::Pixel */
2477 #define _NEW_POINT 0x2000 /**< __GLcontextRec::Point */
2478 #define _NEW_POLYGON 0x4000 /**< __GLcontextRec::Polygon */
2479 #define _NEW_POLYGONSTIPPLE 0x8000 /**< __GLcontextRec::PolygonStipple */
2480 #define _NEW_SCISSOR 0x10000 /**< __GLcontextRec::Scissor */
2481 #define _NEW_STENCIL 0x20000 /**< __GLcontextRec::Stencil */
2482 #define _NEW_TEXTURE 0x40000 /**< __GLcontextRec::Texture */
2483 #define _NEW_TRANSFORM 0x80000 /**< __GLcontextRec::Transform */
2484 #define _NEW_VIEWPORT 0x100000 /**< __GLcontextRec::Viewport */
2485 #define _NEW_PACKUNPACK 0x200000 /**< __GLcontextRec::Pack, __GLcontextRec::Unpack */
2486 #define _NEW_ARRAY 0x400000 /**< __GLcontextRec::Array */
2487 #define _NEW_RENDERMODE 0x800000 /**< __GLcontextRec::RenderMode, __GLcontextRec::Feedback, __GLcontextRec::Select */
2488 #define _NEW_BUFFERS 0x1000000 /**< __GLcontextRec::Visual, __GLcontextRec::DrawBuffer, */
2489 #define _NEW_MULTISAMPLE 0x2000000 /**< __GLcontextRec::Multisample */
2490 #define _NEW_TRACK_MATRIX 0x4000000 /**< __GLcontextRec::VertexProgram */
2491 #define _NEW_PROGRAM 0x8000000 /**< __GLcontextRec::VertexProgram */
2497 * \name Bits to track array state changes
2499 * Also used to summarize array enabled.
2502 #define _NEW_ARRAY_VERTEX VERT_BIT_POS
2503 #define _NEW_ARRAY_WEIGHT VERT_BIT_WEIGHT
2504 #define _NEW_ARRAY_NORMAL VERT_BIT_NORMAL
2505 #define _NEW_ARRAY_COLOR0 VERT_BIT_COLOR0
2506 #define _NEW_ARRAY_COLOR1 VERT_BIT_COLOR1
2507 #define _NEW_ARRAY_FOGCOORD VERT_BIT_FOG
2508 #define _NEW_ARRAY_INDEX VERT_BIT_SIX
2509 #define _NEW_ARRAY_EDGEFLAG VERT_BIT_SEVEN
2510 #define _NEW_ARRAY_TEXCOORD_0 VERT_BIT_TEX0
2511 #define _NEW_ARRAY_TEXCOORD_1 VERT_BIT_TEX1
2512 #define _NEW_ARRAY_TEXCOORD_2 VERT_BIT_TEX2
2513 #define _NEW_ARRAY_TEXCOORD_3 VERT_BIT_TEX3
2514 #define _NEW_ARRAY_TEXCOORD_4 VERT_BIT_TEX4
2515 #define _NEW_ARRAY_TEXCOORD_5 VERT_BIT_TEX5
2516 #define _NEW_ARRAY_TEXCOORD_6 VERT_BIT_TEX6
2517 #define _NEW_ARRAY_TEXCOORD_7 VERT_BIT_TEX7
2518 #define _NEW_ARRAY_ATTRIB_0 0x10000 /* start at bit 16 */
2519 #define _NEW_ARRAY_ALL 0xffffffff
2522 #define _NEW_ARRAY_TEXCOORD(i) (_NEW_ARRAY_TEXCOORD_0 << (i))
2523 #define _NEW_ARRAY_ATTRIB(i) (_NEW_ARRAY_ATTRIB_0 << (i))
2528 * \name A bunch of flags that we think might be useful to drivers.
2530 * Set in the __GLcontextRec::_TriangleCaps bitfield.
2533 #define DD_FLATSHADE 0x1
2534 #define DD_SEPARATE_SPECULAR 0x2
2535 #define DD_TRI_CULL_FRONT_BACK 0x4 /* special case on some hw */
2536 #define DD_TRI_LIGHT_TWOSIDE 0x8
2537 #define DD_TRI_UNFILLED 0x10
2538 #define DD_TRI_SMOOTH 0x20
2539 #define DD_TRI_STIPPLE 0x40
2540 #define DD_TRI_OFFSET 0x80
2541 #define DD_LINE_SMOOTH 0x100
2542 #define DD_LINE_STIPPLE 0x200
2543 #define DD_LINE_WIDTH 0x400
2544 #define DD_POINT_SMOOTH 0x800
2545 #define DD_POINT_SIZE 0x1000
2546 #define DD_POINT_ATTEN 0x2000
2547 #define DD_TRI_TWOSTENCIL 0x4000
2552 * \name Define the state changes under which each of these bits might change
2555 #define _DD_NEW_FLATSHADE _NEW_LIGHT
2556 #define _DD_NEW_SEPARATE_SPECULAR (_NEW_LIGHT | _NEW_FOG | _NEW_PROGRAM)
2557 #define _DD_NEW_TRI_CULL_FRONT_BACK _NEW_POLYGON
2558 #define _DD_NEW_TRI_LIGHT_TWOSIDE _NEW_LIGHT
2559 #define _DD_NEW_TRI_UNFILLED _NEW_POLYGON
2560 #define _DD_NEW_TRI_SMOOTH _NEW_POLYGON
2561 #define _DD_NEW_TRI_STIPPLE _NEW_POLYGON
2562 #define _DD_NEW_TRI_OFFSET _NEW_POLYGON
2563 #define _DD_NEW_LINE_SMOOTH _NEW_LINE
2564 #define _DD_NEW_LINE_STIPPLE _NEW_LINE
2565 #define _DD_NEW_LINE_WIDTH _NEW_LINE
2566 #define _DD_NEW_POINT_SMOOTH _NEW_POINT
2567 #define _DD_NEW_POINT_SIZE _NEW_POINT
2568 #define _DD_NEW_POINT_ATTEN _NEW_POINT
2572 #define _MESA_NEW_NEED_EYE_COORDS (_NEW_LIGHT | \
2577 #define _MESA_NEW_NEED_NORMALS (_NEW_LIGHT | \
2580 #define _IMAGE_NEW_TRANSFER_STATE (_NEW_PIXEL | _NEW_COLOR_MATRIX)
2586 * Forward declaration of display list data types:
2589 typedef union node Node
;
2592 /* This has to be included here. */
2596 #define NUM_VERTEX_FORMAT_ENTRIES (sizeof(GLvertexformat) / sizeof(void *))
2599 * Core Mesa's support for tnl modules:
2601 struct gl_tnl_module
2604 * Vertex format to be lazily swapped into current dispatch.
2606 const GLvertexformat
*Current
;
2609 * \name Record of functions swapped out.
2610 * On restore, only need to swap these functions back in.
2614 _glapi_proc
* location
;
2615 _glapi_proc function
;
2616 } Swapped
[NUM_VERTEX_FORMAT_ENTRIES
];
2621 /* Strictly this is a tnl/ private concept, but it doesn't seem
2622 * worthwhile adding a tnl private structure just to hold this one bit
2625 #define MESA_DLIST_DANGLING_REFS 0x1
2627 /* Provide a location where information about a display list can be
2628 * collected. Could be extended with driverPrivate structures,
2629 * etc. in the future.
2631 struct mesa_display_list
2640 * State used during display list compilation and execution.
2642 struct mesa_list_state
2644 struct mesa_display_list
*CallStack
[MAX_LIST_NESTING
];
2645 GLuint CallDepth
; /**< Current recursion calling depth */
2647 struct mesa_display_list
*CurrentList
;
2648 Node
*CurrentListPtr
; /**< Head of list being compiled */
2649 GLuint CurrentListNum
; /**< Number of the list being compiled */
2650 Node
*CurrentBlock
; /**< Pointer to current block of nodes */
2651 GLuint CurrentPos
; /**< Index into current block of nodes */
2653 GLvertexformat ListVtxfmt
;
2655 GLubyte ActiveAttribSize
[VERT_ATTRIB_MAX
];
2656 GLfloat CurrentAttrib
[VERT_ATTRIB_MAX
][4];
2658 GLubyte ActiveMaterialSize
[MAT_ATTRIB_MAX
];
2659 GLfloat CurrentMaterial
[MAT_ATTRIB_MAX
][4];
2661 GLubyte ActiveIndex
;
2662 GLfloat CurrentIndex
;
2664 GLubyte ActiveEdgeFlag
;
2665 GLboolean CurrentEdgeFlag
;
2670 * Mesa rendering context.
2672 * This is the central context data structure for Mesa. Almost all
2673 * OpenGL state is contained in this structure.
2674 * Think of this as a base class from which device drivers will derive
2677 * The GLcontext typedef names this structure.
2679 struct __GLcontextRec
2682 * \name OS related interfaces.
2684 * These \b must be the first members of this structure, because they are
2685 * exposed to the outside world (i.e. GLX extension).
2688 __GLimports imports
;
2689 __GLexports exports
;
2692 /** State possibly shared with other contexts in the address space */
2693 struct gl_shared_state
*Shared
;
2695 /** \name API function pointer tables */
2697 struct _glapi_table
*Save
; /**< Display list save functions */
2698 struct _glapi_table
*Exec
; /**< Execute functions */
2699 struct _glapi_table
*CurrentDispatch
; /**< == Save or Exec !! */
2703 GLframebuffer
*DrawBuffer
; /**< buffer for writing */
2704 GLframebuffer
*ReadBuffer
; /**< buffer for reading */
2705 GLframebuffer
*WinSysDrawBuffer
; /**< set with MakeCurrent */
2706 GLframebuffer
*WinSysReadBuffer
; /**< set with MakeCurrent */
2709 * Device driver function pointer table
2711 struct dd_function_table Driver
;
2713 void *DriverCtx
; /**< Points to device driver context/state */
2714 void *DriverMgrCtx
; /**< Points to device driver manager (optional)*/
2716 /** Core/Driver constants */
2717 struct gl_constants Const
;
2719 /** \name The various 4x4 matrix stacks */
2721 struct matrix_stack ModelviewMatrixStack
;
2722 struct matrix_stack ProjectionMatrixStack
;
2723 struct matrix_stack ColorMatrixStack
;
2724 struct matrix_stack TextureMatrixStack
[MAX_TEXTURE_COORD_UNITS
];
2725 struct matrix_stack ProgramMatrixStack
[MAX_PROGRAM_MATRICES
];
2726 struct matrix_stack
*CurrentStack
; /**< Points to one of the above stacks */
2729 /** Combined modelview and projection matrix */
2730 GLmatrix _ModelProjectMatrix
;
2732 /** \name Display lists */
2733 struct mesa_list_state ListState
;
2735 GLboolean ExecuteFlag
; /**< Execute GL commands? */
2736 GLboolean CompileFlag
; /**< Compile GL commands into display list? */
2739 struct gl_extensions Extensions
;
2741 /** \name Renderer attribute stack */
2743 GLuint AttribStackDepth
;
2744 struct gl_attrib_node
*AttribStack
[MAX_ATTRIB_STACK_DEPTH
];
2747 /** \name Renderer attribute groups
2749 * We define a struct for each attribute group to make pushing and popping
2750 * attributes easy. Also it's a good organization.
2753 struct gl_accum_attrib Accum
; /**< Accumulation buffer attributes */
2754 struct gl_colorbuffer_attrib Color
; /**< Color buffers attributes */
2755 struct gl_current_attrib Current
; /**< Current attributes */
2756 struct gl_depthbuffer_attrib Depth
; /**< Depth buffer attributes */
2757 struct gl_eval_attrib Eval
; /**< Eval attributes */
2758 struct gl_fog_attrib Fog
; /**< Fog attributes */
2759 struct gl_hint_attrib Hint
; /**< Hint attributes */
2760 struct gl_light_attrib Light
; /**< Light attributes */
2761 struct gl_line_attrib Line
; /**< Line attributes */
2762 struct gl_list_attrib List
; /**< List attributes */
2763 struct gl_multisample_attrib Multisample
;
2764 struct gl_pixel_attrib Pixel
; /**< Pixel attributes */
2765 struct gl_point_attrib Point
; /**< Point attributes */
2766 struct gl_polygon_attrib Polygon
; /**< Polygon attributes */
2767 GLuint PolygonStipple
[32]; /**< Polygon stipple */
2768 struct gl_scissor_attrib Scissor
; /**< Scissor attributes */
2769 struct gl_stencil_attrib Stencil
; /**< Stencil buffer attributes */
2770 struct gl_texture_attrib Texture
; /**< Texture attributes */
2771 struct gl_transform_attrib Transform
; /**< Transformation attributes */
2772 struct gl_viewport_attrib Viewport
; /**< Viewport attributes */
2775 /** \name Client attribute stack */
2777 GLuint ClientAttribStackDepth
;
2778 struct gl_attrib_node
*ClientAttribStack
[MAX_CLIENT_ATTRIB_STACK_DEPTH
];
2781 /** \name Client attribute groups */
2783 struct gl_array_attrib Array
; /**< Vertex arrays */
2784 struct gl_pixelstore_attrib Pack
; /**< Pixel packing */
2785 struct gl_pixelstore_attrib Unpack
; /**< Pixel unpacking */
2786 struct gl_pixelstore_attrib DefaultPacking
; /**< Default params */
2789 /** \name Other assorted state (not pushed/popped on attribute stack) */
2791 struct gl_histogram_attrib Histogram
;
2792 struct gl_minmax_attrib MinMax
;
2793 struct gl_convolution_attrib Convolution1D
;
2794 struct gl_convolution_attrib Convolution2D
;
2795 struct gl_convolution_attrib Separable2D
;
2797 struct gl_evaluators EvalMap
; /**< All evaluators */
2798 struct gl_feedback Feedback
; /**< Feedback */
2799 struct gl_selection Select
; /**< Selection */
2801 struct gl_color_table ColorTable
; /**< Pre-convolution */
2802 struct gl_color_table ProxyColorTable
; /**< Pre-convolution */
2803 struct gl_color_table PostConvolutionColorTable
;
2804 struct gl_color_table ProxyPostConvolutionColorTable
;
2805 struct gl_color_table PostColorMatrixColorTable
;
2806 struct gl_color_table ProxyPostColorMatrixColorTable
;
2808 struct gl_program_state Program
; /**< for vertex or fragment progs */
2809 struct gl_vertex_program_state VertexProgram
; /**< GL_NV_vertex_program */
2810 struct gl_fragment_program_state FragmentProgram
; /**< GL_NV_fragment_program */
2811 struct gl_ati_fragment_shader_state ATIFragmentShader
; /**< GL_ATI_fragment_shader */
2813 struct fragment_program
*_TexEnvProgram
; /**< Texture state as fragment program */
2814 struct vertex_program
*_TnlProgram
; /**< Fixed func TNL state as vertex program */
2816 GLboolean _MaintainTexEnvProgram
;
2817 GLboolean _MaintainTnlProgram
;
2819 struct gl_query_state Query
; /**< GL_ARB_occlusion_query */
2821 struct gl_shader_objects_state ShaderObjects
; /* GL_ARB_shader_objects */
2824 #if FEATURE_EXT_framebuffer_object
2825 /*struct gl_framebuffer *CurrentFramebuffer;*/
2826 struct gl_renderbuffer
*CurrentRenderbuffer
;
2829 GLenum ErrorValue
; /**< Last error code */
2830 GLenum RenderMode
; /**< either GL_RENDER, GL_SELECT, GL_FEEDBACK */
2831 GLbitfield NewState
; /**< bitwise-or of _NEW_* flags */
2833 /** \name Derived state */
2835 GLbitfield _TriangleCaps
; /**< bitwise-or of DD_* flags */
2836 GLbitfield _ImageTransferState
;/**< bitwise-or of IMAGE_*_BIT flags */
2837 GLfloat _EyeZDir
[3];
2838 GLfloat _ModelViewInvScale
;
2839 GLboolean _NeedEyeCoords
;
2840 GLboolean _ForceEyeCoords
;
2841 GLboolean _RotateMode
;
2842 GLenum _CurrentProgram
; /* currently executing program */
2844 struct gl_shine_tab
*_ShineTable
[2]; /**< Active shine tables */
2845 struct gl_shine_tab
*_ShineTabList
; /**< MRU list of inactive shine tables */
2848 struct gl_list_extensions ListExt
; /**< driver dlist extensions */
2851 GLuint _Facing
; /**< This is a hack for 2-sided stencil test.
2853 * We don't have a better way to communicate this value from
2854 * swrast_setup to swrast. */
2856 /** \name Color clamping (tentative part of GL_ARB_color_clamp_control) */
2858 GLboolean ClampFragmentColors
;
2859 GLboolean ClampVertexColors
;
2862 /** \name For debugging/development only */
2864 GLboolean FirstTimeCurrent
;
2867 /** Dither disable via MESA_NO_DITHER env var */
2870 /** software compression/decompression supported or not */
2871 GLboolean Mesa_DXTn
;
2873 /** Core tnl module support */
2874 struct gl_tnl_module TnlModule
;
2877 * \name Hooks for module contexts.
2879 * These will eventually live in the driver or elsewhere.
2882 void *swrast_context
;
2883 void *swsetup_context
;
2884 void *swtnl_context
;
2886 void *acache_context
;
2892 /** The string names for GL_POINT, GL_LINE_LOOP, etc */
2893 extern const char *_mesa_prim_name
[GL_POLYGON
+4];
2897 extern int MESA_VERBOSE
;
2898 extern int MESA_DEBUG_FLAGS
;
2899 # define MESA_FUNCTION __FUNCTION__
2901 # define MESA_VERBOSE 0
2902 # define MESA_DEBUG_FLAGS 0
2903 # define MESA_FUNCTION "a function"
2912 VERBOSE_VARRAY
= 0x0001,
2913 VERBOSE_TEXTURE
= 0x0002,
2914 VERBOSE_IMMEDIATE
= 0x0004,
2915 VERBOSE_PIPELINE
= 0x0008,
2916 VERBOSE_DRIVER
= 0x0010,
2917 VERBOSE_STATE
= 0x0020,
2918 VERBOSE_API
= 0x0040,
2919 VERBOSE_DISPLAY_LIST
= 0x0100,
2920 VERBOSE_LIGHTING
= 0x0200,
2921 VERBOSE_PRIMS
= 0x0400,
2922 VERBOSE_VERTS
= 0x0800,
2923 VERBOSE_DISASSEM
= 0x1000
2929 DEBUG_ALWAYS_FLUSH
= 0x1
2934 #define Elements(x) sizeof(x)/sizeof(*(x))
2937 #endif /* TYPES_H */