1 /* $Id: texstate.c,v 1.57 2001/09/18 23:06:14 kschultz 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 TE_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 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", mode
);
91 if (!ctx
->Extensions
.EXT_texture_env_combine
&&
92 !ctx
->Extensions
.ARB_texture_env_combine
) {
93 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", mode
);
103 TE_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 TE_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 TE_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 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", mode
);
158 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", mode
);
161 if (texUnit
->CombineModeRGB
== mode
)
163 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
164 texUnit
->CombineModeRGB
= mode
;
167 TE_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 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", mode
);
190 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", mode
);
193 if (texUnit
->CombineModeA
== mode
)
195 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
196 texUnit
->CombineModeA
= mode
;
199 TE_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 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", source
);
226 TE_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 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", source
);
252 TE_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 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", operand
);
278 TE_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 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", operand
);
302 TE_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 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", operand
);
325 TE_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 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", operand
);
347 TE_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 TE_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 TE_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 TE_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
,
1009 "glTexParameter(pname=GL_MAX_TEXTURE_ANISOTROPY_EXT)");
1013 case GL_TEXTURE_COMPARE_SGIX
:
1014 if (ctx
->Extensions
.SGIX_shadow
) {
1015 texObj
->CompareFlag
= params
[0] ? GL_TRUE
: GL_FALSE
;
1018 _mesa_error(ctx
, GL_INVALID_ENUM
,
1019 "glTexParameter(pname=GL_TEXTURE_COMPARE_SGIX)");
1023 case GL_TEXTURE_COMPARE_OPERATOR_SGIX
:
1024 if (ctx
->Extensions
.SGIX_shadow
) {
1025 GLenum op
= (GLenum
) params
[0];
1026 if (op
== GL_TEXTURE_LEQUAL_R_SGIX
||
1027 op
== GL_TEXTURE_GEQUAL_R_SGIX
) {
1028 texObj
->CompareOperator
= op
;
1031 _mesa_error(ctx
, GL_INVALID_ENUM
, "glTexParameter(param)");
1035 _mesa_error(ctx
, GL_INVALID_ENUM
,
1036 "glTexParameter(pname=GL_TEXTURE_COMPARE_OPERATOR_SGIX)");
1040 case GL_SHADOW_AMBIENT_SGIX
:
1041 if (ctx
->Extensions
.SGIX_shadow_ambient
) {
1042 UNCLAMPED_FLOAT_TO_CHAN(texObj
->ShadowAmbient
, params
[0]);
1045 _mesa_error(ctx
, GL_INVALID_ENUM
,
1046 "glTexParameter(pname=GL_SHADOW_AMBIENT_SGIX)");
1050 case GL_GENERATE_MIPMAP_SGIS
:
1051 if (ctx
->Extensions
.SGIS_generate_mipmap
) {
1052 texObj
->GenerateMipmap
= params
[0] ? GL_TRUE
: GL_FALSE
;
1055 _mesa_error(ctx
, GL_INVALID_ENUM
,
1056 "glTexParameter(pname=GL_GENERATE_MIPMAP_SGIS)");
1063 sprintf(s
, "glTexParameter(pname=0x%x)", pname
);
1064 _mesa_error( ctx
, GL_INVALID_ENUM
, s
);
1069 ctx
->NewState
|= _NEW_TEXTURE
;
1070 texObj
->Complete
= GL_FALSE
;
1072 if (ctx
->Driver
.TexParameter
) {
1073 (*ctx
->Driver
.TexParameter
)( ctx
, target
, texObj
, pname
, params
);
1079 _mesa_TexParameteri( GLenum target
, GLenum pname
, GLint param
)
1082 fparam
[0] = (GLfloat
) param
;
1083 fparam
[1] = fparam
[2] = fparam
[3] = 0.0;
1084 _mesa_TexParameterfv(target
, pname
, fparam
);
1088 _mesa_TexParameteriv( GLenum target
, GLenum pname
, const GLint
*params
)
1091 fparam
[0] = (GLfloat
) params
[0];
1092 fparam
[1] = fparam
[2] = fparam
[3] = 0.0;
1093 _mesa_TexParameterfv(target
, pname
, fparam
);
1098 _mesa_GetTexLevelParameterfv( GLenum target
, GLint level
,
1099 GLenum pname
, GLfloat
*params
)
1102 _mesa_GetTexLevelParameteriv( target
, level
, pname
, &iparam
);
1103 *params
= (GLfloat
) iparam
;
1108 tex_image_dimensions(GLcontext
*ctx
, GLenum target
)
1112 case GL_PROXY_TEXTURE_1D
:
1115 case GL_PROXY_TEXTURE_2D
:
1118 case GL_PROXY_TEXTURE_3D
:
1120 case GL_TEXTURE_CUBE_MAP_ARB
:
1121 case GL_PROXY_TEXTURE_CUBE_MAP_ARB
:
1122 case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB
:
1123 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB
:
1124 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB
:
1125 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB
:
1126 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB
:
1127 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB
:
1128 return ctx
->Extensions
.ARB_texture_cube_map
? 2 : 0;
1130 _mesa_problem(ctx
, "bad target in _mesa_tex_target_dimensions()");
1137 _mesa_GetTexLevelParameteriv( GLenum target
, GLint level
,
1138 GLenum pname
, GLint
*params
)
1140 GET_CURRENT_CONTEXT(ctx
);
1141 const struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1142 const struct gl_texture_image
*img
= NULL
;
1146 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1148 dimensions
= tex_image_dimensions(ctx
, target
); /* 1, 2 or 3 */
1149 if (dimensions
== 0) {
1150 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexLevelParameter[if]v(target)");
1156 case GL_PROXY_TEXTURE_1D
:
1158 case GL_PROXY_TEXTURE_2D
:
1159 maxLevels
= ctx
->Const
.MaxTextureLevels
;
1162 case GL_PROXY_TEXTURE_3D
:
1163 maxLevels
= ctx
->Const
.Max3DTextureLevels
;
1166 maxLevels
= ctx
->Const
.MaxCubeTextureLevels
;
1170 if (level
< 0 || level
>= maxLevels
) {
1171 _mesa_error( ctx
, GL_INVALID_VALUE
, "glGetTexLevelParameter[if]v" );
1175 img
= _mesa_select_tex_image(ctx
, texUnit
, target
, level
);
1176 if (!img
|| !img
->TexFormat
) {
1177 /* undefined texture image */
1178 if (pname
== GL_TEXTURE_COMPONENTS
)
1185 isProxy
= (target
== GL_PROXY_TEXTURE_1D
) ||
1186 (target
== GL_PROXY_TEXTURE_2D
) ||
1187 (target
== GL_PROXY_TEXTURE_3D
) ||
1188 (target
== GL_PROXY_TEXTURE_CUBE_MAP_ARB
);
1191 case GL_TEXTURE_WIDTH
:
1192 *params
= img
->Width
;
1194 case GL_TEXTURE_HEIGHT
:
1195 *params
= img
->Height
;
1197 case GL_TEXTURE_DEPTH
:
1198 *params
= img
->Depth
;
1200 case GL_TEXTURE_INTERNAL_FORMAT
:
1201 *params
= img
->IntFormat
;
1203 case GL_TEXTURE_BORDER
:
1204 *params
= img
->Border
;
1206 case GL_TEXTURE_RED_SIZE
:
1207 if (img
->Format
== GL_RGB
|| img
->Format
== GL_RGBA
)
1208 *params
= img
->TexFormat
->RedBits
;
1212 case GL_TEXTURE_GREEN_SIZE
:
1213 if (img
->Format
== GL_RGB
|| img
->Format
== GL_RGBA
)
1214 *params
= img
->TexFormat
->GreenBits
;
1218 case GL_TEXTURE_BLUE_SIZE
:
1219 if (img
->Format
== GL_RGB
|| img
->Format
== GL_RGBA
)
1220 *params
= img
->TexFormat
->BlueBits
;
1224 case GL_TEXTURE_ALPHA_SIZE
:
1225 if (img
->Format
== GL_ALPHA
|| img
->Format
== GL_LUMINANCE_ALPHA
||
1226 img
->Format
== GL_RGBA
)
1227 *params
= img
->TexFormat
->AlphaBits
;
1231 case GL_TEXTURE_INTENSITY_SIZE
:
1232 if (img
->Format
!= GL_INTENSITY
)
1234 else if (img
->TexFormat
->IntensityBits
> 0)
1235 *params
= img
->TexFormat
->IntensityBits
;
1236 else /* intensity probably stored as rgb texture */
1237 *params
= MIN2(img
->TexFormat
->RedBits
, img
->TexFormat
->GreenBits
);
1239 case GL_TEXTURE_LUMINANCE_SIZE
:
1240 if (img
->Format
!= GL_LUMINANCE
&&
1241 img
->Format
!= GL_LUMINANCE_ALPHA
)
1243 else if (img
->TexFormat
->LuminanceBits
> 0)
1244 *params
= img
->TexFormat
->LuminanceBits
;
1245 else /* luminance probably stored as rgb texture */
1246 *params
= MIN2(img
->TexFormat
->RedBits
, img
->TexFormat
->GreenBits
);
1248 case GL_TEXTURE_INDEX_SIZE_EXT
:
1249 if (img
->Format
== GL_COLOR_INDEX
)
1250 *params
= img
->TexFormat
->IndexBits
;
1255 /* XXX this isn't in the GL_SGIX_depth_texture spec
1256 * but seems appropriate.
1258 if (ctx
->Extensions
.SGIX_depth_texture
)
1259 *params
= img
->TexFormat
->DepthBits
;
1261 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexLevelParameter[if]v(pname)");
1264 /* GL_ARB_texture_compression */
1265 case GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB
:
1266 if (ctx
->Extensions
.ARB_texture_compression
) {
1267 if (img
->IsCompressed
&& !isProxy
)
1268 *params
= img
->CompressedSize
;
1270 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1271 "glGetTexLevelParameter[if]v(pname)");
1274 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexLevelParameter[if]v(pname)");
1277 case GL_TEXTURE_COMPRESSED_ARB
:
1278 if (ctx
->Extensions
.ARB_texture_compression
) {
1279 *params
= (GLint
) img
->IsCompressed
;
1282 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexLevelParameter[if]v(pname)");
1287 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexLevelParameter[if]v(pname)");
1294 _mesa_GetTexParameterfv( GLenum target
, GLenum pname
, GLfloat
*params
)
1296 GET_CURRENT_CONTEXT(ctx
);
1297 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1298 struct gl_texture_object
*obj
;
1299 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1301 obj
= _mesa_select_tex_object(ctx
, texUnit
, target
);
1303 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexParameterfv(target)");
1308 case GL_TEXTURE_MAG_FILTER
:
1309 *params
= ENUM_TO_FLOAT(obj
->MagFilter
);
1311 case GL_TEXTURE_MIN_FILTER
:
1312 *params
= ENUM_TO_FLOAT(obj
->MinFilter
);
1314 case GL_TEXTURE_WRAP_S
:
1315 *params
= ENUM_TO_FLOAT(obj
->WrapS
);
1317 case GL_TEXTURE_WRAP_T
:
1318 *params
= ENUM_TO_FLOAT(obj
->WrapT
);
1320 case GL_TEXTURE_WRAP_R_EXT
:
1321 *params
= ENUM_TO_FLOAT(obj
->WrapR
);
1323 case GL_TEXTURE_BORDER_COLOR
:
1324 params
[0] = obj
->BorderColor
[0] / CHAN_MAXF
;
1325 params
[1] = obj
->BorderColor
[1] / CHAN_MAXF
;
1326 params
[2] = obj
->BorderColor
[2] / CHAN_MAXF
;
1327 params
[3] = obj
->BorderColor
[3] / CHAN_MAXF
;
1329 case GL_TEXTURE_RESIDENT
:
1332 if (ctx
->Driver
.IsTextureResident
)
1333 resident
= ctx
->Driver
.IsTextureResident(ctx
, obj
);
1336 *params
= ENUM_TO_FLOAT(resident
);
1339 case GL_TEXTURE_PRIORITY
:
1340 *params
= obj
->Priority
;
1342 case GL_TEXTURE_MIN_LOD
:
1343 *params
= obj
->MinLod
;
1345 case GL_TEXTURE_MAX_LOD
:
1346 *params
= obj
->MaxLod
;
1348 case GL_TEXTURE_BASE_LEVEL
:
1349 *params
= (GLfloat
) obj
->BaseLevel
;
1351 case GL_TEXTURE_MAX_LEVEL
:
1352 *params
= (GLfloat
) obj
->MaxLevel
;
1354 case GL_TEXTURE_COMPARE_SGIX
:
1355 if (ctx
->Extensions
.SGIX_shadow
) {
1356 *params
= (GLfloat
) obj
->CompareFlag
;
1360 case GL_TEXTURE_COMPARE_OPERATOR_SGIX
:
1361 if (ctx
->Extensions
.SGIX_shadow
) {
1362 *params
= (GLfloat
) obj
->CompareOperator
;
1366 case GL_SHADOW_AMBIENT_SGIX
:
1367 if (ctx
->Extensions
.SGIX_shadow_ambient
) {
1368 *params
= CHAN_TO_FLOAT(obj
->ShadowAmbient
);
1372 case GL_GENERATE_MIPMAP_SGIS
:
1373 if (ctx
->Extensions
.SGIS_generate_mipmap
) {
1374 *params
= (GLfloat
) obj
->GenerateMipmap
;
1379 ; /* silence warnings */
1381 /* If we get here, pname was an unrecognized enum */
1382 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexParameterfv(pname)" );
1387 _mesa_GetTexParameteriv( GLenum target
, GLenum pname
, GLint
*params
)
1389 GET_CURRENT_CONTEXT(ctx
);
1390 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1391 struct gl_texture_object
*obj
;
1392 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1394 obj
= _mesa_select_tex_object(ctx
, texUnit
, target
);
1396 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexParameteriv(target)");
1401 case GL_TEXTURE_MAG_FILTER
:
1402 *params
= (GLint
) obj
->MagFilter
;
1404 case GL_TEXTURE_MIN_FILTER
:
1405 *params
= (GLint
) obj
->MinFilter
;
1407 case GL_TEXTURE_WRAP_S
:
1408 *params
= (GLint
) obj
->WrapS
;
1410 case GL_TEXTURE_WRAP_T
:
1411 *params
= (GLint
) obj
->WrapT
;
1413 case GL_TEXTURE_WRAP_R_EXT
:
1414 *params
= (GLint
) obj
->WrapR
;
1416 case GL_TEXTURE_BORDER_COLOR
:
1419 color
[0] = obj
->BorderColor
[0] / CHAN_MAXF
;
1420 color
[1] = obj
->BorderColor
[1] / CHAN_MAXF
;
1421 color
[2] = obj
->BorderColor
[2] / CHAN_MAXF
;
1422 color
[3] = obj
->BorderColor
[3] / CHAN_MAXF
;
1423 params
[0] = FLOAT_TO_INT( color
[0] );
1424 params
[1] = FLOAT_TO_INT( color
[1] );
1425 params
[2] = FLOAT_TO_INT( color
[2] );
1426 params
[3] = FLOAT_TO_INT( color
[3] );
1429 case GL_TEXTURE_RESIDENT
:
1432 if (ctx
->Driver
.IsTextureResident
)
1433 resident
= ctx
->Driver
.IsTextureResident(ctx
, obj
);
1436 *params
= (GLint
) resident
;
1439 case GL_TEXTURE_PRIORITY
:
1440 *params
= (GLint
) obj
->Priority
;
1442 case GL_TEXTURE_MIN_LOD
:
1443 *params
= (GLint
) obj
->MinLod
;
1445 case GL_TEXTURE_MAX_LOD
:
1446 *params
= (GLint
) obj
->MaxLod
;
1448 case GL_TEXTURE_BASE_LEVEL
:
1449 *params
= obj
->BaseLevel
;
1451 case GL_TEXTURE_MAX_LEVEL
:
1452 *params
= obj
->MaxLevel
;
1454 case GL_TEXTURE_COMPARE_SGIX
:
1455 if (ctx
->Extensions
.SGIX_shadow
) {
1456 *params
= (GLint
) obj
->CompareFlag
;
1460 case GL_TEXTURE_COMPARE_OPERATOR_SGIX
:
1461 if (ctx
->Extensions
.SGIX_shadow
) {
1462 *params
= (GLint
) obj
->CompareOperator
;
1466 case GL_SHADOW_AMBIENT_SGIX
:
1467 if (ctx
->Extensions
.SGIX_shadow_ambient
) {
1469 *params
= (GLint
) CHAN_TO_FLOAT(obj
->ShadowAmbient
);
1473 case GL_GENERATE_MIPMAP_SGIS
:
1474 if (ctx
->Extensions
.SGIS_generate_mipmap
) {
1475 *params
= (GLint
) obj
->GenerateMipmap
;
1480 ; /* silence warnings */
1482 /* If we get here, pname was an unrecognized enum */
1483 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexParameteriv(pname)" );
1489 /**********************************************************************/
1490 /* Texture Coord Generation */
1491 /**********************************************************************/
1495 _mesa_TexGenfv( GLenum coord
, GLenum pname
, const GLfloat
*params
)
1497 GET_CURRENT_CONTEXT(ctx
);
1498 GLuint tUnit
= ctx
->Texture
.CurrentUnit
;
1499 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[tUnit
];
1500 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1502 if (MESA_VERBOSE
&(VERBOSE_API
|VERBOSE_TEXTURE
))
1503 fprintf(stderr
, "texGEN %s %s %x...\n",
1504 _mesa_lookup_enum_by_nr(coord
),
1505 _mesa_lookup_enum_by_nr(pname
),
1510 if (pname
==GL_TEXTURE_GEN_MODE
) {
1511 GLenum mode
= (GLenum
) (GLint
) *params
;
1514 case GL_OBJECT_LINEAR
:
1515 bits
= TEXGEN_OBJ_LINEAR
;
1518 bits
= TEXGEN_EYE_LINEAR
;
1520 case GL_REFLECTION_MAP_NV
:
1521 bits
= TEXGEN_REFLECTION_MAP_NV
;
1523 case GL_NORMAL_MAP_NV
:
1524 bits
= TEXGEN_NORMAL_MAP_NV
;
1527 bits
= TEXGEN_SPHERE_MAP
;
1530 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(param)" );
1533 if (texUnit
->GenModeS
== mode
)
1535 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1536 texUnit
->GenModeS
= mode
;
1537 texUnit
->_GenBitS
= bits
;
1539 else if (pname
==GL_OBJECT_PLANE
) {
1540 if (TEST_EQ_4V(texUnit
->ObjectPlaneS
, params
))
1542 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1543 texUnit
->ObjectPlaneS
[0] = params
[0];
1544 texUnit
->ObjectPlaneS
[1] = params
[1];
1545 texUnit
->ObjectPlaneS
[2] = params
[2];
1546 texUnit
->ObjectPlaneS
[3] = params
[3];
1548 else if (pname
==GL_EYE_PLANE
) {
1551 /* Transform plane equation by the inverse modelview matrix */
1552 if (ctx
->ModelView
.flags
& MAT_DIRTY_INVERSE
) {
1553 _math_matrix_analyse( &ctx
->ModelView
);
1555 _mesa_transform_vector( tmp
, params
, ctx
->ModelView
.inv
);
1556 if (TEST_EQ_4V(texUnit
->EyePlaneS
, tmp
))
1558 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1559 COPY_4FV(texUnit
->EyePlaneS
, tmp
);
1562 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(pname)" );
1567 if (pname
==GL_TEXTURE_GEN_MODE
) {
1568 GLenum mode
= (GLenum
) (GLint
) *params
;
1571 case GL_OBJECT_LINEAR
:
1572 bitt
= TEXGEN_OBJ_LINEAR
;
1575 bitt
= TEXGEN_EYE_LINEAR
;
1577 case GL_REFLECTION_MAP_NV
:
1578 bitt
= TEXGEN_REFLECTION_MAP_NV
;
1580 case GL_NORMAL_MAP_NV
:
1581 bitt
= TEXGEN_NORMAL_MAP_NV
;
1584 bitt
= TEXGEN_SPHERE_MAP
;
1587 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(param)" );
1590 if (texUnit
->GenModeT
== mode
)
1592 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1593 texUnit
->GenModeT
= mode
;
1594 texUnit
->_GenBitT
= bitt
;
1596 else if (pname
==GL_OBJECT_PLANE
) {
1597 if (TEST_EQ_4V(texUnit
->ObjectPlaneT
, params
))
1599 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1600 texUnit
->ObjectPlaneT
[0] = params
[0];
1601 texUnit
->ObjectPlaneT
[1] = params
[1];
1602 texUnit
->ObjectPlaneT
[2] = params
[2];
1603 texUnit
->ObjectPlaneT
[3] = params
[3];
1605 else if (pname
==GL_EYE_PLANE
) {
1607 /* Transform plane equation by the inverse modelview matrix */
1608 if (ctx
->ModelView
.flags
& MAT_DIRTY_INVERSE
) {
1609 _math_matrix_analyse( &ctx
->ModelView
);
1611 _mesa_transform_vector( tmp
, params
, ctx
->ModelView
.inv
);
1612 if (TEST_EQ_4V(texUnit
->EyePlaneT
, tmp
))
1614 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1615 COPY_4FV(texUnit
->EyePlaneT
, tmp
);
1618 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(pname)" );
1623 if (pname
==GL_TEXTURE_GEN_MODE
) {
1624 GLenum mode
= (GLenum
) (GLint
) *params
;
1627 case GL_OBJECT_LINEAR
:
1628 bitr
= TEXGEN_OBJ_LINEAR
;
1630 case GL_REFLECTION_MAP_NV
:
1631 bitr
= TEXGEN_REFLECTION_MAP_NV
;
1633 case GL_NORMAL_MAP_NV
:
1634 bitr
= TEXGEN_NORMAL_MAP_NV
;
1637 bitr
= TEXGEN_EYE_LINEAR
;
1640 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(param)" );
1643 if (texUnit
->GenModeR
== mode
)
1645 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1646 texUnit
->GenModeR
= mode
;
1647 texUnit
->_GenBitR
= bitr
;
1649 else if (pname
==GL_OBJECT_PLANE
) {
1650 if (TEST_EQ_4V(texUnit
->ObjectPlaneR
, params
))
1652 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1653 texUnit
->ObjectPlaneR
[0] = params
[0];
1654 texUnit
->ObjectPlaneR
[1] = params
[1];
1655 texUnit
->ObjectPlaneR
[2] = params
[2];
1656 texUnit
->ObjectPlaneR
[3] = params
[3];
1658 else if (pname
==GL_EYE_PLANE
) {
1660 /* Transform plane equation by the inverse modelview matrix */
1661 if (ctx
->ModelView
.flags
& MAT_DIRTY_INVERSE
) {
1662 _math_matrix_analyse( &ctx
->ModelView
);
1664 _mesa_transform_vector( tmp
, params
, ctx
->ModelView
.inv
);
1665 if (TEST_EQ_4V(texUnit
->EyePlaneR
, tmp
))
1667 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1668 COPY_4FV(texUnit
->EyePlaneR
, tmp
);
1671 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(pname)" );
1676 if (pname
==GL_TEXTURE_GEN_MODE
) {
1677 GLenum mode
= (GLenum
) (GLint
) *params
;
1680 case GL_OBJECT_LINEAR
:
1681 bitq
= TEXGEN_OBJ_LINEAR
;
1684 bitq
= TEXGEN_EYE_LINEAR
;
1687 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(param)" );
1690 if (texUnit
->GenModeQ
== mode
)
1692 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1693 texUnit
->GenModeQ
= mode
;
1694 texUnit
->_GenBitQ
= bitq
;
1696 else if (pname
==GL_OBJECT_PLANE
) {
1697 if (TEST_EQ_4V(texUnit
->ObjectPlaneQ
, params
))
1699 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1700 texUnit
->ObjectPlaneQ
[0] = params
[0];
1701 texUnit
->ObjectPlaneQ
[1] = params
[1];
1702 texUnit
->ObjectPlaneQ
[2] = params
[2];
1703 texUnit
->ObjectPlaneQ
[3] = params
[3];
1705 else if (pname
==GL_EYE_PLANE
) {
1707 /* Transform plane equation by the inverse modelview matrix */
1708 if (ctx
->ModelView
.flags
& MAT_DIRTY_INVERSE
) {
1709 _math_matrix_analyse( &ctx
->ModelView
);
1711 _mesa_transform_vector( tmp
, params
, ctx
->ModelView
.inv
);
1712 if (TEST_EQ_4V(texUnit
->EyePlaneQ
, tmp
))
1714 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1715 COPY_4FV(texUnit
->EyePlaneQ
, tmp
);
1718 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(pname)" );
1723 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(coord)" );
1727 if (ctx
->Driver
.TexGen
)
1728 ctx
->Driver
.TexGen( ctx
, coord
, pname
, params
);
1733 _mesa_TexGeniv(GLenum coord
, GLenum pname
, const GLint
*params
)
1736 p
[0] = (GLfloat
) params
[0];
1737 p
[1] = (GLfloat
) params
[1];
1738 p
[2] = (GLfloat
) params
[2];
1739 p
[3] = (GLfloat
) params
[3];
1740 _mesa_TexGenfv(coord
, pname
, p
);
1745 _mesa_TexGend(GLenum coord
, GLenum pname
, GLdouble param
)
1747 GLfloat p
= (GLfloat
) param
;
1748 _mesa_TexGenfv( coord
, pname
, &p
);
1753 _mesa_TexGendv(GLenum coord
, GLenum pname
, const GLdouble
*params
)
1756 p
[0] = (GLfloat
) params
[0];
1757 p
[1] = (GLfloat
) params
[1];
1758 p
[2] = (GLfloat
) params
[2];
1759 p
[3] = (GLfloat
) params
[3];
1760 _mesa_TexGenfv( coord
, pname
, p
);
1765 _mesa_TexGenf( GLenum coord
, GLenum pname
, GLfloat param
)
1767 _mesa_TexGenfv(coord
, pname
, ¶m
);
1772 _mesa_TexGeni( GLenum coord
, GLenum pname
, GLint param
)
1774 _mesa_TexGeniv( coord
, pname
, ¶m
);
1780 _mesa_GetTexGendv( GLenum coord
, GLenum pname
, GLdouble
*params
)
1782 GET_CURRENT_CONTEXT(ctx
);
1783 GLuint tUnit
= ctx
->Texture
.CurrentUnit
;
1784 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[tUnit
];
1785 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1789 if (pname
==GL_TEXTURE_GEN_MODE
) {
1790 params
[0] = ENUM_TO_DOUBLE(texUnit
->GenModeS
);
1792 else if (pname
==GL_OBJECT_PLANE
) {
1793 COPY_4V( params
, texUnit
->ObjectPlaneS
);
1795 else if (pname
==GL_EYE_PLANE
) {
1796 COPY_4V( params
, texUnit
->EyePlaneS
);
1799 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGendv(pname)" );
1804 if (pname
==GL_TEXTURE_GEN_MODE
) {
1805 params
[0] = ENUM_TO_DOUBLE(texUnit
->GenModeT
);
1807 else if (pname
==GL_OBJECT_PLANE
) {
1808 COPY_4V( params
, texUnit
->ObjectPlaneT
);
1810 else if (pname
==GL_EYE_PLANE
) {
1811 COPY_4V( params
, texUnit
->EyePlaneT
);
1814 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGendv(pname)" );
1819 if (pname
==GL_TEXTURE_GEN_MODE
) {
1820 params
[0] = ENUM_TO_DOUBLE(texUnit
->GenModeR
);
1822 else if (pname
==GL_OBJECT_PLANE
) {
1823 COPY_4V( params
, texUnit
->ObjectPlaneR
);
1825 else if (pname
==GL_EYE_PLANE
) {
1826 COPY_4V( params
, texUnit
->EyePlaneR
);
1829 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGendv(pname)" );
1834 if (pname
==GL_TEXTURE_GEN_MODE
) {
1835 params
[0] = ENUM_TO_DOUBLE(texUnit
->GenModeQ
);
1837 else if (pname
==GL_OBJECT_PLANE
) {
1838 COPY_4V( params
, texUnit
->ObjectPlaneQ
);
1840 else if (pname
==GL_EYE_PLANE
) {
1841 COPY_4V( params
, texUnit
->EyePlaneQ
);
1844 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGendv(pname)" );
1849 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGendv(coord)" );
1857 _mesa_GetTexGenfv( GLenum coord
, GLenum pname
, GLfloat
*params
)
1859 GET_CURRENT_CONTEXT(ctx
);
1860 GLuint tUnit
= ctx
->Texture
.CurrentUnit
;
1861 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[tUnit
];
1862 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1866 if (pname
==GL_TEXTURE_GEN_MODE
) {
1867 params
[0] = ENUM_TO_FLOAT(texUnit
->GenModeS
);
1869 else if (pname
==GL_OBJECT_PLANE
) {
1870 COPY_4V( params
, texUnit
->ObjectPlaneS
);
1872 else if (pname
==GL_EYE_PLANE
) {
1873 COPY_4V( params
, texUnit
->EyePlaneS
);
1876 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGenfv(pname)" );
1881 if (pname
==GL_TEXTURE_GEN_MODE
) {
1882 params
[0] = ENUM_TO_FLOAT(texUnit
->GenModeT
);
1884 else if (pname
==GL_OBJECT_PLANE
) {
1885 COPY_4V( params
, texUnit
->ObjectPlaneT
);
1887 else if (pname
==GL_EYE_PLANE
) {
1888 COPY_4V( params
, texUnit
->EyePlaneT
);
1891 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGenfv(pname)" );
1896 if (pname
==GL_TEXTURE_GEN_MODE
) {
1897 params
[0] = ENUM_TO_FLOAT(texUnit
->GenModeR
);
1899 else if (pname
==GL_OBJECT_PLANE
) {
1900 COPY_4V( params
, texUnit
->ObjectPlaneR
);
1902 else if (pname
==GL_EYE_PLANE
) {
1903 COPY_4V( params
, texUnit
->EyePlaneR
);
1906 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGenfv(pname)" );
1911 if (pname
==GL_TEXTURE_GEN_MODE
) {
1912 params
[0] = ENUM_TO_FLOAT(texUnit
->GenModeQ
);
1914 else if (pname
==GL_OBJECT_PLANE
) {
1915 COPY_4V( params
, texUnit
->ObjectPlaneQ
);
1917 else if (pname
==GL_EYE_PLANE
) {
1918 COPY_4V( params
, texUnit
->EyePlaneQ
);
1921 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGenfv(pname)" );
1926 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGenfv(coord)" );
1934 _mesa_GetTexGeniv( GLenum coord
, GLenum pname
, GLint
*params
)
1936 GET_CURRENT_CONTEXT(ctx
);
1937 GLuint tUnit
= ctx
->Texture
.CurrentUnit
;
1938 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[tUnit
];
1939 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1943 if (pname
==GL_TEXTURE_GEN_MODE
) {
1944 params
[0] = texUnit
->GenModeS
;
1946 else if (pname
==GL_OBJECT_PLANE
) {
1947 params
[0] = (GLint
) texUnit
->ObjectPlaneS
[0];
1948 params
[1] = (GLint
) texUnit
->ObjectPlaneS
[1];
1949 params
[2] = (GLint
) texUnit
->ObjectPlaneS
[2];
1950 params
[3] = (GLint
) texUnit
->ObjectPlaneS
[3];
1952 else if (pname
==GL_EYE_PLANE
) {
1953 params
[0] = (GLint
) texUnit
->EyePlaneS
[0];
1954 params
[1] = (GLint
) texUnit
->EyePlaneS
[1];
1955 params
[2] = (GLint
) texUnit
->EyePlaneS
[2];
1956 params
[3] = (GLint
) texUnit
->EyePlaneS
[3];
1959 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGeniv(pname)" );
1964 if (pname
==GL_TEXTURE_GEN_MODE
) {
1965 params
[0] = texUnit
->GenModeT
;
1967 else if (pname
==GL_OBJECT_PLANE
) {
1968 params
[0] = (GLint
) texUnit
->ObjectPlaneT
[0];
1969 params
[1] = (GLint
) texUnit
->ObjectPlaneT
[1];
1970 params
[2] = (GLint
) texUnit
->ObjectPlaneT
[2];
1971 params
[3] = (GLint
) texUnit
->ObjectPlaneT
[3];
1973 else if (pname
==GL_EYE_PLANE
) {
1974 params
[0] = (GLint
) texUnit
->EyePlaneT
[0];
1975 params
[1] = (GLint
) texUnit
->EyePlaneT
[1];
1976 params
[2] = (GLint
) texUnit
->EyePlaneT
[2];
1977 params
[3] = (GLint
) texUnit
->EyePlaneT
[3];
1980 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGeniv(pname)" );
1985 if (pname
==GL_TEXTURE_GEN_MODE
) {
1986 params
[0] = texUnit
->GenModeR
;
1988 else if (pname
==GL_OBJECT_PLANE
) {
1989 params
[0] = (GLint
) texUnit
->ObjectPlaneR
[0];
1990 params
[1] = (GLint
) texUnit
->ObjectPlaneR
[1];
1991 params
[2] = (GLint
) texUnit
->ObjectPlaneR
[2];
1992 params
[3] = (GLint
) texUnit
->ObjectPlaneR
[3];
1994 else if (pname
==GL_EYE_PLANE
) {
1995 params
[0] = (GLint
) texUnit
->EyePlaneR
[0];
1996 params
[1] = (GLint
) texUnit
->EyePlaneR
[1];
1997 params
[2] = (GLint
) texUnit
->EyePlaneR
[2];
1998 params
[3] = (GLint
) texUnit
->EyePlaneR
[3];
2001 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGeniv(pname)" );
2006 if (pname
==GL_TEXTURE_GEN_MODE
) {
2007 params
[0] = texUnit
->GenModeQ
;
2009 else if (pname
==GL_OBJECT_PLANE
) {
2010 params
[0] = (GLint
) texUnit
->ObjectPlaneQ
[0];
2011 params
[1] = (GLint
) texUnit
->ObjectPlaneQ
[1];
2012 params
[2] = (GLint
) texUnit
->ObjectPlaneQ
[2];
2013 params
[3] = (GLint
) texUnit
->ObjectPlaneQ
[3];
2015 else if (pname
==GL_EYE_PLANE
) {
2016 params
[0] = (GLint
) texUnit
->EyePlaneQ
[0];
2017 params
[1] = (GLint
) texUnit
->EyePlaneQ
[1];
2018 params
[2] = (GLint
) texUnit
->EyePlaneQ
[2];
2019 params
[3] = (GLint
) texUnit
->EyePlaneQ
[3];
2022 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGeniv(pname)" );
2027 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGeniv(coord)" );
2033 /* GL_ARB_multitexture */
2035 _mesa_ActiveTextureARB( GLenum target
)
2037 GET_CURRENT_CONTEXT(ctx
);
2038 GLuint texUnit
= target
- GL_TEXTURE0_ARB
;
2039 ASSERT_OUTSIDE_BEGIN_END(ctx
);
2041 if (MESA_VERBOSE
& (VERBOSE_API
|VERBOSE_TEXTURE
))
2042 fprintf(stderr
, "glActiveTexture %s\n",
2043 _mesa_lookup_enum_by_nr(target
));
2045 if (texUnit
> ctx
->Const
.MaxTextureUnits
) {
2046 _mesa_error(ctx
, GL_INVALID_ENUM
, "glActiveTextureARB(target)");
2050 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
2051 ctx
->Texture
.CurrentUnit
= texUnit
;
2052 if (ctx
->Driver
.ActiveTexture
) {
2053 (*ctx
->Driver
.ActiveTexture
)( ctx
, (GLuint
) texUnit
);
2058 /* GL_ARB_multitexture */
2060 _mesa_ClientActiveTextureARB( GLenum target
)
2062 GET_CURRENT_CONTEXT(ctx
);
2063 GLuint texUnit
= target
- GL_TEXTURE0_ARB
;
2064 ASSERT_OUTSIDE_BEGIN_END(ctx
);
2066 if (texUnit
> ctx
->Const
.MaxTextureUnits
) {
2067 _mesa_error(ctx
, GL_INVALID_ENUM
, "glClientActiveTextureARB(target)");
2071 FLUSH_VERTICES(ctx
, _NEW_ARRAY
);
2072 ctx
->Array
.ActiveTexture
= texUnit
;
2077 /**********************************************************************/
2078 /* Pixel Texgen Extensions */
2079 /**********************************************************************/
2082 _mesa_PixelTexGenSGIX(GLenum mode
)
2084 GLenum newRgbSource
, newAlphaSource
;
2085 GET_CURRENT_CONTEXT(ctx
);
2086 ASSERT_OUTSIDE_BEGIN_END(ctx
);
2090 newRgbSource
= GL_PIXEL_GROUP_COLOR_SGIS
;
2091 newAlphaSource
= GL_PIXEL_GROUP_COLOR_SGIS
;
2094 newRgbSource
= GL_PIXEL_GROUP_COLOR_SGIS
;
2095 newAlphaSource
= GL_CURRENT_RASTER_COLOR
;
2098 newRgbSource
= GL_CURRENT_RASTER_COLOR
;
2099 newAlphaSource
= GL_PIXEL_GROUP_COLOR_SGIS
;
2102 newRgbSource
= GL_CURRENT_RASTER_COLOR
;
2103 newAlphaSource
= GL_CURRENT_RASTER_COLOR
;
2106 _mesa_error(ctx
, GL_INVALID_ENUM
, "glPixelTexGenSGIX(mode)");
2110 if (newRgbSource
== ctx
->Pixel
.FragmentRgbSource
&&
2111 newAlphaSource
== ctx
->Pixel
.FragmentAlphaSource
)
2114 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
2115 ctx
->Pixel
.FragmentRgbSource
= newRgbSource
;
2116 ctx
->Pixel
.FragmentAlphaSource
= newAlphaSource
;
2121 _mesa_PixelTexGenParameterfSGIS(GLenum target
, GLfloat value
)
2123 _mesa_PixelTexGenParameteriSGIS(target
, (GLint
) value
);
2128 _mesa_PixelTexGenParameterfvSGIS(GLenum target
, const GLfloat
*value
)
2130 _mesa_PixelTexGenParameteriSGIS(target
, (GLint
) *value
);
2135 _mesa_PixelTexGenParameteriSGIS(GLenum target
, GLint value
)
2137 GET_CURRENT_CONTEXT(ctx
);
2138 ASSERT_OUTSIDE_BEGIN_END(ctx
);
2140 if (value
!= GL_CURRENT_RASTER_COLOR
&& value
!= GL_PIXEL_GROUP_COLOR_SGIS
) {
2141 _mesa_error(ctx
, GL_INVALID_ENUM
, "glPixelTexGenParameterSGIS(value)");
2146 case GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS
:
2147 if (ctx
->Pixel
.FragmentRgbSource
== (GLenum
) value
)
2149 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
2150 ctx
->Pixel
.FragmentRgbSource
= (GLenum
) value
;
2152 case GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS
:
2153 if (ctx
->Pixel
.FragmentAlphaSource
== (GLenum
) value
)
2155 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
2156 ctx
->Pixel
.FragmentAlphaSource
= (GLenum
) value
;
2159 _mesa_error(ctx
, GL_INVALID_ENUM
, "glPixelTexGenParameterSGIS(target)");
2166 _mesa_PixelTexGenParameterivSGIS(GLenum target
, const GLint
*value
)
2168 _mesa_PixelTexGenParameteriSGIS(target
, *value
);
2173 _mesa_GetPixelTexGenParameterfvSGIS(GLenum target
, GLfloat
*value
)
2175 GET_CURRENT_CONTEXT(ctx
);
2176 ASSERT_OUTSIDE_BEGIN_END(ctx
);
2178 if (target
== GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS
) {
2179 *value
= (GLfloat
) ctx
->Pixel
.FragmentRgbSource
;
2181 else if (target
== GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS
) {
2182 *value
= (GLfloat
) ctx
->Pixel
.FragmentAlphaSource
;
2185 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetPixelTexGenParameterfvSGIS(target)");
2191 _mesa_GetPixelTexGenParameterivSGIS(GLenum target
, GLint
*value
)
2193 GET_CURRENT_CONTEXT(ctx
);
2194 ASSERT_OUTSIDE_BEGIN_END(ctx
);
2196 if (target
== GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS
) {
2197 *value
= (GLint
) ctx
->Pixel
.FragmentRgbSource
;
2199 else if (target
== GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS
) {
2200 *value
= (GLint
) ctx
->Pixel
.FragmentAlphaSource
;
2203 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetPixelTexGenParameterivSGIS(target)");