1 /* $Id: texstate.c,v 1.76 2002/06/17 23:36:31 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) \
136 sprintf(s, msg, _mesa_lookup_enum_by_nr(value)); \
137 _mesa_error(ctx, errCode, s); \
140 if (target
== GL_TEXTURE_ENV
) {
142 case GL_TEXTURE_ENV_MODE
:
144 const GLenum mode
= (GLenum
) (GLint
) *param
;
145 if (mode
== GL_MODULATE
||
148 mode
== GL_REPLACE
||
149 (mode
== GL_ADD
&& ctx
->Extensions
.EXT_texture_env_add
) ||
150 (mode
== GL_COMBINE_EXT
&&
151 (ctx
->Extensions
.EXT_texture_env_combine
||
152 ctx
->Extensions
.ARB_texture_env_combine
))) {
154 if (texUnit
->EnvMode
== mode
)
156 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
157 texUnit
->EnvMode
= mode
;
160 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", mode
);
165 case GL_TEXTURE_ENV_COLOR
:
168 tmp
[0] = CLAMP( param
[0], 0.0F
, 1.0F
);
169 tmp
[1] = CLAMP( param
[1], 0.0F
, 1.0F
);
170 tmp
[2] = CLAMP( param
[2], 0.0F
, 1.0F
);
171 tmp
[3] = CLAMP( param
[3], 0.0F
, 1.0F
);
172 if (TEST_EQ_4V(tmp
, texUnit
->EnvColor
))
174 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
175 COPY_4FV(texUnit
->EnvColor
, tmp
);
178 case GL_COMBINE_RGB_EXT
:
179 if (ctx
->Extensions
.EXT_texture_env_combine
||
180 ctx
->Extensions
.ARB_texture_env_combine
) {
181 const GLenum mode
= (GLenum
) (GLint
) *param
;
186 case GL_ADD_SIGNED_EXT
:
187 case GL_INTERPOLATE_EXT
:
190 case GL_SUBTRACT_ARB
:
191 if (!ctx
->Extensions
.ARB_texture_env_combine
) {
192 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", mode
);
196 case GL_DOT3_RGB_EXT
:
197 case GL_DOT3_RGBA_EXT
:
198 if (!ctx
->Extensions
.EXT_texture_env_dot3
) {
199 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", mode
);
203 case GL_DOT3_RGB_ARB
:
204 case GL_DOT3_RGBA_ARB
:
205 if (!ctx
->Extensions
.ARB_texture_env_dot3
) {
206 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", mode
);
211 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", mode
);
214 if (texUnit
->CombineModeRGB
== mode
)
216 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
217 texUnit
->CombineModeRGB
= mode
;
220 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(pname=%s)", pname
);
224 case GL_COMBINE_ALPHA_EXT
:
225 if (ctx
->Extensions
.EXT_texture_env_combine
||
226 ctx
->Extensions
.ARB_texture_env_combine
) {
227 const GLenum mode
= (GLenum
) (GLint
) *param
;
228 if (mode
== GL_REPLACE
||
229 mode
== GL_MODULATE
||
231 mode
== GL_ADD_SIGNED_EXT
||
232 mode
== GL_INTERPOLATE_EXT
||
233 (mode
== GL_SUBTRACT_ARB
&&
234 ctx
->Extensions
.ARB_texture_env_combine
)) {
236 if (texUnit
->CombineModeA
== mode
)
238 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
239 texUnit
->CombineModeA
= mode
;
242 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", mode
);
247 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(pname=%s)", pname
);
251 case GL_SOURCE0_RGB_EXT
:
252 case GL_SOURCE1_RGB_EXT
:
253 case GL_SOURCE2_RGB_EXT
:
254 if (ctx
->Extensions
.EXT_texture_env_combine
||
255 ctx
->Extensions
.ARB_texture_env_combine
) {
256 const GLenum source
= (GLenum
) (GLint
) *param
;
257 const GLuint s
= pname
- GL_SOURCE0_RGB_EXT
;
258 if (source
== GL_TEXTURE
||
259 source
== GL_CONSTANT_EXT
||
260 source
== GL_PRIMARY_COLOR_EXT
||
261 source
== GL_PREVIOUS_EXT
||
262 (ctx
->Extensions
.ARB_texture_env_crossbar
&&
263 source
>= GL_TEXTURE0_ARB
&&
264 source
< GL_TEXTURE0_ARB
+ ctx
->Const
.MaxTextureUnits
)) {
266 if (texUnit
->CombineSourceRGB
[s
] == source
)
268 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
269 texUnit
->CombineSourceRGB
[s
] = source
;
272 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", source
);
277 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(pname=%s)", pname
);
281 case GL_SOURCE0_ALPHA_EXT
:
282 case GL_SOURCE1_ALPHA_EXT
:
283 case GL_SOURCE2_ALPHA_EXT
:
284 if (ctx
->Extensions
.EXT_texture_env_combine
||
285 ctx
->Extensions
.ARB_texture_env_combine
) {
286 const GLenum source
= (GLenum
) (GLint
) *param
;
287 const GLuint s
= pname
- GL_SOURCE0_ALPHA_EXT
;
288 if (source
== GL_TEXTURE
||
289 source
== GL_CONSTANT_EXT
||
290 source
== GL_PRIMARY_COLOR_EXT
||
291 source
== GL_PREVIOUS_EXT
||
292 (ctx
->Extensions
.ARB_texture_env_crossbar
&&
293 source
>= GL_TEXTURE0_ARB
&&
294 source
< GL_TEXTURE0_ARB
+ ctx
->Const
.MaxTextureUnits
)) {
296 if (texUnit
->CombineSourceA
[s
] == source
)
298 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
299 texUnit
->CombineSourceA
[s
] = source
;
302 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", source
);
307 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(pname=%s)", pname
);
311 case GL_OPERAND0_RGB_EXT
:
312 case GL_OPERAND1_RGB_EXT
:
313 if (ctx
->Extensions
.EXT_texture_env_combine
||
314 ctx
->Extensions
.ARB_texture_env_combine
) {
315 const GLenum operand
= (GLenum
) (GLint
) *param
;
316 const GLuint s
= pname
- GL_OPERAND0_RGB_EXT
;
319 case GL_ONE_MINUS_SRC_COLOR
:
321 case GL_ONE_MINUS_SRC_ALPHA
:
322 if (texUnit
->CombineOperandRGB
[s
] == operand
)
324 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
325 texUnit
->CombineOperandRGB
[s
] = operand
;
328 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", operand
);
333 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(pname=%s)", pname
);
337 case GL_OPERAND0_ALPHA_EXT
:
338 case GL_OPERAND1_ALPHA_EXT
:
339 if (ctx
->Extensions
.EXT_texture_env_combine
||
340 ctx
->Extensions
.ARB_texture_env_combine
) {
341 const GLenum operand
= (GLenum
) (GLint
) *param
;
344 case GL_ONE_MINUS_SRC_ALPHA
:
345 if (texUnit
->CombineOperandA
[pname
-GL_OPERAND0_ALPHA_EXT
] ==
348 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
349 texUnit
->CombineOperandA
[pname
-GL_OPERAND0_ALPHA_EXT
] = operand
;
352 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", operand
);
357 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(pname=%s)", pname
);
361 case GL_OPERAND2_RGB_EXT
:
362 if (ctx
->Extensions
.EXT_texture_env_combine
||
363 ctx
->Extensions
.ARB_texture_env_combine
) {
364 const GLenum operand
= (GLenum
) (GLint
) *param
;
366 case GL_SRC_COLOR
: /* ARB combine only */
367 case GL_ONE_MINUS_SRC_COLOR
: /* ARB combine only */
369 case GL_ONE_MINUS_SRC_ALPHA
: /* ARB combine only */
370 if (texUnit
->CombineOperandRGB
[2] == operand
)
372 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
373 texUnit
->CombineOperandRGB
[2] = operand
;
375 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", operand
);
380 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(pname=%s)", pname
);
384 case GL_OPERAND2_ALPHA_EXT
:
385 if (ctx
->Extensions
.EXT_texture_env_combine
||
386 ctx
->Extensions
.ARB_texture_env_combine
) {
387 const GLenum operand
= (GLenum
) (GLint
) *param
;
390 case GL_ONE_MINUS_SRC_ALPHA
: /* ARB combine only */
391 if (texUnit
->CombineOperandA
[2] == operand
)
393 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
394 texUnit
->CombineOperandA
[2] = operand
;
397 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", operand
);
402 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(pname=%s)", pname
);
406 case GL_RGB_SCALE_EXT
:
407 if (ctx
->Extensions
.EXT_texture_env_combine
||
408 ctx
->Extensions
.ARB_texture_env_combine
) {
413 else if (*param
== 2.0) {
416 else if (*param
== 4.0) {
420 _mesa_error( ctx
, GL_INVALID_VALUE
,
421 "glTexEnv(GL_RGB_SCALE not 1, 2 or 4)" );
424 if (texUnit
->CombineScaleShiftRGB
== newshift
)
426 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
427 texUnit
->CombineScaleShiftRGB
= newshift
;
430 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(pname=%s)", pname
);
435 if (ctx
->Extensions
.EXT_texture_env_combine
||
436 ctx
->Extensions
.ARB_texture_env_combine
) {
441 else if (*param
== 2.0) {
444 else if (*param
== 4.0) {
448 _mesa_error( ctx
, GL_INVALID_VALUE
,
449 "glTexEnv(GL_ALPHA_SCALE not 1, 2 or 4)" );
452 if (texUnit
->CombineScaleShiftA
== newshift
)
454 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
455 texUnit
->CombineScaleShiftA
= newshift
;
458 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(pname=%s)", pname
);
463 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexEnv(pname)" );
467 else if (target
== GL_TEXTURE_FILTER_CONTROL_EXT
) {
468 /* GL_EXT_texture_lod_bias */
469 if (!ctx
->Extensions
.EXT_texture_lod_bias
) {
470 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexEnv(target)" );
473 if (pname
== GL_TEXTURE_LOD_BIAS_EXT
) {
474 if (texUnit
->LodBias
== param
[0])
476 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
477 texUnit
->LodBias
= CLAMP(param
[0], -ctx
->Const
.MaxTextureLodBias
,
478 ctx
->Const
.MaxTextureLodBias
);
481 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(pname=%s)", pname
);
485 else if (target
== GL_POINT_SPRITE_NV
) {
486 /* GL_NV_point_sprite */
487 if (!ctx
->Extensions
.NV_point_sprite
) {
488 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexEnv(target)" );
491 if (pname
== GL_COORD_REPLACE_NV
) {
492 const GLenum value
= (GLenum
) param
[0];
493 if (value
== GL_TRUE
|| value
== GL_FALSE
) {
494 /* It's kind of weird to set point state via glTexEnv,
495 * but that's what the spec calls for.
497 const GLboolean state
= (GLboolean
) value
;
498 if (ctx
->Point
.CoordReplace
[ctx
->Texture
.CurrentUnit
] == state
)
500 FLUSH_VERTICES(ctx
, _NEW_POINT
);
501 ctx
->Point
.CoordReplace
[ctx
->Texture
.CurrentUnit
] = state
;
504 _mesa_error( ctx
, GL_INVALID_VALUE
, "glTexEnv(param)" );
509 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexEnv(pname)" );
514 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexEnv(target)" );
518 if (MESA_VERBOSE
&(VERBOSE_API
|VERBOSE_TEXTURE
))
519 _mesa_debug(ctx
, "glTexEnv %s %s %.1f(%s) ...\n",
520 _mesa_lookup_enum_by_nr(target
),
521 _mesa_lookup_enum_by_nr(pname
),
523 _mesa_lookup_enum_by_nr((GLenum
) (GLint
) *param
));
525 /* Tell device driver about the new texture environment */
526 if (ctx
->Driver
.TexEnv
) {
527 (*ctx
->Driver
.TexEnv
)( ctx
, target
, pname
, param
);
533 _mesa_TexEnvf( GLenum target
, GLenum pname
, GLfloat param
)
535 _mesa_TexEnvfv( target
, pname
, ¶m
);
541 _mesa_TexEnvi( GLenum target
, GLenum pname
, GLint param
)
544 p
[0] = (GLfloat
) param
;
545 p
[1] = p
[2] = p
[3] = 0.0;
546 _mesa_TexEnvfv( target
, pname
, p
);
551 _mesa_TexEnviv( GLenum target
, GLenum pname
, const GLint
*param
)
554 if (pname
== GL_TEXTURE_ENV_COLOR
) {
555 p
[0] = INT_TO_FLOAT( param
[0] );
556 p
[1] = INT_TO_FLOAT( param
[1] );
557 p
[2] = INT_TO_FLOAT( param
[2] );
558 p
[3] = INT_TO_FLOAT( param
[3] );
561 p
[0] = (GLint
) param
[0];
562 p
[1] = p
[2] = p
[3] = 0; /* init to zero, just to be safe */
564 _mesa_TexEnvfv( target
, pname
, p
);
569 _mesa_GetTexEnvfv( GLenum target
, GLenum pname
, GLfloat
*params
)
571 GET_CURRENT_CONTEXT(ctx
);
572 const struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
573 ASSERT_OUTSIDE_BEGIN_END(ctx
);
575 if (target
== GL_TEXTURE_ENV
) {
577 case GL_TEXTURE_ENV_MODE
:
578 *params
= ENUM_TO_FLOAT(texUnit
->EnvMode
);
580 case GL_TEXTURE_ENV_COLOR
:
581 COPY_4FV( params
, texUnit
->EnvColor
);
583 case GL_COMBINE_RGB_EXT
:
584 if (ctx
->Extensions
.EXT_texture_env_combine
||
585 ctx
->Extensions
.ARB_texture_env_combine
) {
586 *params
= (GLfloat
) texUnit
->CombineModeRGB
;
589 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
592 case GL_COMBINE_ALPHA_EXT
:
593 if (ctx
->Extensions
.EXT_texture_env_combine
||
594 ctx
->Extensions
.ARB_texture_env_combine
) {
595 *params
= (GLfloat
) texUnit
->CombineModeA
;
598 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
601 case GL_SOURCE0_RGB_EXT
:
602 if (ctx
->Extensions
.EXT_texture_env_combine
||
603 ctx
->Extensions
.ARB_texture_env_combine
) {
604 *params
= (GLfloat
) texUnit
->CombineSourceRGB
[0];
607 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
610 case GL_SOURCE1_RGB_EXT
:
611 if (ctx
->Extensions
.EXT_texture_env_combine
||
612 ctx
->Extensions
.ARB_texture_env_combine
) {
613 *params
= (GLfloat
) texUnit
->CombineSourceRGB
[1];
616 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
619 case GL_SOURCE2_RGB_EXT
:
620 if (ctx
->Extensions
.EXT_texture_env_combine
||
621 ctx
->Extensions
.ARB_texture_env_combine
) {
622 *params
= (GLfloat
) texUnit
->CombineSourceRGB
[2];
625 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
628 case GL_SOURCE0_ALPHA_EXT
:
629 if (ctx
->Extensions
.EXT_texture_env_combine
||
630 ctx
->Extensions
.ARB_texture_env_combine
) {
631 *params
= (GLfloat
) texUnit
->CombineSourceA
[0];
634 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
637 case GL_SOURCE1_ALPHA_EXT
:
638 if (ctx
->Extensions
.EXT_texture_env_combine
||
639 ctx
->Extensions
.ARB_texture_env_combine
) {
640 *params
= (GLfloat
) texUnit
->CombineSourceA
[1];
643 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
646 case GL_SOURCE2_ALPHA_EXT
:
647 if (ctx
->Extensions
.EXT_texture_env_combine
||
648 ctx
->Extensions
.ARB_texture_env_combine
) {
649 *params
= (GLfloat
) texUnit
->CombineSourceA
[2];
652 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
655 case GL_OPERAND0_RGB_EXT
:
656 if (ctx
->Extensions
.EXT_texture_env_combine
||
657 ctx
->Extensions
.ARB_texture_env_combine
) {
658 *params
= (GLfloat
) texUnit
->CombineOperandRGB
[0];
661 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
664 case GL_OPERAND1_RGB_EXT
:
665 if (ctx
->Extensions
.EXT_texture_env_combine
||
666 ctx
->Extensions
.ARB_texture_env_combine
) {
667 *params
= (GLfloat
) texUnit
->CombineOperandRGB
[1];
670 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
673 case GL_OPERAND2_RGB_EXT
:
674 if (ctx
->Extensions
.EXT_texture_env_combine
||
675 ctx
->Extensions
.ARB_texture_env_combine
) {
676 *params
= (GLfloat
) texUnit
->CombineOperandRGB
[2];
679 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
682 case GL_OPERAND0_ALPHA_EXT
:
683 if (ctx
->Extensions
.EXT_texture_env_combine
||
684 ctx
->Extensions
.ARB_texture_env_combine
) {
685 *params
= (GLfloat
) texUnit
->CombineOperandA
[0];
688 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
691 case GL_OPERAND1_ALPHA_EXT
:
692 if (ctx
->Extensions
.EXT_texture_env_combine
||
693 ctx
->Extensions
.ARB_texture_env_combine
) {
694 *params
= (GLfloat
) texUnit
->CombineOperandA
[1];
697 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
700 case GL_OPERAND2_ALPHA_EXT
:
701 if (ctx
->Extensions
.EXT_texture_env_combine
||
702 ctx
->Extensions
.ARB_texture_env_combine
) {
703 *params
= (GLfloat
) texUnit
->CombineOperandA
[2];
706 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
709 case GL_RGB_SCALE_EXT
:
710 if (ctx
->Extensions
.EXT_texture_env_combine
||
711 ctx
->Extensions
.ARB_texture_env_combine
) {
712 if (texUnit
->CombineScaleShiftRGB
== 0)
714 else if (texUnit
->CombineScaleShiftRGB
== 1)
720 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
725 if (ctx
->Extensions
.EXT_texture_env_combine
||
726 ctx
->Extensions
.ARB_texture_env_combine
) {
727 if (texUnit
->CombineScaleShiftA
== 0)
729 else if (texUnit
->CombineScaleShiftA
== 1)
735 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
740 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)" );
743 else if (target
== GL_TEXTURE_FILTER_CONTROL_EXT
) {
744 /* GL_EXT_texture_lod_bias */
745 if (!ctx
->Extensions
.EXT_texture_lod_bias
) {
746 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(target)" );
749 if (pname
== GL_TEXTURE_LOD_BIAS_EXT
) {
750 *params
= texUnit
->LodBias
;
753 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)" );
757 else if (target
== GL_POINT_SPRITE_NV
) {
758 /* GL_NV_point_sprite */
759 if (!ctx
->Extensions
.NV_point_sprite
) {
760 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(target)" );
763 if (pname
== GL_COORD_REPLACE_NV
) {
764 *params
= (GLfloat
) ctx
->Point
.CoordReplace
[ctx
->Texture
.CurrentUnit
];
767 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)" );
772 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(target)" );
779 _mesa_GetTexEnviv( GLenum target
, GLenum pname
, GLint
*params
)
781 GET_CURRENT_CONTEXT(ctx
);
782 const struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
783 ASSERT_OUTSIDE_BEGIN_END(ctx
);
785 if (target
== GL_TEXTURE_ENV
) {
787 case GL_TEXTURE_ENV_MODE
:
788 *params
= (GLint
) texUnit
->EnvMode
;
790 case GL_TEXTURE_ENV_COLOR
:
791 params
[0] = FLOAT_TO_INT( texUnit
->EnvColor
[0] );
792 params
[1] = FLOAT_TO_INT( texUnit
->EnvColor
[1] );
793 params
[2] = FLOAT_TO_INT( texUnit
->EnvColor
[2] );
794 params
[3] = FLOAT_TO_INT( texUnit
->EnvColor
[3] );
796 case GL_COMBINE_RGB_EXT
:
797 if (ctx
->Extensions
.EXT_texture_env_combine
||
798 ctx
->Extensions
.ARB_texture_env_combine
) {
799 *params
= (GLint
) texUnit
->CombineModeRGB
;
802 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
805 case GL_COMBINE_ALPHA_EXT
:
806 if (ctx
->Extensions
.EXT_texture_env_combine
||
807 ctx
->Extensions
.ARB_texture_env_combine
) {
808 *params
= (GLint
) texUnit
->CombineModeA
;
811 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
814 case GL_SOURCE0_RGB_EXT
:
815 if (ctx
->Extensions
.EXT_texture_env_combine
||
816 ctx
->Extensions
.ARB_texture_env_combine
) {
817 *params
= (GLint
) texUnit
->CombineSourceRGB
[0];
820 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
823 case GL_SOURCE1_RGB_EXT
:
824 if (ctx
->Extensions
.EXT_texture_env_combine
||
825 ctx
->Extensions
.ARB_texture_env_combine
) {
826 *params
= (GLint
) texUnit
->CombineSourceRGB
[1];
829 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
832 case GL_SOURCE2_RGB_EXT
:
833 if (ctx
->Extensions
.EXT_texture_env_combine
||
834 ctx
->Extensions
.ARB_texture_env_combine
) {
835 *params
= (GLint
) texUnit
->CombineSourceRGB
[2];
838 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
841 case GL_SOURCE0_ALPHA_EXT
:
842 if (ctx
->Extensions
.EXT_texture_env_combine
||
843 ctx
->Extensions
.ARB_texture_env_combine
) {
844 *params
= (GLint
) texUnit
->CombineSourceA
[0];
847 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
850 case GL_SOURCE1_ALPHA_EXT
:
851 if (ctx
->Extensions
.EXT_texture_env_combine
||
852 ctx
->Extensions
.ARB_texture_env_combine
) {
853 *params
= (GLint
) texUnit
->CombineSourceA
[1];
856 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
859 case GL_SOURCE2_ALPHA_EXT
:
860 if (ctx
->Extensions
.EXT_texture_env_combine
||
861 ctx
->Extensions
.ARB_texture_env_combine
) {
862 *params
= (GLint
) texUnit
->CombineSourceA
[2];
865 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
868 case GL_OPERAND0_RGB_EXT
:
869 if (ctx
->Extensions
.EXT_texture_env_combine
||
870 ctx
->Extensions
.ARB_texture_env_combine
) {
871 *params
= (GLint
) texUnit
->CombineOperandRGB
[0];
874 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
877 case GL_OPERAND1_RGB_EXT
:
878 if (ctx
->Extensions
.EXT_texture_env_combine
||
879 ctx
->Extensions
.ARB_texture_env_combine
) {
880 *params
= (GLint
) texUnit
->CombineOperandRGB
[1];
883 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
886 case GL_OPERAND2_RGB_EXT
:
887 if (ctx
->Extensions
.EXT_texture_env_combine
||
888 ctx
->Extensions
.ARB_texture_env_combine
) {
889 *params
= (GLint
) texUnit
->CombineOperandRGB
[2];
892 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
895 case GL_OPERAND0_ALPHA_EXT
:
896 if (ctx
->Extensions
.EXT_texture_env_combine
||
897 ctx
->Extensions
.ARB_texture_env_combine
) {
898 *params
= (GLint
) texUnit
->CombineOperandA
[0];
901 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
904 case GL_OPERAND1_ALPHA_EXT
:
905 if (ctx
->Extensions
.EXT_texture_env_combine
||
906 ctx
->Extensions
.ARB_texture_env_combine
) {
907 *params
= (GLint
) texUnit
->CombineOperandA
[1];
910 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
913 case GL_OPERAND2_ALPHA_EXT
:
914 if (ctx
->Extensions
.EXT_texture_env_combine
||
915 ctx
->Extensions
.ARB_texture_env_combine
) {
916 *params
= (GLint
) texUnit
->CombineOperandA
[2];
919 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
922 case GL_RGB_SCALE_EXT
:
923 if (ctx
->Extensions
.EXT_texture_env_combine
||
924 ctx
->Extensions
.ARB_texture_env_combine
) {
925 if (texUnit
->CombineScaleShiftRGB
== 0)
927 else if (texUnit
->CombineScaleShiftRGB
== 1)
933 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
938 if (ctx
->Extensions
.EXT_texture_env_combine
||
939 ctx
->Extensions
.ARB_texture_env_combine
) {
940 if (texUnit
->CombineScaleShiftA
== 0)
942 else if (texUnit
->CombineScaleShiftA
== 1)
948 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
953 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)" );
956 else if (target
== GL_TEXTURE_FILTER_CONTROL_EXT
) {
957 /* GL_EXT_texture_lod_bias */
958 if (!ctx
->Extensions
.EXT_texture_lod_bias
) {
959 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(target)" );
962 if (pname
== GL_TEXTURE_LOD_BIAS_EXT
) {
963 *params
= (GLint
) texUnit
->LodBias
;
966 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)" );
970 else if (target
== GL_POINT_SPRITE_NV
) {
971 /* GL_NV_point_sprite */
972 if (!ctx
->Extensions
.NV_point_sprite
) {
973 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(target)" );
976 if (pname
== GL_COORD_REPLACE_NV
) {
977 *params
= (GLint
) ctx
->Point
.CoordReplace
[ctx
->Texture
.CurrentUnit
];
980 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)" );
985 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(target)" );
993 /**********************************************************************/
994 /* Texture Parameters */
995 /**********************************************************************/
999 _mesa_TexParameterf( GLenum target
, GLenum pname
, GLfloat param
)
1001 _mesa_TexParameterfv(target
, pname
, ¶m
);
1006 _mesa_TexParameterfv( GLenum target
, GLenum pname
, const GLfloat
*params
)
1008 GET_CURRENT_CONTEXT(ctx
);
1009 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1010 GLenum eparam
= (GLenum
) (GLint
) params
[0];
1011 struct gl_texture_object
*texObj
;
1012 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1014 if (MESA_VERBOSE
&(VERBOSE_API
|VERBOSE_TEXTURE
))
1015 _mesa_debug(ctx
, "texPARAM %s %s %d...\n",
1016 _mesa_lookup_enum_by_nr(target
),
1017 _mesa_lookup_enum_by_nr(pname
),
1023 texObj
= texUnit
->Current1D
;
1026 texObj
= texUnit
->Current2D
;
1028 case GL_TEXTURE_3D_EXT
:
1029 texObj
= texUnit
->Current3D
;
1031 case GL_TEXTURE_CUBE_MAP_ARB
:
1032 if (!ctx
->Extensions
.ARB_texture_cube_map
) {
1033 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexParameter(target)" );
1036 texObj
= texUnit
->CurrentCubeMap
;
1038 case GL_TEXTURE_RECTANGLE_NV
:
1039 if (!ctx
->Extensions
.NV_texture_rectangle
) {
1040 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexParameter(target)" );
1043 texObj
= texUnit
->CurrentRect
;
1046 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexParameter(target)" );
1051 case GL_TEXTURE_MIN_FILTER
:
1052 /* A small optimization */
1053 if (texObj
->MinFilter
== eparam
)
1056 if (eparam
==GL_NEAREST
|| eparam
==GL_LINEAR
) {
1057 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1058 texObj
->MinFilter
= eparam
;
1060 else if ((eparam
==GL_NEAREST_MIPMAP_NEAREST
||
1061 eparam
==GL_LINEAR_MIPMAP_NEAREST
||
1062 eparam
==GL_NEAREST_MIPMAP_LINEAR
||
1063 eparam
==GL_LINEAR_MIPMAP_LINEAR
) &&
1064 texObj
->Target
!= GL_TEXTURE_RECTANGLE_NV
) {
1065 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1066 texObj
->MinFilter
= eparam
;
1069 _mesa_error( ctx
, GL_INVALID_VALUE
, "glTexParameter(param)" );
1073 case GL_TEXTURE_MAG_FILTER
:
1074 /* A small optimization */
1075 if (texObj
->MagFilter
== eparam
)
1078 if (eparam
==GL_NEAREST
|| eparam
==GL_LINEAR
) {
1079 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1080 texObj
->MagFilter
= eparam
;
1083 _mesa_error( ctx
, GL_INVALID_VALUE
, "glTexParameter(param)" );
1087 case GL_TEXTURE_WRAP_S
:
1088 if (texObj
->WrapS
== eparam
)
1090 if (eparam
== GL_CLAMP
|| eparam
== GL_CLAMP_TO_EDGE
||
1091 (eparam
== GL_CLAMP_TO_BORDER_ARB
&&
1092 ctx
->Extensions
.ARB_texture_border_clamp
)) {
1093 /* any texture target */
1094 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1095 texObj
->WrapS
= eparam
;
1097 else if (texObj
->Target
!= GL_TEXTURE_RECTANGLE_NV
&&
1098 (eparam
== GL_REPEAT
||
1099 (eparam
== GL_MIRRORED_REPEAT_ARB
&&
1100 ctx
->Extensions
.ARB_texture_mirrored_repeat
))) {
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 /* non-rectangle texture */
1125 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1126 texObj
->WrapT
= eparam
;
1129 _mesa_error( ctx
, GL_INVALID_VALUE
, "glTexParameter(param)" );
1133 case GL_TEXTURE_WRAP_R_EXT
:
1134 if (texObj
->WrapR
== eparam
)
1136 if (eparam
== GL_CLAMP
|| eparam
== GL_CLAMP_TO_EDGE
||
1137 (eparam
== GL_CLAMP_TO_BORDER_ARB
&&
1138 ctx
->Extensions
.ARB_texture_border_clamp
)) {
1139 /* any texture target */
1140 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1141 texObj
->WrapR
= eparam
;
1143 else if (texObj
->Target
!= GL_TEXTURE_RECTANGLE_NV
&&
1144 (eparam
== GL_REPEAT
||
1145 (eparam
== GL_MIRRORED_REPEAT_ARB
&&
1146 ctx
->Extensions
.ARB_texture_mirrored_repeat
))) {
1147 /* non-rectangle texture */
1148 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1149 texObj
->WrapR
= eparam
;
1152 _mesa_error( ctx
, GL_INVALID_VALUE
, "glTexParameter(param)" );
1156 case GL_TEXTUER_BORDER_VALUES_NV
:
1158 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1159 COPY_4V(texObj
->BorderValues
, params
);
1160 UNCLAMPED_FLOAT_TO_CHAN(texObj
->BorderColor
[0], params
[0]);
1161 UNCLAMPED_FLOAT_TO_CHAN(texObj
->BorderColor
[1], params
[1]);
1162 UNCLAMPED_FLOAT_TO_CHAN(texObj
->BorderColor
[2], params
[2]);
1163 UNCLAMPED_FLOAT_TO_CHAN(texObj
->BorderColor
[3], params
[3]);
1166 case GL_TEXTURE_BORDER_COLOR
:
1168 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1169 texObj
->BorderValues
[0] = CLAMP(params
[0], 0.0F
, 1.0F
);
1170 texObj
->BorderValues
[1] = CLAMP(params
[1], 0.0F
, 1.0F
);
1171 texObj
->BorderValues
[2] = CLAMP(params
[2], 0.0F
, 1.0F
);
1172 texObj
->BorderValues
[3] = CLAMP(params
[3], 0.0F
, 1.0F
);
1173 UNCLAMPED_FLOAT_TO_CHAN(texObj
->BorderColor
[0], texObj
->BorderValues
[0]);
1174 UNCLAMPED_FLOAT_TO_CHAN(texObj
->BorderColor
[1], texObj
->BorderValues
[1]);
1175 UNCLAMPED_FLOAT_TO_CHAN(texObj
->BorderColor
[2], texObj
->BorderValues
[2]);
1176 UNCLAMPED_FLOAT_TO_CHAN(texObj
->BorderColor
[3], texObj
->BorderValues
[3]);
1178 case GL_TEXTURE_MIN_LOD
:
1179 if (texObj
->MinLod
== params
[0])
1181 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1182 texObj
->MinLod
= params
[0];
1184 case GL_TEXTURE_MAX_LOD
:
1185 if (texObj
->MaxLod
== params
[0])
1187 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1188 texObj
->MaxLod
= params
[0];
1190 case GL_TEXTURE_BASE_LEVEL
:
1191 if (params
[0] < 0.0) {
1192 _mesa_error(ctx
, GL_INVALID_VALUE
, "glTexParameter(param)" );
1195 if (target
== GL_TEXTURE_RECTANGLE_NV
&& params
[0] != 0.0) {
1196 _mesa_error(ctx
, GL_INVALID_VALUE
, "glTexParameter(param)" );
1199 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1200 texObj
->BaseLevel
= (GLint
) params
[0];
1202 case GL_TEXTURE_MAX_LEVEL
:
1203 if (params
[0] < 0.0) {
1204 _mesa_error(ctx
, GL_INVALID_VALUE
, "glTexParameter(param)" );
1207 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1208 texObj
->MaxLevel
= (GLint
) params
[0];
1210 case GL_TEXTURE_PRIORITY
:
1211 /* (keithh@netcomuk.co.uk) */
1212 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1213 texObj
->Priority
= CLAMP( params
[0], 0.0F
, 1.0F
);
1215 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1216 if (ctx
->Extensions
.EXT_texture_filter_anisotropic
) {
1217 if (params
[0] < 1.0) {
1218 _mesa_error(ctx
, GL_INVALID_VALUE
, "glTexParameter(param)" );
1221 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1222 texObj
->MaxAnisotropy
= params
[0];
1225 _mesa_error(ctx
, GL_INVALID_ENUM
,
1226 "glTexParameter(pname=GL_MAX_TEXTURE_ANISOTROPY_EXT)");
1230 case GL_TEXTURE_COMPARE_SGIX
:
1231 if (ctx
->Extensions
.SGIX_shadow
) {
1232 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1233 texObj
->CompareFlag
= params
[0] ? GL_TRUE
: GL_FALSE
;
1236 _mesa_error(ctx
, GL_INVALID_ENUM
,
1237 "glTexParameter(pname=GL_TEXTURE_COMPARE_SGIX)");
1241 case GL_TEXTURE_COMPARE_OPERATOR_SGIX
:
1242 if (ctx
->Extensions
.SGIX_shadow
) {
1243 GLenum op
= (GLenum
) params
[0];
1244 if (op
== GL_TEXTURE_LEQUAL_R_SGIX
||
1245 op
== GL_TEXTURE_GEQUAL_R_SGIX
) {
1246 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1247 texObj
->CompareOperator
= op
;
1250 _mesa_error(ctx
, GL_INVALID_ENUM
, "glTexParameter(param)");
1254 _mesa_error(ctx
, GL_INVALID_ENUM
,
1255 "glTexParameter(pname=GL_TEXTURE_COMPARE_OPERATOR_SGIX)");
1259 case GL_SHADOW_AMBIENT_SGIX
: /* aka GL_TEXTURE_COMPARE_FAIL_VALUE_ARB */
1260 if (ctx
->Extensions
.SGIX_shadow_ambient
) {
1261 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1262 UNCLAMPED_FLOAT_TO_CHAN(texObj
->ShadowAmbient
, params
[0]);
1265 _mesa_error(ctx
, GL_INVALID_ENUM
,
1266 "glTexParameter(pname=GL_SHADOW_AMBIENT_SGIX)");
1270 case GL_GENERATE_MIPMAP_SGIS
:
1271 if (ctx
->Extensions
.SGIS_generate_mipmap
) {
1272 texObj
->GenerateMipmap
= params
[0] ? GL_TRUE
: GL_FALSE
;
1275 _mesa_error(ctx
, GL_INVALID_ENUM
,
1276 "glTexParameter(pname=GL_GENERATE_MIPMAP_SGIS)");
1280 case GL_TEXTURE_COMPARE_MODE_ARB
:
1281 if (ctx
->Extensions
.ARB_shadow
) {
1282 const GLenum mode
= (GLenum
) params
[0];
1283 if (mode
== GL_NONE
|| mode
== GL_COMPARE_R_TO_TEXTURE_ARB
) {
1284 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1285 texObj
->CompareMode
= mode
;
1288 _mesa_error(ctx
, GL_INVALID_ENUM
,
1289 "glTexParameter(bad GL_TEXTURE_COMPARE_MODE_ARB)");
1294 _mesa_error(ctx
, GL_INVALID_ENUM
,
1295 "glTexParameter(pname=GL_TEXTURE_COMPARE_MODE_ARB)");
1299 case GL_TEXTURE_COMPARE_FUNC_ARB
:
1300 if (ctx
->Extensions
.ARB_shadow
) {
1301 const GLenum func
= (GLenum
) params
[0];
1302 if (func
== GL_LEQUAL
|| func
== GL_GEQUAL
) {
1303 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1304 texObj
->CompareFunc
= func
;
1306 else if (ctx
->Extensions
.EXT_shadow_funcs
&&
1307 (func
== GL_EQUAL
||
1308 func
== GL_NOTEQUAL
||
1310 func
== GL_GREATER
||
1311 func
== GL_ALWAYS
||
1312 func
== GL_NEVER
)) {
1313 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1314 texObj
->CompareFunc
= func
;
1317 _mesa_error(ctx
, GL_INVALID_ENUM
,
1318 "glTexParameter(bad GL_TEXTURE_COMPARE_FUNC_ARB)");
1323 _mesa_error(ctx
, GL_INVALID_ENUM
,
1324 "glTexParameter(pname=GL_TEXTURE_COMPARE_FUNC_ARB)");
1328 case GL_DEPTH_TEXTURE_MODE_ARB
:
1329 if (ctx
->Extensions
.ARB_depth_texture
) {
1330 const GLenum result
= (GLenum
) params
[0];
1331 if (result
== GL_LUMINANCE
|| result
== GL_INTENSITY
1332 || result
== GL_ALPHA
) {
1333 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1334 texObj
->DepthMode
= result
;
1337 _mesa_error(ctx
, GL_INVALID_ENUM
,
1338 "glTexParameter(bad GL_DEPTH_TEXTURE_MODE_ARB)");
1343 _mesa_error(ctx
, GL_INVALID_ENUM
,
1344 "glTexParameter(pname=GL_DEPTH_TEXTURE_MODE_ARB)");
1352 sprintf(s
, "glTexParameter(pname=0x%x)", pname
);
1353 _mesa_error( ctx
, GL_INVALID_ENUM
, s
);
1358 texObj
->Complete
= GL_FALSE
;
1360 if (ctx
->Driver
.TexParameter
) {
1361 (*ctx
->Driver
.TexParameter
)( ctx
, target
, texObj
, pname
, params
);
1367 _mesa_TexParameteri( GLenum target
, GLenum pname
, GLint param
)
1370 fparam
[0] = (GLfloat
) param
;
1371 fparam
[1] = fparam
[2] = fparam
[3] = 0.0;
1372 _mesa_TexParameterfv(target
, pname
, fparam
);
1376 _mesa_TexParameteriv( GLenum target
, GLenum pname
, const GLint
*params
)
1379 fparam
[0] = (GLfloat
) params
[0];
1380 fparam
[1] = fparam
[2] = fparam
[3] = 0.0;
1381 _mesa_TexParameterfv(target
, pname
, fparam
);
1386 _mesa_GetTexLevelParameterfv( GLenum target
, GLint level
,
1387 GLenum pname
, GLfloat
*params
)
1390 _mesa_GetTexLevelParameteriv( target
, level
, pname
, &iparam
);
1391 *params
= (GLfloat
) iparam
;
1396 tex_image_dimensions(GLcontext
*ctx
, GLenum target
)
1400 case GL_PROXY_TEXTURE_1D
:
1403 case GL_PROXY_TEXTURE_2D
:
1406 case GL_PROXY_TEXTURE_3D
:
1408 case GL_TEXTURE_CUBE_MAP_ARB
:
1409 case GL_PROXY_TEXTURE_CUBE_MAP_ARB
:
1410 case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB
:
1411 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB
:
1412 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB
:
1413 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB
:
1414 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB
:
1415 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB
:
1416 return ctx
->Extensions
.ARB_texture_cube_map
? 2 : 0;
1417 case GL_TEXTURE_RECTANGLE_NV
:
1418 case GL_PROXY_TEXTURE_RECTANGLE_NV
:
1419 return ctx
->Extensions
.NV_texture_rectangle
? 2 : 0;
1421 _mesa_problem(ctx
, "bad target in _mesa_tex_target_dimensions()");
1428 _mesa_GetTexLevelParameteriv( GLenum target
, GLint level
,
1429 GLenum pname
, GLint
*params
)
1431 GET_CURRENT_CONTEXT(ctx
);
1432 const struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1433 const struct gl_texture_image
*img
= NULL
;
1437 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1439 /* this will catch bad target values */
1440 dimensions
= tex_image_dimensions(ctx
, target
); /* 1, 2 or 3 */
1441 if (dimensions
== 0) {
1442 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexLevelParameter[if]v(target)");
1448 case GL_PROXY_TEXTURE_1D
:
1450 case GL_PROXY_TEXTURE_2D
:
1451 maxLevels
= ctx
->Const
.MaxTextureLevels
;
1454 case GL_PROXY_TEXTURE_3D
:
1455 maxLevels
= ctx
->Const
.Max3DTextureLevels
;
1457 case GL_TEXTURE_CUBE_MAP_ARB
:
1458 case GL_PROXY_TEXTURE_CUBE_MAP_ARB
:
1459 maxLevels
= ctx
->Const
.MaxCubeTextureLevels
;
1461 case GL_TEXTURE_RECTANGLE_NV
:
1462 case GL_PROXY_TEXTURE_RECTANGLE_NV
:
1466 _mesa_problem(ctx
, "bad target in _mesa_GetTexLevelParameter");
1470 if (level
< 0 || level
>= maxLevels
) {
1471 _mesa_error( ctx
, GL_INVALID_VALUE
, "glGetTexLevelParameter[if]v" );
1475 img
= _mesa_select_tex_image(ctx
, texUnit
, target
, level
);
1476 if (!img
|| !img
->TexFormat
) {
1477 /* undefined texture image */
1478 if (pname
== GL_TEXTURE_COMPONENTS
)
1485 isProxy
= (target
== GL_PROXY_TEXTURE_1D
) ||
1486 (target
== GL_PROXY_TEXTURE_2D
) ||
1487 (target
== GL_PROXY_TEXTURE_3D
) ||
1488 (target
== GL_PROXY_TEXTURE_CUBE_MAP_ARB
) ||
1489 (target
== GL_PROXY_TEXTURE_RECTANGLE_NV
);
1492 case GL_TEXTURE_WIDTH
:
1493 *params
= img
->Width
;
1495 case GL_TEXTURE_HEIGHT
:
1496 *params
= img
->Height
;
1498 case GL_TEXTURE_DEPTH
:
1499 *params
= img
->Depth
;
1501 case GL_TEXTURE_INTERNAL_FORMAT
:
1502 *params
= img
->IntFormat
;
1504 case GL_TEXTURE_BORDER
:
1505 *params
= img
->Border
;
1507 case GL_TEXTURE_RED_SIZE
:
1508 if (img
->Format
== GL_RGB
|| img
->Format
== GL_RGBA
)
1509 *params
= img
->TexFormat
->RedBits
;
1513 case GL_TEXTURE_GREEN_SIZE
:
1514 if (img
->Format
== GL_RGB
|| img
->Format
== GL_RGBA
)
1515 *params
= img
->TexFormat
->GreenBits
;
1519 case GL_TEXTURE_BLUE_SIZE
:
1520 if (img
->Format
== GL_RGB
|| img
->Format
== GL_RGBA
)
1521 *params
= img
->TexFormat
->BlueBits
;
1525 case GL_TEXTURE_ALPHA_SIZE
:
1526 if (img
->Format
== GL_ALPHA
|| img
->Format
== GL_LUMINANCE_ALPHA
||
1527 img
->Format
== GL_RGBA
)
1528 *params
= img
->TexFormat
->AlphaBits
;
1532 case GL_TEXTURE_INTENSITY_SIZE
:
1533 if (img
->Format
!= GL_INTENSITY
)
1535 else if (img
->TexFormat
->IntensityBits
> 0)
1536 *params
= img
->TexFormat
->IntensityBits
;
1537 else /* intensity probably stored as rgb texture */
1538 *params
= MIN2(img
->TexFormat
->RedBits
, img
->TexFormat
->GreenBits
);
1540 case GL_TEXTURE_LUMINANCE_SIZE
:
1541 if (img
->Format
!= GL_LUMINANCE
&&
1542 img
->Format
!= GL_LUMINANCE_ALPHA
)
1544 else if (img
->TexFormat
->LuminanceBits
> 0)
1545 *params
= img
->TexFormat
->LuminanceBits
;
1546 else /* luminance probably stored as rgb texture */
1547 *params
= MIN2(img
->TexFormat
->RedBits
, img
->TexFormat
->GreenBits
);
1549 case GL_TEXTURE_INDEX_SIZE_EXT
:
1550 if (img
->Format
== GL_COLOR_INDEX
)
1551 *params
= img
->TexFormat
->IndexBits
;
1556 /* XXX this isn't in the GL_SGIX_depth_texture spec
1557 * but seems appropriate.
1559 if (ctx
->Extensions
.SGIX_depth_texture
)
1560 *params
= img
->TexFormat
->DepthBits
;
1562 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexLevelParameter[if]v(pname)");
1565 /* GL_ARB_texture_compression */
1566 case GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB
:
1567 if (ctx
->Extensions
.ARB_texture_compression
) {
1568 if (img
->IsCompressed
&& !isProxy
)
1569 *params
= img
->CompressedSize
;
1571 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1572 "glGetTexLevelParameter[if]v(pname)");
1575 _mesa_error(ctx
, GL_INVALID_ENUM
, "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
, "glGetTexLevelParameter[if]v(pname)");
1588 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexLevelParameter[if]v(pname)");
1595 _mesa_GetTexParameterfv( GLenum target
, GLenum pname
, GLfloat
*params
)
1597 GET_CURRENT_CONTEXT(ctx
);
1598 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1599 struct gl_texture_object
*obj
;
1600 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1602 obj
= _mesa_select_tex_object(ctx
, texUnit
, target
);
1604 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexParameterfv(target)");
1609 case GL_TEXTURE_MAG_FILTER
:
1610 *params
= ENUM_TO_FLOAT(obj
->MagFilter
);
1612 case GL_TEXTURE_MIN_FILTER
:
1613 *params
= ENUM_TO_FLOAT(obj
->MinFilter
);
1615 case GL_TEXTURE_WRAP_S
:
1616 *params
= ENUM_TO_FLOAT(obj
->WrapS
);
1618 case GL_TEXTURE_WRAP_T
:
1619 *params
= ENUM_TO_FLOAT(obj
->WrapT
);
1621 case GL_TEXTURE_WRAP_R_EXT
:
1622 *params
= ENUM_TO_FLOAT(obj
->WrapR
);
1625 case GL_TEXTURE_BORDER_VALUES_NV
:
1627 params
[0] = obj
->BorderValues
[0];
1628 params
[1] = obj
->BorderValues
[1];
1629 params
[2] = obj
->BorderValues
[2];
1630 params
[3] = obj
->BorderValues
[3];
1633 case GL_TEXTURE_BORDER_COLOR
:
1635 params
[0] = obj
->BorderColor
[0] / CHAN_MAXF
;
1636 params
[1] = obj
->BorderColor
[1] / CHAN_MAXF
;
1637 params
[2] = obj
->BorderColor
[2] / CHAN_MAXF
;
1638 params
[3] = obj
->BorderColor
[3] / CHAN_MAXF
;
1640 case GL_TEXTURE_RESIDENT
:
1643 if (ctx
->Driver
.IsTextureResident
)
1644 resident
= ctx
->Driver
.IsTextureResident(ctx
, obj
);
1647 *params
= ENUM_TO_FLOAT(resident
);
1650 case GL_TEXTURE_PRIORITY
:
1651 *params
= obj
->Priority
;
1653 case GL_TEXTURE_MIN_LOD
:
1654 *params
= obj
->MinLod
;
1656 case GL_TEXTURE_MAX_LOD
:
1657 *params
= obj
->MaxLod
;
1659 case GL_TEXTURE_BASE_LEVEL
:
1660 *params
= (GLfloat
) obj
->BaseLevel
;
1662 case GL_TEXTURE_MAX_LEVEL
:
1663 *params
= (GLfloat
) obj
->MaxLevel
;
1665 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1666 if (ctx
->Extensions
.EXT_texture_filter_anisotropic
) {
1667 *params
= obj
->MaxAnisotropy
;
1671 case GL_TEXTURE_COMPARE_SGIX
:
1672 if (ctx
->Extensions
.SGIX_shadow
) {
1673 *params
= (GLfloat
) obj
->CompareFlag
;
1677 case GL_TEXTURE_COMPARE_OPERATOR_SGIX
:
1678 if (ctx
->Extensions
.SGIX_shadow
) {
1679 *params
= (GLfloat
) obj
->CompareOperator
;
1683 case GL_SHADOW_AMBIENT_SGIX
: /* aka GL_TEXTURE_COMPARE_FAIL_VALUE_ARB */
1684 if (ctx
->Extensions
.SGIX_shadow_ambient
) {
1685 *params
= CHAN_TO_FLOAT(obj
->ShadowAmbient
);
1689 case GL_GENERATE_MIPMAP_SGIS
:
1690 if (ctx
->Extensions
.SGIS_generate_mipmap
) {
1691 *params
= (GLfloat
) obj
->GenerateMipmap
;
1695 case GL_TEXTURE_COMPARE_MODE_ARB
:
1696 if (ctx
->Extensions
.ARB_shadow
) {
1697 *params
= (GLfloat
) obj
->CompareMode
;
1701 case GL_TEXTURE_COMPARE_FUNC_ARB
:
1702 if (ctx
->Extensions
.ARB_shadow
) {
1703 *params
= (GLfloat
) obj
->CompareFunc
;
1707 case GL_DEPTH_TEXTURE_MODE_ARB
:
1708 if (ctx
->Extensions
.ARB_depth_texture
) {
1709 *params
= (GLfloat
) obj
->DepthMode
;
1714 ; /* silence warnings */
1716 /* If we get here, pname was an unrecognized enum */
1717 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexParameterfv(pname)" );
1722 _mesa_GetTexParameteriv( GLenum target
, GLenum pname
, GLint
*params
)
1724 GET_CURRENT_CONTEXT(ctx
);
1725 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1726 struct gl_texture_object
*obj
;
1727 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1729 obj
= _mesa_select_tex_object(ctx
, texUnit
, target
);
1731 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexParameteriv(target)");
1736 case GL_TEXTURE_MAG_FILTER
:
1737 *params
= (GLint
) obj
->MagFilter
;
1739 case GL_TEXTURE_MIN_FILTER
:
1740 *params
= (GLint
) obj
->MinFilter
;
1742 case GL_TEXTURE_WRAP_S
:
1743 *params
= (GLint
) obj
->WrapS
;
1745 case GL_TEXTURE_WRAP_T
:
1746 *params
= (GLint
) obj
->WrapT
;
1748 case GL_TEXTURE_WRAP_R_EXT
:
1749 *params
= (GLint
) obj
->WrapR
;
1752 case GL_TEXTURE_BORDER_VALUES_NV
:
1754 params
[0] = FLOAT_TO_INT(obj
->BorderValues
[0]);
1755 params
[1] = FLOAT_TO_INT(obj
->BorderValues
[1]);
1756 params
[2] = FLOAT_TO_INT(obj
->BorderValues
[2]);
1757 params
[3] = FLOAT_TO_INT(obj
->BorderValues
[3]);
1760 case GL_TEXTURE_BORDER_COLOR
:
1764 b
[0] = CLAMP(obj
->BorderValues
[0], 0.0F
, 1.0F
);
1765 b
[1] = CLAMP(obj
->BorderValues
[1], 0.0F
, 1.0F
);
1766 b
[2] = CLAMP(obj
->BorderValues
[2], 0.0F
, 1.0F
);
1767 b
[3] = CLAMP(obj
->BorderValues
[3], 0.0F
, 1.0F
);
1768 params
[0] = FLOAT_TO_INT(b
[0]);
1769 params
[1] = FLOAT_TO_INT(b
[1]);
1770 params
[2] = FLOAT_TO_INT(b
[2]);
1771 params
[3] = FLOAT_TO_INT(b
[3]);
1774 case GL_TEXTURE_RESIDENT
:
1777 if (ctx
->Driver
.IsTextureResident
)
1778 resident
= ctx
->Driver
.IsTextureResident(ctx
, obj
);
1781 *params
= (GLint
) resident
;
1784 case GL_TEXTURE_PRIORITY
:
1785 *params
= (GLint
) obj
->Priority
;
1787 case GL_TEXTURE_MIN_LOD
:
1788 *params
= (GLint
) obj
->MinLod
;
1790 case GL_TEXTURE_MAX_LOD
:
1791 *params
= (GLint
) obj
->MaxLod
;
1793 case GL_TEXTURE_BASE_LEVEL
:
1794 *params
= obj
->BaseLevel
;
1796 case GL_TEXTURE_MAX_LEVEL
:
1797 *params
= obj
->MaxLevel
;
1799 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1800 if (ctx
->Extensions
.EXT_texture_filter_anisotropic
) {
1801 *params
= (GLint
) obj
->MaxAnisotropy
;
1805 case GL_TEXTURE_COMPARE_SGIX
:
1806 if (ctx
->Extensions
.SGIX_shadow
) {
1807 *params
= (GLint
) obj
->CompareFlag
;
1811 case GL_TEXTURE_COMPARE_OPERATOR_SGIX
:
1812 if (ctx
->Extensions
.SGIX_shadow
) {
1813 *params
= (GLint
) obj
->CompareOperator
;
1817 case GL_SHADOW_AMBIENT_SGIX
: /* aka GL_TEXTURE_COMPARE_FAIL_VALUE_ARB */
1818 if (ctx
->Extensions
.SGIX_shadow_ambient
) {
1819 GLfloat a
= CHAN_TO_FLOAT(obj
->ShadowAmbient
);
1820 *params
= (GLint
) FLOAT_TO_INT(a
);
1824 case GL_GENERATE_MIPMAP_SGIS
:
1825 if (ctx
->Extensions
.SGIS_generate_mipmap
) {
1826 *params
= (GLint
) obj
->GenerateMipmap
;
1830 case GL_TEXTURE_COMPARE_MODE_ARB
:
1831 if (ctx
->Extensions
.ARB_shadow
) {
1832 *params
= (GLint
) obj
->CompareMode
;
1836 case GL_TEXTURE_COMPARE_FUNC_ARB
:
1837 if (ctx
->Extensions
.ARB_shadow
) {
1838 *params
= (GLint
) obj
->CompareFunc
;
1842 case GL_DEPTH_TEXTURE_MODE_ARB
:
1843 if (ctx
->Extensions
.ARB_depth_texture
) {
1844 *params
= (GLint
) obj
->DepthMode
;
1849 ; /* silence warnings */
1851 /* If we get here, pname was an unrecognized enum */
1852 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexParameteriv(pname)" );
1858 /**********************************************************************/
1859 /* Texture Coord Generation */
1860 /**********************************************************************/
1864 _mesa_TexGenfv( GLenum coord
, GLenum pname
, const GLfloat
*params
)
1866 GET_CURRENT_CONTEXT(ctx
);
1867 GLuint tUnit
= ctx
->Texture
.CurrentUnit
;
1868 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[tUnit
];
1869 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1871 if (MESA_VERBOSE
&(VERBOSE_API
|VERBOSE_TEXTURE
))
1872 _mesa_debug(ctx
, "texGEN %s %s %x...\n",
1873 _mesa_lookup_enum_by_nr(coord
),
1874 _mesa_lookup_enum_by_nr(pname
),
1879 if (pname
==GL_TEXTURE_GEN_MODE
) {
1880 GLenum mode
= (GLenum
) (GLint
) *params
;
1883 case GL_OBJECT_LINEAR
:
1884 bits
= TEXGEN_OBJ_LINEAR
;
1887 bits
= TEXGEN_EYE_LINEAR
;
1889 case GL_REFLECTION_MAP_NV
:
1890 bits
= TEXGEN_REFLECTION_MAP_NV
;
1892 case GL_NORMAL_MAP_NV
:
1893 bits
= TEXGEN_NORMAL_MAP_NV
;
1896 bits
= TEXGEN_SPHERE_MAP
;
1899 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(param)" );
1902 if (texUnit
->GenModeS
== mode
)
1904 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1905 texUnit
->GenModeS
= mode
;
1906 texUnit
->_GenBitS
= bits
;
1908 else if (pname
==GL_OBJECT_PLANE
) {
1909 if (TEST_EQ_4V(texUnit
->ObjectPlaneS
, params
))
1911 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1912 texUnit
->ObjectPlaneS
[0] = params
[0];
1913 texUnit
->ObjectPlaneS
[1] = params
[1];
1914 texUnit
->ObjectPlaneS
[2] = params
[2];
1915 texUnit
->ObjectPlaneS
[3] = params
[3];
1917 else if (pname
==GL_EYE_PLANE
) {
1920 /* Transform plane equation by the inverse modelview matrix */
1921 if (ctx
->ModelviewMatrixStack
.Top
->flags
& MAT_DIRTY_INVERSE
) {
1922 _math_matrix_analyse( ctx
->ModelviewMatrixStack
.Top
);
1924 _mesa_transform_vector( tmp
, params
, ctx
->ModelviewMatrixStack
.Top
->inv
);
1925 if (TEST_EQ_4V(texUnit
->EyePlaneS
, tmp
))
1927 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1928 COPY_4FV(texUnit
->EyePlaneS
, tmp
);
1931 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(pname)" );
1936 if (pname
==GL_TEXTURE_GEN_MODE
) {
1937 GLenum mode
= (GLenum
) (GLint
) *params
;
1940 case GL_OBJECT_LINEAR
:
1941 bitt
= TEXGEN_OBJ_LINEAR
;
1944 bitt
= TEXGEN_EYE_LINEAR
;
1946 case GL_REFLECTION_MAP_NV
:
1947 bitt
= TEXGEN_REFLECTION_MAP_NV
;
1949 case GL_NORMAL_MAP_NV
:
1950 bitt
= TEXGEN_NORMAL_MAP_NV
;
1953 bitt
= TEXGEN_SPHERE_MAP
;
1956 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(param)" );
1959 if (texUnit
->GenModeT
== mode
)
1961 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1962 texUnit
->GenModeT
= mode
;
1963 texUnit
->_GenBitT
= bitt
;
1965 else if (pname
==GL_OBJECT_PLANE
) {
1966 if (TEST_EQ_4V(texUnit
->ObjectPlaneT
, params
))
1968 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1969 texUnit
->ObjectPlaneT
[0] = params
[0];
1970 texUnit
->ObjectPlaneT
[1] = params
[1];
1971 texUnit
->ObjectPlaneT
[2] = params
[2];
1972 texUnit
->ObjectPlaneT
[3] = params
[3];
1974 else if (pname
==GL_EYE_PLANE
) {
1976 /* Transform plane equation by the inverse modelview matrix */
1977 if (ctx
->ModelviewMatrixStack
.Top
->flags
& MAT_DIRTY_INVERSE
) {
1978 _math_matrix_analyse( ctx
->ModelviewMatrixStack
.Top
);
1980 _mesa_transform_vector( tmp
, params
, ctx
->ModelviewMatrixStack
.Top
->inv
);
1981 if (TEST_EQ_4V(texUnit
->EyePlaneT
, tmp
))
1983 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1984 COPY_4FV(texUnit
->EyePlaneT
, tmp
);
1987 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(pname)" );
1992 if (pname
==GL_TEXTURE_GEN_MODE
) {
1993 GLenum mode
= (GLenum
) (GLint
) *params
;
1996 case GL_OBJECT_LINEAR
:
1997 bitr
= TEXGEN_OBJ_LINEAR
;
1999 case GL_REFLECTION_MAP_NV
:
2000 bitr
= TEXGEN_REFLECTION_MAP_NV
;
2002 case GL_NORMAL_MAP_NV
:
2003 bitr
= TEXGEN_NORMAL_MAP_NV
;
2006 bitr
= TEXGEN_EYE_LINEAR
;
2009 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(param)" );
2012 if (texUnit
->GenModeR
== mode
)
2014 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
2015 texUnit
->GenModeR
= mode
;
2016 texUnit
->_GenBitR
= bitr
;
2018 else if (pname
==GL_OBJECT_PLANE
) {
2019 if (TEST_EQ_4V(texUnit
->ObjectPlaneR
, params
))
2021 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
2022 texUnit
->ObjectPlaneR
[0] = params
[0];
2023 texUnit
->ObjectPlaneR
[1] = params
[1];
2024 texUnit
->ObjectPlaneR
[2] = params
[2];
2025 texUnit
->ObjectPlaneR
[3] = params
[3];
2027 else if (pname
==GL_EYE_PLANE
) {
2029 /* Transform plane equation by the inverse modelview matrix */
2030 if (ctx
->ModelviewMatrixStack
.Top
->flags
& MAT_DIRTY_INVERSE
) {
2031 _math_matrix_analyse( ctx
->ModelviewMatrixStack
.Top
);
2033 _mesa_transform_vector( tmp
, params
, ctx
->ModelviewMatrixStack
.Top
->inv
);
2034 if (TEST_EQ_4V(texUnit
->EyePlaneR
, tmp
))
2036 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
2037 COPY_4FV(texUnit
->EyePlaneR
, tmp
);
2040 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(pname)" );
2045 if (pname
==GL_TEXTURE_GEN_MODE
) {
2046 GLenum mode
= (GLenum
) (GLint
) *params
;
2049 case GL_OBJECT_LINEAR
:
2050 bitq
= TEXGEN_OBJ_LINEAR
;
2053 bitq
= TEXGEN_EYE_LINEAR
;
2056 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(param)" );
2059 if (texUnit
->GenModeQ
== mode
)
2061 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
2062 texUnit
->GenModeQ
= mode
;
2063 texUnit
->_GenBitQ
= bitq
;
2065 else if (pname
==GL_OBJECT_PLANE
) {
2066 if (TEST_EQ_4V(texUnit
->ObjectPlaneQ
, params
))
2068 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
2069 texUnit
->ObjectPlaneQ
[0] = params
[0];
2070 texUnit
->ObjectPlaneQ
[1] = params
[1];
2071 texUnit
->ObjectPlaneQ
[2] = params
[2];
2072 texUnit
->ObjectPlaneQ
[3] = params
[3];
2074 else if (pname
==GL_EYE_PLANE
) {
2076 /* Transform plane equation by the inverse modelview matrix */
2077 if (ctx
->ModelviewMatrixStack
.Top
->flags
& MAT_DIRTY_INVERSE
) {
2078 _math_matrix_analyse( ctx
->ModelviewMatrixStack
.Top
);
2080 _mesa_transform_vector( tmp
, params
, ctx
->ModelviewMatrixStack
.Top
->inv
);
2081 if (TEST_EQ_4V(texUnit
->EyePlaneQ
, tmp
))
2083 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
2084 COPY_4FV(texUnit
->EyePlaneQ
, tmp
);
2087 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(pname)" );
2092 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(coord)" );
2096 if (ctx
->Driver
.TexGen
)
2097 ctx
->Driver
.TexGen( ctx
, coord
, pname
, params
);
2102 _mesa_TexGeniv(GLenum coord
, GLenum pname
, const GLint
*params
)
2105 p
[0] = (GLfloat
) params
[0];
2106 p
[1] = (GLfloat
) params
[1];
2107 p
[2] = (GLfloat
) params
[2];
2108 p
[3] = (GLfloat
) params
[3];
2109 _mesa_TexGenfv(coord
, pname
, p
);
2114 _mesa_TexGend(GLenum coord
, GLenum pname
, GLdouble param
)
2116 GLfloat p
= (GLfloat
) param
;
2117 _mesa_TexGenfv( coord
, pname
, &p
);
2122 _mesa_TexGendv(GLenum coord
, GLenum pname
, const GLdouble
*params
)
2125 p
[0] = (GLfloat
) params
[0];
2126 p
[1] = (GLfloat
) params
[1];
2127 p
[2] = (GLfloat
) params
[2];
2128 p
[3] = (GLfloat
) params
[3];
2129 _mesa_TexGenfv( coord
, pname
, p
);
2134 _mesa_TexGenf( GLenum coord
, GLenum pname
, GLfloat param
)
2136 _mesa_TexGenfv(coord
, pname
, ¶m
);
2141 _mesa_TexGeni( GLenum coord
, GLenum pname
, GLint param
)
2143 _mesa_TexGeniv( coord
, pname
, ¶m
);
2149 _mesa_GetTexGendv( GLenum coord
, GLenum pname
, GLdouble
*params
)
2151 GET_CURRENT_CONTEXT(ctx
);
2152 GLuint tUnit
= ctx
->Texture
.CurrentUnit
;
2153 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[tUnit
];
2154 ASSERT_OUTSIDE_BEGIN_END(ctx
);
2158 if (pname
==GL_TEXTURE_GEN_MODE
) {
2159 params
[0] = ENUM_TO_DOUBLE(texUnit
->GenModeS
);
2161 else if (pname
==GL_OBJECT_PLANE
) {
2162 COPY_4V( params
, texUnit
->ObjectPlaneS
);
2164 else if (pname
==GL_EYE_PLANE
) {
2165 COPY_4V( params
, texUnit
->EyePlaneS
);
2168 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGendv(pname)" );
2173 if (pname
==GL_TEXTURE_GEN_MODE
) {
2174 params
[0] = ENUM_TO_DOUBLE(texUnit
->GenModeT
);
2176 else if (pname
==GL_OBJECT_PLANE
) {
2177 COPY_4V( params
, texUnit
->ObjectPlaneT
);
2179 else if (pname
==GL_EYE_PLANE
) {
2180 COPY_4V( params
, texUnit
->EyePlaneT
);
2183 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGendv(pname)" );
2188 if (pname
==GL_TEXTURE_GEN_MODE
) {
2189 params
[0] = ENUM_TO_DOUBLE(texUnit
->GenModeR
);
2191 else if (pname
==GL_OBJECT_PLANE
) {
2192 COPY_4V( params
, texUnit
->ObjectPlaneR
);
2194 else if (pname
==GL_EYE_PLANE
) {
2195 COPY_4V( params
, texUnit
->EyePlaneR
);
2198 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGendv(pname)" );
2203 if (pname
==GL_TEXTURE_GEN_MODE
) {
2204 params
[0] = ENUM_TO_DOUBLE(texUnit
->GenModeQ
);
2206 else if (pname
==GL_OBJECT_PLANE
) {
2207 COPY_4V( params
, texUnit
->ObjectPlaneQ
);
2209 else if (pname
==GL_EYE_PLANE
) {
2210 COPY_4V( params
, texUnit
->EyePlaneQ
);
2213 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGendv(pname)" );
2218 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGendv(coord)" );
2226 _mesa_GetTexGenfv( GLenum coord
, GLenum pname
, GLfloat
*params
)
2228 GET_CURRENT_CONTEXT(ctx
);
2229 GLuint tUnit
= ctx
->Texture
.CurrentUnit
;
2230 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[tUnit
];
2231 ASSERT_OUTSIDE_BEGIN_END(ctx
);
2235 if (pname
==GL_TEXTURE_GEN_MODE
) {
2236 params
[0] = ENUM_TO_FLOAT(texUnit
->GenModeS
);
2238 else if (pname
==GL_OBJECT_PLANE
) {
2239 COPY_4V( params
, texUnit
->ObjectPlaneS
);
2241 else if (pname
==GL_EYE_PLANE
) {
2242 COPY_4V( params
, texUnit
->EyePlaneS
);
2245 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGenfv(pname)" );
2250 if (pname
==GL_TEXTURE_GEN_MODE
) {
2251 params
[0] = ENUM_TO_FLOAT(texUnit
->GenModeT
);
2253 else if (pname
==GL_OBJECT_PLANE
) {
2254 COPY_4V( params
, texUnit
->ObjectPlaneT
);
2256 else if (pname
==GL_EYE_PLANE
) {
2257 COPY_4V( params
, texUnit
->EyePlaneT
);
2260 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGenfv(pname)" );
2265 if (pname
==GL_TEXTURE_GEN_MODE
) {
2266 params
[0] = ENUM_TO_FLOAT(texUnit
->GenModeR
);
2268 else if (pname
==GL_OBJECT_PLANE
) {
2269 COPY_4V( params
, texUnit
->ObjectPlaneR
);
2271 else if (pname
==GL_EYE_PLANE
) {
2272 COPY_4V( params
, texUnit
->EyePlaneR
);
2275 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGenfv(pname)" );
2280 if (pname
==GL_TEXTURE_GEN_MODE
) {
2281 params
[0] = ENUM_TO_FLOAT(texUnit
->GenModeQ
);
2283 else if (pname
==GL_OBJECT_PLANE
) {
2284 COPY_4V( params
, texUnit
->ObjectPlaneQ
);
2286 else if (pname
==GL_EYE_PLANE
) {
2287 COPY_4V( params
, texUnit
->EyePlaneQ
);
2290 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGenfv(pname)" );
2295 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGenfv(coord)" );
2303 _mesa_GetTexGeniv( GLenum coord
, GLenum pname
, GLint
*params
)
2305 GET_CURRENT_CONTEXT(ctx
);
2306 GLuint tUnit
= ctx
->Texture
.CurrentUnit
;
2307 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[tUnit
];
2308 ASSERT_OUTSIDE_BEGIN_END(ctx
);
2312 if (pname
==GL_TEXTURE_GEN_MODE
) {
2313 params
[0] = texUnit
->GenModeS
;
2315 else if (pname
==GL_OBJECT_PLANE
) {
2316 params
[0] = (GLint
) texUnit
->ObjectPlaneS
[0];
2317 params
[1] = (GLint
) texUnit
->ObjectPlaneS
[1];
2318 params
[2] = (GLint
) texUnit
->ObjectPlaneS
[2];
2319 params
[3] = (GLint
) texUnit
->ObjectPlaneS
[3];
2321 else if (pname
==GL_EYE_PLANE
) {
2322 params
[0] = (GLint
) texUnit
->EyePlaneS
[0];
2323 params
[1] = (GLint
) texUnit
->EyePlaneS
[1];
2324 params
[2] = (GLint
) texUnit
->EyePlaneS
[2];
2325 params
[3] = (GLint
) texUnit
->EyePlaneS
[3];
2328 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGeniv(pname)" );
2333 if (pname
==GL_TEXTURE_GEN_MODE
) {
2334 params
[0] = texUnit
->GenModeT
;
2336 else if (pname
==GL_OBJECT_PLANE
) {
2337 params
[0] = (GLint
) texUnit
->ObjectPlaneT
[0];
2338 params
[1] = (GLint
) texUnit
->ObjectPlaneT
[1];
2339 params
[2] = (GLint
) texUnit
->ObjectPlaneT
[2];
2340 params
[3] = (GLint
) texUnit
->ObjectPlaneT
[3];
2342 else if (pname
==GL_EYE_PLANE
) {
2343 params
[0] = (GLint
) texUnit
->EyePlaneT
[0];
2344 params
[1] = (GLint
) texUnit
->EyePlaneT
[1];
2345 params
[2] = (GLint
) texUnit
->EyePlaneT
[2];
2346 params
[3] = (GLint
) texUnit
->EyePlaneT
[3];
2349 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGeniv(pname)" );
2354 if (pname
==GL_TEXTURE_GEN_MODE
) {
2355 params
[0] = texUnit
->GenModeR
;
2357 else if (pname
==GL_OBJECT_PLANE
) {
2358 params
[0] = (GLint
) texUnit
->ObjectPlaneR
[0];
2359 params
[1] = (GLint
) texUnit
->ObjectPlaneR
[1];
2360 params
[2] = (GLint
) texUnit
->ObjectPlaneR
[2];
2361 params
[3] = (GLint
) texUnit
->ObjectPlaneR
[3];
2363 else if (pname
==GL_EYE_PLANE
) {
2364 params
[0] = (GLint
) texUnit
->EyePlaneR
[0];
2365 params
[1] = (GLint
) texUnit
->EyePlaneR
[1];
2366 params
[2] = (GLint
) texUnit
->EyePlaneR
[2];
2367 params
[3] = (GLint
) texUnit
->EyePlaneR
[3];
2370 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGeniv(pname)" );
2375 if (pname
==GL_TEXTURE_GEN_MODE
) {
2376 params
[0] = texUnit
->GenModeQ
;
2378 else if (pname
==GL_OBJECT_PLANE
) {
2379 params
[0] = (GLint
) texUnit
->ObjectPlaneQ
[0];
2380 params
[1] = (GLint
) texUnit
->ObjectPlaneQ
[1];
2381 params
[2] = (GLint
) texUnit
->ObjectPlaneQ
[2];
2382 params
[3] = (GLint
) texUnit
->ObjectPlaneQ
[3];
2384 else if (pname
==GL_EYE_PLANE
) {
2385 params
[0] = (GLint
) texUnit
->EyePlaneQ
[0];
2386 params
[1] = (GLint
) texUnit
->EyePlaneQ
[1];
2387 params
[2] = (GLint
) texUnit
->EyePlaneQ
[2];
2388 params
[3] = (GLint
) texUnit
->EyePlaneQ
[3];
2391 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGeniv(pname)" );
2396 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGeniv(coord)" );
2402 /* GL_ARB_multitexture */
2404 _mesa_ActiveTextureARB( GLenum target
)
2406 GET_CURRENT_CONTEXT(ctx
);
2407 GLuint texUnit
= target
- GL_TEXTURE0_ARB
;
2408 ASSERT_OUTSIDE_BEGIN_END(ctx
);
2410 if (MESA_VERBOSE
& (VERBOSE_API
|VERBOSE_TEXTURE
))
2411 _mesa_debug(ctx
, "glActiveTexture %s\n",
2412 _mesa_lookup_enum_by_nr(target
));
2414 if (texUnit
> ctx
->Const
.MaxTextureUnits
) {
2415 _mesa_error(ctx
, GL_INVALID_ENUM
, "glActiveTextureARB(target)");
2419 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
2420 ctx
->Texture
.CurrentUnit
= texUnit
;
2421 if (ctx
->Driver
.ActiveTexture
) {
2422 (*ctx
->Driver
.ActiveTexture
)( ctx
, (GLuint
) texUnit
);
2427 /* GL_ARB_multitexture */
2429 _mesa_ClientActiveTextureARB( GLenum target
)
2431 GET_CURRENT_CONTEXT(ctx
);
2432 GLuint texUnit
= target
- GL_TEXTURE0_ARB
;
2433 ASSERT_OUTSIDE_BEGIN_END(ctx
);
2435 if (texUnit
> ctx
->Const
.MaxTextureUnits
) {
2436 _mesa_error(ctx
, GL_INVALID_ENUM
, "glClientActiveTextureARB(target)");
2440 FLUSH_VERTICES(ctx
, _NEW_ARRAY
);
2441 ctx
->Array
.ActiveTexture
= texUnit
;
2446 /**********************************************************************/
2447 /* Pixel Texgen Extensions */
2448 /**********************************************************************/
2451 _mesa_PixelTexGenSGIX(GLenum mode
)
2453 GLenum newRgbSource
, newAlphaSource
;
2454 GET_CURRENT_CONTEXT(ctx
);
2455 ASSERT_OUTSIDE_BEGIN_END(ctx
);
2459 newRgbSource
= GL_PIXEL_GROUP_COLOR_SGIS
;
2460 newAlphaSource
= GL_PIXEL_GROUP_COLOR_SGIS
;
2463 newRgbSource
= GL_PIXEL_GROUP_COLOR_SGIS
;
2464 newAlphaSource
= GL_CURRENT_RASTER_COLOR
;
2467 newRgbSource
= GL_CURRENT_RASTER_COLOR
;
2468 newAlphaSource
= GL_PIXEL_GROUP_COLOR_SGIS
;
2471 newRgbSource
= GL_CURRENT_RASTER_COLOR
;
2472 newAlphaSource
= GL_CURRENT_RASTER_COLOR
;
2475 _mesa_error(ctx
, GL_INVALID_ENUM
, "glPixelTexGenSGIX(mode)");
2479 if (newRgbSource
== ctx
->Pixel
.FragmentRgbSource
&&
2480 newAlphaSource
== ctx
->Pixel
.FragmentAlphaSource
)
2483 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
2484 ctx
->Pixel
.FragmentRgbSource
= newRgbSource
;
2485 ctx
->Pixel
.FragmentAlphaSource
= newAlphaSource
;
2490 _mesa_PixelTexGenParameterfSGIS(GLenum target
, GLfloat value
)
2492 _mesa_PixelTexGenParameteriSGIS(target
, (GLint
) value
);
2497 _mesa_PixelTexGenParameterfvSGIS(GLenum target
, const GLfloat
*value
)
2499 _mesa_PixelTexGenParameteriSGIS(target
, (GLint
) *value
);
2504 _mesa_PixelTexGenParameteriSGIS(GLenum target
, GLint value
)
2506 GET_CURRENT_CONTEXT(ctx
);
2507 ASSERT_OUTSIDE_BEGIN_END(ctx
);
2509 if (value
!= GL_CURRENT_RASTER_COLOR
&& value
!= GL_PIXEL_GROUP_COLOR_SGIS
) {
2510 _mesa_error(ctx
, GL_INVALID_ENUM
, "glPixelTexGenParameterSGIS(value)");
2515 case GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS
:
2516 if (ctx
->Pixel
.FragmentRgbSource
== (GLenum
) value
)
2518 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
2519 ctx
->Pixel
.FragmentRgbSource
= (GLenum
) value
;
2521 case GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS
:
2522 if (ctx
->Pixel
.FragmentAlphaSource
== (GLenum
) value
)
2524 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
2525 ctx
->Pixel
.FragmentAlphaSource
= (GLenum
) value
;
2528 _mesa_error(ctx
, GL_INVALID_ENUM
, "glPixelTexGenParameterSGIS(target)");
2535 _mesa_PixelTexGenParameterivSGIS(GLenum target
, const GLint
*value
)
2537 _mesa_PixelTexGenParameteriSGIS(target
, *value
);
2542 _mesa_GetPixelTexGenParameterfvSGIS(GLenum target
, GLfloat
*value
)
2544 GET_CURRENT_CONTEXT(ctx
);
2545 ASSERT_OUTSIDE_BEGIN_END(ctx
);
2547 if (target
== GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS
) {
2548 *value
= (GLfloat
) ctx
->Pixel
.FragmentRgbSource
;
2550 else if (target
== GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS
) {
2551 *value
= (GLfloat
) ctx
->Pixel
.FragmentAlphaSource
;
2554 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetPixelTexGenParameterfvSGIS(target)");
2560 _mesa_GetPixelTexGenParameterivSGIS(GLenum target
, GLint
*value
)
2562 GET_CURRENT_CONTEXT(ctx
);
2563 ASSERT_OUTSIDE_BEGIN_END(ctx
);
2565 if (target
== GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS
) {
2566 *value
= (GLint
) ctx
->Pixel
.FragmentRgbSource
;
2568 else if (target
== GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS
) {
2569 *value
= (GLint
) ctx
->Pixel
.FragmentAlphaSource
;
2572 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetPixelTexGenParameterivSGIS(target)");