1 /* $Id: texstate.c,v 1.54 2001/06/18 17:26:08 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
;
1137 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1139 dimensions
= tex_image_dimensions(ctx
, target
); /* 1, 2 or 3 */
1140 if (dimensions
== 0) {
1141 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexLevelParameter[if]v(target)");
1147 case GL_PROXY_TEXTURE_1D
:
1149 case GL_PROXY_TEXTURE_2D
:
1150 maxLevels
= ctx
->Const
.MaxTextureLevels
;
1153 case GL_PROXY_TEXTURE_3D
:
1154 maxLevels
= ctx
->Const
.Max3DTextureLevels
;
1157 maxLevels
= ctx
->Const
.MaxCubeTextureLevels
;
1161 if (level
< 0 || level
>= maxLevels
) {
1162 _mesa_error( ctx
, GL_INVALID_VALUE
, "glGetTexLevelParameter[if]v" );
1166 img
= _mesa_select_tex_image(ctx
, texUnit
, target
, level
);
1167 if (!img
|| !img
->TexFormat
) {
1168 /* undefined texture image */
1169 if (pname
== GL_TEXTURE_COMPONENTS
)
1176 isProxy
= (target
== GL_PROXY_TEXTURE_1D
) ||
1177 (target
== GL_PROXY_TEXTURE_2D
) ||
1178 (target
== GL_PROXY_TEXTURE_3D
) ||
1179 (target
== GL_PROXY_TEXTURE_CUBE_MAP_ARB
);
1182 case GL_TEXTURE_WIDTH
:
1183 *params
= img
->Width
;
1185 case GL_TEXTURE_HEIGHT
:
1186 *params
= img
->Height
;
1188 case GL_TEXTURE_DEPTH
:
1189 *params
= img
->Depth
;
1191 case GL_TEXTURE_INTERNAL_FORMAT
:
1192 *params
= img
->IntFormat
;
1194 case GL_TEXTURE_BORDER
:
1195 *params
= img
->Border
;
1197 case GL_TEXTURE_RED_SIZE
:
1198 if (img
->Format
== GL_RGB
|| img
->Format
== GL_RGBA
)
1199 *params
= img
->TexFormat
->RedBits
;
1203 case GL_TEXTURE_GREEN_SIZE
:
1204 if (img
->Format
== GL_RGB
|| img
->Format
== GL_RGBA
)
1205 *params
= img
->TexFormat
->GreenBits
;
1209 case GL_TEXTURE_BLUE_SIZE
:
1210 if (img
->Format
== GL_RGB
|| img
->Format
== GL_RGBA
)
1211 *params
= img
->TexFormat
->BlueBits
;
1215 case GL_TEXTURE_ALPHA_SIZE
:
1216 if (img
->Format
== GL_ALPHA
|| img
->Format
== GL_LUMINANCE_ALPHA
||
1217 img
->Format
== GL_RGBA
)
1218 *params
= img
->TexFormat
->AlphaBits
;
1222 case GL_TEXTURE_INTENSITY_SIZE
:
1223 if (img
->Format
!= GL_INTENSITY
)
1225 else if (img
->TexFormat
->IntensityBits
> 0)
1226 *params
= img
->TexFormat
->IntensityBits
;
1227 else /* intensity probably stored as rgb texture */
1228 *params
= MIN2(img
->TexFormat
->RedBits
, img
->TexFormat
->GreenBits
);
1230 case GL_TEXTURE_LUMINANCE_SIZE
:
1231 if (img
->Format
!= GL_LUMINANCE
&&
1232 img
->Format
!= GL_LUMINANCE_ALPHA
)
1234 else if (img
->TexFormat
->LuminanceBits
> 0)
1235 *params
= img
->TexFormat
->LuminanceBits
;
1236 else /* luminance probably stored as rgb texture */
1237 *params
= MIN2(img
->TexFormat
->RedBits
, img
->TexFormat
->GreenBits
);
1239 case GL_TEXTURE_INDEX_SIZE_EXT
:
1240 if (img
->Format
== GL_COLOR_INDEX
)
1241 *params
= img
->TexFormat
->IndexBits
;
1246 /* XXX this isn't in the GL_SGIX_depth_texture spec
1247 * but seems appropriate.
1249 if (ctx
->Extensions
.SGIX_depth_texture
)
1250 *params
= img
->TexFormat
->DepthBits
;
1252 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexLevelParameter[if]v(pname)");
1255 /* GL_ARB_texture_compression */
1256 case GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB
:
1257 if (ctx
->Extensions
.ARB_texture_compression
) {
1258 if (img
->IsCompressed
&& !isProxy
)
1259 *params
= img
->CompressedSize
;
1261 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1262 "glGetTexLevelParameter[if]v(pname)");
1265 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexLevelParameter[if]v(pname)");
1268 case GL_TEXTURE_COMPRESSED_ARB
:
1269 if (ctx
->Extensions
.ARB_texture_compression
) {
1270 *params
= (GLint
) img
->IsCompressed
;
1273 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexLevelParameter[if]v(pname)");
1278 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexLevelParameter[if]v(pname)");
1285 _mesa_GetTexParameterfv( GLenum target
, GLenum pname
, GLfloat
*params
)
1287 GET_CURRENT_CONTEXT(ctx
);
1288 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1289 struct gl_texture_object
*obj
;
1290 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1292 obj
= _mesa_select_tex_object(ctx
, texUnit
, target
);
1294 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexParameterfv(target)");
1299 case GL_TEXTURE_MAG_FILTER
:
1300 *params
= ENUM_TO_FLOAT(obj
->MagFilter
);
1302 case GL_TEXTURE_MIN_FILTER
:
1303 *params
= ENUM_TO_FLOAT(obj
->MinFilter
);
1305 case GL_TEXTURE_WRAP_S
:
1306 *params
= ENUM_TO_FLOAT(obj
->WrapS
);
1308 case GL_TEXTURE_WRAP_T
:
1309 *params
= ENUM_TO_FLOAT(obj
->WrapT
);
1311 case GL_TEXTURE_WRAP_R_EXT
:
1312 *params
= ENUM_TO_FLOAT(obj
->WrapR
);
1314 case GL_TEXTURE_BORDER_COLOR
:
1315 params
[0] = obj
->BorderColor
[0] / CHAN_MAXF
;
1316 params
[1] = obj
->BorderColor
[1] / CHAN_MAXF
;
1317 params
[2] = obj
->BorderColor
[2] / CHAN_MAXF
;
1318 params
[3] = obj
->BorderColor
[3] / CHAN_MAXF
;
1320 case GL_TEXTURE_RESIDENT
:
1323 if (ctx
->Driver
.IsTextureResident
)
1324 resident
= ctx
->Driver
.IsTextureResident(ctx
, obj
);
1327 *params
= ENUM_TO_FLOAT(resident
);
1330 case GL_TEXTURE_PRIORITY
:
1331 *params
= obj
->Priority
;
1333 case GL_TEXTURE_MIN_LOD
:
1334 *params
= obj
->MinLod
;
1336 case GL_TEXTURE_MAX_LOD
:
1337 *params
= obj
->MaxLod
;
1339 case GL_TEXTURE_BASE_LEVEL
:
1340 *params
= (GLfloat
) obj
->BaseLevel
;
1342 case GL_TEXTURE_MAX_LEVEL
:
1343 *params
= (GLfloat
) obj
->MaxLevel
;
1345 case GL_TEXTURE_COMPARE_SGIX
:
1346 if (ctx
->Extensions
.SGIX_shadow
) {
1347 *params
= (GLfloat
) obj
->CompareFlag
;
1351 case GL_TEXTURE_COMPARE_OPERATOR_SGIX
:
1352 if (ctx
->Extensions
.SGIX_shadow
) {
1353 *params
= (GLfloat
) obj
->CompareOperator
;
1357 case GL_SHADOW_AMBIENT_SGIX
:
1358 if (ctx
->Extensions
.SGIX_shadow_ambient
) {
1359 *params
= CHAN_TO_FLOAT(obj
->ShadowAmbient
);
1363 case GL_GENERATE_MIPMAP_SGIS
:
1364 if (ctx
->Extensions
.SGIS_generate_mipmap
) {
1365 *params
= (GLfloat
) obj
->GenerateMipmap
;
1370 ; /* silence warnings */
1372 /* If we get here, pname was an unrecognized enum */
1373 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexParameterfv(pname)" );
1378 _mesa_GetTexParameteriv( GLenum target
, GLenum pname
, GLint
*params
)
1380 GET_CURRENT_CONTEXT(ctx
);
1381 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1382 struct gl_texture_object
*obj
;
1383 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1385 obj
= _mesa_select_tex_object(ctx
, texUnit
, target
);
1387 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexParameteriv(target)");
1392 case GL_TEXTURE_MAG_FILTER
:
1393 *params
= (GLint
) obj
->MagFilter
;
1395 case GL_TEXTURE_MIN_FILTER
:
1396 *params
= (GLint
) obj
->MinFilter
;
1398 case GL_TEXTURE_WRAP_S
:
1399 *params
= (GLint
) obj
->WrapS
;
1401 case GL_TEXTURE_WRAP_T
:
1402 *params
= (GLint
) obj
->WrapT
;
1404 case GL_TEXTURE_WRAP_R_EXT
:
1405 *params
= (GLint
) obj
->WrapR
;
1407 case GL_TEXTURE_BORDER_COLOR
:
1410 color
[0] = obj
->BorderColor
[0] / CHAN_MAXF
;
1411 color
[1] = obj
->BorderColor
[1] / CHAN_MAXF
;
1412 color
[2] = obj
->BorderColor
[2] / CHAN_MAXF
;
1413 color
[3] = obj
->BorderColor
[3] / CHAN_MAXF
;
1414 params
[0] = FLOAT_TO_INT( color
[0] );
1415 params
[1] = FLOAT_TO_INT( color
[1] );
1416 params
[2] = FLOAT_TO_INT( color
[2] );
1417 params
[3] = FLOAT_TO_INT( color
[3] );
1420 case GL_TEXTURE_RESIDENT
:
1423 if (ctx
->Driver
.IsTextureResident
)
1424 resident
= ctx
->Driver
.IsTextureResident(ctx
, obj
);
1427 *params
= (GLint
) resident
;
1430 case GL_TEXTURE_PRIORITY
:
1431 *params
= (GLint
) obj
->Priority
;
1433 case GL_TEXTURE_MIN_LOD
:
1434 *params
= (GLint
) obj
->MinLod
;
1436 case GL_TEXTURE_MAX_LOD
:
1437 *params
= (GLint
) obj
->MaxLod
;
1439 case GL_TEXTURE_BASE_LEVEL
:
1440 *params
= obj
->BaseLevel
;
1442 case GL_TEXTURE_MAX_LEVEL
:
1443 *params
= obj
->MaxLevel
;
1445 case GL_TEXTURE_COMPARE_SGIX
:
1446 if (ctx
->Extensions
.SGIX_shadow
) {
1447 *params
= (GLint
) obj
->CompareFlag
;
1451 case GL_TEXTURE_COMPARE_OPERATOR_SGIX
:
1452 if (ctx
->Extensions
.SGIX_shadow
) {
1453 *params
= (GLint
) obj
->CompareOperator
;
1457 case GL_SHADOW_AMBIENT_SGIX
:
1458 if (ctx
->Extensions
.SGIX_shadow_ambient
) {
1460 *params
= (GLint
) CHAN_TO_FLOAT(obj
->ShadowAmbient
);
1464 case GL_GENERATE_MIPMAP_SGIS
:
1465 if (ctx
->Extensions
.SGIS_generate_mipmap
) {
1466 *params
= (GLint
) obj
->GenerateMipmap
;
1471 ; /* silence warnings */
1473 /* If we get here, pname was an unrecognized enum */
1474 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexParameteriv(pname)" );
1480 /**********************************************************************/
1481 /* Texture Coord Generation */
1482 /**********************************************************************/
1486 _mesa_TexGenfv( GLenum coord
, GLenum pname
, const GLfloat
*params
)
1488 GET_CURRENT_CONTEXT(ctx
);
1489 GLuint tUnit
= ctx
->Texture
.CurrentUnit
;
1490 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[tUnit
];
1491 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1493 if (MESA_VERBOSE
&(VERBOSE_API
|VERBOSE_TEXTURE
))
1494 fprintf(stderr
, "texGEN %s %s %x...\n",
1495 _mesa_lookup_enum_by_nr(coord
),
1496 _mesa_lookup_enum_by_nr(pname
),
1501 if (pname
==GL_TEXTURE_GEN_MODE
) {
1502 GLenum mode
= (GLenum
) (GLint
) *params
;
1505 case GL_OBJECT_LINEAR
:
1506 bits
= TEXGEN_OBJ_LINEAR
;
1509 bits
= TEXGEN_EYE_LINEAR
;
1511 case GL_REFLECTION_MAP_NV
:
1512 bits
= TEXGEN_REFLECTION_MAP_NV
;
1514 case GL_NORMAL_MAP_NV
:
1515 bits
= TEXGEN_NORMAL_MAP_NV
;
1518 bits
= TEXGEN_SPHERE_MAP
;
1521 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(param)" );
1524 if (texUnit
->GenModeS
== mode
)
1526 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1527 texUnit
->GenModeS
= mode
;
1528 texUnit
->_GenBitS
= bits
;
1530 else if (pname
==GL_OBJECT_PLANE
) {
1531 if (TEST_EQ_4V(texUnit
->ObjectPlaneS
, params
))
1533 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1534 texUnit
->ObjectPlaneS
[0] = params
[0];
1535 texUnit
->ObjectPlaneS
[1] = params
[1];
1536 texUnit
->ObjectPlaneS
[2] = params
[2];
1537 texUnit
->ObjectPlaneS
[3] = params
[3];
1539 else if (pname
==GL_EYE_PLANE
) {
1542 /* Transform plane equation by the inverse modelview matrix */
1543 if (ctx
->ModelView
.flags
& MAT_DIRTY_INVERSE
) {
1544 _math_matrix_analyse( &ctx
->ModelView
);
1546 _mesa_transform_vector( tmp
, params
, ctx
->ModelView
.inv
);
1547 if (TEST_EQ_4V(texUnit
->EyePlaneS
, tmp
))
1549 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1550 COPY_4FV(texUnit
->EyePlaneS
, tmp
);
1553 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(pname)" );
1558 if (pname
==GL_TEXTURE_GEN_MODE
) {
1559 GLenum mode
= (GLenum
) (GLint
) *params
;
1562 case GL_OBJECT_LINEAR
:
1563 bitt
= TEXGEN_OBJ_LINEAR
;
1566 bitt
= TEXGEN_EYE_LINEAR
;
1568 case GL_REFLECTION_MAP_NV
:
1569 bitt
= TEXGEN_REFLECTION_MAP_NV
;
1571 case GL_NORMAL_MAP_NV
:
1572 bitt
= TEXGEN_NORMAL_MAP_NV
;
1575 bitt
= TEXGEN_SPHERE_MAP
;
1578 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(param)" );
1581 if (texUnit
->GenModeT
== mode
)
1583 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1584 texUnit
->GenModeT
= mode
;
1585 texUnit
->_GenBitT
= bitt
;
1587 else if (pname
==GL_OBJECT_PLANE
) {
1588 if (TEST_EQ_4V(texUnit
->ObjectPlaneT
, params
))
1590 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1591 texUnit
->ObjectPlaneT
[0] = params
[0];
1592 texUnit
->ObjectPlaneT
[1] = params
[1];
1593 texUnit
->ObjectPlaneT
[2] = params
[2];
1594 texUnit
->ObjectPlaneT
[3] = params
[3];
1596 else if (pname
==GL_EYE_PLANE
) {
1598 /* Transform plane equation by the inverse modelview matrix */
1599 if (ctx
->ModelView
.flags
& MAT_DIRTY_INVERSE
) {
1600 _math_matrix_analyse( &ctx
->ModelView
);
1602 _mesa_transform_vector( tmp
, params
, ctx
->ModelView
.inv
);
1603 if (TEST_EQ_4V(texUnit
->EyePlaneT
, tmp
))
1605 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1606 COPY_4FV(texUnit
->EyePlaneT
, tmp
);
1609 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(pname)" );
1614 if (pname
==GL_TEXTURE_GEN_MODE
) {
1615 GLenum mode
= (GLenum
) (GLint
) *params
;
1618 case GL_OBJECT_LINEAR
:
1619 bitr
= TEXGEN_OBJ_LINEAR
;
1621 case GL_REFLECTION_MAP_NV
:
1622 bitr
= TEXGEN_REFLECTION_MAP_NV
;
1624 case GL_NORMAL_MAP_NV
:
1625 bitr
= TEXGEN_NORMAL_MAP_NV
;
1628 bitr
= TEXGEN_EYE_LINEAR
;
1631 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(param)" );
1634 if (texUnit
->GenModeR
== mode
)
1636 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1637 texUnit
->GenModeR
= mode
;
1638 texUnit
->_GenBitR
= bitr
;
1640 else if (pname
==GL_OBJECT_PLANE
) {
1641 if (TEST_EQ_4V(texUnit
->ObjectPlaneR
, params
))
1643 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1644 texUnit
->ObjectPlaneR
[0] = params
[0];
1645 texUnit
->ObjectPlaneR
[1] = params
[1];
1646 texUnit
->ObjectPlaneR
[2] = params
[2];
1647 texUnit
->ObjectPlaneR
[3] = params
[3];
1649 else if (pname
==GL_EYE_PLANE
) {
1651 /* Transform plane equation by the inverse modelview matrix */
1652 if (ctx
->ModelView
.flags
& MAT_DIRTY_INVERSE
) {
1653 _math_matrix_analyse( &ctx
->ModelView
);
1655 _mesa_transform_vector( tmp
, params
, ctx
->ModelView
.inv
);
1656 if (TEST_EQ_4V(texUnit
->EyePlaneR
, tmp
))
1658 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1659 COPY_4FV(texUnit
->EyePlaneR
, tmp
);
1662 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(pname)" );
1667 if (pname
==GL_TEXTURE_GEN_MODE
) {
1668 GLenum mode
= (GLenum
) (GLint
) *params
;
1671 case GL_OBJECT_LINEAR
:
1672 bitq
= TEXGEN_OBJ_LINEAR
;
1675 bitq
= TEXGEN_EYE_LINEAR
;
1678 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(param)" );
1681 if (texUnit
->GenModeQ
== mode
)
1683 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1684 texUnit
->GenModeQ
= mode
;
1685 texUnit
->_GenBitQ
= bitq
;
1687 else if (pname
==GL_OBJECT_PLANE
) {
1688 if (TEST_EQ_4V(texUnit
->ObjectPlaneQ
, params
))
1690 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1691 texUnit
->ObjectPlaneQ
[0] = params
[0];
1692 texUnit
->ObjectPlaneQ
[1] = params
[1];
1693 texUnit
->ObjectPlaneQ
[2] = params
[2];
1694 texUnit
->ObjectPlaneQ
[3] = params
[3];
1696 else if (pname
==GL_EYE_PLANE
) {
1698 /* Transform plane equation by the inverse modelview matrix */
1699 if (ctx
->ModelView
.flags
& MAT_DIRTY_INVERSE
) {
1700 _math_matrix_analyse( &ctx
->ModelView
);
1702 _mesa_transform_vector( tmp
, params
, ctx
->ModelView
.inv
);
1703 if (TEST_EQ_4V(texUnit
->EyePlaneQ
, tmp
))
1705 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1706 COPY_4FV(texUnit
->EyePlaneQ
, tmp
);
1709 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(pname)" );
1714 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(coord)" );
1718 if (ctx
->Driver
.TexGen
)
1719 ctx
->Driver
.TexGen( ctx
, coord
, pname
, params
);
1724 _mesa_TexGeniv(GLenum coord
, GLenum pname
, const GLint
*params
)
1731 _mesa_TexGenfv(coord
, pname
, p
);
1736 _mesa_TexGend(GLenum coord
, GLenum pname
, GLdouble param
)
1738 GLfloat p
= (GLfloat
) param
;
1739 _mesa_TexGenfv( coord
, pname
, &p
);
1744 _mesa_TexGendv(GLenum coord
, GLenum pname
, const GLdouble
*params
)
1751 _mesa_TexGenfv( coord
, pname
, p
);
1756 _mesa_TexGenf( GLenum coord
, GLenum pname
, GLfloat param
)
1758 _mesa_TexGenfv(coord
, pname
, ¶m
);
1763 _mesa_TexGeni( GLenum coord
, GLenum pname
, GLint param
)
1765 _mesa_TexGeniv( coord
, pname
, ¶m
);
1771 _mesa_GetTexGendv( GLenum coord
, GLenum pname
, GLdouble
*params
)
1773 GET_CURRENT_CONTEXT(ctx
);
1774 GLuint tUnit
= ctx
->Texture
.CurrentUnit
;
1775 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[tUnit
];
1776 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1780 if (pname
==GL_TEXTURE_GEN_MODE
) {
1781 params
[0] = ENUM_TO_DOUBLE(texUnit
->GenModeS
);
1783 else if (pname
==GL_OBJECT_PLANE
) {
1784 COPY_4V( params
, texUnit
->ObjectPlaneS
);
1786 else if (pname
==GL_EYE_PLANE
) {
1787 COPY_4V( params
, texUnit
->EyePlaneS
);
1790 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGendv(pname)" );
1795 if (pname
==GL_TEXTURE_GEN_MODE
) {
1796 params
[0] = ENUM_TO_DOUBLE(texUnit
->GenModeT
);
1798 else if (pname
==GL_OBJECT_PLANE
) {
1799 COPY_4V( params
, texUnit
->ObjectPlaneT
);
1801 else if (pname
==GL_EYE_PLANE
) {
1802 COPY_4V( params
, texUnit
->EyePlaneT
);
1805 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGendv(pname)" );
1810 if (pname
==GL_TEXTURE_GEN_MODE
) {
1811 params
[0] = ENUM_TO_DOUBLE(texUnit
->GenModeR
);
1813 else if (pname
==GL_OBJECT_PLANE
) {
1814 COPY_4V( params
, texUnit
->ObjectPlaneR
);
1816 else if (pname
==GL_EYE_PLANE
) {
1817 COPY_4V( params
, texUnit
->EyePlaneR
);
1820 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGendv(pname)" );
1825 if (pname
==GL_TEXTURE_GEN_MODE
) {
1826 params
[0] = ENUM_TO_DOUBLE(texUnit
->GenModeQ
);
1828 else if (pname
==GL_OBJECT_PLANE
) {
1829 COPY_4V( params
, texUnit
->ObjectPlaneQ
);
1831 else if (pname
==GL_EYE_PLANE
) {
1832 COPY_4V( params
, texUnit
->EyePlaneQ
);
1835 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGendv(pname)" );
1840 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGendv(coord)" );
1848 _mesa_GetTexGenfv( GLenum coord
, GLenum pname
, GLfloat
*params
)
1850 GET_CURRENT_CONTEXT(ctx
);
1851 GLuint tUnit
= ctx
->Texture
.CurrentUnit
;
1852 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[tUnit
];
1853 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1857 if (pname
==GL_TEXTURE_GEN_MODE
) {
1858 params
[0] = ENUM_TO_FLOAT(texUnit
->GenModeS
);
1860 else if (pname
==GL_OBJECT_PLANE
) {
1861 COPY_4V( params
, texUnit
->ObjectPlaneS
);
1863 else if (pname
==GL_EYE_PLANE
) {
1864 COPY_4V( params
, texUnit
->EyePlaneS
);
1867 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGenfv(pname)" );
1872 if (pname
==GL_TEXTURE_GEN_MODE
) {
1873 params
[0] = ENUM_TO_FLOAT(texUnit
->GenModeT
);
1875 else if (pname
==GL_OBJECT_PLANE
) {
1876 COPY_4V( params
, texUnit
->ObjectPlaneT
);
1878 else if (pname
==GL_EYE_PLANE
) {
1879 COPY_4V( params
, texUnit
->EyePlaneT
);
1882 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGenfv(pname)" );
1887 if (pname
==GL_TEXTURE_GEN_MODE
) {
1888 params
[0] = ENUM_TO_FLOAT(texUnit
->GenModeR
);
1890 else if (pname
==GL_OBJECT_PLANE
) {
1891 COPY_4V( params
, texUnit
->ObjectPlaneR
);
1893 else if (pname
==GL_EYE_PLANE
) {
1894 COPY_4V( params
, texUnit
->EyePlaneR
);
1897 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGenfv(pname)" );
1902 if (pname
==GL_TEXTURE_GEN_MODE
) {
1903 params
[0] = ENUM_TO_FLOAT(texUnit
->GenModeQ
);
1905 else if (pname
==GL_OBJECT_PLANE
) {
1906 COPY_4V( params
, texUnit
->ObjectPlaneQ
);
1908 else if (pname
==GL_EYE_PLANE
) {
1909 COPY_4V( params
, texUnit
->EyePlaneQ
);
1912 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGenfv(pname)" );
1917 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGenfv(coord)" );
1925 _mesa_GetTexGeniv( GLenum coord
, GLenum pname
, GLint
*params
)
1927 GET_CURRENT_CONTEXT(ctx
);
1928 GLuint tUnit
= ctx
->Texture
.CurrentUnit
;
1929 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[tUnit
];
1930 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1934 if (pname
==GL_TEXTURE_GEN_MODE
) {
1935 params
[0] = texUnit
->GenModeS
;
1937 else if (pname
==GL_OBJECT_PLANE
) {
1938 params
[0] = (GLint
) texUnit
->ObjectPlaneS
[0];
1939 params
[1] = (GLint
) texUnit
->ObjectPlaneS
[1];
1940 params
[2] = (GLint
) texUnit
->ObjectPlaneS
[2];
1941 params
[3] = (GLint
) texUnit
->ObjectPlaneS
[3];
1943 else if (pname
==GL_EYE_PLANE
) {
1944 params
[0] = (GLint
) texUnit
->EyePlaneS
[0];
1945 params
[1] = (GLint
) texUnit
->EyePlaneS
[1];
1946 params
[2] = (GLint
) texUnit
->EyePlaneS
[2];
1947 params
[3] = (GLint
) texUnit
->EyePlaneS
[3];
1950 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGeniv(pname)" );
1955 if (pname
==GL_TEXTURE_GEN_MODE
) {
1956 params
[0] = texUnit
->GenModeT
;
1958 else if (pname
==GL_OBJECT_PLANE
) {
1959 params
[0] = (GLint
) texUnit
->ObjectPlaneT
[0];
1960 params
[1] = (GLint
) texUnit
->ObjectPlaneT
[1];
1961 params
[2] = (GLint
) texUnit
->ObjectPlaneT
[2];
1962 params
[3] = (GLint
) texUnit
->ObjectPlaneT
[3];
1964 else if (pname
==GL_EYE_PLANE
) {
1965 params
[0] = (GLint
) texUnit
->EyePlaneT
[0];
1966 params
[1] = (GLint
) texUnit
->EyePlaneT
[1];
1967 params
[2] = (GLint
) texUnit
->EyePlaneT
[2];
1968 params
[3] = (GLint
) texUnit
->EyePlaneT
[3];
1971 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGeniv(pname)" );
1976 if (pname
==GL_TEXTURE_GEN_MODE
) {
1977 params
[0] = texUnit
->GenModeR
;
1979 else if (pname
==GL_OBJECT_PLANE
) {
1980 params
[0] = (GLint
) texUnit
->ObjectPlaneR
[0];
1981 params
[1] = (GLint
) texUnit
->ObjectPlaneR
[1];
1982 params
[2] = (GLint
) texUnit
->ObjectPlaneR
[2];
1983 params
[3] = (GLint
) texUnit
->ObjectPlaneR
[3];
1985 else if (pname
==GL_EYE_PLANE
) {
1986 params
[0] = (GLint
) texUnit
->EyePlaneR
[0];
1987 params
[1] = (GLint
) texUnit
->EyePlaneR
[1];
1988 params
[2] = (GLint
) texUnit
->EyePlaneR
[2];
1989 params
[3] = (GLint
) texUnit
->EyePlaneR
[3];
1992 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGeniv(pname)" );
1997 if (pname
==GL_TEXTURE_GEN_MODE
) {
1998 params
[0] = texUnit
->GenModeQ
;
2000 else if (pname
==GL_OBJECT_PLANE
) {
2001 params
[0] = (GLint
) texUnit
->ObjectPlaneQ
[0];
2002 params
[1] = (GLint
) texUnit
->ObjectPlaneQ
[1];
2003 params
[2] = (GLint
) texUnit
->ObjectPlaneQ
[2];
2004 params
[3] = (GLint
) texUnit
->ObjectPlaneQ
[3];
2006 else if (pname
==GL_EYE_PLANE
) {
2007 params
[0] = (GLint
) texUnit
->EyePlaneQ
[0];
2008 params
[1] = (GLint
) texUnit
->EyePlaneQ
[1];
2009 params
[2] = (GLint
) texUnit
->EyePlaneQ
[2];
2010 params
[3] = (GLint
) texUnit
->EyePlaneQ
[3];
2013 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGeniv(pname)" );
2018 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGeniv(coord)" );
2024 /* GL_ARB_multitexture */
2026 _mesa_ActiveTextureARB( GLenum target
)
2028 GET_CURRENT_CONTEXT(ctx
);
2029 GLuint texUnit
= target
- GL_TEXTURE0_ARB
;
2030 ASSERT_OUTSIDE_BEGIN_END(ctx
);
2032 if (MESA_VERBOSE
& (VERBOSE_API
|VERBOSE_TEXTURE
))
2033 fprintf(stderr
, "glActiveTexture %s\n",
2034 _mesa_lookup_enum_by_nr(target
));
2036 if (texUnit
> ctx
->Const
.MaxTextureUnits
) {
2037 _mesa_error(ctx
, GL_INVALID_ENUM
, "glActiveTextureARB(target)");
2041 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
2042 ctx
->Texture
.CurrentUnit
= texUnit
;
2043 if (ctx
->Driver
.ActiveTexture
) {
2044 (*ctx
->Driver
.ActiveTexture
)( ctx
, (GLuint
) texUnit
);
2049 /* GL_ARB_multitexture */
2051 _mesa_ClientActiveTextureARB( GLenum target
)
2053 GET_CURRENT_CONTEXT(ctx
);
2054 GLuint texUnit
= target
- GL_TEXTURE0_ARB
;
2055 ASSERT_OUTSIDE_BEGIN_END(ctx
);
2057 if (texUnit
> ctx
->Const
.MaxTextureUnits
) {
2058 _mesa_error(ctx
, GL_INVALID_ENUM
, "glClientActiveTextureARB(target)");
2062 FLUSH_VERTICES(ctx
, _NEW_ARRAY
);
2063 ctx
->Array
.ActiveTexture
= texUnit
;
2068 /**********************************************************************/
2069 /* Pixel Texgen Extensions */
2070 /**********************************************************************/
2073 _mesa_PixelTexGenSGIX(GLenum mode
)
2075 GLenum newRgbSource
, newAlphaSource
;
2076 GET_CURRENT_CONTEXT(ctx
);
2077 ASSERT_OUTSIDE_BEGIN_END(ctx
);
2081 newRgbSource
= GL_PIXEL_GROUP_COLOR_SGIS
;
2082 newAlphaSource
= GL_PIXEL_GROUP_COLOR_SGIS
;
2085 newRgbSource
= GL_PIXEL_GROUP_COLOR_SGIS
;
2086 newAlphaSource
= GL_CURRENT_RASTER_COLOR
;
2089 newRgbSource
= GL_CURRENT_RASTER_COLOR
;
2090 newAlphaSource
= GL_PIXEL_GROUP_COLOR_SGIS
;
2093 newRgbSource
= GL_CURRENT_RASTER_COLOR
;
2094 newAlphaSource
= GL_CURRENT_RASTER_COLOR
;
2097 _mesa_error(ctx
, GL_INVALID_ENUM
, "glPixelTexGenSGIX(mode)");
2101 if (newRgbSource
== ctx
->Pixel
.FragmentRgbSource
&&
2102 newAlphaSource
== ctx
->Pixel
.FragmentAlphaSource
)
2105 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
2106 ctx
->Pixel
.FragmentRgbSource
= newRgbSource
;
2107 ctx
->Pixel
.FragmentAlphaSource
= newAlphaSource
;
2112 _mesa_PixelTexGenParameterfSGIS(GLenum target
, GLfloat value
)
2114 _mesa_PixelTexGenParameteriSGIS(target
, (GLint
) value
);
2119 _mesa_PixelTexGenParameterfvSGIS(GLenum target
, const GLfloat
*value
)
2121 _mesa_PixelTexGenParameteriSGIS(target
, (GLint
) *value
);
2126 _mesa_PixelTexGenParameteriSGIS(GLenum target
, GLint value
)
2128 GET_CURRENT_CONTEXT(ctx
);
2129 ASSERT_OUTSIDE_BEGIN_END(ctx
);
2131 if (value
!= GL_CURRENT_RASTER_COLOR
&& value
!= GL_PIXEL_GROUP_COLOR_SGIS
) {
2132 _mesa_error(ctx
, GL_INVALID_ENUM
, "glPixelTexGenParameterSGIS(value)");
2137 case GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS
:
2138 if (ctx
->Pixel
.FragmentRgbSource
== (GLenum
) value
)
2140 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
2141 ctx
->Pixel
.FragmentRgbSource
= (GLenum
) value
;
2143 case GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS
:
2144 if (ctx
->Pixel
.FragmentAlphaSource
== (GLenum
) value
)
2146 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
2147 ctx
->Pixel
.FragmentAlphaSource
= (GLenum
) value
;
2150 _mesa_error(ctx
, GL_INVALID_ENUM
, "glPixelTexGenParameterSGIS(target)");
2157 _mesa_PixelTexGenParameterivSGIS(GLenum target
, const GLint
*value
)
2159 _mesa_PixelTexGenParameteriSGIS(target
, *value
);
2164 _mesa_GetPixelTexGenParameterfvSGIS(GLenum target
, GLfloat
*value
)
2166 GET_CURRENT_CONTEXT(ctx
);
2167 ASSERT_OUTSIDE_BEGIN_END(ctx
);
2169 if (target
== GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS
) {
2170 *value
= (GLfloat
) ctx
->Pixel
.FragmentRgbSource
;
2172 else if (target
== GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS
) {
2173 *value
= (GLfloat
) ctx
->Pixel
.FragmentAlphaSource
;
2176 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetPixelTexGenParameterfvSGIS(target)");
2182 _mesa_GetPixelTexGenParameterivSGIS(GLenum target
, GLint
*value
)
2184 GET_CURRENT_CONTEXT(ctx
);
2185 ASSERT_OUTSIDE_BEGIN_END(ctx
);
2187 if (target
== GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS
) {
2188 *value
= (GLint
) ctx
->Pixel
.FragmentRgbSource
;
2190 else if (target
== GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS
) {
2191 *value
= (GLint
) ctx
->Pixel
.FragmentAlphaSource
;
2194 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetPixelTexGenParameterivSGIS(target)");