1 /* $Id: texstate.c,v 1.87 2002/11/05 20:58:37 brianp Exp $ */
4 * Mesa 3-D graphics library
7 * Copyright (C) 1999-2002 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.
32 #include "extensions.h"
38 #include "math/m_xform.h"
39 #include "math/m_matrix.h"
44 /* Needed for an Amiga compiler */
45 #define ENUM_TO_FLOAT(X) ((GLfloat)(GLint)(X))
46 #define ENUM_TO_DOUBLE(X) ((GLdouble)(GLint)(X))
48 /* all other compilers */
49 #define ENUM_TO_FLOAT(X) ((GLfloat)(X))
50 #define ENUM_TO_DOUBLE(X) ((GLdouble)(X))
56 _mesa_copy_texture_state( const GLcontext
*src
, GLcontext
*dst
)
63 dst
->Texture
.CurrentUnit
= src
->Texture
.CurrentUnit
;
64 dst
->Texture
._GenFlags
= src
->Texture
._GenFlags
;
65 dst
->Texture
._TexGenEnabled
= src
->Texture
._TexGenEnabled
;
66 dst
->Texture
._TexMatEnabled
= src
->Texture
._TexMatEnabled
;
67 dst
->Texture
.SharedPalette
= src
->Texture
.SharedPalette
;
70 for (i
= 0; i
< src
->Const
.MaxTextureUnits
; i
++) {
71 dst
->Texture
.Unit
[i
].Enabled
= src
->Texture
.Unit
[i
].Enabled
;
72 dst
->Texture
.Unit
[i
].EnvMode
= src
->Texture
.Unit
[i
].EnvMode
;
73 COPY_4V(dst
->Texture
.Unit
[i
].EnvColor
, src
->Texture
.Unit
[i
].EnvColor
);
74 dst
->Texture
.Unit
[i
].TexGenEnabled
= src
->Texture
.Unit
[i
].TexGenEnabled
;
75 dst
->Texture
.Unit
[i
].GenModeS
= src
->Texture
.Unit
[i
].GenModeS
;
76 dst
->Texture
.Unit
[i
].GenModeT
= src
->Texture
.Unit
[i
].GenModeT
;
77 dst
->Texture
.Unit
[i
].GenModeR
= src
->Texture
.Unit
[i
].GenModeR
;
78 dst
->Texture
.Unit
[i
].GenModeQ
= src
->Texture
.Unit
[i
].GenModeQ
;
79 dst
->Texture
.Unit
[i
]._GenBitS
= src
->Texture
.Unit
[i
]._GenBitS
;
80 dst
->Texture
.Unit
[i
]._GenBitT
= src
->Texture
.Unit
[i
]._GenBitT
;
81 dst
->Texture
.Unit
[i
]._GenBitR
= src
->Texture
.Unit
[i
]._GenBitR
;
82 dst
->Texture
.Unit
[i
]._GenBitQ
= src
->Texture
.Unit
[i
]._GenBitQ
;
83 dst
->Texture
.Unit
[i
]._GenFlags
= src
->Texture
.Unit
[i
]._GenFlags
;
84 COPY_4V(dst
->Texture
.Unit
[i
].ObjectPlaneS
, src
->Texture
.Unit
[i
].ObjectPlaneS
);
85 COPY_4V(dst
->Texture
.Unit
[i
].ObjectPlaneT
, src
->Texture
.Unit
[i
].ObjectPlaneT
);
86 COPY_4V(dst
->Texture
.Unit
[i
].ObjectPlaneR
, src
->Texture
.Unit
[i
].ObjectPlaneR
);
87 COPY_4V(dst
->Texture
.Unit
[i
].ObjectPlaneQ
, src
->Texture
.Unit
[i
].ObjectPlaneQ
);
88 COPY_4V(dst
->Texture
.Unit
[i
].EyePlaneS
, src
->Texture
.Unit
[i
].EyePlaneS
);
89 COPY_4V(dst
->Texture
.Unit
[i
].EyePlaneT
, src
->Texture
.Unit
[i
].EyePlaneT
);
90 COPY_4V(dst
->Texture
.Unit
[i
].EyePlaneR
, src
->Texture
.Unit
[i
].EyePlaneR
);
91 COPY_4V(dst
->Texture
.Unit
[i
].EyePlaneQ
, src
->Texture
.Unit
[i
].EyePlaneQ
);
92 dst
->Texture
.Unit
[i
].LodBias
= src
->Texture
.Unit
[i
].LodBias
;
94 /* GL_EXT_texture_env_combine */
95 dst
->Texture
.Unit
[i
].CombineModeRGB
= src
->Texture
.Unit
[i
].CombineModeRGB
;
96 dst
->Texture
.Unit
[i
].CombineModeA
= src
->Texture
.Unit
[i
].CombineModeA
;
97 COPY_3V(dst
->Texture
.Unit
[i
].CombineSourceRGB
, src
->Texture
.Unit
[i
].CombineSourceRGB
);
98 COPY_3V(dst
->Texture
.Unit
[i
].CombineSourceA
, src
->Texture
.Unit
[i
].CombineSourceA
);
99 COPY_3V(dst
->Texture
.Unit
[i
].CombineOperandRGB
, src
->Texture
.Unit
[i
].CombineOperandRGB
);
100 COPY_3V(dst
->Texture
.Unit
[i
].CombineOperandA
, src
->Texture
.Unit
[i
].CombineOperandA
);
101 dst
->Texture
.Unit
[i
].CombineScaleShiftRGB
= src
->Texture
.Unit
[i
].CombineScaleShiftRGB
;
102 dst
->Texture
.Unit
[i
].CombineScaleShiftA
= src
->Texture
.Unit
[i
].CombineScaleShiftA
;
104 /* texture object state */
105 _mesa_copy_texture_object(dst
->Texture
.Unit
[i
].Current1D
,
106 src
->Texture
.Unit
[i
].Current1D
);
107 _mesa_copy_texture_object(dst
->Texture
.Unit
[i
].Current2D
,
108 src
->Texture
.Unit
[i
].Current2D
);
109 _mesa_copy_texture_object(dst
->Texture
.Unit
[i
].Current3D
,
110 src
->Texture
.Unit
[i
].Current3D
);
111 _mesa_copy_texture_object(dst
->Texture
.Unit
[i
].CurrentCubeMap
,
112 src
->Texture
.Unit
[i
].CurrentCubeMap
);
113 _mesa_copy_texture_object(dst
->Texture
.Unit
[i
].CurrentRect
,
114 src
->Texture
.Unit
[i
].CurrentRect
);
119 /**********************************************************************/
120 /* Texture Environment */
121 /**********************************************************************/
125 _mesa_TexEnvfv( GLenum target
, GLenum pname
, const GLfloat
*param
)
127 GET_CURRENT_CONTEXT(ctx
);
128 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
129 ASSERT_OUTSIDE_BEGIN_END(ctx
);
131 #define TE_ERROR(errCode, msg, value) \
132 _mesa_error(ctx, errCode, msg, _mesa_lookup_enum_by_nr(value));
134 if (target
== GL_TEXTURE_ENV
) {
136 case GL_TEXTURE_ENV_MODE
:
138 const GLenum mode
= (GLenum
) (GLint
) *param
;
139 if (mode
== GL_MODULATE
||
142 mode
== GL_REPLACE
||
143 (mode
== GL_ADD
&& ctx
->Extensions
.EXT_texture_env_add
) ||
144 (mode
== GL_COMBINE_EXT
&&
145 (ctx
->Extensions
.EXT_texture_env_combine
||
146 ctx
->Extensions
.ARB_texture_env_combine
))) {
148 if (texUnit
->EnvMode
== mode
)
150 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
151 texUnit
->EnvMode
= mode
;
154 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", mode
);
159 case GL_TEXTURE_ENV_COLOR
:
162 tmp
[0] = CLAMP( param
[0], 0.0F
, 1.0F
);
163 tmp
[1] = CLAMP( param
[1], 0.0F
, 1.0F
);
164 tmp
[2] = CLAMP( param
[2], 0.0F
, 1.0F
);
165 tmp
[3] = CLAMP( param
[3], 0.0F
, 1.0F
);
166 if (TEST_EQ_4V(tmp
, texUnit
->EnvColor
))
168 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
169 COPY_4FV(texUnit
->EnvColor
, tmp
);
172 case GL_COMBINE_RGB_EXT
:
173 if (ctx
->Extensions
.EXT_texture_env_combine
||
174 ctx
->Extensions
.ARB_texture_env_combine
) {
175 const GLenum mode
= (GLenum
) (GLint
) *param
;
180 case GL_ADD_SIGNED_EXT
:
181 case GL_INTERPOLATE_EXT
:
184 case GL_SUBTRACT_ARB
:
185 if (!ctx
->Extensions
.ARB_texture_env_combine
) {
186 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", mode
);
190 case GL_DOT3_RGB_EXT
:
191 case GL_DOT3_RGBA_EXT
:
192 if (!ctx
->Extensions
.EXT_texture_env_dot3
) {
193 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", mode
);
197 case GL_DOT3_RGB_ARB
:
198 case GL_DOT3_RGBA_ARB
:
199 if (!ctx
->Extensions
.ARB_texture_env_dot3
) {
200 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", mode
);
205 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", mode
);
208 if (texUnit
->CombineModeRGB
== mode
)
210 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
211 texUnit
->CombineModeRGB
= mode
;
214 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(pname=%s)", pname
);
218 case GL_COMBINE_ALPHA_EXT
:
219 if (ctx
->Extensions
.EXT_texture_env_combine
||
220 ctx
->Extensions
.ARB_texture_env_combine
) {
221 const GLenum mode
= (GLenum
) (GLint
) *param
;
222 if (mode
== GL_REPLACE
||
223 mode
== GL_MODULATE
||
225 mode
== GL_ADD_SIGNED_EXT
||
226 mode
== GL_INTERPOLATE_EXT
||
227 (mode
== GL_SUBTRACT_ARB
&&
228 ctx
->Extensions
.ARB_texture_env_combine
)) {
230 if (texUnit
->CombineModeA
== mode
)
232 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
233 texUnit
->CombineModeA
= mode
;
236 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", mode
);
241 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(pname=%s)", pname
);
245 case GL_SOURCE0_RGB_EXT
:
246 case GL_SOURCE1_RGB_EXT
:
247 case GL_SOURCE2_RGB_EXT
:
248 if (ctx
->Extensions
.EXT_texture_env_combine
||
249 ctx
->Extensions
.ARB_texture_env_combine
) {
250 const GLenum source
= (GLenum
) (GLint
) *param
;
251 const GLuint s
= pname
- GL_SOURCE0_RGB_EXT
;
252 if (source
== GL_TEXTURE
||
253 source
== GL_CONSTANT_EXT
||
254 source
== GL_PRIMARY_COLOR_EXT
||
255 source
== GL_PREVIOUS_EXT
||
256 (ctx
->Extensions
.ARB_texture_env_crossbar
&&
257 source
>= GL_TEXTURE0_ARB
&&
258 source
< GL_TEXTURE0_ARB
+ ctx
->Const
.MaxTextureUnits
)) {
260 if (texUnit
->CombineSourceRGB
[s
] == source
)
262 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
263 texUnit
->CombineSourceRGB
[s
] = source
;
266 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", source
);
271 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(pname=%s)", pname
);
275 case GL_SOURCE0_ALPHA_EXT
:
276 case GL_SOURCE1_ALPHA_EXT
:
277 case GL_SOURCE2_ALPHA_EXT
:
278 if (ctx
->Extensions
.EXT_texture_env_combine
||
279 ctx
->Extensions
.ARB_texture_env_combine
) {
280 const GLenum source
= (GLenum
) (GLint
) *param
;
281 const GLuint s
= pname
- GL_SOURCE0_ALPHA_EXT
;
282 if (source
== GL_TEXTURE
||
283 source
== GL_CONSTANT_EXT
||
284 source
== GL_PRIMARY_COLOR_EXT
||
285 source
== GL_PREVIOUS_EXT
||
286 (ctx
->Extensions
.ARB_texture_env_crossbar
&&
287 source
>= GL_TEXTURE0_ARB
&&
288 source
< GL_TEXTURE0_ARB
+ ctx
->Const
.MaxTextureUnits
)) {
290 if (texUnit
->CombineSourceA
[s
] == source
)
292 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
293 texUnit
->CombineSourceA
[s
] = source
;
296 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", source
);
301 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(pname=%s)", pname
);
305 case GL_OPERAND0_RGB_EXT
:
306 case GL_OPERAND1_RGB_EXT
:
307 if (ctx
->Extensions
.EXT_texture_env_combine
||
308 ctx
->Extensions
.ARB_texture_env_combine
) {
309 const GLenum operand
= (GLenum
) (GLint
) *param
;
310 const GLuint s
= pname
- GL_OPERAND0_RGB_EXT
;
313 case GL_ONE_MINUS_SRC_COLOR
:
315 case GL_ONE_MINUS_SRC_ALPHA
:
316 if (texUnit
->CombineOperandRGB
[s
] == operand
)
318 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
319 texUnit
->CombineOperandRGB
[s
] = operand
;
322 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", operand
);
327 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(pname=%s)", pname
);
331 case GL_OPERAND0_ALPHA_EXT
:
332 case GL_OPERAND1_ALPHA_EXT
:
333 if (ctx
->Extensions
.EXT_texture_env_combine
||
334 ctx
->Extensions
.ARB_texture_env_combine
) {
335 const GLenum operand
= (GLenum
) (GLint
) *param
;
338 case GL_ONE_MINUS_SRC_ALPHA
:
339 if (texUnit
->CombineOperandA
[pname
-GL_OPERAND0_ALPHA_EXT
] ==
342 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
343 texUnit
->CombineOperandA
[pname
-GL_OPERAND0_ALPHA_EXT
] = operand
;
346 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", operand
);
351 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(pname=%s)", pname
);
355 case GL_OPERAND2_RGB_EXT
:
356 if (ctx
->Extensions
.EXT_texture_env_combine
||
357 ctx
->Extensions
.ARB_texture_env_combine
) {
358 const GLenum operand
= (GLenum
) (GLint
) *param
;
360 case GL_SRC_COLOR
: /* ARB combine only */
361 case GL_ONE_MINUS_SRC_COLOR
: /* ARB combine only */
363 case GL_ONE_MINUS_SRC_ALPHA
: /* ARB combine only */
364 if (texUnit
->CombineOperandRGB
[2] == operand
)
366 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
367 texUnit
->CombineOperandRGB
[2] = operand
;
369 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", operand
);
374 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(pname=%s)", pname
);
378 case GL_OPERAND2_ALPHA_EXT
:
379 if (ctx
->Extensions
.EXT_texture_env_combine
||
380 ctx
->Extensions
.ARB_texture_env_combine
) {
381 const GLenum operand
= (GLenum
) (GLint
) *param
;
384 case GL_ONE_MINUS_SRC_ALPHA
: /* ARB combine only */
385 if (texUnit
->CombineOperandA
[2] == operand
)
387 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
388 texUnit
->CombineOperandA
[2] = operand
;
391 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", operand
);
396 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(pname=%s)", pname
);
400 case GL_RGB_SCALE_EXT
:
401 if (ctx
->Extensions
.EXT_texture_env_combine
||
402 ctx
->Extensions
.ARB_texture_env_combine
) {
407 else if (*param
== 2.0) {
410 else if (*param
== 4.0) {
414 _mesa_error( ctx
, GL_INVALID_VALUE
,
415 "glTexEnv(GL_RGB_SCALE not 1, 2 or 4)" );
418 if (texUnit
->CombineScaleShiftRGB
== newshift
)
420 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
421 texUnit
->CombineScaleShiftRGB
= newshift
;
424 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(pname=%s)", pname
);
429 if (ctx
->Extensions
.EXT_texture_env_combine
||
430 ctx
->Extensions
.ARB_texture_env_combine
) {
435 else if (*param
== 2.0) {
438 else if (*param
== 4.0) {
442 _mesa_error( ctx
, GL_INVALID_VALUE
,
443 "glTexEnv(GL_ALPHA_SCALE not 1, 2 or 4)" );
446 if (texUnit
->CombineScaleShiftA
== newshift
)
448 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
449 texUnit
->CombineScaleShiftA
= newshift
;
452 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(pname=%s)", pname
);
457 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexEnv(pname)" );
461 else if (target
== GL_TEXTURE_FILTER_CONTROL_EXT
) {
462 /* GL_EXT_texture_lod_bias */
463 if (!ctx
->Extensions
.EXT_texture_lod_bias
) {
464 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexEnv(target=0x%x)", target
);
467 if (pname
== GL_TEXTURE_LOD_BIAS_EXT
) {
468 if (texUnit
->LodBias
== param
[0])
470 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
471 texUnit
->LodBias
= CLAMP(param
[0], -ctx
->Const
.MaxTextureLodBias
,
472 ctx
->Const
.MaxTextureLodBias
);
475 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(pname=%s)", pname
);
479 else if (target
== GL_POINT_SPRITE_NV
) {
480 /* GL_NV_point_sprite */
481 if (!ctx
->Extensions
.NV_point_sprite
) {
482 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexEnv(target=0x%x)", target
);
485 if (pname
== GL_COORD_REPLACE_NV
) {
486 const GLenum value
= (GLenum
) param
[0];
487 if (value
== GL_TRUE
|| value
== GL_FALSE
) {
488 /* It's kind of weird to set point state via glTexEnv,
489 * but that's what the spec calls for.
491 const GLboolean state
= (GLboolean
) value
;
492 if (ctx
->Point
.CoordReplace
[ctx
->Texture
.CurrentUnit
] == state
)
494 FLUSH_VERTICES(ctx
, _NEW_POINT
);
495 ctx
->Point
.CoordReplace
[ctx
->Texture
.CurrentUnit
] = state
;
498 _mesa_error( ctx
, GL_INVALID_VALUE
, "glTexEnv(param=0x%x)", value
);
503 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexEnv(pname=0x%x)", pname
);
508 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexEnv(target=0x%x)",target
);
512 if (MESA_VERBOSE
&(VERBOSE_API
|VERBOSE_TEXTURE
))
513 _mesa_debug(ctx
, "glTexEnv %s %s %.1f(%s) ...\n",
514 _mesa_lookup_enum_by_nr(target
),
515 _mesa_lookup_enum_by_nr(pname
),
517 _mesa_lookup_enum_by_nr((GLenum
) (GLint
) *param
));
519 /* Tell device driver about the new texture environment */
520 if (ctx
->Driver
.TexEnv
) {
521 (*ctx
->Driver
.TexEnv
)( ctx
, target
, pname
, param
);
527 _mesa_TexEnvf( GLenum target
, GLenum pname
, GLfloat param
)
529 _mesa_TexEnvfv( target
, pname
, ¶m
);
535 _mesa_TexEnvi( GLenum target
, GLenum pname
, GLint param
)
538 p
[0] = (GLfloat
) param
;
539 p
[1] = p
[2] = p
[3] = 0.0;
540 _mesa_TexEnvfv( target
, pname
, p
);
545 _mesa_TexEnviv( GLenum target
, GLenum pname
, const GLint
*param
)
548 if (pname
== GL_TEXTURE_ENV_COLOR
) {
549 p
[0] = INT_TO_FLOAT( param
[0] );
550 p
[1] = INT_TO_FLOAT( param
[1] );
551 p
[2] = INT_TO_FLOAT( param
[2] );
552 p
[3] = INT_TO_FLOAT( param
[3] );
555 p
[0] = (GLfloat
) param
[0];
556 p
[1] = p
[2] = p
[3] = 0; /* init to zero, just to be safe */
558 _mesa_TexEnvfv( target
, pname
, p
);
563 _mesa_GetTexEnvfv( GLenum target
, GLenum pname
, GLfloat
*params
)
565 GET_CURRENT_CONTEXT(ctx
);
566 const struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
567 ASSERT_OUTSIDE_BEGIN_END(ctx
);
569 if (target
== GL_TEXTURE_ENV
) {
571 case GL_TEXTURE_ENV_MODE
:
572 *params
= ENUM_TO_FLOAT(texUnit
->EnvMode
);
574 case GL_TEXTURE_ENV_COLOR
:
575 COPY_4FV( params
, texUnit
->EnvColor
);
577 case GL_COMBINE_RGB_EXT
:
578 if (ctx
->Extensions
.EXT_texture_env_combine
||
579 ctx
->Extensions
.ARB_texture_env_combine
) {
580 *params
= (GLfloat
) texUnit
->CombineModeRGB
;
583 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
586 case GL_COMBINE_ALPHA_EXT
:
587 if (ctx
->Extensions
.EXT_texture_env_combine
||
588 ctx
->Extensions
.ARB_texture_env_combine
) {
589 *params
= (GLfloat
) texUnit
->CombineModeA
;
592 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
595 case GL_SOURCE0_RGB_EXT
:
596 if (ctx
->Extensions
.EXT_texture_env_combine
||
597 ctx
->Extensions
.ARB_texture_env_combine
) {
598 *params
= (GLfloat
) texUnit
->CombineSourceRGB
[0];
601 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
604 case GL_SOURCE1_RGB_EXT
:
605 if (ctx
->Extensions
.EXT_texture_env_combine
||
606 ctx
->Extensions
.ARB_texture_env_combine
) {
607 *params
= (GLfloat
) texUnit
->CombineSourceRGB
[1];
610 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
613 case GL_SOURCE2_RGB_EXT
:
614 if (ctx
->Extensions
.EXT_texture_env_combine
||
615 ctx
->Extensions
.ARB_texture_env_combine
) {
616 *params
= (GLfloat
) texUnit
->CombineSourceRGB
[2];
619 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
622 case GL_SOURCE0_ALPHA_EXT
:
623 if (ctx
->Extensions
.EXT_texture_env_combine
||
624 ctx
->Extensions
.ARB_texture_env_combine
) {
625 *params
= (GLfloat
) texUnit
->CombineSourceA
[0];
628 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
631 case GL_SOURCE1_ALPHA_EXT
:
632 if (ctx
->Extensions
.EXT_texture_env_combine
||
633 ctx
->Extensions
.ARB_texture_env_combine
) {
634 *params
= (GLfloat
) texUnit
->CombineSourceA
[1];
637 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
640 case GL_SOURCE2_ALPHA_EXT
:
641 if (ctx
->Extensions
.EXT_texture_env_combine
||
642 ctx
->Extensions
.ARB_texture_env_combine
) {
643 *params
= (GLfloat
) texUnit
->CombineSourceA
[2];
646 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
649 case GL_OPERAND0_RGB_EXT
:
650 if (ctx
->Extensions
.EXT_texture_env_combine
||
651 ctx
->Extensions
.ARB_texture_env_combine
) {
652 *params
= (GLfloat
) texUnit
->CombineOperandRGB
[0];
655 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
658 case GL_OPERAND1_RGB_EXT
:
659 if (ctx
->Extensions
.EXT_texture_env_combine
||
660 ctx
->Extensions
.ARB_texture_env_combine
) {
661 *params
= (GLfloat
) texUnit
->CombineOperandRGB
[1];
664 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
667 case GL_OPERAND2_RGB_EXT
:
668 if (ctx
->Extensions
.EXT_texture_env_combine
||
669 ctx
->Extensions
.ARB_texture_env_combine
) {
670 *params
= (GLfloat
) texUnit
->CombineOperandRGB
[2];
673 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
676 case GL_OPERAND0_ALPHA_EXT
:
677 if (ctx
->Extensions
.EXT_texture_env_combine
||
678 ctx
->Extensions
.ARB_texture_env_combine
) {
679 *params
= (GLfloat
) texUnit
->CombineOperandA
[0];
682 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
685 case GL_OPERAND1_ALPHA_EXT
:
686 if (ctx
->Extensions
.EXT_texture_env_combine
||
687 ctx
->Extensions
.ARB_texture_env_combine
) {
688 *params
= (GLfloat
) texUnit
->CombineOperandA
[1];
691 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
694 case GL_OPERAND2_ALPHA_EXT
:
695 if (ctx
->Extensions
.EXT_texture_env_combine
||
696 ctx
->Extensions
.ARB_texture_env_combine
) {
697 *params
= (GLfloat
) texUnit
->CombineOperandA
[2];
700 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
703 case GL_RGB_SCALE_EXT
:
704 if (ctx
->Extensions
.EXT_texture_env_combine
||
705 ctx
->Extensions
.ARB_texture_env_combine
) {
706 if (texUnit
->CombineScaleShiftRGB
== 0)
708 else if (texUnit
->CombineScaleShiftRGB
== 1)
714 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
719 if (ctx
->Extensions
.EXT_texture_env_combine
||
720 ctx
->Extensions
.ARB_texture_env_combine
) {
721 if (texUnit
->CombineScaleShiftA
== 0)
723 else if (texUnit
->CombineScaleShiftA
== 1)
729 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
734 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)" );
737 else if (target
== GL_TEXTURE_FILTER_CONTROL_EXT
) {
738 /* GL_EXT_texture_lod_bias */
739 if (!ctx
->Extensions
.EXT_texture_lod_bias
) {
740 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(target)" );
743 if (pname
== GL_TEXTURE_LOD_BIAS_EXT
) {
744 *params
= texUnit
->LodBias
;
747 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)" );
751 else if (target
== GL_POINT_SPRITE_NV
) {
752 /* GL_NV_point_sprite */
753 if (!ctx
->Extensions
.NV_point_sprite
) {
754 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(target)" );
757 if (pname
== GL_COORD_REPLACE_NV
) {
758 *params
= (GLfloat
) ctx
->Point
.CoordReplace
[ctx
->Texture
.CurrentUnit
];
761 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)" );
766 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(target)" );
773 _mesa_GetTexEnviv( GLenum target
, GLenum pname
, GLint
*params
)
775 GET_CURRENT_CONTEXT(ctx
);
776 const struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
777 ASSERT_OUTSIDE_BEGIN_END(ctx
);
779 if (target
== GL_TEXTURE_ENV
) {
781 case GL_TEXTURE_ENV_MODE
:
782 *params
= (GLint
) texUnit
->EnvMode
;
784 case GL_TEXTURE_ENV_COLOR
:
785 params
[0] = FLOAT_TO_INT( texUnit
->EnvColor
[0] );
786 params
[1] = FLOAT_TO_INT( texUnit
->EnvColor
[1] );
787 params
[2] = FLOAT_TO_INT( texUnit
->EnvColor
[2] );
788 params
[3] = FLOAT_TO_INT( texUnit
->EnvColor
[3] );
790 case GL_COMBINE_RGB_EXT
:
791 if (ctx
->Extensions
.EXT_texture_env_combine
||
792 ctx
->Extensions
.ARB_texture_env_combine
) {
793 *params
= (GLint
) texUnit
->CombineModeRGB
;
796 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
799 case GL_COMBINE_ALPHA_EXT
:
800 if (ctx
->Extensions
.EXT_texture_env_combine
||
801 ctx
->Extensions
.ARB_texture_env_combine
) {
802 *params
= (GLint
) texUnit
->CombineModeA
;
805 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
808 case GL_SOURCE0_RGB_EXT
:
809 if (ctx
->Extensions
.EXT_texture_env_combine
||
810 ctx
->Extensions
.ARB_texture_env_combine
) {
811 *params
= (GLint
) texUnit
->CombineSourceRGB
[0];
814 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
817 case GL_SOURCE1_RGB_EXT
:
818 if (ctx
->Extensions
.EXT_texture_env_combine
||
819 ctx
->Extensions
.ARB_texture_env_combine
) {
820 *params
= (GLint
) texUnit
->CombineSourceRGB
[1];
823 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
826 case GL_SOURCE2_RGB_EXT
:
827 if (ctx
->Extensions
.EXT_texture_env_combine
||
828 ctx
->Extensions
.ARB_texture_env_combine
) {
829 *params
= (GLint
) texUnit
->CombineSourceRGB
[2];
832 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
835 case GL_SOURCE0_ALPHA_EXT
:
836 if (ctx
->Extensions
.EXT_texture_env_combine
||
837 ctx
->Extensions
.ARB_texture_env_combine
) {
838 *params
= (GLint
) texUnit
->CombineSourceA
[0];
841 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
844 case GL_SOURCE1_ALPHA_EXT
:
845 if (ctx
->Extensions
.EXT_texture_env_combine
||
846 ctx
->Extensions
.ARB_texture_env_combine
) {
847 *params
= (GLint
) texUnit
->CombineSourceA
[1];
850 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
853 case GL_SOURCE2_ALPHA_EXT
:
854 if (ctx
->Extensions
.EXT_texture_env_combine
||
855 ctx
->Extensions
.ARB_texture_env_combine
) {
856 *params
= (GLint
) texUnit
->CombineSourceA
[2];
859 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
862 case GL_OPERAND0_RGB_EXT
:
863 if (ctx
->Extensions
.EXT_texture_env_combine
||
864 ctx
->Extensions
.ARB_texture_env_combine
) {
865 *params
= (GLint
) texUnit
->CombineOperandRGB
[0];
868 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
871 case GL_OPERAND1_RGB_EXT
:
872 if (ctx
->Extensions
.EXT_texture_env_combine
||
873 ctx
->Extensions
.ARB_texture_env_combine
) {
874 *params
= (GLint
) texUnit
->CombineOperandRGB
[1];
877 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
880 case GL_OPERAND2_RGB_EXT
:
881 if (ctx
->Extensions
.EXT_texture_env_combine
||
882 ctx
->Extensions
.ARB_texture_env_combine
) {
883 *params
= (GLint
) texUnit
->CombineOperandRGB
[2];
886 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
889 case GL_OPERAND0_ALPHA_EXT
:
890 if (ctx
->Extensions
.EXT_texture_env_combine
||
891 ctx
->Extensions
.ARB_texture_env_combine
) {
892 *params
= (GLint
) texUnit
->CombineOperandA
[0];
895 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
898 case GL_OPERAND1_ALPHA_EXT
:
899 if (ctx
->Extensions
.EXT_texture_env_combine
||
900 ctx
->Extensions
.ARB_texture_env_combine
) {
901 *params
= (GLint
) texUnit
->CombineOperandA
[1];
904 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
907 case GL_OPERAND2_ALPHA_EXT
:
908 if (ctx
->Extensions
.EXT_texture_env_combine
||
909 ctx
->Extensions
.ARB_texture_env_combine
) {
910 *params
= (GLint
) texUnit
->CombineOperandA
[2];
913 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
916 case GL_RGB_SCALE_EXT
:
917 if (ctx
->Extensions
.EXT_texture_env_combine
||
918 ctx
->Extensions
.ARB_texture_env_combine
) {
919 if (texUnit
->CombineScaleShiftRGB
== 0)
921 else if (texUnit
->CombineScaleShiftRGB
== 1)
927 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
932 if (ctx
->Extensions
.EXT_texture_env_combine
||
933 ctx
->Extensions
.ARB_texture_env_combine
) {
934 if (texUnit
->CombineScaleShiftA
== 0)
936 else if (texUnit
->CombineScaleShiftA
== 1)
942 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
947 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)" );
950 else if (target
== GL_TEXTURE_FILTER_CONTROL_EXT
) {
951 /* GL_EXT_texture_lod_bias */
952 if (!ctx
->Extensions
.EXT_texture_lod_bias
) {
953 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(target)" );
956 if (pname
== GL_TEXTURE_LOD_BIAS_EXT
) {
957 *params
= (GLint
) texUnit
->LodBias
;
960 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)" );
964 else if (target
== GL_POINT_SPRITE_NV
) {
965 /* GL_NV_point_sprite */
966 if (!ctx
->Extensions
.NV_point_sprite
) {
967 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(target)" );
970 if (pname
== GL_COORD_REPLACE_NV
) {
971 *params
= (GLint
) ctx
->Point
.CoordReplace
[ctx
->Texture
.CurrentUnit
];
974 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)" );
979 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(target)" );
987 /**********************************************************************/
988 /* Texture Parameters */
989 /**********************************************************************/
993 _mesa_TexParameterf( GLenum target
, GLenum pname
, GLfloat param
)
995 _mesa_TexParameterfv(target
, pname
, ¶m
);
1000 _mesa_TexParameterfv( GLenum target
, GLenum pname
, const GLfloat
*params
)
1002 GET_CURRENT_CONTEXT(ctx
);
1003 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1004 GLenum eparam
= (GLenum
) (GLint
) params
[0];
1005 struct gl_texture_object
*texObj
;
1006 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1008 if (MESA_VERBOSE
&(VERBOSE_API
|VERBOSE_TEXTURE
))
1009 _mesa_debug(ctx
, "texPARAM %s %s %d...\n",
1010 _mesa_lookup_enum_by_nr(target
),
1011 _mesa_lookup_enum_by_nr(pname
),
1017 texObj
= texUnit
->Current1D
;
1020 texObj
= texUnit
->Current2D
;
1022 case GL_TEXTURE_3D_EXT
:
1023 texObj
= texUnit
->Current3D
;
1025 case GL_TEXTURE_CUBE_MAP_ARB
:
1026 if (!ctx
->Extensions
.ARB_texture_cube_map
) {
1027 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexParameter(target)" );
1030 texObj
= texUnit
->CurrentCubeMap
;
1032 case GL_TEXTURE_RECTANGLE_NV
:
1033 if (!ctx
->Extensions
.NV_texture_rectangle
) {
1034 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexParameter(target)" );
1037 texObj
= texUnit
->CurrentRect
;
1040 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexParameter(target)" );
1045 case GL_TEXTURE_MIN_FILTER
:
1046 /* A small optimization */
1047 if (texObj
->MinFilter
== eparam
)
1049 if (eparam
==GL_NEAREST
|| eparam
==GL_LINEAR
) {
1050 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1051 texObj
->MinFilter
= eparam
;
1053 else if ((eparam
==GL_NEAREST_MIPMAP_NEAREST
||
1054 eparam
==GL_LINEAR_MIPMAP_NEAREST
||
1055 eparam
==GL_NEAREST_MIPMAP_LINEAR
||
1056 eparam
==GL_LINEAR_MIPMAP_LINEAR
) &&
1057 texObj
->Target
!= GL_TEXTURE_RECTANGLE_NV
) {
1058 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1059 texObj
->MinFilter
= eparam
;
1062 _mesa_error( ctx
, GL_INVALID_VALUE
, "glTexParameter(param)" );
1066 case GL_TEXTURE_MAG_FILTER
:
1067 /* A small optimization */
1068 if (texObj
->MagFilter
== eparam
)
1071 if (eparam
==GL_NEAREST
|| eparam
==GL_LINEAR
) {
1072 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1073 texObj
->MagFilter
= eparam
;
1076 _mesa_error( ctx
, GL_INVALID_VALUE
, "glTexParameter(param)" );
1080 case GL_TEXTURE_WRAP_S
:
1081 if (texObj
->WrapS
== eparam
)
1083 if (eparam
== GL_CLAMP
|| eparam
== GL_CLAMP_TO_EDGE
||
1084 (eparam
== GL_CLAMP_TO_BORDER_ARB
&&
1085 ctx
->Extensions
.ARB_texture_border_clamp
)) {
1086 /* any texture target */
1087 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1088 texObj
->WrapS
= eparam
;
1090 else if (texObj
->Target
!= GL_TEXTURE_RECTANGLE_NV
&&
1091 (eparam
== GL_REPEAT
||
1092 (eparam
== GL_MIRRORED_REPEAT_ARB
&&
1093 ctx
->Extensions
.ARB_texture_mirrored_repeat
) ||
1094 (eparam
== GL_MIRROR_CLAMP_ATI
&&
1095 ctx
->Extensions
.ATI_texture_mirror_once
) ||
1096 (eparam
== GL_MIRROR_CLAMP_TO_EDGE_ATI
&&
1097 ctx
->Extensions
.ATI_texture_mirror_once
))) {
1098 /* non-rectangle texture */
1099 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1100 texObj
->WrapS
= eparam
;
1103 _mesa_error( ctx
, GL_INVALID_VALUE
, "glTexParameter(param)" );
1107 case GL_TEXTURE_WRAP_T
:
1108 if (texObj
->WrapT
== eparam
)
1110 if (eparam
== GL_CLAMP
|| eparam
== GL_CLAMP_TO_EDGE
||
1111 (eparam
== GL_CLAMP_TO_BORDER_ARB
&&
1112 ctx
->Extensions
.ARB_texture_border_clamp
)) {
1113 /* any texture target */
1114 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1115 texObj
->WrapT
= eparam
;
1117 else if (texObj
->Target
!= GL_TEXTURE_RECTANGLE_NV
&&
1118 (eparam
== GL_REPEAT
||
1119 (eparam
== GL_MIRRORED_REPEAT_ARB
&&
1120 ctx
->Extensions
.ARB_texture_mirrored_repeat
) ||
1121 (eparam
== GL_MIRROR_CLAMP_ATI
&&
1122 ctx
->Extensions
.ATI_texture_mirror_once
) ||
1123 (eparam
== GL_MIRROR_CLAMP_TO_EDGE_ATI
&&
1124 ctx
->Extensions
.ATI_texture_mirror_once
))) {
1125 /* non-rectangle texture */
1126 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1127 texObj
->WrapT
= eparam
;
1130 _mesa_error( ctx
, GL_INVALID_VALUE
, "glTexParameter(param)" );
1134 case GL_TEXTURE_WRAP_R_EXT
:
1135 if (texObj
->WrapR
== eparam
)
1137 if (eparam
== GL_CLAMP
|| eparam
== GL_CLAMP_TO_EDGE
||
1138 (eparam
== GL_CLAMP_TO_BORDER_ARB
&&
1139 ctx
->Extensions
.ARB_texture_border_clamp
)) {
1140 /* any texture target */
1141 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1142 texObj
->WrapR
= eparam
;
1144 else if (texObj
->Target
!= GL_TEXTURE_RECTANGLE_NV
&&
1145 (eparam
== GL_REPEAT
||
1146 (eparam
== GL_MIRRORED_REPEAT_ARB
&&
1147 ctx
->Extensions
.ARB_texture_mirrored_repeat
) ||
1148 (eparam
== GL_MIRROR_CLAMP_ATI
&&
1149 ctx
->Extensions
.ATI_texture_mirror_once
) ||
1150 (eparam
== GL_MIRROR_CLAMP_TO_EDGE_ATI
&&
1151 ctx
->Extensions
.ATI_texture_mirror_once
))) {
1152 /* non-rectangle texture */
1153 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1154 texObj
->WrapR
= eparam
;
1157 _mesa_error( ctx
, GL_INVALID_VALUE
, "glTexParameter(param)" );
1160 case GL_TEXTURE_BORDER_COLOR
:
1161 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1162 texObj
->BorderColor
[RCOMP
] = params
[0];
1163 texObj
->BorderColor
[GCOMP
] = params
[1];
1164 texObj
->BorderColor
[BCOMP
] = params
[2];
1165 texObj
->BorderColor
[ACOMP
] = params
[3];
1166 UNCLAMPED_FLOAT_TO_CHAN(texObj
->_BorderChan
[RCOMP
], params
[0]);
1167 UNCLAMPED_FLOAT_TO_CHAN(texObj
->_BorderChan
[GCOMP
], params
[1]);
1168 UNCLAMPED_FLOAT_TO_CHAN(texObj
->_BorderChan
[BCOMP
], params
[2]);
1169 UNCLAMPED_FLOAT_TO_CHAN(texObj
->_BorderChan
[ACOMP
], params
[3]);
1171 case GL_TEXTURE_MIN_LOD
:
1172 if (texObj
->MinLod
== params
[0])
1174 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1175 texObj
->MinLod
= params
[0];
1177 case GL_TEXTURE_MAX_LOD
:
1178 if (texObj
->MaxLod
== params
[0])
1180 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1181 texObj
->MaxLod
= params
[0];
1183 case GL_TEXTURE_BASE_LEVEL
:
1184 if (params
[0] < 0.0) {
1185 _mesa_error(ctx
, GL_INVALID_VALUE
, "glTexParameter(param)" );
1188 if (target
== GL_TEXTURE_RECTANGLE_NV
&& params
[0] != 0.0) {
1189 _mesa_error(ctx
, GL_INVALID_VALUE
, "glTexParameter(param)" );
1192 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1193 texObj
->BaseLevel
= (GLint
) params
[0];
1195 case GL_TEXTURE_MAX_LEVEL
:
1196 if (params
[0] < 0.0) {
1197 _mesa_error(ctx
, GL_INVALID_VALUE
, "glTexParameter(param)" );
1200 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1201 texObj
->MaxLevel
= (GLint
) params
[0];
1203 case GL_TEXTURE_PRIORITY
:
1204 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1205 texObj
->Priority
= CLAMP( params
[0], 0.0F
, 1.0F
);
1207 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1208 if (ctx
->Extensions
.EXT_texture_filter_anisotropic
) {
1209 if (params
[0] < 1.0) {
1210 _mesa_error(ctx
, GL_INVALID_VALUE
, "glTexParameter(param)" );
1213 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1214 texObj
->MaxAnisotropy
= params
[0];
1217 _mesa_error(ctx
, GL_INVALID_ENUM
,
1218 "glTexParameter(pname=GL_TEXTURE_MAX_ANISOTROPY_EXT)");
1222 case GL_TEXTURE_COMPARE_SGIX
:
1223 if (ctx
->Extensions
.SGIX_shadow
) {
1224 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1225 texObj
->CompareFlag
= params
[0] ? GL_TRUE
: GL_FALSE
;
1228 _mesa_error(ctx
, GL_INVALID_ENUM
,
1229 "glTexParameter(pname=GL_TEXTURE_COMPARE_SGIX)");
1233 case GL_TEXTURE_COMPARE_OPERATOR_SGIX
:
1234 if (ctx
->Extensions
.SGIX_shadow
) {
1235 GLenum op
= (GLenum
) params
[0];
1236 if (op
== GL_TEXTURE_LEQUAL_R_SGIX
||
1237 op
== GL_TEXTURE_GEQUAL_R_SGIX
) {
1238 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1239 texObj
->CompareOperator
= op
;
1242 _mesa_error(ctx
, GL_INVALID_ENUM
, "glTexParameter(param)");
1246 _mesa_error(ctx
, GL_INVALID_ENUM
,
1247 "glTexParameter(pname=GL_TEXTURE_COMPARE_OPERATOR_SGIX)");
1251 case GL_SHADOW_AMBIENT_SGIX
: /* aka GL_TEXTURE_COMPARE_FAIL_VALUE_ARB */
1252 if (ctx
->Extensions
.SGIX_shadow_ambient
) {
1253 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1254 texObj
->ShadowAmbient
= CLAMP(params
[0], 0.0F
, 1.0F
);
1257 _mesa_error(ctx
, GL_INVALID_ENUM
,
1258 "glTexParameter(pname=GL_SHADOW_AMBIENT_SGIX)");
1262 case GL_GENERATE_MIPMAP_SGIS
:
1263 if (ctx
->Extensions
.SGIS_generate_mipmap
) {
1264 texObj
->GenerateMipmap
= params
[0] ? GL_TRUE
: GL_FALSE
;
1267 _mesa_error(ctx
, GL_INVALID_ENUM
,
1268 "glTexParameter(pname=GL_GENERATE_MIPMAP_SGIS)");
1272 case GL_TEXTURE_COMPARE_MODE_ARB
:
1273 if (ctx
->Extensions
.ARB_shadow
) {
1274 const GLenum mode
= (GLenum
) params
[0];
1275 if (mode
== GL_NONE
|| mode
== GL_COMPARE_R_TO_TEXTURE_ARB
) {
1276 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1277 texObj
->CompareMode
= mode
;
1280 _mesa_error(ctx
, GL_INVALID_ENUM
,
1281 "glTexParameter(bad GL_TEXTURE_COMPARE_MODE_ARB)");
1286 _mesa_error(ctx
, GL_INVALID_ENUM
,
1287 "glTexParameter(pname=GL_TEXTURE_COMPARE_MODE_ARB)");
1291 case GL_TEXTURE_COMPARE_FUNC_ARB
:
1292 if (ctx
->Extensions
.ARB_shadow
) {
1293 const GLenum func
= (GLenum
) params
[0];
1294 if (func
== GL_LEQUAL
|| func
== GL_GEQUAL
) {
1295 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1296 texObj
->CompareFunc
= func
;
1298 else if (ctx
->Extensions
.EXT_shadow_funcs
&&
1299 (func
== GL_EQUAL
||
1300 func
== GL_NOTEQUAL
||
1302 func
== GL_GREATER
||
1303 func
== GL_ALWAYS
||
1304 func
== GL_NEVER
)) {
1305 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1306 texObj
->CompareFunc
= func
;
1309 _mesa_error(ctx
, GL_INVALID_ENUM
,
1310 "glTexParameter(bad GL_TEXTURE_COMPARE_FUNC_ARB)");
1315 _mesa_error(ctx
, GL_INVALID_ENUM
,
1316 "glTexParameter(pname=GL_TEXTURE_COMPARE_FUNC_ARB)");
1320 case GL_DEPTH_TEXTURE_MODE_ARB
:
1321 if (ctx
->Extensions
.ARB_depth_texture
) {
1322 const GLenum result
= (GLenum
) params
[0];
1323 if (result
== GL_LUMINANCE
|| result
== GL_INTENSITY
1324 || result
== GL_ALPHA
) {
1325 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1326 texObj
->DepthMode
= result
;
1329 _mesa_error(ctx
, GL_INVALID_ENUM
,
1330 "glTexParameter(bad GL_DEPTH_TEXTURE_MODE_ARB)");
1335 _mesa_error(ctx
, GL_INVALID_ENUM
,
1336 "glTexParameter(pname=GL_DEPTH_TEXTURE_MODE_ARB)");
1342 _mesa_error(ctx
, GL_INVALID_ENUM
,
1343 "glTexParameter(pname=0x%x)", pname
);
1347 texObj
->Complete
= GL_FALSE
;
1349 if (ctx
->Driver
.TexParameter
) {
1350 (*ctx
->Driver
.TexParameter
)( ctx
, target
, texObj
, pname
, params
);
1356 _mesa_TexParameteri( GLenum target
, GLenum pname
, GLint param
)
1359 fparam
[0] = (GLfloat
) param
;
1360 fparam
[1] = fparam
[2] = fparam
[3] = 0.0;
1361 _mesa_TexParameterfv(target
, pname
, fparam
);
1366 _mesa_TexParameteriv( GLenum target
, GLenum pname
, const GLint
*params
)
1369 if (pname
== GL_TEXTURE_BORDER_COLOR
) {
1370 fparam
[0] = INT_TO_FLOAT(params
[0]);
1371 fparam
[1] = INT_TO_FLOAT(params
[1]);
1372 fparam
[2] = INT_TO_FLOAT(params
[2]);
1373 fparam
[3] = INT_TO_FLOAT(params
[3]);
1376 fparam
[0] = (GLfloat
) params
[0];
1377 fparam
[1] = fparam
[2] = fparam
[3] = 0.0F
;
1379 _mesa_TexParameterfv(target
, pname
, fparam
);
1384 _mesa_GetTexLevelParameterfv( GLenum target
, GLint level
,
1385 GLenum pname
, GLfloat
*params
)
1388 _mesa_GetTexLevelParameteriv( target
, level
, pname
, &iparam
);
1389 *params
= (GLfloat
) iparam
;
1394 tex_image_dimensions(GLcontext
*ctx
, GLenum target
)
1398 case GL_PROXY_TEXTURE_1D
:
1401 case GL_PROXY_TEXTURE_2D
:
1404 case GL_PROXY_TEXTURE_3D
:
1406 case GL_TEXTURE_CUBE_MAP_ARB
:
1407 case GL_PROXY_TEXTURE_CUBE_MAP_ARB
:
1408 case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB
:
1409 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB
:
1410 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB
:
1411 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB
:
1412 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB
:
1413 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB
:
1414 return ctx
->Extensions
.ARB_texture_cube_map
? 2 : 0;
1415 case GL_TEXTURE_RECTANGLE_NV
:
1416 case GL_PROXY_TEXTURE_RECTANGLE_NV
:
1417 return ctx
->Extensions
.NV_texture_rectangle
? 2 : 0;
1419 _mesa_problem(ctx
, "bad target in _mesa_tex_target_dimensions()");
1426 _mesa_GetTexLevelParameteriv( GLenum target
, GLint level
,
1427 GLenum pname
, GLint
*params
)
1429 GET_CURRENT_CONTEXT(ctx
);
1430 const struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1431 const struct gl_texture_image
*img
= NULL
;
1435 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1437 /* this will catch bad target values */
1438 dimensions
= tex_image_dimensions(ctx
, target
); /* 1, 2 or 3 */
1439 if (dimensions
== 0) {
1440 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexLevelParameter[if]v(target)");
1446 case GL_PROXY_TEXTURE_1D
:
1448 case GL_PROXY_TEXTURE_2D
:
1449 maxLevels
= ctx
->Const
.MaxTextureLevels
;
1452 case GL_PROXY_TEXTURE_3D
:
1453 maxLevels
= ctx
->Const
.Max3DTextureLevels
;
1455 case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB
:
1456 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB
:
1457 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB
:
1458 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB
:
1459 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB
:
1460 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB
:
1461 case GL_PROXY_TEXTURE_CUBE_MAP_ARB
:
1462 maxLevels
= ctx
->Const
.MaxCubeTextureLevels
;
1464 case GL_TEXTURE_RECTANGLE_NV
:
1465 case GL_PROXY_TEXTURE_RECTANGLE_NV
:
1469 _mesa_problem(ctx
, "switch in _mesa_GetTexLevelParameter");
1473 if (level
< 0 || level
>= maxLevels
) {
1474 _mesa_error( ctx
, GL_INVALID_VALUE
, "glGetTexLevelParameter[if]v" );
1478 img
= _mesa_select_tex_image(ctx
, texUnit
, target
, level
);
1479 if (!img
|| !img
->TexFormat
) {
1480 /* undefined texture image */
1481 if (pname
== GL_TEXTURE_COMPONENTS
)
1488 isProxy
= (target
== GL_PROXY_TEXTURE_1D
) ||
1489 (target
== GL_PROXY_TEXTURE_2D
) ||
1490 (target
== GL_PROXY_TEXTURE_3D
) ||
1491 (target
== GL_PROXY_TEXTURE_CUBE_MAP_ARB
) ||
1492 (target
== GL_PROXY_TEXTURE_RECTANGLE_NV
);
1495 case GL_TEXTURE_WIDTH
:
1496 *params
= img
->Width
;
1498 case GL_TEXTURE_HEIGHT
:
1499 *params
= img
->Height
;
1501 case GL_TEXTURE_DEPTH
:
1502 *params
= img
->Depth
;
1504 case GL_TEXTURE_INTERNAL_FORMAT
:
1505 *params
= img
->IntFormat
;
1507 case GL_TEXTURE_BORDER
:
1508 *params
= img
->Border
;
1510 case GL_TEXTURE_RED_SIZE
:
1511 if (img
->Format
== GL_RGB
|| img
->Format
== GL_RGBA
)
1512 *params
= img
->TexFormat
->RedBits
;
1516 case GL_TEXTURE_GREEN_SIZE
:
1517 if (img
->Format
== GL_RGB
|| img
->Format
== GL_RGBA
)
1518 *params
= img
->TexFormat
->GreenBits
;
1522 case GL_TEXTURE_BLUE_SIZE
:
1523 if (img
->Format
== GL_RGB
|| img
->Format
== GL_RGBA
)
1524 *params
= img
->TexFormat
->BlueBits
;
1528 case GL_TEXTURE_ALPHA_SIZE
:
1529 if (img
->Format
== GL_ALPHA
|| img
->Format
== GL_LUMINANCE_ALPHA
||
1530 img
->Format
== GL_RGBA
)
1531 *params
= img
->TexFormat
->AlphaBits
;
1535 case GL_TEXTURE_INTENSITY_SIZE
:
1536 if (img
->Format
!= GL_INTENSITY
)
1538 else if (img
->TexFormat
->IntensityBits
> 0)
1539 *params
= img
->TexFormat
->IntensityBits
;
1540 else /* intensity probably stored as rgb texture */
1541 *params
= MIN2(img
->TexFormat
->RedBits
, img
->TexFormat
->GreenBits
);
1543 case GL_TEXTURE_LUMINANCE_SIZE
:
1544 if (img
->Format
!= GL_LUMINANCE
&&
1545 img
->Format
!= GL_LUMINANCE_ALPHA
)
1547 else if (img
->TexFormat
->LuminanceBits
> 0)
1548 *params
= img
->TexFormat
->LuminanceBits
;
1549 else /* luminance probably stored as rgb texture */
1550 *params
= MIN2(img
->TexFormat
->RedBits
, img
->TexFormat
->GreenBits
);
1552 case GL_TEXTURE_INDEX_SIZE_EXT
:
1553 if (img
->Format
== GL_COLOR_INDEX
)
1554 *params
= img
->TexFormat
->IndexBits
;
1559 /* XXX this isn't in the GL_SGIX_depth_texture spec
1560 * but seems appropriate.
1562 if (ctx
->Extensions
.SGIX_depth_texture
)
1563 *params
= img
->TexFormat
->DepthBits
;
1565 _mesa_error(ctx
, GL_INVALID_ENUM
,
1566 "glGetTexLevelParameter[if]v(pname)");
1569 /* GL_ARB_texture_compression */
1570 case GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB
:
1571 if (ctx
->Extensions
.ARB_texture_compression
) {
1572 if (img
->IsCompressed
&& !isProxy
)
1573 *params
= img
->CompressedSize
;
1575 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1576 "glGetTexLevelParameter[if]v(pname)");
1579 _mesa_error(ctx
, GL_INVALID_ENUM
,
1580 "glGetTexLevelParameter[if]v(pname)");
1583 case GL_TEXTURE_COMPRESSED_ARB
:
1584 if (ctx
->Extensions
.ARB_texture_compression
) {
1585 *params
= (GLint
) img
->IsCompressed
;
1588 _mesa_error(ctx
, GL_INVALID_ENUM
,
1589 "glGetTexLevelParameter[if]v(pname)");
1594 _mesa_error(ctx
, GL_INVALID_ENUM
,
1595 "glGetTexLevelParameter[if]v(pname)");
1602 _mesa_GetTexParameterfv( GLenum target
, GLenum pname
, GLfloat
*params
)
1604 GET_CURRENT_CONTEXT(ctx
);
1605 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1606 struct gl_texture_object
*obj
;
1607 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1609 obj
= _mesa_select_tex_object(ctx
, texUnit
, target
);
1611 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexParameterfv(target)");
1616 case GL_TEXTURE_MAG_FILTER
:
1617 *params
= ENUM_TO_FLOAT(obj
->MagFilter
);
1619 case GL_TEXTURE_MIN_FILTER
:
1620 *params
= ENUM_TO_FLOAT(obj
->MinFilter
);
1622 case GL_TEXTURE_WRAP_S
:
1623 *params
= ENUM_TO_FLOAT(obj
->WrapS
);
1625 case GL_TEXTURE_WRAP_T
:
1626 *params
= ENUM_TO_FLOAT(obj
->WrapT
);
1628 case GL_TEXTURE_WRAP_R_EXT
:
1629 *params
= ENUM_TO_FLOAT(obj
->WrapR
);
1631 case GL_TEXTURE_BORDER_COLOR
:
1632 params
[0] = CLAMP(obj
->BorderColor
[0], 0.0F
, 1.0F
);
1633 params
[1] = CLAMP(obj
->BorderColor
[1], 0.0F
, 1.0F
);
1634 params
[2] = CLAMP(obj
->BorderColor
[2], 0.0F
, 1.0F
);
1635 params
[3] = CLAMP(obj
->BorderColor
[3], 0.0F
, 1.0F
);
1637 case GL_TEXTURE_RESIDENT
:
1640 if (ctx
->Driver
.IsTextureResident
)
1641 resident
= ctx
->Driver
.IsTextureResident(ctx
, obj
);
1644 *params
= ENUM_TO_FLOAT(resident
);
1647 case GL_TEXTURE_PRIORITY
:
1648 *params
= obj
->Priority
;
1650 case GL_TEXTURE_MIN_LOD
:
1651 *params
= obj
->MinLod
;
1653 case GL_TEXTURE_MAX_LOD
:
1654 *params
= obj
->MaxLod
;
1656 case GL_TEXTURE_BASE_LEVEL
:
1657 *params
= (GLfloat
) obj
->BaseLevel
;
1659 case GL_TEXTURE_MAX_LEVEL
:
1660 *params
= (GLfloat
) obj
->MaxLevel
;
1662 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1663 if (ctx
->Extensions
.EXT_texture_filter_anisotropic
) {
1664 *params
= obj
->MaxAnisotropy
;
1668 case GL_TEXTURE_COMPARE_SGIX
:
1669 if (ctx
->Extensions
.SGIX_shadow
) {
1670 *params
= (GLfloat
) obj
->CompareFlag
;
1674 case GL_TEXTURE_COMPARE_OPERATOR_SGIX
:
1675 if (ctx
->Extensions
.SGIX_shadow
) {
1676 *params
= (GLfloat
) obj
->CompareOperator
;
1680 case GL_SHADOW_AMBIENT_SGIX
: /* aka GL_TEXTURE_COMPARE_FAIL_VALUE_ARB */
1681 if (ctx
->Extensions
.SGIX_shadow_ambient
) {
1682 *params
= obj
->ShadowAmbient
;
1686 case GL_GENERATE_MIPMAP_SGIS
:
1687 if (ctx
->Extensions
.SGIS_generate_mipmap
) {
1688 *params
= (GLfloat
) obj
->GenerateMipmap
;
1692 case GL_TEXTURE_COMPARE_MODE_ARB
:
1693 if (ctx
->Extensions
.ARB_shadow
) {
1694 *params
= (GLfloat
) obj
->CompareMode
;
1698 case GL_TEXTURE_COMPARE_FUNC_ARB
:
1699 if (ctx
->Extensions
.ARB_shadow
) {
1700 *params
= (GLfloat
) obj
->CompareFunc
;
1704 case GL_DEPTH_TEXTURE_MODE_ARB
:
1705 if (ctx
->Extensions
.ARB_depth_texture
) {
1706 *params
= (GLfloat
) obj
->DepthMode
;
1711 ; /* silence warnings */
1713 /* If we get here, pname was an unrecognized enum */
1714 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexParameterfv(pname)" );
1719 _mesa_GetTexParameteriv( GLenum target
, GLenum pname
, GLint
*params
)
1721 GET_CURRENT_CONTEXT(ctx
);
1722 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1723 struct gl_texture_object
*obj
;
1724 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1726 obj
= _mesa_select_tex_object(ctx
, texUnit
, target
);
1728 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexParameteriv(target)");
1733 case GL_TEXTURE_MAG_FILTER
:
1734 *params
= (GLint
) obj
->MagFilter
;
1736 case GL_TEXTURE_MIN_FILTER
:
1737 *params
= (GLint
) obj
->MinFilter
;
1739 case GL_TEXTURE_WRAP_S
:
1740 *params
= (GLint
) obj
->WrapS
;
1742 case GL_TEXTURE_WRAP_T
:
1743 *params
= (GLint
) obj
->WrapT
;
1745 case GL_TEXTURE_WRAP_R_EXT
:
1746 *params
= (GLint
) obj
->WrapR
;
1748 case GL_TEXTURE_BORDER_COLOR
:
1751 b
[0] = CLAMP(obj
->BorderColor
[0], 0.0F
, 1.0F
);
1752 b
[1] = CLAMP(obj
->BorderColor
[1], 0.0F
, 1.0F
);
1753 b
[2] = CLAMP(obj
->BorderColor
[2], 0.0F
, 1.0F
);
1754 b
[3] = CLAMP(obj
->BorderColor
[3], 0.0F
, 1.0F
);
1755 params
[0] = FLOAT_TO_INT(b
[0]);
1756 params
[1] = FLOAT_TO_INT(b
[1]);
1757 params
[2] = FLOAT_TO_INT(b
[2]);
1758 params
[3] = FLOAT_TO_INT(b
[3]);
1761 case GL_TEXTURE_RESIDENT
:
1764 if (ctx
->Driver
.IsTextureResident
)
1765 resident
= ctx
->Driver
.IsTextureResident(ctx
, obj
);
1768 *params
= (GLint
) resident
;
1771 case GL_TEXTURE_PRIORITY
:
1772 *params
= (GLint
) obj
->Priority
;
1774 case GL_TEXTURE_MIN_LOD
:
1775 *params
= (GLint
) obj
->MinLod
;
1777 case GL_TEXTURE_MAX_LOD
:
1778 *params
= (GLint
) obj
->MaxLod
;
1780 case GL_TEXTURE_BASE_LEVEL
:
1781 *params
= obj
->BaseLevel
;
1783 case GL_TEXTURE_MAX_LEVEL
:
1784 *params
= obj
->MaxLevel
;
1786 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1787 if (ctx
->Extensions
.EXT_texture_filter_anisotropic
) {
1788 *params
= (GLint
) obj
->MaxAnisotropy
;
1792 case GL_TEXTURE_COMPARE_SGIX
:
1793 if (ctx
->Extensions
.SGIX_shadow
) {
1794 *params
= (GLint
) obj
->CompareFlag
;
1798 case GL_TEXTURE_COMPARE_OPERATOR_SGIX
:
1799 if (ctx
->Extensions
.SGIX_shadow
) {
1800 *params
= (GLint
) obj
->CompareOperator
;
1804 case GL_SHADOW_AMBIENT_SGIX
: /* aka GL_TEXTURE_COMPARE_FAIL_VALUE_ARB */
1805 if (ctx
->Extensions
.SGIX_shadow_ambient
) {
1806 *params
= (GLint
) FLOAT_TO_INT(obj
->ShadowAmbient
);
1810 case GL_GENERATE_MIPMAP_SGIS
:
1811 if (ctx
->Extensions
.SGIS_generate_mipmap
) {
1812 *params
= (GLint
) obj
->GenerateMipmap
;
1816 case GL_TEXTURE_COMPARE_MODE_ARB
:
1817 if (ctx
->Extensions
.ARB_shadow
) {
1818 *params
= (GLint
) obj
->CompareMode
;
1822 case GL_TEXTURE_COMPARE_FUNC_ARB
:
1823 if (ctx
->Extensions
.ARB_shadow
) {
1824 *params
= (GLint
) obj
->CompareFunc
;
1828 case GL_DEPTH_TEXTURE_MODE_ARB
:
1829 if (ctx
->Extensions
.ARB_depth_texture
) {
1830 *params
= (GLint
) obj
->DepthMode
;
1835 ; /* silence warnings */
1837 /* If we get here, pname was an unrecognized enum */
1838 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexParameteriv(pname)" );
1844 /**********************************************************************/
1845 /* Texture Coord Generation */
1846 /**********************************************************************/
1850 _mesa_TexGenfv( GLenum coord
, GLenum pname
, const GLfloat
*params
)
1852 GET_CURRENT_CONTEXT(ctx
);
1853 GLuint tUnit
= ctx
->Texture
.CurrentUnit
;
1854 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[tUnit
];
1855 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1857 if (MESA_VERBOSE
&(VERBOSE_API
|VERBOSE_TEXTURE
))
1858 _mesa_debug(ctx
, "texGEN %s %s %x...\n",
1859 _mesa_lookup_enum_by_nr(coord
),
1860 _mesa_lookup_enum_by_nr(pname
),
1865 if (pname
==GL_TEXTURE_GEN_MODE
) {
1866 GLenum mode
= (GLenum
) (GLint
) *params
;
1869 case GL_OBJECT_LINEAR
:
1870 bits
= TEXGEN_OBJ_LINEAR
;
1873 bits
= TEXGEN_EYE_LINEAR
;
1875 case GL_REFLECTION_MAP_NV
:
1876 bits
= TEXGEN_REFLECTION_MAP_NV
;
1878 case GL_NORMAL_MAP_NV
:
1879 bits
= TEXGEN_NORMAL_MAP_NV
;
1882 bits
= TEXGEN_SPHERE_MAP
;
1885 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(param)" );
1888 if (texUnit
->GenModeS
== mode
)
1890 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1891 texUnit
->GenModeS
= mode
;
1892 texUnit
->_GenBitS
= bits
;
1894 else if (pname
==GL_OBJECT_PLANE
) {
1895 if (TEST_EQ_4V(texUnit
->ObjectPlaneS
, params
))
1897 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1898 texUnit
->ObjectPlaneS
[0] = params
[0];
1899 texUnit
->ObjectPlaneS
[1] = params
[1];
1900 texUnit
->ObjectPlaneS
[2] = params
[2];
1901 texUnit
->ObjectPlaneS
[3] = params
[3];
1903 else if (pname
==GL_EYE_PLANE
) {
1906 /* Transform plane equation by the inverse modelview matrix */
1907 if (ctx
->ModelviewMatrixStack
.Top
->flags
& MAT_DIRTY_INVERSE
) {
1908 _math_matrix_analyse( ctx
->ModelviewMatrixStack
.Top
);
1910 _mesa_transform_vector( tmp
, params
, ctx
->ModelviewMatrixStack
.Top
->inv
);
1911 if (TEST_EQ_4V(texUnit
->EyePlaneS
, tmp
))
1913 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1914 COPY_4FV(texUnit
->EyePlaneS
, tmp
);
1917 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(pname)" );
1922 if (pname
==GL_TEXTURE_GEN_MODE
) {
1923 GLenum mode
= (GLenum
) (GLint
) *params
;
1926 case GL_OBJECT_LINEAR
:
1927 bitt
= TEXGEN_OBJ_LINEAR
;
1930 bitt
= TEXGEN_EYE_LINEAR
;
1932 case GL_REFLECTION_MAP_NV
:
1933 bitt
= TEXGEN_REFLECTION_MAP_NV
;
1935 case GL_NORMAL_MAP_NV
:
1936 bitt
= TEXGEN_NORMAL_MAP_NV
;
1939 bitt
= TEXGEN_SPHERE_MAP
;
1942 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(param)" );
1945 if (texUnit
->GenModeT
== mode
)
1947 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1948 texUnit
->GenModeT
= mode
;
1949 texUnit
->_GenBitT
= bitt
;
1951 else if (pname
==GL_OBJECT_PLANE
) {
1952 if (TEST_EQ_4V(texUnit
->ObjectPlaneT
, params
))
1954 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1955 texUnit
->ObjectPlaneT
[0] = params
[0];
1956 texUnit
->ObjectPlaneT
[1] = params
[1];
1957 texUnit
->ObjectPlaneT
[2] = params
[2];
1958 texUnit
->ObjectPlaneT
[3] = params
[3];
1960 else if (pname
==GL_EYE_PLANE
) {
1962 /* Transform plane equation by the inverse modelview matrix */
1963 if (ctx
->ModelviewMatrixStack
.Top
->flags
& MAT_DIRTY_INVERSE
) {
1964 _math_matrix_analyse( ctx
->ModelviewMatrixStack
.Top
);
1966 _mesa_transform_vector( tmp
, params
, ctx
->ModelviewMatrixStack
.Top
->inv
);
1967 if (TEST_EQ_4V(texUnit
->EyePlaneT
, tmp
))
1969 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1970 COPY_4FV(texUnit
->EyePlaneT
, tmp
);
1973 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(pname)" );
1978 if (pname
==GL_TEXTURE_GEN_MODE
) {
1979 GLenum mode
= (GLenum
) (GLint
) *params
;
1982 case GL_OBJECT_LINEAR
:
1983 bitr
= TEXGEN_OBJ_LINEAR
;
1985 case GL_REFLECTION_MAP_NV
:
1986 bitr
= TEXGEN_REFLECTION_MAP_NV
;
1988 case GL_NORMAL_MAP_NV
:
1989 bitr
= TEXGEN_NORMAL_MAP_NV
;
1992 bitr
= TEXGEN_EYE_LINEAR
;
1995 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(param)" );
1998 if (texUnit
->GenModeR
== mode
)
2000 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
2001 texUnit
->GenModeR
= mode
;
2002 texUnit
->_GenBitR
= bitr
;
2004 else if (pname
==GL_OBJECT_PLANE
) {
2005 if (TEST_EQ_4V(texUnit
->ObjectPlaneR
, params
))
2007 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
2008 texUnit
->ObjectPlaneR
[0] = params
[0];
2009 texUnit
->ObjectPlaneR
[1] = params
[1];
2010 texUnit
->ObjectPlaneR
[2] = params
[2];
2011 texUnit
->ObjectPlaneR
[3] = params
[3];
2013 else if (pname
==GL_EYE_PLANE
) {
2015 /* Transform plane equation by the inverse modelview matrix */
2016 if (ctx
->ModelviewMatrixStack
.Top
->flags
& MAT_DIRTY_INVERSE
) {
2017 _math_matrix_analyse( ctx
->ModelviewMatrixStack
.Top
);
2019 _mesa_transform_vector( tmp
, params
, ctx
->ModelviewMatrixStack
.Top
->inv
);
2020 if (TEST_EQ_4V(texUnit
->EyePlaneR
, tmp
))
2022 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
2023 COPY_4FV(texUnit
->EyePlaneR
, tmp
);
2026 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(pname)" );
2031 if (pname
==GL_TEXTURE_GEN_MODE
) {
2032 GLenum mode
= (GLenum
) (GLint
) *params
;
2035 case GL_OBJECT_LINEAR
:
2036 bitq
= TEXGEN_OBJ_LINEAR
;
2039 bitq
= TEXGEN_EYE_LINEAR
;
2042 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(param)" );
2045 if (texUnit
->GenModeQ
== mode
)
2047 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
2048 texUnit
->GenModeQ
= mode
;
2049 texUnit
->_GenBitQ
= bitq
;
2051 else if (pname
==GL_OBJECT_PLANE
) {
2052 if (TEST_EQ_4V(texUnit
->ObjectPlaneQ
, params
))
2054 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
2055 texUnit
->ObjectPlaneQ
[0] = params
[0];
2056 texUnit
->ObjectPlaneQ
[1] = params
[1];
2057 texUnit
->ObjectPlaneQ
[2] = params
[2];
2058 texUnit
->ObjectPlaneQ
[3] = params
[3];
2060 else if (pname
==GL_EYE_PLANE
) {
2062 /* Transform plane equation by the inverse modelview matrix */
2063 if (ctx
->ModelviewMatrixStack
.Top
->flags
& MAT_DIRTY_INVERSE
) {
2064 _math_matrix_analyse( ctx
->ModelviewMatrixStack
.Top
);
2066 _mesa_transform_vector( tmp
, params
, ctx
->ModelviewMatrixStack
.Top
->inv
);
2067 if (TEST_EQ_4V(texUnit
->EyePlaneQ
, tmp
))
2069 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
2070 COPY_4FV(texUnit
->EyePlaneQ
, tmp
);
2073 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(pname)" );
2078 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(coord)" );
2082 if (ctx
->Driver
.TexGen
)
2083 ctx
->Driver
.TexGen( ctx
, coord
, pname
, params
);
2088 _mesa_TexGeniv(GLenum coord
, GLenum pname
, const GLint
*params
)
2091 p
[0] = (GLfloat
) params
[0];
2092 p
[1] = (GLfloat
) params
[1];
2093 p
[2] = (GLfloat
) params
[2];
2094 p
[3] = (GLfloat
) params
[3];
2095 _mesa_TexGenfv(coord
, pname
, p
);
2100 _mesa_TexGend(GLenum coord
, GLenum pname
, GLdouble param
)
2102 GLfloat p
= (GLfloat
) param
;
2103 _mesa_TexGenfv( coord
, pname
, &p
);
2108 _mesa_TexGendv(GLenum coord
, GLenum pname
, const GLdouble
*params
)
2111 p
[0] = (GLfloat
) params
[0];
2112 p
[1] = (GLfloat
) params
[1];
2113 p
[2] = (GLfloat
) params
[2];
2114 p
[3] = (GLfloat
) params
[3];
2115 _mesa_TexGenfv( coord
, pname
, p
);
2120 _mesa_TexGenf( GLenum coord
, GLenum pname
, GLfloat param
)
2122 _mesa_TexGenfv(coord
, pname
, ¶m
);
2127 _mesa_TexGeni( GLenum coord
, GLenum pname
, GLint param
)
2129 _mesa_TexGeniv( coord
, pname
, ¶m
);
2135 _mesa_GetTexGendv( GLenum coord
, GLenum pname
, GLdouble
*params
)
2137 GET_CURRENT_CONTEXT(ctx
);
2138 GLuint tUnit
= ctx
->Texture
.CurrentUnit
;
2139 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[tUnit
];
2140 ASSERT_OUTSIDE_BEGIN_END(ctx
);
2144 if (pname
==GL_TEXTURE_GEN_MODE
) {
2145 params
[0] = ENUM_TO_DOUBLE(texUnit
->GenModeS
);
2147 else if (pname
==GL_OBJECT_PLANE
) {
2148 COPY_4V( params
, texUnit
->ObjectPlaneS
);
2150 else if (pname
==GL_EYE_PLANE
) {
2151 COPY_4V( params
, texUnit
->EyePlaneS
);
2154 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGendv(pname)" );
2159 if (pname
==GL_TEXTURE_GEN_MODE
) {
2160 params
[0] = ENUM_TO_DOUBLE(texUnit
->GenModeT
);
2162 else if (pname
==GL_OBJECT_PLANE
) {
2163 COPY_4V( params
, texUnit
->ObjectPlaneT
);
2165 else if (pname
==GL_EYE_PLANE
) {
2166 COPY_4V( params
, texUnit
->EyePlaneT
);
2169 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGendv(pname)" );
2174 if (pname
==GL_TEXTURE_GEN_MODE
) {
2175 params
[0] = ENUM_TO_DOUBLE(texUnit
->GenModeR
);
2177 else if (pname
==GL_OBJECT_PLANE
) {
2178 COPY_4V( params
, texUnit
->ObjectPlaneR
);
2180 else if (pname
==GL_EYE_PLANE
) {
2181 COPY_4V( params
, texUnit
->EyePlaneR
);
2184 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGendv(pname)" );
2189 if (pname
==GL_TEXTURE_GEN_MODE
) {
2190 params
[0] = ENUM_TO_DOUBLE(texUnit
->GenModeQ
);
2192 else if (pname
==GL_OBJECT_PLANE
) {
2193 COPY_4V( params
, texUnit
->ObjectPlaneQ
);
2195 else if (pname
==GL_EYE_PLANE
) {
2196 COPY_4V( params
, texUnit
->EyePlaneQ
);
2199 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGendv(pname)" );
2204 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGendv(coord)" );
2212 _mesa_GetTexGenfv( GLenum coord
, GLenum pname
, GLfloat
*params
)
2214 GET_CURRENT_CONTEXT(ctx
);
2215 GLuint tUnit
= ctx
->Texture
.CurrentUnit
;
2216 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[tUnit
];
2217 ASSERT_OUTSIDE_BEGIN_END(ctx
);
2221 if (pname
==GL_TEXTURE_GEN_MODE
) {
2222 params
[0] = ENUM_TO_FLOAT(texUnit
->GenModeS
);
2224 else if (pname
==GL_OBJECT_PLANE
) {
2225 COPY_4V( params
, texUnit
->ObjectPlaneS
);
2227 else if (pname
==GL_EYE_PLANE
) {
2228 COPY_4V( params
, texUnit
->EyePlaneS
);
2231 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGenfv(pname)" );
2236 if (pname
==GL_TEXTURE_GEN_MODE
) {
2237 params
[0] = ENUM_TO_FLOAT(texUnit
->GenModeT
);
2239 else if (pname
==GL_OBJECT_PLANE
) {
2240 COPY_4V( params
, texUnit
->ObjectPlaneT
);
2242 else if (pname
==GL_EYE_PLANE
) {
2243 COPY_4V( params
, texUnit
->EyePlaneT
);
2246 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGenfv(pname)" );
2251 if (pname
==GL_TEXTURE_GEN_MODE
) {
2252 params
[0] = ENUM_TO_FLOAT(texUnit
->GenModeR
);
2254 else if (pname
==GL_OBJECT_PLANE
) {
2255 COPY_4V( params
, texUnit
->ObjectPlaneR
);
2257 else if (pname
==GL_EYE_PLANE
) {
2258 COPY_4V( params
, texUnit
->EyePlaneR
);
2261 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGenfv(pname)" );
2266 if (pname
==GL_TEXTURE_GEN_MODE
) {
2267 params
[0] = ENUM_TO_FLOAT(texUnit
->GenModeQ
);
2269 else if (pname
==GL_OBJECT_PLANE
) {
2270 COPY_4V( params
, texUnit
->ObjectPlaneQ
);
2272 else if (pname
==GL_EYE_PLANE
) {
2273 COPY_4V( params
, texUnit
->EyePlaneQ
);
2276 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGenfv(pname)" );
2281 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGenfv(coord)" );
2289 _mesa_GetTexGeniv( GLenum coord
, GLenum pname
, GLint
*params
)
2291 GET_CURRENT_CONTEXT(ctx
);
2292 GLuint tUnit
= ctx
->Texture
.CurrentUnit
;
2293 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[tUnit
];
2294 ASSERT_OUTSIDE_BEGIN_END(ctx
);
2298 if (pname
==GL_TEXTURE_GEN_MODE
) {
2299 params
[0] = texUnit
->GenModeS
;
2301 else if (pname
==GL_OBJECT_PLANE
) {
2302 params
[0] = (GLint
) texUnit
->ObjectPlaneS
[0];
2303 params
[1] = (GLint
) texUnit
->ObjectPlaneS
[1];
2304 params
[2] = (GLint
) texUnit
->ObjectPlaneS
[2];
2305 params
[3] = (GLint
) texUnit
->ObjectPlaneS
[3];
2307 else if (pname
==GL_EYE_PLANE
) {
2308 params
[0] = (GLint
) texUnit
->EyePlaneS
[0];
2309 params
[1] = (GLint
) texUnit
->EyePlaneS
[1];
2310 params
[2] = (GLint
) texUnit
->EyePlaneS
[2];
2311 params
[3] = (GLint
) texUnit
->EyePlaneS
[3];
2314 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGeniv(pname)" );
2319 if (pname
==GL_TEXTURE_GEN_MODE
) {
2320 params
[0] = texUnit
->GenModeT
;
2322 else if (pname
==GL_OBJECT_PLANE
) {
2323 params
[0] = (GLint
) texUnit
->ObjectPlaneT
[0];
2324 params
[1] = (GLint
) texUnit
->ObjectPlaneT
[1];
2325 params
[2] = (GLint
) texUnit
->ObjectPlaneT
[2];
2326 params
[3] = (GLint
) texUnit
->ObjectPlaneT
[3];
2328 else if (pname
==GL_EYE_PLANE
) {
2329 params
[0] = (GLint
) texUnit
->EyePlaneT
[0];
2330 params
[1] = (GLint
) texUnit
->EyePlaneT
[1];
2331 params
[2] = (GLint
) texUnit
->EyePlaneT
[2];
2332 params
[3] = (GLint
) texUnit
->EyePlaneT
[3];
2335 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGeniv(pname)" );
2340 if (pname
==GL_TEXTURE_GEN_MODE
) {
2341 params
[0] = texUnit
->GenModeR
;
2343 else if (pname
==GL_OBJECT_PLANE
) {
2344 params
[0] = (GLint
) texUnit
->ObjectPlaneR
[0];
2345 params
[1] = (GLint
) texUnit
->ObjectPlaneR
[1];
2346 params
[2] = (GLint
) texUnit
->ObjectPlaneR
[2];
2347 params
[3] = (GLint
) texUnit
->ObjectPlaneR
[3];
2349 else if (pname
==GL_EYE_PLANE
) {
2350 params
[0] = (GLint
) texUnit
->EyePlaneR
[0];
2351 params
[1] = (GLint
) texUnit
->EyePlaneR
[1];
2352 params
[2] = (GLint
) texUnit
->EyePlaneR
[2];
2353 params
[3] = (GLint
) texUnit
->EyePlaneR
[3];
2356 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGeniv(pname)" );
2361 if (pname
==GL_TEXTURE_GEN_MODE
) {
2362 params
[0] = texUnit
->GenModeQ
;
2364 else if (pname
==GL_OBJECT_PLANE
) {
2365 params
[0] = (GLint
) texUnit
->ObjectPlaneQ
[0];
2366 params
[1] = (GLint
) texUnit
->ObjectPlaneQ
[1];
2367 params
[2] = (GLint
) texUnit
->ObjectPlaneQ
[2];
2368 params
[3] = (GLint
) texUnit
->ObjectPlaneQ
[3];
2370 else if (pname
==GL_EYE_PLANE
) {
2371 params
[0] = (GLint
) texUnit
->EyePlaneQ
[0];
2372 params
[1] = (GLint
) texUnit
->EyePlaneQ
[1];
2373 params
[2] = (GLint
) texUnit
->EyePlaneQ
[2];
2374 params
[3] = (GLint
) texUnit
->EyePlaneQ
[3];
2377 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGeniv(pname)" );
2382 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGeniv(coord)" );
2388 /* GL_ARB_multitexture */
2390 _mesa_ActiveTextureARB( GLenum target
)
2392 GET_CURRENT_CONTEXT(ctx
);
2393 GLuint texUnit
= target
- GL_TEXTURE0_ARB
;
2394 ASSERT_OUTSIDE_BEGIN_END(ctx
);
2396 if (MESA_VERBOSE
& (VERBOSE_API
|VERBOSE_TEXTURE
))
2397 _mesa_debug(ctx
, "glActiveTexture %s\n",
2398 _mesa_lookup_enum_by_nr(target
));
2400 if (texUnit
> ctx
->Const
.MaxTextureUnits
) {
2401 _mesa_error(ctx
, GL_INVALID_ENUM
, "glActiveTextureARB(target)");
2405 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
2406 ctx
->Texture
.CurrentUnit
= texUnit
;
2407 if (ctx
->Driver
.ActiveTexture
) {
2408 (*ctx
->Driver
.ActiveTexture
)( ctx
, (GLuint
) texUnit
);
2413 /* GL_ARB_multitexture */
2415 _mesa_ClientActiveTextureARB( GLenum target
)
2417 GET_CURRENT_CONTEXT(ctx
);
2418 GLuint texUnit
= target
- GL_TEXTURE0_ARB
;
2419 ASSERT_OUTSIDE_BEGIN_END(ctx
);
2421 if (texUnit
> ctx
->Const
.MaxTextureUnits
) {
2422 _mesa_error(ctx
, GL_INVALID_ENUM
, "glClientActiveTextureARB(target)");
2426 FLUSH_VERTICES(ctx
, _NEW_ARRAY
);
2427 ctx
->Array
.ActiveTexture
= texUnit
;
2432 /**********************************************************************/
2433 /* Pixel Texgen Extensions */
2434 /**********************************************************************/
2437 _mesa_PixelTexGenSGIX(GLenum mode
)
2439 GLenum newRgbSource
, newAlphaSource
;
2440 GET_CURRENT_CONTEXT(ctx
);
2441 ASSERT_OUTSIDE_BEGIN_END(ctx
);
2445 newRgbSource
= GL_PIXEL_GROUP_COLOR_SGIS
;
2446 newAlphaSource
= GL_PIXEL_GROUP_COLOR_SGIS
;
2449 newRgbSource
= GL_PIXEL_GROUP_COLOR_SGIS
;
2450 newAlphaSource
= GL_CURRENT_RASTER_COLOR
;
2453 newRgbSource
= GL_CURRENT_RASTER_COLOR
;
2454 newAlphaSource
= GL_PIXEL_GROUP_COLOR_SGIS
;
2457 newRgbSource
= GL_CURRENT_RASTER_COLOR
;
2458 newAlphaSource
= GL_CURRENT_RASTER_COLOR
;
2461 _mesa_error(ctx
, GL_INVALID_ENUM
, "glPixelTexGenSGIX(mode)");
2465 if (newRgbSource
== ctx
->Pixel
.FragmentRgbSource
&&
2466 newAlphaSource
== ctx
->Pixel
.FragmentAlphaSource
)
2469 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
2470 ctx
->Pixel
.FragmentRgbSource
= newRgbSource
;
2471 ctx
->Pixel
.FragmentAlphaSource
= newAlphaSource
;
2476 _mesa_PixelTexGenParameterfSGIS(GLenum target
, GLfloat value
)
2478 _mesa_PixelTexGenParameteriSGIS(target
, (GLint
) value
);
2483 _mesa_PixelTexGenParameterfvSGIS(GLenum target
, const GLfloat
*value
)
2485 _mesa_PixelTexGenParameteriSGIS(target
, (GLint
) *value
);
2490 _mesa_PixelTexGenParameteriSGIS(GLenum target
, GLint value
)
2492 GET_CURRENT_CONTEXT(ctx
);
2493 ASSERT_OUTSIDE_BEGIN_END(ctx
);
2495 if (value
!= GL_CURRENT_RASTER_COLOR
&& value
!= GL_PIXEL_GROUP_COLOR_SGIS
) {
2496 _mesa_error(ctx
, GL_INVALID_ENUM
, "glPixelTexGenParameterSGIS(value)");
2501 case GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS
:
2502 if (ctx
->Pixel
.FragmentRgbSource
== (GLenum
) value
)
2504 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
2505 ctx
->Pixel
.FragmentRgbSource
= (GLenum
) value
;
2507 case GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS
:
2508 if (ctx
->Pixel
.FragmentAlphaSource
== (GLenum
) value
)
2510 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
2511 ctx
->Pixel
.FragmentAlphaSource
= (GLenum
) value
;
2514 _mesa_error(ctx
, GL_INVALID_ENUM
, "glPixelTexGenParameterSGIS(target)");
2521 _mesa_PixelTexGenParameterivSGIS(GLenum target
, const GLint
*value
)
2523 _mesa_PixelTexGenParameteriSGIS(target
, *value
);
2528 _mesa_GetPixelTexGenParameterfvSGIS(GLenum target
, GLfloat
*value
)
2530 GET_CURRENT_CONTEXT(ctx
);
2531 ASSERT_OUTSIDE_BEGIN_END(ctx
);
2533 if (target
== GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS
) {
2534 *value
= (GLfloat
) ctx
->Pixel
.FragmentRgbSource
;
2536 else if (target
== GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS
) {
2537 *value
= (GLfloat
) ctx
->Pixel
.FragmentAlphaSource
;
2540 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetPixelTexGenParameterfvSGIS(target)");
2546 _mesa_GetPixelTexGenParameterivSGIS(GLenum target
, GLint
*value
)
2548 GET_CURRENT_CONTEXT(ctx
);
2549 ASSERT_OUTSIDE_BEGIN_END(ctx
);
2551 if (target
== GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS
) {
2552 *value
= (GLint
) ctx
->Pixel
.FragmentRgbSource
;
2554 else if (target
== GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS
) {
2555 *value
= (GLint
) ctx
->Pixel
.FragmentAlphaSource
;
2558 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetPixelTexGenParameterivSGIS(target)");