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