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
->EnvColor
))
95 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
96 COPY_4FV(texUnit
->EnvColor
, color
);
100 /** Set an RGB or A combiner mode/function */
102 set_combiner_mode(struct gl_context
*ctx
,
103 struct gl_texture_unit
*texUnit
,
104 GLenum pname
, GLenum mode
)
117 legal
= ctx
->Extensions
.ARB_texture_env_combine
;
119 case GL_DOT3_RGB_EXT
:
120 case GL_DOT3_RGBA_EXT
:
121 legal
= (ctx
->Extensions
.EXT_texture_env_dot3
&&
122 pname
== GL_COMBINE_RGB
);
126 legal
= (ctx
->Extensions
.ARB_texture_env_dot3
&&
127 pname
== GL_COMBINE_RGB
);
129 case GL_MODULATE_ADD_ATI
:
130 case GL_MODULATE_SIGNED_ADD_ATI
:
131 case GL_MODULATE_SUBTRACT_ATI
:
132 legal
= ctx
->Extensions
.ATI_texture_env_combine3
;
134 case GL_BUMP_ENVMAP_ATI
:
135 legal
= (ctx
->Extensions
.ATI_envmap_bumpmap
&&
136 pname
== GL_COMBINE_RGB
);
143 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", mode
);
149 if (texUnit
->Combine
.ModeRGB
== mode
)
151 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
152 texUnit
->Combine
.ModeRGB
= mode
;
155 case GL_COMBINE_ALPHA
:
156 if (texUnit
->Combine
.ModeA
== mode
)
158 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
159 texUnit
->Combine
.ModeA
= mode
;
162 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(pname=%s)", pname
);
168 /** Set an RGB or A combiner source term */
170 set_combiner_source(struct gl_context
*ctx
,
171 struct gl_texture_unit
*texUnit
,
172 GLenum pname
, GLenum param
)
175 GLboolean alpha
, legal
;
178 * Translate pname to (term, alpha).
180 * The enums were given sequential values for a reason.
186 case GL_SOURCE3_RGB_NV
:
187 term
= pname
- GL_SOURCE0_RGB
;
190 case GL_SOURCE0_ALPHA
:
191 case GL_SOURCE1_ALPHA
:
192 case GL_SOURCE2_ALPHA
:
193 case GL_SOURCE3_ALPHA_NV
:
194 term
= pname
- GL_SOURCE0_ALPHA
;
198 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(pname=%s)", pname
);
202 if ((term
== 3) && !ctx
->Extensions
.NV_texture_env_combine4
) {
203 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(pname=%s)", pname
);
207 assert(term
< MAX_COMBINER_TERMS
);
210 * Error-check param (the source term)
215 case GL_PRIMARY_COLOR
:
227 legal
= (ctx
->Extensions
.ARB_texture_env_crossbar
&&
228 param
- GL_TEXTURE0
< ctx
->Const
.MaxTextureUnits
);
231 legal
= (ctx
->Extensions
.ATI_texture_env_combine3
||
232 ctx
->Extensions
.NV_texture_env_combine4
);
235 legal
= ctx
->Extensions
.ATI_texture_env_combine3
;
242 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", param
);
246 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
249 texUnit
->Combine
.SourceA
[term
] = param
;
251 texUnit
->Combine
.SourceRGB
[term
] = param
;
255 /** Set an RGB or A combiner operand term */
257 set_combiner_operand(struct gl_context
*ctx
,
258 struct gl_texture_unit
*texUnit
,
259 GLenum pname
, GLenum param
)
262 GLboolean alpha
, legal
;
264 /* The enums were given sequential values for a reason.
267 case GL_OPERAND0_RGB
:
268 case GL_OPERAND1_RGB
:
269 case GL_OPERAND2_RGB
:
270 case GL_OPERAND3_RGB_NV
:
271 term
= pname
- GL_OPERAND0_RGB
;
274 case GL_OPERAND0_ALPHA
:
275 case GL_OPERAND1_ALPHA
:
276 case GL_OPERAND2_ALPHA
:
277 case GL_OPERAND3_ALPHA_NV
:
278 term
= pname
- GL_OPERAND0_ALPHA
;
282 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(pname=%s)", pname
);
286 if ((term
== 3) && !ctx
->Extensions
.NV_texture_env_combine4
) {
287 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(pname=%s)", pname
);
291 assert(term
< MAX_COMBINER_TERMS
);
294 * Error-check param (the source operand)
298 case GL_ONE_MINUS_SRC_COLOR
:
299 /* The color input can only be used with GL_OPERAND[01]_RGB in the EXT
300 * version. In the ARB and NV versions they can be used for any RGB
304 && ((term
< 2) || ctx
->Extensions
.ARB_texture_env_combine
305 || ctx
->Extensions
.NV_texture_env_combine4
);
307 case GL_ONE_MINUS_SRC_ALPHA
:
308 /* GL_ONE_MINUS_SRC_ALPHA can only be used with
309 * GL_OPERAND[01]_(RGB|ALPHA) in the EXT version. In the ARB and NV
310 * versions it can be used for any operand.
312 legal
= (term
< 2) || ctx
->Extensions
.ARB_texture_env_combine
313 || ctx
->Extensions
.NV_texture_env_combine4
;
323 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", param
);
327 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
330 texUnit
->Combine
.OperandA
[term
] = param
;
332 texUnit
->Combine
.OperandRGB
[term
] = param
;
337 set_combiner_scale(struct gl_context
*ctx
,
338 struct gl_texture_unit
*texUnit
,
339 GLenum pname
, GLfloat scale
)
346 else if (scale
== 2.0F
) {
349 else if (scale
== 4.0F
) {
353 _mesa_error( ctx
, GL_INVALID_VALUE
,
354 "glTexEnv(GL_RGB_SCALE not 1, 2 or 4)" );
360 if (texUnit
->Combine
.ScaleShiftRGB
== shift
)
362 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
363 texUnit
->Combine
.ScaleShiftRGB
= shift
;
366 if (texUnit
->Combine
.ScaleShiftA
== shift
)
368 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
369 texUnit
->Combine
.ScaleShiftA
= shift
;
372 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(pname=%s)", pname
);
379 _mesa_TexEnvfv( GLenum target
, GLenum pname
, const GLfloat
*param
)
381 const GLint iparam0
= (GLint
) param
[0];
382 struct gl_texture_unit
*texUnit
;
385 GET_CURRENT_CONTEXT(ctx
);
386 ASSERT_OUTSIDE_BEGIN_END(ctx
);
388 maxUnit
= (target
== GL_POINT_SPRITE_NV
&& pname
== GL_COORD_REPLACE_NV
)
389 ? ctx
->Const
.MaxTextureCoordUnits
: ctx
->Const
.MaxCombinedTextureImageUnits
;
390 if (ctx
->Texture
.CurrentUnit
>= maxUnit
) {
391 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glTexEnvfv(current unit)");
395 texUnit
= _mesa_get_current_tex_unit(ctx
);
397 if (target
== GL_TEXTURE_ENV
) {
399 case GL_TEXTURE_ENV_MODE
:
400 set_env_mode(ctx
, texUnit
, (GLenum
) iparam0
);
402 case GL_TEXTURE_ENV_COLOR
:
403 set_env_color(ctx
, texUnit
, param
);
406 case GL_COMBINE_ALPHA
:
407 set_combiner_mode(ctx
, texUnit
, pname
, (GLenum
) iparam0
);
412 case GL_SOURCE3_RGB_NV
:
413 case GL_SOURCE0_ALPHA
:
414 case GL_SOURCE1_ALPHA
:
415 case GL_SOURCE2_ALPHA
:
416 case GL_SOURCE3_ALPHA_NV
:
417 set_combiner_source(ctx
, texUnit
, pname
, (GLenum
) iparam0
);
419 case GL_OPERAND0_RGB
:
420 case GL_OPERAND1_RGB
:
421 case GL_OPERAND2_RGB
:
422 case GL_OPERAND3_RGB_NV
:
423 case GL_OPERAND0_ALPHA
:
424 case GL_OPERAND1_ALPHA
:
425 case GL_OPERAND2_ALPHA
:
426 case GL_OPERAND3_ALPHA_NV
:
427 set_combiner_operand(ctx
, texUnit
, pname
, (GLenum
) iparam0
);
431 set_combiner_scale(ctx
, texUnit
, pname
, param
[0]);
433 case GL_BUMP_TARGET_ATI
:
434 if (!ctx
->Extensions
.ATI_envmap_bumpmap
) {
435 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexEnv(pname=0x%x)", pname
);
438 if ((iparam0
< GL_TEXTURE0
) ||
439 (iparam0
> GL_TEXTURE31
)) {
440 /* spec doesn't say this but it seems logical */
441 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexEnv(param=0x%x)", iparam0
);
444 if (!((1 << (iparam0
- GL_TEXTURE0
)) & ctx
->Const
.SupportedBumpUnits
)) {
445 _mesa_error( ctx
, GL_INVALID_VALUE
, "glTexEnv(param=0x%x)", iparam0
);
449 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
450 texUnit
->BumpTarget
= iparam0
;
454 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexEnv(pname)" );
458 else if (target
== GL_TEXTURE_FILTER_CONTROL_EXT
) {
459 if (pname
== GL_TEXTURE_LOD_BIAS_EXT
) {
460 if (texUnit
->LodBias
== param
[0])
462 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
463 texUnit
->LodBias
= param
[0];
466 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(pname=%s)", pname
);
470 else if (target
== GL_POINT_SPRITE_NV
) {
471 /* GL_ARB_point_sprite / GL_NV_point_sprite */
472 if (!ctx
->Extensions
.NV_point_sprite
473 && !ctx
->Extensions
.ARB_point_sprite
) {
474 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexEnv(target=0x%x)", target
);
477 if (pname
== GL_COORD_REPLACE_NV
) {
478 if (iparam0
== GL_TRUE
|| iparam0
== GL_FALSE
) {
479 /* It's kind of weird to set point state via glTexEnv,
480 * but that's what the spec calls for.
482 const GLboolean state
= (GLboolean
) iparam0
;
483 if (ctx
->Point
.CoordReplace
[ctx
->Texture
.CurrentUnit
] == state
)
485 FLUSH_VERTICES(ctx
, _NEW_POINT
);
486 ctx
->Point
.CoordReplace
[ctx
->Texture
.CurrentUnit
] = state
;
489 _mesa_error( ctx
, GL_INVALID_VALUE
, "glTexEnv(param=0x%x)", iparam0
);
494 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexEnv(pname=0x%x)", pname
);
499 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexEnv(target=0x%x)",target
);
503 if (MESA_VERBOSE
&(VERBOSE_API
|VERBOSE_TEXTURE
))
504 _mesa_debug(ctx
, "glTexEnv %s %s %.1f(%s) ...\n",
505 _mesa_lookup_enum_by_nr(target
),
506 _mesa_lookup_enum_by_nr(pname
),
508 _mesa_lookup_enum_by_nr((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
, const struct gl_texture_unit
*texUnit
,
566 case GL_TEXTURE_ENV_MODE
:
567 return texUnit
->EnvMode
;
570 return texUnit
->Combine
.ModeRGB
;
571 case GL_COMBINE_ALPHA
:
572 return texUnit
->Combine
.ModeA
;
575 case GL_SOURCE2_RGB
: {
576 const unsigned rgb_idx
= pname
- GL_SOURCE0_RGB
;
577 return texUnit
->Combine
.SourceRGB
[rgb_idx
];
579 case GL_SOURCE3_RGB_NV
:
580 if (ctx
->Extensions
.NV_texture_env_combine4
) {
581 return texUnit
->Combine
.SourceRGB
[3];
584 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
587 case GL_SOURCE0_ALPHA
:
588 case GL_SOURCE1_ALPHA
:
589 case GL_SOURCE2_ALPHA
: {
590 const unsigned alpha_idx
= pname
- GL_SOURCE0_ALPHA
;
591 return texUnit
->Combine
.SourceA
[alpha_idx
];
593 case GL_SOURCE3_ALPHA_NV
:
594 if (ctx
->Extensions
.NV_texture_env_combine4
) {
595 return texUnit
->Combine
.SourceA
[3];
598 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
601 case GL_OPERAND0_RGB
:
602 case GL_OPERAND1_RGB
:
603 case GL_OPERAND2_RGB
: {
604 const unsigned op_rgb
= pname
- GL_OPERAND0_RGB
;
605 return texUnit
->Combine
.OperandRGB
[op_rgb
];
607 case GL_OPERAND3_RGB_NV
:
608 if (ctx
->Extensions
.NV_texture_env_combine4
) {
609 return texUnit
->Combine
.OperandRGB
[3];
612 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
615 case GL_OPERAND0_ALPHA
:
616 case GL_OPERAND1_ALPHA
:
617 case GL_OPERAND2_ALPHA
: {
618 const unsigned op_alpha
= pname
- GL_OPERAND0_ALPHA
;
619 return texUnit
->Combine
.OperandA
[op_alpha
];
621 case GL_OPERAND3_ALPHA_NV
:
622 if (ctx
->Extensions
.NV_texture_env_combine4
) {
623 return texUnit
->Combine
.OperandA
[3];
626 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
630 return 1 << texUnit
->Combine
.ScaleShiftRGB
;
632 return 1 << texUnit
->Combine
.ScaleShiftA
;
633 case GL_BUMP_TARGET_ATI
:
634 /* spec doesn't say so, but I think this should be queryable */
635 if (ctx
->Extensions
.ATI_envmap_bumpmap
) {
636 return texUnit
->BumpTarget
;
639 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
644 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
648 return -1; /* error */
654 _mesa_GetTexEnvfv( GLenum target
, GLenum pname
, GLfloat
*params
)
657 const struct gl_texture_unit
*texUnit
;
658 GET_CURRENT_CONTEXT(ctx
);
659 ASSERT_OUTSIDE_BEGIN_END(ctx
);
661 maxUnit
= (target
== GL_POINT_SPRITE_NV
&& pname
== GL_COORD_REPLACE_NV
)
662 ? ctx
->Const
.MaxTextureCoordUnits
: ctx
->Const
.MaxCombinedTextureImageUnits
;
663 if (ctx
->Texture
.CurrentUnit
>= maxUnit
) {
664 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glGetTexEnvfv(current unit)");
668 texUnit
= _mesa_get_current_tex_unit(ctx
);
670 if (target
== GL_TEXTURE_ENV
) {
671 if (pname
== GL_TEXTURE_ENV_COLOR
) {
672 if(ctx
->NewState
& _NEW_BUFFERS
)
673 _mesa_update_state(ctx
);
674 COPY_4FV( params
, texUnit
->EnvColor
);
677 GLint val
= get_texenvi(ctx
, texUnit
, pname
);
679 *params
= (GLfloat
) val
;
683 else if (target
== GL_TEXTURE_FILTER_CONTROL_EXT
) {
684 if (pname
== GL_TEXTURE_LOD_BIAS_EXT
) {
685 *params
= texUnit
->LodBias
;
688 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)" );
692 else if (target
== GL_POINT_SPRITE_NV
) {
693 /* GL_ARB_point_sprite / GL_NV_point_sprite */
694 if (!ctx
->Extensions
.NV_point_sprite
695 && !ctx
->Extensions
.ARB_point_sprite
) {
696 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(target)" );
699 if (pname
== GL_COORD_REPLACE_NV
) {
700 *params
= (GLfloat
) ctx
->Point
.CoordReplace
[ctx
->Texture
.CurrentUnit
];
703 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)" );
708 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(target)" );
715 _mesa_GetTexEnviv( GLenum target
, GLenum pname
, GLint
*params
)
718 const struct gl_texture_unit
*texUnit
;
719 GET_CURRENT_CONTEXT(ctx
);
720 ASSERT_OUTSIDE_BEGIN_END(ctx
);
722 maxUnit
= (target
== GL_POINT_SPRITE_NV
&& pname
== GL_COORD_REPLACE_NV
)
723 ? ctx
->Const
.MaxTextureCoordUnits
: ctx
->Const
.MaxCombinedTextureImageUnits
;
724 if (ctx
->Texture
.CurrentUnit
>= maxUnit
) {
725 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glGetTexEnviv(current unit)");
729 texUnit
= _mesa_get_current_tex_unit(ctx
);
731 if (target
== GL_TEXTURE_ENV
) {
732 if (pname
== GL_TEXTURE_ENV_COLOR
) {
733 params
[0] = FLOAT_TO_INT( texUnit
->EnvColor
[0] );
734 params
[1] = FLOAT_TO_INT( texUnit
->EnvColor
[1] );
735 params
[2] = FLOAT_TO_INT( texUnit
->EnvColor
[2] );
736 params
[3] = FLOAT_TO_INT( texUnit
->EnvColor
[3] );
739 GLint val
= get_texenvi(ctx
, texUnit
, pname
);
745 else if (target
== GL_TEXTURE_FILTER_CONTROL_EXT
) {
746 if (pname
== GL_TEXTURE_LOD_BIAS_EXT
) {
747 *params
= (GLint
) texUnit
->LodBias
;
750 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)" );
754 else if (target
== GL_POINT_SPRITE_NV
) {
755 /* GL_ARB_point_sprite / GL_NV_point_sprite */
756 if (!ctx
->Extensions
.NV_point_sprite
757 && !ctx
->Extensions
.ARB_point_sprite
) {
758 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(target)" );
761 if (pname
== GL_COORD_REPLACE_NV
) {
762 *params
= (GLint
) ctx
->Point
.CoordReplace
[ctx
->Texture
.CurrentUnit
];
765 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)" );
770 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(target)" );
777 * Why does ATI_envmap_bumpmap require new entrypoints? Should just
778 * reuse TexEnv ones...
781 _mesa_TexBumpParameterivATI( GLenum pname
, const GLint
*param
)
784 GET_CURRENT_CONTEXT(ctx
);
785 ASSERT_OUTSIDE_BEGIN_END(ctx
);
787 if (!ctx
->Extensions
.ATI_envmap_bumpmap
) {
788 /* This isn't an "official" error case, but let's tell the user
789 * that something's wrong.
791 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glTexBumpParameterivATI");
795 if (pname
== GL_BUMP_ROT_MATRIX_ATI
) {
796 /* hope that conversion is correct here */
797 p
[0] = INT_TO_FLOAT( param
[0] );
798 p
[1] = INT_TO_FLOAT( param
[1] );
799 p
[2] = INT_TO_FLOAT( param
[2] );
800 p
[3] = INT_TO_FLOAT( param
[3] );
803 p
[0] = (GLfloat
) param
[0];
804 p
[1] = p
[2] = p
[3] = 0.0F
; /* init to zero, just to be safe */
806 _mesa_TexBumpParameterfvATI( pname
, p
);
811 _mesa_TexBumpParameterfvATI( GLenum pname
, const GLfloat
*param
)
813 struct gl_texture_unit
*texUnit
;
814 GET_CURRENT_CONTEXT(ctx
);
815 ASSERT_OUTSIDE_BEGIN_END(ctx
);
817 if (!ctx
->Extensions
.ATI_envmap_bumpmap
) {
818 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glTexBumpParameterfvATI");
822 texUnit
= _mesa_get_current_tex_unit(ctx
);
824 if (pname
== GL_BUMP_ROT_MATRIX_ATI
) {
825 if (TEST_EQ_4V(param
, texUnit
->RotMatrix
))
827 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
828 COPY_4FV(texUnit
->RotMatrix
, param
);
831 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexBumpParameter(pname)" );
834 /* Drivers might want to know about this, instead of dedicated function
835 just shove it into TexEnv where it really belongs anyway */
836 if (ctx
->Driver
.TexEnv
) {
837 (*ctx
->Driver
.TexEnv
)( ctx
, 0, pname
, param
);
843 _mesa_GetTexBumpParameterivATI( GLenum pname
, GLint
*param
)
845 const struct gl_texture_unit
*texUnit
;
847 GET_CURRENT_CONTEXT(ctx
);
848 ASSERT_OUTSIDE_BEGIN_END(ctx
);
850 if (!ctx
->Extensions
.ATI_envmap_bumpmap
) {
851 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glGetTexBumpParameterivATI");
855 texUnit
= _mesa_get_current_tex_unit(ctx
);
857 if (pname
== GL_BUMP_ROT_MATRIX_SIZE_ATI
) {
858 /* spec leaves open to support larger matrices.
859 Don't think anyone would ever want to use it
860 (and apps almost certainly would not understand it and
861 thus fail to submit matrices correctly) so hardcode this. */
864 else if (pname
== GL_BUMP_ROT_MATRIX_ATI
) {
865 /* hope that conversion is correct here */
866 param
[0] = FLOAT_TO_INT(texUnit
->RotMatrix
[0]);
867 param
[1] = FLOAT_TO_INT(texUnit
->RotMatrix
[1]);
868 param
[2] = FLOAT_TO_INT(texUnit
->RotMatrix
[2]);
869 param
[3] = FLOAT_TO_INT(texUnit
->RotMatrix
[3]);
871 else if (pname
== GL_BUMP_NUM_TEX_UNITS_ATI
) {
873 for (i
= 0; i
< ctx
->Const
.MaxTextureImageUnits
; i
++) {
874 if (ctx
->Const
.SupportedBumpUnits
& (1 << i
)) {
880 else if (pname
== GL_BUMP_TEX_UNITS_ATI
) {
881 for (i
= 0; i
< ctx
->Const
.MaxTextureImageUnits
; i
++) {
882 if (ctx
->Const
.SupportedBumpUnits
& (1 << i
)) {
883 *param
++ = i
+ GL_TEXTURE0
;
888 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexBumpParameter(pname)" );
895 _mesa_GetTexBumpParameterfvATI( GLenum pname
, GLfloat
*param
)
897 const struct gl_texture_unit
*texUnit
;
899 GET_CURRENT_CONTEXT(ctx
);
900 ASSERT_OUTSIDE_BEGIN_END(ctx
);
902 if (!ctx
->Extensions
.ATI_envmap_bumpmap
) {
903 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glGetTexBumpParameterfvATI");
907 texUnit
= _mesa_get_current_tex_unit(ctx
);
909 if (pname
== GL_BUMP_ROT_MATRIX_SIZE_ATI
) {
910 /* spec leaves open to support larger matrices.
911 Don't think anyone would ever want to use it
912 (and apps might not understand it) so hardcode this. */
915 else if (pname
== GL_BUMP_ROT_MATRIX_ATI
) {
916 param
[0] = texUnit
->RotMatrix
[0];
917 param
[1] = texUnit
->RotMatrix
[1];
918 param
[2] = texUnit
->RotMatrix
[2];
919 param
[3] = texUnit
->RotMatrix
[3];
921 else if (pname
== GL_BUMP_NUM_TEX_UNITS_ATI
) {
923 for (i
= 0; i
< ctx
->Const
.MaxTextureImageUnits
; i
++) {
924 if (ctx
->Const
.SupportedBumpUnits
& (1 << i
)) {
928 *param
= (GLfloat
) count
;
930 else if (pname
== GL_BUMP_TEX_UNITS_ATI
) {
931 for (i
= 0; i
< ctx
->Const
.MaxTextureImageUnits
; i
++) {
932 if (ctx
->Const
.SupportedBumpUnits
& (1 << i
)) {
933 *param
++ = (GLfloat
) (i
+ GL_TEXTURE0
);
938 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexBumpParameter(pname)" );