1 /* $Id: texstate.c,v 1.51 2001/05/21 16:41:03 brianp Exp $ */
4 * Mesa 3-D graphics library
7 * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
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:
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
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.
35 #include "extensions.h"
41 #include "math/m_xform.h"
42 #include "math/m_matrix.h"
48 /* Needed for an Amiga compiler */
49 #define ENUM_TO_FLOAT(X) ((GLfloat)(GLint)(X))
50 #define ENUM_TO_DOUBLE(X) ((GLdouble)(GLint)(X))
52 /* all other compilers */
53 #define ENUM_TO_FLOAT(X) ((GLfloat)(X))
54 #define ENUM_TO_DOUBLE(X) ((GLdouble)(X))
59 /**********************************************************************/
60 /* Texture Environment */
61 /**********************************************************************/
65 _mesa_TexEnvfv( GLenum target
, GLenum pname
, const GLfloat
*param
)
67 GET_CURRENT_CONTEXT(ctx
);
68 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
69 ASSERT_OUTSIDE_BEGIN_END(ctx
);
71 #define ERROR(errCode, msg, value) \
74 sprintf(s, msg, _mesa_lookup_enum_by_nr(value)); \
75 _mesa_error(ctx, errCode, s); \
78 if (target
==GL_TEXTURE_ENV
) {
80 case GL_TEXTURE_ENV_MODE
: {
81 GLenum mode
= (GLenum
) (GLint
) *param
;
85 if (!ctx
->Extensions
.EXT_texture_env_add
) {
86 ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", mode
);
91 if (!ctx
->Extensions
.EXT_texture_env_combine
&&
92 !ctx
->Extensions
.ARB_texture_env_combine
) {
93 ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", mode
);
103 ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", mode
);
107 if (texUnit
->EnvMode
== mode
)
109 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
110 texUnit
->EnvMode
= mode
;
113 case GL_TEXTURE_ENV_COLOR
: {
115 tmp
[0] = CLAMP( param
[0], 0.0F
, 1.0F
);
116 tmp
[1] = CLAMP( param
[1], 0.0F
, 1.0F
);
117 tmp
[2] = CLAMP( param
[2], 0.0F
, 1.0F
);
118 tmp
[3] = CLAMP( param
[3], 0.0F
, 1.0F
);
119 if (TEST_EQ_4V(tmp
, texUnit
->EnvColor
))
121 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
122 COPY_4FV(texUnit
->EnvColor
, tmp
);
125 case GL_COMBINE_RGB_EXT
:
126 if (ctx
->Extensions
.EXT_texture_env_combine
||
127 ctx
->Extensions
.ARB_texture_env_combine
) {
128 const GLenum mode
= (GLenum
) (GLint
) *param
;
133 case GL_ADD_SIGNED_EXT
:
134 case GL_INTERPOLATE_EXT
:
137 case GL_SUBTRACT_ARB
:
138 if (!ctx
->Extensions
.ARB_texture_env_combine
) {
139 ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", mode
);
143 case GL_DOT3_RGB_EXT
:
144 case GL_DOT3_RGBA_EXT
:
145 if (!ctx
->Extensions
.EXT_texture_env_dot3
) {
146 ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", mode
);
150 case GL_DOT3_RGB_ARB
:
151 case GL_DOT3_RGBA_ARB
:
152 if (!ctx
->Extensions
.ARB_texture_env_dot3
) {
153 ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", mode
);
158 ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", mode
);
161 if (texUnit
->CombineModeRGB
== mode
)
163 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
164 texUnit
->CombineModeRGB
= mode
;
167 ERROR(GL_INVALID_ENUM
, "glTexEnv(pname=%s)", pname
);
171 case GL_COMBINE_ALPHA_EXT
:
172 if (ctx
->Extensions
.EXT_texture_env_combine
||
173 ctx
->Extensions
.ARB_texture_env_combine
) {
174 const GLenum mode
= (GLenum
) (GLint
) *param
;
179 case GL_ADD_SIGNED_EXT
:
180 case GL_INTERPOLATE_EXT
:
183 case GL_SUBTRACT_ARB
:
184 if (!ctx
->Extensions
.ARB_texture_env_combine
) {
185 ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", mode
);
190 ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", mode
);
193 if (texUnit
->CombineModeA
== mode
)
195 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
196 texUnit
->CombineModeA
= mode
;
199 ERROR(GL_INVALID_ENUM
, "glTexEnv(pname=%s)", pname
);
203 case GL_SOURCE0_RGB_EXT
:
204 case GL_SOURCE1_RGB_EXT
:
205 case GL_SOURCE2_RGB_EXT
:
206 if (ctx
->Extensions
.EXT_texture_env_combine
||
207 ctx
->Extensions
.ARB_texture_env_combine
) {
208 GLenum source
= (GLenum
) (GLint
) *param
;
209 GLuint s
= pname
- GL_SOURCE0_RGB_EXT
;
212 case GL_CONSTANT_EXT
:
213 case GL_PRIMARY_COLOR_EXT
:
214 case GL_PREVIOUS_EXT
:
215 if (texUnit
->CombineSourceRGB
[s
] == source
)
217 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
218 texUnit
->CombineSourceRGB
[s
] = source
;
221 ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", source
);
226 ERROR(GL_INVALID_ENUM
, "glTexEnv(pname=%s)", pname
);
230 case GL_SOURCE0_ALPHA_EXT
:
231 case GL_SOURCE1_ALPHA_EXT
:
232 case GL_SOURCE2_ALPHA_EXT
:
233 if (ctx
->Extensions
.EXT_texture_env_combine
||
234 ctx
->Extensions
.ARB_texture_env_combine
) {
235 GLenum source
= (GLenum
) (GLint
) *param
;
236 GLuint s
= pname
- GL_SOURCE0_ALPHA_EXT
;
239 case GL_CONSTANT_EXT
:
240 case GL_PRIMARY_COLOR_EXT
:
241 case GL_PREVIOUS_EXT
:
242 if (texUnit
->CombineSourceA
[s
] == source
) return;
243 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
244 texUnit
->CombineSourceA
[s
] = source
;
247 ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", source
);
252 ERROR(GL_INVALID_ENUM
, "glTexEnv(pname=%s)", pname
);
256 case GL_OPERAND0_RGB_EXT
:
257 case GL_OPERAND1_RGB_EXT
:
258 if (ctx
->Extensions
.EXT_texture_env_combine
||
259 ctx
->Extensions
.ARB_texture_env_combine
) {
260 GLenum operand
= (GLenum
) (GLint
) *param
;
261 GLuint s
= pname
- GL_OPERAND0_RGB_EXT
;
264 case GL_ONE_MINUS_SRC_COLOR
:
266 case GL_ONE_MINUS_SRC_ALPHA
:
267 if (texUnit
->CombineOperandRGB
[s
] == operand
)
269 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
270 texUnit
->CombineOperandRGB
[s
] = operand
;
273 ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", operand
);
278 ERROR(GL_INVALID_ENUM
, "glTexEnv(pname=%s)", pname
);
282 case GL_OPERAND0_ALPHA_EXT
:
283 case GL_OPERAND1_ALPHA_EXT
:
284 if (ctx
->Extensions
.EXT_texture_env_combine
||
285 ctx
->Extensions
.ARB_texture_env_combine
) {
286 GLenum operand
= (GLenum
) (GLint
) *param
;
289 case GL_ONE_MINUS_SRC_ALPHA
:
290 if (texUnit
->CombineOperandA
[pname
-GL_OPERAND0_ALPHA_EXT
] ==
293 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
294 texUnit
->CombineOperandA
[pname
-GL_OPERAND0_ALPHA_EXT
] = operand
;
297 ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", operand
);
302 ERROR(GL_INVALID_ENUM
, "glTexEnv(pname=%s)", pname
);
306 case GL_OPERAND2_RGB_EXT
:
307 if (ctx
->Extensions
.EXT_texture_env_combine
||
308 ctx
->Extensions
.ARB_texture_env_combine
) {
309 GLenum operand
= (GLenum
) (GLint
) *param
;
311 case GL_SRC_COLOR
: /* ARB combine only */
312 case GL_ONE_MINUS_SRC_COLOR
: /* ARB combine only */
314 case GL_ONE_MINUS_SRC_ALPHA
: /* ARB combine only */
315 if (texUnit
->CombineOperandRGB
[2] == operand
)
317 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
318 texUnit
->CombineOperandRGB
[2] = operand
;
320 ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", operand
);
325 ERROR(GL_INVALID_ENUM
, "glTexEnv(pname=%s)", pname
);
329 case GL_OPERAND2_ALPHA_EXT
:
330 if (ctx
->Extensions
.EXT_texture_env_combine
||
331 ctx
->Extensions
.ARB_texture_env_combine
) {
332 GLenum operand
= (GLenum
) (GLint
) *param
;
335 case GL_ONE_MINUS_SRC_ALPHA
: /* ARB combine only */
336 if (texUnit
->CombineOperandA
[2] == operand
)
338 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
339 texUnit
->CombineOperandA
[2] = operand
;
342 ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", operand
);
347 ERROR(GL_INVALID_ENUM
, "glTexEnv(pname=%s)", pname
);
351 case GL_RGB_SCALE_EXT
:
352 if (ctx
->Extensions
.EXT_texture_env_combine
||
353 ctx
->Extensions
.ARB_texture_env_combine
) {
358 else if (*param
== 2.0) {
361 else if (*param
== 4.0) {
365 _mesa_error( ctx
, GL_INVALID_VALUE
,
366 "glTexEnv(GL_RGB_SCALE not 1, 2 or 4)" );
369 if (texUnit
->CombineScaleShiftRGB
== newshift
)
371 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
372 texUnit
->CombineScaleShiftRGB
= newshift
;
375 ERROR(GL_INVALID_ENUM
, "glTexEnv(pname=%s)", pname
);
380 if (ctx
->Extensions
.EXT_texture_env_combine
||
381 ctx
->Extensions
.ARB_texture_env_combine
) {
386 else if (*param
== 2.0) {
389 else if (*param
== 4.0) {
393 _mesa_error( ctx
, GL_INVALID_VALUE
,
394 "glTexEnv(GL_ALPHA_SCALE not 1, 2 or 4)" );
397 if (texUnit
->CombineScaleShiftA
== newshift
)
399 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
400 texUnit
->CombineScaleShiftA
= newshift
;
403 ERROR(GL_INVALID_ENUM
, "glTexEnv(pname=%s)", pname
);
408 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexEnv(pname)" );
412 else if (target
==GL_TEXTURE_FILTER_CONTROL_EXT
) {
413 if (!ctx
->Extensions
.EXT_texture_lod_bias
) {
414 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexEnv(param)" );
418 case GL_TEXTURE_LOD_BIAS_EXT
:
419 if (texUnit
->LodBias
== param
[0])
421 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
422 texUnit
->LodBias
= param
[0];
425 ERROR(GL_INVALID_ENUM
, "glTexEnv(pname=%s)", pname
);
430 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexEnv(target)" );
434 if (MESA_VERBOSE
&(VERBOSE_API
|VERBOSE_TEXTURE
))
435 fprintf(stderr
, "glTexEnv %s %s %.1f(%s) ...\n",
436 _mesa_lookup_enum_by_nr(target
),
437 _mesa_lookup_enum_by_nr(pname
),
439 _mesa_lookup_enum_by_nr((GLenum
) (GLint
) *param
));
441 /* Tell device driver about the new texture environment */
442 if (ctx
->Driver
.TexEnv
) {
443 (*ctx
->Driver
.TexEnv
)( ctx
, target
, pname
, param
);
449 _mesa_TexEnvf( GLenum target
, GLenum pname
, GLfloat param
)
451 _mesa_TexEnvfv( target
, pname
, ¶m
);
457 _mesa_TexEnvi( GLenum target
, GLenum pname
, GLint param
)
460 p
[0] = (GLfloat
) param
;
461 p
[1] = p
[2] = p
[3] = 0.0;
462 _mesa_TexEnvfv( target
, pname
, p
);
467 _mesa_TexEnviv( GLenum target
, GLenum pname
, const GLint
*param
)
470 p
[0] = INT_TO_FLOAT( param
[0] );
471 p
[1] = INT_TO_FLOAT( param
[1] );
472 p
[2] = INT_TO_FLOAT( param
[2] );
473 p
[3] = INT_TO_FLOAT( param
[3] );
474 _mesa_TexEnvfv( target
, pname
, p
);
479 _mesa_GetTexEnvfv( GLenum target
, GLenum pname
, GLfloat
*params
)
481 GET_CURRENT_CONTEXT(ctx
);
482 const struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
483 ASSERT_OUTSIDE_BEGIN_END(ctx
);
485 if (target
!=GL_TEXTURE_ENV
) {
486 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(target)" );
491 case GL_TEXTURE_ENV_MODE
:
492 *params
= ENUM_TO_FLOAT(texUnit
->EnvMode
);
494 case GL_TEXTURE_ENV_COLOR
:
495 COPY_4FV( params
, texUnit
->EnvColor
);
497 case GL_COMBINE_RGB_EXT
:
498 if (ctx
->Extensions
.EXT_texture_env_combine
||
499 ctx
->Extensions
.ARB_texture_env_combine
) {
500 *params
= (GLfloat
) texUnit
->CombineModeRGB
;
503 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
506 case GL_COMBINE_ALPHA_EXT
:
507 if (ctx
->Extensions
.EXT_texture_env_combine
||
508 ctx
->Extensions
.ARB_texture_env_combine
) {
509 *params
= (GLfloat
) texUnit
->CombineModeA
;
512 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
515 case GL_SOURCE0_RGB_EXT
:
516 if (ctx
->Extensions
.EXT_texture_env_combine
||
517 ctx
->Extensions
.ARB_texture_env_combine
) {
518 *params
= (GLfloat
) texUnit
->CombineSourceRGB
[0];
521 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
524 case GL_SOURCE1_RGB_EXT
:
525 if (ctx
->Extensions
.EXT_texture_env_combine
||
526 ctx
->Extensions
.ARB_texture_env_combine
) {
527 *params
= (GLfloat
) texUnit
->CombineSourceRGB
[1];
530 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
533 case GL_SOURCE2_RGB_EXT
:
534 if (ctx
->Extensions
.EXT_texture_env_combine
||
535 ctx
->Extensions
.ARB_texture_env_combine
) {
536 *params
= (GLfloat
) texUnit
->CombineSourceRGB
[2];
539 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
542 case GL_SOURCE0_ALPHA_EXT
:
543 if (ctx
->Extensions
.EXT_texture_env_combine
||
544 ctx
->Extensions
.ARB_texture_env_combine
) {
545 *params
= (GLfloat
) texUnit
->CombineSourceA
[0];
548 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
551 case GL_SOURCE1_ALPHA_EXT
:
552 if (ctx
->Extensions
.EXT_texture_env_combine
||
553 ctx
->Extensions
.ARB_texture_env_combine
) {
554 *params
= (GLfloat
) texUnit
->CombineSourceA
[1];
557 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
560 case GL_SOURCE2_ALPHA_EXT
:
561 if (ctx
->Extensions
.EXT_texture_env_combine
||
562 ctx
->Extensions
.ARB_texture_env_combine
) {
563 *params
= (GLfloat
) texUnit
->CombineSourceA
[2];
566 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
569 case GL_OPERAND0_RGB_EXT
:
570 if (ctx
->Extensions
.EXT_texture_env_combine
||
571 ctx
->Extensions
.ARB_texture_env_combine
) {
572 *params
= (GLfloat
) texUnit
->CombineOperandRGB
[0];
575 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
578 case GL_OPERAND1_RGB_EXT
:
579 if (ctx
->Extensions
.EXT_texture_env_combine
||
580 ctx
->Extensions
.ARB_texture_env_combine
) {
581 *params
= (GLfloat
) texUnit
->CombineOperandRGB
[1];
584 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
587 case GL_OPERAND2_RGB_EXT
:
588 if (ctx
->Extensions
.EXT_texture_env_combine
||
589 ctx
->Extensions
.ARB_texture_env_combine
) {
590 *params
= (GLfloat
) texUnit
->CombineOperandRGB
[2];
593 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
596 case GL_OPERAND0_ALPHA_EXT
:
597 if (ctx
->Extensions
.EXT_texture_env_combine
||
598 ctx
->Extensions
.ARB_texture_env_combine
) {
599 *params
= (GLfloat
) texUnit
->CombineOperandA
[0];
602 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
605 case GL_OPERAND1_ALPHA_EXT
:
606 if (ctx
->Extensions
.EXT_texture_env_combine
||
607 ctx
->Extensions
.ARB_texture_env_combine
) {
608 *params
= (GLfloat
) texUnit
->CombineOperandA
[1];
611 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
614 case GL_OPERAND2_ALPHA_EXT
:
615 if (ctx
->Extensions
.EXT_texture_env_combine
||
616 ctx
->Extensions
.ARB_texture_env_combine
) {
617 *params
= (GLfloat
) texUnit
->CombineOperandA
[2];
620 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
623 case GL_RGB_SCALE_EXT
:
624 if (ctx
->Extensions
.EXT_texture_env_combine
||
625 ctx
->Extensions
.ARB_texture_env_combine
) {
626 if (texUnit
->CombineScaleShiftRGB
== 0)
628 else if (texUnit
->CombineScaleShiftRGB
== 1)
634 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
639 if (ctx
->Extensions
.EXT_texture_env_combine
||
640 ctx
->Extensions
.ARB_texture_env_combine
) {
641 if (texUnit
->CombineScaleShiftA
== 0)
643 else if (texUnit
->CombineScaleShiftA
== 1)
649 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
654 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)" );
660 _mesa_GetTexEnviv( GLenum target
, GLenum pname
, GLint
*params
)
662 GET_CURRENT_CONTEXT(ctx
);
663 const struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
664 ASSERT_OUTSIDE_BEGIN_END(ctx
);
666 if (target
!= GL_TEXTURE_ENV
) {
667 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(target)" );
672 case GL_TEXTURE_ENV_MODE
:
673 *params
= (GLint
) texUnit
->EnvMode
;
675 case GL_TEXTURE_ENV_COLOR
:
676 params
[0] = FLOAT_TO_INT( texUnit
->EnvColor
[0] );
677 params
[1] = FLOAT_TO_INT( texUnit
->EnvColor
[1] );
678 params
[2] = FLOAT_TO_INT( texUnit
->EnvColor
[2] );
679 params
[3] = FLOAT_TO_INT( texUnit
->EnvColor
[3] );
681 case GL_COMBINE_RGB_EXT
:
682 if (ctx
->Extensions
.EXT_texture_env_combine
||
683 ctx
->Extensions
.ARB_texture_env_combine
) {
684 *params
= (GLint
) texUnit
->CombineModeRGB
;
687 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
690 case GL_COMBINE_ALPHA_EXT
:
691 if (ctx
->Extensions
.EXT_texture_env_combine
||
692 ctx
->Extensions
.ARB_texture_env_combine
) {
693 *params
= (GLint
) texUnit
->CombineModeA
;
696 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
699 case GL_SOURCE0_RGB_EXT
:
700 if (ctx
->Extensions
.EXT_texture_env_combine
||
701 ctx
->Extensions
.ARB_texture_env_combine
) {
702 *params
= (GLint
) texUnit
->CombineSourceRGB
[0];
705 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
708 case GL_SOURCE1_RGB_EXT
:
709 if (ctx
->Extensions
.EXT_texture_env_combine
||
710 ctx
->Extensions
.ARB_texture_env_combine
) {
711 *params
= (GLint
) texUnit
->CombineSourceRGB
[1];
714 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
717 case GL_SOURCE2_RGB_EXT
:
718 if (ctx
->Extensions
.EXT_texture_env_combine
||
719 ctx
->Extensions
.ARB_texture_env_combine
) {
720 *params
= (GLint
) texUnit
->CombineSourceRGB
[2];
723 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
726 case GL_SOURCE0_ALPHA_EXT
:
727 if (ctx
->Extensions
.EXT_texture_env_combine
||
728 ctx
->Extensions
.ARB_texture_env_combine
) {
729 *params
= (GLint
) texUnit
->CombineSourceA
[0];
732 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
735 case GL_SOURCE1_ALPHA_EXT
:
736 if (ctx
->Extensions
.EXT_texture_env_combine
||
737 ctx
->Extensions
.ARB_texture_env_combine
) {
738 *params
= (GLint
) texUnit
->CombineSourceA
[1];
741 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
744 case GL_SOURCE2_ALPHA_EXT
:
745 if (ctx
->Extensions
.EXT_texture_env_combine
||
746 ctx
->Extensions
.ARB_texture_env_combine
) {
747 *params
= (GLint
) texUnit
->CombineSourceA
[2];
750 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
753 case GL_OPERAND0_RGB_EXT
:
754 if (ctx
->Extensions
.EXT_texture_env_combine
||
755 ctx
->Extensions
.ARB_texture_env_combine
) {
756 *params
= (GLint
) texUnit
->CombineOperandRGB
[0];
759 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
762 case GL_OPERAND1_RGB_EXT
:
763 if (ctx
->Extensions
.EXT_texture_env_combine
||
764 ctx
->Extensions
.ARB_texture_env_combine
) {
765 *params
= (GLint
) texUnit
->CombineOperandRGB
[1];
768 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
771 case GL_OPERAND2_RGB_EXT
:
772 if (ctx
->Extensions
.EXT_texture_env_combine
||
773 ctx
->Extensions
.ARB_texture_env_combine
) {
774 *params
= (GLint
) texUnit
->CombineOperandRGB
[2];
777 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
780 case GL_OPERAND0_ALPHA_EXT
:
781 if (ctx
->Extensions
.EXT_texture_env_combine
||
782 ctx
->Extensions
.ARB_texture_env_combine
) {
783 *params
= (GLint
) texUnit
->CombineOperandA
[0];
786 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
789 case GL_OPERAND1_ALPHA_EXT
:
790 if (ctx
->Extensions
.EXT_texture_env_combine
||
791 ctx
->Extensions
.ARB_texture_env_combine
) {
792 *params
= (GLint
) texUnit
->CombineOperandA
[1];
795 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
798 case GL_OPERAND2_ALPHA_EXT
:
799 if (ctx
->Extensions
.EXT_texture_env_combine
||
800 ctx
->Extensions
.ARB_texture_env_combine
) {
801 *params
= (GLint
) texUnit
->CombineOperandA
[2];
804 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
807 case GL_RGB_SCALE_EXT
:
808 if (ctx
->Extensions
.EXT_texture_env_combine
||
809 ctx
->Extensions
.ARB_texture_env_combine
) {
810 if (texUnit
->CombineScaleShiftRGB
== 0)
812 else if (texUnit
->CombineScaleShiftRGB
== 1)
818 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
823 if (ctx
->Extensions
.EXT_texture_env_combine
||
824 ctx
->Extensions
.ARB_texture_env_combine
) {
825 if (texUnit
->CombineScaleShiftA
== 0)
827 else if (texUnit
->CombineScaleShiftA
== 1)
833 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
838 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)" );
845 /**********************************************************************/
846 /* Texture Parameters */
847 /**********************************************************************/
851 _mesa_TexParameterf( GLenum target
, GLenum pname
, GLfloat param
)
853 _mesa_TexParameterfv(target
, pname
, ¶m
);
858 _mesa_TexParameterfv( GLenum target
, GLenum pname
, const GLfloat
*params
)
860 GET_CURRENT_CONTEXT(ctx
);
861 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
862 GLenum eparam
= (GLenum
) (GLint
) params
[0];
863 struct gl_texture_object
*texObj
;
864 ASSERT_OUTSIDE_BEGIN_END(ctx
);
866 if (MESA_VERBOSE
&(VERBOSE_API
|VERBOSE_TEXTURE
))
867 fprintf(stderr
, "texPARAM %s %s %d...\n",
868 _mesa_lookup_enum_by_nr(target
),
869 _mesa_lookup_enum_by_nr(pname
),
875 texObj
= texUnit
->Current1D
;
878 texObj
= texUnit
->Current2D
;
880 case GL_TEXTURE_3D_EXT
:
881 texObj
= texUnit
->Current3D
;
883 case GL_TEXTURE_CUBE_MAP_ARB
:
884 if (ctx
->Extensions
.ARB_texture_cube_map
) {
885 texObj
= texUnit
->CurrentCubeMap
;
890 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexParameter(target)" );
895 case GL_TEXTURE_MIN_FILTER
:
896 /* A small optimization */
897 if (texObj
->MinFilter
== eparam
)
900 if (eparam
==GL_NEAREST
|| eparam
==GL_LINEAR
901 || eparam
==GL_NEAREST_MIPMAP_NEAREST
902 || eparam
==GL_LINEAR_MIPMAP_NEAREST
903 || eparam
==GL_NEAREST_MIPMAP_LINEAR
904 || eparam
==GL_LINEAR_MIPMAP_LINEAR
) {
905 texObj
->MinFilter
= eparam
;
908 _mesa_error( ctx
, GL_INVALID_VALUE
, "glTexParameter(param)" );
912 case GL_TEXTURE_MAG_FILTER
:
913 /* A small optimization */
914 if (texObj
->MagFilter
== eparam
)
917 if (eparam
==GL_NEAREST
|| eparam
==GL_LINEAR
) {
918 texObj
->MagFilter
= eparam
;
921 _mesa_error( ctx
, GL_INVALID_VALUE
, "glTexParameter(param)" );
925 case GL_TEXTURE_WRAP_S
:
926 if (texObj
->WrapS
== eparam
)
928 if (eparam
==GL_CLAMP
||
930 eparam
==GL_CLAMP_TO_EDGE
||
931 (eparam
== GL_CLAMP_TO_BORDER_ARB
&&
932 ctx
->Extensions
.ARB_texture_border_clamp
)) {
933 texObj
->WrapS
= eparam
;
936 _mesa_error( ctx
, GL_INVALID_VALUE
, "glTexParameter(param)" );
940 case GL_TEXTURE_WRAP_T
:
941 if (texObj
->WrapT
== eparam
)
943 if (eparam
==GL_CLAMP
||
945 eparam
==GL_CLAMP_TO_EDGE
||
946 (eparam
== GL_CLAMP_TO_BORDER_ARB
&&
947 ctx
->Extensions
.ARB_texture_border_clamp
)) {
948 texObj
->WrapT
= eparam
;
951 _mesa_error( ctx
, GL_INVALID_VALUE
, "glTexParameter(param)" );
955 case GL_TEXTURE_WRAP_R_EXT
:
956 if (texObj
->WrapR
== eparam
)
958 if (eparam
==GL_CLAMP
||
960 eparam
==GL_CLAMP_TO_EDGE
||
961 (eparam
== GL_CLAMP_TO_BORDER_ARB
&&
962 ctx
->Extensions
.ARB_texture_border_clamp
)) {
963 texObj
->WrapR
= eparam
;
966 _mesa_error( ctx
, GL_INVALID_VALUE
, "glTexParameter(param)" );
969 case GL_TEXTURE_BORDER_COLOR
:
970 UNCLAMPED_FLOAT_TO_CHAN(texObj
->BorderColor
[0], params
[0]);
971 UNCLAMPED_FLOAT_TO_CHAN(texObj
->BorderColor
[1], params
[1]);
972 UNCLAMPED_FLOAT_TO_CHAN(texObj
->BorderColor
[2], params
[2]);
973 UNCLAMPED_FLOAT_TO_CHAN(texObj
->BorderColor
[3], params
[3]);
975 case GL_TEXTURE_MIN_LOD
:
976 texObj
->MinLod
= params
[0];
978 case GL_TEXTURE_MAX_LOD
:
979 texObj
->MaxLod
= params
[0];
981 case GL_TEXTURE_BASE_LEVEL
:
982 if (params
[0] < 0.0) {
983 _mesa_error(ctx
, GL_INVALID_VALUE
, "glTexParameter(param)" );
986 texObj
->BaseLevel
= (GLint
) params
[0];
988 case GL_TEXTURE_MAX_LEVEL
:
989 if (params
[0] < 0.0) {
990 _mesa_error(ctx
, GL_INVALID_VALUE
, "glTexParameter(param)" );
993 texObj
->MaxLevel
= (GLint
) params
[0];
995 case GL_TEXTURE_PRIORITY
:
996 /* (keithh@netcomuk.co.uk) */
997 texObj
->Priority
= CLAMP( params
[0], 0.0F
, 1.0F
);
999 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1000 if (ctx
->Extensions
.EXT_texture_filter_anisotropic
) {
1001 if (params
[0] < 1.0) {
1002 _mesa_error(ctx
, GL_INVALID_VALUE
, "glTexParameter(param)" );
1005 texObj
->MaxAnisotropy
= params
[0];
1008 _mesa_error(ctx
, GL_INVALID_ENUM
, "glTexParameter(pname)");
1012 case GL_TEXTURE_COMPARE_SGIX
:
1013 if (ctx
->Extensions
.SGIX_shadow
) {
1014 texObj
->CompareFlag
= params
[0] ? GL_TRUE
: GL_FALSE
;
1017 _mesa_error(ctx
, GL_INVALID_ENUM
, "glTexParameter(pname)");
1021 case GL_TEXTURE_COMPARE_OPERATOR_SGIX
:
1022 if (ctx
->Extensions
.SGIX_shadow
) {
1023 GLenum op
= (GLenum
) params
[0];
1024 if (op
== GL_TEXTURE_LEQUAL_R_SGIX
||
1025 op
== GL_TEXTURE_GEQUAL_R_SGIX
) {
1026 texObj
->CompareOperator
= op
;
1029 _mesa_error(ctx
, GL_INVALID_ENUM
, "glTexParameter(param)");
1033 _mesa_error(ctx
, GL_INVALID_ENUM
, "glTexParameter(pname)");
1037 case GL_SHADOW_AMBIENT_SGIX
:
1038 if (ctx
->Extensions
.SGIX_shadow_ambient
) {
1039 UNCLAMPED_FLOAT_TO_CHAN(texObj
->ShadowAmbient
, params
[0]);
1042 _mesa_error(ctx
, GL_INVALID_ENUM
, "glTexParameter(pname)");
1046 case GL_GENERATE_MIPMAP_SGIS
:
1047 if (ctx
->Extensions
.SGIS_generate_mipmap
) {
1048 texObj
->GenerateMipmap
= params
[0] ? GL_TRUE
: GL_FALSE
;
1051 _mesa_error(ctx
, GL_INVALID_ENUM
, "glTexParameter(pname)");
1056 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexParameter(pname)" );
1060 ctx
->NewState
|= _NEW_TEXTURE
;
1061 texObj
->Complete
= GL_FALSE
;
1063 if (ctx
->Driver
.TexParameter
) {
1064 (*ctx
->Driver
.TexParameter
)( ctx
, target
, texObj
, pname
, params
);
1070 _mesa_TexParameteri( GLenum target
, GLenum pname
, GLint param
)
1073 fparam
[0] = (GLfloat
) param
;
1074 fparam
[1] = fparam
[2] = fparam
[3] = 0.0;
1075 _mesa_TexParameterfv(target
, pname
, fparam
);
1079 _mesa_TexParameteriv( GLenum target
, GLenum pname
, const GLint
*params
)
1082 fparam
[0] = (GLfloat
) params
[0];
1083 fparam
[1] = fparam
[2] = fparam
[3] = 0.0;
1084 _mesa_TexParameterfv(target
, pname
, fparam
);
1089 _mesa_GetTexLevelParameterfv( GLenum target
, GLint level
,
1090 GLenum pname
, GLfloat
*params
)
1093 _mesa_GetTexLevelParameteriv( target
, level
, pname
, &iparam
);
1094 *params
= (GLfloat
) iparam
;
1099 tex_image_dimensions(GLcontext
*ctx
, GLenum target
)
1103 case GL_PROXY_TEXTURE_1D
:
1106 case GL_PROXY_TEXTURE_2D
:
1109 case GL_PROXY_TEXTURE_3D
:
1111 case GL_TEXTURE_CUBE_MAP_ARB
:
1112 case GL_PROXY_TEXTURE_CUBE_MAP_ARB
:
1113 case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB
:
1114 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB
:
1115 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB
:
1116 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB
:
1117 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB
:
1118 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB
:
1119 return ctx
->Extensions
.ARB_texture_cube_map
? 2 : 0;
1121 _mesa_problem(ctx
, "bad target in _mesa_tex_target_dimensions()");
1128 _mesa_GetTexLevelParameteriv( GLenum target
, GLint level
,
1129 GLenum pname
, GLint
*params
)
1131 GET_CURRENT_CONTEXT(ctx
);
1132 const struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1133 const struct gl_texture_image
*img
= NULL
;
1136 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1138 if (level
< 0 || level
>= ctx
->Const
.MaxTextureLevels
) {
1139 _mesa_error( ctx
, GL_INVALID_VALUE
, "glGetTexLevelParameter[if]v" );
1143 dimensions
= tex_image_dimensions(ctx
, target
); /* 1, 2 or 3 */
1144 if (dimensions
== 0) {
1145 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexLevelParameter[if]v(target)");
1149 img
= _mesa_select_tex_image(ctx
, texUnit
, target
, level
);
1150 if (!img
|| !img
->TexFormat
) {
1151 /* undefined texture image */
1152 if (pname
== GL_TEXTURE_COMPONENTS
)
1159 isProxy
= (target
== GL_PROXY_TEXTURE_1D
) ||
1160 (target
== GL_PROXY_TEXTURE_2D
) ||
1161 (target
== GL_PROXY_TEXTURE_3D
) ||
1162 (target
== GL_PROXY_TEXTURE_CUBE_MAP_ARB
);
1165 case GL_TEXTURE_WIDTH
:
1166 *params
= img
->Width
;
1168 case GL_TEXTURE_HEIGHT
:
1169 *params
= img
->Height
;
1171 case GL_TEXTURE_DEPTH
:
1172 *params
= img
->Depth
;
1174 case GL_TEXTURE_INTERNAL_FORMAT
:
1175 *params
= img
->IntFormat
;
1177 case GL_TEXTURE_BORDER
:
1178 *params
= img
->Border
;
1180 case GL_TEXTURE_RED_SIZE
:
1181 if (img
->Format
== GL_RGB
|| img
->Format
== GL_RGBA
)
1182 *params
= img
->TexFormat
->RedBits
;
1186 case GL_TEXTURE_GREEN_SIZE
:
1187 if (img
->Format
== GL_RGB
|| img
->Format
== GL_RGBA
)
1188 *params
= img
->TexFormat
->GreenBits
;
1192 case GL_TEXTURE_BLUE_SIZE
:
1193 if (img
->Format
== GL_RGB
|| img
->Format
== GL_RGBA
)
1194 *params
= img
->TexFormat
->BlueBits
;
1198 case GL_TEXTURE_ALPHA_SIZE
:
1199 if (img
->Format
== GL_ALPHA
|| img
->Format
== GL_LUMINANCE_ALPHA
||
1200 img
->Format
== GL_RGBA
)
1201 *params
= img
->TexFormat
->AlphaBits
;
1205 case GL_TEXTURE_INTENSITY_SIZE
:
1206 if (img
->Format
!= GL_INTENSITY
)
1208 else if (img
->TexFormat
->IntensityBits
> 0)
1209 *params
= img
->TexFormat
->IntensityBits
;
1210 else /* intensity probably stored as rgb texture */
1211 *params
= MIN2(img
->TexFormat
->RedBits
, img
->TexFormat
->GreenBits
);
1213 case GL_TEXTURE_LUMINANCE_SIZE
:
1214 if (img
->Format
!= GL_LUMINANCE
&&
1215 img
->Format
!= GL_LUMINANCE_ALPHA
)
1217 else if (img
->TexFormat
->LuminanceBits
> 0)
1218 *params
= img
->TexFormat
->LuminanceBits
;
1219 else /* luminance probably stored as rgb texture */
1220 *params
= MIN2(img
->TexFormat
->RedBits
, img
->TexFormat
->GreenBits
);
1222 case GL_TEXTURE_INDEX_SIZE_EXT
:
1223 if (img
->Format
== GL_COLOR_INDEX
)
1224 *params
= img
->TexFormat
->IndexBits
;
1229 /* XXX this isn't in the GL_SGIX_depth_texture spec
1230 * but seems appropriate.
1232 if (ctx
->Extensions
.SGIX_depth_texture
)
1233 *params
= img
->TexFormat
->DepthBits
;
1235 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexLevelParameter[if]v(pname)");
1238 /* GL_ARB_texture_compression */
1239 case GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB
:
1240 if (ctx
->Extensions
.ARB_texture_compression
) {
1241 if (img
->IsCompressed
&& !isProxy
)
1242 *params
= img
->CompressedSize
;
1244 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1245 "glGetTexLevelParameter[if]v(pname)");
1248 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexLevelParameter[if]v(pname)");
1251 case GL_TEXTURE_COMPRESSED_ARB
:
1252 if (ctx
->Extensions
.ARB_texture_compression
) {
1253 *params
= (GLint
) img
->IsCompressed
;
1256 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexLevelParameter[if]v(pname)");
1261 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexLevelParameter[if]v(pname)");
1268 _mesa_GetTexParameterfv( GLenum target
, GLenum pname
, GLfloat
*params
)
1270 GET_CURRENT_CONTEXT(ctx
);
1271 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1272 struct gl_texture_object
*obj
;
1273 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1275 obj
= _mesa_select_tex_object(ctx
, texUnit
, target
);
1277 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexParameterfv(target)");
1282 case GL_TEXTURE_MAG_FILTER
:
1283 *params
= ENUM_TO_FLOAT(obj
->MagFilter
);
1285 case GL_TEXTURE_MIN_FILTER
:
1286 *params
= ENUM_TO_FLOAT(obj
->MinFilter
);
1288 case GL_TEXTURE_WRAP_S
:
1289 *params
= ENUM_TO_FLOAT(obj
->WrapS
);
1291 case GL_TEXTURE_WRAP_T
:
1292 *params
= ENUM_TO_FLOAT(obj
->WrapT
);
1294 case GL_TEXTURE_WRAP_R_EXT
:
1295 *params
= ENUM_TO_FLOAT(obj
->WrapR
);
1297 case GL_TEXTURE_BORDER_COLOR
:
1298 params
[0] = obj
->BorderColor
[0] / CHAN_MAXF
;
1299 params
[1] = obj
->BorderColor
[1] / CHAN_MAXF
;
1300 params
[2] = obj
->BorderColor
[2] / CHAN_MAXF
;
1301 params
[3] = obj
->BorderColor
[3] / CHAN_MAXF
;
1303 case GL_TEXTURE_RESIDENT
:
1306 if (ctx
->Driver
.IsTextureResident
)
1307 resident
= ctx
->Driver
.IsTextureResident(ctx
, obj
);
1310 *params
= ENUM_TO_FLOAT(resident
);
1313 case GL_TEXTURE_PRIORITY
:
1314 *params
= obj
->Priority
;
1316 case GL_TEXTURE_MIN_LOD
:
1317 *params
= obj
->MinLod
;
1319 case GL_TEXTURE_MAX_LOD
:
1320 *params
= obj
->MaxLod
;
1322 case GL_TEXTURE_BASE_LEVEL
:
1323 *params
= (GLfloat
) obj
->BaseLevel
;
1325 case GL_TEXTURE_MAX_LEVEL
:
1326 *params
= (GLfloat
) obj
->MaxLevel
;
1328 case GL_TEXTURE_COMPARE_SGIX
:
1329 if (ctx
->Extensions
.SGIX_shadow
) {
1330 *params
= (GLfloat
) obj
->CompareFlag
;
1334 case GL_TEXTURE_COMPARE_OPERATOR_SGIX
:
1335 if (ctx
->Extensions
.SGIX_shadow
) {
1336 *params
= (GLfloat
) obj
->CompareOperator
;
1340 case GL_SHADOW_AMBIENT_SGIX
:
1341 if (ctx
->Extensions
.SGIX_shadow_ambient
) {
1342 *params
= CHAN_TO_FLOAT(obj
->ShadowAmbient
);
1346 case GL_GENERATE_MIPMAP_SGIS
:
1347 if (ctx
->Extensions
.SGIS_generate_mipmap
) {
1348 *params
= (GLfloat
) obj
->GenerateMipmap
;
1353 ; /* silence warnings */
1355 /* If we get here, pname was an unrecognized enum */
1356 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexParameterfv(pname)" );
1361 _mesa_GetTexParameteriv( GLenum target
, GLenum pname
, GLint
*params
)
1363 GET_CURRENT_CONTEXT(ctx
);
1364 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1365 struct gl_texture_object
*obj
;
1366 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1368 obj
= _mesa_select_tex_object(ctx
, texUnit
, target
);
1370 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexParameteriv(target)");
1375 case GL_TEXTURE_MAG_FILTER
:
1376 *params
= (GLint
) obj
->MagFilter
;
1378 case GL_TEXTURE_MIN_FILTER
:
1379 *params
= (GLint
) obj
->MinFilter
;
1381 case GL_TEXTURE_WRAP_S
:
1382 *params
= (GLint
) obj
->WrapS
;
1384 case GL_TEXTURE_WRAP_T
:
1385 *params
= (GLint
) obj
->WrapT
;
1387 case GL_TEXTURE_WRAP_R_EXT
:
1388 *params
= (GLint
) obj
->WrapR
;
1390 case GL_TEXTURE_BORDER_COLOR
:
1393 color
[0] = obj
->BorderColor
[0] / CHAN_MAXF
;
1394 color
[1] = obj
->BorderColor
[1] / CHAN_MAXF
;
1395 color
[2] = obj
->BorderColor
[2] / CHAN_MAXF
;
1396 color
[3] = obj
->BorderColor
[3] / CHAN_MAXF
;
1397 params
[0] = FLOAT_TO_INT( color
[0] );
1398 params
[1] = FLOAT_TO_INT( color
[1] );
1399 params
[2] = FLOAT_TO_INT( color
[2] );
1400 params
[3] = FLOAT_TO_INT( color
[3] );
1403 case GL_TEXTURE_RESIDENT
:
1406 if (ctx
->Driver
.IsTextureResident
)
1407 resident
= ctx
->Driver
.IsTextureResident(ctx
, obj
);
1410 *params
= (GLint
) resident
;
1413 case GL_TEXTURE_PRIORITY
:
1414 *params
= (GLint
) obj
->Priority
;
1416 case GL_TEXTURE_MIN_LOD
:
1417 *params
= (GLint
) obj
->MinLod
;
1419 case GL_TEXTURE_MAX_LOD
:
1420 *params
= (GLint
) obj
->MaxLod
;
1422 case GL_TEXTURE_BASE_LEVEL
:
1423 *params
= obj
->BaseLevel
;
1425 case GL_TEXTURE_MAX_LEVEL
:
1426 *params
= obj
->MaxLevel
;
1428 case GL_TEXTURE_COMPARE_SGIX
:
1429 if (ctx
->Extensions
.SGIX_shadow
) {
1430 *params
= (GLint
) obj
->CompareFlag
;
1434 case GL_TEXTURE_COMPARE_OPERATOR_SGIX
:
1435 if (ctx
->Extensions
.SGIX_shadow
) {
1436 *params
= (GLint
) obj
->CompareOperator
;
1440 case GL_SHADOW_AMBIENT_SGIX
:
1441 if (ctx
->Extensions
.SGIX_shadow_ambient
) {
1443 *params
= (GLint
) CHAN_TO_FLOAT(obj
->ShadowAmbient
);
1447 case GL_GENERATE_MIPMAP_SGIS
:
1448 if (ctx
->Extensions
.SGIS_generate_mipmap
) {
1449 *params
= (GLint
) obj
->GenerateMipmap
;
1454 ; /* silence warnings */
1456 /* If we get here, pname was an unrecognized enum */
1457 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexParameteriv(pname)" );
1463 /**********************************************************************/
1464 /* Texture Coord Generation */
1465 /**********************************************************************/
1469 _mesa_TexGenfv( GLenum coord
, GLenum pname
, const GLfloat
*params
)
1471 GET_CURRENT_CONTEXT(ctx
);
1472 GLuint tUnit
= ctx
->Texture
.CurrentTransformUnit
;
1473 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[tUnit
];
1474 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1476 if (MESA_VERBOSE
&(VERBOSE_API
|VERBOSE_TEXTURE
))
1477 fprintf(stderr
, "texGEN %s %s %x...\n",
1478 _mesa_lookup_enum_by_nr(coord
),
1479 _mesa_lookup_enum_by_nr(pname
),
1484 if (pname
==GL_TEXTURE_GEN_MODE
) {
1485 GLenum mode
= (GLenum
) (GLint
) *params
;
1488 case GL_OBJECT_LINEAR
:
1489 bits
= TEXGEN_OBJ_LINEAR
;
1492 bits
= TEXGEN_EYE_LINEAR
;
1494 case GL_REFLECTION_MAP_NV
:
1495 bits
= TEXGEN_REFLECTION_MAP_NV
;
1497 case GL_NORMAL_MAP_NV
:
1498 bits
= TEXGEN_NORMAL_MAP_NV
;
1501 bits
= TEXGEN_SPHERE_MAP
;
1504 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(param)" );
1507 if (texUnit
->GenModeS
== mode
)
1509 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1510 texUnit
->GenModeS
= mode
;
1511 texUnit
->_GenBitS
= bits
;
1513 else if (pname
==GL_OBJECT_PLANE
) {
1514 if (TEST_EQ_4V(texUnit
->ObjectPlaneS
, params
))
1516 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1517 texUnit
->ObjectPlaneS
[0] = params
[0];
1518 texUnit
->ObjectPlaneS
[1] = params
[1];
1519 texUnit
->ObjectPlaneS
[2] = params
[2];
1520 texUnit
->ObjectPlaneS
[3] = params
[3];
1522 else if (pname
==GL_EYE_PLANE
) {
1525 /* Transform plane equation by the inverse modelview matrix */
1526 if (ctx
->ModelView
.flags
& MAT_DIRTY_INVERSE
) {
1527 _math_matrix_analyse( &ctx
->ModelView
);
1529 _mesa_transform_vector( tmp
, params
, ctx
->ModelView
.inv
);
1530 if (TEST_EQ_4V(texUnit
->EyePlaneS
, tmp
))
1532 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1533 COPY_4FV(texUnit
->EyePlaneS
, tmp
);
1536 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(pname)" );
1541 if (pname
==GL_TEXTURE_GEN_MODE
) {
1542 GLenum mode
= (GLenum
) (GLint
) *params
;
1545 case GL_OBJECT_LINEAR
:
1546 bitt
= TEXGEN_OBJ_LINEAR
;
1549 bitt
= TEXGEN_EYE_LINEAR
;
1551 case GL_REFLECTION_MAP_NV
:
1552 bitt
= TEXGEN_REFLECTION_MAP_NV
;
1554 case GL_NORMAL_MAP_NV
:
1555 bitt
= TEXGEN_NORMAL_MAP_NV
;
1558 bitt
= TEXGEN_SPHERE_MAP
;
1561 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(param)" );
1564 if (texUnit
->GenModeT
== mode
)
1566 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1567 texUnit
->GenModeT
= mode
;
1568 texUnit
->_GenBitT
= bitt
;
1570 else if (pname
==GL_OBJECT_PLANE
) {
1571 if (TEST_EQ_4V(texUnit
->ObjectPlaneT
, params
))
1573 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1574 texUnit
->ObjectPlaneT
[0] = params
[0];
1575 texUnit
->ObjectPlaneT
[1] = params
[1];
1576 texUnit
->ObjectPlaneT
[2] = params
[2];
1577 texUnit
->ObjectPlaneT
[3] = params
[3];
1579 else if (pname
==GL_EYE_PLANE
) {
1581 /* Transform plane equation by the inverse modelview matrix */
1582 if (ctx
->ModelView
.flags
& MAT_DIRTY_INVERSE
) {
1583 _math_matrix_analyse( &ctx
->ModelView
);
1585 _mesa_transform_vector( tmp
, params
, ctx
->ModelView
.inv
);
1586 if (TEST_EQ_4V(texUnit
->EyePlaneT
, tmp
))
1588 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1589 COPY_4FV(texUnit
->EyePlaneT
, tmp
);
1592 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(pname)" );
1597 if (pname
==GL_TEXTURE_GEN_MODE
) {
1598 GLenum mode
= (GLenum
) (GLint
) *params
;
1601 case GL_OBJECT_LINEAR
:
1602 bitr
= TEXGEN_OBJ_LINEAR
;
1604 case GL_REFLECTION_MAP_NV
:
1605 bitr
= TEXGEN_REFLECTION_MAP_NV
;
1607 case GL_NORMAL_MAP_NV
:
1608 bitr
= TEXGEN_NORMAL_MAP_NV
;
1611 bitr
= TEXGEN_EYE_LINEAR
;
1614 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(param)" );
1617 if (texUnit
->GenModeR
== mode
)
1619 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1620 texUnit
->GenModeR
= mode
;
1621 texUnit
->_GenBitR
= bitr
;
1623 else if (pname
==GL_OBJECT_PLANE
) {
1624 if (TEST_EQ_4V(texUnit
->ObjectPlaneR
, params
))
1626 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1627 texUnit
->ObjectPlaneR
[0] = params
[0];
1628 texUnit
->ObjectPlaneR
[1] = params
[1];
1629 texUnit
->ObjectPlaneR
[2] = params
[2];
1630 texUnit
->ObjectPlaneR
[3] = params
[3];
1632 else if (pname
==GL_EYE_PLANE
) {
1634 /* Transform plane equation by the inverse modelview matrix */
1635 if (ctx
->ModelView
.flags
& MAT_DIRTY_INVERSE
) {
1636 _math_matrix_analyse( &ctx
->ModelView
);
1638 _mesa_transform_vector( tmp
, params
, ctx
->ModelView
.inv
);
1639 if (TEST_EQ_4V(texUnit
->EyePlaneR
, tmp
))
1641 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1642 COPY_4FV(texUnit
->EyePlaneR
, tmp
);
1645 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(pname)" );
1650 if (pname
==GL_TEXTURE_GEN_MODE
) {
1651 GLenum mode
= (GLenum
) (GLint
) *params
;
1654 case GL_OBJECT_LINEAR
:
1655 bitq
= TEXGEN_OBJ_LINEAR
;
1658 bitq
= TEXGEN_EYE_LINEAR
;
1661 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(param)" );
1664 if (texUnit
->GenModeQ
== mode
)
1666 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1667 texUnit
->GenModeQ
= mode
;
1668 texUnit
->_GenBitQ
= bitq
;
1670 else if (pname
==GL_OBJECT_PLANE
) {
1671 if (TEST_EQ_4V(texUnit
->ObjectPlaneQ
, params
))
1673 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1674 texUnit
->ObjectPlaneQ
[0] = params
[0];
1675 texUnit
->ObjectPlaneQ
[1] = params
[1];
1676 texUnit
->ObjectPlaneQ
[2] = params
[2];
1677 texUnit
->ObjectPlaneQ
[3] = params
[3];
1679 else if (pname
==GL_EYE_PLANE
) {
1681 /* Transform plane equation by the inverse modelview matrix */
1682 if (ctx
->ModelView
.flags
& MAT_DIRTY_INVERSE
) {
1683 _math_matrix_analyse( &ctx
->ModelView
);
1685 _mesa_transform_vector( tmp
, params
, ctx
->ModelView
.inv
);
1686 if (TEST_EQ_4V(texUnit
->EyePlaneQ
, tmp
))
1688 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1689 COPY_4FV(texUnit
->EyePlaneQ
, tmp
);
1692 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(pname)" );
1697 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(coord)" );
1701 if (ctx
->Driver
.TexGen
)
1702 ctx
->Driver
.TexGen( ctx
, coord
, pname
, params
);
1707 _mesa_TexGeniv(GLenum coord
, GLenum pname
, const GLint
*params
)
1714 _mesa_TexGenfv(coord
, pname
, p
);
1719 _mesa_TexGend(GLenum coord
, GLenum pname
, GLdouble param
)
1721 GLfloat p
= (GLfloat
) param
;
1722 _mesa_TexGenfv( coord
, pname
, &p
);
1727 _mesa_TexGendv(GLenum coord
, GLenum pname
, const GLdouble
*params
)
1734 _mesa_TexGenfv( coord
, pname
, p
);
1739 _mesa_TexGenf( GLenum coord
, GLenum pname
, GLfloat param
)
1741 _mesa_TexGenfv(coord
, pname
, ¶m
);
1746 _mesa_TexGeni( GLenum coord
, GLenum pname
, GLint param
)
1748 _mesa_TexGeniv( coord
, pname
, ¶m
);
1754 _mesa_GetTexGendv( GLenum coord
, GLenum pname
, GLdouble
*params
)
1756 GET_CURRENT_CONTEXT(ctx
);
1757 GLuint tUnit
= ctx
->Texture
.CurrentTransformUnit
;
1758 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[tUnit
];
1759 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1763 if (pname
==GL_TEXTURE_GEN_MODE
) {
1764 params
[0] = ENUM_TO_DOUBLE(texUnit
->GenModeS
);
1766 else if (pname
==GL_OBJECT_PLANE
) {
1767 COPY_4V( params
, texUnit
->ObjectPlaneS
);
1769 else if (pname
==GL_EYE_PLANE
) {
1770 COPY_4V( params
, texUnit
->EyePlaneS
);
1773 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGendv(pname)" );
1778 if (pname
==GL_TEXTURE_GEN_MODE
) {
1779 params
[0] = ENUM_TO_DOUBLE(texUnit
->GenModeT
);
1781 else if (pname
==GL_OBJECT_PLANE
) {
1782 COPY_4V( params
, texUnit
->ObjectPlaneT
);
1784 else if (pname
==GL_EYE_PLANE
) {
1785 COPY_4V( params
, texUnit
->EyePlaneT
);
1788 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGendv(pname)" );
1793 if (pname
==GL_TEXTURE_GEN_MODE
) {
1794 params
[0] = ENUM_TO_DOUBLE(texUnit
->GenModeR
);
1796 else if (pname
==GL_OBJECT_PLANE
) {
1797 COPY_4V( params
, texUnit
->ObjectPlaneR
);
1799 else if (pname
==GL_EYE_PLANE
) {
1800 COPY_4V( params
, texUnit
->EyePlaneR
);
1803 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGendv(pname)" );
1808 if (pname
==GL_TEXTURE_GEN_MODE
) {
1809 params
[0] = ENUM_TO_DOUBLE(texUnit
->GenModeQ
);
1811 else if (pname
==GL_OBJECT_PLANE
) {
1812 COPY_4V( params
, texUnit
->ObjectPlaneQ
);
1814 else if (pname
==GL_EYE_PLANE
) {
1815 COPY_4V( params
, texUnit
->EyePlaneQ
);
1818 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGendv(pname)" );
1823 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGendv(coord)" );
1831 _mesa_GetTexGenfv( GLenum coord
, GLenum pname
, GLfloat
*params
)
1833 GET_CURRENT_CONTEXT(ctx
);
1834 GLuint tUnit
= ctx
->Texture
.CurrentTransformUnit
;
1835 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[tUnit
];
1836 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1840 if (pname
==GL_TEXTURE_GEN_MODE
) {
1841 params
[0] = ENUM_TO_FLOAT(texUnit
->GenModeS
);
1843 else if (pname
==GL_OBJECT_PLANE
) {
1844 COPY_4V( params
, texUnit
->ObjectPlaneS
);
1846 else if (pname
==GL_EYE_PLANE
) {
1847 COPY_4V( params
, texUnit
->EyePlaneS
);
1850 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGenfv(pname)" );
1855 if (pname
==GL_TEXTURE_GEN_MODE
) {
1856 params
[0] = ENUM_TO_FLOAT(texUnit
->GenModeT
);
1858 else if (pname
==GL_OBJECT_PLANE
) {
1859 COPY_4V( params
, texUnit
->ObjectPlaneT
);
1861 else if (pname
==GL_EYE_PLANE
) {
1862 COPY_4V( params
, texUnit
->EyePlaneT
);
1865 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGenfv(pname)" );
1870 if (pname
==GL_TEXTURE_GEN_MODE
) {
1871 params
[0] = ENUM_TO_FLOAT(texUnit
->GenModeR
);
1873 else if (pname
==GL_OBJECT_PLANE
) {
1874 COPY_4V( params
, texUnit
->ObjectPlaneR
);
1876 else if (pname
==GL_EYE_PLANE
) {
1877 COPY_4V( params
, texUnit
->EyePlaneR
);
1880 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGenfv(pname)" );
1885 if (pname
==GL_TEXTURE_GEN_MODE
) {
1886 params
[0] = ENUM_TO_FLOAT(texUnit
->GenModeQ
);
1888 else if (pname
==GL_OBJECT_PLANE
) {
1889 COPY_4V( params
, texUnit
->ObjectPlaneQ
);
1891 else if (pname
==GL_EYE_PLANE
) {
1892 COPY_4V( params
, texUnit
->EyePlaneQ
);
1895 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGenfv(pname)" );
1900 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGenfv(coord)" );
1908 _mesa_GetTexGeniv( GLenum coord
, GLenum pname
, GLint
*params
)
1910 GET_CURRENT_CONTEXT(ctx
);
1911 GLuint tUnit
= ctx
->Texture
.CurrentTransformUnit
;
1912 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[tUnit
];
1913 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1917 if (pname
==GL_TEXTURE_GEN_MODE
) {
1918 params
[0] = texUnit
->GenModeS
;
1920 else if (pname
==GL_OBJECT_PLANE
) {
1921 params
[0] = (GLint
) texUnit
->ObjectPlaneS
[0];
1922 params
[1] = (GLint
) texUnit
->ObjectPlaneS
[1];
1923 params
[2] = (GLint
) texUnit
->ObjectPlaneS
[2];
1924 params
[3] = (GLint
) texUnit
->ObjectPlaneS
[3];
1926 else if (pname
==GL_EYE_PLANE
) {
1927 params
[0] = (GLint
) texUnit
->EyePlaneS
[0];
1928 params
[1] = (GLint
) texUnit
->EyePlaneS
[1];
1929 params
[2] = (GLint
) texUnit
->EyePlaneS
[2];
1930 params
[3] = (GLint
) texUnit
->EyePlaneS
[3];
1933 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGeniv(pname)" );
1938 if (pname
==GL_TEXTURE_GEN_MODE
) {
1939 params
[0] = texUnit
->GenModeT
;
1941 else if (pname
==GL_OBJECT_PLANE
) {
1942 params
[0] = (GLint
) texUnit
->ObjectPlaneT
[0];
1943 params
[1] = (GLint
) texUnit
->ObjectPlaneT
[1];
1944 params
[2] = (GLint
) texUnit
->ObjectPlaneT
[2];
1945 params
[3] = (GLint
) texUnit
->ObjectPlaneT
[3];
1947 else if (pname
==GL_EYE_PLANE
) {
1948 params
[0] = (GLint
) texUnit
->EyePlaneT
[0];
1949 params
[1] = (GLint
) texUnit
->EyePlaneT
[1];
1950 params
[2] = (GLint
) texUnit
->EyePlaneT
[2];
1951 params
[3] = (GLint
) texUnit
->EyePlaneT
[3];
1954 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGeniv(pname)" );
1959 if (pname
==GL_TEXTURE_GEN_MODE
) {
1960 params
[0] = texUnit
->GenModeR
;
1962 else if (pname
==GL_OBJECT_PLANE
) {
1963 params
[0] = (GLint
) texUnit
->ObjectPlaneR
[0];
1964 params
[1] = (GLint
) texUnit
->ObjectPlaneR
[1];
1965 params
[2] = (GLint
) texUnit
->ObjectPlaneR
[2];
1966 params
[3] = (GLint
) texUnit
->ObjectPlaneR
[3];
1968 else if (pname
==GL_EYE_PLANE
) {
1969 params
[0] = (GLint
) texUnit
->EyePlaneR
[0];
1970 params
[1] = (GLint
) texUnit
->EyePlaneR
[1];
1971 params
[2] = (GLint
) texUnit
->EyePlaneR
[2];
1972 params
[3] = (GLint
) texUnit
->EyePlaneR
[3];
1975 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGeniv(pname)" );
1980 if (pname
==GL_TEXTURE_GEN_MODE
) {
1981 params
[0] = texUnit
->GenModeQ
;
1983 else if (pname
==GL_OBJECT_PLANE
) {
1984 params
[0] = (GLint
) texUnit
->ObjectPlaneQ
[0];
1985 params
[1] = (GLint
) texUnit
->ObjectPlaneQ
[1];
1986 params
[2] = (GLint
) texUnit
->ObjectPlaneQ
[2];
1987 params
[3] = (GLint
) texUnit
->ObjectPlaneQ
[3];
1989 else if (pname
==GL_EYE_PLANE
) {
1990 params
[0] = (GLint
) texUnit
->EyePlaneQ
[0];
1991 params
[1] = (GLint
) texUnit
->EyePlaneQ
[1];
1992 params
[2] = (GLint
) texUnit
->EyePlaneQ
[2];
1993 params
[3] = (GLint
) texUnit
->EyePlaneQ
[3];
1996 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGeniv(pname)" );
2001 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGeniv(coord)" );
2007 /* GL_ARB_multitexture */
2009 _mesa_ActiveTextureARB( GLenum target
)
2011 GET_CURRENT_CONTEXT(ctx
);
2012 GLuint texUnit
= target
- GL_TEXTURE0_ARB
;
2013 ASSERT_OUTSIDE_BEGIN_END(ctx
);
2015 if (MESA_VERBOSE
& (VERBOSE_API
|VERBOSE_TEXTURE
))
2016 fprintf(stderr
, "glActiveTexture %s\n",
2017 _mesa_lookup_enum_by_nr(target
));
2019 if (texUnit
> ctx
->Const
.MaxTextureUnits
) {
2020 _mesa_error(ctx
, GL_INVALID_ENUM
, "glActiveTextureARB(target)");
2024 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
2025 ctx
->Texture
.CurrentUnit
= texUnit
;
2026 ctx
->Texture
.CurrentTransformUnit
= texUnit
;
2027 if (ctx
->Driver
.ActiveTexture
) {
2028 (*ctx
->Driver
.ActiveTexture
)( ctx
, (GLuint
) texUnit
);
2033 /* GL_ARB_multitexture */
2035 _mesa_ClientActiveTextureARB( GLenum target
)
2037 GET_CURRENT_CONTEXT(ctx
);
2038 GLuint texUnit
= target
- GL_TEXTURE0_ARB
;
2039 ASSERT_OUTSIDE_BEGIN_END(ctx
);
2041 if (texUnit
> ctx
->Const
.MaxTextureUnits
) {
2042 _mesa_error(ctx
, GL_INVALID_ENUM
, "glClientActiveTextureARB(target)");
2046 FLUSH_VERTICES(ctx
, _NEW_ARRAY
);
2047 ctx
->Array
.ActiveTexture
= texUnit
;