2 * Mesa 3-D graphics library
4 * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
5 * Copyright (C) 2009 VMware, Inc. All Rights Reserved.
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
21 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 * OTHER DEALINGS IN THE SOFTWARE.
29 * glTexEnv-related functions
33 #include "main/glheader.h"
34 #include "main/context.h"
35 #include "main/blend.h"
36 #include "main/enums.h"
37 #include "main/macros.h"
38 #include "main/mtypes.h"
39 #include "main/state.h"
40 #include "main/texenv.h"
41 #include "main/texstate.h"
44 #define TE_ERROR(errCode, msg, value) \
45 _mesa_error(ctx, errCode, msg, _mesa_enum_to_string(value));
48 /** Set texture env mode */
50 set_env_mode(struct gl_context
*ctx
,
51 struct gl_fixedfunc_texture_unit
*texUnit
,
56 if (texUnit
->EnvMode
== mode
)
69 mode
= GL_REPLACE
; /* GL_REPLACE_EXT != GL_REPLACE */
73 legal
= ctx
->Extensions
.NV_texture_env_combine4
;
80 FLUSH_VERTICES(ctx
, _NEW_TEXTURE_STATE
);
81 texUnit
->EnvMode
= mode
;
84 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", mode
);
90 set_env_color(struct gl_context
*ctx
,
91 struct gl_fixedfunc_texture_unit
*texUnit
,
94 if (TEST_EQ_4V(color
, texUnit
->EnvColorUnclamped
))
96 FLUSH_VERTICES(ctx
, _NEW_TEXTURE_STATE
);
97 COPY_4FV(texUnit
->EnvColorUnclamped
, color
);
98 texUnit
->EnvColor
[0] = CLAMP(color
[0], 0.0F
, 1.0F
);
99 texUnit
->EnvColor
[1] = CLAMP(color
[1], 0.0F
, 1.0F
);
100 texUnit
->EnvColor
[2] = CLAMP(color
[2], 0.0F
, 1.0F
);
101 texUnit
->EnvColor
[3] = CLAMP(color
[3], 0.0F
, 1.0F
);
105 /** Set an RGB or A combiner mode/function */
107 set_combiner_mode(struct gl_context
*ctx
,
108 struct gl_fixedfunc_texture_unit
*texUnit
,
109 GLenum pname
, GLenum mode
)
122 legal
= ctx
->Extensions
.ARB_texture_env_combine
;
124 case GL_DOT3_RGB_EXT
:
125 case GL_DOT3_RGBA_EXT
:
126 legal
= (ctx
->API
== API_OPENGL_COMPAT
&&
127 ctx
->Extensions
.EXT_texture_env_dot3
&&
128 pname
== GL_COMBINE_RGB
);
132 legal
= (ctx
->Extensions
.ARB_texture_env_dot3
&&
133 pname
== GL_COMBINE_RGB
);
135 case GL_MODULATE_ADD_ATI
:
136 case GL_MODULATE_SIGNED_ADD_ATI
:
137 case GL_MODULATE_SUBTRACT_ATI
:
138 legal
= (ctx
->API
== API_OPENGL_COMPAT
&&
139 ctx
->Extensions
.ATI_texture_env_combine3
);
146 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", mode
);
152 if (texUnit
->Combine
.ModeRGB
== mode
)
154 FLUSH_VERTICES(ctx
, _NEW_TEXTURE_STATE
);
155 texUnit
->Combine
.ModeRGB
= mode
;
158 case GL_COMBINE_ALPHA
:
159 if (texUnit
->Combine
.ModeA
== mode
)
161 FLUSH_VERTICES(ctx
, _NEW_TEXTURE_STATE
);
162 texUnit
->Combine
.ModeA
= mode
;
165 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(pname=%s)", pname
);
171 /** Set an RGB or A combiner source term */
173 set_combiner_source(struct gl_context
*ctx
,
174 struct gl_fixedfunc_texture_unit
*texUnit
,
175 GLenum pname
, GLenum param
)
178 GLboolean alpha
, legal
;
181 * Translate pname to (term, alpha).
183 * The enums were given sequential values for a reason.
189 case GL_SOURCE3_RGB_NV
:
190 term
= pname
- GL_SOURCE0_RGB
;
193 case GL_SOURCE0_ALPHA
:
194 case GL_SOURCE1_ALPHA
:
195 case GL_SOURCE2_ALPHA
:
196 case GL_SOURCE3_ALPHA_NV
:
197 term
= pname
- GL_SOURCE0_ALPHA
;
201 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(pname=%s)", pname
);
205 if ((term
== 3) && (ctx
->API
!= API_OPENGL_COMPAT
206 || !ctx
->Extensions
.NV_texture_env_combine4
)) {
207 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(pname=%s)", pname
);
211 assert(term
< MAX_COMBINER_TERMS
);
214 * Error-check param (the source term)
219 case GL_PRIMARY_COLOR
:
231 legal
= (ctx
->Extensions
.ARB_texture_env_crossbar
&&
232 param
- GL_TEXTURE0
< ctx
->Const
.MaxTextureUnits
);
235 legal
= (ctx
->API
== API_OPENGL_COMPAT
&&
236 (ctx
->Extensions
.ATI_texture_env_combine3
||
237 ctx
->Extensions
.NV_texture_env_combine4
));
240 legal
= (ctx
->API
== API_OPENGL_COMPAT
&&
241 ctx
->Extensions
.ATI_texture_env_combine3
);
248 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", param
);
252 FLUSH_VERTICES(ctx
, _NEW_TEXTURE_STATE
);
255 texUnit
->Combine
.SourceA
[term
] = param
;
257 texUnit
->Combine
.SourceRGB
[term
] = param
;
261 /** Set an RGB or A combiner operand term */
263 set_combiner_operand(struct gl_context
*ctx
,
264 struct gl_fixedfunc_texture_unit
*texUnit
,
265 GLenum pname
, GLenum param
)
268 GLboolean alpha
, legal
;
270 /* The enums were given sequential values for a reason.
273 case GL_OPERAND0_RGB
:
274 case GL_OPERAND1_RGB
:
275 case GL_OPERAND2_RGB
:
276 case GL_OPERAND3_RGB_NV
:
277 term
= pname
- GL_OPERAND0_RGB
;
280 case GL_OPERAND0_ALPHA
:
281 case GL_OPERAND1_ALPHA
:
282 case GL_OPERAND2_ALPHA
:
283 case GL_OPERAND3_ALPHA_NV
:
284 term
= pname
- GL_OPERAND0_ALPHA
;
288 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(pname=%s)", pname
);
292 if ((term
== 3) && (ctx
->API
!= API_OPENGL_COMPAT
293 || !ctx
->Extensions
.NV_texture_env_combine4
)) {
294 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(pname=%s)", pname
);
298 assert(term
< MAX_COMBINER_TERMS
);
301 * Error-check param (the source operand)
305 case GL_ONE_MINUS_SRC_COLOR
:
306 /* The color input can only be used with GL_OPERAND[01]_RGB in the EXT
307 * version. In the ARB and NV versions and OpenGL ES 1.x they can be
308 * used for any RGB operand.
311 && ((term
< 2) || ctx
->Extensions
.ARB_texture_env_combine
312 || ctx
->Extensions
.NV_texture_env_combine4
);
314 case GL_ONE_MINUS_SRC_ALPHA
:
315 /* GL_ONE_MINUS_SRC_ALPHA can only be used with
316 * GL_OPERAND[01]_(RGB|ALPHA) in the EXT version. In the ARB and NV
317 * versions and OpenGL ES 1.x it can be used for any operand.
319 legal
= (term
< 2) || ctx
->Extensions
.ARB_texture_env_combine
320 || ctx
->Extensions
.NV_texture_env_combine4
;
330 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", param
);
334 FLUSH_VERTICES(ctx
, _NEW_TEXTURE_STATE
);
337 texUnit
->Combine
.OperandA
[term
] = param
;
339 texUnit
->Combine
.OperandRGB
[term
] = param
;
344 set_combiner_scale(struct gl_context
*ctx
,
345 struct gl_fixedfunc_texture_unit
*texUnit
,
346 GLenum pname
, GLfloat scale
)
353 else if (scale
== 2.0F
) {
356 else if (scale
== 4.0F
) {
360 _mesa_error( ctx
, GL_INVALID_VALUE
,
361 "glTexEnv(GL_RGB_SCALE not 1, 2 or 4)" );
367 if (texUnit
->Combine
.ScaleShiftRGB
== shift
)
369 FLUSH_VERTICES(ctx
, _NEW_TEXTURE_STATE
);
370 texUnit
->Combine
.ScaleShiftRGB
= shift
;
373 if (texUnit
->Combine
.ScaleShiftA
== shift
)
375 FLUSH_VERTICES(ctx
, _NEW_TEXTURE_STATE
);
376 texUnit
->Combine
.ScaleShiftA
= shift
;
379 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(pname=%s)", pname
);
386 _mesa_TexEnvfv( GLenum target
, GLenum pname
, const GLfloat
*param
)
388 const GLint iparam0
= (GLint
) param
[0];
390 GET_CURRENT_CONTEXT(ctx
);
392 maxUnit
= (target
== GL_POINT_SPRITE_NV
&& pname
== GL_COORD_REPLACE_NV
)
393 ? ctx
->Const
.MaxTextureCoordUnits
: ctx
->Const
.MaxCombinedTextureImageUnits
;
394 if (ctx
->Texture
.CurrentUnit
>= maxUnit
) {
395 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glTexEnvfv(current unit)");
399 if (target
== GL_TEXTURE_ENV
) {
400 struct gl_fixedfunc_texture_unit
*texUnit
=
401 _mesa_get_current_fixedfunc_tex_unit(ctx
);
403 /* The GL spec says that we should report an error if the unit is greater
404 * than GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, but in practice, only
405 * fixed-function units are usable. This is probably a spec bug.
406 * Ignore glTexEnv(GL_TEXTURE_ENV) calls for non-fixed-func units,
407 * because we don't want to process calls that have no effect.
413 case GL_TEXTURE_ENV_MODE
:
414 set_env_mode(ctx
, texUnit
, (GLenum
) iparam0
);
416 case GL_TEXTURE_ENV_COLOR
:
417 set_env_color(ctx
, texUnit
, param
);
420 case GL_COMBINE_ALPHA
:
421 set_combiner_mode(ctx
, texUnit
, pname
, (GLenum
) iparam0
);
426 case GL_SOURCE3_RGB_NV
:
427 case GL_SOURCE0_ALPHA
:
428 case GL_SOURCE1_ALPHA
:
429 case GL_SOURCE2_ALPHA
:
430 case GL_SOURCE3_ALPHA_NV
:
431 set_combiner_source(ctx
, texUnit
, pname
, (GLenum
) iparam0
);
433 case GL_OPERAND0_RGB
:
434 case GL_OPERAND1_RGB
:
435 case GL_OPERAND2_RGB
:
436 case GL_OPERAND3_RGB_NV
:
437 case GL_OPERAND0_ALPHA
:
438 case GL_OPERAND1_ALPHA
:
439 case GL_OPERAND2_ALPHA
:
440 case GL_OPERAND3_ALPHA_NV
:
441 set_combiner_operand(ctx
, texUnit
, pname
, (GLenum
) iparam0
);
445 set_combiner_scale(ctx
, texUnit
, pname
, param
[0]);
448 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexEnv(pname)" );
452 else if (target
== GL_TEXTURE_FILTER_CONTROL_EXT
) {
453 struct gl_texture_unit
*texUnit
=
454 _mesa_get_current_tex_unit(ctx
);
456 if (pname
== GL_TEXTURE_LOD_BIAS_EXT
) {
457 if (texUnit
->LodBias
== param
[0])
459 FLUSH_VERTICES(ctx
, _NEW_TEXTURE_OBJECT
);
460 texUnit
->LodBias
= param
[0];
463 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(pname=%s)", pname
);
467 else if (target
== GL_POINT_SPRITE_NV
) {
468 /* GL_ARB_point_sprite / GL_NV_point_sprite */
469 if (!ctx
->Extensions
.NV_point_sprite
470 && !ctx
->Extensions
.ARB_point_sprite
) {
471 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexEnv(target=0x%x)", target
);
474 if (pname
== GL_COORD_REPLACE_NV
) {
475 /* It's kind of weird to set point state via glTexEnv,
476 * but that's what the spec calls for.
478 if (iparam0
== GL_TRUE
) {
479 if (ctx
->Point
.CoordReplace
& (1u << ctx
->Texture
.CurrentUnit
))
481 ctx
->Point
.CoordReplace
|= (1u << ctx
->Texture
.CurrentUnit
);
482 } else if (iparam0
== GL_FALSE
) {
483 if (~(ctx
->Point
.CoordReplace
) & (1u << ctx
->Texture
.CurrentUnit
))
485 ctx
->Point
.CoordReplace
&= ~(1u << ctx
->Texture
.CurrentUnit
);
487 _mesa_error( ctx
, GL_INVALID_VALUE
, "glTexEnv(param=0x%x)", iparam0
);
490 FLUSH_VERTICES(ctx
, _NEW_POINT
);
493 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexEnv(pname=0x%x)", pname
);
498 _mesa_error(ctx
, GL_INVALID_ENUM
, "glTexEnv(target=%s)",
499 _mesa_enum_to_string(target
));
503 if (MESA_VERBOSE
&(VERBOSE_API
|VERBOSE_TEXTURE
))
504 _mesa_debug(ctx
, "glTexEnv %s %s %.1f(%s) ...\n",
505 _mesa_enum_to_string(target
),
506 _mesa_enum_to_string(pname
),
508 _mesa_enum_to_string((GLenum
) iparam0
));
510 /* Tell device driver about the new texture environment */
511 if (ctx
->Driver
.TexEnv
) {
512 ctx
->Driver
.TexEnv(ctx
, target
, pname
, param
);
518 _mesa_TexEnvf( GLenum target
, GLenum pname
, GLfloat param
)
522 p
[1] = p
[2] = p
[3] = 0.0;
523 _mesa_TexEnvfv( target
, pname
, p
);
529 _mesa_TexEnvi( GLenum target
, GLenum pname
, GLint param
)
532 p
[0] = (GLfloat
) param
;
533 p
[1] = p
[2] = p
[3] = 0.0;
534 _mesa_TexEnvfv( target
, pname
, p
);
539 _mesa_TexEnviv( GLenum target
, GLenum pname
, const GLint
*param
)
542 if (pname
== GL_TEXTURE_ENV_COLOR
) {
543 p
[0] = INT_TO_FLOAT( param
[0] );
544 p
[1] = INT_TO_FLOAT( param
[1] );
545 p
[2] = INT_TO_FLOAT( param
[2] );
546 p
[3] = INT_TO_FLOAT( param
[3] );
549 p
[0] = (GLfloat
) param
[0];
550 p
[1] = p
[2] = p
[3] = 0; /* init to zero, just to be safe */
552 _mesa_TexEnvfv( target
, pname
, p
);
558 * Helper for glGetTexEnvi/f()
559 * \return value of queried pname or -1 if error.
562 get_texenvi(struct gl_context
*ctx
,
563 const struct gl_fixedfunc_texture_unit
*texUnit
,
567 case GL_TEXTURE_ENV_MODE
:
568 return texUnit
->EnvMode
;
571 return texUnit
->Combine
.ModeRGB
;
572 case GL_COMBINE_ALPHA
:
573 return texUnit
->Combine
.ModeA
;
576 case GL_SOURCE2_RGB
: {
577 const unsigned rgb_idx
= pname
- GL_SOURCE0_RGB
;
578 return texUnit
->Combine
.SourceRGB
[rgb_idx
];
580 case GL_SOURCE3_RGB_NV
:
581 if (ctx
->API
== API_OPENGL_COMPAT
&& ctx
->Extensions
.NV_texture_env_combine4
) {
582 return texUnit
->Combine
.SourceRGB
[3];
585 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
588 case GL_SOURCE0_ALPHA
:
589 case GL_SOURCE1_ALPHA
:
590 case GL_SOURCE2_ALPHA
: {
591 const unsigned alpha_idx
= pname
- GL_SOURCE0_ALPHA
;
592 return texUnit
->Combine
.SourceA
[alpha_idx
];
594 case GL_SOURCE3_ALPHA_NV
:
595 if (ctx
->API
== API_OPENGL_COMPAT
&& ctx
->Extensions
.NV_texture_env_combine4
) {
596 return texUnit
->Combine
.SourceA
[3];
599 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
602 case GL_OPERAND0_RGB
:
603 case GL_OPERAND1_RGB
:
604 case GL_OPERAND2_RGB
: {
605 const unsigned op_rgb
= pname
- GL_OPERAND0_RGB
;
606 return texUnit
->Combine
.OperandRGB
[op_rgb
];
608 case GL_OPERAND3_RGB_NV
:
609 if (ctx
->API
== API_OPENGL_COMPAT
&& ctx
->Extensions
.NV_texture_env_combine4
) {
610 return texUnit
->Combine
.OperandRGB
[3];
613 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
616 case GL_OPERAND0_ALPHA
:
617 case GL_OPERAND1_ALPHA
:
618 case GL_OPERAND2_ALPHA
: {
619 const unsigned op_alpha
= pname
- GL_OPERAND0_ALPHA
;
620 return texUnit
->Combine
.OperandA
[op_alpha
];
622 case GL_OPERAND3_ALPHA_NV
:
623 if (ctx
->API
== API_OPENGL_COMPAT
&& ctx
->Extensions
.NV_texture_env_combine4
) {
624 return texUnit
->Combine
.OperandA
[3];
627 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
631 return 1 << texUnit
->Combine
.ScaleShiftRGB
;
633 return 1 << texUnit
->Combine
.ScaleShiftA
;
635 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
639 return -1; /* error */
645 _mesa_GetTexEnvfv( GLenum target
, GLenum pname
, GLfloat
*params
)
648 GET_CURRENT_CONTEXT(ctx
);
650 maxUnit
= (target
== GL_POINT_SPRITE_NV
&& pname
== GL_COORD_REPLACE_NV
)
651 ? ctx
->Const
.MaxTextureCoordUnits
: ctx
->Const
.MaxCombinedTextureImageUnits
;
652 if (ctx
->Texture
.CurrentUnit
>= maxUnit
) {
653 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glGetTexEnvfv(current unit)");
657 if (target
== GL_TEXTURE_ENV
) {
658 struct gl_fixedfunc_texture_unit
*texUnit
=
659 _mesa_get_current_fixedfunc_tex_unit(ctx
);
661 /* The GL spec says that we should report an error if the unit is greater
662 * than GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, but in practice, only
663 * fixed-function units are usable. This is probably a spec bug.
664 * Ignore calls for non-fixed-func units, because we don't process
665 * glTexEnv for them either.
670 if (pname
== GL_TEXTURE_ENV_COLOR
) {
671 if(ctx
->NewState
& (_NEW_BUFFERS
| _NEW_FRAG_CLAMP
))
672 _mesa_update_state(ctx
);
673 if (_mesa_get_clamp_fragment_color(ctx
, ctx
->DrawBuffer
))
674 COPY_4FV( params
, texUnit
->EnvColor
);
676 COPY_4FV( params
, texUnit
->EnvColorUnclamped
);
679 GLint val
= get_texenvi(ctx
, texUnit
, pname
);
681 *params
= (GLfloat
) val
;
685 else if (target
== GL_TEXTURE_FILTER_CONTROL_EXT
) {
686 const struct gl_texture_unit
*texUnit
= _mesa_get_current_tex_unit(ctx
);
688 if (pname
== GL_TEXTURE_LOD_BIAS_EXT
) {
689 *params
= texUnit
->LodBias
;
692 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)" );
696 else if (target
== GL_POINT_SPRITE_NV
) {
697 /* GL_ARB_point_sprite / GL_NV_point_sprite */
698 if (!ctx
->Extensions
.NV_point_sprite
699 && !ctx
->Extensions
.ARB_point_sprite
) {
700 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(target)" );
703 if (pname
== GL_COORD_REPLACE_NV
) {
704 if (ctx
->Point
.CoordReplace
& (1u << ctx
->Texture
.CurrentUnit
))
710 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)" );
715 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(target)" );
722 _mesa_GetTexEnviv( GLenum target
, GLenum pname
, GLint
*params
)
725 GET_CURRENT_CONTEXT(ctx
);
727 maxUnit
= (target
== GL_POINT_SPRITE_NV
&& pname
== GL_COORD_REPLACE_NV
)
728 ? ctx
->Const
.MaxTextureCoordUnits
: ctx
->Const
.MaxCombinedTextureImageUnits
;
729 if (ctx
->Texture
.CurrentUnit
>= maxUnit
) {
730 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glGetTexEnviv(current unit)");
734 if (target
== GL_TEXTURE_ENV
) {
735 struct gl_fixedfunc_texture_unit
*texUnit
=
736 _mesa_get_current_fixedfunc_tex_unit(ctx
);
738 /* The GL spec says that we should report an error if the unit is greater
739 * than GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, but in practice, only
740 * fixed-function units are usable. This is probably a spec bug.
741 * Ignore calls for non-fixed-func units, because we don't process
742 * glTexEnv for them either.
747 if (pname
== GL_TEXTURE_ENV_COLOR
) {
748 params
[0] = FLOAT_TO_INT( texUnit
->EnvColor
[0] );
749 params
[1] = FLOAT_TO_INT( texUnit
->EnvColor
[1] );
750 params
[2] = FLOAT_TO_INT( texUnit
->EnvColor
[2] );
751 params
[3] = FLOAT_TO_INT( texUnit
->EnvColor
[3] );
754 GLint val
= get_texenvi(ctx
, texUnit
, pname
);
760 else if (target
== GL_TEXTURE_FILTER_CONTROL_EXT
) {
761 const struct gl_texture_unit
*texUnit
= _mesa_get_current_tex_unit(ctx
);
763 if (pname
== GL_TEXTURE_LOD_BIAS_EXT
) {
764 *params
= (GLint
) texUnit
->LodBias
;
767 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)" );
771 else if (target
== GL_POINT_SPRITE_NV
) {
772 /* GL_ARB_point_sprite / GL_NV_point_sprite */
773 if (!ctx
->Extensions
.NV_point_sprite
774 && !ctx
->Extensions
.ARB_point_sprite
) {
775 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(target)" );
778 if (pname
== GL_COORD_REPLACE_NV
) {
779 if (ctx
->Point
.CoordReplace
& (1u << ctx
->Texture
.CurrentUnit
))
785 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)" );
790 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(target)" );