b8c2ec7af6e1f178321506ef706051c24e7f7ee3
[mesa.git] / src / mesa / main / mtypes.h
1 /* $Id: mtypes.h,v 1.42 2001/05/21 16:41:03 brianp Exp $ */
2
3 /*
4 * Mesa 3-D graphics library
5 * Version: 3.5
6 *
7 * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
8 *
9 * Permission is hereby granted, free of charge, to any person obtaining a
10 * copy of this software and associated documentation files (the "Software"),
11 * to deal in the Software without restriction, including without limitation
12 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 * and/or sell copies of the Software, and to permit persons to whom the
14 * Software is furnished to do so, subject to the following conditions:
15 *
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
23 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 */
26
27
28 #ifndef TYPES_H
29 #define TYPES_H
30
31
32 #include "glheader.h"
33 #include "config.h" /* Hardwired parameters */
34 #include "glapitable.h"
35 #include "glthread.h"
36
37 #include "math/m_matrix.h" /* GLmatrix */
38
39 #if defined(MESA_TRACE)
40 #include "Trace/tr_context.h"
41 #endif
42
43
44 /* Please try to mark derived values with a leading underscore ('_').
45 */
46
47 /*
48 * Color channel data type:
49 */
50 #if CHAN_BITS == 8
51 typedef GLubyte GLchan;
52 #define CHAN_MAX 255
53 #define CHAN_MAXF 255.0F
54 #define CHAN_TYPE GL_UNSIGNED_BYTE
55 #elif CHAN_BITS == 16
56 typedef GLushort GLchan;
57 #define CHAN_MAX 65535
58 #define CHAN_MAXF 65535.0F
59 #define CHAN_TYPE GL_UNSIGNED_SHORT
60 #elif CHAN_BITS == 32
61 typedef GLfloat GLchan;
62 #define CHAN_MAX 1.0
63 #define CHAN_MAXF 1.0F
64 #define CHAN_TYPE GL_FLOAT
65 #else
66 #error illegal number of color channel bits
67 #endif
68
69
70 /*
71 * Accumulation buffer data type:
72 */
73 #if ACCUM_BITS==8
74 typedef GLbyte GLaccum;
75 #elif ACCUM_BITS==16
76 typedef GLshort GLaccum;
77 #else
78 # error "illegal number of accumulation bits"
79 #endif
80
81
82 /*
83 * Stencil buffer data type:
84 */
85 #if STENCIL_BITS==8
86 typedef GLubyte GLstencil;
87 # define STENCIL_MAX 0xff
88 #elif STENCIL_BITS==16
89 typedef GLushort GLstencil;
90 # define STENCIL_MAX 0xffff
91 #else
92 # error "illegal number of stencil bits"
93 #endif
94
95
96 /*
97 * Depth buffer data type:
98 */
99 typedef GLuint GLdepth; /* Must be 32-bits! */
100
101
102 /*
103 * Fixed point data type:
104 */
105 typedef int GLfixed;
106
107
108
109 /*
110 * Some forward type declarations
111 */
112 struct _mesa_HashTable;
113 struct gl_texture_image;
114 struct gl_texture_object;
115 typedef struct __GLcontextRec GLcontext;
116 typedef struct __GLcontextModesRec GLvisual;
117 typedef struct gl_frame_buffer GLframebuffer;
118
119
120
121 /* Maximum number of temporary vertices required for clipping. (Used
122 * in array_cache and tnl modules).
123 */
124 #define MAX_CLIPPED_VERTICES ((2 * (6 + MAX_CLIP_PLANES))+1)
125
126
127 /* Data structure for color tables */
128 struct gl_color_table {
129 GLenum Format; /* GL_ALPHA, GL_RGB, GL_RGB, etc */
130 GLenum IntFormat;
131 GLuint Size; /* number of entries (rows) in table */
132 GLvoid *Table; /* either GLfloat * or GLchan * */
133 GLboolean FloatTable; /* are entries stored as floats? */
134 GLubyte RedSize;
135 GLubyte GreenSize;
136 GLubyte BlueSize;
137 GLubyte AlphaSize;
138 GLubyte LuminanceSize;
139 GLubyte IntensitySize;
140 };
141
142
143 /*
144 * Bit flags used for updating material values.
145 */
146 #define FRONT_AMBIENT_BIT 0x1
147 #define BACK_AMBIENT_BIT 0x2
148 #define FRONT_DIFFUSE_BIT 0x4
149 #define BACK_DIFFUSE_BIT 0x8
150 #define FRONT_SPECULAR_BIT 0x10
151 #define BACK_SPECULAR_BIT 0x20
152 #define FRONT_EMISSION_BIT 0x40
153 #define BACK_EMISSION_BIT 0x80
154 #define FRONT_SHININESS_BIT 0x100
155 #define BACK_SHININESS_BIT 0x200
156 #define FRONT_INDEXES_BIT 0x400
157 #define BACK_INDEXES_BIT 0x800
158
159 #define FRONT_MATERIAL_BITS (FRONT_EMISSION_BIT | FRONT_AMBIENT_BIT | \
160 FRONT_DIFFUSE_BIT | FRONT_SPECULAR_BIT | \
161 FRONT_SHININESS_BIT | FRONT_INDEXES_BIT)
162
163 #define BACK_MATERIAL_BITS (BACK_EMISSION_BIT | BACK_AMBIENT_BIT | \
164 BACK_DIFFUSE_BIT | BACK_SPECULAR_BIT | \
165 BACK_SHININESS_BIT | BACK_INDEXES_BIT)
166
167 #define ALL_MATERIAL_BITS (FRONT_MATERIAL_BITS | BACK_MATERIAL_BITS)
168
169
170
171 /*
172 * Specular exponent and material shininess lookup table sizes:
173 */
174 #define EXP_TABLE_SIZE 512
175 #define SHINE_TABLE_SIZE 256
176
177 struct gl_shine_tab {
178 struct gl_shine_tab *next, *prev;
179 GLfloat tab[SHINE_TABLE_SIZE+1];
180 GLfloat shininess;
181 GLuint refcount;
182 };
183
184
185 struct gl_light {
186 struct gl_light *next; /* double linked list with sentinel */
187 struct gl_light *prev;
188
189 GLfloat Ambient[4]; /* ambient color */
190 GLfloat Diffuse[4]; /* diffuse color */
191 GLfloat Specular[4]; /* specular color */
192 GLfloat EyePosition[4]; /* position in eye coordinates */
193 GLfloat EyeDirection[4]; /* spotlight dir in eye coordinates */
194 GLfloat SpotExponent;
195 GLfloat SpotCutoff; /* in degress */
196 GLfloat _CosCutoff; /* = MAX(0, cos(SpotCutoff)) */
197 GLfloat ConstantAttenuation;
198 GLfloat LinearAttenuation;
199 GLfloat QuadraticAttenuation;
200 GLboolean Enabled; /* On/off flag */
201
202 /* Derived fields */
203 GLuint _Flags; /* State */
204
205 GLfloat _Position[4]; /* position in eye/obj coordinates */
206 GLfloat _VP_inf_norm[3]; /* Norm direction to infinite light */
207 GLfloat _h_inf_norm[3]; /* Norm( _VP_inf_norm + <0,0,1> ) */
208 GLfloat _NormDirection[4]; /* normalized spotlight direction */
209 GLfloat _VP_inf_spot_attenuation;
210
211 GLfloat _SpotExpTable[EXP_TABLE_SIZE][2]; /* to replace a pow() call */
212 GLfloat _MatAmbient[2][3]; /* material ambient * light ambient */
213 GLfloat _MatDiffuse[2][3]; /* material diffuse * light diffuse */
214 GLfloat _MatSpecular[2][3]; /* material spec * light specular */
215 GLfloat _dli; /* CI diffuse light intensity */
216 GLfloat _sli; /* CI specular light intensity */
217 };
218
219
220 struct gl_lightmodel {
221 GLfloat Ambient[4]; /* ambient color */
222 GLboolean LocalViewer; /* Local (or infinite) view point? */
223 GLboolean TwoSide; /* Two (or one) sided lighting? */
224 GLenum ColorControl; /* either GL_SINGLE_COLOR */
225 /* or GL_SEPARATE_SPECULAR_COLOR */
226 };
227
228
229 struct gl_material
230 {
231 GLfloat Ambient[4];
232 GLfloat Diffuse[4];
233 GLfloat Specular[4];
234 GLfloat Emission[4];
235 GLfloat Shininess;
236 GLfloat AmbientIndex; /* for color index lighting */
237 GLfloat DiffuseIndex; /* for color index lighting */
238 GLfloat SpecularIndex; /* for color index lighting */
239 };
240
241
242 /*
243 * Attribute structures:
244 * We define a struct for each attribute group to make pushing and
245 * popping attributes easy. Also it's a good organization.
246 */
247 struct gl_accum_attrib {
248 GLfloat ClearColor[4]; /* Accumulation buffer clear color */
249 };
250
251
252 /*
253 * Used in DrawDestMask below
254 */
255 #define FRONT_LEFT_BIT 1
256 #define FRONT_RIGHT_BIT 2
257 #define BACK_LEFT_BIT 4
258 #define BACK_RIGHT_BIT 8
259
260
261 struct gl_colorbuffer_attrib {
262 GLuint ClearIndex; /* Index to use for glClear */
263 GLchan ClearColor[4]; /* Color to use for glClear */
264
265 GLuint IndexMask; /* Color index write mask */
266 GLubyte ColorMask[4]; /* Each flag is 0xff or 0x0 */
267
268 GLenum DrawBuffer; /* Which buffer to draw into */
269 GLenum DriverDrawBuffer; /* Current device driver dest buffer */
270 GLboolean MultiDrawBuffer; /* Drawing to mutliple buffers? */
271 GLubyte DrawDestMask; /* bitwise-OR of bitflags above */
272
273 /* alpha testing */
274 GLboolean AlphaEnabled; /* Alpha test enabled flag */
275 GLenum AlphaFunc; /* Alpha test function */
276 GLchan AlphaRef; /* Alpha ref value as GLchan */
277
278 /* blending */
279 GLboolean BlendEnabled; /* Blending enabled flag */
280 GLenum BlendSrcRGB; /* Blending source operator */
281 GLenum BlendDstRGB; /* Blending destination operator */
282 GLenum BlendSrcA; /* GL_INGR_blend_func_separate */
283 GLenum BlendDstA; /* GL_INGR_blend_func_separate */
284 GLenum BlendEquation;
285 GLfloat BlendColor[4];
286
287 /* logic op */
288 GLenum LogicOp; /* Logic operator */
289 GLboolean IndexLogicOpEnabled; /* Color index logic op enabled flag */
290 GLboolean ColorLogicOpEnabled; /* RGBA logic op enabled flag */
291
292 GLboolean DitherFlag; /* Dither enable flag */
293 };
294
295
296 struct gl_current_attrib {
297 /* These values valid only when FLUSH_VERTICES has been called.
298 */
299 GLfloat Normal[3]; /* Current vertex normal */
300 GLfloat Color[4]; /* Current RGBA color */
301 GLfloat SecondaryColor[4]; /* Current secondary color */
302 GLfloat FogCoord; /* Current Fog coord */
303 GLuint Index; /* Current color index */
304 GLboolean EdgeFlag; /* Current edge flag */
305 GLfloat Texcoord[MAX_TEXTURE_UNITS][4]; /* Current texture coords */
306
307 /* These values are always valid.
308 */
309 GLfloat RasterPos[4]; /* Current raster position */
310 GLfloat RasterDistance; /* Current raster distance */
311 GLfloat RasterColor[4]; /* Current raster color */
312 GLuint RasterIndex; /* Current raster index */
313 GLfloat *RasterTexCoord; /* Current raster texcoord*/
314 GLfloat RasterMultiTexCoord[MAX_TEXTURE_UNITS][4];
315 GLboolean RasterPosValid; /* Raster po valid flag */
316 };
317
318
319 struct gl_depthbuffer_attrib {
320 GLenum Func; /* Function for depth buffer compare */
321 GLfloat Clear; /* Value to clear depth buffer to */
322 GLboolean Test; /* Depth buffering enabled flag */
323 GLboolean Mask; /* Depth buffer writable? */
324 GLboolean OcclusionTest; /* GL_HP_occlusion_test */
325 };
326
327
328 struct gl_enable_attrib {
329 GLboolean AlphaTest;
330 GLboolean AutoNormal;
331 GLboolean Blend;
332 GLboolean ClipPlane[MAX_CLIP_PLANES];
333 GLboolean ColorMaterial;
334 GLboolean Convolution1D;
335 GLboolean Convolution2D;
336 GLboolean Separable2D;
337 GLboolean CullFace;
338 GLboolean DepthTest;
339 GLboolean Dither;
340 GLboolean Fog;
341 GLboolean Histogram;
342 GLboolean Light[MAX_LIGHTS];
343 GLboolean Lighting;
344 GLboolean LineSmooth;
345 GLboolean LineStipple;
346 GLboolean IndexLogicOp;
347 GLboolean ColorLogicOp;
348 GLboolean Map1Color4;
349 GLboolean Map1Index;
350 GLboolean Map1Normal;
351 GLboolean Map1TextureCoord1;
352 GLboolean Map1TextureCoord2;
353 GLboolean Map1TextureCoord3;
354 GLboolean Map1TextureCoord4;
355 GLboolean Map1Vertex3;
356 GLboolean Map1Vertex4;
357 GLboolean Map2Color4;
358 GLboolean Map2Index;
359 GLboolean Map2Normal;
360 GLboolean Map2TextureCoord1;
361 GLboolean Map2TextureCoord2;
362 GLboolean Map2TextureCoord3;
363 GLboolean Map2TextureCoord4;
364 GLboolean Map2Vertex3;
365 GLboolean Map2Vertex4;
366 GLboolean MinMax;
367 GLboolean Normalize;
368 GLboolean PixelTexture;
369 GLboolean PointSmooth;
370 GLboolean PolygonOffsetPoint;
371 GLboolean PolygonOffsetLine;
372 GLboolean PolygonOffsetFill;
373 GLboolean PolygonSmooth;
374 GLboolean PolygonStipple;
375 GLboolean RescaleNormals;
376 GLboolean Scissor;
377 GLboolean Stencil;
378 GLuint Texture[MAX_TEXTURE_UNITS];
379 GLuint TexGen[MAX_TEXTURE_UNITS];
380 };
381
382
383 struct gl_eval_attrib {
384 /* Enable bits */
385 GLboolean Map1Color4;
386 GLboolean Map1Index;
387 GLboolean Map1Normal;
388 GLboolean Map1TextureCoord1;
389 GLboolean Map1TextureCoord2;
390 GLboolean Map1TextureCoord3;
391 GLboolean Map1TextureCoord4;
392 GLboolean Map1Vertex3;
393 GLboolean Map1Vertex4;
394 GLboolean Map2Color4;
395 GLboolean Map2Index;
396 GLboolean Map2Normal;
397 GLboolean Map2TextureCoord1;
398 GLboolean Map2TextureCoord2;
399 GLboolean Map2TextureCoord3;
400 GLboolean Map2TextureCoord4;
401 GLboolean Map2Vertex3;
402 GLboolean Map2Vertex4;
403 GLboolean AutoNormal;
404 /* Map Grid endpoints and divisions and calculated du values */
405 GLint MapGrid1un;
406 GLfloat MapGrid1u1, MapGrid1u2, MapGrid1du;
407 GLint MapGrid2un, MapGrid2vn;
408 GLfloat MapGrid2u1, MapGrid2u2, MapGrid2du;
409 GLfloat MapGrid2v1, MapGrid2v2, MapGrid2dv;
410 };
411
412
413 struct gl_fog_attrib {
414 GLboolean Enabled; /* Fog enabled flag */
415 GLfloat Color[4]; /* Fog color */
416 GLfloat Density; /* Density >= 0.0 */
417 GLfloat Start; /* Start distance in eye coords */
418 GLfloat End; /* End distance in eye coords */
419 GLfloat Index; /* Fog index */
420 GLenum Mode; /* Fog mode */
421 GLboolean ColorSumEnabled;
422 GLenum FogCoordinateSource;
423 };
424
425
426 struct gl_hint_attrib {
427 /* always one of GL_FASTEST, GL_NICEST, or GL_DONT_CARE */
428 GLenum PerspectiveCorrection;
429 GLenum PointSmooth;
430 GLenum LineSmooth;
431 GLenum PolygonSmooth;
432 GLenum Fog;
433 GLenum ClipVolumeClipping; /* GL_EXT_clip_volume_hint */
434 GLenum TextureCompression; /* GL_ARB_texture_compression */
435 GLenum GenerateMipmap; /* GL_SGIS_generate_mipmap */
436 };
437
438
439 struct gl_histogram_attrib {
440 GLuint Width; /* number of table entries */
441 GLint Format; /* GL_ALPHA, GL_RGB, etc */
442 GLuint Count[HISTOGRAM_TABLE_SIZE][4]; /* the histogram */
443 GLboolean Sink; /* terminate image transfer? */
444 GLubyte RedSize; /* Bits per counter */
445 GLubyte GreenSize;
446 GLubyte BlueSize;
447 GLubyte AlphaSize;
448 GLubyte LuminanceSize;
449 };
450
451
452 struct gl_minmax_attrib {
453 GLenum Format;
454 GLboolean Sink;
455 GLfloat Min[4], Max[4]; /* RGBA */
456 };
457
458
459 struct gl_convolution_attrib {
460 GLenum Format;
461 GLenum InternalFormat;
462 GLuint Width;
463 GLuint Height;
464 GLfloat Filter[MAX_CONVOLUTION_WIDTH * MAX_CONVOLUTION_HEIGHT * 4];
465 };
466
467
468 struct gl_light_attrib {
469 struct gl_light Light[MAX_LIGHTS]; /* Array of lights */
470 struct gl_lightmodel Model; /* Lighting model */
471
472 /* Must flush FLUSH_VERTICES before referencing:
473 */
474 struct gl_material Material[2]; /* Material 0=front, 1=back */
475
476 GLboolean Enabled; /* Lighting enabled flag */
477 GLenum ShadeModel; /* GL_FLAT or GL_SMOOTH */
478 GLenum ColorMaterialFace; /* GL_FRONT, BACK or FRONT_AND_BACK */
479 GLenum ColorMaterialMode; /* GL_AMBIENT, GL_DIFFUSE, etc */
480 GLuint ColorMaterialBitmask; /* bitmask formed from Face and Mode */
481 GLboolean ColorMaterialEnabled;
482
483 struct gl_light EnabledList; /* List sentinel */
484
485 /* Derived for optimizations: */
486 GLboolean _NeedVertices; /* Use fast shader? */
487 GLuint _Flags; /* LIGHT_* flags, see below */
488 GLfloat _BaseColor[2][3];
489 GLfloat _BaseAlpha[2];
490 };
491
492
493 #define LIGHT_SPOT 0x1
494 #define LIGHT_LOCAL_VIEWER 0x2
495 #define LIGHT_POSITIONAL 0x4
496
497 #define LIGHT_NEED_VERTICES (LIGHT_POSITIONAL|LIGHT_LOCAL_VIEWER)
498
499 struct gl_line_attrib {
500 GLboolean SmoothFlag; /* GL_LINE_SMOOTH enabled? */
501 GLboolean StippleFlag; /* GL_LINE_STIPPLE enabled? */
502 GLushort StipplePattern; /* Stipple pattern */
503 GLint StippleFactor; /* Stipple repeat factor */
504 GLfloat Width; /* Line width */
505 GLfloat _Width; /* Clamped Line width */
506 };
507
508
509 struct gl_list_attrib {
510 GLuint ListBase;
511 };
512
513 struct gl_list_opcode {
514 GLuint size;
515 void (*execute)( GLcontext *ctx, void *data );
516 void (*destroy)( GLcontext *ctx, void *data );
517 void (*print)( GLcontext *ctx, void *data );
518 };
519
520 #define GL_MAX_EXT_OPCODES 16
521
522 struct gl_list_extensions {
523 struct gl_list_opcode opcode[GL_MAX_EXT_OPCODES];
524 GLuint nr_opcodes;
525 };
526
527 struct gl_pixel_attrib {
528 GLenum ReadBuffer; /* src buffer for glRead/CopyPixels */
529 GLenum DriverReadBuffer; /* Driver's current source buffer */
530 GLfloat RedBias, RedScale;
531 GLfloat GreenBias, GreenScale;
532 GLfloat BlueBias, BlueScale;
533 GLfloat AlphaBias, AlphaScale;
534 GLfloat DepthBias, DepthScale;
535 GLint IndexShift, IndexOffset;
536 GLboolean MapColorFlag;
537 GLboolean MapStencilFlag;
538 GLfloat ZoomX, ZoomY;
539 GLint MapStoSsize; /* Size of each pixel map */
540 GLint MapItoIsize;
541 GLint MapItoRsize;
542 GLint MapItoGsize;
543 GLint MapItoBsize;
544 GLint MapItoAsize;
545 GLint MapRtoRsize;
546 GLint MapGtoGsize;
547 GLint MapBtoBsize;
548 GLint MapAtoAsize;
549 GLint MapStoS[MAX_PIXEL_MAP_TABLE]; /* Pixel map tables */
550 GLint MapItoI[MAX_PIXEL_MAP_TABLE];
551 GLfloat MapItoR[MAX_PIXEL_MAP_TABLE];
552 GLfloat MapItoG[MAX_PIXEL_MAP_TABLE];
553 GLfloat MapItoB[MAX_PIXEL_MAP_TABLE];
554 GLfloat MapItoA[MAX_PIXEL_MAP_TABLE];
555 GLubyte MapItoR8[MAX_PIXEL_MAP_TABLE]; /* converted to 8-bit color */
556 GLubyte MapItoG8[MAX_PIXEL_MAP_TABLE];
557 GLubyte MapItoB8[MAX_PIXEL_MAP_TABLE];
558 GLubyte MapItoA8[MAX_PIXEL_MAP_TABLE];
559 GLfloat MapRtoR[MAX_PIXEL_MAP_TABLE];
560 GLfloat MapGtoG[MAX_PIXEL_MAP_TABLE];
561 GLfloat MapBtoB[MAX_PIXEL_MAP_TABLE];
562 GLfloat MapAtoA[MAX_PIXEL_MAP_TABLE];
563 /* GL_EXT_histogram */
564 GLboolean HistogramEnabled;
565 GLboolean MinMaxEnabled;
566 /* GL_SGIS_pixel_texture */
567 GLboolean PixelTextureEnabled;
568 GLenum FragmentRgbSource;
569 GLenum FragmentAlphaSource;
570 /* GL_SGI_color_matrix */
571 GLfloat PostColorMatrixScale[4]; /* RGBA */
572 GLfloat PostColorMatrixBias[4]; /* RGBA */
573 /* GL_SGI_color_table */
574 GLfloat ColorTableScale[4];
575 GLfloat ColorTableBias[4];
576 GLboolean ColorTableEnabled;
577 GLfloat PCCTscale[4];
578 GLfloat PCCTbias[4];
579 GLboolean PostConvolutionColorTableEnabled;
580 GLfloat PCMCTscale[4];
581 GLfloat PCMCTbias[4];
582 GLboolean PostColorMatrixColorTableEnabled;
583 /* Convolution */
584 GLboolean Convolution1DEnabled;
585 GLboolean Convolution2DEnabled;
586 GLboolean Separable2DEnabled;
587 GLfloat ConvolutionBorderColor[3][4];
588 GLenum ConvolutionBorderMode[3];
589 GLfloat ConvolutionFilterScale[3][4];
590 GLfloat ConvolutionFilterBias[3][4];
591 GLfloat PostConvolutionScale[4]; /* RGBA */
592 GLfloat PostConvolutionBias[4]; /* RGBA */
593 };
594
595
596 struct gl_point_attrib {
597 GLboolean SmoothFlag; /* True if GL_POINT_SMOOTH is enabled */
598 GLboolean SpriteMode; /* GL_MESA_sprite_point extension */
599 GLfloat Size; /* User-specified point size */
600 GLfloat _Size; /* Size clamped to Const.Min/MaxPointSize */
601 GLfloat Params[3]; /* GL_EXT_point_parameters */
602 GLfloat MinSize, MaxSize; /* GL_EXT_point_parameters */
603 GLfloat Threshold; /* GL_EXT_point_parameters */
604 GLboolean _Attenuated; /* True if Params != [1, 0, 0] */
605 };
606
607
608 struct gl_polygon_attrib {
609 GLenum FrontFace; /* Either GL_CW or GL_CCW */
610 GLenum FrontMode; /* Either GL_POINT, GL_LINE or GL_FILL */
611 GLenum BackMode; /* Either GL_POINT, GL_LINE or GL_FILL */
612 GLboolean _FrontBit; /* */
613 GLboolean CullFlag; /* Culling on/off flag */
614 GLboolean SmoothFlag; /* True if GL_POLYGON_SMOOTH is enabled */
615 GLboolean StippleFlag; /* True if GL_POLYGON_STIPPLE is enabled */
616 GLenum CullFaceMode; /* Culling mode GL_FRONT or GL_BACK */
617 GLfloat OffsetFactor; /* Polygon offset factor, from user */
618 GLfloat OffsetUnits; /* Polygon offset units, from user */
619 GLfloat OffsetMRD; /* = OffsetUnits * visual->MRD */
620 GLboolean OffsetPoint; /* Offset in GL_POINT mode */
621 GLboolean OffsetLine; /* Offset in GL_LINE mode */
622 GLboolean OffsetFill; /* Offset in GL_FILL mode */
623 GLboolean _OffsetAny;
624 };
625
626
627 struct gl_scissor_attrib {
628 GLboolean Enabled; /* Scissor test enabled? */
629 GLint X, Y; /* Lower left corner of box */
630 GLsizei Width, Height; /* Size of box */
631 };
632
633
634 struct gl_stencil_attrib {
635 GLboolean Enabled; /* Enabled flag */
636 GLenum Function; /* Stencil function */
637 GLenum FailFunc; /* Fail function */
638 GLenum ZPassFunc; /* Depth buffer pass function */
639 GLenum ZFailFunc; /* Depth buffer fail function */
640 GLstencil Ref; /* Reference value */
641 GLstencil ValueMask; /* Value mask */
642 GLstencil Clear; /* Clear value */
643 GLstencil WriteMask; /* Write mask */
644 };
645
646
647 /* TexGenEnabled flags */
648 #define S_BIT 1
649 #define T_BIT 2
650 #define R_BIT 4
651 #define Q_BIT 8
652
653 /* Texture Enabled flags */
654 #define TEXTURE0_1D 0x1 /* Texture unit 0 (default) */
655 #define TEXTURE0_2D 0x2
656 #define TEXTURE0_3D 0x4
657 #define TEXTURE0_CUBE 0x8
658 #define TEXTURE0_ANY (TEXTURE0_1D | TEXTURE0_2D | TEXTURE0_3D | TEXTURE0_CUBE)
659 #define TEXTURE1_1D (TEXTURE0_1D << 4) /* Texture unit 1 */
660 #define TEXTURE1_2D (TEXTURE0_2D << 4)
661 #define TEXTURE1_3D (TEXTURE0_3D << 4)
662 #define TEXTURE1_CUBE (TEXTURE0_CUBE << 4)
663 #define TEXTURE1_ANY (TEXTURE1_1D | TEXTURE1_2D | TEXTURE1_3D | TEXTURE1_CUBE)
664 #define TEXTURE2_1D (TEXTURE0_1D << 8) /* Texture unit 2 */
665 #define TEXTURE2_2D (TEXTURE0_2D << 8)
666 #define TEXTURE2_3D (TEXTURE0_3D << 8)
667 #define TEXTURE2_CUBE (TEXTURE0_CUBE << 8)
668 #define TEXTURE2_ANY (TEXTURE2_1D | TEXTURE2_2D | TEXTURE2_3D | TEXTURE2_CUBE)
669 #define TEXTURE3_1D (TEXTURE0_1D << 12) /* Texture unit 3 */
670 #define TEXTURE3_2D (TEXTURE0_2D << 12)
671 #define TEXTURE3_3D (TEXTURE0_3D << 12)
672 #define TEXTURE3_CUBE (TEXTURE0_CUBE << 12)
673 #define TEXTURE3_ANY (TEXTURE3_1D | TEXTURE3_2D | TEXTURE3_3D | TEXTURE3_CUBE)
674 #define TEXTURE4_1D (TEXTURE0_1D << 16) /* Texture unit 4 */
675 #define TEXTURE4_2D (TEXTURE0_2D << 16)
676 #define TEXTURE4_3D (TEXTURE0_3D << 16)
677 #define TEXTURE4_CUBE (TEXTURE0_CUBE << 16)
678 #define TEXTURE5_ANY (TEXTURE3_1D | TEXTURE3_2D | TEXTURE3_3D | TEXTURE3_CUBE)
679 #define TEXTURE5_1D (TEXTURE0_1D << 20) /* Texture unit 5 */
680 #define TEXTURE5_2D (TEXTURE0_2D << 20)
681 #define TEXTURE5_3D (TEXTURE0_3D << 20)
682 #define TEXTURE5_CUBE (TEXTURE0_CUBE << 20)
683 #define TEXTURE5_ANY (TEXTURE3_1D | TEXTURE3_2D | TEXTURE3_3D | TEXTURE3_CUBE)
684 #define TEXTURE6_1D (TEXTURE0_1D << 24) /* Texture unit 6 */
685 #define TEXTURE6_2D (TEXTURE0_2D << 24)
686 #define TEXTURE6_3D (TEXTURE0_3D << 24)
687 #define TEXTURE6_CUBE (TEXTURE0_CUBE << 24)
688 #define TEXTURE6_ANY (TEXTURE3_1D | TEXTURE3_2D | TEXTURE3_3D | TEXTURE3_CUBE)
689 #define TEXTURE7_1D (TEXTURE0_1D << 28) /* Texture unit 7 */
690 #define TEXTURE7_2D (TEXTURE0_2D << 28)
691 #define TEXTURE7_3D (TEXTURE0_3D << 28)
692 #define TEXTURE7_CUBE (TEXTURE0_CUBE << 28)
693 #define TEXTURE7_ANY (TEXTURE3_1D | TEXTURE3_2D | TEXTURE3_3D | TEXTURE3_CUBE)
694
695 /* Bitmap versions of the GL_ constants.
696 */
697 #define TEXGEN_SPHERE_MAP 0x1
698 #define TEXGEN_OBJ_LINEAR 0x2
699 #define TEXGEN_EYE_LINEAR 0x4
700 #define TEXGEN_REFLECTION_MAP_NV 0x8
701 #define TEXGEN_NORMAL_MAP_NV 0x10
702
703 #define TEXGEN_NEED_NORMALS (TEXGEN_SPHERE_MAP | \
704 TEXGEN_REFLECTION_MAP_NV | \
705 TEXGEN_NORMAL_MAP_NV)
706 #define TEXGEN_NEED_EYE_COORD (TEXGEN_SPHERE_MAP | \
707 TEXGEN_REFLECTION_MAP_NV | \
708 TEXGEN_NORMAL_MAP_NV | \
709 TEXGEN_EYE_LINEAR)
710
711
712
713 /* A selection of state flags to make driver and module's lives easier.
714 */
715 #define ENABLE_TEXGEN0 0x1
716 #define ENABLE_TEXGEN1 0x2
717 #define ENABLE_TEXGEN2 0x4
718 #define ENABLE_TEXGEN3 0x8
719 #define ENABLE_TEXGEN4 0x10
720 #define ENABLE_TEXGEN5 0x20
721 #define ENABLE_TEXGEN6 0x40
722 #define ENABLE_TEXGEN7 0x80
723
724 #define ENABLE_TEXMAT0 0x1 /* Ie. not the identity matrix */
725 #define ENABLE_TEXMAT1 0x2
726 #define ENABLE_TEXMAT2 0x4
727 #define ENABLE_TEXMAT3 0x8
728 #define ENABLE_TEXMAT4 0x10
729 #define ENABLE_TEXMAT5 0x20
730 #define ENABLE_TEXMAT6 0x40
731 #define ENABLE_TEXMAT7 0x80
732
733 #define ENABLE_TEXGEN(i) (ENABLE_TEXGEN0 << (i))
734 #define ENABLE_TEXMAT(i) (ENABLE_TEXMAT0 << (i))
735
736 /*
737 * If teximage is color-index, texelOut returns GLchan[1].
738 * If teximage is depth, texelOut returns GLfloat[1].
739 * Otherwise, texelOut returns GLchan[4].
740 */
741 typedef void (*FetchTexelFunc)( const struct gl_texture_image *texImage,
742 GLint col, GLint row, GLint img,
743 GLvoid *texelOut );
744
745 /* Texture format record */
746 struct gl_texture_format {
747 GLint MesaFormat; /* One of the MESA_FORMAT_* values */
748
749 GLenum BaseFormat; /* Either GL_ALPHA, GL_INTENSITY, GL_LUMINANCE,
750 * GL_LUMINANCE_ALPHA, GL_RGB, GL_RGBA,
751 * GL_COLOR_INDEX or GL_DEPTH_COMPONENT.
752 */
753 GLenum Type; /* Internal type as GL enum value */
754
755 GLubyte RedBits; /* Bits per texel component */
756 GLubyte GreenBits;
757 GLubyte BlueBits;
758 GLubyte AlphaBits;
759 GLubyte LuminanceBits;
760 GLubyte IntensityBits;
761 GLubyte IndexBits;
762 GLubyte DepthBits;
763
764 GLint TexelBytes;
765
766 FetchTexelFunc FetchTexel1D; /* Texel fetch function pointers */
767 FetchTexelFunc FetchTexel2D;
768 FetchTexelFunc FetchTexel3D;
769 };
770
771 /* Texture image record */
772 struct gl_texture_image {
773 GLenum Format; /* GL_ALPHA, GL_LUMINANCE, GL_LUMINANCE_ALPHA,
774 * GL_INTENSITY, GL_RGB, GL_RGBA,
775 * GL_COLOR_INDEX or GL_DEPTH_COMPONENT only.
776 */
777 GLint IntFormat; /* Internal format as given by the user */
778 GLuint Border; /* 0 or 1 */
779 GLuint Width; /* = 2^WidthLog2 + 2*Border */
780 GLuint Height; /* = 2^HeightLog2 + 2*Border */
781 GLuint Depth; /* = 2^DepthLog2 + 2*Border */
782 GLuint Width2; /* = Width - 2*Border */
783 GLuint Height2; /* = Height - 2*Border */
784 GLuint Depth2; /* = Depth - 2*Border */
785 GLuint WidthLog2; /* = log2(Width2) */
786 GLuint HeightLog2; /* = log2(Height2) */
787 GLuint DepthLog2; /* = log2(Depth2) */
788 GLuint MaxLog2; /* = MAX(WidthLog2, HeightLog2) */
789 GLvoid *Data; /* Image data, accessed via FetchTexel() */
790
791 const struct gl_texture_format *TexFormat;
792
793 FetchTexelFunc FetchTexel; /* Texel fetch function pointer */
794
795 GLboolean IsCompressed; /* GL_ARB_texture_compression */
796 GLuint CompressedSize; /* GL_ARB_texture_compression */
797
798 /* For device driver: */
799 void *DriverData; /* Arbitrary device driver data */
800 };
801
802
803 /* Texture object record */
804 struct gl_texture_object {
805 _glthread_Mutex Mutex; /* for thread safety */
806 GLint RefCount; /* reference count */
807 GLuint Name; /* an unsigned integer */
808 GLuint Dimensions; /* 1 or 2 or 3 or 6 (cube map) */
809 GLfloat Priority; /* in [0,1] */
810 GLchan BorderColor[4];
811 GLenum WrapS; /* Wrap modes are: GL_CLAMP, REPEAT */
812 GLenum WrapT; /* GL_CLAMP_TO_EDGE, and */
813 GLenum WrapR; /* GL_CLAMP_TO_BORDER_ARB */
814 GLenum MinFilter; /* minification filter */
815 GLenum MagFilter; /* magnification filter */
816 GLfloat MinLod; /* min lambda, OpenGL 1.2 */
817 GLfloat MaxLod; /* max lambda, OpenGL 1.2 */
818 GLint BaseLevel; /* min mipmap level, OpenGL 1.2 */
819 GLint MaxLevel; /* max mipmap level, OpenGL 1.2 */
820 GLfloat MaxAnisotropy; /* GL_EXT_texture_filter_anisotropic */
821 GLboolean CompareFlag; /* GL_SGIX_shadow */
822 GLenum CompareOperator; /* GL_SGIX_shadow */
823 GLchan ShadowAmbient; /* GL_SGIX_shadow_ambient */
824 GLint _MaxLevel; /* actual max mipmap level (q in the spec) */
825 GLfloat _MaxLambda; /* = _MaxLevel - BaseLevel (q - b in spec) */
826 GLboolean GenerateMipmap; /* GL_SGIS_generate_mipmap */
827
828 struct gl_texture_image *Image[MAX_TEXTURE_LEVELS];
829
830 /* Texture cube faces */
831 /* Image[] is alias for *PosX[MAX_TEXTURE_LEVELS]; */
832 struct gl_texture_image *NegX[MAX_TEXTURE_LEVELS];
833 struct gl_texture_image *PosY[MAX_TEXTURE_LEVELS];
834 struct gl_texture_image *NegY[MAX_TEXTURE_LEVELS];
835 struct gl_texture_image *PosZ[MAX_TEXTURE_LEVELS];
836 struct gl_texture_image *NegZ[MAX_TEXTURE_LEVELS];
837
838 /* GL_EXT_paletted_texture */
839 struct gl_color_table Palette;
840
841 GLboolean Complete; /* Is texture object complete? */
842 struct gl_texture_object *Next; /* Next in linked list */
843
844 /* For device driver: */
845 void *DriverData; /* Arbitrary device driver data */
846 };
847
848
849
850 /*
851 * Texture units are new with the multitexture extension.
852 */
853 struct gl_texture_unit {
854 GLuint Enabled; /* bitmask of TEXTURE0_1D, _2D, _3D, _CUBE */
855 GLuint _ReallyEnabled; /* 0 or one of TEXTURE0_1D, _2D, _3D, _CUBE */
856
857 GLenum EnvMode; /* GL_MODULATE, GL_DECAL, GL_BLEND, etc. */
858 GLfloat EnvColor[4];
859 GLuint TexGenEnabled; /* Bitwise-OR of [STRQ]_BIT values */
860 GLenum GenModeS; /* Tex coord generation mode, either */
861 GLenum GenModeT; /* GL_OBJECT_LINEAR, or */
862 GLenum GenModeR; /* GL_EYE_LINEAR, or */
863 GLenum GenModeQ; /* GL_SPHERE_MAP */
864 GLuint _GenBitS;
865 GLuint _GenBitT;
866 GLuint _GenBitR;
867 GLuint _GenBitQ;
868 GLuint _GenFlags; /* bitwise or of GenBit[STRQ] */
869 GLfloat ObjectPlaneS[4];
870 GLfloat ObjectPlaneT[4];
871 GLfloat ObjectPlaneR[4];
872 GLfloat ObjectPlaneQ[4];
873 GLfloat EyePlaneS[4];
874 GLfloat EyePlaneT[4];
875 GLfloat EyePlaneR[4];
876 GLfloat EyePlaneQ[4];
877 GLfloat LodBias; /* for biasing mipmap levels */
878
879 /* GL_EXT_texture_env_combine */
880 GLenum CombineModeRGB; /* GL_REPLACE, GL_DECAL, GL_ADD, etc. */
881 GLenum CombineModeA; /* GL_REPLACE, GL_DECAL, GL_ADD, etc. */
882 GLenum CombineSourceRGB[3]; /* GL_PRIMARY_COLOR, GL_TEXTURE, etc. */
883 GLenum CombineSourceA[3]; /* GL_PRIMARY_COLOR, GL_TEXTURE, etc. */
884 GLenum CombineOperandRGB[3]; /* SRC_COLOR, ONE_MINUS_SRC_COLOR, etc */
885 GLenum CombineOperandA[3]; /* SRC_ALPHA, ONE_MINUS_SRC_ALPHA, etc */
886 GLuint CombineScaleShiftRGB; /* 0, 1 or 2 */
887 GLuint CombineScaleShiftA; /* 0, 1 or 2 */
888
889 struct gl_texture_object *Current1D;
890 struct gl_texture_object *Current2D;
891 struct gl_texture_object *Current3D;
892 struct gl_texture_object *CurrentCubeMap; /* GL_ARB_texture_cube_map */
893
894 struct gl_texture_object *_Current; /* Points to really enabled tex obj */
895
896 struct gl_texture_object Saved1D; /* only used by glPush/PopAttrib */
897 struct gl_texture_object Saved2D;
898 struct gl_texture_object Saved3D;
899 struct gl_texture_object SavedCubeMap;
900 };
901
902
903 struct gl_texture_attrib {
904 /* multitexture */
905 GLuint CurrentUnit; /* Active texture unit */
906 GLuint CurrentTransformUnit; /* Client active texture xform unit */
907
908 GLuint _ReallyEnabled; /* enables for all texture units: */
909 /* = (Unit[0]._ReallyEnabled << 0) | */
910 /* (Unit[1]._ReallyEnabled << 4) | */
911 /* (Unit[2]._ReallyEnabled << 8) | etc... */
912
913 GLuint _GenFlags; /* for texgen */
914 GLuint _TexGenEnabled;
915 GLuint _TexMatEnabled;
916
917 struct gl_texture_unit Unit[MAX_TEXTURE_UNITS];
918
919 struct gl_texture_object *Proxy1D;
920 struct gl_texture_object *Proxy2D;
921 struct gl_texture_object *Proxy3D;
922 struct gl_texture_object *ProxyCubeMap;
923
924 /* GL_EXT_shared_texture_palette */
925 GLboolean SharedPalette;
926 struct gl_color_table Palette;
927 };
928
929
930 struct gl_transform_attrib {
931 GLenum MatrixMode; /* Matrix mode */
932 GLfloat EyeUserPlane[MAX_CLIP_PLANES][4];
933 GLfloat _ClipUserPlane[MAX_CLIP_PLANES][4]; /* derived */
934 GLboolean ClipEnabled[MAX_CLIP_PLANES];
935 GLubyte _AnyClip; /* How many ClipEnabled? */
936 GLboolean Normalize; /* Normalize all normals? */
937 GLboolean RescaleNormals; /* GL_EXT_rescale_normal */
938 };
939
940
941 struct gl_viewport_attrib {
942 GLint X, Y; /* position */
943 GLsizei Width, Height; /* size */
944 GLfloat Near, Far; /* Depth buffer range */
945 GLmatrix _WindowMap; /* Mapping transformation as a matrix. */
946 };
947
948
949 /* For the attribute stack: */
950 struct gl_attrib_node {
951 GLbitfield kind;
952 void *data;
953 struct gl_attrib_node *next;
954 };
955
956
957 /*
958 * Client pixel packing/unpacking attributes
959 */
960 struct gl_pixelstore_attrib {
961 GLint Alignment;
962 GLint RowLength;
963 GLint SkipPixels;
964 GLint SkipRows;
965 GLint ImageHeight; /* for GL_EXT_texture3D */
966 GLint SkipImages; /* for GL_EXT_texture3D */
967 GLboolean SwapBytes;
968 GLboolean LsbFirst;
969 };
970
971
972 #define CA_CLIENT_DATA 0x1 /* Data not alloced by mesa */
973
974
975 /*
976 * Client vertex array attributes
977 */
978 struct gl_client_array {
979 GLint Size;
980 GLenum Type;
981 GLsizei Stride; /* user-specified stride */
982 GLsizei StrideB; /* actual stride in bytes */
983 void *Ptr;
984 GLuint Flags;
985 GLboolean Enabled;
986 };
987
988
989 struct gl_array_attrib {
990 struct gl_client_array Vertex; /* client data descriptors */
991 struct gl_client_array Normal;
992 struct gl_client_array Color;
993 struct gl_client_array SecondaryColor;
994 struct gl_client_array FogCoord;
995 struct gl_client_array Index;
996 struct gl_client_array TexCoord[MAX_TEXTURE_UNITS];
997 struct gl_client_array EdgeFlag;
998
999 GLint TexCoordInterleaveFactor;
1000 GLint ActiveTexture; /* Client Active Texture */
1001 GLuint LockFirst;
1002 GLuint LockCount;
1003
1004 GLuint _Enabled; /* _NEW_ARRAY_* - bit set if array enabled */
1005 GLuint NewState; /* _NEW_ARRAY_* */
1006 };
1007
1008
1009 struct gl_feedback {
1010 GLenum Type;
1011 GLuint _Mask; /* FB_* bits */
1012 GLfloat *Buffer;
1013 GLuint BufferSize;
1014 GLuint Count;
1015 };
1016
1017
1018 struct gl_selection {
1019 GLuint *Buffer;
1020 GLuint BufferSize; /* size of SelectBuffer */
1021 GLuint BufferCount; /* number of values in SelectBuffer */
1022 GLuint Hits; /* number of records in SelectBuffer */
1023 GLuint NameStackDepth;
1024 GLuint NameStack[MAX_NAME_STACK_DEPTH];
1025 GLboolean HitFlag;
1026 GLfloat HitMinZ, HitMaxZ;
1027 };
1028
1029
1030 /*
1031 * 1-D Evaluator control points
1032 */
1033 struct gl_1d_map {
1034 GLuint Order; /* Number of control points */
1035 GLfloat u1, u2, du; /* u1, u2, 1.0/(u2-u1) */
1036 GLfloat *Points; /* Points to contiguous control points */
1037 };
1038
1039
1040 /*
1041 * 2-D Evaluator control points
1042 */
1043 struct gl_2d_map {
1044 GLuint Uorder; /* Number of control points in U dimension */
1045 GLuint Vorder; /* Number of control points in V dimension */
1046 GLfloat u1, u2, du;
1047 GLfloat v1, v2, dv;
1048 GLfloat *Points; /* Points to contiguous control points */
1049 };
1050
1051
1052 /*
1053 * All evalutator control points
1054 */
1055 struct gl_evaluators {
1056 /* 1-D maps */
1057 struct gl_1d_map Map1Vertex3;
1058 struct gl_1d_map Map1Vertex4;
1059 struct gl_1d_map Map1Index;
1060 struct gl_1d_map Map1Color4;
1061 struct gl_1d_map Map1Normal;
1062 struct gl_1d_map Map1Texture1;
1063 struct gl_1d_map Map1Texture2;
1064 struct gl_1d_map Map1Texture3;
1065 struct gl_1d_map Map1Texture4;
1066
1067 /* 2-D maps */
1068 struct gl_2d_map Map2Vertex3;
1069 struct gl_2d_map Map2Vertex4;
1070 struct gl_2d_map Map2Index;
1071 struct gl_2d_map Map2Color4;
1072 struct gl_2d_map Map2Normal;
1073 struct gl_2d_map Map2Texture1;
1074 struct gl_2d_map Map2Texture2;
1075 struct gl_2d_map Map2Texture3;
1076 struct gl_2d_map Map2Texture4;
1077 };
1078
1079
1080 /*
1081 * State which can be shared by multiple contexts:
1082 */
1083 struct gl_shared_state {
1084 _glthread_Mutex Mutex; /* for thread safety */
1085 GLint RefCount; /* Reference count */
1086 struct _mesa_HashTable *DisplayList; /* Display lists hash table */
1087 struct _mesa_HashTable *TexObjects; /* Texture objects hash table */
1088 struct gl_texture_object *TexObjectList;/* Linked list of texture objects */
1089
1090 /* Default texture objects (shared by all multi-texture units) */
1091 struct gl_texture_object *Default1D;
1092 struct gl_texture_object *Default2D;
1093 struct gl_texture_object *Default3D;
1094 struct gl_texture_object *DefaultCubeMap;
1095
1096 void *DriverData; /* Device driver shared state */
1097 };
1098
1099
1100 /*
1101 * A "frame buffer" is a color buffer and its optional ancillary buffers:
1102 * depth, accum, stencil, and software-simulated alpha buffers.
1103 * In C++ terms, think of this as a base class from which device drivers
1104 * will make derived classes.
1105 */
1106 struct gl_frame_buffer {
1107 GLvisual Visual; /* The corresponding visual */
1108
1109 GLint Width, Height; /* size of frame buffer in pixels */
1110
1111 GLboolean UseSoftwareDepthBuffer;
1112 GLboolean UseSoftwareAccumBuffer;
1113 GLboolean UseSoftwareStencilBuffer;
1114 GLboolean UseSoftwareAlphaBuffers;
1115
1116 /* Software depth (aka Z) buffer */
1117 GLvoid *DepthBuffer; /* array [Width*Height] of GLushort or GLuint*/
1118
1119 /* Software stencil buffer */
1120 GLstencil *Stencil; /* array [Width*Height] of GLstencil values */
1121
1122 /* Software accumulation buffer */
1123 GLaccum *Accum; /* array [4*Width*Height] of GLaccum values */
1124
1125 /* Software alpha planes */
1126 GLchan *FrontLeftAlpha; /* array [Width*Height] of GLubyte */
1127 GLchan *BackLeftAlpha; /* array [Width*Height] of GLubyte */
1128 GLchan *FrontRightAlpha; /* array [Width*Height] of GLubyte */
1129 GLchan *BackRightAlpha; /* array [Width*Height] of GLubyte */
1130 GLchan *Alpha; /* Points to current alpha buffer */
1131
1132 /* Drawing bounds: intersection of window size and scissor box */
1133 GLint _Xmin, _Ymin; /* inclusive */
1134 GLint _Xmax, _Ymax; /* exclusive */
1135 };
1136
1137
1138 /*
1139 * Constants which may be overriden by device driver during context creation
1140 * but are never changed after that.
1141 */
1142 struct gl_constants {
1143 GLint MaxTextureSize;
1144 GLint MaxCubeTextureSize;
1145 GLint MaxTextureLevels;
1146 GLuint MaxTextureUnits;
1147 GLfloat MaxTextureMaxAnisotropy; /* GL_EXT_texture_filter_anisotropic */
1148 GLuint MaxArrayLockSize;
1149 GLint SubPixelBits;
1150 GLfloat MinPointSize, MaxPointSize; /* aliased */
1151 GLfloat MinPointSizeAA, MaxPointSizeAA; /* antialiased */
1152 GLfloat PointSizeGranularity;
1153 GLfloat MinLineWidth, MaxLineWidth; /* aliased */
1154 GLfloat MinLineWidthAA, MaxLineWidthAA; /* antialiased */
1155 GLfloat LineWidthGranularity;
1156 GLuint NumAuxBuffers;
1157 GLuint MaxColorTableSize;
1158 GLuint MaxConvolutionWidth;
1159 GLuint MaxConvolutionHeight;
1160 GLuint NumCompressedTextureFormats; /* GL_ARB_texture_compression */
1161 GLenum CompressedTextureFormats[MAX_COMPRESSED_TEXTURE_FORMATS];
1162 GLuint MaxClipPlanes;
1163 GLuint MaxLights;
1164 };
1165
1166
1167 /*
1168 * List of extensions.
1169 */
1170 struct extension;
1171 struct gl_extensions {
1172 char *ext_string;
1173 struct extension *ext_list;
1174 /* Flags to quickly test if certain extensions are available.
1175 * Not every extension needs to have such a flag, but it's encouraged.
1176 */
1177 GLboolean ARB_imaging;
1178 GLboolean ARB_multitexture;
1179 GLboolean ARB_texture_border_clamp;
1180 GLboolean ARB_texture_compression;
1181 GLboolean ARB_texture_cube_map;
1182 GLboolean ARB_texture_env_combine;
1183 GLboolean ARB_texture_env_dot3;
1184 GLboolean EXT_blend_color;
1185 GLboolean EXT_blend_func_separate;
1186 GLboolean EXT_blend_logic_op;
1187 GLboolean EXT_blend_minmax;
1188 GLboolean EXT_blend_subtract;
1189 GLboolean EXT_clip_volume_hint;
1190 GLboolean EXT_convolution;
1191 GLboolean EXT_compiled_vertex_array;
1192 GLboolean EXT_fog_coord;
1193 GLboolean EXT_histogram;
1194 GLboolean EXT_packed_pixels;
1195 GLboolean EXT_paletted_texture;
1196 GLboolean EXT_point_parameters;
1197 GLboolean EXT_polygon_offset;
1198 GLboolean EXT_rescale_normal;
1199 GLboolean EXT_secondary_color;
1200 GLboolean EXT_shared_texture_palette;
1201 GLboolean EXT_stencil_wrap;
1202 GLboolean EXT_texture3D;
1203 GLboolean EXT_texture_compression_s3tc;
1204 GLboolean EXT_texture_env_add;
1205 GLboolean EXT_texture_env_combine;
1206 GLboolean EXT_texture_env_dot3;
1207 GLboolean EXT_texture_filter_anisotropic;
1208 GLboolean EXT_texture_object;
1209 GLboolean EXT_texture_lod_bias;
1210 GLboolean EXT_vertex_array_set;
1211 GLboolean HP_occlusion_test;
1212 GLboolean INGR_blend_func_separate;
1213 GLboolean MESA_window_pos;
1214 GLboolean MESA_resize_buffers;
1215 GLboolean MESA_sprite_point;
1216 GLboolean NV_blend_square;
1217 GLboolean NV_texgen_reflection;
1218 GLboolean SGI_color_matrix;
1219 GLboolean SGI_color_table;
1220 GLboolean SGIS_generate_mipmap;
1221 GLboolean SGIS_pixel_texture;
1222 GLboolean SGIS_texture_edge_clamp;
1223 GLboolean SGIX_depth_texture;
1224 GLboolean SGIX_pixel_texture;
1225 GLboolean SGIX_shadow;
1226 GLboolean SGIX_shadow_ambient;
1227 GLboolean _3DFX_texture_compression_FXT1;
1228 };
1229
1230
1231
1232 /*
1233 * Bits for image transfer operations (ctx->ImageTransferState).
1234 */
1235 #define IMAGE_SCALE_BIAS_BIT 0x1
1236 #define IMAGE_SHIFT_OFFSET_BIT 0x2
1237 #define IMAGE_MAP_COLOR_BIT 0x4
1238 #define IMAGE_COLOR_TABLE_BIT 0x8
1239 #define IMAGE_CONVOLUTION_BIT 0x10
1240 #define IMAGE_POST_CONVOLUTION_SCALE_BIAS 0x20
1241 #define IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT 0x40
1242 #define IMAGE_COLOR_MATRIX_BIT 0x80
1243 #define IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT 0x100
1244 #define IMAGE_HISTOGRAM_BIT 0x200
1245 #define IMAGE_MIN_MAX_BIT 0x400
1246
1247 /* transfer ops up to convolution: */
1248 #define IMAGE_PRE_CONVOLUTION_BITS (IMAGE_SCALE_BIAS_BIT | \
1249 IMAGE_SHIFT_OFFSET_BIT | \
1250 IMAGE_MAP_COLOR_BIT | \
1251 IMAGE_COLOR_TABLE_BIT)
1252
1253 /* transfer ops after convolution: */
1254 #define IMAGE_POST_CONVOLUTION_BITS (IMAGE_POST_CONVOLUTION_SCALE_BIAS | \
1255 IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT | \
1256 IMAGE_COLOR_MATRIX_BIT | \
1257 IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT |\
1258 IMAGE_HISTOGRAM_BIT | \
1259 IMAGE_MIN_MAX_BIT)
1260
1261
1262 /*
1263 * Bits to indicate what state has changed. 6 unused flags.
1264 */
1265 #define _NEW_MODELVIEW 0x1 /* ctx->ModelView */
1266 #define _NEW_PROJECTION 0x2 /* ctx->Projection */
1267 #define _NEW_TEXTURE_MATRIX 0x4 /* ctx->TextureMatrix */
1268 #define _NEW_COLOR_MATRIX 0x8 /* ctx->ColorMatrix */
1269 #define _NEW_ACCUM 0x10 /* ctx->Accum */
1270 #define _NEW_COLOR 0x20 /* ctx->Color */
1271 #define _NEW_DEPTH 0x40 /* ctx->Depth */
1272 #define _NEW_EVAL 0x80 /* ctx->Eval, ctx->EvalMap */
1273 #define _NEW_FOG 0x100 /* ctx->Fog */
1274 #define _NEW_HINT 0x200 /* ctx->Hint */
1275 #define _NEW_LIGHT 0x400 /* ctx->Light */
1276 #define _NEW_LINE 0x800 /* ctx->Line */
1277 #define _NEW_PIXEL 0x1000 /* ctx->Pixel */
1278 #define _NEW_POINT 0x2000 /* ctx->Point */
1279 #define _NEW_POLYGON 0x4000 /* ctx->Polygon */
1280 #define _NEW_POLYGONSTIPPLE 0x8000 /* ctx->PolygonStipple */
1281 #define _NEW_SCISSOR 0x10000 /* ctx->Scissor */
1282 #define _NEW_STENCIL 0x20000 /* ctx->Stencil */
1283 #define _NEW_TEXTURE 0x40000 /* ctx->Texture */
1284 #define _NEW_TRANSFORM 0x80000 /* ctx->Transform */
1285 #define _NEW_VIEWPORT 0x100000 /* ctx->Viewport */
1286 #define _NEW_PACKUNPACK 0x200000 /* ctx->Pack, ctx->Unpack */
1287 #define _NEW_ARRAY 0x400000 /* ctx->Array */
1288 #define _NEW_RENDERMODE 0x800000 /* RenderMode, Feedback, Select */
1289 #define _NEW_BUFFERS 0x1000000 /* ctx->Visual, ctx->DrawBuffer, */
1290
1291 #define _NEW_ALL ~0
1292
1293
1294
1295 /* Bits to track array state changes (also used to summarize array enabled)
1296 */
1297 #define _NEW_ARRAY_VERTEX 0x1
1298 #define _NEW_ARRAY_COLOR 0x2
1299 #define _NEW_ARRAY_NORMAL 0x4
1300 #define _NEW_ARRAY_INDEX 0x8
1301 #define _NEW_ARRAY_EDGEFLAG 0x10
1302 #define _NEW_ARRAY_SECONDARYCOLOR 0x20
1303 #define _NEW_ARRAY_FOGCOORD 0x40
1304 #define _NEW_ARRAY_TEXCOORD_0 0x80
1305 #define _NEW_ARRAY_TEXCOORD_1 0x100
1306 #define _NEW_ARRAY_TEXCOORD_2 0x200
1307 #define _NEW_ARRAY_TEXCOORD_3 0x400
1308 #define _NEW_ARRAY_TEXCOORD_4 0x800
1309 #define _NEW_ARRAY_TEXCOORD_5 0x1000
1310 #define _NEW_ARRAY_TEXCOORD_6 0x2000
1311 #define _NEW_ARRAY_TEXCOORD_7 0x4000
1312 #define _NEW_ARRAY_ALL 0x7fff
1313
1314 #define _NEW_ARRAY_TEXCOORD(i) (_NEW_ARRAY_TEXCOORD_0 << (i))
1315
1316 /* A bunch of flags that we think might be useful to drivers.
1317 */
1318 #define DD_FLATSHADE 0x1
1319 #define DD_SEPARATE_SPECULAR 0x2
1320 #define DD_TRI_CULL_FRONT_BACK 0x4 /* special case on some hw */
1321 #define DD_TRI_LIGHT_TWOSIDE 0x8
1322 #define DD_TRI_UNFILLED 0x10
1323 #define DD_TRI_SMOOTH 0x20
1324 #define DD_TRI_STIPPLE 0x40
1325 #define DD_TRI_OFFSET 0x80
1326 #define DD_LINE_SMOOTH 0x100
1327 #define DD_LINE_STIPPLE 0x200
1328 #define DD_LINE_WIDTH 0x400
1329 #define DD_POINT_SMOOTH 0x800
1330 #define DD_POINT_SIZE 0x1000
1331 #define DD_POINT_ATTEN 0x2000
1332
1333 /* Define the state changes under which each of these bits might change
1334 */
1335 #define _DD_NEW_FLATSHADE _NEW_LIGHT
1336 #define _DD_NEW_SEPARATE_SPECULAR (_NEW_LIGHT | _NEW_FOG)
1337 #define _DD_NEW_TRI_CULL_FRONT_BACK _NEW_POLYGON
1338 #define _DD_NEW_TRI_LIGHT_TWOSIDE _NEW_LIGHT
1339 #define _DD_NEW_TRI_UNFILLED _NEW_POLYGON
1340 #define _DD_NEW_TRI_SMOOTH _NEW_POLYGON
1341 #define _DD_NEW_TRI_STIPPLE _NEW_POLYGON
1342 #define _DD_NEW_TRI_OFFSET _NEW_POLYGON
1343 #define _DD_NEW_LINE_SMOOTH _NEW_LINE
1344 #define _DD_NEW_LINE_STIPPLE _NEW_LINE
1345 #define _DD_NEW_LINE_WIDTH _NEW_LINE
1346 #define _DD_NEW_POINT_SMOOTH _NEW_POINT
1347 #define _DD_NEW_POINT_SIZE _NEW_POINT
1348 #define _DD_NEW_POINT_ATTEN _NEW_POINT
1349
1350 #define _MESA_NEW_NEED_EYE_COORDS (_NEW_LIGHT | \
1351 _NEW_TEXTURE | \
1352 _NEW_POINT | \
1353 _NEW_MODELVIEW)
1354
1355 #define _MESA_NEW_NEED_NORMALS (_NEW_LIGHT | \
1356 _NEW_TEXTURE)
1357
1358 #define _IMAGE_NEW_TRANSFER_STATE (_NEW_PIXEL | _NEW_COLOR_MATRIX)
1359
1360
1361 #define NEED_NORMALS_TEXGEN 0x1
1362 #define NEED_NORMALS_LIGHT 0x2
1363
1364 #define NEED_EYE_TEXGEN 0x1
1365 #define NEED_EYE_LIGHT 0x2
1366 #define NEED_EYE_LIGHT_MODELVIEW 0x4
1367 #define NEED_EYE_POINT_ATTEN 0x8
1368
1369
1370 /*
1371 * Forward declaration of display list datatypes:
1372 */
1373 union node;
1374 typedef union node Node;
1375
1376
1377 /* This has to be included here. */
1378 #include "dd.h"
1379
1380
1381 /*
1382 * Core Mesa's support for tnl modules:
1383 */
1384 #define NUM_VERTEX_FORMAT_ENTRIES (sizeof(GLvertexformat) / sizeof(void *))
1385
1386 struct gl_tnl_module {
1387 /* Vertex format to be lazily swapped into current dispatch.
1388 */
1389 GLvertexformat *Current;
1390
1391 /* Record of functions swapped out. On restore, only need to swap
1392 * these functions back in.
1393 */
1394 void *Swapped[NUM_VERTEX_FORMAT_ENTRIES][2];
1395 GLuint SwapCount;
1396 };
1397
1398
1399 /*
1400 * The library context:
1401 */
1402 struct __GLcontextRec {
1403 /*
1404 ** Os related interfaces; these *must* be the first members of this
1405 ** structure, because they are exposed to the outside world (i.e. GLX
1406 ** extension).
1407 */
1408 __GLimports imports;
1409 __GLexports exports;
1410
1411 /* State possibly shared with other contexts in the address space */
1412 struct gl_shared_state *Shared;
1413
1414 /* API function pointer tables */
1415 struct _glapi_table *Save; /* Display list save funcs */
1416 struct _glapi_table *Exec; /* Execute funcs */
1417 struct _glapi_table *CurrentDispatch; /* == Save or Exec !! */
1418
1419 GLboolean ExecPrefersFloat; /* What preference for color conversion? */
1420 GLboolean SavePrefersFloat;
1421
1422 GLvisual Visual;
1423 GLframebuffer *DrawBuffer; /* buffer for writing */
1424 GLframebuffer *ReadBuffer; /* buffer for reading */
1425
1426 /* Driver function pointer table */
1427 struct dd_function_table Driver;
1428
1429 void *DriverCtx; /* Points to device driver context/state */
1430 void *DriverMgrCtx; /* Points to device driver manager (optional)*/
1431
1432 /* Core/Driver constants */
1433 struct gl_constants Const;
1434
1435 /* Modelview matrix and stack */
1436 GLmatrix ModelView; /* current matrix, not stored on stack */
1437 GLuint ModelViewStackDepth;
1438 GLmatrix ModelViewStack[MAX_MODELVIEW_STACK_DEPTH - 1];
1439
1440 /* Projection matrix and stack */
1441 GLmatrix ProjectionMatrix; /* current matrix, not stored on stack */
1442 GLuint ProjectionStackDepth;
1443 GLmatrix ProjectionStack[MAX_PROJECTION_STACK_DEPTH - 1];
1444
1445 /* Combined modelview and projection matrix */
1446 GLmatrix _ModelProjectMatrix;
1447
1448 /* Texture matrix and stack */
1449 GLmatrix TextureMatrix[MAX_TEXTURE_UNITS];
1450 GLuint TextureStackDepth[MAX_TEXTURE_UNITS];
1451 GLmatrix TextureStack[MAX_TEXTURE_UNITS][MAX_TEXTURE_STACK_DEPTH - 1];
1452
1453 /* Color matrix and stack */
1454 GLmatrix ColorMatrix;
1455 GLuint ColorStackDepth;
1456 GLmatrix ColorStack[MAX_COLOR_STACK_DEPTH - 1];
1457
1458 /* Display lists */
1459 GLuint CallDepth; /* Current recursion calling depth */
1460 GLboolean ExecuteFlag; /* Execute GL commands? */
1461 GLboolean CompileFlag; /* Compile GL commands into display list? */
1462 Node *CurrentListPtr; /* Head of list being compiled */
1463 GLuint CurrentListNum; /* Number of the list being compiled */
1464 Node *CurrentBlock; /* Pointer to current block of nodes */
1465 GLuint CurrentPos; /* Index into current block of nodes */
1466
1467 /* Extensions */
1468 struct gl_extensions Extensions;
1469
1470 /* Renderer attribute stack */
1471 GLuint AttribStackDepth;
1472 struct gl_attrib_node *AttribStack[MAX_ATTRIB_STACK_DEPTH];
1473
1474 /* Renderer attribute groups */
1475 struct gl_accum_attrib Accum;
1476 struct gl_colorbuffer_attrib Color;
1477 struct gl_current_attrib Current;
1478 struct gl_depthbuffer_attrib Depth;
1479 struct gl_eval_attrib Eval;
1480 struct gl_fog_attrib Fog;
1481 struct gl_hint_attrib Hint;
1482 struct gl_light_attrib Light;
1483 struct gl_line_attrib Line;
1484 struct gl_list_attrib List;
1485 struct gl_pixel_attrib Pixel;
1486 struct gl_point_attrib Point;
1487 struct gl_polygon_attrib Polygon;
1488 GLuint PolygonStipple[32];
1489 struct gl_scissor_attrib Scissor;
1490 struct gl_stencil_attrib Stencil;
1491 struct gl_texture_attrib Texture;
1492 struct gl_transform_attrib Transform;
1493 struct gl_viewport_attrib Viewport;
1494
1495 /* Other attribute groups */
1496 struct gl_histogram_attrib Histogram;
1497 struct gl_minmax_attrib MinMax;
1498 struct gl_convolution_attrib Convolution1D;
1499 struct gl_convolution_attrib Convolution2D;
1500 struct gl_convolution_attrib Separable2D;
1501
1502 /* Client attribute stack */
1503 GLuint ClientAttribStackDepth;
1504 struct gl_attrib_node *ClientAttribStack[MAX_CLIENT_ATTRIB_STACK_DEPTH];
1505
1506 /* Client attribute groups */
1507 struct gl_array_attrib Array; /* Vertex arrays */
1508 struct gl_pixelstore_attrib Pack; /* Pixel packing */
1509 struct gl_pixelstore_attrib Unpack; /* Pixel unpacking */
1510
1511 struct gl_evaluators EvalMap; /* All evaluators */
1512 struct gl_feedback Feedback; /* Feedback */
1513 struct gl_selection Select; /* Selection */
1514
1515 struct gl_color_table ColorTable; /* Pre-convolution */
1516 struct gl_color_table ProxyColorTable; /* Pre-convolution */
1517 struct gl_color_table PostConvolutionColorTable;
1518 struct gl_color_table ProxyPostConvolutionColorTable;
1519 struct gl_color_table PostColorMatrixColorTable;
1520 struct gl_color_table ProxyPostColorMatrixColorTable;
1521
1522 GLenum ErrorValue; /* Last error code */
1523 GLenum RenderMode; /* either GL_RENDER, GL_SELECT, GL_FEEDBACK */
1524 GLuint NewState; /* bitwise-or of _NEW_* flags */
1525
1526 /* Derived */
1527 GLuint _TriangleCaps; /* bitwise-or of DD_* flags */
1528 GLuint _ImageTransferState;/* bitwise-or of IMAGE_*_BIT flags */
1529 GLfloat _EyeZDir[3];
1530 GLfloat _ModelViewInvScale;
1531 GLuint _NeedEyeCoords;
1532 GLuint _NeedNormals; /* Are vertex normal vectors needed? */
1533
1534 struct gl_shine_tab *_ShineTable[2]; /* Active shine tables */
1535 struct gl_shine_tab *_ShineTabList; /* Mru list of inactive shine tables */
1536
1537 struct gl_list_extensions listext; /* driver dlist extensions */
1538
1539
1540 GLboolean OcclusionResult; /* GL_HP_occlusion_test */
1541 GLboolean OcclusionResultSaved; /* GL_HP_occlusion_test */
1542
1543 /* Z buffer stuff */
1544 GLuint DepthMax; /* Max depth buffer value */
1545 GLfloat DepthMaxF; /* Float max depth buffer value */
1546 GLfloat MRD; /* minimum resolvable difference in Z values */
1547
1548 /* Should 3Dfx Glide driver catch signals? */
1549 GLboolean CatchSignals;
1550
1551 /* For debugging/development only */
1552 GLboolean NoRaster;
1553 GLboolean FirstTimeCurrent;
1554
1555 /* Dither disable via MESA_NO_DITHER env var */
1556 GLboolean NoDither;
1557
1558 GLboolean Rendering;
1559
1560 #if defined(MESA_TRACE)
1561 struct _glapi_table *TraceDispatch;
1562 trace_context_t *TraceCtx;
1563 #else
1564 void *TraceDispatch;
1565 void *TraceCtx;
1566 #endif
1567
1568 /* Core tnl module support */
1569 struct gl_tnl_module TnlModule;
1570
1571 /* Hooks for module contexts. These will eventually live
1572 * in the driver or elsewhere.
1573 */
1574 void *swrast_context;
1575 void *swsetup_context;
1576 void *swtnl_context;
1577 void *swtnl_im;
1578 void *acache_context;
1579 void *aelt_context;
1580 };
1581
1582
1583 /* The string names for GL_POINT, GL_LINE_LOOP, etc */
1584 extern const char *_mesa_prim_name[GL_POLYGON+4];
1585
1586
1587 #ifdef MESA_DEBUG
1588 extern int MESA_VERBOSE;
1589 extern int MESA_DEBUG_FLAGS;
1590 #else
1591 # define MESA_VERBOSE 0
1592 # define MESA_DEBUG_FLAGS 0
1593 # ifndef NDEBUG
1594 # define NDEBUG
1595 # endif
1596 #endif
1597
1598
1599 enum _verbose {
1600 VERBOSE_VARRAY = 0x0001,
1601 VERBOSE_TEXTURE = 0x0002,
1602 VERBOSE_IMMEDIATE = 0x0004,
1603 VERBOSE_PIPELINE = 0x0008,
1604 VERBOSE_DRIVER = 0x0010,
1605 VERBOSE_STATE = 0x0020,
1606 VERBOSE_API = 0x0040,
1607 VERBOSE_DISPLAY_LIST = 0x0200,
1608 VERBOSE_LIGHTING = 0x0400
1609 };
1610
1611
1612 enum _debug {
1613 DEBUG_ALWAYS_FLUSH = 0x1
1614 };
1615
1616
1617
1618 #define Elements(x) sizeof(x)/sizeof(*(x))
1619
1620
1621
1622 /* Eventually let the driver specify what statechanges require a flush:
1623 */
1624 #define FLUSH_VERTICES(ctx, newstate) \
1625 do { \
1626 if (ctx->Driver.NeedFlush & FLUSH_STORED_VERTICES) \
1627 ctx->Driver.FlushVertices(ctx, FLUSH_STORED_VERTICES); \
1628 ctx->NewState |= newstate; \
1629 } while (0)
1630
1631 #define FLUSH_CURRENT(ctx, newstate) \
1632 do { \
1633 if (ctx->Driver.NeedFlush & FLUSH_UPDATE_CURRENT) \
1634 ctx->Driver.FlushVertices(ctx, FLUSH_UPDATE_CURRENT); \
1635 ctx->NewState |= newstate; \
1636 } while (0)
1637
1638 #define ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, retval) \
1639 do { \
1640 if (ctx->Driver.CurrentExecPrimitive != PRIM_OUTSIDE_BEGIN_END) { \
1641 _mesa_error( ctx, GL_INVALID_OPERATION, "begin/end" ); \
1642 return retval; \
1643 } \
1644 } while (0)
1645
1646 #define ASSERT_OUTSIDE_BEGIN_END(ctx) \
1647 do { \
1648 if (ctx->Driver.CurrentExecPrimitive != PRIM_OUTSIDE_BEGIN_END) { \
1649 _mesa_error( ctx, GL_INVALID_OPERATION, "begin/end" ); \
1650 return; \
1651 } \
1652 } while (0)
1653
1654 #define ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx) \
1655 do { \
1656 ASSERT_OUTSIDE_BEGIN_END(ctx); \
1657 FLUSH_VERTICES(ctx, 0); \
1658 } while (0)
1659
1660 #define ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH_WITH_RETVAL(ctx, retval) \
1661 do { \
1662 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, retval); \
1663 FLUSH_VERTICES(ctx, 0); \
1664 } while (0)
1665
1666
1667
1668
1669 #endif /* TYPES_H */