1 /* $Id: texstate.c,v 1.79 2002/09/27 02:45:38 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.
35 #include "extensions.h"
41 #include "math/m_xform.h"
42 #include "math/m_matrix.h"
48 /* Needed for an Amiga compiler */
49 #define ENUM_TO_FLOAT(X) ((GLfloat)(GLint)(X))
50 #define ENUM_TO_DOUBLE(X) ((GLdouble)(GLint)(X))
52 /* all other compilers */
53 #define ENUM_TO_FLOAT(X) ((GLfloat)(X))
54 #define ENUM_TO_DOUBLE(X) ((GLdouble)(X))
60 _mesa_copy_texture_state( const GLcontext
*src
, GLcontext
*dst
)
67 dst
->Texture
.CurrentUnit
= src
->Texture
.CurrentUnit
;
68 dst
->Texture
._GenFlags
= src
->Texture
._GenFlags
;
69 dst
->Texture
._TexGenEnabled
= src
->Texture
._TexGenEnabled
;
70 dst
->Texture
._TexMatEnabled
= src
->Texture
._TexMatEnabled
;
71 dst
->Texture
.SharedPalette
= src
->Texture
.SharedPalette
;
74 for (i
= 0; i
< src
->Const
.MaxTextureUnits
; i
++) {
75 dst
->Texture
.Unit
[i
].Enabled
= src
->Texture
.Unit
[i
].Enabled
;
76 dst
->Texture
.Unit
[i
].EnvMode
= src
->Texture
.Unit
[i
].EnvMode
;
77 COPY_4V(dst
->Texture
.Unit
[i
].EnvColor
, src
->Texture
.Unit
[i
].EnvColor
);
78 dst
->Texture
.Unit
[i
].TexGenEnabled
= src
->Texture
.Unit
[i
].TexGenEnabled
;
79 dst
->Texture
.Unit
[i
].GenModeS
= src
->Texture
.Unit
[i
].GenModeS
;
80 dst
->Texture
.Unit
[i
].GenModeT
= src
->Texture
.Unit
[i
].GenModeT
;
81 dst
->Texture
.Unit
[i
].GenModeR
= src
->Texture
.Unit
[i
].GenModeR
;
82 dst
->Texture
.Unit
[i
].GenModeQ
= src
->Texture
.Unit
[i
].GenModeQ
;
83 dst
->Texture
.Unit
[i
]._GenBitS
= src
->Texture
.Unit
[i
]._GenBitS
;
84 dst
->Texture
.Unit
[i
]._GenBitT
= src
->Texture
.Unit
[i
]._GenBitT
;
85 dst
->Texture
.Unit
[i
]._GenBitR
= src
->Texture
.Unit
[i
]._GenBitR
;
86 dst
->Texture
.Unit
[i
]._GenBitQ
= src
->Texture
.Unit
[i
]._GenBitQ
;
87 dst
->Texture
.Unit
[i
]._GenFlags
= src
->Texture
.Unit
[i
]._GenFlags
;
88 COPY_4V(dst
->Texture
.Unit
[i
].ObjectPlaneS
, src
->Texture
.Unit
[i
].ObjectPlaneS
);
89 COPY_4V(dst
->Texture
.Unit
[i
].ObjectPlaneT
, src
->Texture
.Unit
[i
].ObjectPlaneT
);
90 COPY_4V(dst
->Texture
.Unit
[i
].ObjectPlaneR
, src
->Texture
.Unit
[i
].ObjectPlaneR
);
91 COPY_4V(dst
->Texture
.Unit
[i
].ObjectPlaneQ
, src
->Texture
.Unit
[i
].ObjectPlaneQ
);
92 COPY_4V(dst
->Texture
.Unit
[i
].EyePlaneS
, src
->Texture
.Unit
[i
].EyePlaneS
);
93 COPY_4V(dst
->Texture
.Unit
[i
].EyePlaneT
, src
->Texture
.Unit
[i
].EyePlaneT
);
94 COPY_4V(dst
->Texture
.Unit
[i
].EyePlaneR
, src
->Texture
.Unit
[i
].EyePlaneR
);
95 COPY_4V(dst
->Texture
.Unit
[i
].EyePlaneQ
, src
->Texture
.Unit
[i
].EyePlaneQ
);
96 dst
->Texture
.Unit
[i
].LodBias
= src
->Texture
.Unit
[i
].LodBias
;
98 /* GL_EXT_texture_env_combine */
99 dst
->Texture
.Unit
[i
].CombineModeRGB
= src
->Texture
.Unit
[i
].CombineModeRGB
;
100 dst
->Texture
.Unit
[i
].CombineModeA
= src
->Texture
.Unit
[i
].CombineModeA
;
101 COPY_3V(dst
->Texture
.Unit
[i
].CombineSourceRGB
, src
->Texture
.Unit
[i
].CombineSourceRGB
);
102 COPY_3V(dst
->Texture
.Unit
[i
].CombineSourceA
, src
->Texture
.Unit
[i
].CombineSourceA
);
103 COPY_3V(dst
->Texture
.Unit
[i
].CombineOperandRGB
, src
->Texture
.Unit
[i
].CombineOperandRGB
);
104 COPY_3V(dst
->Texture
.Unit
[i
].CombineOperandA
, src
->Texture
.Unit
[i
].CombineOperandA
);
105 dst
->Texture
.Unit
[i
].CombineScaleShiftRGB
= src
->Texture
.Unit
[i
].CombineScaleShiftRGB
;
106 dst
->Texture
.Unit
[i
].CombineScaleShiftA
= src
->Texture
.Unit
[i
].CombineScaleShiftA
;
108 /* texture object state */
109 _mesa_copy_texture_object(dst
->Texture
.Unit
[i
].Current1D
,
110 src
->Texture
.Unit
[i
].Current1D
);
111 _mesa_copy_texture_object(dst
->Texture
.Unit
[i
].Current2D
,
112 src
->Texture
.Unit
[i
].Current2D
);
113 _mesa_copy_texture_object(dst
->Texture
.Unit
[i
].Current3D
,
114 src
->Texture
.Unit
[i
].Current3D
);
115 _mesa_copy_texture_object(dst
->Texture
.Unit
[i
].CurrentCubeMap
,
116 src
->Texture
.Unit
[i
].CurrentCubeMap
);
121 /**********************************************************************/
122 /* Texture Environment */
123 /**********************************************************************/
127 _mesa_TexEnvfv( GLenum target
, GLenum pname
, const GLfloat
*param
)
129 GET_CURRENT_CONTEXT(ctx
);
130 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
131 ASSERT_OUTSIDE_BEGIN_END(ctx
);
133 #define TE_ERROR(errCode, msg, value) \
134 _mesa_error(ctx, errCode, msg, _mesa_lookup_enum_by_nr(value));
136 if (target
== GL_TEXTURE_ENV
) {
138 case GL_TEXTURE_ENV_MODE
:
140 const GLenum mode
= (GLenum
) (GLint
) *param
;
141 if (mode
== GL_MODULATE
||
144 mode
== GL_REPLACE
||
145 (mode
== GL_ADD
&& ctx
->Extensions
.EXT_texture_env_add
) ||
146 (mode
== GL_COMBINE_EXT
&&
147 (ctx
->Extensions
.EXT_texture_env_combine
||
148 ctx
->Extensions
.ARB_texture_env_combine
))) {
150 if (texUnit
->EnvMode
== mode
)
152 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
153 texUnit
->EnvMode
= mode
;
156 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", mode
);
161 case GL_TEXTURE_ENV_COLOR
:
164 tmp
[0] = CLAMP( param
[0], 0.0F
, 1.0F
);
165 tmp
[1] = CLAMP( param
[1], 0.0F
, 1.0F
);
166 tmp
[2] = CLAMP( param
[2], 0.0F
, 1.0F
);
167 tmp
[3] = CLAMP( param
[3], 0.0F
, 1.0F
);
168 if (TEST_EQ_4V(tmp
, texUnit
->EnvColor
))
170 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
171 COPY_4FV(texUnit
->EnvColor
, tmp
);
174 case GL_COMBINE_RGB_EXT
:
175 if (ctx
->Extensions
.EXT_texture_env_combine
||
176 ctx
->Extensions
.ARB_texture_env_combine
) {
177 const GLenum mode
= (GLenum
) (GLint
) *param
;
182 case GL_ADD_SIGNED_EXT
:
183 case GL_INTERPOLATE_EXT
:
186 case GL_SUBTRACT_ARB
:
187 if (!ctx
->Extensions
.ARB_texture_env_combine
) {
188 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", mode
);
192 case GL_DOT3_RGB_EXT
:
193 case GL_DOT3_RGBA_EXT
:
194 if (!ctx
->Extensions
.EXT_texture_env_dot3
) {
195 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", mode
);
199 case GL_DOT3_RGB_ARB
:
200 case GL_DOT3_RGBA_ARB
:
201 if (!ctx
->Extensions
.ARB_texture_env_dot3
) {
202 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", mode
);
207 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", mode
);
210 if (texUnit
->CombineModeRGB
== mode
)
212 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
213 texUnit
->CombineModeRGB
= mode
;
216 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(pname=%s)", pname
);
220 case GL_COMBINE_ALPHA_EXT
:
221 if (ctx
->Extensions
.EXT_texture_env_combine
||
222 ctx
->Extensions
.ARB_texture_env_combine
) {
223 const GLenum mode
= (GLenum
) (GLint
) *param
;
224 if (mode
== GL_REPLACE
||
225 mode
== GL_MODULATE
||
227 mode
== GL_ADD_SIGNED_EXT
||
228 mode
== GL_INTERPOLATE_EXT
||
229 (mode
== GL_SUBTRACT_ARB
&&
230 ctx
->Extensions
.ARB_texture_env_combine
)) {
232 if (texUnit
->CombineModeA
== mode
)
234 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
235 texUnit
->CombineModeA
= mode
;
238 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", mode
);
243 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(pname=%s)", pname
);
247 case GL_SOURCE0_RGB_EXT
:
248 case GL_SOURCE1_RGB_EXT
:
249 case GL_SOURCE2_RGB_EXT
:
250 if (ctx
->Extensions
.EXT_texture_env_combine
||
251 ctx
->Extensions
.ARB_texture_env_combine
) {
252 const GLenum source
= (GLenum
) (GLint
) *param
;
253 const GLuint s
= pname
- GL_SOURCE0_RGB_EXT
;
254 if (source
== GL_TEXTURE
||
255 source
== GL_CONSTANT_EXT
||
256 source
== GL_PRIMARY_COLOR_EXT
||
257 source
== GL_PREVIOUS_EXT
||
258 (ctx
->Extensions
.ARB_texture_env_crossbar
&&
259 source
>= GL_TEXTURE0_ARB
&&
260 source
< GL_TEXTURE0_ARB
+ ctx
->Const
.MaxTextureUnits
)) {
262 if (texUnit
->CombineSourceRGB
[s
] == source
)
264 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
265 texUnit
->CombineSourceRGB
[s
] = source
;
268 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", source
);
273 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(pname=%s)", pname
);
277 case GL_SOURCE0_ALPHA_EXT
:
278 case GL_SOURCE1_ALPHA_EXT
:
279 case GL_SOURCE2_ALPHA_EXT
:
280 if (ctx
->Extensions
.EXT_texture_env_combine
||
281 ctx
->Extensions
.ARB_texture_env_combine
) {
282 const GLenum source
= (GLenum
) (GLint
) *param
;
283 const GLuint s
= pname
- GL_SOURCE0_ALPHA_EXT
;
284 if (source
== GL_TEXTURE
||
285 source
== GL_CONSTANT_EXT
||
286 source
== GL_PRIMARY_COLOR_EXT
||
287 source
== GL_PREVIOUS_EXT
||
288 (ctx
->Extensions
.ARB_texture_env_crossbar
&&
289 source
>= GL_TEXTURE0_ARB
&&
290 source
< GL_TEXTURE0_ARB
+ ctx
->Const
.MaxTextureUnits
)) {
292 if (texUnit
->CombineSourceA
[s
] == source
)
294 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
295 texUnit
->CombineSourceA
[s
] = source
;
298 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", source
);
303 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(pname=%s)", pname
);
307 case GL_OPERAND0_RGB_EXT
:
308 case GL_OPERAND1_RGB_EXT
:
309 if (ctx
->Extensions
.EXT_texture_env_combine
||
310 ctx
->Extensions
.ARB_texture_env_combine
) {
311 const GLenum operand
= (GLenum
) (GLint
) *param
;
312 const GLuint s
= pname
- GL_OPERAND0_RGB_EXT
;
315 case GL_ONE_MINUS_SRC_COLOR
:
317 case GL_ONE_MINUS_SRC_ALPHA
:
318 if (texUnit
->CombineOperandRGB
[s
] == operand
)
320 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
321 texUnit
->CombineOperandRGB
[s
] = operand
;
324 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", operand
);
329 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(pname=%s)", pname
);
333 case GL_OPERAND0_ALPHA_EXT
:
334 case GL_OPERAND1_ALPHA_EXT
:
335 if (ctx
->Extensions
.EXT_texture_env_combine
||
336 ctx
->Extensions
.ARB_texture_env_combine
) {
337 const GLenum operand
= (GLenum
) (GLint
) *param
;
340 case GL_ONE_MINUS_SRC_ALPHA
:
341 if (texUnit
->CombineOperandA
[pname
-GL_OPERAND0_ALPHA_EXT
] ==
344 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
345 texUnit
->CombineOperandA
[pname
-GL_OPERAND0_ALPHA_EXT
] = operand
;
348 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", operand
);
353 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(pname=%s)", pname
);
357 case GL_OPERAND2_RGB_EXT
:
358 if (ctx
->Extensions
.EXT_texture_env_combine
||
359 ctx
->Extensions
.ARB_texture_env_combine
) {
360 const GLenum operand
= (GLenum
) (GLint
) *param
;
362 case GL_SRC_COLOR
: /* ARB combine only */
363 case GL_ONE_MINUS_SRC_COLOR
: /* ARB combine only */
365 case GL_ONE_MINUS_SRC_ALPHA
: /* ARB combine only */
366 if (texUnit
->CombineOperandRGB
[2] == operand
)
368 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
369 texUnit
->CombineOperandRGB
[2] = operand
;
371 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", operand
);
376 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(pname=%s)", pname
);
380 case GL_OPERAND2_ALPHA_EXT
:
381 if (ctx
->Extensions
.EXT_texture_env_combine
||
382 ctx
->Extensions
.ARB_texture_env_combine
) {
383 const GLenum operand
= (GLenum
) (GLint
) *param
;
386 case GL_ONE_MINUS_SRC_ALPHA
: /* ARB combine only */
387 if (texUnit
->CombineOperandA
[2] == operand
)
389 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
390 texUnit
->CombineOperandA
[2] = operand
;
393 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", operand
);
398 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(pname=%s)", pname
);
402 case GL_RGB_SCALE_EXT
:
403 if (ctx
->Extensions
.EXT_texture_env_combine
||
404 ctx
->Extensions
.ARB_texture_env_combine
) {
409 else if (*param
== 2.0) {
412 else if (*param
== 4.0) {
416 _mesa_error( ctx
, GL_INVALID_VALUE
,
417 "glTexEnv(GL_RGB_SCALE not 1, 2 or 4)" );
420 if (texUnit
->CombineScaleShiftRGB
== newshift
)
422 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
423 texUnit
->CombineScaleShiftRGB
= newshift
;
426 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(pname=%s)", pname
);
431 if (ctx
->Extensions
.EXT_texture_env_combine
||
432 ctx
->Extensions
.ARB_texture_env_combine
) {
437 else if (*param
== 2.0) {
440 else if (*param
== 4.0) {
444 _mesa_error( ctx
, GL_INVALID_VALUE
,
445 "glTexEnv(GL_ALPHA_SCALE not 1, 2 or 4)" );
448 if (texUnit
->CombineScaleShiftA
== newshift
)
450 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
451 texUnit
->CombineScaleShiftA
= newshift
;
454 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(pname=%s)", pname
);
459 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexEnv(pname)" );
463 else if (target
== GL_TEXTURE_FILTER_CONTROL_EXT
) {
464 /* GL_EXT_texture_lod_bias */
465 if (!ctx
->Extensions
.EXT_texture_lod_bias
) {
466 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexEnv(target=0x%x)", target
);
469 if (pname
== GL_TEXTURE_LOD_BIAS_EXT
) {
470 if (texUnit
->LodBias
== param
[0])
472 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
473 texUnit
->LodBias
= CLAMP(param
[0], -ctx
->Const
.MaxTextureLodBias
,
474 ctx
->Const
.MaxTextureLodBias
);
477 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(pname=%s)", pname
);
481 else if (target
== GL_POINT_SPRITE_NV
) {
482 /* GL_NV_point_sprite */
483 if (!ctx
->Extensions
.NV_point_sprite
) {
484 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexEnv(target=0x%x)", target
);
487 if (pname
== GL_COORD_REPLACE_NV
) {
488 const GLenum value
= (GLenum
) param
[0];
489 if (value
== GL_TRUE
|| value
== GL_FALSE
) {
490 /* It's kind of weird to set point state via glTexEnv,
491 * but that's what the spec calls for.
493 const GLboolean state
= (GLboolean
) value
;
494 if (ctx
->Point
.CoordReplace
[ctx
->Texture
.CurrentUnit
] == state
)
496 FLUSH_VERTICES(ctx
, _NEW_POINT
);
497 ctx
->Point
.CoordReplace
[ctx
->Texture
.CurrentUnit
] = state
;
500 _mesa_error( ctx
, GL_INVALID_VALUE
, "glTexEnv(param=0x%x)", value
);
505 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexEnv(pname=0x%x)", pname
);
510 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexEnv(target=0x%x)",target
);
514 if (MESA_VERBOSE
&(VERBOSE_API
|VERBOSE_TEXTURE
))
515 _mesa_debug(ctx
, "glTexEnv %s %s %.1f(%s) ...\n",
516 _mesa_lookup_enum_by_nr(target
),
517 _mesa_lookup_enum_by_nr(pname
),
519 _mesa_lookup_enum_by_nr((GLenum
) (GLint
) *param
));
521 /* Tell device driver about the new texture environment */
522 if (ctx
->Driver
.TexEnv
) {
523 (*ctx
->Driver
.TexEnv
)( ctx
, target
, pname
, param
);
529 _mesa_TexEnvf( GLenum target
, GLenum pname
, GLfloat param
)
531 _mesa_TexEnvfv( target
, pname
, ¶m
);
537 _mesa_TexEnvi( GLenum target
, GLenum pname
, GLint param
)
540 p
[0] = (GLfloat
) param
;
541 p
[1] = p
[2] = p
[3] = 0.0;
542 _mesa_TexEnvfv( target
, pname
, p
);
547 _mesa_TexEnviv( GLenum target
, GLenum pname
, const GLint
*param
)
550 if (pname
== GL_TEXTURE_ENV_COLOR
) {
551 p
[0] = INT_TO_FLOAT( param
[0] );
552 p
[1] = INT_TO_FLOAT( param
[1] );
553 p
[2] = INT_TO_FLOAT( param
[2] );
554 p
[3] = INT_TO_FLOAT( param
[3] );
557 p
[0] = (GLint
) param
[0];
558 p
[1] = p
[2] = p
[3] = 0; /* init to zero, just to be safe */
560 _mesa_TexEnvfv( target
, pname
, p
);
565 _mesa_GetTexEnvfv( GLenum target
, GLenum pname
, GLfloat
*params
)
567 GET_CURRENT_CONTEXT(ctx
);
568 const struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
569 ASSERT_OUTSIDE_BEGIN_END(ctx
);
571 if (target
== GL_TEXTURE_ENV
) {
573 case GL_TEXTURE_ENV_MODE
:
574 *params
= ENUM_TO_FLOAT(texUnit
->EnvMode
);
576 case GL_TEXTURE_ENV_COLOR
:
577 COPY_4FV( params
, texUnit
->EnvColor
);
579 case GL_COMBINE_RGB_EXT
:
580 if (ctx
->Extensions
.EXT_texture_env_combine
||
581 ctx
->Extensions
.ARB_texture_env_combine
) {
582 *params
= (GLfloat
) texUnit
->CombineModeRGB
;
585 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
588 case GL_COMBINE_ALPHA_EXT
:
589 if (ctx
->Extensions
.EXT_texture_env_combine
||
590 ctx
->Extensions
.ARB_texture_env_combine
) {
591 *params
= (GLfloat
) texUnit
->CombineModeA
;
594 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
597 case GL_SOURCE0_RGB_EXT
:
598 if (ctx
->Extensions
.EXT_texture_env_combine
||
599 ctx
->Extensions
.ARB_texture_env_combine
) {
600 *params
= (GLfloat
) texUnit
->CombineSourceRGB
[0];
603 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
606 case GL_SOURCE1_RGB_EXT
:
607 if (ctx
->Extensions
.EXT_texture_env_combine
||
608 ctx
->Extensions
.ARB_texture_env_combine
) {
609 *params
= (GLfloat
) texUnit
->CombineSourceRGB
[1];
612 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
615 case GL_SOURCE2_RGB_EXT
:
616 if (ctx
->Extensions
.EXT_texture_env_combine
||
617 ctx
->Extensions
.ARB_texture_env_combine
) {
618 *params
= (GLfloat
) texUnit
->CombineSourceRGB
[2];
621 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
624 case GL_SOURCE0_ALPHA_EXT
:
625 if (ctx
->Extensions
.EXT_texture_env_combine
||
626 ctx
->Extensions
.ARB_texture_env_combine
) {
627 *params
= (GLfloat
) texUnit
->CombineSourceA
[0];
630 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
633 case GL_SOURCE1_ALPHA_EXT
:
634 if (ctx
->Extensions
.EXT_texture_env_combine
||
635 ctx
->Extensions
.ARB_texture_env_combine
) {
636 *params
= (GLfloat
) texUnit
->CombineSourceA
[1];
639 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
642 case GL_SOURCE2_ALPHA_EXT
:
643 if (ctx
->Extensions
.EXT_texture_env_combine
||
644 ctx
->Extensions
.ARB_texture_env_combine
) {
645 *params
= (GLfloat
) texUnit
->CombineSourceA
[2];
648 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
651 case GL_OPERAND0_RGB_EXT
:
652 if (ctx
->Extensions
.EXT_texture_env_combine
||
653 ctx
->Extensions
.ARB_texture_env_combine
) {
654 *params
= (GLfloat
) texUnit
->CombineOperandRGB
[0];
657 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
660 case GL_OPERAND1_RGB_EXT
:
661 if (ctx
->Extensions
.EXT_texture_env_combine
||
662 ctx
->Extensions
.ARB_texture_env_combine
) {
663 *params
= (GLfloat
) texUnit
->CombineOperandRGB
[1];
666 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
669 case GL_OPERAND2_RGB_EXT
:
670 if (ctx
->Extensions
.EXT_texture_env_combine
||
671 ctx
->Extensions
.ARB_texture_env_combine
) {
672 *params
= (GLfloat
) texUnit
->CombineOperandRGB
[2];
675 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
678 case GL_OPERAND0_ALPHA_EXT
:
679 if (ctx
->Extensions
.EXT_texture_env_combine
||
680 ctx
->Extensions
.ARB_texture_env_combine
) {
681 *params
= (GLfloat
) texUnit
->CombineOperandA
[0];
684 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
687 case GL_OPERAND1_ALPHA_EXT
:
688 if (ctx
->Extensions
.EXT_texture_env_combine
||
689 ctx
->Extensions
.ARB_texture_env_combine
) {
690 *params
= (GLfloat
) texUnit
->CombineOperandA
[1];
693 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
696 case GL_OPERAND2_ALPHA_EXT
:
697 if (ctx
->Extensions
.EXT_texture_env_combine
||
698 ctx
->Extensions
.ARB_texture_env_combine
) {
699 *params
= (GLfloat
) texUnit
->CombineOperandA
[2];
702 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
705 case GL_RGB_SCALE_EXT
:
706 if (ctx
->Extensions
.EXT_texture_env_combine
||
707 ctx
->Extensions
.ARB_texture_env_combine
) {
708 if (texUnit
->CombineScaleShiftRGB
== 0)
710 else if (texUnit
->CombineScaleShiftRGB
== 1)
716 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
721 if (ctx
->Extensions
.EXT_texture_env_combine
||
722 ctx
->Extensions
.ARB_texture_env_combine
) {
723 if (texUnit
->CombineScaleShiftA
== 0)
725 else if (texUnit
->CombineScaleShiftA
== 1)
731 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
736 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)" );
739 else if (target
== GL_TEXTURE_FILTER_CONTROL_EXT
) {
740 /* GL_EXT_texture_lod_bias */
741 if (!ctx
->Extensions
.EXT_texture_lod_bias
) {
742 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(target)" );
745 if (pname
== GL_TEXTURE_LOD_BIAS_EXT
) {
746 *params
= texUnit
->LodBias
;
749 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)" );
753 else if (target
== GL_POINT_SPRITE_NV
) {
754 /* GL_NV_point_sprite */
755 if (!ctx
->Extensions
.NV_point_sprite
) {
756 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(target)" );
759 if (pname
== GL_COORD_REPLACE_NV
) {
760 *params
= (GLfloat
) ctx
->Point
.CoordReplace
[ctx
->Texture
.CurrentUnit
];
763 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)" );
768 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(target)" );
775 _mesa_GetTexEnviv( GLenum target
, GLenum pname
, GLint
*params
)
777 GET_CURRENT_CONTEXT(ctx
);
778 const struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
779 ASSERT_OUTSIDE_BEGIN_END(ctx
);
781 if (target
== GL_TEXTURE_ENV
) {
783 case GL_TEXTURE_ENV_MODE
:
784 *params
= (GLint
) texUnit
->EnvMode
;
786 case GL_TEXTURE_ENV_COLOR
:
787 params
[0] = FLOAT_TO_INT( texUnit
->EnvColor
[0] );
788 params
[1] = FLOAT_TO_INT( texUnit
->EnvColor
[1] );
789 params
[2] = FLOAT_TO_INT( texUnit
->EnvColor
[2] );
790 params
[3] = FLOAT_TO_INT( texUnit
->EnvColor
[3] );
792 case GL_COMBINE_RGB_EXT
:
793 if (ctx
->Extensions
.EXT_texture_env_combine
||
794 ctx
->Extensions
.ARB_texture_env_combine
) {
795 *params
= (GLint
) texUnit
->CombineModeRGB
;
798 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
801 case GL_COMBINE_ALPHA_EXT
:
802 if (ctx
->Extensions
.EXT_texture_env_combine
||
803 ctx
->Extensions
.ARB_texture_env_combine
) {
804 *params
= (GLint
) texUnit
->CombineModeA
;
807 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
810 case GL_SOURCE0_RGB_EXT
:
811 if (ctx
->Extensions
.EXT_texture_env_combine
||
812 ctx
->Extensions
.ARB_texture_env_combine
) {
813 *params
= (GLint
) texUnit
->CombineSourceRGB
[0];
816 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
819 case GL_SOURCE1_RGB_EXT
:
820 if (ctx
->Extensions
.EXT_texture_env_combine
||
821 ctx
->Extensions
.ARB_texture_env_combine
) {
822 *params
= (GLint
) texUnit
->CombineSourceRGB
[1];
825 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
828 case GL_SOURCE2_RGB_EXT
:
829 if (ctx
->Extensions
.EXT_texture_env_combine
||
830 ctx
->Extensions
.ARB_texture_env_combine
) {
831 *params
= (GLint
) texUnit
->CombineSourceRGB
[2];
834 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
837 case GL_SOURCE0_ALPHA_EXT
:
838 if (ctx
->Extensions
.EXT_texture_env_combine
||
839 ctx
->Extensions
.ARB_texture_env_combine
) {
840 *params
= (GLint
) texUnit
->CombineSourceA
[0];
843 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
846 case GL_SOURCE1_ALPHA_EXT
:
847 if (ctx
->Extensions
.EXT_texture_env_combine
||
848 ctx
->Extensions
.ARB_texture_env_combine
) {
849 *params
= (GLint
) texUnit
->CombineSourceA
[1];
852 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
855 case GL_SOURCE2_ALPHA_EXT
:
856 if (ctx
->Extensions
.EXT_texture_env_combine
||
857 ctx
->Extensions
.ARB_texture_env_combine
) {
858 *params
= (GLint
) texUnit
->CombineSourceA
[2];
861 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
864 case GL_OPERAND0_RGB_EXT
:
865 if (ctx
->Extensions
.EXT_texture_env_combine
||
866 ctx
->Extensions
.ARB_texture_env_combine
) {
867 *params
= (GLint
) texUnit
->CombineOperandRGB
[0];
870 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
873 case GL_OPERAND1_RGB_EXT
:
874 if (ctx
->Extensions
.EXT_texture_env_combine
||
875 ctx
->Extensions
.ARB_texture_env_combine
) {
876 *params
= (GLint
) texUnit
->CombineOperandRGB
[1];
879 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
882 case GL_OPERAND2_RGB_EXT
:
883 if (ctx
->Extensions
.EXT_texture_env_combine
||
884 ctx
->Extensions
.ARB_texture_env_combine
) {
885 *params
= (GLint
) texUnit
->CombineOperandRGB
[2];
888 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
891 case GL_OPERAND0_ALPHA_EXT
:
892 if (ctx
->Extensions
.EXT_texture_env_combine
||
893 ctx
->Extensions
.ARB_texture_env_combine
) {
894 *params
= (GLint
) texUnit
->CombineOperandA
[0];
897 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
900 case GL_OPERAND1_ALPHA_EXT
:
901 if (ctx
->Extensions
.EXT_texture_env_combine
||
902 ctx
->Extensions
.ARB_texture_env_combine
) {
903 *params
= (GLint
) texUnit
->CombineOperandA
[1];
906 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
909 case GL_OPERAND2_ALPHA_EXT
:
910 if (ctx
->Extensions
.EXT_texture_env_combine
||
911 ctx
->Extensions
.ARB_texture_env_combine
) {
912 *params
= (GLint
) texUnit
->CombineOperandA
[2];
915 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
918 case GL_RGB_SCALE_EXT
:
919 if (ctx
->Extensions
.EXT_texture_env_combine
||
920 ctx
->Extensions
.ARB_texture_env_combine
) {
921 if (texUnit
->CombineScaleShiftRGB
== 0)
923 else if (texUnit
->CombineScaleShiftRGB
== 1)
929 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
934 if (ctx
->Extensions
.EXT_texture_env_combine
||
935 ctx
->Extensions
.ARB_texture_env_combine
) {
936 if (texUnit
->CombineScaleShiftA
== 0)
938 else if (texUnit
->CombineScaleShiftA
== 1)
944 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
949 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)" );
952 else if (target
== GL_TEXTURE_FILTER_CONTROL_EXT
) {
953 /* GL_EXT_texture_lod_bias */
954 if (!ctx
->Extensions
.EXT_texture_lod_bias
) {
955 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(target)" );
958 if (pname
== GL_TEXTURE_LOD_BIAS_EXT
) {
959 *params
= (GLint
) texUnit
->LodBias
;
962 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)" );
966 else if (target
== GL_POINT_SPRITE_NV
) {
967 /* GL_NV_point_sprite */
968 if (!ctx
->Extensions
.NV_point_sprite
) {
969 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(target)" );
972 if (pname
== GL_COORD_REPLACE_NV
) {
973 *params
= (GLint
) ctx
->Point
.CoordReplace
[ctx
->Texture
.CurrentUnit
];
976 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)" );
981 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(target)" );
989 /**********************************************************************/
990 /* Texture Parameters */
991 /**********************************************************************/
995 _mesa_TexParameterf( GLenum target
, GLenum pname
, GLfloat param
)
997 _mesa_TexParameterfv(target
, pname
, ¶m
);
1002 _mesa_TexParameterfv( GLenum target
, GLenum pname
, const GLfloat
*params
)
1004 GET_CURRENT_CONTEXT(ctx
);
1005 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1006 GLenum eparam
= (GLenum
) (GLint
) params
[0];
1007 struct gl_texture_object
*texObj
;
1008 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1010 if (MESA_VERBOSE
&(VERBOSE_API
|VERBOSE_TEXTURE
))
1011 _mesa_debug(ctx
, "texPARAM %s %s %d...\n",
1012 _mesa_lookup_enum_by_nr(target
),
1013 _mesa_lookup_enum_by_nr(pname
),
1019 texObj
= texUnit
->Current1D
;
1022 texObj
= texUnit
->Current2D
;
1024 case GL_TEXTURE_3D_EXT
:
1025 texObj
= texUnit
->Current3D
;
1027 case GL_TEXTURE_CUBE_MAP_ARB
:
1028 if (!ctx
->Extensions
.ARB_texture_cube_map
) {
1029 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexParameter(target)" );
1032 texObj
= texUnit
->CurrentCubeMap
;
1034 case GL_TEXTURE_RECTANGLE_NV
:
1035 if (!ctx
->Extensions
.NV_texture_rectangle
) {
1036 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexParameter(target)" );
1039 texObj
= texUnit
->CurrentRect
;
1042 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexParameter(target)" );
1047 case GL_TEXTURE_MIN_FILTER
:
1048 /* A small optimization */
1049 if (texObj
->MinFilter
== eparam
)
1052 if (eparam
==GL_NEAREST
|| eparam
==GL_LINEAR
) {
1053 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1054 texObj
->MinFilter
= eparam
;
1056 else if ((eparam
==GL_NEAREST_MIPMAP_NEAREST
||
1057 eparam
==GL_LINEAR_MIPMAP_NEAREST
||
1058 eparam
==GL_NEAREST_MIPMAP_LINEAR
||
1059 eparam
==GL_LINEAR_MIPMAP_LINEAR
) &&
1060 texObj
->Target
!= GL_TEXTURE_RECTANGLE_NV
) {
1061 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1062 texObj
->MinFilter
= eparam
;
1065 _mesa_error( ctx
, GL_INVALID_VALUE
, "glTexParameter(param)" );
1069 case GL_TEXTURE_MAG_FILTER
:
1070 /* A small optimization */
1071 if (texObj
->MagFilter
== eparam
)
1074 if (eparam
==GL_NEAREST
|| eparam
==GL_LINEAR
) {
1075 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1076 texObj
->MagFilter
= eparam
;
1079 _mesa_error( ctx
, GL_INVALID_VALUE
, "glTexParameter(param)" );
1083 case GL_TEXTURE_WRAP_S
:
1084 if (texObj
->WrapS
== eparam
)
1086 if (eparam
== GL_CLAMP
|| eparam
== GL_CLAMP_TO_EDGE
||
1087 (eparam
== GL_CLAMP_TO_BORDER_ARB
&&
1088 ctx
->Extensions
.ARB_texture_border_clamp
)) {
1089 /* any texture target */
1090 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1091 texObj
->WrapS
= eparam
;
1093 else if (texObj
->Target
!= GL_TEXTURE_RECTANGLE_NV
&&
1094 (eparam
== GL_REPEAT
||
1095 (eparam
== GL_MIRRORED_REPEAT_ARB
&&
1096 ctx
->Extensions
.ARB_texture_mirrored_repeat
))) {
1097 /* non-rectangle texture */
1098 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1099 texObj
->WrapS
= eparam
;
1102 _mesa_error( ctx
, GL_INVALID_VALUE
, "glTexParameter(param)" );
1106 case GL_TEXTURE_WRAP_T
:
1107 if (texObj
->WrapT
== eparam
)
1109 if (eparam
== GL_CLAMP
|| eparam
== GL_CLAMP_TO_EDGE
||
1110 (eparam
== GL_CLAMP_TO_BORDER_ARB
&&
1111 ctx
->Extensions
.ARB_texture_border_clamp
)) {
1112 /* any texture target */
1113 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1114 texObj
->WrapT
= eparam
;
1116 else if (texObj
->Target
!= GL_TEXTURE_RECTANGLE_NV
&&
1117 (eparam
== GL_REPEAT
||
1118 (eparam
== GL_MIRRORED_REPEAT_ARB
&&
1119 ctx
->Extensions
.ARB_texture_mirrored_repeat
))) {
1120 /* non-rectangle texture */
1121 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1122 texObj
->WrapT
= eparam
;
1125 _mesa_error( ctx
, GL_INVALID_VALUE
, "glTexParameter(param)" );
1129 case GL_TEXTURE_WRAP_R_EXT
:
1130 if (texObj
->WrapR
== eparam
)
1132 if (eparam
== GL_CLAMP
|| eparam
== GL_CLAMP_TO_EDGE
||
1133 (eparam
== GL_CLAMP_TO_BORDER_ARB
&&
1134 ctx
->Extensions
.ARB_texture_border_clamp
)) {
1135 /* any texture target */
1136 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1137 texObj
->WrapR
= eparam
;
1139 else if (texObj
->Target
!= GL_TEXTURE_RECTANGLE_NV
&&
1140 (eparam
== GL_REPEAT
||
1141 (eparam
== GL_MIRRORED_REPEAT_ARB
&&
1142 ctx
->Extensions
.ARB_texture_mirrored_repeat
))) {
1143 /* non-rectangle texture */
1144 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1145 texObj
->WrapR
= eparam
;
1148 _mesa_error( ctx
, GL_INVALID_VALUE
, "glTexParameter(param)" );
1152 case GL_TEXTUER_BORDER_VALUES_NV
:
1154 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1155 COPY_4V(texObj
->BorderValues
, params
);
1156 UNCLAMPED_FLOAT_TO_CHAN(texObj
->BorderColor
[0], params
[0]);
1157 UNCLAMPED_FLOAT_TO_CHAN(texObj
->BorderColor
[1], params
[1]);
1158 UNCLAMPED_FLOAT_TO_CHAN(texObj
->BorderColor
[2], params
[2]);
1159 UNCLAMPED_FLOAT_TO_CHAN(texObj
->BorderColor
[3], params
[3]);
1162 case GL_TEXTURE_BORDER_COLOR
:
1164 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1165 texObj
->BorderValues
[0] = CLAMP(params
[0], 0.0F
, 1.0F
);
1166 texObj
->BorderValues
[1] = CLAMP(params
[1], 0.0F
, 1.0F
);
1167 texObj
->BorderValues
[2] = CLAMP(params
[2], 0.0F
, 1.0F
);
1168 texObj
->BorderValues
[3] = CLAMP(params
[3], 0.0F
, 1.0F
);
1169 UNCLAMPED_FLOAT_TO_CHAN(texObj
->BorderColor
[0], texObj
->BorderValues
[0]);
1170 UNCLAMPED_FLOAT_TO_CHAN(texObj
->BorderColor
[1], texObj
->BorderValues
[1]);
1171 UNCLAMPED_FLOAT_TO_CHAN(texObj
->BorderColor
[2], texObj
->BorderValues
[2]);
1172 UNCLAMPED_FLOAT_TO_CHAN(texObj
->BorderColor
[3], texObj
->BorderValues
[3]);
1174 case GL_TEXTURE_MIN_LOD
:
1175 if (texObj
->MinLod
== params
[0])
1177 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1178 texObj
->MinLod
= params
[0];
1180 case GL_TEXTURE_MAX_LOD
:
1181 if (texObj
->MaxLod
== params
[0])
1183 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1184 texObj
->MaxLod
= params
[0];
1186 case GL_TEXTURE_BASE_LEVEL
:
1187 if (params
[0] < 0.0) {
1188 _mesa_error(ctx
, GL_INVALID_VALUE
, "glTexParameter(param)" );
1191 if (target
== GL_TEXTURE_RECTANGLE_NV
&& params
[0] != 0.0) {
1192 _mesa_error(ctx
, GL_INVALID_VALUE
, "glTexParameter(param)" );
1195 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1196 texObj
->BaseLevel
= (GLint
) params
[0];
1198 case GL_TEXTURE_MAX_LEVEL
:
1199 if (params
[0] < 0.0) {
1200 _mesa_error(ctx
, GL_INVALID_VALUE
, "glTexParameter(param)" );
1203 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1204 texObj
->MaxLevel
= (GLint
) params
[0];
1206 case GL_TEXTURE_PRIORITY
:
1207 /* (keithh@netcomuk.co.uk) */
1208 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1209 texObj
->Priority
= CLAMP( params
[0], 0.0F
, 1.0F
);
1211 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1212 if (ctx
->Extensions
.EXT_texture_filter_anisotropic
) {
1213 if (params
[0] < 1.0) {
1214 _mesa_error(ctx
, GL_INVALID_VALUE
, "glTexParameter(param)" );
1217 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1218 texObj
->MaxAnisotropy
= params
[0];
1221 _mesa_error(ctx
, GL_INVALID_ENUM
,
1222 "glTexParameter(pname=GL_MAX_TEXTURE_ANISOTROPY_EXT)");
1226 case GL_TEXTURE_COMPARE_SGIX
:
1227 if (ctx
->Extensions
.SGIX_shadow
) {
1228 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1229 texObj
->CompareFlag
= params
[0] ? GL_TRUE
: GL_FALSE
;
1232 _mesa_error(ctx
, GL_INVALID_ENUM
,
1233 "glTexParameter(pname=GL_TEXTURE_COMPARE_SGIX)");
1237 case GL_TEXTURE_COMPARE_OPERATOR_SGIX
:
1238 if (ctx
->Extensions
.SGIX_shadow
) {
1239 GLenum op
= (GLenum
) params
[0];
1240 if (op
== GL_TEXTURE_LEQUAL_R_SGIX
||
1241 op
== GL_TEXTURE_GEQUAL_R_SGIX
) {
1242 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1243 texObj
->CompareOperator
= op
;
1246 _mesa_error(ctx
, GL_INVALID_ENUM
, "glTexParameter(param)");
1250 _mesa_error(ctx
, GL_INVALID_ENUM
,
1251 "glTexParameter(pname=GL_TEXTURE_COMPARE_OPERATOR_SGIX)");
1255 case GL_SHADOW_AMBIENT_SGIX
: /* aka GL_TEXTURE_COMPARE_FAIL_VALUE_ARB */
1256 if (ctx
->Extensions
.SGIX_shadow_ambient
) {
1257 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1258 UNCLAMPED_FLOAT_TO_CHAN(texObj
->ShadowAmbient
, params
[0]);
1261 _mesa_error(ctx
, GL_INVALID_ENUM
,
1262 "glTexParameter(pname=GL_SHADOW_AMBIENT_SGIX)");
1266 case GL_GENERATE_MIPMAP_SGIS
:
1267 if (ctx
->Extensions
.SGIS_generate_mipmap
) {
1268 texObj
->GenerateMipmap
= params
[0] ? GL_TRUE
: GL_FALSE
;
1271 _mesa_error(ctx
, GL_INVALID_ENUM
,
1272 "glTexParameter(pname=GL_GENERATE_MIPMAP_SGIS)");
1276 case GL_TEXTURE_COMPARE_MODE_ARB
:
1277 if (ctx
->Extensions
.ARB_shadow
) {
1278 const GLenum mode
= (GLenum
) params
[0];
1279 if (mode
== GL_NONE
|| mode
== GL_COMPARE_R_TO_TEXTURE_ARB
) {
1280 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1281 texObj
->CompareMode
= mode
;
1284 _mesa_error(ctx
, GL_INVALID_ENUM
,
1285 "glTexParameter(bad GL_TEXTURE_COMPARE_MODE_ARB)");
1290 _mesa_error(ctx
, GL_INVALID_ENUM
,
1291 "glTexParameter(pname=GL_TEXTURE_COMPARE_MODE_ARB)");
1295 case GL_TEXTURE_COMPARE_FUNC_ARB
:
1296 if (ctx
->Extensions
.ARB_shadow
) {
1297 const GLenum func
= (GLenum
) params
[0];
1298 if (func
== GL_LEQUAL
|| func
== GL_GEQUAL
) {
1299 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1300 texObj
->CompareFunc
= func
;
1302 else if (ctx
->Extensions
.EXT_shadow_funcs
&&
1303 (func
== GL_EQUAL
||
1304 func
== GL_NOTEQUAL
||
1306 func
== GL_GREATER
||
1307 func
== GL_ALWAYS
||
1308 func
== GL_NEVER
)) {
1309 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1310 texObj
->CompareFunc
= func
;
1313 _mesa_error(ctx
, GL_INVALID_ENUM
,
1314 "glTexParameter(bad GL_TEXTURE_COMPARE_FUNC_ARB)");
1319 _mesa_error(ctx
, GL_INVALID_ENUM
,
1320 "glTexParameter(pname=GL_TEXTURE_COMPARE_FUNC_ARB)");
1324 case GL_DEPTH_TEXTURE_MODE_ARB
:
1325 if (ctx
->Extensions
.ARB_depth_texture
) {
1326 const GLenum result
= (GLenum
) params
[0];
1327 if (result
== GL_LUMINANCE
|| result
== GL_INTENSITY
1328 || result
== GL_ALPHA
) {
1329 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1330 texObj
->DepthMode
= result
;
1333 _mesa_error(ctx
, GL_INVALID_ENUM
,
1334 "glTexParameter(bad GL_DEPTH_TEXTURE_MODE_ARB)");
1339 _mesa_error(ctx
, GL_INVALID_ENUM
,
1340 "glTexParameter(pname=GL_DEPTH_TEXTURE_MODE_ARB)");
1346 _mesa_error(ctx
, GL_INVALID_ENUM
,
1347 "glTexParameter(pname=0x%x)", pname
);
1351 texObj
->Complete
= GL_FALSE
;
1353 if (ctx
->Driver
.TexParameter
) {
1354 (*ctx
->Driver
.TexParameter
)( ctx
, target
, texObj
, pname
, params
);
1360 _mesa_TexParameteri( GLenum target
, GLenum pname
, GLint param
)
1363 fparam
[0] = (GLfloat
) param
;
1364 fparam
[1] = fparam
[2] = fparam
[3] = 0.0;
1365 _mesa_TexParameterfv(target
, pname
, fparam
);
1369 _mesa_TexParameteriv( GLenum target
, GLenum pname
, const GLint
*params
)
1372 fparam
[0] = (GLfloat
) params
[0];
1373 fparam
[1] = fparam
[2] = fparam
[3] = 0.0;
1374 _mesa_TexParameterfv(target
, pname
, fparam
);
1379 _mesa_GetTexLevelParameterfv( GLenum target
, GLint level
,
1380 GLenum pname
, GLfloat
*params
)
1383 _mesa_GetTexLevelParameteriv( target
, level
, pname
, &iparam
);
1384 *params
= (GLfloat
) iparam
;
1389 tex_image_dimensions(GLcontext
*ctx
, GLenum target
)
1393 case GL_PROXY_TEXTURE_1D
:
1396 case GL_PROXY_TEXTURE_2D
:
1399 case GL_PROXY_TEXTURE_3D
:
1401 case GL_TEXTURE_CUBE_MAP_ARB
:
1402 case GL_PROXY_TEXTURE_CUBE_MAP_ARB
:
1403 case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB
:
1404 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB
:
1405 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB
:
1406 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB
:
1407 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB
:
1408 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB
:
1409 return ctx
->Extensions
.ARB_texture_cube_map
? 2 : 0;
1410 case GL_TEXTURE_RECTANGLE_NV
:
1411 case GL_PROXY_TEXTURE_RECTANGLE_NV
:
1412 return ctx
->Extensions
.NV_texture_rectangle
? 2 : 0;
1414 _mesa_problem(ctx
, "bad target in _mesa_tex_target_dimensions()");
1421 _mesa_GetTexLevelParameteriv( GLenum target
, GLint level
,
1422 GLenum pname
, GLint
*params
)
1424 GET_CURRENT_CONTEXT(ctx
);
1425 const struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1426 const struct gl_texture_image
*img
= NULL
;
1430 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1432 /* this will catch bad target values */
1433 dimensions
= tex_image_dimensions(ctx
, target
); /* 1, 2 or 3 */
1434 if (dimensions
== 0) {
1435 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexLevelParameter[if]v(target)");
1441 case GL_PROXY_TEXTURE_1D
:
1443 case GL_PROXY_TEXTURE_2D
:
1444 maxLevels
= ctx
->Const
.MaxTextureLevels
;
1447 case GL_PROXY_TEXTURE_3D
:
1448 maxLevels
= ctx
->Const
.Max3DTextureLevels
;
1450 case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB
:
1451 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB
:
1452 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB
:
1453 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB
:
1454 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB
:
1455 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB
:
1456 case GL_PROXY_TEXTURE_CUBE_MAP_ARB
:
1457 maxLevels
= ctx
->Const
.MaxCubeTextureLevels
;
1459 case GL_TEXTURE_RECTANGLE_NV
:
1460 case GL_PROXY_TEXTURE_RECTANGLE_NV
:
1464 _mesa_problem(ctx
, "switch in _mesa_GetTexLevelParameter");
1468 if (level
< 0 || level
>= maxLevels
) {
1469 _mesa_error( ctx
, GL_INVALID_VALUE
, "glGetTexLevelParameter[if]v" );
1473 img
= _mesa_select_tex_image(ctx
, texUnit
, target
, level
);
1474 if (!img
|| !img
->TexFormat
) {
1475 /* undefined texture image */
1476 if (pname
== GL_TEXTURE_COMPONENTS
)
1483 isProxy
= (target
== GL_PROXY_TEXTURE_1D
) ||
1484 (target
== GL_PROXY_TEXTURE_2D
) ||
1485 (target
== GL_PROXY_TEXTURE_3D
) ||
1486 (target
== GL_PROXY_TEXTURE_CUBE_MAP_ARB
) ||
1487 (target
== GL_PROXY_TEXTURE_RECTANGLE_NV
);
1490 case GL_TEXTURE_WIDTH
:
1491 *params
= img
->Width
;
1493 case GL_TEXTURE_HEIGHT
:
1494 *params
= img
->Height
;
1496 case GL_TEXTURE_DEPTH
:
1497 *params
= img
->Depth
;
1499 case GL_TEXTURE_INTERNAL_FORMAT
:
1500 *params
= img
->IntFormat
;
1502 case GL_TEXTURE_BORDER
:
1503 *params
= img
->Border
;
1505 case GL_TEXTURE_RED_SIZE
:
1506 if (img
->Format
== GL_RGB
|| img
->Format
== GL_RGBA
)
1507 *params
= img
->TexFormat
->RedBits
;
1511 case GL_TEXTURE_GREEN_SIZE
:
1512 if (img
->Format
== GL_RGB
|| img
->Format
== GL_RGBA
)
1513 *params
= img
->TexFormat
->GreenBits
;
1517 case GL_TEXTURE_BLUE_SIZE
:
1518 if (img
->Format
== GL_RGB
|| img
->Format
== GL_RGBA
)
1519 *params
= img
->TexFormat
->BlueBits
;
1523 case GL_TEXTURE_ALPHA_SIZE
:
1524 if (img
->Format
== GL_ALPHA
|| img
->Format
== GL_LUMINANCE_ALPHA
||
1525 img
->Format
== GL_RGBA
)
1526 *params
= img
->TexFormat
->AlphaBits
;
1530 case GL_TEXTURE_INTENSITY_SIZE
:
1531 if (img
->Format
!= GL_INTENSITY
)
1533 else if (img
->TexFormat
->IntensityBits
> 0)
1534 *params
= img
->TexFormat
->IntensityBits
;
1535 else /* intensity probably stored as rgb texture */
1536 *params
= MIN2(img
->TexFormat
->RedBits
, img
->TexFormat
->GreenBits
);
1538 case GL_TEXTURE_LUMINANCE_SIZE
:
1539 if (img
->Format
!= GL_LUMINANCE
&&
1540 img
->Format
!= GL_LUMINANCE_ALPHA
)
1542 else if (img
->TexFormat
->LuminanceBits
> 0)
1543 *params
= img
->TexFormat
->LuminanceBits
;
1544 else /* luminance probably stored as rgb texture */
1545 *params
= MIN2(img
->TexFormat
->RedBits
, img
->TexFormat
->GreenBits
);
1547 case GL_TEXTURE_INDEX_SIZE_EXT
:
1548 if (img
->Format
== GL_COLOR_INDEX
)
1549 *params
= img
->TexFormat
->IndexBits
;
1554 /* XXX this isn't in the GL_SGIX_depth_texture spec
1555 * but seems appropriate.
1557 if (ctx
->Extensions
.SGIX_depth_texture
)
1558 *params
= img
->TexFormat
->DepthBits
;
1560 _mesa_error(ctx
, GL_INVALID_ENUM
,
1561 "glGetTexLevelParameter[if]v(pname)");
1564 /* GL_ARB_texture_compression */
1565 case GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB
:
1566 if (ctx
->Extensions
.ARB_texture_compression
) {
1567 if (img
->IsCompressed
&& !isProxy
)
1568 *params
= img
->CompressedSize
;
1570 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1571 "glGetTexLevelParameter[if]v(pname)");
1574 _mesa_error(ctx
, GL_INVALID_ENUM
,
1575 "glGetTexLevelParameter[if]v(pname)");
1578 case GL_TEXTURE_COMPRESSED_ARB
:
1579 if (ctx
->Extensions
.ARB_texture_compression
) {
1580 *params
= (GLint
) img
->IsCompressed
;
1583 _mesa_error(ctx
, GL_INVALID_ENUM
,
1584 "glGetTexLevelParameter[if]v(pname)");
1589 _mesa_error(ctx
, GL_INVALID_ENUM
,
1590 "glGetTexLevelParameter[if]v(pname)");
1597 _mesa_GetTexParameterfv( GLenum target
, GLenum pname
, GLfloat
*params
)
1599 GET_CURRENT_CONTEXT(ctx
);
1600 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1601 struct gl_texture_object
*obj
;
1602 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1604 obj
= _mesa_select_tex_object(ctx
, texUnit
, target
);
1606 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexParameterfv(target)");
1611 case GL_TEXTURE_MAG_FILTER
:
1612 *params
= ENUM_TO_FLOAT(obj
->MagFilter
);
1614 case GL_TEXTURE_MIN_FILTER
:
1615 *params
= ENUM_TO_FLOAT(obj
->MinFilter
);
1617 case GL_TEXTURE_WRAP_S
:
1618 *params
= ENUM_TO_FLOAT(obj
->WrapS
);
1620 case GL_TEXTURE_WRAP_T
:
1621 *params
= ENUM_TO_FLOAT(obj
->WrapT
);
1623 case GL_TEXTURE_WRAP_R_EXT
:
1624 *params
= ENUM_TO_FLOAT(obj
->WrapR
);
1627 case GL_TEXTURE_BORDER_VALUES_NV
:
1629 params
[0] = obj
->BorderValues
[0];
1630 params
[1] = obj
->BorderValues
[1];
1631 params
[2] = obj
->BorderValues
[2];
1632 params
[3] = obj
->BorderValues
[3];
1635 case GL_TEXTURE_BORDER_COLOR
:
1637 params
[0] = obj
->BorderColor
[0] / CHAN_MAXF
;
1638 params
[1] = obj
->BorderColor
[1] / CHAN_MAXF
;
1639 params
[2] = obj
->BorderColor
[2] / CHAN_MAXF
;
1640 params
[3] = obj
->BorderColor
[3] / CHAN_MAXF
;
1642 case GL_TEXTURE_RESIDENT
:
1645 if (ctx
->Driver
.IsTextureResident
)
1646 resident
= ctx
->Driver
.IsTextureResident(ctx
, obj
);
1649 *params
= ENUM_TO_FLOAT(resident
);
1652 case GL_TEXTURE_PRIORITY
:
1653 *params
= obj
->Priority
;
1655 case GL_TEXTURE_MIN_LOD
:
1656 *params
= obj
->MinLod
;
1658 case GL_TEXTURE_MAX_LOD
:
1659 *params
= obj
->MaxLod
;
1661 case GL_TEXTURE_BASE_LEVEL
:
1662 *params
= (GLfloat
) obj
->BaseLevel
;
1664 case GL_TEXTURE_MAX_LEVEL
:
1665 *params
= (GLfloat
) obj
->MaxLevel
;
1667 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1668 if (ctx
->Extensions
.EXT_texture_filter_anisotropic
) {
1669 *params
= obj
->MaxAnisotropy
;
1673 case GL_TEXTURE_COMPARE_SGIX
:
1674 if (ctx
->Extensions
.SGIX_shadow
) {
1675 *params
= (GLfloat
) obj
->CompareFlag
;
1679 case GL_TEXTURE_COMPARE_OPERATOR_SGIX
:
1680 if (ctx
->Extensions
.SGIX_shadow
) {
1681 *params
= (GLfloat
) obj
->CompareOperator
;
1685 case GL_SHADOW_AMBIENT_SGIX
: /* aka GL_TEXTURE_COMPARE_FAIL_VALUE_ARB */
1686 if (ctx
->Extensions
.SGIX_shadow_ambient
) {
1687 *params
= CHAN_TO_FLOAT(obj
->ShadowAmbient
);
1691 case GL_GENERATE_MIPMAP_SGIS
:
1692 if (ctx
->Extensions
.SGIS_generate_mipmap
) {
1693 *params
= (GLfloat
) obj
->GenerateMipmap
;
1697 case GL_TEXTURE_COMPARE_MODE_ARB
:
1698 if (ctx
->Extensions
.ARB_shadow
) {
1699 *params
= (GLfloat
) obj
->CompareMode
;
1703 case GL_TEXTURE_COMPARE_FUNC_ARB
:
1704 if (ctx
->Extensions
.ARB_shadow
) {
1705 *params
= (GLfloat
) obj
->CompareFunc
;
1709 case GL_DEPTH_TEXTURE_MODE_ARB
:
1710 if (ctx
->Extensions
.ARB_depth_texture
) {
1711 *params
= (GLfloat
) obj
->DepthMode
;
1716 ; /* silence warnings */
1718 /* If we get here, pname was an unrecognized enum */
1719 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexParameterfv(pname)" );
1724 _mesa_GetTexParameteriv( GLenum target
, GLenum pname
, GLint
*params
)
1726 GET_CURRENT_CONTEXT(ctx
);
1727 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1728 struct gl_texture_object
*obj
;
1729 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1731 obj
= _mesa_select_tex_object(ctx
, texUnit
, target
);
1733 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexParameteriv(target)");
1738 case GL_TEXTURE_MAG_FILTER
:
1739 *params
= (GLint
) obj
->MagFilter
;
1741 case GL_TEXTURE_MIN_FILTER
:
1742 *params
= (GLint
) obj
->MinFilter
;
1744 case GL_TEXTURE_WRAP_S
:
1745 *params
= (GLint
) obj
->WrapS
;
1747 case GL_TEXTURE_WRAP_T
:
1748 *params
= (GLint
) obj
->WrapT
;
1750 case GL_TEXTURE_WRAP_R_EXT
:
1751 *params
= (GLint
) obj
->WrapR
;
1754 case GL_TEXTURE_BORDER_VALUES_NV
:
1756 params
[0] = FLOAT_TO_INT(obj
->BorderValues
[0]);
1757 params
[1] = FLOAT_TO_INT(obj
->BorderValues
[1]);
1758 params
[2] = FLOAT_TO_INT(obj
->BorderValues
[2]);
1759 params
[3] = FLOAT_TO_INT(obj
->BorderValues
[3]);
1762 case GL_TEXTURE_BORDER_COLOR
:
1766 b
[0] = CLAMP(obj
->BorderValues
[0], 0.0F
, 1.0F
);
1767 b
[1] = CLAMP(obj
->BorderValues
[1], 0.0F
, 1.0F
);
1768 b
[2] = CLAMP(obj
->BorderValues
[2], 0.0F
, 1.0F
);
1769 b
[3] = CLAMP(obj
->BorderValues
[3], 0.0F
, 1.0F
);
1770 params
[0] = FLOAT_TO_INT(b
[0]);
1771 params
[1] = FLOAT_TO_INT(b
[1]);
1772 params
[2] = FLOAT_TO_INT(b
[2]);
1773 params
[3] = FLOAT_TO_INT(b
[3]);
1776 case GL_TEXTURE_RESIDENT
:
1779 if (ctx
->Driver
.IsTextureResident
)
1780 resident
= ctx
->Driver
.IsTextureResident(ctx
, obj
);
1783 *params
= (GLint
) resident
;
1786 case GL_TEXTURE_PRIORITY
:
1787 *params
= (GLint
) obj
->Priority
;
1789 case GL_TEXTURE_MIN_LOD
:
1790 *params
= (GLint
) obj
->MinLod
;
1792 case GL_TEXTURE_MAX_LOD
:
1793 *params
= (GLint
) obj
->MaxLod
;
1795 case GL_TEXTURE_BASE_LEVEL
:
1796 *params
= obj
->BaseLevel
;
1798 case GL_TEXTURE_MAX_LEVEL
:
1799 *params
= obj
->MaxLevel
;
1801 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1802 if (ctx
->Extensions
.EXT_texture_filter_anisotropic
) {
1803 *params
= (GLint
) obj
->MaxAnisotropy
;
1807 case GL_TEXTURE_COMPARE_SGIX
:
1808 if (ctx
->Extensions
.SGIX_shadow
) {
1809 *params
= (GLint
) obj
->CompareFlag
;
1813 case GL_TEXTURE_COMPARE_OPERATOR_SGIX
:
1814 if (ctx
->Extensions
.SGIX_shadow
) {
1815 *params
= (GLint
) obj
->CompareOperator
;
1819 case GL_SHADOW_AMBIENT_SGIX
: /* aka GL_TEXTURE_COMPARE_FAIL_VALUE_ARB */
1820 if (ctx
->Extensions
.SGIX_shadow_ambient
) {
1821 GLfloat a
= CHAN_TO_FLOAT(obj
->ShadowAmbient
);
1822 *params
= (GLint
) FLOAT_TO_INT(a
);
1826 case GL_GENERATE_MIPMAP_SGIS
:
1827 if (ctx
->Extensions
.SGIS_generate_mipmap
) {
1828 *params
= (GLint
) obj
->GenerateMipmap
;
1832 case GL_TEXTURE_COMPARE_MODE_ARB
:
1833 if (ctx
->Extensions
.ARB_shadow
) {
1834 *params
= (GLint
) obj
->CompareMode
;
1838 case GL_TEXTURE_COMPARE_FUNC_ARB
:
1839 if (ctx
->Extensions
.ARB_shadow
) {
1840 *params
= (GLint
) obj
->CompareFunc
;
1844 case GL_DEPTH_TEXTURE_MODE_ARB
:
1845 if (ctx
->Extensions
.ARB_depth_texture
) {
1846 *params
= (GLint
) obj
->DepthMode
;
1851 ; /* silence warnings */
1853 /* If we get here, pname was an unrecognized enum */
1854 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexParameteriv(pname)" );
1860 /**********************************************************************/
1861 /* Texture Coord Generation */
1862 /**********************************************************************/
1866 _mesa_TexGenfv( GLenum coord
, GLenum pname
, const GLfloat
*params
)
1868 GET_CURRENT_CONTEXT(ctx
);
1869 GLuint tUnit
= ctx
->Texture
.CurrentUnit
;
1870 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[tUnit
];
1871 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1873 if (MESA_VERBOSE
&(VERBOSE_API
|VERBOSE_TEXTURE
))
1874 _mesa_debug(ctx
, "texGEN %s %s %x...\n",
1875 _mesa_lookup_enum_by_nr(coord
),
1876 _mesa_lookup_enum_by_nr(pname
),
1881 if (pname
==GL_TEXTURE_GEN_MODE
) {
1882 GLenum mode
= (GLenum
) (GLint
) *params
;
1885 case GL_OBJECT_LINEAR
:
1886 bits
= TEXGEN_OBJ_LINEAR
;
1889 bits
= TEXGEN_EYE_LINEAR
;
1891 case GL_REFLECTION_MAP_NV
:
1892 bits
= TEXGEN_REFLECTION_MAP_NV
;
1894 case GL_NORMAL_MAP_NV
:
1895 bits
= TEXGEN_NORMAL_MAP_NV
;
1898 bits
= TEXGEN_SPHERE_MAP
;
1901 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(param)" );
1904 if (texUnit
->GenModeS
== mode
)
1906 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1907 texUnit
->GenModeS
= mode
;
1908 texUnit
->_GenBitS
= bits
;
1910 else if (pname
==GL_OBJECT_PLANE
) {
1911 if (TEST_EQ_4V(texUnit
->ObjectPlaneS
, params
))
1913 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1914 texUnit
->ObjectPlaneS
[0] = params
[0];
1915 texUnit
->ObjectPlaneS
[1] = params
[1];
1916 texUnit
->ObjectPlaneS
[2] = params
[2];
1917 texUnit
->ObjectPlaneS
[3] = params
[3];
1919 else if (pname
==GL_EYE_PLANE
) {
1922 /* Transform plane equation by the inverse modelview matrix */
1923 if (ctx
->ModelviewMatrixStack
.Top
->flags
& MAT_DIRTY_INVERSE
) {
1924 _math_matrix_analyse( ctx
->ModelviewMatrixStack
.Top
);
1926 _mesa_transform_vector( tmp
, params
, ctx
->ModelviewMatrixStack
.Top
->inv
);
1927 if (TEST_EQ_4V(texUnit
->EyePlaneS
, tmp
))
1929 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1930 COPY_4FV(texUnit
->EyePlaneS
, tmp
);
1933 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(pname)" );
1938 if (pname
==GL_TEXTURE_GEN_MODE
) {
1939 GLenum mode
= (GLenum
) (GLint
) *params
;
1942 case GL_OBJECT_LINEAR
:
1943 bitt
= TEXGEN_OBJ_LINEAR
;
1946 bitt
= TEXGEN_EYE_LINEAR
;
1948 case GL_REFLECTION_MAP_NV
:
1949 bitt
= TEXGEN_REFLECTION_MAP_NV
;
1951 case GL_NORMAL_MAP_NV
:
1952 bitt
= TEXGEN_NORMAL_MAP_NV
;
1955 bitt
= TEXGEN_SPHERE_MAP
;
1958 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(param)" );
1961 if (texUnit
->GenModeT
== mode
)
1963 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1964 texUnit
->GenModeT
= mode
;
1965 texUnit
->_GenBitT
= bitt
;
1967 else if (pname
==GL_OBJECT_PLANE
) {
1968 if (TEST_EQ_4V(texUnit
->ObjectPlaneT
, params
))
1970 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1971 texUnit
->ObjectPlaneT
[0] = params
[0];
1972 texUnit
->ObjectPlaneT
[1] = params
[1];
1973 texUnit
->ObjectPlaneT
[2] = params
[2];
1974 texUnit
->ObjectPlaneT
[3] = params
[3];
1976 else if (pname
==GL_EYE_PLANE
) {
1978 /* Transform plane equation by the inverse modelview matrix */
1979 if (ctx
->ModelviewMatrixStack
.Top
->flags
& MAT_DIRTY_INVERSE
) {
1980 _math_matrix_analyse( ctx
->ModelviewMatrixStack
.Top
);
1982 _mesa_transform_vector( tmp
, params
, ctx
->ModelviewMatrixStack
.Top
->inv
);
1983 if (TEST_EQ_4V(texUnit
->EyePlaneT
, tmp
))
1985 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1986 COPY_4FV(texUnit
->EyePlaneT
, tmp
);
1989 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(pname)" );
1994 if (pname
==GL_TEXTURE_GEN_MODE
) {
1995 GLenum mode
= (GLenum
) (GLint
) *params
;
1998 case GL_OBJECT_LINEAR
:
1999 bitr
= TEXGEN_OBJ_LINEAR
;
2001 case GL_REFLECTION_MAP_NV
:
2002 bitr
= TEXGEN_REFLECTION_MAP_NV
;
2004 case GL_NORMAL_MAP_NV
:
2005 bitr
= TEXGEN_NORMAL_MAP_NV
;
2008 bitr
= TEXGEN_EYE_LINEAR
;
2011 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(param)" );
2014 if (texUnit
->GenModeR
== mode
)
2016 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
2017 texUnit
->GenModeR
= mode
;
2018 texUnit
->_GenBitR
= bitr
;
2020 else if (pname
==GL_OBJECT_PLANE
) {
2021 if (TEST_EQ_4V(texUnit
->ObjectPlaneR
, params
))
2023 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
2024 texUnit
->ObjectPlaneR
[0] = params
[0];
2025 texUnit
->ObjectPlaneR
[1] = params
[1];
2026 texUnit
->ObjectPlaneR
[2] = params
[2];
2027 texUnit
->ObjectPlaneR
[3] = params
[3];
2029 else if (pname
==GL_EYE_PLANE
) {
2031 /* Transform plane equation by the inverse modelview matrix */
2032 if (ctx
->ModelviewMatrixStack
.Top
->flags
& MAT_DIRTY_INVERSE
) {
2033 _math_matrix_analyse( ctx
->ModelviewMatrixStack
.Top
);
2035 _mesa_transform_vector( tmp
, params
, ctx
->ModelviewMatrixStack
.Top
->inv
);
2036 if (TEST_EQ_4V(texUnit
->EyePlaneR
, tmp
))
2038 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
2039 COPY_4FV(texUnit
->EyePlaneR
, tmp
);
2042 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(pname)" );
2047 if (pname
==GL_TEXTURE_GEN_MODE
) {
2048 GLenum mode
= (GLenum
) (GLint
) *params
;
2051 case GL_OBJECT_LINEAR
:
2052 bitq
= TEXGEN_OBJ_LINEAR
;
2055 bitq
= TEXGEN_EYE_LINEAR
;
2058 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(param)" );
2061 if (texUnit
->GenModeQ
== mode
)
2063 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
2064 texUnit
->GenModeQ
= mode
;
2065 texUnit
->_GenBitQ
= bitq
;
2067 else if (pname
==GL_OBJECT_PLANE
) {
2068 if (TEST_EQ_4V(texUnit
->ObjectPlaneQ
, params
))
2070 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
2071 texUnit
->ObjectPlaneQ
[0] = params
[0];
2072 texUnit
->ObjectPlaneQ
[1] = params
[1];
2073 texUnit
->ObjectPlaneQ
[2] = params
[2];
2074 texUnit
->ObjectPlaneQ
[3] = params
[3];
2076 else if (pname
==GL_EYE_PLANE
) {
2078 /* Transform plane equation by the inverse modelview matrix */
2079 if (ctx
->ModelviewMatrixStack
.Top
->flags
& MAT_DIRTY_INVERSE
) {
2080 _math_matrix_analyse( ctx
->ModelviewMatrixStack
.Top
);
2082 _mesa_transform_vector( tmp
, params
, ctx
->ModelviewMatrixStack
.Top
->inv
);
2083 if (TEST_EQ_4V(texUnit
->EyePlaneQ
, tmp
))
2085 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
2086 COPY_4FV(texUnit
->EyePlaneQ
, tmp
);
2089 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(pname)" );
2094 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(coord)" );
2098 if (ctx
->Driver
.TexGen
)
2099 ctx
->Driver
.TexGen( ctx
, coord
, pname
, params
);
2104 _mesa_TexGeniv(GLenum coord
, GLenum pname
, const GLint
*params
)
2107 p
[0] = (GLfloat
) params
[0];
2108 p
[1] = (GLfloat
) params
[1];
2109 p
[2] = (GLfloat
) params
[2];
2110 p
[3] = (GLfloat
) params
[3];
2111 _mesa_TexGenfv(coord
, pname
, p
);
2116 _mesa_TexGend(GLenum coord
, GLenum pname
, GLdouble param
)
2118 GLfloat p
= (GLfloat
) param
;
2119 _mesa_TexGenfv( coord
, pname
, &p
);
2124 _mesa_TexGendv(GLenum coord
, GLenum pname
, const GLdouble
*params
)
2127 p
[0] = (GLfloat
) params
[0];
2128 p
[1] = (GLfloat
) params
[1];
2129 p
[2] = (GLfloat
) params
[2];
2130 p
[3] = (GLfloat
) params
[3];
2131 _mesa_TexGenfv( coord
, pname
, p
);
2136 _mesa_TexGenf( GLenum coord
, GLenum pname
, GLfloat param
)
2138 _mesa_TexGenfv(coord
, pname
, ¶m
);
2143 _mesa_TexGeni( GLenum coord
, GLenum pname
, GLint param
)
2145 _mesa_TexGeniv( coord
, pname
, ¶m
);
2151 _mesa_GetTexGendv( GLenum coord
, GLenum pname
, GLdouble
*params
)
2153 GET_CURRENT_CONTEXT(ctx
);
2154 GLuint tUnit
= ctx
->Texture
.CurrentUnit
;
2155 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[tUnit
];
2156 ASSERT_OUTSIDE_BEGIN_END(ctx
);
2160 if (pname
==GL_TEXTURE_GEN_MODE
) {
2161 params
[0] = ENUM_TO_DOUBLE(texUnit
->GenModeS
);
2163 else if (pname
==GL_OBJECT_PLANE
) {
2164 COPY_4V( params
, texUnit
->ObjectPlaneS
);
2166 else if (pname
==GL_EYE_PLANE
) {
2167 COPY_4V( params
, texUnit
->EyePlaneS
);
2170 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGendv(pname)" );
2175 if (pname
==GL_TEXTURE_GEN_MODE
) {
2176 params
[0] = ENUM_TO_DOUBLE(texUnit
->GenModeT
);
2178 else if (pname
==GL_OBJECT_PLANE
) {
2179 COPY_4V( params
, texUnit
->ObjectPlaneT
);
2181 else if (pname
==GL_EYE_PLANE
) {
2182 COPY_4V( params
, texUnit
->EyePlaneT
);
2185 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGendv(pname)" );
2190 if (pname
==GL_TEXTURE_GEN_MODE
) {
2191 params
[0] = ENUM_TO_DOUBLE(texUnit
->GenModeR
);
2193 else if (pname
==GL_OBJECT_PLANE
) {
2194 COPY_4V( params
, texUnit
->ObjectPlaneR
);
2196 else if (pname
==GL_EYE_PLANE
) {
2197 COPY_4V( params
, texUnit
->EyePlaneR
);
2200 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGendv(pname)" );
2205 if (pname
==GL_TEXTURE_GEN_MODE
) {
2206 params
[0] = ENUM_TO_DOUBLE(texUnit
->GenModeQ
);
2208 else if (pname
==GL_OBJECT_PLANE
) {
2209 COPY_4V( params
, texUnit
->ObjectPlaneQ
);
2211 else if (pname
==GL_EYE_PLANE
) {
2212 COPY_4V( params
, texUnit
->EyePlaneQ
);
2215 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGendv(pname)" );
2220 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGendv(coord)" );
2228 _mesa_GetTexGenfv( GLenum coord
, GLenum pname
, GLfloat
*params
)
2230 GET_CURRENT_CONTEXT(ctx
);
2231 GLuint tUnit
= ctx
->Texture
.CurrentUnit
;
2232 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[tUnit
];
2233 ASSERT_OUTSIDE_BEGIN_END(ctx
);
2237 if (pname
==GL_TEXTURE_GEN_MODE
) {
2238 params
[0] = ENUM_TO_FLOAT(texUnit
->GenModeS
);
2240 else if (pname
==GL_OBJECT_PLANE
) {
2241 COPY_4V( params
, texUnit
->ObjectPlaneS
);
2243 else if (pname
==GL_EYE_PLANE
) {
2244 COPY_4V( params
, texUnit
->EyePlaneS
);
2247 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGenfv(pname)" );
2252 if (pname
==GL_TEXTURE_GEN_MODE
) {
2253 params
[0] = ENUM_TO_FLOAT(texUnit
->GenModeT
);
2255 else if (pname
==GL_OBJECT_PLANE
) {
2256 COPY_4V( params
, texUnit
->ObjectPlaneT
);
2258 else if (pname
==GL_EYE_PLANE
) {
2259 COPY_4V( params
, texUnit
->EyePlaneT
);
2262 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGenfv(pname)" );
2267 if (pname
==GL_TEXTURE_GEN_MODE
) {
2268 params
[0] = ENUM_TO_FLOAT(texUnit
->GenModeR
);
2270 else if (pname
==GL_OBJECT_PLANE
) {
2271 COPY_4V( params
, texUnit
->ObjectPlaneR
);
2273 else if (pname
==GL_EYE_PLANE
) {
2274 COPY_4V( params
, texUnit
->EyePlaneR
);
2277 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGenfv(pname)" );
2282 if (pname
==GL_TEXTURE_GEN_MODE
) {
2283 params
[0] = ENUM_TO_FLOAT(texUnit
->GenModeQ
);
2285 else if (pname
==GL_OBJECT_PLANE
) {
2286 COPY_4V( params
, texUnit
->ObjectPlaneQ
);
2288 else if (pname
==GL_EYE_PLANE
) {
2289 COPY_4V( params
, texUnit
->EyePlaneQ
);
2292 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGenfv(pname)" );
2297 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGenfv(coord)" );
2305 _mesa_GetTexGeniv( GLenum coord
, GLenum pname
, GLint
*params
)
2307 GET_CURRENT_CONTEXT(ctx
);
2308 GLuint tUnit
= ctx
->Texture
.CurrentUnit
;
2309 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[tUnit
];
2310 ASSERT_OUTSIDE_BEGIN_END(ctx
);
2314 if (pname
==GL_TEXTURE_GEN_MODE
) {
2315 params
[0] = texUnit
->GenModeS
;
2317 else if (pname
==GL_OBJECT_PLANE
) {
2318 params
[0] = (GLint
) texUnit
->ObjectPlaneS
[0];
2319 params
[1] = (GLint
) texUnit
->ObjectPlaneS
[1];
2320 params
[2] = (GLint
) texUnit
->ObjectPlaneS
[2];
2321 params
[3] = (GLint
) texUnit
->ObjectPlaneS
[3];
2323 else if (pname
==GL_EYE_PLANE
) {
2324 params
[0] = (GLint
) texUnit
->EyePlaneS
[0];
2325 params
[1] = (GLint
) texUnit
->EyePlaneS
[1];
2326 params
[2] = (GLint
) texUnit
->EyePlaneS
[2];
2327 params
[3] = (GLint
) texUnit
->EyePlaneS
[3];
2330 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGeniv(pname)" );
2335 if (pname
==GL_TEXTURE_GEN_MODE
) {
2336 params
[0] = texUnit
->GenModeT
;
2338 else if (pname
==GL_OBJECT_PLANE
) {
2339 params
[0] = (GLint
) texUnit
->ObjectPlaneT
[0];
2340 params
[1] = (GLint
) texUnit
->ObjectPlaneT
[1];
2341 params
[2] = (GLint
) texUnit
->ObjectPlaneT
[2];
2342 params
[3] = (GLint
) texUnit
->ObjectPlaneT
[3];
2344 else if (pname
==GL_EYE_PLANE
) {
2345 params
[0] = (GLint
) texUnit
->EyePlaneT
[0];
2346 params
[1] = (GLint
) texUnit
->EyePlaneT
[1];
2347 params
[2] = (GLint
) texUnit
->EyePlaneT
[2];
2348 params
[3] = (GLint
) texUnit
->EyePlaneT
[3];
2351 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGeniv(pname)" );
2356 if (pname
==GL_TEXTURE_GEN_MODE
) {
2357 params
[0] = texUnit
->GenModeR
;
2359 else if (pname
==GL_OBJECT_PLANE
) {
2360 params
[0] = (GLint
) texUnit
->ObjectPlaneR
[0];
2361 params
[1] = (GLint
) texUnit
->ObjectPlaneR
[1];
2362 params
[2] = (GLint
) texUnit
->ObjectPlaneR
[2];
2363 params
[3] = (GLint
) texUnit
->ObjectPlaneR
[3];
2365 else if (pname
==GL_EYE_PLANE
) {
2366 params
[0] = (GLint
) texUnit
->EyePlaneR
[0];
2367 params
[1] = (GLint
) texUnit
->EyePlaneR
[1];
2368 params
[2] = (GLint
) texUnit
->EyePlaneR
[2];
2369 params
[3] = (GLint
) texUnit
->EyePlaneR
[3];
2372 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGeniv(pname)" );
2377 if (pname
==GL_TEXTURE_GEN_MODE
) {
2378 params
[0] = texUnit
->GenModeQ
;
2380 else if (pname
==GL_OBJECT_PLANE
) {
2381 params
[0] = (GLint
) texUnit
->ObjectPlaneQ
[0];
2382 params
[1] = (GLint
) texUnit
->ObjectPlaneQ
[1];
2383 params
[2] = (GLint
) texUnit
->ObjectPlaneQ
[2];
2384 params
[3] = (GLint
) texUnit
->ObjectPlaneQ
[3];
2386 else if (pname
==GL_EYE_PLANE
) {
2387 params
[0] = (GLint
) texUnit
->EyePlaneQ
[0];
2388 params
[1] = (GLint
) texUnit
->EyePlaneQ
[1];
2389 params
[2] = (GLint
) texUnit
->EyePlaneQ
[2];
2390 params
[3] = (GLint
) texUnit
->EyePlaneQ
[3];
2393 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGeniv(pname)" );
2398 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGeniv(coord)" );
2404 /* GL_ARB_multitexture */
2406 _mesa_ActiveTextureARB( GLenum target
)
2408 GET_CURRENT_CONTEXT(ctx
);
2409 GLuint texUnit
= target
- GL_TEXTURE0_ARB
;
2410 ASSERT_OUTSIDE_BEGIN_END(ctx
);
2412 if (MESA_VERBOSE
& (VERBOSE_API
|VERBOSE_TEXTURE
))
2413 _mesa_debug(ctx
, "glActiveTexture %s\n",
2414 _mesa_lookup_enum_by_nr(target
));
2416 if (texUnit
> ctx
->Const
.MaxTextureUnits
) {
2417 _mesa_error(ctx
, GL_INVALID_ENUM
, "glActiveTextureARB(target)");
2421 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
2422 ctx
->Texture
.CurrentUnit
= texUnit
;
2423 if (ctx
->Driver
.ActiveTexture
) {
2424 (*ctx
->Driver
.ActiveTexture
)( ctx
, (GLuint
) texUnit
);
2429 /* GL_ARB_multitexture */
2431 _mesa_ClientActiveTextureARB( GLenum target
)
2433 GET_CURRENT_CONTEXT(ctx
);
2434 GLuint texUnit
= target
- GL_TEXTURE0_ARB
;
2435 ASSERT_OUTSIDE_BEGIN_END(ctx
);
2437 if (texUnit
> ctx
->Const
.MaxTextureUnits
) {
2438 _mesa_error(ctx
, GL_INVALID_ENUM
, "glClientActiveTextureARB(target)");
2442 FLUSH_VERTICES(ctx
, _NEW_ARRAY
);
2443 ctx
->Array
.ActiveTexture
= texUnit
;
2448 /**********************************************************************/
2449 /* Pixel Texgen Extensions */
2450 /**********************************************************************/
2453 _mesa_PixelTexGenSGIX(GLenum mode
)
2455 GLenum newRgbSource
, newAlphaSource
;
2456 GET_CURRENT_CONTEXT(ctx
);
2457 ASSERT_OUTSIDE_BEGIN_END(ctx
);
2461 newRgbSource
= GL_PIXEL_GROUP_COLOR_SGIS
;
2462 newAlphaSource
= GL_PIXEL_GROUP_COLOR_SGIS
;
2465 newRgbSource
= GL_PIXEL_GROUP_COLOR_SGIS
;
2466 newAlphaSource
= GL_CURRENT_RASTER_COLOR
;
2469 newRgbSource
= GL_CURRENT_RASTER_COLOR
;
2470 newAlphaSource
= GL_PIXEL_GROUP_COLOR_SGIS
;
2473 newRgbSource
= GL_CURRENT_RASTER_COLOR
;
2474 newAlphaSource
= GL_CURRENT_RASTER_COLOR
;
2477 _mesa_error(ctx
, GL_INVALID_ENUM
, "glPixelTexGenSGIX(mode)");
2481 if (newRgbSource
== ctx
->Pixel
.FragmentRgbSource
&&
2482 newAlphaSource
== ctx
->Pixel
.FragmentAlphaSource
)
2485 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
2486 ctx
->Pixel
.FragmentRgbSource
= newRgbSource
;
2487 ctx
->Pixel
.FragmentAlphaSource
= newAlphaSource
;
2492 _mesa_PixelTexGenParameterfSGIS(GLenum target
, GLfloat value
)
2494 _mesa_PixelTexGenParameteriSGIS(target
, (GLint
) value
);
2499 _mesa_PixelTexGenParameterfvSGIS(GLenum target
, const GLfloat
*value
)
2501 _mesa_PixelTexGenParameteriSGIS(target
, (GLint
) *value
);
2506 _mesa_PixelTexGenParameteriSGIS(GLenum target
, GLint value
)
2508 GET_CURRENT_CONTEXT(ctx
);
2509 ASSERT_OUTSIDE_BEGIN_END(ctx
);
2511 if (value
!= GL_CURRENT_RASTER_COLOR
&& value
!= GL_PIXEL_GROUP_COLOR_SGIS
) {
2512 _mesa_error(ctx
, GL_INVALID_ENUM
, "glPixelTexGenParameterSGIS(value)");
2517 case GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS
:
2518 if (ctx
->Pixel
.FragmentRgbSource
== (GLenum
) value
)
2520 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
2521 ctx
->Pixel
.FragmentRgbSource
= (GLenum
) value
;
2523 case GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS
:
2524 if (ctx
->Pixel
.FragmentAlphaSource
== (GLenum
) value
)
2526 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
2527 ctx
->Pixel
.FragmentAlphaSource
= (GLenum
) value
;
2530 _mesa_error(ctx
, GL_INVALID_ENUM
, "glPixelTexGenParameterSGIS(target)");
2537 _mesa_PixelTexGenParameterivSGIS(GLenum target
, const GLint
*value
)
2539 _mesa_PixelTexGenParameteriSGIS(target
, *value
);
2544 _mesa_GetPixelTexGenParameterfvSGIS(GLenum target
, GLfloat
*value
)
2546 GET_CURRENT_CONTEXT(ctx
);
2547 ASSERT_OUTSIDE_BEGIN_END(ctx
);
2549 if (target
== GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS
) {
2550 *value
= (GLfloat
) ctx
->Pixel
.FragmentRgbSource
;
2552 else if (target
== GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS
) {
2553 *value
= (GLfloat
) ctx
->Pixel
.FragmentAlphaSource
;
2556 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetPixelTexGenParameterfvSGIS(target)");
2562 _mesa_GetPixelTexGenParameterivSGIS(GLenum target
, GLint
*value
)
2564 GET_CURRENT_CONTEXT(ctx
);
2565 ASSERT_OUTSIDE_BEGIN_END(ctx
);
2567 if (target
== GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS
) {
2568 *value
= (GLint
) ctx
->Pixel
.FragmentRgbSource
;
2570 else if (target
== GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS
) {
2571 *value
= (GLint
) ctx
->Pixel
.FragmentAlphaSource
;
2574 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetPixelTexGenParameterivSGIS(target)");