changed a warning string
[mesa.git] / src / mesa / main / texstate.c
1 /* $Id: texstate.c,v 1.5 1999/11/11 01:22:28 brianp Exp $ */
2
3 /*
4 * Mesa 3-D graphics library
5 * Version: 3.3
6 *
7 * Copyright (C) 1999 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 #ifdef PC_HEADER
29 #include "all.h"
30 #else
31 #include "glheader.h"
32 #include "context.h"
33 #include "enums.h"
34 #include "macros.h"
35 #include "matrix.h"
36 #include "texobj.h"
37 #include "texstate.h"
38 #include "texture.h"
39 #include "types.h"
40 #include "xform.h"
41 #endif
42
43
44
45 #ifdef SPECIALCAST
46 /* Needed for an Amiga compiler */
47 #define ENUM_TO_FLOAT(X) ((GLfloat)(GLint)(X))
48 #define ENUM_TO_DOUBLE(X) ((GLdouble)(GLint)(X))
49 #else
50 /* all other compilers */
51 #define ENUM_TO_FLOAT(X) ((GLfloat)(X))
52 #define ENUM_TO_DOUBLE(X) ((GLdouble)(X))
53 #endif
54
55
56
57
58 /**********************************************************************/
59 /* Texture Environment */
60 /**********************************************************************/
61
62
63 void
64 _mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param )
65 {
66 GET_CURRENT_CONTEXT(ctx);
67 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
68
69 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glTexEnv");
70
71 if (target!=GL_TEXTURE_ENV) {
72 gl_error( ctx, GL_INVALID_ENUM, "glTexEnv(target)" );
73 return;
74 }
75
76 if (MESA_VERBOSE&(VERBOSE_API|VERBOSE_TEXTURE))
77 fprintf(stderr, "glTexEnv %s %s %.1f(%s) ...\n",
78 gl_lookup_enum_by_nr(target),
79 gl_lookup_enum_by_nr(pname),
80 *param,
81 gl_lookup_enum_by_nr((GLenum) (GLint) *param));
82
83
84 if (pname==GL_TEXTURE_ENV_MODE) {
85 GLenum mode = (GLenum) (GLint) *param;
86 switch (mode) {
87 case GL_MODULATE:
88 case GL_BLEND:
89 case GL_DECAL:
90 case GL_REPLACE:
91 /* A small optimization for drivers */
92 if (texUnit->EnvMode == mode)
93 return;
94
95 if (MESA_VERBOSE & (VERBOSE_STATE|VERBOSE_TEXTURE))
96 fprintf(stderr, "glTexEnv: old mode %s, new mode %s\n",
97 gl_lookup_enum_by_nr(texUnit->EnvMode),
98 gl_lookup_enum_by_nr(mode));
99
100 texUnit->EnvMode = mode;
101 ctx->NewState |= NEW_TEXTURE_ENV;
102 break;
103 default:
104 gl_error( ctx, GL_INVALID_VALUE, "glTexEnv(param)" );
105 return;
106 }
107 }
108 else if (pname==GL_TEXTURE_ENV_COLOR) {
109 texUnit->EnvColor[0] = CLAMP( param[0], 0.0F, 1.0F );
110 texUnit->EnvColor[1] = CLAMP( param[1], 0.0F, 1.0F );
111 texUnit->EnvColor[2] = CLAMP( param[2], 0.0F, 1.0F );
112 texUnit->EnvColor[3] = CLAMP( param[3], 0.0F, 1.0F );
113 }
114 else {
115 gl_error( ctx, GL_INVALID_ENUM, "glTexEnv(pname)" );
116 return;
117 }
118
119 /* Tell device driver about the new texture environment */
120 if (ctx->Driver.TexEnv) {
121 (*ctx->Driver.TexEnv)( ctx, pname, param );
122 }
123 }
124
125
126 void
127 _mesa_TexEnvf( GLenum target, GLenum pname, GLfloat param )
128 {
129 _mesa_TexEnvfv( target, pname, &param );
130 }
131
132
133
134 void
135 _mesa_TexEnvi( GLenum target, GLenum pname, GLint param )
136 {
137 GLfloat p[4];
138 p[0] = (GLfloat) param;
139 p[1] = p[2] = p[3] = 0.0;
140 _mesa_TexEnvfv( target, pname, p );
141 }
142
143
144 void
145 _mesa_TexEnviv( GLenum target, GLenum pname, const GLint *param )
146 {
147 GLfloat p[4];
148 p[0] = INT_TO_FLOAT( param[0] );
149 p[1] = INT_TO_FLOAT( param[1] );
150 p[2] = INT_TO_FLOAT( param[2] );
151 p[3] = INT_TO_FLOAT( param[3] );
152 _mesa_TexEnvfv( target, pname, p );
153 }
154
155
156 void
157 _mesa_GetTexEnvfv( GLenum target, GLenum pname, GLfloat *params )
158 {
159 GET_CURRENT_CONTEXT(ctx);
160 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
161 if (target!=GL_TEXTURE_ENV) {
162 gl_error( ctx, GL_INVALID_ENUM, "glGetTexEnvfv(target)" );
163 return;
164 }
165 switch (pname) {
166 case GL_TEXTURE_ENV_MODE:
167 *params = ENUM_TO_FLOAT(texUnit->EnvMode);
168 break;
169 case GL_TEXTURE_ENV_COLOR:
170 COPY_4FV( params, texUnit->EnvColor );
171 break;
172 default:
173 gl_error( ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)" );
174 }
175 }
176
177
178 void
179 _mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params )
180 {
181 GET_CURRENT_CONTEXT(ctx);
182 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
183 if (target!=GL_TEXTURE_ENV) {
184 gl_error( ctx, GL_INVALID_ENUM, "glGetTexEnviv(target)" );
185 return;
186 }
187 switch (pname) {
188 case GL_TEXTURE_ENV_MODE:
189 *params = (GLint) texUnit->EnvMode;
190 break;
191 case GL_TEXTURE_ENV_COLOR:
192 params[0] = FLOAT_TO_INT( texUnit->EnvColor[0] );
193 params[1] = FLOAT_TO_INT( texUnit->EnvColor[1] );
194 params[2] = FLOAT_TO_INT( texUnit->EnvColor[2] );
195 params[3] = FLOAT_TO_INT( texUnit->EnvColor[3] );
196 break;
197 default:
198 gl_error( ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)" );
199 }
200 }
201
202
203
204
205 /**********************************************************************/
206 /* Texture Parameters */
207 /**********************************************************************/
208
209
210 void
211 _mesa_TexParameterf( GLenum target, GLenum pname, GLfloat param )
212 {
213 _mesa_TexParameterfv(target, pname, &param);
214 }
215
216
217 void
218 _mesa_TexParameterfv( GLenum target, GLenum pname, const GLfloat *params )
219 {
220 GET_CURRENT_CONTEXT(ctx);
221 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
222 GLenum eparam = (GLenum) (GLint) params[0];
223 struct gl_texture_object *texObj;
224
225 if (MESA_VERBOSE&(VERBOSE_API|VERBOSE_TEXTURE))
226 fprintf(stderr, "texPARAM %s %s %d...\n",
227 gl_lookup_enum_by_nr(target),
228 gl_lookup_enum_by_nr(pname),
229 eparam);
230
231
232 switch (target) {
233 case GL_TEXTURE_1D:
234 texObj = texUnit->CurrentD[1];
235 break;
236 case GL_TEXTURE_2D:
237 texObj = texUnit->CurrentD[2];
238 break;
239 case GL_TEXTURE_3D_EXT:
240 texObj = texUnit->CurrentD[3];
241 break;
242 default:
243 gl_error( ctx, GL_INVALID_ENUM, "glTexParameter(target)" );
244 return;
245 }
246
247 switch (pname) {
248 case GL_TEXTURE_MIN_FILTER:
249 /* A small optimization */
250 if (texObj->MinFilter == eparam)
251 return;
252
253 if (eparam==GL_NEAREST || eparam==GL_LINEAR
254 || eparam==GL_NEAREST_MIPMAP_NEAREST
255 || eparam==GL_LINEAR_MIPMAP_NEAREST
256 || eparam==GL_NEAREST_MIPMAP_LINEAR
257 || eparam==GL_LINEAR_MIPMAP_LINEAR) {
258 texObj->MinFilter = eparam;
259 ctx->NewState |= NEW_TEXTURING;
260 }
261 else {
262 gl_error( ctx, GL_INVALID_VALUE, "glTexParameter(param)" );
263 return;
264 }
265 break;
266 case GL_TEXTURE_MAG_FILTER:
267 /* A small optimization */
268 if (texObj->MagFilter == eparam)
269 return;
270
271 if (eparam==GL_NEAREST || eparam==GL_LINEAR) {
272 texObj->MagFilter = eparam;
273 ctx->NewState |= NEW_TEXTURING;
274 }
275 else {
276 gl_error( ctx, GL_INVALID_VALUE, "glTexParameter(param)" );
277 return;
278 }
279 break;
280 case GL_TEXTURE_WRAP_S:
281 if (texObj->WrapS == eparam)
282 return;
283
284 if (eparam==GL_CLAMP || eparam==GL_REPEAT || eparam==GL_CLAMP_TO_EDGE) {
285 texObj->WrapS = eparam;
286 ctx->NewState |= NEW_TEXTURING;
287 }
288 else {
289 gl_error( ctx, GL_INVALID_VALUE, "glTexParameter(param)" );
290 return;
291 }
292 break;
293 case GL_TEXTURE_WRAP_T:
294 if (texObj->WrapT == eparam)
295 return;
296
297 if (eparam==GL_CLAMP || eparam==GL_REPEAT || eparam==GL_CLAMP_TO_EDGE) {
298 texObj->WrapT = eparam;
299 ctx->NewState |= NEW_TEXTURING;
300 }
301 else {
302 gl_error( ctx, GL_INVALID_VALUE, "glTexParameter(param)" );
303 return;
304 }
305 break;
306 case GL_TEXTURE_WRAP_R_EXT:
307 if (texObj->WrapR == eparam)
308 return;
309
310 if (eparam==GL_CLAMP || eparam==GL_REPEAT || eparam==GL_CLAMP_TO_EDGE) {
311 texObj->WrapR = eparam;
312 ctx->NewState |= NEW_TEXTURING;
313 }
314 else {
315 gl_error( ctx, GL_INVALID_VALUE, "glTexParameter(param)" );
316 }
317 break;
318 case GL_TEXTURE_BORDER_COLOR:
319 texObj->BorderColor[0] = (GLubyte) CLAMP((GLint)(params[0]*255.0), 0, 255);
320 texObj->BorderColor[1] = (GLubyte) CLAMP((GLint)(params[1]*255.0), 0, 255);
321 texObj->BorderColor[2] = (GLubyte) CLAMP((GLint)(params[2]*255.0), 0, 255);
322 texObj->BorderColor[3] = (GLubyte) CLAMP((GLint)(params[3]*255.0), 0, 255);
323 break;
324 case GL_TEXTURE_MIN_LOD:
325 texObj->MinLod = params[0];
326 ctx->NewState |= NEW_TEXTURING;
327 break;
328 case GL_TEXTURE_MAX_LOD:
329 texObj->MaxLod = params[0];
330 ctx->NewState |= NEW_TEXTURING;
331 break;
332 case GL_TEXTURE_BASE_LEVEL:
333 if (params[0] < 0.0) {
334 gl_error(ctx, GL_INVALID_VALUE, "glTexParameter(param)" );
335 return;
336 }
337 texObj->BaseLevel = (GLint) params[0];
338 ctx->NewState |= NEW_TEXTURING;
339 break;
340 case GL_TEXTURE_MAX_LEVEL:
341 if (params[0] < 0.0) {
342 gl_error(ctx, GL_INVALID_VALUE, "glTexParameter(param)" );
343 return;
344 }
345 texObj->MaxLevel = (GLint) params[0];
346 ctx->NewState |= NEW_TEXTURING;
347 break;
348 case GL_TEXTURE_PRIORITY:
349 /* (keithh@netcomuk.co.uk) */
350 texObj->Priority = CLAMP( params[0], 0.0F, 1.0F );
351 break;
352 default:
353 gl_error( ctx, GL_INVALID_ENUM, "glTexParameter(pname)" );
354 return;
355 }
356
357 gl_put_texobj_on_dirty_list( ctx, texObj );
358
359 if (ctx->Driver.TexParameter) {
360 (*ctx->Driver.TexParameter)( ctx, target, texObj, pname, params );
361 }
362 }
363
364
365 void
366 _mesa_TexParameteri( GLenum target, GLenum pname, const GLint param )
367 {
368 GLfloat fparam[4];
369 fparam[0] = (GLfloat) param;
370 fparam[1] = fparam[2] = fparam[3] = 0.0;
371 _mesa_TexParameterfv(target, pname, fparam);
372 }
373
374 void
375 _mesa_TexParameteriv( GLenum target, GLenum pname, const GLint *params )
376 {
377 GLfloat fparam[4];
378 fparam[0] = (GLfloat) params[0];
379 fparam[1] = fparam[2] = fparam[3] = 0.0;
380 _mesa_TexParameterfv(target, pname, fparam);
381 }
382
383
384 void
385 _mesa_GetTexLevelParameterfv( GLenum target, GLint level,
386 GLenum pname, GLfloat *params )
387 {
388 GLint iparam;
389 _mesa_GetTexLevelParameteriv( target, level, pname, &iparam );
390 *params = (GLfloat) iparam;
391 }
392
393
394
395 void
396 _mesa_GetTexLevelParameteriv( GLenum target, GLint level,
397 GLenum pname, GLint *params )
398 {
399 GET_CURRENT_CONTEXT(ctx);
400 const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
401 const struct gl_texture_image *img = NULL;
402 GLuint dimensions;
403
404 if (level < 0 || level >= ctx->Const.MaxTextureLevels) {
405 gl_error( ctx, GL_INVALID_VALUE, "glGetTexLevelParameter[if]v" );
406 return;
407 }
408
409 switch (target) {
410 case GL_TEXTURE_1D:
411 img = texUnit->CurrentD[1]->Image[level];
412 dimensions = 1;
413 break;
414 case GL_TEXTURE_2D:
415 img = texUnit->CurrentD[2]->Image[level];
416 dimensions = 2;
417 break;
418 case GL_TEXTURE_3D:
419 img = texUnit->CurrentD[3]->Image[level];
420 dimensions = 3;
421 break;
422 case GL_PROXY_TEXTURE_1D:
423 img = ctx->Texture.Proxy1D->Image[level];
424 dimensions = 1;
425 break;
426 case GL_PROXY_TEXTURE_2D:
427 img = ctx->Texture.Proxy2D->Image[level];
428 dimensions = 2;
429 break;
430 case GL_PROXY_TEXTURE_3D:
431 img = ctx->Texture.Proxy3D->Image[level];
432 dimensions = 3;
433 break;
434 default:
435 gl_error(ctx, GL_INVALID_ENUM, "glGetTexLevelParameter[if]v(target)");
436 return;
437 }
438
439 if (!img) {
440 if (pname == GL_TEXTURE_COMPONENTS)
441 *params = 1;
442 else
443 *params = 0;
444 return;
445 }
446
447 switch (pname) {
448 case GL_TEXTURE_WIDTH:
449 *params = img->Width;
450 return;
451 case GL_TEXTURE_HEIGHT:
452 if (dimensions > 1) {
453 *params = img->Height;
454 }
455 else {
456 gl_error( ctx, GL_INVALID_ENUM,
457 "glGetTexLevelParameter[if]v(pname=GL_TEXTURE_HEIGHT)" );
458 }
459 return;
460 case GL_TEXTURE_DEPTH:
461 if (dimensions > 2) {
462 *params = img->Depth;
463 }
464 else {
465 gl_error( ctx, GL_INVALID_ENUM,
466 "glGetTexLevelParameter[if]v(pname=GL_TEXTURE_DEPTH)" );
467 }
468 return;
469 case GL_TEXTURE_COMPONENTS:
470 *params = img->IntFormat;
471 return;
472 case GL_TEXTURE_BORDER:
473 *params = img->Border;
474 return;
475 case GL_TEXTURE_RED_SIZE:
476 *params = img->RedBits;
477 return;
478 case GL_TEXTURE_GREEN_SIZE:
479 *params = img->GreenBits;
480 return;
481 case GL_TEXTURE_BLUE_SIZE:
482 *params = img->BlueBits;
483 return;
484 case GL_TEXTURE_ALPHA_SIZE:
485 *params = img->AlphaBits;
486 return;
487 case GL_TEXTURE_INTENSITY_SIZE:
488 *params = img->IntensityBits;
489 return;
490 case GL_TEXTURE_LUMINANCE_SIZE:
491 *params = img->LuminanceBits;
492 return;
493 case GL_TEXTURE_INDEX_SIZE_EXT:
494 *params = img->IndexBits;
495 return;
496 default:
497 gl_error( ctx, GL_INVALID_ENUM,
498 "glGetTexLevelParameter[if]v(pname)" );
499 }
500 }
501
502
503
504 void
505 _mesa_GetTexParameterfv( GLenum target, GLenum pname, GLfloat *params )
506 {
507 GET_CURRENT_CONTEXT(ctx);
508 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
509 struct gl_texture_object *obj;
510
511 switch (target) {
512 case GL_TEXTURE_1D:
513 obj = texUnit->CurrentD[1];
514 break;
515 case GL_TEXTURE_2D:
516 obj = texUnit->CurrentD[2];
517 break;
518 case GL_TEXTURE_3D_EXT:
519 obj = texUnit->CurrentD[3];
520 break;
521 default:
522 gl_error(ctx, GL_INVALID_ENUM, "glGetTexParameterfv(target)");
523 return;
524 }
525
526 switch (pname) {
527 case GL_TEXTURE_MAG_FILTER:
528 *params = ENUM_TO_FLOAT(obj->MagFilter);
529 break;
530 case GL_TEXTURE_MIN_FILTER:
531 *params = ENUM_TO_FLOAT(obj->MinFilter);
532 break;
533 case GL_TEXTURE_WRAP_S:
534 *params = ENUM_TO_FLOAT(obj->WrapS);
535 break;
536 case GL_TEXTURE_WRAP_T:
537 *params = ENUM_TO_FLOAT(obj->WrapT);
538 break;
539 case GL_TEXTURE_WRAP_R_EXT:
540 *params = ENUM_TO_FLOAT(obj->WrapR);
541 break;
542 case GL_TEXTURE_BORDER_COLOR:
543 params[0] = obj->BorderColor[0] / 255.0F;
544 params[1] = obj->BorderColor[1] / 255.0F;
545 params[2] = obj->BorderColor[2] / 255.0F;
546 params[3] = obj->BorderColor[3] / 255.0F;
547 break;
548 case GL_TEXTURE_RESIDENT:
549 *params = ENUM_TO_FLOAT(GL_TRUE);
550 break;
551 case GL_TEXTURE_PRIORITY:
552 *params = obj->Priority;
553 break;
554 case GL_TEXTURE_MIN_LOD:
555 *params = obj->MinLod;
556 break;
557 case GL_TEXTURE_MAX_LOD:
558 *params = obj->MaxLod;
559 break;
560 case GL_TEXTURE_BASE_LEVEL:
561 *params = (GLfloat) obj->BaseLevel;
562 break;
563 case GL_TEXTURE_MAX_LEVEL:
564 *params = (GLfloat) obj->MaxLevel;
565 break;
566 default:
567 gl_error( ctx, GL_INVALID_ENUM, "glGetTexParameterfv(pname)" );
568 }
569 }
570
571
572 void
573 _mesa_GetTexParameteriv( GLenum target, GLenum pname, GLint *params )
574 {
575 GET_CURRENT_CONTEXT(ctx);
576 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
577 struct gl_texture_object *obj;
578
579 switch (target) {
580 case GL_TEXTURE_1D:
581 obj = texUnit->CurrentD[1];
582 break;
583 case GL_TEXTURE_2D:
584 obj = texUnit->CurrentD[2];
585 break;
586 case GL_TEXTURE_3D_EXT:
587 obj = texUnit->CurrentD[3];
588 break;
589 default:
590 gl_error(ctx, GL_INVALID_ENUM, "glGetTexParameterfv(target)");
591 return;
592 }
593
594 switch (pname) {
595 case GL_TEXTURE_MAG_FILTER:
596 *params = (GLint) obj->MagFilter;
597 break;
598 case GL_TEXTURE_MIN_FILTER:
599 *params = (GLint) obj->MinFilter;
600 break;
601 case GL_TEXTURE_WRAP_S:
602 *params = (GLint) obj->WrapS;
603 break;
604 case GL_TEXTURE_WRAP_T:
605 *params = (GLint) obj->WrapT;
606 break;
607 case GL_TEXTURE_WRAP_R_EXT:
608 *params = (GLint) obj->WrapR;
609 break;
610 case GL_TEXTURE_BORDER_COLOR:
611 {
612 GLfloat color[4];
613 color[0] = obj->BorderColor[0] / 255.0F;
614 color[1] = obj->BorderColor[1] / 255.0F;
615 color[2] = obj->BorderColor[2] / 255.0F;
616 color[3] = obj->BorderColor[3] / 255.0F;
617 params[0] = FLOAT_TO_INT( color[0] );
618 params[1] = FLOAT_TO_INT( color[1] );
619 params[2] = FLOAT_TO_INT( color[2] );
620 params[3] = FLOAT_TO_INT( color[3] );
621 }
622 break;
623 case GL_TEXTURE_RESIDENT:
624 *params = (GLint) GL_TRUE;
625 break;
626 case GL_TEXTURE_PRIORITY:
627 *params = (GLint) obj->Priority;
628 break;
629 case GL_TEXTURE_MIN_LOD:
630 *params = (GLint) obj->MinLod;
631 break;
632 case GL_TEXTURE_MAX_LOD:
633 *params = (GLint) obj->MaxLod;
634 break;
635 case GL_TEXTURE_BASE_LEVEL:
636 *params = obj->BaseLevel;
637 break;
638 case GL_TEXTURE_MAX_LEVEL:
639 *params = obj->MaxLevel;
640 break;
641 default:
642 gl_error( ctx, GL_INVALID_ENUM, "glGetTexParameteriv(pname)" );
643 }
644 }
645
646
647
648
649 /**********************************************************************/
650 /* Texture Coord Generation */
651 /**********************************************************************/
652
653
654 void
655 _mesa_TexGenfv( GLenum coord, GLenum pname, const GLfloat *params )
656 {
657 GET_CURRENT_CONTEXT(ctx);
658 GLuint tUnit = ctx->Texture.CurrentTransformUnit;
659 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[tUnit];
660 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glTexGenfv");
661
662 if (MESA_VERBOSE&(VERBOSE_API|VERBOSE_TEXTURE))
663 fprintf(stderr, "texGEN %s %s %x...\n",
664 gl_lookup_enum_by_nr(coord),
665 gl_lookup_enum_by_nr(pname),
666 *(int *)params);
667
668 switch (coord) {
669 case GL_S:
670 if (pname==GL_TEXTURE_GEN_MODE) {
671 GLenum mode = (GLenum) (GLint) *params;
672 switch (mode) {
673 case GL_OBJECT_LINEAR:
674 texUnit->GenModeS = mode;
675 texUnit->GenBitS = TEXGEN_OBJ_LINEAR;
676 break;
677 case GL_EYE_LINEAR:
678 texUnit->GenModeS = mode;
679 texUnit->GenBitS = TEXGEN_EYE_LINEAR;
680 break;
681 case GL_REFLECTION_MAP_NV:
682 texUnit->GenModeS = mode;
683 texUnit->GenBitS = TEXGEN_REFLECTION_MAP_NV;
684 break;
685 case GL_NORMAL_MAP_NV:
686 texUnit->GenModeS = mode;
687 texUnit->GenBitS = TEXGEN_NORMAL_MAP_NV;
688 break;
689 case GL_SPHERE_MAP:
690 texUnit->GenModeS = mode;
691 texUnit->GenBitS = TEXGEN_SPHERE_MAP;
692 break;
693 default:
694 gl_error( ctx, GL_INVALID_ENUM, "glTexGenfv(param)" );
695 return;
696 }
697 }
698 else if (pname==GL_OBJECT_PLANE) {
699 texUnit->ObjectPlaneS[0] = params[0];
700 texUnit->ObjectPlaneS[1] = params[1];
701 texUnit->ObjectPlaneS[2] = params[2];
702 texUnit->ObjectPlaneS[3] = params[3];
703 }
704 else if (pname==GL_EYE_PLANE) {
705 /* Transform plane equation by the inverse modelview matrix */
706 if (ctx->ModelView.flags & MAT_DIRTY_INVERSE) {
707 gl_matrix_analyze( &ctx->ModelView );
708 }
709 gl_transform_vector( texUnit->EyePlaneS, params,
710 ctx->ModelView.inv );
711 }
712 else {
713 gl_error( ctx, GL_INVALID_ENUM, "glTexGenfv(pname)" );
714 return;
715 }
716 break;
717 case GL_T:
718 if (pname==GL_TEXTURE_GEN_MODE) {
719 GLenum mode = (GLenum) (GLint) *params;
720 switch(mode) {
721 case GL_OBJECT_LINEAR:
722 texUnit->GenModeT = GL_OBJECT_LINEAR;
723 texUnit->GenBitT = TEXGEN_OBJ_LINEAR;
724 break;
725 case GL_EYE_LINEAR:
726 texUnit->GenModeT = GL_EYE_LINEAR;
727 texUnit->GenBitT = TEXGEN_EYE_LINEAR;
728 break;
729 case GL_REFLECTION_MAP_NV:
730 texUnit->GenModeT = GL_REFLECTION_MAP_NV;
731 texUnit->GenBitT = TEXGEN_REFLECTION_MAP_NV;
732 break;
733 case GL_NORMAL_MAP_NV:
734 texUnit->GenModeT = GL_NORMAL_MAP_NV;
735 texUnit->GenBitT = TEXGEN_NORMAL_MAP_NV;
736 break;
737 case GL_SPHERE_MAP:
738 texUnit->GenModeT = GL_SPHERE_MAP;
739 texUnit->GenBitT = TEXGEN_SPHERE_MAP;
740 break;
741 default:
742 gl_error( ctx, GL_INVALID_ENUM, "glTexGenfv(param)" );
743 return;
744 }
745 }
746 else if (pname==GL_OBJECT_PLANE) {
747 texUnit->ObjectPlaneT[0] = params[0];
748 texUnit->ObjectPlaneT[1] = params[1];
749 texUnit->ObjectPlaneT[2] = params[2];
750 texUnit->ObjectPlaneT[3] = params[3];
751 }
752 else if (pname==GL_EYE_PLANE) {
753 /* Transform plane equation by the inverse modelview matrix */
754 if (ctx->ModelView.flags & MAT_DIRTY_INVERSE) {
755 gl_matrix_analyze( &ctx->ModelView );
756 }
757 gl_transform_vector( texUnit->EyePlaneT, params,
758 ctx->ModelView.inv );
759 }
760 else {
761 gl_error( ctx, GL_INVALID_ENUM, "glTexGenfv(pname)" );
762 return;
763 }
764 break;
765 case GL_R:
766 if (pname==GL_TEXTURE_GEN_MODE) {
767 GLenum mode = (GLenum) (GLint) *params;
768 switch (mode) {
769 case GL_OBJECT_LINEAR:
770 texUnit->GenModeR = GL_OBJECT_LINEAR;
771 texUnit->GenBitR = TEXGEN_OBJ_LINEAR;
772 break;
773 case GL_REFLECTION_MAP_NV:
774 texUnit->GenModeR = GL_REFLECTION_MAP_NV;
775 texUnit->GenBitR = TEXGEN_REFLECTION_MAP_NV;
776 break;
777 case GL_NORMAL_MAP_NV:
778 texUnit->GenModeR = GL_NORMAL_MAP_NV;
779 texUnit->GenBitR = TEXGEN_NORMAL_MAP_NV;
780 break;
781 case GL_EYE_LINEAR:
782 texUnit->GenModeR = GL_EYE_LINEAR;
783 texUnit->GenBitR = TEXGEN_EYE_LINEAR;
784 break;
785 default:
786 gl_error( ctx, GL_INVALID_ENUM, "glTexGenfv(param)" );
787 return;
788 }
789 }
790 else if (pname==GL_OBJECT_PLANE) {
791 texUnit->ObjectPlaneR[0] = params[0];
792 texUnit->ObjectPlaneR[1] = params[1];
793 texUnit->ObjectPlaneR[2] = params[2];
794 texUnit->ObjectPlaneR[3] = params[3];
795 }
796 else if (pname==GL_EYE_PLANE) {
797 /* Transform plane equation by the inverse modelview matrix */
798 if (ctx->ModelView.flags & MAT_DIRTY_INVERSE) {
799 gl_matrix_analyze( &ctx->ModelView );
800 }
801 gl_transform_vector( texUnit->EyePlaneR, params,
802 ctx->ModelView.inv );
803 }
804 else {
805 gl_error( ctx, GL_INVALID_ENUM, "glTexGenfv(pname)" );
806 return;
807 }
808 break;
809 case GL_Q:
810 if (pname==GL_TEXTURE_GEN_MODE) {
811 GLenum mode = (GLenum) (GLint) *params;
812 switch (mode) {
813 case GL_OBJECT_LINEAR:
814 texUnit->GenModeQ = GL_OBJECT_LINEAR;
815 texUnit->GenBitQ = TEXGEN_OBJ_LINEAR;
816 break;
817 case GL_EYE_LINEAR:
818 texUnit->GenModeQ = GL_EYE_LINEAR;
819 texUnit->GenBitQ = TEXGEN_EYE_LINEAR;
820 break;
821 default:
822 gl_error( ctx, GL_INVALID_ENUM, "glTexGenfv(param)" );
823 return;
824 }
825 }
826 else if (pname==GL_OBJECT_PLANE) {
827 texUnit->ObjectPlaneQ[0] = params[0];
828 texUnit->ObjectPlaneQ[1] = params[1];
829 texUnit->ObjectPlaneQ[2] = params[2];
830 texUnit->ObjectPlaneQ[3] = params[3];
831 }
832 else if (pname==GL_EYE_PLANE) {
833 /* Transform plane equation by the inverse modelview matrix */
834 if (ctx->ModelView.flags & MAT_DIRTY_INVERSE) {
835 gl_matrix_analyze( &ctx->ModelView );
836 }
837 gl_transform_vector( texUnit->EyePlaneQ, params,
838 ctx->ModelView.inv );
839 }
840 else {
841 gl_error( ctx, GL_INVALID_ENUM, "glTexGenfv(pname)" );
842 return;
843 }
844 break;
845 default:
846 gl_error( ctx, GL_INVALID_ENUM, "glTexGenfv(coord)" );
847 return;
848 }
849
850 ctx->NewState |= NEW_TEXTURING;
851 }
852
853
854 void
855 _mesa_TexGeniv(GLenum coord, GLenum pname, const GLint *params )
856 {
857 GLfloat p[4];
858 p[0] = params[0];
859 p[1] = params[1];
860 p[2] = params[2];
861 p[3] = params[3];
862 _mesa_TexGenfv(coord, pname, p);
863 }
864
865
866 void
867 _mesa_TexGend(GLenum coord, GLenum pname, GLdouble param )
868 {
869 GLfloat p = (GLfloat) param;
870 _mesa_TexGenfv( coord, pname, &p );
871 }
872
873
874 void
875 _mesa_TexGendv(GLenum coord, GLenum pname, const GLdouble *params )
876 {
877 GLfloat p[4];
878 p[0] = params[0];
879 p[1] = params[1];
880 p[2] = params[2];
881 p[3] = params[3];
882 _mesa_TexGenfv( coord, pname, p );
883 }
884
885
886 void
887 _mesa_TexGenf( GLenum coord, GLenum pname, GLfloat param )
888 {
889 _mesa_TexGenfv(coord, pname, &param);
890 }
891
892
893 void
894 _mesa_TexGeni( GLenum coord, GLenum pname, GLint param )
895 {
896 _mesa_TexGeniv( coord, pname, &param );
897 }
898
899
900
901 void
902 _mesa_GetTexGendv( GLenum coord, GLenum pname, GLdouble *params )
903 {
904 GET_CURRENT_CONTEXT(ctx);
905 GLuint tUnit = ctx->Texture.CurrentTransformUnit;
906 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[tUnit];
907
908 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glGetTexGendv");
909
910 switch( coord ) {
911 case GL_S:
912 if (pname==GL_TEXTURE_GEN_MODE) {
913 params[0] = ENUM_TO_DOUBLE(texUnit->GenModeS);
914 }
915 else if (pname==GL_OBJECT_PLANE) {
916 COPY_4V( params, texUnit->ObjectPlaneS );
917 }
918 else if (pname==GL_EYE_PLANE) {
919 COPY_4V( params, texUnit->EyePlaneS );
920 }
921 else {
922 gl_error( ctx, GL_INVALID_ENUM, "glGetTexGendv(pname)" );
923 return;
924 }
925 break;
926 case GL_T:
927 if (pname==GL_TEXTURE_GEN_MODE) {
928 params[0] = ENUM_TO_DOUBLE(texUnit->GenModeT);
929 }
930 else if (pname==GL_OBJECT_PLANE) {
931 COPY_4V( params, texUnit->ObjectPlaneT );
932 }
933 else if (pname==GL_EYE_PLANE) {
934 COPY_4V( params, texUnit->EyePlaneT );
935 }
936 else {
937 gl_error( ctx, GL_INVALID_ENUM, "glGetTexGendv(pname)" );
938 return;
939 }
940 break;
941 case GL_R:
942 if (pname==GL_TEXTURE_GEN_MODE) {
943 params[0] = ENUM_TO_DOUBLE(texUnit->GenModeR);
944 }
945 else if (pname==GL_OBJECT_PLANE) {
946 COPY_4V( params, texUnit->ObjectPlaneR );
947 }
948 else if (pname==GL_EYE_PLANE) {
949 COPY_4V( params, texUnit->EyePlaneR );
950 }
951 else {
952 gl_error( ctx, GL_INVALID_ENUM, "glGetTexGendv(pname)" );
953 return;
954 }
955 break;
956 case GL_Q:
957 if (pname==GL_TEXTURE_GEN_MODE) {
958 params[0] = ENUM_TO_DOUBLE(texUnit->GenModeQ);
959 }
960 else if (pname==GL_OBJECT_PLANE) {
961 COPY_4V( params, texUnit->ObjectPlaneQ );
962 }
963 else if (pname==GL_EYE_PLANE) {
964 COPY_4V( params, texUnit->EyePlaneQ );
965 }
966 else {
967 gl_error( ctx, GL_INVALID_ENUM, "glGetTexGendv(pname)" );
968 return;
969 }
970 break;
971 default:
972 gl_error( ctx, GL_INVALID_ENUM, "glGetTexGendv(coord)" );
973 return;
974 }
975 }
976
977
978
979 void
980 _mesa_GetTexGenfv( GLenum coord, GLenum pname, GLfloat *params )
981 {
982 GET_CURRENT_CONTEXT(ctx);
983 GLuint tUnit = ctx->Texture.CurrentTransformUnit;
984 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[tUnit];
985
986 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glGetTexGenfv");
987
988 switch( coord ) {
989 case GL_S:
990 if (pname==GL_TEXTURE_GEN_MODE) {
991 params[0] = ENUM_TO_FLOAT(texUnit->GenModeS);
992 }
993 else if (pname==GL_OBJECT_PLANE) {
994 COPY_4V( params, texUnit->ObjectPlaneS );
995 }
996 else if (pname==GL_EYE_PLANE) {
997 COPY_4V( params, texUnit->EyePlaneS );
998 }
999 else {
1000 gl_error( ctx, GL_INVALID_ENUM, "glGetTexGenfv(pname)" );
1001 return;
1002 }
1003 break;
1004 case GL_T:
1005 if (pname==GL_TEXTURE_GEN_MODE) {
1006 params[0] = ENUM_TO_FLOAT(texUnit->GenModeT);
1007 }
1008 else if (pname==GL_OBJECT_PLANE) {
1009 COPY_4V( params, texUnit->ObjectPlaneT );
1010 }
1011 else if (pname==GL_EYE_PLANE) {
1012 COPY_4V( params, texUnit->EyePlaneT );
1013 }
1014 else {
1015 gl_error( ctx, GL_INVALID_ENUM, "glGetTexGenfv(pname)" );
1016 return;
1017 }
1018 break;
1019 case GL_R:
1020 if (pname==GL_TEXTURE_GEN_MODE) {
1021 params[0] = ENUM_TO_FLOAT(texUnit->GenModeR);
1022 }
1023 else if (pname==GL_OBJECT_PLANE) {
1024 COPY_4V( params, texUnit->ObjectPlaneR );
1025 }
1026 else if (pname==GL_EYE_PLANE) {
1027 COPY_4V( params, texUnit->EyePlaneR );
1028 }
1029 else {
1030 gl_error( ctx, GL_INVALID_ENUM, "glGetTexGenfv(pname)" );
1031 return;
1032 }
1033 break;
1034 case GL_Q:
1035 if (pname==GL_TEXTURE_GEN_MODE) {
1036 params[0] = ENUM_TO_FLOAT(texUnit->GenModeQ);
1037 }
1038 else if (pname==GL_OBJECT_PLANE) {
1039 COPY_4V( params, texUnit->ObjectPlaneQ );
1040 }
1041 else if (pname==GL_EYE_PLANE) {
1042 COPY_4V( params, texUnit->EyePlaneQ );
1043 }
1044 else {
1045 gl_error( ctx, GL_INVALID_ENUM, "glGetTexGenfv(pname)" );
1046 return;
1047 }
1048 break;
1049 default:
1050 gl_error( ctx, GL_INVALID_ENUM, "glGetTexGenfv(coord)" );
1051 return;
1052 }
1053 }
1054
1055
1056
1057 void
1058 _mesa_GetTexGeniv( GLenum coord, GLenum pname, GLint *params )
1059 {
1060 GET_CURRENT_CONTEXT(ctx);
1061 GLuint tUnit = ctx->Texture.CurrentTransformUnit;
1062 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[tUnit];
1063
1064 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glGetTexGeniv");
1065
1066 switch( coord ) {
1067 case GL_S:
1068 if (pname==GL_TEXTURE_GEN_MODE) {
1069 params[0] = texUnit->GenModeS;
1070 }
1071 else if (pname==GL_OBJECT_PLANE) {
1072 params[0] = (GLint) texUnit->ObjectPlaneS[0];
1073 params[1] = (GLint) texUnit->ObjectPlaneS[1];
1074 params[2] = (GLint) texUnit->ObjectPlaneS[2];
1075 params[3] = (GLint) texUnit->ObjectPlaneS[3];
1076 }
1077 else if (pname==GL_EYE_PLANE) {
1078 params[0] = (GLint) texUnit->EyePlaneS[0];
1079 params[1] = (GLint) texUnit->EyePlaneS[1];
1080 params[2] = (GLint) texUnit->EyePlaneS[2];
1081 params[3] = (GLint) texUnit->EyePlaneS[3];
1082 }
1083 else {
1084 gl_error( ctx, GL_INVALID_ENUM, "glGetTexGeniv(pname)" );
1085 return;
1086 }
1087 break;
1088 case GL_T:
1089 if (pname==GL_TEXTURE_GEN_MODE) {
1090 params[0] = texUnit->GenModeT;
1091 }
1092 else if (pname==GL_OBJECT_PLANE) {
1093 params[0] = (GLint) texUnit->ObjectPlaneT[0];
1094 params[1] = (GLint) texUnit->ObjectPlaneT[1];
1095 params[2] = (GLint) texUnit->ObjectPlaneT[2];
1096 params[3] = (GLint) texUnit->ObjectPlaneT[3];
1097 }
1098 else if (pname==GL_EYE_PLANE) {
1099 params[0] = (GLint) texUnit->EyePlaneT[0];
1100 params[1] = (GLint) texUnit->EyePlaneT[1];
1101 params[2] = (GLint) texUnit->EyePlaneT[2];
1102 params[3] = (GLint) texUnit->EyePlaneT[3];
1103 }
1104 else {
1105 gl_error( ctx, GL_INVALID_ENUM, "glGetTexGeniv(pname)" );
1106 return;
1107 }
1108 break;
1109 case GL_R:
1110 if (pname==GL_TEXTURE_GEN_MODE) {
1111 params[0] = texUnit->GenModeR;
1112 }
1113 else if (pname==GL_OBJECT_PLANE) {
1114 params[0] = (GLint) texUnit->ObjectPlaneR[0];
1115 params[1] = (GLint) texUnit->ObjectPlaneR[1];
1116 params[2] = (GLint) texUnit->ObjectPlaneR[2];
1117 params[3] = (GLint) texUnit->ObjectPlaneR[3];
1118 }
1119 else if (pname==GL_EYE_PLANE) {
1120 params[0] = (GLint) texUnit->EyePlaneR[0];
1121 params[1] = (GLint) texUnit->EyePlaneR[1];
1122 params[2] = (GLint) texUnit->EyePlaneR[2];
1123 params[3] = (GLint) texUnit->EyePlaneR[3];
1124 }
1125 else {
1126 gl_error( ctx, GL_INVALID_ENUM, "glGetTexGeniv(pname)" );
1127 return;
1128 }
1129 break;
1130 case GL_Q:
1131 if (pname==GL_TEXTURE_GEN_MODE) {
1132 params[0] = texUnit->GenModeQ;
1133 }
1134 else if (pname==GL_OBJECT_PLANE) {
1135 params[0] = (GLint) texUnit->ObjectPlaneQ[0];
1136 params[1] = (GLint) texUnit->ObjectPlaneQ[1];
1137 params[2] = (GLint) texUnit->ObjectPlaneQ[2];
1138 params[3] = (GLint) texUnit->ObjectPlaneQ[3];
1139 }
1140 else if (pname==GL_EYE_PLANE) {
1141 params[0] = (GLint) texUnit->EyePlaneQ[0];
1142 params[1] = (GLint) texUnit->EyePlaneQ[1];
1143 params[2] = (GLint) texUnit->EyePlaneQ[2];
1144 params[3] = (GLint) texUnit->EyePlaneQ[3];
1145 }
1146 else {
1147 gl_error( ctx, GL_INVALID_ENUM, "glGetTexGeniv(pname)" );
1148 return;
1149 }
1150 break;
1151 default:
1152 gl_error( ctx, GL_INVALID_ENUM, "glGetTexGeniv(coord)" );
1153 return;
1154 }
1155 }
1156
1157
1158 /* GL_ARB_multitexture */
1159 void
1160 _mesa_ActiveTextureARB( GLenum target )
1161 {
1162 GET_CURRENT_CONTEXT(ctx);
1163 GLint maxUnits = ctx->Const.MaxTextureUnits;
1164
1165 ASSERT_OUTSIDE_BEGIN_END( ctx, "glActiveTextureARB" );
1166
1167 if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE))
1168 fprintf(stderr, "glActiveTexture %s\n",
1169 gl_lookup_enum_by_nr(target));
1170
1171 if (target >= GL_TEXTURE0_ARB && target < GL_TEXTURE0_ARB + maxUnits) {
1172 GLint texUnit = target - GL_TEXTURE0_ARB;
1173 ctx->Texture.CurrentUnit = texUnit;
1174 ctx->Texture.CurrentTransformUnit = texUnit;
1175 if (ctx->Driver.ActiveTexture) {
1176 (*ctx->Driver.ActiveTexture)( ctx, (GLuint) texUnit );
1177 }
1178 }
1179 else {
1180 gl_error(ctx, GL_INVALID_OPERATION, "glActiveTextureARB(target)");
1181 }
1182 }
1183
1184
1185 /* GL_ARB_multitexture */
1186 void
1187 _mesa_ClientActiveTextureARB( GLenum target )
1188 {
1189 GET_CURRENT_CONTEXT(ctx);
1190 GLint maxUnits = ctx->Const.MaxTextureUnits;
1191
1192 ASSERT_OUTSIDE_BEGIN_END( ctx, "glClientActiveTextureARB" );
1193
1194 if (target >= GL_TEXTURE0_ARB && target < GL_TEXTURE0_ARB + maxUnits) {
1195 GLint texUnit = target - GL_TEXTURE0_ARB;
1196 ctx->Array.ActiveTexture = texUnit;
1197 }
1198 else {
1199 gl_error(ctx, GL_INVALID_OPERATION, "glActiveTextureARB(target)");
1200 }
1201 }
1202
1203
1204
1205 /*
1206 * Put the given texture object into the list of dirty texture objects.
1207 * When a texture object is dirty we have to reexamine it for completeness
1208 * and perhaps choose a different texture sampling function.
1209 */
1210 void gl_put_texobj_on_dirty_list( GLcontext *ctx, struct gl_texture_object *t )
1211 {
1212 ASSERT(ctx);
1213 ASSERT(t);
1214 /* Only insert if not already in the dirty list.
1215 * The Dirty flag is only set iff the texture object is in the dirty list.
1216 */
1217 if (!t->Dirty) {
1218 ASSERT(t->NextDirty == NULL);
1219 t->Dirty = GL_TRUE;
1220 t->NextDirty = ctx->Shared->DirtyTexObjList;
1221 ctx->Shared->DirtyTexObjList = t;
1222 }
1223 #ifdef DEBUG
1224 else {
1225 /* make sure t is in the list */
1226 struct gl_texture_object *obj = ctx->Shared->DirtyTexObjList;
1227 while (obj) {
1228 if (obj == t) {
1229 return;
1230 }
1231 obj = obj->NextDirty;
1232 }
1233 gl_problem(ctx, "Error in gl_put_texobj_on_dirty_list");
1234 }
1235 #endif
1236 }
1237
1238
1239 /*
1240 * Remove a texture object from the dirty texture list.
1241 */
1242 void gl_remove_texobj_from_dirty_list( struct gl_shared_state *shared,
1243 struct gl_texture_object *tObj )
1244 {
1245 struct gl_texture_object *t, *prev = NULL;
1246 ASSERT(shared);
1247 ASSERT(tObj);
1248 for (t = shared->DirtyTexObjList; t; t = t->NextDirty) {
1249 if (t == tObj) {
1250 if (prev) {
1251 prev->NextDirty = t->NextDirty;
1252 }
1253 else {
1254 shared->DirtyTexObjList = t->NextDirty;
1255 }
1256 return;
1257 }
1258 prev = t;
1259 }
1260 }
1261
1262
1263 /*
1264 * This is called by gl_update_state() if the NEW_TEXTURING bit in
1265 * ctx->NewState is unit.
1266 */
1267 void gl_update_dirty_texobjs( GLcontext *ctx )
1268 {
1269 struct gl_texture_object *t, *next;
1270 for (t = ctx->Shared->DirtyTexObjList; t; t = next) {
1271 next = t->NextDirty;
1272 gl_test_texture_object_completeness(ctx, t);
1273 gl_set_texture_sampler(t);
1274 t->NextDirty = NULL;
1275 t->Dirty = GL_FALSE;
1276 }
1277 ctx->Shared->DirtyTexObjList = NULL;
1278 }