1 /* $Id: texstate.c,v 1.82 2002/10/21 15:52:34 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] = (GLfloat
) 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 (eparam
== GL_MIRROR_CLAMP_ATI
&&
1098 ctx
->Extensions
.ATI_texture_mirror_once
) ||
1099 (eparam
== GL_MIRROR_CLAMP_TO_EDGE_ATI
&&
1100 ctx
->Extensions
.ATI_texture_mirror_once
))) {
1101 /* non-rectangle texture */
1102 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1103 texObj
->WrapS
= eparam
;
1106 _mesa_error( ctx
, GL_INVALID_VALUE
, "glTexParameter(param)" );
1110 case GL_TEXTURE_WRAP_T
:
1111 if (texObj
->WrapT
== eparam
)
1113 if (eparam
== GL_CLAMP
|| eparam
== GL_CLAMP_TO_EDGE
||
1114 (eparam
== GL_CLAMP_TO_BORDER_ARB
&&
1115 ctx
->Extensions
.ARB_texture_border_clamp
)) {
1116 /* any texture target */
1117 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1118 texObj
->WrapT
= eparam
;
1120 else if (texObj
->Target
!= GL_TEXTURE_RECTANGLE_NV
&&
1121 (eparam
== GL_REPEAT
||
1122 (eparam
== GL_MIRRORED_REPEAT_ARB
&&
1123 ctx
->Extensions
.ARB_texture_mirrored_repeat
) ||
1124 (eparam
== GL_MIRROR_CLAMP_ATI
&&
1125 ctx
->Extensions
.ATI_texture_mirror_once
) ||
1126 (eparam
== GL_MIRROR_CLAMP_TO_EDGE_ATI
&&
1127 ctx
->Extensions
.ATI_texture_mirror_once
))) {
1128 /* non-rectangle texture */
1129 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1130 texObj
->WrapT
= eparam
;
1133 _mesa_error( ctx
, GL_INVALID_VALUE
, "glTexParameter(param)" );
1137 case GL_TEXTURE_WRAP_R_EXT
:
1138 if (texObj
->WrapR
== eparam
)
1140 if (eparam
== GL_CLAMP
|| eparam
== GL_CLAMP_TO_EDGE
||
1141 (eparam
== GL_CLAMP_TO_BORDER_ARB
&&
1142 ctx
->Extensions
.ARB_texture_border_clamp
)) {
1143 /* any texture target */
1144 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1145 texObj
->WrapR
= eparam
;
1147 else if (texObj
->Target
!= GL_TEXTURE_RECTANGLE_NV
&&
1148 (eparam
== GL_REPEAT
||
1149 (eparam
== GL_MIRRORED_REPEAT_ARB
&&
1150 ctx
->Extensions
.ARB_texture_mirrored_repeat
) ||
1151 (eparam
== GL_MIRROR_CLAMP_ATI
&&
1152 ctx
->Extensions
.ATI_texture_mirror_once
) ||
1153 (eparam
== GL_MIRROR_CLAMP_TO_EDGE_ATI
&&
1154 ctx
->Extensions
.ATI_texture_mirror_once
))) {
1155 /* non-rectangle texture */
1156 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1157 texObj
->WrapR
= eparam
;
1160 _mesa_error( ctx
, GL_INVALID_VALUE
, "glTexParameter(param)" );
1163 case GL_TEXTURE_BORDER_COLOR
:
1164 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1165 texObj
->BorderColor
[RCOMP
] = params
[0];
1166 texObj
->BorderColor
[GCOMP
] = params
[1];
1167 texObj
->BorderColor
[BCOMP
] = params
[2];
1168 texObj
->BorderColor
[ACOMP
] = params
[3];
1169 UNCLAMPED_FLOAT_TO_CHAN(texObj
->_BorderChan
[RCOMP
], params
[0]);
1170 UNCLAMPED_FLOAT_TO_CHAN(texObj
->_BorderChan
[GCOMP
], params
[1]);
1171 UNCLAMPED_FLOAT_TO_CHAN(texObj
->_BorderChan
[BCOMP
], params
[2]);
1172 UNCLAMPED_FLOAT_TO_CHAN(texObj
->_BorderChan
[ACOMP
], params
[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 texObj
->ShadowAmbient
= CLAMP(params
[0], 0.0F
, 1.0F
);
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
);
1626 case GL_TEXTURE_BORDER_COLOR
:
1627 params
[0] = CLAMP(obj
->BorderColor
[0], 0.0F
, 1.0F
);
1628 params
[1] = CLAMP(obj
->BorderColor
[1], 0.0F
, 1.0F
);
1629 params
[2] = CLAMP(obj
->BorderColor
[2], 0.0F
, 1.0F
);
1630 params
[3] = CLAMP(obj
->BorderColor
[3], 0.0F
, 1.0F
);
1632 case GL_TEXTURE_RESIDENT
:
1635 if (ctx
->Driver
.IsTextureResident
)
1636 resident
= ctx
->Driver
.IsTextureResident(ctx
, obj
);
1639 *params
= ENUM_TO_FLOAT(resident
);
1642 case GL_TEXTURE_PRIORITY
:
1643 *params
= obj
->Priority
;
1645 case GL_TEXTURE_MIN_LOD
:
1646 *params
= obj
->MinLod
;
1648 case GL_TEXTURE_MAX_LOD
:
1649 *params
= obj
->MaxLod
;
1651 case GL_TEXTURE_BASE_LEVEL
:
1652 *params
= (GLfloat
) obj
->BaseLevel
;
1654 case GL_TEXTURE_MAX_LEVEL
:
1655 *params
= (GLfloat
) obj
->MaxLevel
;
1657 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1658 if (ctx
->Extensions
.EXT_texture_filter_anisotropic
) {
1659 *params
= obj
->MaxAnisotropy
;
1663 case GL_TEXTURE_COMPARE_SGIX
:
1664 if (ctx
->Extensions
.SGIX_shadow
) {
1665 *params
= (GLfloat
) obj
->CompareFlag
;
1669 case GL_TEXTURE_COMPARE_OPERATOR_SGIX
:
1670 if (ctx
->Extensions
.SGIX_shadow
) {
1671 *params
= (GLfloat
) obj
->CompareOperator
;
1675 case GL_SHADOW_AMBIENT_SGIX
: /* aka GL_TEXTURE_COMPARE_FAIL_VALUE_ARB */
1676 if (ctx
->Extensions
.SGIX_shadow_ambient
) {
1677 *params
= obj
->ShadowAmbient
;
1681 case GL_GENERATE_MIPMAP_SGIS
:
1682 if (ctx
->Extensions
.SGIS_generate_mipmap
) {
1683 *params
= (GLfloat
) obj
->GenerateMipmap
;
1687 case GL_TEXTURE_COMPARE_MODE_ARB
:
1688 if (ctx
->Extensions
.ARB_shadow
) {
1689 *params
= (GLfloat
) obj
->CompareMode
;
1693 case GL_TEXTURE_COMPARE_FUNC_ARB
:
1694 if (ctx
->Extensions
.ARB_shadow
) {
1695 *params
= (GLfloat
) obj
->CompareFunc
;
1699 case GL_DEPTH_TEXTURE_MODE_ARB
:
1700 if (ctx
->Extensions
.ARB_depth_texture
) {
1701 *params
= (GLfloat
) obj
->DepthMode
;
1706 ; /* silence warnings */
1708 /* If we get here, pname was an unrecognized enum */
1709 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexParameterfv(pname)" );
1714 _mesa_GetTexParameteriv( GLenum target
, GLenum pname
, GLint
*params
)
1716 GET_CURRENT_CONTEXT(ctx
);
1717 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1718 struct gl_texture_object
*obj
;
1719 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1721 obj
= _mesa_select_tex_object(ctx
, texUnit
, target
);
1723 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexParameteriv(target)");
1728 case GL_TEXTURE_MAG_FILTER
:
1729 *params
= (GLint
) obj
->MagFilter
;
1731 case GL_TEXTURE_MIN_FILTER
:
1732 *params
= (GLint
) obj
->MinFilter
;
1734 case GL_TEXTURE_WRAP_S
:
1735 *params
= (GLint
) obj
->WrapS
;
1737 case GL_TEXTURE_WRAP_T
:
1738 *params
= (GLint
) obj
->WrapT
;
1740 case GL_TEXTURE_WRAP_R_EXT
:
1741 *params
= (GLint
) obj
->WrapR
;
1743 case GL_TEXTURE_BORDER_COLOR
:
1746 b
[0] = CLAMP(obj
->BorderColor
[0], 0.0F
, 1.0F
);
1747 b
[1] = CLAMP(obj
->BorderColor
[1], 0.0F
, 1.0F
);
1748 b
[2] = CLAMP(obj
->BorderColor
[2], 0.0F
, 1.0F
);
1749 b
[3] = CLAMP(obj
->BorderColor
[3], 0.0F
, 1.0F
);
1750 params
[0] = FLOAT_TO_INT(b
[0]);
1751 params
[1] = FLOAT_TO_INT(b
[1]);
1752 params
[2] = FLOAT_TO_INT(b
[2]);
1753 params
[3] = FLOAT_TO_INT(b
[3]);
1756 case GL_TEXTURE_RESIDENT
:
1759 if (ctx
->Driver
.IsTextureResident
)
1760 resident
= ctx
->Driver
.IsTextureResident(ctx
, obj
);
1763 *params
= (GLint
) resident
;
1766 case GL_TEXTURE_PRIORITY
:
1767 *params
= (GLint
) obj
->Priority
;
1769 case GL_TEXTURE_MIN_LOD
:
1770 *params
= (GLint
) obj
->MinLod
;
1772 case GL_TEXTURE_MAX_LOD
:
1773 *params
= (GLint
) obj
->MaxLod
;
1775 case GL_TEXTURE_BASE_LEVEL
:
1776 *params
= obj
->BaseLevel
;
1778 case GL_TEXTURE_MAX_LEVEL
:
1779 *params
= obj
->MaxLevel
;
1781 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1782 if (ctx
->Extensions
.EXT_texture_filter_anisotropic
) {
1783 *params
= (GLint
) obj
->MaxAnisotropy
;
1787 case GL_TEXTURE_COMPARE_SGIX
:
1788 if (ctx
->Extensions
.SGIX_shadow
) {
1789 *params
= (GLint
) obj
->CompareFlag
;
1793 case GL_TEXTURE_COMPARE_OPERATOR_SGIX
:
1794 if (ctx
->Extensions
.SGIX_shadow
) {
1795 *params
= (GLint
) obj
->CompareOperator
;
1799 case GL_SHADOW_AMBIENT_SGIX
: /* aka GL_TEXTURE_COMPARE_FAIL_VALUE_ARB */
1800 if (ctx
->Extensions
.SGIX_shadow_ambient
) {
1801 *params
= (GLint
) FLOAT_TO_INT(obj
->ShadowAmbient
);
1805 case GL_GENERATE_MIPMAP_SGIS
:
1806 if (ctx
->Extensions
.SGIS_generate_mipmap
) {
1807 *params
= (GLint
) obj
->GenerateMipmap
;
1811 case GL_TEXTURE_COMPARE_MODE_ARB
:
1812 if (ctx
->Extensions
.ARB_shadow
) {
1813 *params
= (GLint
) obj
->CompareMode
;
1817 case GL_TEXTURE_COMPARE_FUNC_ARB
:
1818 if (ctx
->Extensions
.ARB_shadow
) {
1819 *params
= (GLint
) obj
->CompareFunc
;
1823 case GL_DEPTH_TEXTURE_MODE_ARB
:
1824 if (ctx
->Extensions
.ARB_depth_texture
) {
1825 *params
= (GLint
) obj
->DepthMode
;
1830 ; /* silence warnings */
1832 /* If we get here, pname was an unrecognized enum */
1833 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexParameteriv(pname)" );
1839 /**********************************************************************/
1840 /* Texture Coord Generation */
1841 /**********************************************************************/
1845 _mesa_TexGenfv( GLenum coord
, GLenum pname
, const GLfloat
*params
)
1847 GET_CURRENT_CONTEXT(ctx
);
1848 GLuint tUnit
= ctx
->Texture
.CurrentUnit
;
1849 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[tUnit
];
1850 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1852 if (MESA_VERBOSE
&(VERBOSE_API
|VERBOSE_TEXTURE
))
1853 _mesa_debug(ctx
, "texGEN %s %s %x...\n",
1854 _mesa_lookup_enum_by_nr(coord
),
1855 _mesa_lookup_enum_by_nr(pname
),
1860 if (pname
==GL_TEXTURE_GEN_MODE
) {
1861 GLenum mode
= (GLenum
) (GLint
) *params
;
1864 case GL_OBJECT_LINEAR
:
1865 bits
= TEXGEN_OBJ_LINEAR
;
1868 bits
= TEXGEN_EYE_LINEAR
;
1870 case GL_REFLECTION_MAP_NV
:
1871 bits
= TEXGEN_REFLECTION_MAP_NV
;
1873 case GL_NORMAL_MAP_NV
:
1874 bits
= TEXGEN_NORMAL_MAP_NV
;
1877 bits
= TEXGEN_SPHERE_MAP
;
1880 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(param)" );
1883 if (texUnit
->GenModeS
== mode
)
1885 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1886 texUnit
->GenModeS
= mode
;
1887 texUnit
->_GenBitS
= bits
;
1889 else if (pname
==GL_OBJECT_PLANE
) {
1890 if (TEST_EQ_4V(texUnit
->ObjectPlaneS
, params
))
1892 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1893 texUnit
->ObjectPlaneS
[0] = params
[0];
1894 texUnit
->ObjectPlaneS
[1] = params
[1];
1895 texUnit
->ObjectPlaneS
[2] = params
[2];
1896 texUnit
->ObjectPlaneS
[3] = params
[3];
1898 else if (pname
==GL_EYE_PLANE
) {
1901 /* Transform plane equation by the inverse modelview matrix */
1902 if (ctx
->ModelviewMatrixStack
.Top
->flags
& MAT_DIRTY_INVERSE
) {
1903 _math_matrix_analyse( ctx
->ModelviewMatrixStack
.Top
);
1905 _mesa_transform_vector( tmp
, params
, ctx
->ModelviewMatrixStack
.Top
->inv
);
1906 if (TEST_EQ_4V(texUnit
->EyePlaneS
, tmp
))
1908 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1909 COPY_4FV(texUnit
->EyePlaneS
, tmp
);
1912 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(pname)" );
1917 if (pname
==GL_TEXTURE_GEN_MODE
) {
1918 GLenum mode
= (GLenum
) (GLint
) *params
;
1921 case GL_OBJECT_LINEAR
:
1922 bitt
= TEXGEN_OBJ_LINEAR
;
1925 bitt
= TEXGEN_EYE_LINEAR
;
1927 case GL_REFLECTION_MAP_NV
:
1928 bitt
= TEXGEN_REFLECTION_MAP_NV
;
1930 case GL_NORMAL_MAP_NV
:
1931 bitt
= TEXGEN_NORMAL_MAP_NV
;
1934 bitt
= TEXGEN_SPHERE_MAP
;
1937 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(param)" );
1940 if (texUnit
->GenModeT
== mode
)
1942 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1943 texUnit
->GenModeT
= mode
;
1944 texUnit
->_GenBitT
= bitt
;
1946 else if (pname
==GL_OBJECT_PLANE
) {
1947 if (TEST_EQ_4V(texUnit
->ObjectPlaneT
, params
))
1949 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1950 texUnit
->ObjectPlaneT
[0] = params
[0];
1951 texUnit
->ObjectPlaneT
[1] = params
[1];
1952 texUnit
->ObjectPlaneT
[2] = params
[2];
1953 texUnit
->ObjectPlaneT
[3] = params
[3];
1955 else if (pname
==GL_EYE_PLANE
) {
1957 /* Transform plane equation by the inverse modelview matrix */
1958 if (ctx
->ModelviewMatrixStack
.Top
->flags
& MAT_DIRTY_INVERSE
) {
1959 _math_matrix_analyse( ctx
->ModelviewMatrixStack
.Top
);
1961 _mesa_transform_vector( tmp
, params
, ctx
->ModelviewMatrixStack
.Top
->inv
);
1962 if (TEST_EQ_4V(texUnit
->EyePlaneT
, tmp
))
1964 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1965 COPY_4FV(texUnit
->EyePlaneT
, tmp
);
1968 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(pname)" );
1973 if (pname
==GL_TEXTURE_GEN_MODE
) {
1974 GLenum mode
= (GLenum
) (GLint
) *params
;
1977 case GL_OBJECT_LINEAR
:
1978 bitr
= TEXGEN_OBJ_LINEAR
;
1980 case GL_REFLECTION_MAP_NV
:
1981 bitr
= TEXGEN_REFLECTION_MAP_NV
;
1983 case GL_NORMAL_MAP_NV
:
1984 bitr
= TEXGEN_NORMAL_MAP_NV
;
1987 bitr
= TEXGEN_EYE_LINEAR
;
1990 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(param)" );
1993 if (texUnit
->GenModeR
== mode
)
1995 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1996 texUnit
->GenModeR
= mode
;
1997 texUnit
->_GenBitR
= bitr
;
1999 else if (pname
==GL_OBJECT_PLANE
) {
2000 if (TEST_EQ_4V(texUnit
->ObjectPlaneR
, params
))
2002 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
2003 texUnit
->ObjectPlaneR
[0] = params
[0];
2004 texUnit
->ObjectPlaneR
[1] = params
[1];
2005 texUnit
->ObjectPlaneR
[2] = params
[2];
2006 texUnit
->ObjectPlaneR
[3] = params
[3];
2008 else if (pname
==GL_EYE_PLANE
) {
2010 /* Transform plane equation by the inverse modelview matrix */
2011 if (ctx
->ModelviewMatrixStack
.Top
->flags
& MAT_DIRTY_INVERSE
) {
2012 _math_matrix_analyse( ctx
->ModelviewMatrixStack
.Top
);
2014 _mesa_transform_vector( tmp
, params
, ctx
->ModelviewMatrixStack
.Top
->inv
);
2015 if (TEST_EQ_4V(texUnit
->EyePlaneR
, tmp
))
2017 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
2018 COPY_4FV(texUnit
->EyePlaneR
, tmp
);
2021 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(pname)" );
2026 if (pname
==GL_TEXTURE_GEN_MODE
) {
2027 GLenum mode
= (GLenum
) (GLint
) *params
;
2030 case GL_OBJECT_LINEAR
:
2031 bitq
= TEXGEN_OBJ_LINEAR
;
2034 bitq
= TEXGEN_EYE_LINEAR
;
2037 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(param)" );
2040 if (texUnit
->GenModeQ
== mode
)
2042 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
2043 texUnit
->GenModeQ
= mode
;
2044 texUnit
->_GenBitQ
= bitq
;
2046 else if (pname
==GL_OBJECT_PLANE
) {
2047 if (TEST_EQ_4V(texUnit
->ObjectPlaneQ
, params
))
2049 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
2050 texUnit
->ObjectPlaneQ
[0] = params
[0];
2051 texUnit
->ObjectPlaneQ
[1] = params
[1];
2052 texUnit
->ObjectPlaneQ
[2] = params
[2];
2053 texUnit
->ObjectPlaneQ
[3] = params
[3];
2055 else if (pname
==GL_EYE_PLANE
) {
2057 /* Transform plane equation by the inverse modelview matrix */
2058 if (ctx
->ModelviewMatrixStack
.Top
->flags
& MAT_DIRTY_INVERSE
) {
2059 _math_matrix_analyse( ctx
->ModelviewMatrixStack
.Top
);
2061 _mesa_transform_vector( tmp
, params
, ctx
->ModelviewMatrixStack
.Top
->inv
);
2062 if (TEST_EQ_4V(texUnit
->EyePlaneQ
, tmp
))
2064 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
2065 COPY_4FV(texUnit
->EyePlaneQ
, tmp
);
2068 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(pname)" );
2073 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(coord)" );
2077 if (ctx
->Driver
.TexGen
)
2078 ctx
->Driver
.TexGen( ctx
, coord
, pname
, params
);
2083 _mesa_TexGeniv(GLenum coord
, GLenum pname
, const GLint
*params
)
2086 p
[0] = (GLfloat
) params
[0];
2087 p
[1] = (GLfloat
) params
[1];
2088 p
[2] = (GLfloat
) params
[2];
2089 p
[3] = (GLfloat
) params
[3];
2090 _mesa_TexGenfv(coord
, pname
, p
);
2095 _mesa_TexGend(GLenum coord
, GLenum pname
, GLdouble param
)
2097 GLfloat p
= (GLfloat
) param
;
2098 _mesa_TexGenfv( coord
, pname
, &p
);
2103 _mesa_TexGendv(GLenum coord
, GLenum pname
, const GLdouble
*params
)
2106 p
[0] = (GLfloat
) params
[0];
2107 p
[1] = (GLfloat
) params
[1];
2108 p
[2] = (GLfloat
) params
[2];
2109 p
[3] = (GLfloat
) params
[3];
2110 _mesa_TexGenfv( coord
, pname
, p
);
2115 _mesa_TexGenf( GLenum coord
, GLenum pname
, GLfloat param
)
2117 _mesa_TexGenfv(coord
, pname
, ¶m
);
2122 _mesa_TexGeni( GLenum coord
, GLenum pname
, GLint param
)
2124 _mesa_TexGeniv( coord
, pname
, ¶m
);
2130 _mesa_GetTexGendv( GLenum coord
, GLenum pname
, GLdouble
*params
)
2132 GET_CURRENT_CONTEXT(ctx
);
2133 GLuint tUnit
= ctx
->Texture
.CurrentUnit
;
2134 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[tUnit
];
2135 ASSERT_OUTSIDE_BEGIN_END(ctx
);
2139 if (pname
==GL_TEXTURE_GEN_MODE
) {
2140 params
[0] = ENUM_TO_DOUBLE(texUnit
->GenModeS
);
2142 else if (pname
==GL_OBJECT_PLANE
) {
2143 COPY_4V( params
, texUnit
->ObjectPlaneS
);
2145 else if (pname
==GL_EYE_PLANE
) {
2146 COPY_4V( params
, texUnit
->EyePlaneS
);
2149 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGendv(pname)" );
2154 if (pname
==GL_TEXTURE_GEN_MODE
) {
2155 params
[0] = ENUM_TO_DOUBLE(texUnit
->GenModeT
);
2157 else if (pname
==GL_OBJECT_PLANE
) {
2158 COPY_4V( params
, texUnit
->ObjectPlaneT
);
2160 else if (pname
==GL_EYE_PLANE
) {
2161 COPY_4V( params
, texUnit
->EyePlaneT
);
2164 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGendv(pname)" );
2169 if (pname
==GL_TEXTURE_GEN_MODE
) {
2170 params
[0] = ENUM_TO_DOUBLE(texUnit
->GenModeR
);
2172 else if (pname
==GL_OBJECT_PLANE
) {
2173 COPY_4V( params
, texUnit
->ObjectPlaneR
);
2175 else if (pname
==GL_EYE_PLANE
) {
2176 COPY_4V( params
, texUnit
->EyePlaneR
);
2179 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGendv(pname)" );
2184 if (pname
==GL_TEXTURE_GEN_MODE
) {
2185 params
[0] = ENUM_TO_DOUBLE(texUnit
->GenModeQ
);
2187 else if (pname
==GL_OBJECT_PLANE
) {
2188 COPY_4V( params
, texUnit
->ObjectPlaneQ
);
2190 else if (pname
==GL_EYE_PLANE
) {
2191 COPY_4V( params
, texUnit
->EyePlaneQ
);
2194 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGendv(pname)" );
2199 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGendv(coord)" );
2207 _mesa_GetTexGenfv( GLenum coord
, GLenum pname
, GLfloat
*params
)
2209 GET_CURRENT_CONTEXT(ctx
);
2210 GLuint tUnit
= ctx
->Texture
.CurrentUnit
;
2211 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[tUnit
];
2212 ASSERT_OUTSIDE_BEGIN_END(ctx
);
2216 if (pname
==GL_TEXTURE_GEN_MODE
) {
2217 params
[0] = ENUM_TO_FLOAT(texUnit
->GenModeS
);
2219 else if (pname
==GL_OBJECT_PLANE
) {
2220 COPY_4V( params
, texUnit
->ObjectPlaneS
);
2222 else if (pname
==GL_EYE_PLANE
) {
2223 COPY_4V( params
, texUnit
->EyePlaneS
);
2226 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGenfv(pname)" );
2231 if (pname
==GL_TEXTURE_GEN_MODE
) {
2232 params
[0] = ENUM_TO_FLOAT(texUnit
->GenModeT
);
2234 else if (pname
==GL_OBJECT_PLANE
) {
2235 COPY_4V( params
, texUnit
->ObjectPlaneT
);
2237 else if (pname
==GL_EYE_PLANE
) {
2238 COPY_4V( params
, texUnit
->EyePlaneT
);
2241 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGenfv(pname)" );
2246 if (pname
==GL_TEXTURE_GEN_MODE
) {
2247 params
[0] = ENUM_TO_FLOAT(texUnit
->GenModeR
);
2249 else if (pname
==GL_OBJECT_PLANE
) {
2250 COPY_4V( params
, texUnit
->ObjectPlaneR
);
2252 else if (pname
==GL_EYE_PLANE
) {
2253 COPY_4V( params
, texUnit
->EyePlaneR
);
2256 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGenfv(pname)" );
2261 if (pname
==GL_TEXTURE_GEN_MODE
) {
2262 params
[0] = ENUM_TO_FLOAT(texUnit
->GenModeQ
);
2264 else if (pname
==GL_OBJECT_PLANE
) {
2265 COPY_4V( params
, texUnit
->ObjectPlaneQ
);
2267 else if (pname
==GL_EYE_PLANE
) {
2268 COPY_4V( params
, texUnit
->EyePlaneQ
);
2271 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGenfv(pname)" );
2276 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGenfv(coord)" );
2284 _mesa_GetTexGeniv( GLenum coord
, GLenum pname
, GLint
*params
)
2286 GET_CURRENT_CONTEXT(ctx
);
2287 GLuint tUnit
= ctx
->Texture
.CurrentUnit
;
2288 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[tUnit
];
2289 ASSERT_OUTSIDE_BEGIN_END(ctx
);
2293 if (pname
==GL_TEXTURE_GEN_MODE
) {
2294 params
[0] = texUnit
->GenModeS
;
2296 else if (pname
==GL_OBJECT_PLANE
) {
2297 params
[0] = (GLint
) texUnit
->ObjectPlaneS
[0];
2298 params
[1] = (GLint
) texUnit
->ObjectPlaneS
[1];
2299 params
[2] = (GLint
) texUnit
->ObjectPlaneS
[2];
2300 params
[3] = (GLint
) texUnit
->ObjectPlaneS
[3];
2302 else if (pname
==GL_EYE_PLANE
) {
2303 params
[0] = (GLint
) texUnit
->EyePlaneS
[0];
2304 params
[1] = (GLint
) texUnit
->EyePlaneS
[1];
2305 params
[2] = (GLint
) texUnit
->EyePlaneS
[2];
2306 params
[3] = (GLint
) texUnit
->EyePlaneS
[3];
2309 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGeniv(pname)" );
2314 if (pname
==GL_TEXTURE_GEN_MODE
) {
2315 params
[0] = texUnit
->GenModeT
;
2317 else if (pname
==GL_OBJECT_PLANE
) {
2318 params
[0] = (GLint
) texUnit
->ObjectPlaneT
[0];
2319 params
[1] = (GLint
) texUnit
->ObjectPlaneT
[1];
2320 params
[2] = (GLint
) texUnit
->ObjectPlaneT
[2];
2321 params
[3] = (GLint
) texUnit
->ObjectPlaneT
[3];
2323 else if (pname
==GL_EYE_PLANE
) {
2324 params
[0] = (GLint
) texUnit
->EyePlaneT
[0];
2325 params
[1] = (GLint
) texUnit
->EyePlaneT
[1];
2326 params
[2] = (GLint
) texUnit
->EyePlaneT
[2];
2327 params
[3] = (GLint
) texUnit
->EyePlaneT
[3];
2330 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGeniv(pname)" );
2335 if (pname
==GL_TEXTURE_GEN_MODE
) {
2336 params
[0] = texUnit
->GenModeR
;
2338 else if (pname
==GL_OBJECT_PLANE
) {
2339 params
[0] = (GLint
) texUnit
->ObjectPlaneR
[0];
2340 params
[1] = (GLint
) texUnit
->ObjectPlaneR
[1];
2341 params
[2] = (GLint
) texUnit
->ObjectPlaneR
[2];
2342 params
[3] = (GLint
) texUnit
->ObjectPlaneR
[3];
2344 else if (pname
==GL_EYE_PLANE
) {
2345 params
[0] = (GLint
) texUnit
->EyePlaneR
[0];
2346 params
[1] = (GLint
) texUnit
->EyePlaneR
[1];
2347 params
[2] = (GLint
) texUnit
->EyePlaneR
[2];
2348 params
[3] = (GLint
) texUnit
->EyePlaneR
[3];
2351 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGeniv(pname)" );
2356 if (pname
==GL_TEXTURE_GEN_MODE
) {
2357 params
[0] = texUnit
->GenModeQ
;
2359 else if (pname
==GL_OBJECT_PLANE
) {
2360 params
[0] = (GLint
) texUnit
->ObjectPlaneQ
[0];
2361 params
[1] = (GLint
) texUnit
->ObjectPlaneQ
[1];
2362 params
[2] = (GLint
) texUnit
->ObjectPlaneQ
[2];
2363 params
[3] = (GLint
) texUnit
->ObjectPlaneQ
[3];
2365 else if (pname
==GL_EYE_PLANE
) {
2366 params
[0] = (GLint
) texUnit
->EyePlaneQ
[0];
2367 params
[1] = (GLint
) texUnit
->EyePlaneQ
[1];
2368 params
[2] = (GLint
) texUnit
->EyePlaneQ
[2];
2369 params
[3] = (GLint
) texUnit
->EyePlaneQ
[3];
2372 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGeniv(pname)" );
2377 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGeniv(coord)" );
2383 /* GL_ARB_multitexture */
2385 _mesa_ActiveTextureARB( GLenum target
)
2387 GET_CURRENT_CONTEXT(ctx
);
2388 GLuint texUnit
= target
- GL_TEXTURE0_ARB
;
2389 ASSERT_OUTSIDE_BEGIN_END(ctx
);
2391 if (MESA_VERBOSE
& (VERBOSE_API
|VERBOSE_TEXTURE
))
2392 _mesa_debug(ctx
, "glActiveTexture %s\n",
2393 _mesa_lookup_enum_by_nr(target
));
2395 if (texUnit
> ctx
->Const
.MaxTextureUnits
) {
2396 _mesa_error(ctx
, GL_INVALID_ENUM
, "glActiveTextureARB(target)");
2400 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
2401 ctx
->Texture
.CurrentUnit
= texUnit
;
2402 if (ctx
->Driver
.ActiveTexture
) {
2403 (*ctx
->Driver
.ActiveTexture
)( ctx
, (GLuint
) texUnit
);
2408 /* GL_ARB_multitexture */
2410 _mesa_ClientActiveTextureARB( GLenum target
)
2412 GET_CURRENT_CONTEXT(ctx
);
2413 GLuint texUnit
= target
- GL_TEXTURE0_ARB
;
2414 ASSERT_OUTSIDE_BEGIN_END(ctx
);
2416 if (texUnit
> ctx
->Const
.MaxTextureUnits
) {
2417 _mesa_error(ctx
, GL_INVALID_ENUM
, "glClientActiveTextureARB(target)");
2421 FLUSH_VERTICES(ctx
, _NEW_ARRAY
);
2422 ctx
->Array
.ActiveTexture
= texUnit
;
2427 /**********************************************************************/
2428 /* Pixel Texgen Extensions */
2429 /**********************************************************************/
2432 _mesa_PixelTexGenSGIX(GLenum mode
)
2434 GLenum newRgbSource
, newAlphaSource
;
2435 GET_CURRENT_CONTEXT(ctx
);
2436 ASSERT_OUTSIDE_BEGIN_END(ctx
);
2440 newRgbSource
= GL_PIXEL_GROUP_COLOR_SGIS
;
2441 newAlphaSource
= GL_PIXEL_GROUP_COLOR_SGIS
;
2444 newRgbSource
= GL_PIXEL_GROUP_COLOR_SGIS
;
2445 newAlphaSource
= GL_CURRENT_RASTER_COLOR
;
2448 newRgbSource
= GL_CURRENT_RASTER_COLOR
;
2449 newAlphaSource
= GL_PIXEL_GROUP_COLOR_SGIS
;
2452 newRgbSource
= GL_CURRENT_RASTER_COLOR
;
2453 newAlphaSource
= GL_CURRENT_RASTER_COLOR
;
2456 _mesa_error(ctx
, GL_INVALID_ENUM
, "glPixelTexGenSGIX(mode)");
2460 if (newRgbSource
== ctx
->Pixel
.FragmentRgbSource
&&
2461 newAlphaSource
== ctx
->Pixel
.FragmentAlphaSource
)
2464 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
2465 ctx
->Pixel
.FragmentRgbSource
= newRgbSource
;
2466 ctx
->Pixel
.FragmentAlphaSource
= newAlphaSource
;
2471 _mesa_PixelTexGenParameterfSGIS(GLenum target
, GLfloat value
)
2473 _mesa_PixelTexGenParameteriSGIS(target
, (GLint
) value
);
2478 _mesa_PixelTexGenParameterfvSGIS(GLenum target
, const GLfloat
*value
)
2480 _mesa_PixelTexGenParameteriSGIS(target
, (GLint
) *value
);
2485 _mesa_PixelTexGenParameteriSGIS(GLenum target
, GLint value
)
2487 GET_CURRENT_CONTEXT(ctx
);
2488 ASSERT_OUTSIDE_BEGIN_END(ctx
);
2490 if (value
!= GL_CURRENT_RASTER_COLOR
&& value
!= GL_PIXEL_GROUP_COLOR_SGIS
) {
2491 _mesa_error(ctx
, GL_INVALID_ENUM
, "glPixelTexGenParameterSGIS(value)");
2496 case GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS
:
2497 if (ctx
->Pixel
.FragmentRgbSource
== (GLenum
) value
)
2499 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
2500 ctx
->Pixel
.FragmentRgbSource
= (GLenum
) value
;
2502 case GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS
:
2503 if (ctx
->Pixel
.FragmentAlphaSource
== (GLenum
) value
)
2505 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
2506 ctx
->Pixel
.FragmentAlphaSource
= (GLenum
) value
;
2509 _mesa_error(ctx
, GL_INVALID_ENUM
, "glPixelTexGenParameterSGIS(target)");
2516 _mesa_PixelTexGenParameterivSGIS(GLenum target
, const GLint
*value
)
2518 _mesa_PixelTexGenParameteriSGIS(target
, *value
);
2523 _mesa_GetPixelTexGenParameterfvSGIS(GLenum target
, GLfloat
*value
)
2525 GET_CURRENT_CONTEXT(ctx
);
2526 ASSERT_OUTSIDE_BEGIN_END(ctx
);
2528 if (target
== GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS
) {
2529 *value
= (GLfloat
) ctx
->Pixel
.FragmentRgbSource
;
2531 else if (target
== GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS
) {
2532 *value
= (GLfloat
) ctx
->Pixel
.FragmentAlphaSource
;
2535 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetPixelTexGenParameterfvSGIS(target)");
2541 _mesa_GetPixelTexGenParameterivSGIS(GLenum target
, GLint
*value
)
2543 GET_CURRENT_CONTEXT(ctx
);
2544 ASSERT_OUTSIDE_BEGIN_END(ctx
);
2546 if (target
== GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS
) {
2547 *value
= (GLint
) ctx
->Pixel
.FragmentRgbSource
;
2549 else if (target
== GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS
) {
2550 *value
= (GLint
) ctx
->Pixel
.FragmentAlphaSource
;
2553 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetPixelTexGenParameterivSGIS(target)");