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