1 /* $Id: texstate.c,v 1.25 2000/11/24 10:25:06 keithw Exp $ */
4 * Mesa 3-D graphics library
7 * Copyright (C) 1999-2000 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"
42 #include "math/m_xform.h"
43 #include "math/m_matrix.h"
44 #include "swrast/swrast.h"
50 /* Needed for an Amiga compiler */
51 #define ENUM_TO_FLOAT(X) ((GLfloat)(GLint)(X))
52 #define ENUM_TO_DOUBLE(X) ((GLdouble)(GLint)(X))
54 /* all other compilers */
55 #define ENUM_TO_FLOAT(X) ((GLfloat)(X))
56 #define ENUM_TO_DOUBLE(X) ((GLdouble)(X))
62 /**********************************************************************/
63 /* Texture Environment */
64 /**********************************************************************/
68 _mesa_TexEnvfv( GLenum target
, GLenum pname
, const GLfloat
*param
)
70 GET_CURRENT_CONTEXT(ctx
);
71 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
73 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
, "glTexEnv");
75 if (target
==GL_TEXTURE_ENV
) {
77 case GL_TEXTURE_ENV_MODE
:
79 GLenum mode
= (GLenum
) (GLint
) *param
;
88 !ctx
->Extensions
.EXT_texture_env_add
) {
89 gl_error(ctx
, GL_INVALID_ENUM
, "glTexEnv(param)");
92 if (mode
== GL_COMBINE_EXT
&&
93 !ctx
->Extensions
.EXT_texture_env_combine
) {
94 gl_error(ctx
, GL_INVALID_ENUM
, "glTexEnv(param)");
97 if (texUnit
->EnvMode
== mode
)
98 return; /* no change */
99 texUnit
->EnvMode
= mode
;
102 gl_error( ctx
, GL_INVALID_VALUE
, "glTexEnv(param)" );
107 case GL_TEXTURE_ENV_COLOR
:
108 texUnit
->EnvColor
[0] = CLAMP( param
[0], 0.0F
, 1.0F
);
109 texUnit
->EnvColor
[1] = CLAMP( param
[1], 0.0F
, 1.0F
);
110 texUnit
->EnvColor
[2] = CLAMP( param
[2], 0.0F
, 1.0F
);
111 texUnit
->EnvColor
[3] = CLAMP( param
[3], 0.0F
, 1.0F
);
113 case GL_COMBINE_RGB_EXT
:
114 if (ctx
->Extensions
.EXT_texture_env_combine
) {
115 GLenum mode
= (GLenum
) (GLint
) *param
;
120 case GL_ADD_SIGNED_EXT
:
121 case GL_INTERPOLATE_EXT
:
122 if (texUnit
->CombineModeRGB
== mode
)
123 return; /* no change */
124 texUnit
->CombineModeRGB
= mode
;
127 gl_error( ctx
, GL_INVALID_ENUM
, "glTexEnv(param)" );
132 gl_error(ctx
, GL_INVALID_ENUM
, "glTexEnv(pname)");
136 case GL_COMBINE_ALPHA_EXT
:
137 if (ctx
->Extensions
.EXT_texture_env_combine
) {
138 GLenum mode
= (GLenum
) (GLint
) *param
;
143 case GL_ADD_SIGNED_EXT
:
144 case GL_INTERPOLATE_EXT
:
145 if (texUnit
->CombineModeA
== mode
)
146 return; /* no change */
147 texUnit
->CombineModeA
= mode
;
150 gl_error( ctx
, GL_INVALID_ENUM
, "glTexEnv(param)" );
155 gl_error(ctx
, GL_INVALID_ENUM
, "glTexEnv(pname)");
159 case GL_SOURCE0_RGB_EXT
:
160 case GL_SOURCE1_RGB_EXT
:
161 case GL_SOURCE2_RGB_EXT
:
162 if (ctx
->Extensions
.EXT_texture_env_combine
) {
163 GLenum source
= (GLenum
) (GLint
) *param
;
164 GLuint s
= pname
- GL_SOURCE0_RGB_EXT
;
167 case GL_CONSTANT_EXT
:
168 case GL_PRIMARY_COLOR_EXT
:
169 case GL_PREVIOUS_EXT
:
170 if (texUnit
->CombineSourceRGB
[s
] == source
)
171 return; /* no change */
172 texUnit
->CombineSourceRGB
[s
] = source
;
175 gl_error( ctx
, GL_INVALID_ENUM
, "glTexEnv(param)" );
180 gl_error(ctx
, GL_INVALID_ENUM
, "glTexEnv(pname)");
184 case GL_SOURCE0_ALPHA_EXT
:
185 case GL_SOURCE1_ALPHA_EXT
:
186 case GL_SOURCE2_ALPHA_EXT
:
187 if (ctx
->Extensions
.EXT_texture_env_combine
) {
188 GLenum source
= (GLenum
) (GLint
) *param
;
189 GLuint s
= pname
- GL_SOURCE0_ALPHA_EXT
;
192 case GL_CONSTANT_EXT
:
193 case GL_PRIMARY_COLOR_EXT
:
194 case GL_PREVIOUS_EXT
:
195 if (texUnit
->CombineSourceA
[s
] == source
) return;
196 texUnit
->CombineSourceA
[s
] = source
;
199 gl_error( ctx
, GL_INVALID_ENUM
, "glTexEnv(param)" );
204 gl_error(ctx
, GL_INVALID_ENUM
, "glTexEnv(pname)");
208 case GL_OPERAND0_RGB_EXT
:
209 case GL_OPERAND1_RGB_EXT
:
210 if (ctx
->Extensions
.EXT_texture_env_combine
) {
211 GLenum operand
= (GLenum
) (GLint
) *param
;
212 GLuint s
= pname
- GL_OPERAND0_RGB_EXT
;
215 case GL_ONE_MINUS_SRC_COLOR
:
217 case GL_ONE_MINUS_SRC_ALPHA
:
218 texUnit
->CombineOperandRGB
[s
] = operand
;
221 gl_error( ctx
, GL_INVALID_ENUM
, "glTexEnv(param)" );
226 gl_error(ctx
, GL_INVALID_ENUM
, "glTexEnv(pname)");
230 case GL_OPERAND0_ALPHA_EXT
:
231 case GL_OPERAND1_ALPHA_EXT
:
232 if (ctx
->Extensions
.EXT_texture_env_combine
) {
233 GLenum operand
= (GLenum
) (GLint
) *param
;
236 case GL_ONE_MINUS_SRC_ALPHA
:
237 texUnit
->CombineOperandA
[pname
-GL_OPERAND0_ALPHA_EXT
]
241 gl_error( ctx
, GL_INVALID_ENUM
, "glTexEnv(param)" );
246 gl_error(ctx
, GL_INVALID_ENUM
, "glTexEnv(pname)");
250 case GL_OPERAND2_RGB_EXT
:
251 if (ctx
->Extensions
.EXT_texture_env_combine
) {
252 if ((GLenum
) (GLint
) *param
== GL_SRC_ALPHA
) {
253 texUnit
->CombineOperandRGB
[2] = (GLenum
) (GLint
) *param
;
256 gl_error( ctx
, GL_INVALID_ENUM
, "glTexEnv(param)" );
261 gl_error(ctx
, GL_INVALID_ENUM
, "glTexEnv(pname)");
265 case GL_OPERAND2_ALPHA_EXT
:
266 if (ctx
->Extensions
.EXT_texture_env_combine
) {
267 if ((GLenum
) (GLint
) *param
== GL_SRC_ALPHA
) {
268 texUnit
->CombineOperandA
[2] = (GLenum
) (GLint
) *param
;
271 gl_error( ctx
, GL_INVALID_ENUM
, "glTexEnv(param)" );
276 gl_error(ctx
, GL_INVALID_ENUM
, "glTexEnv(pname)");
280 case GL_RGB_SCALE_EXT
:
281 if (ctx
->Extensions
.EXT_texture_env_combine
) {
283 texUnit
->CombineScaleShiftRGB
= 0;
285 else if (*param
== 2.0) {
286 texUnit
->CombineScaleShiftRGB
= 1;
288 else if (*param
== 4.0) {
289 texUnit
->CombineScaleShiftRGB
= 2;
292 gl_error( ctx
, GL_INVALID_VALUE
, "glTexEnv(param)" );
297 gl_error(ctx
, GL_INVALID_ENUM
, "glTexEnv(pname)");
302 if (ctx
->Extensions
.EXT_texture_env_combine
) {
304 texUnit
->CombineScaleShiftA
= 0;
306 else if (*param
== 2.0) {
307 texUnit
->CombineScaleShiftA
= 1;
309 else if (*param
== 4.0) {
310 texUnit
->CombineScaleShiftA
= 2;
313 gl_error( ctx
, GL_INVALID_VALUE
, "glTexEnv(param)" );
318 gl_error(ctx
, GL_INVALID_ENUM
, "glTexEnv(pname)");
323 gl_error( ctx
, GL_INVALID_ENUM
, "glTexEnv(pname)" );
327 else if (target
==GL_TEXTURE_FILTER_CONTROL_EXT
) {
328 if (!ctx
->Extensions
.EXT_texture_lod_bias
) {
329 gl_error( ctx
, GL_INVALID_ENUM
, "glTexEnv(param)" );
332 if (pname
== GL_TEXTURE_LOD_BIAS_EXT
) {
333 texUnit
->LodBias
= param
[0];
336 gl_error( ctx
, GL_INVALID_ENUM
, "glTexEnv(pname)" );
341 gl_error( ctx
, GL_INVALID_ENUM
, "glTexEnv(target)" );
345 if (MESA_VERBOSE
&(VERBOSE_API
|VERBOSE_TEXTURE
))
346 fprintf(stderr
, "glTexEnv %s %s %.1f(%s) ...\n",
347 gl_lookup_enum_by_nr(target
),
348 gl_lookup_enum_by_nr(pname
),
350 gl_lookup_enum_by_nr((GLenum
) (GLint
) *param
));
352 /* Tell device driver about the new texture environment */
353 if (ctx
->Driver
.TexEnv
) {
354 (*ctx
->Driver
.TexEnv
)( ctx
, target
, pname
, param
);
357 ctx
->NewState
|= _NEW_TEXTURE
;
362 _mesa_TexEnvf( GLenum target
, GLenum pname
, GLfloat param
)
364 _mesa_TexEnvfv( target
, pname
, ¶m
);
370 _mesa_TexEnvi( GLenum target
, GLenum pname
, GLint param
)
373 p
[0] = (GLfloat
) param
;
374 p
[1] = p
[2] = p
[3] = 0.0;
375 _mesa_TexEnvfv( target
, pname
, p
);
380 _mesa_TexEnviv( GLenum target
, GLenum pname
, const GLint
*param
)
383 p
[0] = INT_TO_FLOAT( param
[0] );
384 p
[1] = INT_TO_FLOAT( param
[1] );
385 p
[2] = INT_TO_FLOAT( param
[2] );
386 p
[3] = INT_TO_FLOAT( param
[3] );
387 _mesa_TexEnvfv( target
, pname
, p
);
392 _mesa_GetTexEnvfv( GLenum target
, GLenum pname
, GLfloat
*params
)
394 GET_CURRENT_CONTEXT(ctx
);
395 const struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
397 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
, "glGetTexEnvfv");
399 if (target
!=GL_TEXTURE_ENV
) {
400 gl_error( ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(target)" );
405 case GL_TEXTURE_ENV_MODE
:
406 *params
= ENUM_TO_FLOAT(texUnit
->EnvMode
);
408 case GL_TEXTURE_ENV_COLOR
:
409 COPY_4FV( params
, texUnit
->EnvColor
);
411 case GL_RGB_SCALE_EXT
:
412 if (ctx
->Extensions
.EXT_texture_env_combine
) {
413 if (texUnit
->CombineScaleShiftRGB
== 0)
415 else if (texUnit
->CombineScaleShiftRGB
== 1)
421 gl_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
426 if (ctx
->Extensions
.EXT_texture_env_combine
) {
427 if (texUnit
->CombineScaleShiftA
== 0)
429 else if (texUnit
->CombineScaleShiftA
== 1)
435 gl_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
440 gl_error( ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)" );
446 _mesa_GetTexEnviv( GLenum target
, GLenum pname
, GLint
*params
)
448 GET_CURRENT_CONTEXT(ctx
);
449 const struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
451 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
, "glGetTexEnviv");
453 if (target
!= GL_TEXTURE_ENV
) {
454 gl_error( ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(target)" );
459 case GL_TEXTURE_ENV_MODE
:
460 *params
= (GLint
) texUnit
->EnvMode
;
462 case GL_TEXTURE_ENV_COLOR
:
463 params
[0] = FLOAT_TO_INT( texUnit
->EnvColor
[0] );
464 params
[1] = FLOAT_TO_INT( texUnit
->EnvColor
[1] );
465 params
[2] = FLOAT_TO_INT( texUnit
->EnvColor
[2] );
466 params
[3] = FLOAT_TO_INT( texUnit
->EnvColor
[3] );
468 case GL_COMBINE_RGB_EXT
:
469 if (ctx
->Extensions
.EXT_texture_env_combine
) {
470 *params
= (GLint
) texUnit
->CombineModeRGB
;
473 gl_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
476 case GL_COMBINE_ALPHA_EXT
:
477 if (ctx
->Extensions
.EXT_texture_env_combine
) {
478 *params
= (GLint
) texUnit
->CombineModeA
;
481 gl_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
484 case GL_SOURCE0_RGB_EXT
:
485 if (ctx
->Extensions
.EXT_texture_env_combine
) {
486 *params
= (GLint
) texUnit
->CombineSourceRGB
[0];
489 gl_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
492 case GL_SOURCE1_RGB_EXT
:
493 if (ctx
->Extensions
.EXT_texture_env_combine
) {
494 *params
= (GLint
) texUnit
->CombineSourceRGB
[1];
497 gl_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
500 case GL_SOURCE2_RGB_EXT
:
501 if (ctx
->Extensions
.EXT_texture_env_combine
) {
502 *params
= (GLint
) texUnit
->CombineSourceRGB
[2];
505 gl_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
508 case GL_SOURCE0_ALPHA_EXT
:
509 if (ctx
->Extensions
.EXT_texture_env_combine
) {
510 *params
= (GLint
) texUnit
->CombineSourceA
[0];
513 gl_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
516 case GL_SOURCE1_ALPHA_EXT
:
517 if (ctx
->Extensions
.EXT_texture_env_combine
) {
518 *params
= (GLint
) texUnit
->CombineSourceA
[1];
521 gl_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
524 case GL_SOURCE2_ALPHA_EXT
:
525 if (ctx
->Extensions
.EXT_texture_env_combine
) {
526 *params
= (GLint
) texUnit
->CombineSourceA
[2];
529 gl_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
532 case GL_OPERAND0_RGB_EXT
:
533 if (ctx
->Extensions
.EXT_texture_env_combine
) {
534 *params
= (GLint
) texUnit
->CombineOperandRGB
[0];
537 gl_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
540 case GL_OPERAND1_RGB_EXT
:
541 if (ctx
->Extensions
.EXT_texture_env_combine
) {
542 *params
= (GLint
) texUnit
->CombineOperandRGB
[1];
545 gl_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
548 case GL_OPERAND2_RGB_EXT
:
549 if (ctx
->Extensions
.EXT_texture_env_combine
) {
550 *params
= (GLint
) texUnit
->CombineOperandRGB
[2];
553 gl_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
556 case GL_OPERAND0_ALPHA_EXT
:
557 if (ctx
->Extensions
.EXT_texture_env_combine
) {
558 *params
= (GLint
) texUnit
->CombineOperandA
[0];
561 gl_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
564 case GL_OPERAND1_ALPHA_EXT
:
565 if (ctx
->Extensions
.EXT_texture_env_combine
) {
566 *params
= (GLint
) texUnit
->CombineOperandA
[1];
569 gl_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
572 case GL_OPERAND2_ALPHA_EXT
:
573 if (ctx
->Extensions
.EXT_texture_env_combine
) {
574 *params
= (GLint
) texUnit
->CombineOperandA
[2];
577 gl_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
581 gl_error( ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)" );
588 /**********************************************************************/
589 /* Texture Parameters */
590 /**********************************************************************/
594 _mesa_TexParameterf( GLenum target
, GLenum pname
, GLfloat param
)
596 _mesa_TexParameterfv(target
, pname
, ¶m
);
601 _mesa_TexParameterfv( GLenum target
, GLenum pname
, const GLfloat
*params
)
603 GET_CURRENT_CONTEXT(ctx
);
604 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
605 GLenum eparam
= (GLenum
) (GLint
) params
[0];
606 struct gl_texture_object
*texObj
;
608 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
, "glTexParameterfv");
610 if (MESA_VERBOSE
&(VERBOSE_API
|VERBOSE_TEXTURE
))
611 fprintf(stderr
, "texPARAM %s %s %d...\n",
612 gl_lookup_enum_by_nr(target
),
613 gl_lookup_enum_by_nr(pname
),
619 texObj
= texUnit
->Current1D
;
622 texObj
= texUnit
->Current2D
;
624 case GL_TEXTURE_3D_EXT
:
625 texObj
= texUnit
->Current3D
;
627 case GL_TEXTURE_CUBE_MAP_ARB
:
628 if (ctx
->Extensions
.ARB_texture_cube_map
) {
629 texObj
= texUnit
->CurrentCubeMap
;
634 gl_error( ctx
, GL_INVALID_ENUM
, "glTexParameter(target)" );
639 case GL_TEXTURE_MIN_FILTER
:
640 /* A small optimization */
641 if (texObj
->MinFilter
== eparam
)
644 if (eparam
==GL_NEAREST
|| eparam
==GL_LINEAR
645 || eparam
==GL_NEAREST_MIPMAP_NEAREST
646 || eparam
==GL_LINEAR_MIPMAP_NEAREST
647 || eparam
==GL_NEAREST_MIPMAP_LINEAR
648 || eparam
==GL_LINEAR_MIPMAP_LINEAR
) {
649 texObj
->MinFilter
= eparam
;
652 gl_error( ctx
, GL_INVALID_VALUE
, "glTexParameter(param)" );
656 case GL_TEXTURE_MAG_FILTER
:
657 /* A small optimization */
658 if (texObj
->MagFilter
== eparam
)
661 if (eparam
==GL_NEAREST
|| eparam
==GL_LINEAR
) {
662 texObj
->MagFilter
= eparam
;
665 gl_error( ctx
, GL_INVALID_VALUE
, "glTexParameter(param)" );
669 case GL_TEXTURE_WRAP_S
:
670 if (texObj
->WrapS
== eparam
)
673 if (eparam
==GL_CLAMP
|| eparam
==GL_REPEAT
|| eparam
==GL_CLAMP_TO_EDGE
) {
674 texObj
->WrapS
= eparam
;
677 gl_error( ctx
, GL_INVALID_VALUE
, "glTexParameter(param)" );
681 case GL_TEXTURE_WRAP_T
:
682 if (texObj
->WrapT
== eparam
)
685 if (eparam
==GL_CLAMP
|| eparam
==GL_REPEAT
|| eparam
==GL_CLAMP_TO_EDGE
) {
686 texObj
->WrapT
= eparam
;
689 gl_error( ctx
, GL_INVALID_VALUE
, "glTexParameter(param)" );
693 case GL_TEXTURE_WRAP_R_EXT
:
694 if (texObj
->WrapR
== eparam
)
697 if (eparam
==GL_CLAMP
|| eparam
==GL_REPEAT
|| eparam
==GL_CLAMP_TO_EDGE
) {
698 texObj
->WrapR
= eparam
;
701 gl_error( ctx
, GL_INVALID_VALUE
, "glTexParameter(param)" );
704 case GL_TEXTURE_BORDER_COLOR
:
705 texObj
->BorderColor
[0] = (GLchan
) CLAMP((GLint
)(params
[0]*CHAN_MAXF
), 0, CHAN_MAX
);
706 texObj
->BorderColor
[1] = (GLchan
) CLAMP((GLint
)(params
[1]*CHAN_MAXF
), 0, CHAN_MAX
);
707 texObj
->BorderColor
[2] = (GLchan
) CLAMP((GLint
)(params
[2]*CHAN_MAXF
), 0, CHAN_MAX
);
708 texObj
->BorderColor
[3] = (GLchan
) CLAMP((GLint
)(params
[3]*CHAN_MAXF
), 0, CHAN_MAX
);
710 case GL_TEXTURE_MIN_LOD
:
711 texObj
->MinLod
= params
[0];
713 case GL_TEXTURE_MAX_LOD
:
714 texObj
->MaxLod
= params
[0];
716 case GL_TEXTURE_BASE_LEVEL
:
717 if (params
[0] < 0.0) {
718 gl_error(ctx
, GL_INVALID_VALUE
, "glTexParameter(param)" );
721 texObj
->BaseLevel
= (GLint
) params
[0];
723 case GL_TEXTURE_MAX_LEVEL
:
724 if (params
[0] < 0.0) {
725 gl_error(ctx
, GL_INVALID_VALUE
, "glTexParameter(param)" );
728 texObj
->MaxLevel
= (GLint
) params
[0];
730 case GL_TEXTURE_PRIORITY
:
731 /* (keithh@netcomuk.co.uk) */
732 texObj
->Priority
= CLAMP( params
[0], 0.0F
, 1.0F
);
735 gl_error( ctx
, GL_INVALID_ENUM
, "glTexParameter(pname)" );
739 ctx
->NewState
|= _NEW_TEXTURE
;
740 texObj
->Complete
= GL_FALSE
;
742 if (ctx
->Driver
.TexParameter
) {
743 (*ctx
->Driver
.TexParameter
)( ctx
, target
, texObj
, pname
, params
);
749 _mesa_TexParameteri( GLenum target
, GLenum pname
, const GLint param
)
752 fparam
[0] = (GLfloat
) param
;
753 fparam
[1] = fparam
[2] = fparam
[3] = 0.0;
754 _mesa_TexParameterfv(target
, pname
, fparam
);
758 _mesa_TexParameteriv( GLenum target
, GLenum pname
, const GLint
*params
)
761 fparam
[0] = (GLfloat
) params
[0];
762 fparam
[1] = fparam
[2] = fparam
[3] = 0.0;
763 _mesa_TexParameterfv(target
, pname
, fparam
);
768 _mesa_GetTexLevelParameterfv( GLenum target
, GLint level
,
769 GLenum pname
, GLfloat
*params
)
772 _mesa_GetTexLevelParameteriv( target
, level
, pname
, &iparam
);
773 *params
= (GLfloat
) iparam
;
778 tex_image_dimensions(GLcontext
*ctx
, GLenum target
)
782 case GL_PROXY_TEXTURE_1D
:
785 case GL_PROXY_TEXTURE_2D
:
788 case GL_PROXY_TEXTURE_3D
:
790 case GL_TEXTURE_CUBE_MAP_ARB
:
791 case GL_PROXY_TEXTURE_CUBE_MAP_ARB
:
792 return ctx
->Extensions
.ARB_texture_cube_map
? 2 : 0;
794 gl_problem(ctx
, "bad target in _mesa_tex_target_dimensions()");
801 _mesa_GetTexLevelParameteriv( GLenum target
, GLint level
,
802 GLenum pname
, GLint
*params
)
804 GET_CURRENT_CONTEXT(ctx
);
805 const struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
806 const struct gl_texture_image
*img
= NULL
;
810 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
, "glGetTexLevelParameter");
812 if (level
< 0 || level
>= ctx
->Const
.MaxTextureLevels
) {
813 gl_error( ctx
, GL_INVALID_VALUE
, "glGetTexLevelParameter[if]v" );
817 dimensions
= tex_image_dimensions(ctx
, target
); /* 1, 2 or 3 */
818 if (dimensions
== 0) {
819 gl_error(ctx
, GL_INVALID_ENUM
, "glGetTexLevelParameter[if]v(target)");
823 img
= _mesa_select_tex_image(ctx
, texUnit
, target
, level
);
825 if (pname
== GL_TEXTURE_COMPONENTS
)
832 isProxy
= (target
== GL_PROXY_TEXTURE_1D
) ||
833 (target
== GL_PROXY_TEXTURE_2D
) ||
834 (target
== GL_PROXY_TEXTURE_3D
) ||
835 (target
== GL_PROXY_TEXTURE_CUBE_MAP_ARB
);
838 case GL_TEXTURE_WIDTH
:
839 *params
= img
->Width
;
841 case GL_TEXTURE_HEIGHT
:
842 if (dimensions
> 1) {
843 *params
= img
->Height
;
846 gl_error( ctx
, GL_INVALID_ENUM
,
847 "glGetTexLevelParameter[if]v(pname=GL_TEXTURE_HEIGHT)" );
850 case GL_TEXTURE_DEPTH
:
851 if (dimensions
> 2) {
852 *params
= img
->Depth
;
855 gl_error( ctx
, GL_INVALID_ENUM
,
856 "glGetTexLevelParameter[if]v(pname=GL_TEXTURE_DEPTH)" );
859 case GL_TEXTURE_COMPONENTS
:
860 *params
= img
->IntFormat
;
862 case GL_TEXTURE_BORDER
:
863 *params
= img
->Border
;
865 case GL_TEXTURE_RED_SIZE
:
866 *params
= img
->RedBits
;
868 case GL_TEXTURE_GREEN_SIZE
:
869 *params
= img
->GreenBits
;
871 case GL_TEXTURE_BLUE_SIZE
:
872 *params
= img
->BlueBits
;
874 case GL_TEXTURE_ALPHA_SIZE
:
875 *params
= img
->AlphaBits
;
877 case GL_TEXTURE_INTENSITY_SIZE
:
878 *params
= img
->IntensityBits
;
880 case GL_TEXTURE_LUMINANCE_SIZE
:
881 *params
= img
->LuminanceBits
;
883 case GL_TEXTURE_INDEX_SIZE_EXT
:
884 *params
= img
->IndexBits
;
887 /* GL_ARB_texture_compression */
888 case GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB
:
889 if (ctx
->Extensions
.ARB_texture_compression
) {
890 if (img
->IsCompressed
&& !isProxy
)
891 *params
= img
->CompressedSize
;
893 gl_error(ctx
, GL_INVALID_OPERATION
,
894 "glGetTexLevelParameter[if]v(pname)");
897 gl_error(ctx
, GL_INVALID_ENUM
, "glGetTexLevelParameter[if]v(pname)");
900 case GL_TEXTURE_COMPRESSED_ARB
:
901 if (ctx
->Extensions
.ARB_texture_compression
) {
902 *params
= (GLint
) img
->IsCompressed
;
905 gl_error(ctx
, GL_INVALID_ENUM
, "glGetTexLevelParameter[if]v(pname)");
910 gl_error(ctx
, GL_INVALID_ENUM
, "glGetTexLevelParameter[if]v(pname)");
917 _mesa_GetTexParameterfv( GLenum target
, GLenum pname
, GLfloat
*params
)
919 GET_CURRENT_CONTEXT(ctx
);
920 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
921 struct gl_texture_object
*obj
;
923 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
, "glGetTexParameterfv");
925 obj
= _mesa_select_tex_object(ctx
, texUnit
, target
);
927 gl_error(ctx
, GL_INVALID_ENUM
, "glGetTexParameterfv(target)");
932 case GL_TEXTURE_MAG_FILTER
:
933 *params
= ENUM_TO_FLOAT(obj
->MagFilter
);
935 case GL_TEXTURE_MIN_FILTER
:
936 *params
= ENUM_TO_FLOAT(obj
->MinFilter
);
938 case GL_TEXTURE_WRAP_S
:
939 *params
= ENUM_TO_FLOAT(obj
->WrapS
);
941 case GL_TEXTURE_WRAP_T
:
942 *params
= ENUM_TO_FLOAT(obj
->WrapT
);
944 case GL_TEXTURE_WRAP_R_EXT
:
945 *params
= ENUM_TO_FLOAT(obj
->WrapR
);
947 case GL_TEXTURE_BORDER_COLOR
:
948 params
[0] = obj
->BorderColor
[0] / CHAN_MAXF
;
949 params
[1] = obj
->BorderColor
[1] / CHAN_MAXF
;
950 params
[2] = obj
->BorderColor
[2] / CHAN_MAXF
;
951 params
[3] = obj
->BorderColor
[3] / CHAN_MAXF
;
953 case GL_TEXTURE_RESIDENT
:
956 if (ctx
->Driver
.IsTextureResident
)
957 resident
= ctx
->Driver
.IsTextureResident(ctx
, obj
);
960 *params
= ENUM_TO_FLOAT(resident
);
963 case GL_TEXTURE_PRIORITY
:
964 *params
= obj
->Priority
;
966 case GL_TEXTURE_MIN_LOD
:
967 *params
= obj
->MinLod
;
969 case GL_TEXTURE_MAX_LOD
:
970 *params
= obj
->MaxLod
;
972 case GL_TEXTURE_BASE_LEVEL
:
973 *params
= (GLfloat
) obj
->BaseLevel
;
975 case GL_TEXTURE_MAX_LEVEL
:
976 *params
= (GLfloat
) obj
->MaxLevel
;
979 gl_error( ctx
, GL_INVALID_ENUM
, "glGetTexParameterfv(pname)" );
985 _mesa_GetTexParameteriv( GLenum target
, GLenum pname
, GLint
*params
)
987 GET_CURRENT_CONTEXT(ctx
);
988 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
989 struct gl_texture_object
*obj
;
991 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
, "glGetTexParameteriv");
993 obj
= _mesa_select_tex_object(ctx
, texUnit
, target
);
995 gl_error(ctx
, GL_INVALID_ENUM
, "glGetTexParameteriv(target)");
1000 case GL_TEXTURE_MAG_FILTER
:
1001 *params
= (GLint
) obj
->MagFilter
;
1003 case GL_TEXTURE_MIN_FILTER
:
1004 *params
= (GLint
) obj
->MinFilter
;
1006 case GL_TEXTURE_WRAP_S
:
1007 *params
= (GLint
) obj
->WrapS
;
1009 case GL_TEXTURE_WRAP_T
:
1010 *params
= (GLint
) obj
->WrapT
;
1012 case GL_TEXTURE_WRAP_R_EXT
:
1013 *params
= (GLint
) obj
->WrapR
;
1015 case GL_TEXTURE_BORDER_COLOR
:
1018 color
[0] = obj
->BorderColor
[0] / CHAN_MAXF
;
1019 color
[1] = obj
->BorderColor
[1] / CHAN_MAXF
;
1020 color
[2] = obj
->BorderColor
[2] / CHAN_MAXF
;
1021 color
[3] = obj
->BorderColor
[3] / CHAN_MAXF
;
1022 params
[0] = FLOAT_TO_INT( color
[0] );
1023 params
[1] = FLOAT_TO_INT( color
[1] );
1024 params
[2] = FLOAT_TO_INT( color
[2] );
1025 params
[3] = FLOAT_TO_INT( color
[3] );
1028 case GL_TEXTURE_RESIDENT
:
1031 if (ctx
->Driver
.IsTextureResident
)
1032 resident
= ctx
->Driver
.IsTextureResident(ctx
, obj
);
1035 *params
= (GLint
) resident
;
1038 case GL_TEXTURE_PRIORITY
:
1039 *params
= (GLint
) obj
->Priority
;
1041 case GL_TEXTURE_MIN_LOD
:
1042 *params
= (GLint
) obj
->MinLod
;
1044 case GL_TEXTURE_MAX_LOD
:
1045 *params
= (GLint
) obj
->MaxLod
;
1047 case GL_TEXTURE_BASE_LEVEL
:
1048 *params
= obj
->BaseLevel
;
1050 case GL_TEXTURE_MAX_LEVEL
:
1051 *params
= obj
->MaxLevel
;
1054 gl_error( ctx
, GL_INVALID_ENUM
, "glGetTexParameteriv(pname)" );
1061 /**********************************************************************/
1062 /* Texture Coord Generation */
1063 /**********************************************************************/
1067 _mesa_TexGenfv( GLenum coord
, GLenum pname
, const GLfloat
*params
)
1069 GET_CURRENT_CONTEXT(ctx
);
1070 GLuint tUnit
= ctx
->Texture
.CurrentTransformUnit
;
1071 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[tUnit
];
1072 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
, "glTexGenfv");
1074 if (MESA_VERBOSE
&(VERBOSE_API
|VERBOSE_TEXTURE
))
1075 fprintf(stderr
, "texGEN %s %s %x...\n",
1076 gl_lookup_enum_by_nr(coord
),
1077 gl_lookup_enum_by_nr(pname
),
1082 if (pname
==GL_TEXTURE_GEN_MODE
) {
1083 GLenum mode
= (GLenum
) (GLint
) *params
;
1085 case GL_OBJECT_LINEAR
:
1086 texUnit
->GenModeS
= mode
;
1087 texUnit
->_GenBitS
= TEXGEN_OBJ_LINEAR
;
1090 texUnit
->GenModeS
= mode
;
1091 texUnit
->_GenBitS
= TEXGEN_EYE_LINEAR
;
1093 case GL_REFLECTION_MAP_NV
:
1094 texUnit
->GenModeS
= mode
;
1095 texUnit
->_GenBitS
= TEXGEN_REFLECTION_MAP_NV
;
1097 case GL_NORMAL_MAP_NV
:
1098 texUnit
->GenModeS
= mode
;
1099 texUnit
->_GenBitS
= TEXGEN_NORMAL_MAP_NV
;
1102 texUnit
->GenModeS
= mode
;
1103 texUnit
->_GenBitS
= TEXGEN_SPHERE_MAP
;
1106 gl_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(param)" );
1110 else if (pname
==GL_OBJECT_PLANE
) {
1111 texUnit
->ObjectPlaneS
[0] = params
[0];
1112 texUnit
->ObjectPlaneS
[1] = params
[1];
1113 texUnit
->ObjectPlaneS
[2] = params
[2];
1114 texUnit
->ObjectPlaneS
[3] = params
[3];
1116 else if (pname
==GL_EYE_PLANE
) {
1117 /* Transform plane equation by the inverse modelview matrix */
1118 if (ctx
->ModelView
.flags
& MAT_DIRTY_INVERSE
) {
1119 _math_matrix_analyse( &ctx
->ModelView
);
1121 gl_transform_vector( texUnit
->EyePlaneS
, params
,
1122 ctx
->ModelView
.inv
);
1125 gl_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(pname)" );
1130 if (pname
==GL_TEXTURE_GEN_MODE
) {
1131 GLenum mode
= (GLenum
) (GLint
) *params
;
1133 case GL_OBJECT_LINEAR
:
1134 texUnit
->GenModeT
= GL_OBJECT_LINEAR
;
1135 texUnit
->_GenBitT
= TEXGEN_OBJ_LINEAR
;
1138 texUnit
->GenModeT
= GL_EYE_LINEAR
;
1139 texUnit
->_GenBitT
= TEXGEN_EYE_LINEAR
;
1141 case GL_REFLECTION_MAP_NV
:
1142 texUnit
->GenModeT
= GL_REFLECTION_MAP_NV
;
1143 texUnit
->_GenBitT
= TEXGEN_REFLECTION_MAP_NV
;
1145 case GL_NORMAL_MAP_NV
:
1146 texUnit
->GenModeT
= GL_NORMAL_MAP_NV
;
1147 texUnit
->_GenBitT
= TEXGEN_NORMAL_MAP_NV
;
1150 texUnit
->GenModeT
= GL_SPHERE_MAP
;
1151 texUnit
->_GenBitT
= TEXGEN_SPHERE_MAP
;
1154 gl_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(param)" );
1158 else if (pname
==GL_OBJECT_PLANE
) {
1159 texUnit
->ObjectPlaneT
[0] = params
[0];
1160 texUnit
->ObjectPlaneT
[1] = params
[1];
1161 texUnit
->ObjectPlaneT
[2] = params
[2];
1162 texUnit
->ObjectPlaneT
[3] = params
[3];
1164 else if (pname
==GL_EYE_PLANE
) {
1165 /* Transform plane equation by the inverse modelview matrix */
1166 if (ctx
->ModelView
.flags
& MAT_DIRTY_INVERSE
) {
1167 _math_matrix_analyse( &ctx
->ModelView
);
1169 gl_transform_vector( texUnit
->EyePlaneT
, params
,
1170 ctx
->ModelView
.inv
);
1173 gl_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(pname)" );
1178 if (pname
==GL_TEXTURE_GEN_MODE
) {
1179 GLenum mode
= (GLenum
) (GLint
) *params
;
1181 case GL_OBJECT_LINEAR
:
1182 texUnit
->GenModeR
= GL_OBJECT_LINEAR
;
1183 texUnit
->_GenBitR
= TEXGEN_OBJ_LINEAR
;
1185 case GL_REFLECTION_MAP_NV
:
1186 texUnit
->GenModeR
= GL_REFLECTION_MAP_NV
;
1187 texUnit
->_GenBitR
= TEXGEN_REFLECTION_MAP_NV
;
1189 case GL_NORMAL_MAP_NV
:
1190 texUnit
->GenModeR
= GL_NORMAL_MAP_NV
;
1191 texUnit
->_GenBitR
= TEXGEN_NORMAL_MAP_NV
;
1194 texUnit
->GenModeR
= GL_EYE_LINEAR
;
1195 texUnit
->_GenBitR
= TEXGEN_EYE_LINEAR
;
1198 gl_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(param)" );
1202 else if (pname
==GL_OBJECT_PLANE
) {
1203 texUnit
->ObjectPlaneR
[0] = params
[0];
1204 texUnit
->ObjectPlaneR
[1] = params
[1];
1205 texUnit
->ObjectPlaneR
[2] = params
[2];
1206 texUnit
->ObjectPlaneR
[3] = params
[3];
1208 else if (pname
==GL_EYE_PLANE
) {
1209 /* Transform plane equation by the inverse modelview matrix */
1210 if (ctx
->ModelView
.flags
& MAT_DIRTY_INVERSE
) {
1211 _math_matrix_analyse( &ctx
->ModelView
);
1213 gl_transform_vector( texUnit
->EyePlaneR
, params
,
1214 ctx
->ModelView
.inv
);
1217 gl_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(pname)" );
1222 if (pname
==GL_TEXTURE_GEN_MODE
) {
1223 GLenum mode
= (GLenum
) (GLint
) *params
;
1225 case GL_OBJECT_LINEAR
:
1226 texUnit
->GenModeQ
= GL_OBJECT_LINEAR
;
1227 texUnit
->_GenBitQ
= TEXGEN_OBJ_LINEAR
;
1230 texUnit
->GenModeQ
= GL_EYE_LINEAR
;
1231 texUnit
->_GenBitQ
= TEXGEN_EYE_LINEAR
;
1234 gl_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(param)" );
1238 else if (pname
==GL_OBJECT_PLANE
) {
1239 texUnit
->ObjectPlaneQ
[0] = params
[0];
1240 texUnit
->ObjectPlaneQ
[1] = params
[1];
1241 texUnit
->ObjectPlaneQ
[2] = params
[2];
1242 texUnit
->ObjectPlaneQ
[3] = params
[3];
1244 else if (pname
==GL_EYE_PLANE
) {
1245 /* Transform plane equation by the inverse modelview matrix */
1246 if (ctx
->ModelView
.flags
& MAT_DIRTY_INVERSE
) {
1247 _math_matrix_analyse( &ctx
->ModelView
);
1249 gl_transform_vector( texUnit
->EyePlaneQ
, params
,
1250 ctx
->ModelView
.inv
);
1253 gl_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(pname)" );
1258 gl_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(coord)" );
1262 if (ctx
->Driver
.TexGen
)
1263 ctx
->Driver
.TexGen( ctx
, coord
, pname
, params
);
1265 ctx
->NewState
|= _NEW_TEXTURE
;
1270 _mesa_TexGeniv(GLenum coord
, GLenum pname
, const GLint
*params
)
1277 _mesa_TexGenfv(coord
, pname
, p
);
1282 _mesa_TexGend(GLenum coord
, GLenum pname
, GLdouble param
)
1284 GLfloat p
= (GLfloat
) param
;
1285 _mesa_TexGenfv( coord
, pname
, &p
);
1290 _mesa_TexGendv(GLenum coord
, GLenum pname
, const GLdouble
*params
)
1297 _mesa_TexGenfv( coord
, pname
, p
);
1302 _mesa_TexGenf( GLenum coord
, GLenum pname
, GLfloat param
)
1304 _mesa_TexGenfv(coord
, pname
, ¶m
);
1309 _mesa_TexGeni( GLenum coord
, GLenum pname
, GLint param
)
1311 _mesa_TexGeniv( coord
, pname
, ¶m
);
1317 _mesa_GetTexGendv( GLenum coord
, GLenum pname
, GLdouble
*params
)
1319 GET_CURRENT_CONTEXT(ctx
);
1320 GLuint tUnit
= ctx
->Texture
.CurrentTransformUnit
;
1321 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[tUnit
];
1323 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
, "glGetTexGendv");
1327 if (pname
==GL_TEXTURE_GEN_MODE
) {
1328 params
[0] = ENUM_TO_DOUBLE(texUnit
->GenModeS
);
1330 else if (pname
==GL_OBJECT_PLANE
) {
1331 COPY_4V( params
, texUnit
->ObjectPlaneS
);
1333 else if (pname
==GL_EYE_PLANE
) {
1334 COPY_4V( params
, texUnit
->EyePlaneS
);
1337 gl_error( ctx
, GL_INVALID_ENUM
, "glGetTexGendv(pname)" );
1342 if (pname
==GL_TEXTURE_GEN_MODE
) {
1343 params
[0] = ENUM_TO_DOUBLE(texUnit
->GenModeT
);
1345 else if (pname
==GL_OBJECT_PLANE
) {
1346 COPY_4V( params
, texUnit
->ObjectPlaneT
);
1348 else if (pname
==GL_EYE_PLANE
) {
1349 COPY_4V( params
, texUnit
->EyePlaneT
);
1352 gl_error( ctx
, GL_INVALID_ENUM
, "glGetTexGendv(pname)" );
1357 if (pname
==GL_TEXTURE_GEN_MODE
) {
1358 params
[0] = ENUM_TO_DOUBLE(texUnit
->GenModeR
);
1360 else if (pname
==GL_OBJECT_PLANE
) {
1361 COPY_4V( params
, texUnit
->ObjectPlaneR
);
1363 else if (pname
==GL_EYE_PLANE
) {
1364 COPY_4V( params
, texUnit
->EyePlaneR
);
1367 gl_error( ctx
, GL_INVALID_ENUM
, "glGetTexGendv(pname)" );
1372 if (pname
==GL_TEXTURE_GEN_MODE
) {
1373 params
[0] = ENUM_TO_DOUBLE(texUnit
->GenModeQ
);
1375 else if (pname
==GL_OBJECT_PLANE
) {
1376 COPY_4V( params
, texUnit
->ObjectPlaneQ
);
1378 else if (pname
==GL_EYE_PLANE
) {
1379 COPY_4V( params
, texUnit
->EyePlaneQ
);
1382 gl_error( ctx
, GL_INVALID_ENUM
, "glGetTexGendv(pname)" );
1387 gl_error( ctx
, GL_INVALID_ENUM
, "glGetTexGendv(coord)" );
1395 _mesa_GetTexGenfv( GLenum coord
, GLenum pname
, GLfloat
*params
)
1397 GET_CURRENT_CONTEXT(ctx
);
1398 GLuint tUnit
= ctx
->Texture
.CurrentTransformUnit
;
1399 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[tUnit
];
1401 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
, "glGetTexGenfv");
1405 if (pname
==GL_TEXTURE_GEN_MODE
) {
1406 params
[0] = ENUM_TO_FLOAT(texUnit
->GenModeS
);
1408 else if (pname
==GL_OBJECT_PLANE
) {
1409 COPY_4V( params
, texUnit
->ObjectPlaneS
);
1411 else if (pname
==GL_EYE_PLANE
) {
1412 COPY_4V( params
, texUnit
->EyePlaneS
);
1415 gl_error( ctx
, GL_INVALID_ENUM
, "glGetTexGenfv(pname)" );
1420 if (pname
==GL_TEXTURE_GEN_MODE
) {
1421 params
[0] = ENUM_TO_FLOAT(texUnit
->GenModeT
);
1423 else if (pname
==GL_OBJECT_PLANE
) {
1424 COPY_4V( params
, texUnit
->ObjectPlaneT
);
1426 else if (pname
==GL_EYE_PLANE
) {
1427 COPY_4V( params
, texUnit
->EyePlaneT
);
1430 gl_error( ctx
, GL_INVALID_ENUM
, "glGetTexGenfv(pname)" );
1435 if (pname
==GL_TEXTURE_GEN_MODE
) {
1436 params
[0] = ENUM_TO_FLOAT(texUnit
->GenModeR
);
1438 else if (pname
==GL_OBJECT_PLANE
) {
1439 COPY_4V( params
, texUnit
->ObjectPlaneR
);
1441 else if (pname
==GL_EYE_PLANE
) {
1442 COPY_4V( params
, texUnit
->EyePlaneR
);
1445 gl_error( ctx
, GL_INVALID_ENUM
, "glGetTexGenfv(pname)" );
1450 if (pname
==GL_TEXTURE_GEN_MODE
) {
1451 params
[0] = ENUM_TO_FLOAT(texUnit
->GenModeQ
);
1453 else if (pname
==GL_OBJECT_PLANE
) {
1454 COPY_4V( params
, texUnit
->ObjectPlaneQ
);
1456 else if (pname
==GL_EYE_PLANE
) {
1457 COPY_4V( params
, texUnit
->EyePlaneQ
);
1460 gl_error( ctx
, GL_INVALID_ENUM
, "glGetTexGenfv(pname)" );
1465 gl_error( ctx
, GL_INVALID_ENUM
, "glGetTexGenfv(coord)" );
1473 _mesa_GetTexGeniv( GLenum coord
, GLenum pname
, GLint
*params
)
1475 GET_CURRENT_CONTEXT(ctx
);
1476 GLuint tUnit
= ctx
->Texture
.CurrentTransformUnit
;
1477 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[tUnit
];
1479 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
, "glGetTexGeniv");
1483 if (pname
==GL_TEXTURE_GEN_MODE
) {
1484 params
[0] = texUnit
->GenModeS
;
1486 else if (pname
==GL_OBJECT_PLANE
) {
1487 params
[0] = (GLint
) texUnit
->ObjectPlaneS
[0];
1488 params
[1] = (GLint
) texUnit
->ObjectPlaneS
[1];
1489 params
[2] = (GLint
) texUnit
->ObjectPlaneS
[2];
1490 params
[3] = (GLint
) texUnit
->ObjectPlaneS
[3];
1492 else if (pname
==GL_EYE_PLANE
) {
1493 params
[0] = (GLint
) texUnit
->EyePlaneS
[0];
1494 params
[1] = (GLint
) texUnit
->EyePlaneS
[1];
1495 params
[2] = (GLint
) texUnit
->EyePlaneS
[2];
1496 params
[3] = (GLint
) texUnit
->EyePlaneS
[3];
1499 gl_error( ctx
, GL_INVALID_ENUM
, "glGetTexGeniv(pname)" );
1504 if (pname
==GL_TEXTURE_GEN_MODE
) {
1505 params
[0] = texUnit
->GenModeT
;
1507 else if (pname
==GL_OBJECT_PLANE
) {
1508 params
[0] = (GLint
) texUnit
->ObjectPlaneT
[0];
1509 params
[1] = (GLint
) texUnit
->ObjectPlaneT
[1];
1510 params
[2] = (GLint
) texUnit
->ObjectPlaneT
[2];
1511 params
[3] = (GLint
) texUnit
->ObjectPlaneT
[3];
1513 else if (pname
==GL_EYE_PLANE
) {
1514 params
[0] = (GLint
) texUnit
->EyePlaneT
[0];
1515 params
[1] = (GLint
) texUnit
->EyePlaneT
[1];
1516 params
[2] = (GLint
) texUnit
->EyePlaneT
[2];
1517 params
[3] = (GLint
) texUnit
->EyePlaneT
[3];
1520 gl_error( ctx
, GL_INVALID_ENUM
, "glGetTexGeniv(pname)" );
1525 if (pname
==GL_TEXTURE_GEN_MODE
) {
1526 params
[0] = texUnit
->GenModeR
;
1528 else if (pname
==GL_OBJECT_PLANE
) {
1529 params
[0] = (GLint
) texUnit
->ObjectPlaneR
[0];
1530 params
[1] = (GLint
) texUnit
->ObjectPlaneR
[1];
1531 params
[2] = (GLint
) texUnit
->ObjectPlaneR
[2];
1532 params
[3] = (GLint
) texUnit
->ObjectPlaneR
[3];
1534 else if (pname
==GL_EYE_PLANE
) {
1535 params
[0] = (GLint
) texUnit
->EyePlaneR
[0];
1536 params
[1] = (GLint
) texUnit
->EyePlaneR
[1];
1537 params
[2] = (GLint
) texUnit
->EyePlaneR
[2];
1538 params
[3] = (GLint
) texUnit
->EyePlaneR
[3];
1541 gl_error( ctx
, GL_INVALID_ENUM
, "glGetTexGeniv(pname)" );
1546 if (pname
==GL_TEXTURE_GEN_MODE
) {
1547 params
[0] = texUnit
->GenModeQ
;
1549 else if (pname
==GL_OBJECT_PLANE
) {
1550 params
[0] = (GLint
) texUnit
->ObjectPlaneQ
[0];
1551 params
[1] = (GLint
) texUnit
->ObjectPlaneQ
[1];
1552 params
[2] = (GLint
) texUnit
->ObjectPlaneQ
[2];
1553 params
[3] = (GLint
) texUnit
->ObjectPlaneQ
[3];
1555 else if (pname
==GL_EYE_PLANE
) {
1556 params
[0] = (GLint
) texUnit
->EyePlaneQ
[0];
1557 params
[1] = (GLint
) texUnit
->EyePlaneQ
[1];
1558 params
[2] = (GLint
) texUnit
->EyePlaneQ
[2];
1559 params
[3] = (GLint
) texUnit
->EyePlaneQ
[3];
1562 gl_error( ctx
, GL_INVALID_ENUM
, "glGetTexGeniv(pname)" );
1567 gl_error( ctx
, GL_INVALID_ENUM
, "glGetTexGeniv(coord)" );
1573 /* GL_ARB_multitexture */
1575 _mesa_ActiveTextureARB( GLenum target
)
1577 GET_CURRENT_CONTEXT(ctx
);
1578 GLint maxUnits
= ctx
->Const
.MaxTextureUnits
;
1580 ASSERT_OUTSIDE_BEGIN_END( ctx
, "glActiveTextureARB" );
1582 if (MESA_VERBOSE
& (VERBOSE_API
|VERBOSE_TEXTURE
))
1583 fprintf(stderr
, "glActiveTexture %s\n",
1584 gl_lookup_enum_by_nr(target
));
1586 if (target
>= GL_TEXTURE0_ARB
&& target
< GL_TEXTURE0_ARB
+ maxUnits
) {
1587 GLint texUnit
= target
- GL_TEXTURE0_ARB
;
1588 ctx
->Texture
.CurrentUnit
= texUnit
;
1589 ctx
->Texture
.CurrentTransformUnit
= texUnit
;
1590 if (ctx
->Driver
.ActiveTexture
) {
1591 (*ctx
->Driver
.ActiveTexture
)( ctx
, (GLuint
) texUnit
);
1593 ctx
->NewState
|= _NEW_TEXTURE
;
1596 gl_error(ctx
, GL_INVALID_OPERATION
, "glActiveTextureARB(target)");
1601 /* GL_ARB_multitexture */
1603 _mesa_ClientActiveTextureARB( GLenum target
)
1605 GET_CURRENT_CONTEXT(ctx
);
1606 GLint maxUnits
= ctx
->Const
.MaxTextureUnits
;
1608 ASSERT_OUTSIDE_BEGIN_END( ctx
, "glClientActiveTextureARB" );
1610 if (target
>= GL_TEXTURE0_ARB
&& target
< GL_TEXTURE0_ARB
+ maxUnits
) {
1611 GLint texUnit
= target
- GL_TEXTURE0_ARB
;
1612 ctx
->Array
.ActiveTexture
= texUnit
;
1613 ctx
->NewState
|= _NEW_ARRAY
;
1616 gl_error(ctx
, GL_INVALID_OPERATION
, "glActiveTextureARB(target)");