2 * Mesa 3-D graphics library
5 * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
6 * Copyright (C) 2009 VMware, Inc. All Rights Reserved.
8 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this software and associated documentation files (the "Software"),
10 * to deal in the Software without restriction, including without limitation
11 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 * and/or sell copies of the Software, and to permit persons to whom the
13 * Software is furnished to do so, subject to the following conditions:
15 * The above copyright notice and this permission notice shall be included
16 * in all copies or substantial portions of the Software.
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
22 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 * glTexEnv-related functions
33 #include "main/glheader.h"
34 #include "main/context.h"
35 #include "main/enums.h"
36 #include "main/macros.h"
37 #include "main/mtypes.h"
38 #include "main/state.h"
39 #include "main/texenv.h"
40 #include "main/texstate.h"
43 #define TE_ERROR(errCode, msg, value) \
44 _mesa_error(ctx, errCode, msg, _mesa_lookup_enum_by_nr(value));
47 /** Set texture env mode */
49 set_env_mode(struct gl_context
*ctx
,
50 struct gl_texture_unit
*texUnit
,
55 if (texUnit
->EnvMode
== mode
)
68 mode
= GL_REPLACE
; /* GL_REPLACE_EXT != GL_REPLACE */
72 legal
= ctx
->Extensions
.NV_texture_env_combine4
;
79 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
80 texUnit
->EnvMode
= mode
;
83 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", mode
);
89 set_env_color(struct gl_context
*ctx
,
90 struct gl_texture_unit
*texUnit
,
93 if (TEST_EQ_4V(color
, texUnit
->EnvColorUnclamped
))
95 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
96 COPY_4FV(texUnit
->EnvColorUnclamped
, color
);
97 texUnit
->EnvColor
[0] = CLAMP(color
[0], 0.0F
, 1.0F
);
98 texUnit
->EnvColor
[1] = CLAMP(color
[1], 0.0F
, 1.0F
);
99 texUnit
->EnvColor
[2] = CLAMP(color
[2], 0.0F
, 1.0F
);
100 texUnit
->EnvColor
[3] = CLAMP(color
[3], 0.0F
, 1.0F
);
104 /** Set an RGB or A combiner mode/function */
106 set_combiner_mode(struct gl_context
*ctx
,
107 struct gl_texture_unit
*texUnit
,
108 GLenum pname
, GLenum mode
)
121 legal
= ctx
->Extensions
.ARB_texture_env_combine
;
123 case GL_DOT3_RGB_EXT
:
124 case GL_DOT3_RGBA_EXT
:
125 legal
= (ctx
->Extensions
.EXT_texture_env_dot3
&&
126 pname
== GL_COMBINE_RGB
);
130 legal
= (ctx
->Extensions
.ARB_texture_env_dot3
&&
131 pname
== GL_COMBINE_RGB
);
133 case GL_MODULATE_ADD_ATI
:
134 case GL_MODULATE_SIGNED_ADD_ATI
:
135 case GL_MODULATE_SUBTRACT_ATI
:
136 legal
= ctx
->Extensions
.ATI_texture_env_combine3
;
138 case GL_BUMP_ENVMAP_ATI
:
139 legal
= (ctx
->Extensions
.ATI_envmap_bumpmap
&&
140 pname
== GL_COMBINE_RGB
);
147 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", mode
);
153 if (texUnit
->Combine
.ModeRGB
== mode
)
155 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
156 texUnit
->Combine
.ModeRGB
= mode
;
159 case GL_COMBINE_ALPHA
:
160 if (texUnit
->Combine
.ModeA
== mode
)
162 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
163 texUnit
->Combine
.ModeA
= mode
;
166 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(pname=%s)", pname
);
172 /** Set an RGB or A combiner source term */
174 set_combiner_source(struct gl_context
*ctx
,
175 struct gl_texture_unit
*texUnit
,
176 GLenum pname
, GLenum param
)
179 GLboolean alpha
, legal
;
182 * Translate pname to (term, alpha).
184 * The enums were given sequential values for a reason.
190 case GL_SOURCE3_RGB_NV
:
191 term
= pname
- GL_SOURCE0_RGB
;
194 case GL_SOURCE0_ALPHA
:
195 case GL_SOURCE1_ALPHA
:
196 case GL_SOURCE2_ALPHA
:
197 case GL_SOURCE3_ALPHA_NV
:
198 term
= pname
- GL_SOURCE0_ALPHA
;
202 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(pname=%s)", pname
);
206 if ((term
== 3) && !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
->Extensions
.ATI_texture_env_combine3
||
236 ctx
->Extensions
.NV_texture_env_combine4
);
239 legal
= ctx
->Extensions
.ATI_texture_env_combine3
;
246 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", param
);
250 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
253 texUnit
->Combine
.SourceA
[term
] = param
;
255 texUnit
->Combine
.SourceRGB
[term
] = param
;
259 /** Set an RGB or A combiner operand term */
261 set_combiner_operand(struct gl_context
*ctx
,
262 struct gl_texture_unit
*texUnit
,
263 GLenum pname
, GLenum param
)
266 GLboolean alpha
, legal
;
268 /* The enums were given sequential values for a reason.
271 case GL_OPERAND0_RGB
:
272 case GL_OPERAND1_RGB
:
273 case GL_OPERAND2_RGB
:
274 case GL_OPERAND3_RGB_NV
:
275 term
= pname
- GL_OPERAND0_RGB
;
278 case GL_OPERAND0_ALPHA
:
279 case GL_OPERAND1_ALPHA
:
280 case GL_OPERAND2_ALPHA
:
281 case GL_OPERAND3_ALPHA_NV
:
282 term
= pname
- GL_OPERAND0_ALPHA
;
286 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(pname=%s)", pname
);
290 if ((term
== 3) && !ctx
->Extensions
.NV_texture_env_combine4
) {
291 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(pname=%s)", pname
);
295 assert(term
< MAX_COMBINER_TERMS
);
298 * Error-check param (the source operand)
302 case GL_ONE_MINUS_SRC_COLOR
:
303 /* The color input can only be used with GL_OPERAND[01]_RGB in the EXT
304 * version. In the ARB and NV versions they can be used for any RGB
308 && ((term
< 2) || ctx
->Extensions
.ARB_texture_env_combine
309 || ctx
->Extensions
.NV_texture_env_combine4
);
311 case GL_ONE_MINUS_SRC_ALPHA
:
312 /* GL_ONE_MINUS_SRC_ALPHA can only be used with
313 * GL_OPERAND[01]_(RGB|ALPHA) in the EXT version. In the ARB and NV
314 * versions it can be used for any operand.
316 legal
= (term
< 2) || ctx
->Extensions
.ARB_texture_env_combine
317 || ctx
->Extensions
.NV_texture_env_combine4
;
327 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", param
);
331 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
334 texUnit
->Combine
.OperandA
[term
] = param
;
336 texUnit
->Combine
.OperandRGB
[term
] = param
;
341 set_combiner_scale(struct gl_context
*ctx
,
342 struct gl_texture_unit
*texUnit
,
343 GLenum pname
, GLfloat scale
)
350 else if (scale
== 2.0F
) {
353 else if (scale
== 4.0F
) {
357 _mesa_error( ctx
, GL_INVALID_VALUE
,
358 "glTexEnv(GL_RGB_SCALE not 1, 2 or 4)" );
364 if (texUnit
->Combine
.ScaleShiftRGB
== shift
)
366 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
367 texUnit
->Combine
.ScaleShiftRGB
= shift
;
370 if (texUnit
->Combine
.ScaleShiftA
== shift
)
372 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
373 texUnit
->Combine
.ScaleShiftA
= shift
;
376 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(pname=%s)", pname
);
383 _mesa_TexEnvfv( GLenum target
, GLenum pname
, const GLfloat
*param
)
385 const GLint iparam0
= (GLint
) param
[0];
386 struct gl_texture_unit
*texUnit
;
389 GET_CURRENT_CONTEXT(ctx
);
390 ASSERT_OUTSIDE_BEGIN_END(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 texUnit
= _mesa_get_current_tex_unit(ctx
);
401 if (target
== GL_TEXTURE_ENV
) {
403 case GL_TEXTURE_ENV_MODE
:
404 set_env_mode(ctx
, texUnit
, (GLenum
) iparam0
);
406 case GL_TEXTURE_ENV_COLOR
:
407 set_env_color(ctx
, texUnit
, param
);
410 case GL_COMBINE_ALPHA
:
411 set_combiner_mode(ctx
, texUnit
, pname
, (GLenum
) iparam0
);
416 case GL_SOURCE3_RGB_NV
:
417 case GL_SOURCE0_ALPHA
:
418 case GL_SOURCE1_ALPHA
:
419 case GL_SOURCE2_ALPHA
:
420 case GL_SOURCE3_ALPHA_NV
:
421 set_combiner_source(ctx
, texUnit
, pname
, (GLenum
) iparam0
);
423 case GL_OPERAND0_RGB
:
424 case GL_OPERAND1_RGB
:
425 case GL_OPERAND2_RGB
:
426 case GL_OPERAND3_RGB_NV
:
427 case GL_OPERAND0_ALPHA
:
428 case GL_OPERAND1_ALPHA
:
429 case GL_OPERAND2_ALPHA
:
430 case GL_OPERAND3_ALPHA_NV
:
431 set_combiner_operand(ctx
, texUnit
, pname
, (GLenum
) iparam0
);
435 set_combiner_scale(ctx
, texUnit
, pname
, param
[0]);
437 case GL_BUMP_TARGET_ATI
:
438 if (!ctx
->Extensions
.ATI_envmap_bumpmap
) {
439 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexEnv(pname=0x%x)", pname
);
442 if ((iparam0
< GL_TEXTURE0
) ||
443 (iparam0
> GL_TEXTURE31
)) {
444 /* spec doesn't say this but it seems logical */
445 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexEnv(param=0x%x)", iparam0
);
448 if (!((1 << (iparam0
- GL_TEXTURE0
)) & ctx
->Const
.SupportedBumpUnits
)) {
449 _mesa_error( ctx
, GL_INVALID_VALUE
, "glTexEnv(param=0x%x)", iparam0
);
453 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
454 texUnit
->BumpTarget
= iparam0
;
458 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexEnv(pname)" );
462 else if (target
== GL_TEXTURE_FILTER_CONTROL_EXT
) {
463 if (pname
== GL_TEXTURE_LOD_BIAS_EXT
) {
464 if (texUnit
->LodBias
== param
[0])
466 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
467 texUnit
->LodBias
= param
[0];
470 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(pname=%s)", pname
);
474 else if (target
== GL_POINT_SPRITE_NV
) {
475 /* GL_ARB_point_sprite / GL_NV_point_sprite */
476 if (!ctx
->Extensions
.NV_point_sprite
477 && !ctx
->Extensions
.ARB_point_sprite
) {
478 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexEnv(target=0x%x)", target
);
481 if (pname
== GL_COORD_REPLACE_NV
) {
482 if (iparam0
== GL_TRUE
|| iparam0
== GL_FALSE
) {
483 /* It's kind of weird to set point state via glTexEnv,
484 * but that's what the spec calls for.
486 const GLboolean state
= (GLboolean
) iparam0
;
487 if (ctx
->Point
.CoordReplace
[ctx
->Texture
.CurrentUnit
] == state
)
489 FLUSH_VERTICES(ctx
, _NEW_POINT
);
490 ctx
->Point
.CoordReplace
[ctx
->Texture
.CurrentUnit
] = state
;
493 _mesa_error( ctx
, GL_INVALID_VALUE
, "glTexEnv(param=0x%x)", iparam0
);
498 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexEnv(pname=0x%x)", pname
);
503 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexEnv(target=0x%x)",target
);
507 if (MESA_VERBOSE
&(VERBOSE_API
|VERBOSE_TEXTURE
))
508 _mesa_debug(ctx
, "glTexEnv %s %s %.1f(%s) ...\n",
509 _mesa_lookup_enum_by_nr(target
),
510 _mesa_lookup_enum_by_nr(pname
),
512 _mesa_lookup_enum_by_nr((GLenum
) iparam0
));
514 /* Tell device driver about the new texture environment */
515 if (ctx
->Driver
.TexEnv
) {
516 (*ctx
->Driver
.TexEnv
)( ctx
, target
, pname
, param
);
522 _mesa_TexEnvf( GLenum target
, GLenum pname
, GLfloat param
)
526 p
[1] = p
[2] = p
[3] = 0.0;
527 _mesa_TexEnvfv( target
, pname
, p
);
533 _mesa_TexEnvi( GLenum target
, GLenum pname
, GLint param
)
536 p
[0] = (GLfloat
) param
;
537 p
[1] = p
[2] = p
[3] = 0.0;
538 _mesa_TexEnvfv( target
, pname
, p
);
543 _mesa_TexEnviv( GLenum target
, GLenum pname
, const GLint
*param
)
546 if (pname
== GL_TEXTURE_ENV_COLOR
) {
547 p
[0] = INT_TO_FLOAT( param
[0] );
548 p
[1] = INT_TO_FLOAT( param
[1] );
549 p
[2] = INT_TO_FLOAT( param
[2] );
550 p
[3] = INT_TO_FLOAT( param
[3] );
553 p
[0] = (GLfloat
) param
[0];
554 p
[1] = p
[2] = p
[3] = 0; /* init to zero, just to be safe */
556 _mesa_TexEnvfv( target
, pname
, p
);
562 * Helper for glGetTexEnvi/f()
563 * \return value of queried pname or -1 if error.
566 get_texenvi(struct gl_context
*ctx
, const struct gl_texture_unit
*texUnit
,
570 case GL_TEXTURE_ENV_MODE
:
571 return texUnit
->EnvMode
;
574 return texUnit
->Combine
.ModeRGB
;
575 case GL_COMBINE_ALPHA
:
576 return texUnit
->Combine
.ModeA
;
579 case GL_SOURCE2_RGB
: {
580 const unsigned rgb_idx
= pname
- GL_SOURCE0_RGB
;
581 return texUnit
->Combine
.SourceRGB
[rgb_idx
];
583 case GL_SOURCE3_RGB_NV
:
584 if (ctx
->Extensions
.NV_texture_env_combine4
) {
585 return texUnit
->Combine
.SourceRGB
[3];
588 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
591 case GL_SOURCE0_ALPHA
:
592 case GL_SOURCE1_ALPHA
:
593 case GL_SOURCE2_ALPHA
: {
594 const unsigned alpha_idx
= pname
- GL_SOURCE0_ALPHA
;
595 return texUnit
->Combine
.SourceA
[alpha_idx
];
597 case GL_SOURCE3_ALPHA_NV
:
598 if (ctx
->Extensions
.NV_texture_env_combine4
) {
599 return texUnit
->Combine
.SourceA
[3];
602 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
605 case GL_OPERAND0_RGB
:
606 case GL_OPERAND1_RGB
:
607 case GL_OPERAND2_RGB
: {
608 const unsigned op_rgb
= pname
- GL_OPERAND0_RGB
;
609 return texUnit
->Combine
.OperandRGB
[op_rgb
];
611 case GL_OPERAND3_RGB_NV
:
612 if (ctx
->Extensions
.NV_texture_env_combine4
) {
613 return texUnit
->Combine
.OperandRGB
[3];
616 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
619 case GL_OPERAND0_ALPHA
:
620 case GL_OPERAND1_ALPHA
:
621 case GL_OPERAND2_ALPHA
: {
622 const unsigned op_alpha
= pname
- GL_OPERAND0_ALPHA
;
623 return texUnit
->Combine
.OperandA
[op_alpha
];
625 case GL_OPERAND3_ALPHA_NV
:
626 if (ctx
->Extensions
.NV_texture_env_combine4
) {
627 return texUnit
->Combine
.OperandA
[3];
630 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
634 return 1 << texUnit
->Combine
.ScaleShiftRGB
;
636 return 1 << texUnit
->Combine
.ScaleShiftA
;
637 case GL_BUMP_TARGET_ATI
:
638 /* spec doesn't say so, but I think this should be queryable */
639 if (ctx
->Extensions
.ATI_envmap_bumpmap
) {
640 return texUnit
->BumpTarget
;
643 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
648 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
652 return -1; /* error */
658 _mesa_GetTexEnvfv( GLenum target
, GLenum pname
, GLfloat
*params
)
661 const struct gl_texture_unit
*texUnit
;
662 GET_CURRENT_CONTEXT(ctx
);
663 ASSERT_OUTSIDE_BEGIN_END(ctx
);
665 maxUnit
= (target
== GL_POINT_SPRITE_NV
&& pname
== GL_COORD_REPLACE_NV
)
666 ? ctx
->Const
.MaxTextureCoordUnits
: ctx
->Const
.MaxCombinedTextureImageUnits
;
667 if (ctx
->Texture
.CurrentUnit
>= maxUnit
) {
668 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glGetTexEnvfv(current unit)");
672 texUnit
= _mesa_get_current_tex_unit(ctx
);
674 if (target
== GL_TEXTURE_ENV
) {
675 if (pname
== GL_TEXTURE_ENV_COLOR
) {
676 if(ctx
->NewState
& (_NEW_BUFFERS
| _NEW_FRAG_CLAMP
))
677 _mesa_update_state(ctx
);
678 if(ctx
->Color
._ClampFragmentColor
)
679 COPY_4FV( params
, texUnit
->EnvColor
);
681 COPY_4FV( params
, texUnit
->EnvColorUnclamped
);
684 GLint val
= get_texenvi(ctx
, texUnit
, pname
);
686 *params
= (GLfloat
) val
;
690 else if (target
== GL_TEXTURE_FILTER_CONTROL_EXT
) {
691 if (pname
== GL_TEXTURE_LOD_BIAS_EXT
) {
692 *params
= texUnit
->LodBias
;
695 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)" );
699 else if (target
== GL_POINT_SPRITE_NV
) {
700 /* GL_ARB_point_sprite / GL_NV_point_sprite */
701 if (!ctx
->Extensions
.NV_point_sprite
702 && !ctx
->Extensions
.ARB_point_sprite
) {
703 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(target)" );
706 if (pname
== GL_COORD_REPLACE_NV
) {
707 *params
= (GLfloat
) ctx
->Point
.CoordReplace
[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 const struct gl_texture_unit
*texUnit
;
726 GET_CURRENT_CONTEXT(ctx
);
727 ASSERT_OUTSIDE_BEGIN_END(ctx
);
729 maxUnit
= (target
== GL_POINT_SPRITE_NV
&& pname
== GL_COORD_REPLACE_NV
)
730 ? ctx
->Const
.MaxTextureCoordUnits
: ctx
->Const
.MaxCombinedTextureImageUnits
;
731 if (ctx
->Texture
.CurrentUnit
>= maxUnit
) {
732 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glGetTexEnviv(current unit)");
736 texUnit
= _mesa_get_current_tex_unit(ctx
);
738 if (target
== GL_TEXTURE_ENV
) {
739 if (pname
== GL_TEXTURE_ENV_COLOR
) {
740 params
[0] = FLOAT_TO_INT( texUnit
->EnvColor
[0] );
741 params
[1] = FLOAT_TO_INT( texUnit
->EnvColor
[1] );
742 params
[2] = FLOAT_TO_INT( texUnit
->EnvColor
[2] );
743 params
[3] = FLOAT_TO_INT( texUnit
->EnvColor
[3] );
746 GLint val
= get_texenvi(ctx
, texUnit
, pname
);
752 else if (target
== GL_TEXTURE_FILTER_CONTROL_EXT
) {
753 if (pname
== GL_TEXTURE_LOD_BIAS_EXT
) {
754 *params
= (GLint
) texUnit
->LodBias
;
757 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)" );
761 else if (target
== GL_POINT_SPRITE_NV
) {
762 /* GL_ARB_point_sprite / GL_NV_point_sprite */
763 if (!ctx
->Extensions
.NV_point_sprite
764 && !ctx
->Extensions
.ARB_point_sprite
) {
765 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(target)" );
768 if (pname
== GL_COORD_REPLACE_NV
) {
769 *params
= (GLint
) ctx
->Point
.CoordReplace
[ctx
->Texture
.CurrentUnit
];
772 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)" );
777 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(target)" );
784 * Why does ATI_envmap_bumpmap require new entrypoints? Should just
785 * reuse TexEnv ones...
788 _mesa_TexBumpParameterivATI( GLenum pname
, const GLint
*param
)
791 GET_CURRENT_CONTEXT(ctx
);
792 ASSERT_OUTSIDE_BEGIN_END(ctx
);
794 if (!ctx
->Extensions
.ATI_envmap_bumpmap
) {
795 /* This isn't an "official" error case, but let's tell the user
796 * that something's wrong.
798 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glTexBumpParameterivATI");
802 if (pname
== GL_BUMP_ROT_MATRIX_ATI
) {
803 /* hope that conversion is correct here */
804 p
[0] = INT_TO_FLOAT( param
[0] );
805 p
[1] = INT_TO_FLOAT( param
[1] );
806 p
[2] = INT_TO_FLOAT( param
[2] );
807 p
[3] = INT_TO_FLOAT( param
[3] );
810 p
[0] = (GLfloat
) param
[0];
811 p
[1] = p
[2] = p
[3] = 0.0F
; /* init to zero, just to be safe */
813 _mesa_TexBumpParameterfvATI( pname
, p
);
818 _mesa_TexBumpParameterfvATI( GLenum pname
, const GLfloat
*param
)
820 struct gl_texture_unit
*texUnit
;
821 GET_CURRENT_CONTEXT(ctx
);
822 ASSERT_OUTSIDE_BEGIN_END(ctx
);
824 if (!ctx
->Extensions
.ATI_envmap_bumpmap
) {
825 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glTexBumpParameterfvATI");
829 texUnit
= _mesa_get_current_tex_unit(ctx
);
831 if (pname
== GL_BUMP_ROT_MATRIX_ATI
) {
832 if (TEST_EQ_4V(param
, texUnit
->RotMatrix
))
834 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
835 COPY_4FV(texUnit
->RotMatrix
, param
);
838 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexBumpParameter(pname)" );
841 /* Drivers might want to know about this, instead of dedicated function
842 just shove it into TexEnv where it really belongs anyway */
843 if (ctx
->Driver
.TexEnv
) {
844 (*ctx
->Driver
.TexEnv
)( ctx
, 0, pname
, param
);
850 _mesa_GetTexBumpParameterivATI( GLenum pname
, GLint
*param
)
852 const struct gl_texture_unit
*texUnit
;
854 GET_CURRENT_CONTEXT(ctx
);
855 ASSERT_OUTSIDE_BEGIN_END(ctx
);
857 if (!ctx
->Extensions
.ATI_envmap_bumpmap
) {
858 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glGetTexBumpParameterivATI");
862 texUnit
= _mesa_get_current_tex_unit(ctx
);
864 if (pname
== GL_BUMP_ROT_MATRIX_SIZE_ATI
) {
865 /* spec leaves open to support larger matrices.
866 Don't think anyone would ever want to use it
867 (and apps almost certainly would not understand it and
868 thus fail to submit matrices correctly) so hardcode this. */
871 else if (pname
== GL_BUMP_ROT_MATRIX_ATI
) {
872 /* hope that conversion is correct here */
873 param
[0] = FLOAT_TO_INT(texUnit
->RotMatrix
[0]);
874 param
[1] = FLOAT_TO_INT(texUnit
->RotMatrix
[1]);
875 param
[2] = FLOAT_TO_INT(texUnit
->RotMatrix
[2]);
876 param
[3] = FLOAT_TO_INT(texUnit
->RotMatrix
[3]);
878 else if (pname
== GL_BUMP_NUM_TEX_UNITS_ATI
) {
880 for (i
= 0; i
< ctx
->Const
.MaxTextureImageUnits
; i
++) {
881 if (ctx
->Const
.SupportedBumpUnits
& (1 << i
)) {
887 else if (pname
== GL_BUMP_TEX_UNITS_ATI
) {
888 for (i
= 0; i
< ctx
->Const
.MaxTextureImageUnits
; i
++) {
889 if (ctx
->Const
.SupportedBumpUnits
& (1 << i
)) {
890 *param
++ = i
+ GL_TEXTURE0
;
895 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexBumpParameter(pname)" );
902 _mesa_GetTexBumpParameterfvATI( GLenum pname
, GLfloat
*param
)
904 const struct gl_texture_unit
*texUnit
;
906 GET_CURRENT_CONTEXT(ctx
);
907 ASSERT_OUTSIDE_BEGIN_END(ctx
);
909 if (!ctx
->Extensions
.ATI_envmap_bumpmap
) {
910 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glGetTexBumpParameterfvATI");
914 texUnit
= _mesa_get_current_tex_unit(ctx
);
916 if (pname
== GL_BUMP_ROT_MATRIX_SIZE_ATI
) {
917 /* spec leaves open to support larger matrices.
918 Don't think anyone would ever want to use it
919 (and apps might not understand it) so hardcode this. */
922 else if (pname
== GL_BUMP_ROT_MATRIX_ATI
) {
923 param
[0] = texUnit
->RotMatrix
[0];
924 param
[1] = texUnit
->RotMatrix
[1];
925 param
[2] = texUnit
->RotMatrix
[2];
926 param
[3] = texUnit
->RotMatrix
[3];
928 else if (pname
== GL_BUMP_NUM_TEX_UNITS_ATI
) {
930 for (i
= 0; i
< ctx
->Const
.MaxTextureImageUnits
; i
++) {
931 if (ctx
->Const
.SupportedBumpUnits
& (1 << i
)) {
935 *param
= (GLfloat
) count
;
937 else if (pname
== GL_BUMP_TEX_UNITS_ATI
) {
938 for (i
= 0; i
< ctx
->Const
.MaxTextureImageUnits
; i
++) {
939 if (ctx
->Const
.SupportedBumpUnits
& (1 << i
)) {
940 *param
++ = (GLfloat
) (i
+ GL_TEXTURE0
);
945 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexBumpParameter(pname)" );