1 /* $Id: texstate.c,v 1.81 2002/10/17 22:26:06 kschultz 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 /* non-rectangle texture */
1098 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1099 texObj
->WrapS
= eparam
;
1102 _mesa_error( ctx
, GL_INVALID_VALUE
, "glTexParameter(param)" );
1106 case GL_TEXTURE_WRAP_T
:
1107 if (texObj
->WrapT
== eparam
)
1109 if (eparam
== GL_CLAMP
|| eparam
== GL_CLAMP_TO_EDGE
||
1110 (eparam
== GL_CLAMP_TO_BORDER_ARB
&&
1111 ctx
->Extensions
.ARB_texture_border_clamp
)) {
1112 /* any texture target */
1113 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1114 texObj
->WrapT
= eparam
;
1116 else if (texObj
->Target
!= GL_TEXTURE_RECTANGLE_NV
&&
1117 (eparam
== GL_REPEAT
||
1118 (eparam
== GL_MIRRORED_REPEAT_ARB
&&
1119 ctx
->Extensions
.ARB_texture_mirrored_repeat
))) {
1120 /* non-rectangle texture */
1121 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1122 texObj
->WrapT
= eparam
;
1125 _mesa_error( ctx
, GL_INVALID_VALUE
, "glTexParameter(param)" );
1129 case GL_TEXTURE_WRAP_R_EXT
:
1130 if (texObj
->WrapR
== eparam
)
1132 if (eparam
== GL_CLAMP
|| eparam
== GL_CLAMP_TO_EDGE
||
1133 (eparam
== GL_CLAMP_TO_BORDER_ARB
&&
1134 ctx
->Extensions
.ARB_texture_border_clamp
)) {
1135 /* any texture target */
1136 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1137 texObj
->WrapR
= eparam
;
1139 else if (texObj
->Target
!= GL_TEXTURE_RECTANGLE_NV
&&
1140 (eparam
== GL_REPEAT
||
1141 (eparam
== GL_MIRRORED_REPEAT_ARB
&&
1142 ctx
->Extensions
.ARB_texture_mirrored_repeat
))) {
1143 /* non-rectangle texture */
1144 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1145 texObj
->WrapR
= eparam
;
1148 _mesa_error( ctx
, GL_INVALID_VALUE
, "glTexParameter(param)" );
1151 case GL_TEXTURE_BORDER_COLOR
:
1152 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1153 texObj
->BorderColor
[RCOMP
] = params
[0];
1154 texObj
->BorderColor
[GCOMP
] = params
[1];
1155 texObj
->BorderColor
[BCOMP
] = params
[2];
1156 texObj
->BorderColor
[ACOMP
] = params
[3];
1157 UNCLAMPED_FLOAT_TO_CHAN(texObj
->_BorderChan
[RCOMP
], params
[0]);
1158 UNCLAMPED_FLOAT_TO_CHAN(texObj
->_BorderChan
[GCOMP
], params
[1]);
1159 UNCLAMPED_FLOAT_TO_CHAN(texObj
->_BorderChan
[BCOMP
], params
[2]);
1160 UNCLAMPED_FLOAT_TO_CHAN(texObj
->_BorderChan
[ACOMP
], params
[3]);
1162 case GL_TEXTURE_MIN_LOD
:
1163 if (texObj
->MinLod
== params
[0])
1165 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1166 texObj
->MinLod
= params
[0];
1168 case GL_TEXTURE_MAX_LOD
:
1169 if (texObj
->MaxLod
== params
[0])
1171 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1172 texObj
->MaxLod
= params
[0];
1174 case GL_TEXTURE_BASE_LEVEL
:
1175 if (params
[0] < 0.0) {
1176 _mesa_error(ctx
, GL_INVALID_VALUE
, "glTexParameter(param)" );
1179 if (target
== GL_TEXTURE_RECTANGLE_NV
&& params
[0] != 0.0) {
1180 _mesa_error(ctx
, GL_INVALID_VALUE
, "glTexParameter(param)" );
1183 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1184 texObj
->BaseLevel
= (GLint
) params
[0];
1186 case GL_TEXTURE_MAX_LEVEL
:
1187 if (params
[0] < 0.0) {
1188 _mesa_error(ctx
, GL_INVALID_VALUE
, "glTexParameter(param)" );
1191 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1192 texObj
->MaxLevel
= (GLint
) params
[0];
1194 case GL_TEXTURE_PRIORITY
:
1195 /* (keithh@netcomuk.co.uk) */
1196 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1197 texObj
->Priority
= CLAMP( params
[0], 0.0F
, 1.0F
);
1199 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1200 if (ctx
->Extensions
.EXT_texture_filter_anisotropic
) {
1201 if (params
[0] < 1.0) {
1202 _mesa_error(ctx
, GL_INVALID_VALUE
, "glTexParameter(param)" );
1205 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1206 texObj
->MaxAnisotropy
= params
[0];
1209 _mesa_error(ctx
, GL_INVALID_ENUM
,
1210 "glTexParameter(pname=GL_MAX_TEXTURE_ANISOTROPY_EXT)");
1214 case GL_TEXTURE_COMPARE_SGIX
:
1215 if (ctx
->Extensions
.SGIX_shadow
) {
1216 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1217 texObj
->CompareFlag
= params
[0] ? GL_TRUE
: GL_FALSE
;
1220 _mesa_error(ctx
, GL_INVALID_ENUM
,
1221 "glTexParameter(pname=GL_TEXTURE_COMPARE_SGIX)");
1225 case GL_TEXTURE_COMPARE_OPERATOR_SGIX
:
1226 if (ctx
->Extensions
.SGIX_shadow
) {
1227 GLenum op
= (GLenum
) params
[0];
1228 if (op
== GL_TEXTURE_LEQUAL_R_SGIX
||
1229 op
== GL_TEXTURE_GEQUAL_R_SGIX
) {
1230 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1231 texObj
->CompareOperator
= op
;
1234 _mesa_error(ctx
, GL_INVALID_ENUM
, "glTexParameter(param)");
1238 _mesa_error(ctx
, GL_INVALID_ENUM
,
1239 "glTexParameter(pname=GL_TEXTURE_COMPARE_OPERATOR_SGIX)");
1243 case GL_SHADOW_AMBIENT_SGIX
: /* aka GL_TEXTURE_COMPARE_FAIL_VALUE_ARB */
1244 if (ctx
->Extensions
.SGIX_shadow_ambient
) {
1245 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1246 texObj
->ShadowAmbient
= CLAMP(params
[0], 0.0F
, 1.0F
);
1249 _mesa_error(ctx
, GL_INVALID_ENUM
,
1250 "glTexParameter(pname=GL_SHADOW_AMBIENT_SGIX)");
1254 case GL_GENERATE_MIPMAP_SGIS
:
1255 if (ctx
->Extensions
.SGIS_generate_mipmap
) {
1256 texObj
->GenerateMipmap
= params
[0] ? GL_TRUE
: GL_FALSE
;
1259 _mesa_error(ctx
, GL_INVALID_ENUM
,
1260 "glTexParameter(pname=GL_GENERATE_MIPMAP_SGIS)");
1264 case GL_TEXTURE_COMPARE_MODE_ARB
:
1265 if (ctx
->Extensions
.ARB_shadow
) {
1266 const GLenum mode
= (GLenum
) params
[0];
1267 if (mode
== GL_NONE
|| mode
== GL_COMPARE_R_TO_TEXTURE_ARB
) {
1268 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1269 texObj
->CompareMode
= mode
;
1272 _mesa_error(ctx
, GL_INVALID_ENUM
,
1273 "glTexParameter(bad GL_TEXTURE_COMPARE_MODE_ARB)");
1278 _mesa_error(ctx
, GL_INVALID_ENUM
,
1279 "glTexParameter(pname=GL_TEXTURE_COMPARE_MODE_ARB)");
1283 case GL_TEXTURE_COMPARE_FUNC_ARB
:
1284 if (ctx
->Extensions
.ARB_shadow
) {
1285 const GLenum func
= (GLenum
) params
[0];
1286 if (func
== GL_LEQUAL
|| func
== GL_GEQUAL
) {
1287 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1288 texObj
->CompareFunc
= func
;
1290 else if (ctx
->Extensions
.EXT_shadow_funcs
&&
1291 (func
== GL_EQUAL
||
1292 func
== GL_NOTEQUAL
||
1294 func
== GL_GREATER
||
1295 func
== GL_ALWAYS
||
1296 func
== GL_NEVER
)) {
1297 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1298 texObj
->CompareFunc
= func
;
1301 _mesa_error(ctx
, GL_INVALID_ENUM
,
1302 "glTexParameter(bad GL_TEXTURE_COMPARE_FUNC_ARB)");
1307 _mesa_error(ctx
, GL_INVALID_ENUM
,
1308 "glTexParameter(pname=GL_TEXTURE_COMPARE_FUNC_ARB)");
1312 case GL_DEPTH_TEXTURE_MODE_ARB
:
1313 if (ctx
->Extensions
.ARB_depth_texture
) {
1314 const GLenum result
= (GLenum
) params
[0];
1315 if (result
== GL_LUMINANCE
|| result
== GL_INTENSITY
1316 || result
== GL_ALPHA
) {
1317 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1318 texObj
->DepthMode
= result
;
1321 _mesa_error(ctx
, GL_INVALID_ENUM
,
1322 "glTexParameter(bad GL_DEPTH_TEXTURE_MODE_ARB)");
1327 _mesa_error(ctx
, GL_INVALID_ENUM
,
1328 "glTexParameter(pname=GL_DEPTH_TEXTURE_MODE_ARB)");
1334 _mesa_error(ctx
, GL_INVALID_ENUM
,
1335 "glTexParameter(pname=0x%x)", pname
);
1339 texObj
->Complete
= GL_FALSE
;
1341 if (ctx
->Driver
.TexParameter
) {
1342 (*ctx
->Driver
.TexParameter
)( ctx
, target
, texObj
, pname
, params
);
1348 _mesa_TexParameteri( GLenum target
, GLenum pname
, GLint param
)
1351 fparam
[0] = (GLfloat
) param
;
1352 fparam
[1] = fparam
[2] = fparam
[3] = 0.0;
1353 _mesa_TexParameterfv(target
, pname
, fparam
);
1357 _mesa_TexParameteriv( GLenum target
, GLenum pname
, const GLint
*params
)
1360 fparam
[0] = (GLfloat
) params
[0];
1361 fparam
[1] = fparam
[2] = fparam
[3] = 0.0;
1362 _mesa_TexParameterfv(target
, pname
, fparam
);
1367 _mesa_GetTexLevelParameterfv( GLenum target
, GLint level
,
1368 GLenum pname
, GLfloat
*params
)
1371 _mesa_GetTexLevelParameteriv( target
, level
, pname
, &iparam
);
1372 *params
= (GLfloat
) iparam
;
1377 tex_image_dimensions(GLcontext
*ctx
, GLenum target
)
1381 case GL_PROXY_TEXTURE_1D
:
1384 case GL_PROXY_TEXTURE_2D
:
1387 case GL_PROXY_TEXTURE_3D
:
1389 case GL_TEXTURE_CUBE_MAP_ARB
:
1390 case GL_PROXY_TEXTURE_CUBE_MAP_ARB
:
1391 case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB
:
1392 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB
:
1393 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB
:
1394 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB
:
1395 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB
:
1396 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB
:
1397 return ctx
->Extensions
.ARB_texture_cube_map
? 2 : 0;
1398 case GL_TEXTURE_RECTANGLE_NV
:
1399 case GL_PROXY_TEXTURE_RECTANGLE_NV
:
1400 return ctx
->Extensions
.NV_texture_rectangle
? 2 : 0;
1402 _mesa_problem(ctx
, "bad target in _mesa_tex_target_dimensions()");
1409 _mesa_GetTexLevelParameteriv( GLenum target
, GLint level
,
1410 GLenum pname
, GLint
*params
)
1412 GET_CURRENT_CONTEXT(ctx
);
1413 const struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1414 const struct gl_texture_image
*img
= NULL
;
1418 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1420 /* this will catch bad target values */
1421 dimensions
= tex_image_dimensions(ctx
, target
); /* 1, 2 or 3 */
1422 if (dimensions
== 0) {
1423 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexLevelParameter[if]v(target)");
1429 case GL_PROXY_TEXTURE_1D
:
1431 case GL_PROXY_TEXTURE_2D
:
1432 maxLevels
= ctx
->Const
.MaxTextureLevels
;
1435 case GL_PROXY_TEXTURE_3D
:
1436 maxLevels
= ctx
->Const
.Max3DTextureLevels
;
1438 case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB
:
1439 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB
:
1440 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB
:
1441 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB
:
1442 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB
:
1443 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB
:
1444 case GL_PROXY_TEXTURE_CUBE_MAP_ARB
:
1445 maxLevels
= ctx
->Const
.MaxCubeTextureLevels
;
1447 case GL_TEXTURE_RECTANGLE_NV
:
1448 case GL_PROXY_TEXTURE_RECTANGLE_NV
:
1452 _mesa_problem(ctx
, "switch in _mesa_GetTexLevelParameter");
1456 if (level
< 0 || level
>= maxLevels
) {
1457 _mesa_error( ctx
, GL_INVALID_VALUE
, "glGetTexLevelParameter[if]v" );
1461 img
= _mesa_select_tex_image(ctx
, texUnit
, target
, level
);
1462 if (!img
|| !img
->TexFormat
) {
1463 /* undefined texture image */
1464 if (pname
== GL_TEXTURE_COMPONENTS
)
1471 isProxy
= (target
== GL_PROXY_TEXTURE_1D
) ||
1472 (target
== GL_PROXY_TEXTURE_2D
) ||
1473 (target
== GL_PROXY_TEXTURE_3D
) ||
1474 (target
== GL_PROXY_TEXTURE_CUBE_MAP_ARB
) ||
1475 (target
== GL_PROXY_TEXTURE_RECTANGLE_NV
);
1478 case GL_TEXTURE_WIDTH
:
1479 *params
= img
->Width
;
1481 case GL_TEXTURE_HEIGHT
:
1482 *params
= img
->Height
;
1484 case GL_TEXTURE_DEPTH
:
1485 *params
= img
->Depth
;
1487 case GL_TEXTURE_INTERNAL_FORMAT
:
1488 *params
= img
->IntFormat
;
1490 case GL_TEXTURE_BORDER
:
1491 *params
= img
->Border
;
1493 case GL_TEXTURE_RED_SIZE
:
1494 if (img
->Format
== GL_RGB
|| img
->Format
== GL_RGBA
)
1495 *params
= img
->TexFormat
->RedBits
;
1499 case GL_TEXTURE_GREEN_SIZE
:
1500 if (img
->Format
== GL_RGB
|| img
->Format
== GL_RGBA
)
1501 *params
= img
->TexFormat
->GreenBits
;
1505 case GL_TEXTURE_BLUE_SIZE
:
1506 if (img
->Format
== GL_RGB
|| img
->Format
== GL_RGBA
)
1507 *params
= img
->TexFormat
->BlueBits
;
1511 case GL_TEXTURE_ALPHA_SIZE
:
1512 if (img
->Format
== GL_ALPHA
|| img
->Format
== GL_LUMINANCE_ALPHA
||
1513 img
->Format
== GL_RGBA
)
1514 *params
= img
->TexFormat
->AlphaBits
;
1518 case GL_TEXTURE_INTENSITY_SIZE
:
1519 if (img
->Format
!= GL_INTENSITY
)
1521 else if (img
->TexFormat
->IntensityBits
> 0)
1522 *params
= img
->TexFormat
->IntensityBits
;
1523 else /* intensity probably stored as rgb texture */
1524 *params
= MIN2(img
->TexFormat
->RedBits
, img
->TexFormat
->GreenBits
);
1526 case GL_TEXTURE_LUMINANCE_SIZE
:
1527 if (img
->Format
!= GL_LUMINANCE
&&
1528 img
->Format
!= GL_LUMINANCE_ALPHA
)
1530 else if (img
->TexFormat
->LuminanceBits
> 0)
1531 *params
= img
->TexFormat
->LuminanceBits
;
1532 else /* luminance probably stored as rgb texture */
1533 *params
= MIN2(img
->TexFormat
->RedBits
, img
->TexFormat
->GreenBits
);
1535 case GL_TEXTURE_INDEX_SIZE_EXT
:
1536 if (img
->Format
== GL_COLOR_INDEX
)
1537 *params
= img
->TexFormat
->IndexBits
;
1542 /* XXX this isn't in the GL_SGIX_depth_texture spec
1543 * but seems appropriate.
1545 if (ctx
->Extensions
.SGIX_depth_texture
)
1546 *params
= img
->TexFormat
->DepthBits
;
1548 _mesa_error(ctx
, GL_INVALID_ENUM
,
1549 "glGetTexLevelParameter[if]v(pname)");
1552 /* GL_ARB_texture_compression */
1553 case GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB
:
1554 if (ctx
->Extensions
.ARB_texture_compression
) {
1555 if (img
->IsCompressed
&& !isProxy
)
1556 *params
= img
->CompressedSize
;
1558 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1559 "glGetTexLevelParameter[if]v(pname)");
1562 _mesa_error(ctx
, GL_INVALID_ENUM
,
1563 "glGetTexLevelParameter[if]v(pname)");
1566 case GL_TEXTURE_COMPRESSED_ARB
:
1567 if (ctx
->Extensions
.ARB_texture_compression
) {
1568 *params
= (GLint
) img
->IsCompressed
;
1571 _mesa_error(ctx
, GL_INVALID_ENUM
,
1572 "glGetTexLevelParameter[if]v(pname)");
1577 _mesa_error(ctx
, GL_INVALID_ENUM
,
1578 "glGetTexLevelParameter[if]v(pname)");
1585 _mesa_GetTexParameterfv( GLenum target
, GLenum pname
, GLfloat
*params
)
1587 GET_CURRENT_CONTEXT(ctx
);
1588 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1589 struct gl_texture_object
*obj
;
1590 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1592 obj
= _mesa_select_tex_object(ctx
, texUnit
, target
);
1594 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexParameterfv(target)");
1599 case GL_TEXTURE_MAG_FILTER
:
1600 *params
= ENUM_TO_FLOAT(obj
->MagFilter
);
1602 case GL_TEXTURE_MIN_FILTER
:
1603 *params
= ENUM_TO_FLOAT(obj
->MinFilter
);
1605 case GL_TEXTURE_WRAP_S
:
1606 *params
= ENUM_TO_FLOAT(obj
->WrapS
);
1608 case GL_TEXTURE_WRAP_T
:
1609 *params
= ENUM_TO_FLOAT(obj
->WrapT
);
1611 case GL_TEXTURE_WRAP_R_EXT
:
1612 *params
= ENUM_TO_FLOAT(obj
->WrapR
);
1614 case GL_TEXTURE_BORDER_COLOR
:
1615 params
[0] = CLAMP(obj
->BorderColor
[0], 0.0F
, 1.0F
);
1616 params
[1] = CLAMP(obj
->BorderColor
[1], 0.0F
, 1.0F
);
1617 params
[2] = CLAMP(obj
->BorderColor
[2], 0.0F
, 1.0F
);
1618 params
[3] = CLAMP(obj
->BorderColor
[3], 0.0F
, 1.0F
);
1620 case GL_TEXTURE_RESIDENT
:
1623 if (ctx
->Driver
.IsTextureResident
)
1624 resident
= ctx
->Driver
.IsTextureResident(ctx
, obj
);
1627 *params
= ENUM_TO_FLOAT(resident
);
1630 case GL_TEXTURE_PRIORITY
:
1631 *params
= obj
->Priority
;
1633 case GL_TEXTURE_MIN_LOD
:
1634 *params
= obj
->MinLod
;
1636 case GL_TEXTURE_MAX_LOD
:
1637 *params
= obj
->MaxLod
;
1639 case GL_TEXTURE_BASE_LEVEL
:
1640 *params
= (GLfloat
) obj
->BaseLevel
;
1642 case GL_TEXTURE_MAX_LEVEL
:
1643 *params
= (GLfloat
) obj
->MaxLevel
;
1645 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1646 if (ctx
->Extensions
.EXT_texture_filter_anisotropic
) {
1647 *params
= obj
->MaxAnisotropy
;
1651 case GL_TEXTURE_COMPARE_SGIX
:
1652 if (ctx
->Extensions
.SGIX_shadow
) {
1653 *params
= (GLfloat
) obj
->CompareFlag
;
1657 case GL_TEXTURE_COMPARE_OPERATOR_SGIX
:
1658 if (ctx
->Extensions
.SGIX_shadow
) {
1659 *params
= (GLfloat
) obj
->CompareOperator
;
1663 case GL_SHADOW_AMBIENT_SGIX
: /* aka GL_TEXTURE_COMPARE_FAIL_VALUE_ARB */
1664 if (ctx
->Extensions
.SGIX_shadow_ambient
) {
1665 *params
= obj
->ShadowAmbient
;
1669 case GL_GENERATE_MIPMAP_SGIS
:
1670 if (ctx
->Extensions
.SGIS_generate_mipmap
) {
1671 *params
= (GLfloat
) obj
->GenerateMipmap
;
1675 case GL_TEXTURE_COMPARE_MODE_ARB
:
1676 if (ctx
->Extensions
.ARB_shadow
) {
1677 *params
= (GLfloat
) obj
->CompareMode
;
1681 case GL_TEXTURE_COMPARE_FUNC_ARB
:
1682 if (ctx
->Extensions
.ARB_shadow
) {
1683 *params
= (GLfloat
) obj
->CompareFunc
;
1687 case GL_DEPTH_TEXTURE_MODE_ARB
:
1688 if (ctx
->Extensions
.ARB_depth_texture
) {
1689 *params
= (GLfloat
) obj
->DepthMode
;
1694 ; /* silence warnings */
1696 /* If we get here, pname was an unrecognized enum */
1697 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexParameterfv(pname)" );
1702 _mesa_GetTexParameteriv( GLenum target
, GLenum pname
, GLint
*params
)
1704 GET_CURRENT_CONTEXT(ctx
);
1705 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1706 struct gl_texture_object
*obj
;
1707 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1709 obj
= _mesa_select_tex_object(ctx
, texUnit
, target
);
1711 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexParameteriv(target)");
1716 case GL_TEXTURE_MAG_FILTER
:
1717 *params
= (GLint
) obj
->MagFilter
;
1719 case GL_TEXTURE_MIN_FILTER
:
1720 *params
= (GLint
) obj
->MinFilter
;
1722 case GL_TEXTURE_WRAP_S
:
1723 *params
= (GLint
) obj
->WrapS
;
1725 case GL_TEXTURE_WRAP_T
:
1726 *params
= (GLint
) obj
->WrapT
;
1728 case GL_TEXTURE_WRAP_R_EXT
:
1729 *params
= (GLint
) obj
->WrapR
;
1731 case GL_TEXTURE_BORDER_COLOR
:
1734 b
[0] = CLAMP(obj
->BorderColor
[0], 0.0F
, 1.0F
);
1735 b
[1] = CLAMP(obj
->BorderColor
[1], 0.0F
, 1.0F
);
1736 b
[2] = CLAMP(obj
->BorderColor
[2], 0.0F
, 1.0F
);
1737 b
[3] = CLAMP(obj
->BorderColor
[3], 0.0F
, 1.0F
);
1738 params
[0] = FLOAT_TO_INT(b
[0]);
1739 params
[1] = FLOAT_TO_INT(b
[1]);
1740 params
[2] = FLOAT_TO_INT(b
[2]);
1741 params
[3] = FLOAT_TO_INT(b
[3]);
1744 case GL_TEXTURE_RESIDENT
:
1747 if (ctx
->Driver
.IsTextureResident
)
1748 resident
= ctx
->Driver
.IsTextureResident(ctx
, obj
);
1751 *params
= (GLint
) resident
;
1754 case GL_TEXTURE_PRIORITY
:
1755 *params
= (GLint
) obj
->Priority
;
1757 case GL_TEXTURE_MIN_LOD
:
1758 *params
= (GLint
) obj
->MinLod
;
1760 case GL_TEXTURE_MAX_LOD
:
1761 *params
= (GLint
) obj
->MaxLod
;
1763 case GL_TEXTURE_BASE_LEVEL
:
1764 *params
= obj
->BaseLevel
;
1766 case GL_TEXTURE_MAX_LEVEL
:
1767 *params
= obj
->MaxLevel
;
1769 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1770 if (ctx
->Extensions
.EXT_texture_filter_anisotropic
) {
1771 *params
= (GLint
) obj
->MaxAnisotropy
;
1775 case GL_TEXTURE_COMPARE_SGIX
:
1776 if (ctx
->Extensions
.SGIX_shadow
) {
1777 *params
= (GLint
) obj
->CompareFlag
;
1781 case GL_TEXTURE_COMPARE_OPERATOR_SGIX
:
1782 if (ctx
->Extensions
.SGIX_shadow
) {
1783 *params
= (GLint
) obj
->CompareOperator
;
1787 case GL_SHADOW_AMBIENT_SGIX
: /* aka GL_TEXTURE_COMPARE_FAIL_VALUE_ARB */
1788 if (ctx
->Extensions
.SGIX_shadow_ambient
) {
1789 *params
= (GLint
) FLOAT_TO_INT(obj
->ShadowAmbient
);
1793 case GL_GENERATE_MIPMAP_SGIS
:
1794 if (ctx
->Extensions
.SGIS_generate_mipmap
) {
1795 *params
= (GLint
) obj
->GenerateMipmap
;
1799 case GL_TEXTURE_COMPARE_MODE_ARB
:
1800 if (ctx
->Extensions
.ARB_shadow
) {
1801 *params
= (GLint
) obj
->CompareMode
;
1805 case GL_TEXTURE_COMPARE_FUNC_ARB
:
1806 if (ctx
->Extensions
.ARB_shadow
) {
1807 *params
= (GLint
) obj
->CompareFunc
;
1811 case GL_DEPTH_TEXTURE_MODE_ARB
:
1812 if (ctx
->Extensions
.ARB_depth_texture
) {
1813 *params
= (GLint
) obj
->DepthMode
;
1818 ; /* silence warnings */
1820 /* If we get here, pname was an unrecognized enum */
1821 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexParameteriv(pname)" );
1827 /**********************************************************************/
1828 /* Texture Coord Generation */
1829 /**********************************************************************/
1833 _mesa_TexGenfv( GLenum coord
, GLenum pname
, const GLfloat
*params
)
1835 GET_CURRENT_CONTEXT(ctx
);
1836 GLuint tUnit
= ctx
->Texture
.CurrentUnit
;
1837 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[tUnit
];
1838 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1840 if (MESA_VERBOSE
&(VERBOSE_API
|VERBOSE_TEXTURE
))
1841 _mesa_debug(ctx
, "texGEN %s %s %x...\n",
1842 _mesa_lookup_enum_by_nr(coord
),
1843 _mesa_lookup_enum_by_nr(pname
),
1848 if (pname
==GL_TEXTURE_GEN_MODE
) {
1849 GLenum mode
= (GLenum
) (GLint
) *params
;
1852 case GL_OBJECT_LINEAR
:
1853 bits
= TEXGEN_OBJ_LINEAR
;
1856 bits
= TEXGEN_EYE_LINEAR
;
1858 case GL_REFLECTION_MAP_NV
:
1859 bits
= TEXGEN_REFLECTION_MAP_NV
;
1861 case GL_NORMAL_MAP_NV
:
1862 bits
= TEXGEN_NORMAL_MAP_NV
;
1865 bits
= TEXGEN_SPHERE_MAP
;
1868 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(param)" );
1871 if (texUnit
->GenModeS
== mode
)
1873 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1874 texUnit
->GenModeS
= mode
;
1875 texUnit
->_GenBitS
= bits
;
1877 else if (pname
==GL_OBJECT_PLANE
) {
1878 if (TEST_EQ_4V(texUnit
->ObjectPlaneS
, params
))
1880 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1881 texUnit
->ObjectPlaneS
[0] = params
[0];
1882 texUnit
->ObjectPlaneS
[1] = params
[1];
1883 texUnit
->ObjectPlaneS
[2] = params
[2];
1884 texUnit
->ObjectPlaneS
[3] = params
[3];
1886 else if (pname
==GL_EYE_PLANE
) {
1889 /* Transform plane equation by the inverse modelview matrix */
1890 if (ctx
->ModelviewMatrixStack
.Top
->flags
& MAT_DIRTY_INVERSE
) {
1891 _math_matrix_analyse( ctx
->ModelviewMatrixStack
.Top
);
1893 _mesa_transform_vector( tmp
, params
, ctx
->ModelviewMatrixStack
.Top
->inv
);
1894 if (TEST_EQ_4V(texUnit
->EyePlaneS
, tmp
))
1896 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1897 COPY_4FV(texUnit
->EyePlaneS
, tmp
);
1900 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(pname)" );
1905 if (pname
==GL_TEXTURE_GEN_MODE
) {
1906 GLenum mode
= (GLenum
) (GLint
) *params
;
1909 case GL_OBJECT_LINEAR
:
1910 bitt
= TEXGEN_OBJ_LINEAR
;
1913 bitt
= TEXGEN_EYE_LINEAR
;
1915 case GL_REFLECTION_MAP_NV
:
1916 bitt
= TEXGEN_REFLECTION_MAP_NV
;
1918 case GL_NORMAL_MAP_NV
:
1919 bitt
= TEXGEN_NORMAL_MAP_NV
;
1922 bitt
= TEXGEN_SPHERE_MAP
;
1925 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(param)" );
1928 if (texUnit
->GenModeT
== mode
)
1930 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1931 texUnit
->GenModeT
= mode
;
1932 texUnit
->_GenBitT
= bitt
;
1934 else if (pname
==GL_OBJECT_PLANE
) {
1935 if (TEST_EQ_4V(texUnit
->ObjectPlaneT
, params
))
1937 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1938 texUnit
->ObjectPlaneT
[0] = params
[0];
1939 texUnit
->ObjectPlaneT
[1] = params
[1];
1940 texUnit
->ObjectPlaneT
[2] = params
[2];
1941 texUnit
->ObjectPlaneT
[3] = params
[3];
1943 else if (pname
==GL_EYE_PLANE
) {
1945 /* Transform plane equation by the inverse modelview matrix */
1946 if (ctx
->ModelviewMatrixStack
.Top
->flags
& MAT_DIRTY_INVERSE
) {
1947 _math_matrix_analyse( ctx
->ModelviewMatrixStack
.Top
);
1949 _mesa_transform_vector( tmp
, params
, ctx
->ModelviewMatrixStack
.Top
->inv
);
1950 if (TEST_EQ_4V(texUnit
->EyePlaneT
, tmp
))
1952 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1953 COPY_4FV(texUnit
->EyePlaneT
, tmp
);
1956 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(pname)" );
1961 if (pname
==GL_TEXTURE_GEN_MODE
) {
1962 GLenum mode
= (GLenum
) (GLint
) *params
;
1965 case GL_OBJECT_LINEAR
:
1966 bitr
= TEXGEN_OBJ_LINEAR
;
1968 case GL_REFLECTION_MAP_NV
:
1969 bitr
= TEXGEN_REFLECTION_MAP_NV
;
1971 case GL_NORMAL_MAP_NV
:
1972 bitr
= TEXGEN_NORMAL_MAP_NV
;
1975 bitr
= TEXGEN_EYE_LINEAR
;
1978 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(param)" );
1981 if (texUnit
->GenModeR
== mode
)
1983 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1984 texUnit
->GenModeR
= mode
;
1985 texUnit
->_GenBitR
= bitr
;
1987 else if (pname
==GL_OBJECT_PLANE
) {
1988 if (TEST_EQ_4V(texUnit
->ObjectPlaneR
, params
))
1990 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1991 texUnit
->ObjectPlaneR
[0] = params
[0];
1992 texUnit
->ObjectPlaneR
[1] = params
[1];
1993 texUnit
->ObjectPlaneR
[2] = params
[2];
1994 texUnit
->ObjectPlaneR
[3] = params
[3];
1996 else if (pname
==GL_EYE_PLANE
) {
1998 /* Transform plane equation by the inverse modelview matrix */
1999 if (ctx
->ModelviewMatrixStack
.Top
->flags
& MAT_DIRTY_INVERSE
) {
2000 _math_matrix_analyse( ctx
->ModelviewMatrixStack
.Top
);
2002 _mesa_transform_vector( tmp
, params
, ctx
->ModelviewMatrixStack
.Top
->inv
);
2003 if (TEST_EQ_4V(texUnit
->EyePlaneR
, tmp
))
2005 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
2006 COPY_4FV(texUnit
->EyePlaneR
, tmp
);
2009 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(pname)" );
2014 if (pname
==GL_TEXTURE_GEN_MODE
) {
2015 GLenum mode
= (GLenum
) (GLint
) *params
;
2018 case GL_OBJECT_LINEAR
:
2019 bitq
= TEXGEN_OBJ_LINEAR
;
2022 bitq
= TEXGEN_EYE_LINEAR
;
2025 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(param)" );
2028 if (texUnit
->GenModeQ
== mode
)
2030 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
2031 texUnit
->GenModeQ
= mode
;
2032 texUnit
->_GenBitQ
= bitq
;
2034 else if (pname
==GL_OBJECT_PLANE
) {
2035 if (TEST_EQ_4V(texUnit
->ObjectPlaneQ
, params
))
2037 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
2038 texUnit
->ObjectPlaneQ
[0] = params
[0];
2039 texUnit
->ObjectPlaneQ
[1] = params
[1];
2040 texUnit
->ObjectPlaneQ
[2] = params
[2];
2041 texUnit
->ObjectPlaneQ
[3] = params
[3];
2043 else if (pname
==GL_EYE_PLANE
) {
2045 /* Transform plane equation by the inverse modelview matrix */
2046 if (ctx
->ModelviewMatrixStack
.Top
->flags
& MAT_DIRTY_INVERSE
) {
2047 _math_matrix_analyse( ctx
->ModelviewMatrixStack
.Top
);
2049 _mesa_transform_vector( tmp
, params
, ctx
->ModelviewMatrixStack
.Top
->inv
);
2050 if (TEST_EQ_4V(texUnit
->EyePlaneQ
, tmp
))
2052 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
2053 COPY_4FV(texUnit
->EyePlaneQ
, tmp
);
2056 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(pname)" );
2061 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(coord)" );
2065 if (ctx
->Driver
.TexGen
)
2066 ctx
->Driver
.TexGen( ctx
, coord
, pname
, params
);
2071 _mesa_TexGeniv(GLenum coord
, GLenum pname
, const GLint
*params
)
2074 p
[0] = (GLfloat
) params
[0];
2075 p
[1] = (GLfloat
) params
[1];
2076 p
[2] = (GLfloat
) params
[2];
2077 p
[3] = (GLfloat
) params
[3];
2078 _mesa_TexGenfv(coord
, pname
, p
);
2083 _mesa_TexGend(GLenum coord
, GLenum pname
, GLdouble param
)
2085 GLfloat p
= (GLfloat
) param
;
2086 _mesa_TexGenfv( coord
, pname
, &p
);
2091 _mesa_TexGendv(GLenum coord
, GLenum pname
, const GLdouble
*params
)
2094 p
[0] = (GLfloat
) params
[0];
2095 p
[1] = (GLfloat
) params
[1];
2096 p
[2] = (GLfloat
) params
[2];
2097 p
[3] = (GLfloat
) params
[3];
2098 _mesa_TexGenfv( coord
, pname
, p
);
2103 _mesa_TexGenf( GLenum coord
, GLenum pname
, GLfloat param
)
2105 _mesa_TexGenfv(coord
, pname
, ¶m
);
2110 _mesa_TexGeni( GLenum coord
, GLenum pname
, GLint param
)
2112 _mesa_TexGeniv( coord
, pname
, ¶m
);
2118 _mesa_GetTexGendv( GLenum coord
, GLenum pname
, GLdouble
*params
)
2120 GET_CURRENT_CONTEXT(ctx
);
2121 GLuint tUnit
= ctx
->Texture
.CurrentUnit
;
2122 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[tUnit
];
2123 ASSERT_OUTSIDE_BEGIN_END(ctx
);
2127 if (pname
==GL_TEXTURE_GEN_MODE
) {
2128 params
[0] = ENUM_TO_DOUBLE(texUnit
->GenModeS
);
2130 else if (pname
==GL_OBJECT_PLANE
) {
2131 COPY_4V( params
, texUnit
->ObjectPlaneS
);
2133 else if (pname
==GL_EYE_PLANE
) {
2134 COPY_4V( params
, texUnit
->EyePlaneS
);
2137 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGendv(pname)" );
2142 if (pname
==GL_TEXTURE_GEN_MODE
) {
2143 params
[0] = ENUM_TO_DOUBLE(texUnit
->GenModeT
);
2145 else if (pname
==GL_OBJECT_PLANE
) {
2146 COPY_4V( params
, texUnit
->ObjectPlaneT
);
2148 else if (pname
==GL_EYE_PLANE
) {
2149 COPY_4V( params
, texUnit
->EyePlaneT
);
2152 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGendv(pname)" );
2157 if (pname
==GL_TEXTURE_GEN_MODE
) {
2158 params
[0] = ENUM_TO_DOUBLE(texUnit
->GenModeR
);
2160 else if (pname
==GL_OBJECT_PLANE
) {
2161 COPY_4V( params
, texUnit
->ObjectPlaneR
);
2163 else if (pname
==GL_EYE_PLANE
) {
2164 COPY_4V( params
, texUnit
->EyePlaneR
);
2167 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGendv(pname)" );
2172 if (pname
==GL_TEXTURE_GEN_MODE
) {
2173 params
[0] = ENUM_TO_DOUBLE(texUnit
->GenModeQ
);
2175 else if (pname
==GL_OBJECT_PLANE
) {
2176 COPY_4V( params
, texUnit
->ObjectPlaneQ
);
2178 else if (pname
==GL_EYE_PLANE
) {
2179 COPY_4V( params
, texUnit
->EyePlaneQ
);
2182 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGendv(pname)" );
2187 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGendv(coord)" );
2195 _mesa_GetTexGenfv( GLenum coord
, GLenum pname
, GLfloat
*params
)
2197 GET_CURRENT_CONTEXT(ctx
);
2198 GLuint tUnit
= ctx
->Texture
.CurrentUnit
;
2199 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[tUnit
];
2200 ASSERT_OUTSIDE_BEGIN_END(ctx
);
2204 if (pname
==GL_TEXTURE_GEN_MODE
) {
2205 params
[0] = ENUM_TO_FLOAT(texUnit
->GenModeS
);
2207 else if (pname
==GL_OBJECT_PLANE
) {
2208 COPY_4V( params
, texUnit
->ObjectPlaneS
);
2210 else if (pname
==GL_EYE_PLANE
) {
2211 COPY_4V( params
, texUnit
->EyePlaneS
);
2214 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGenfv(pname)" );
2219 if (pname
==GL_TEXTURE_GEN_MODE
) {
2220 params
[0] = ENUM_TO_FLOAT(texUnit
->GenModeT
);
2222 else if (pname
==GL_OBJECT_PLANE
) {
2223 COPY_4V( params
, texUnit
->ObjectPlaneT
);
2225 else if (pname
==GL_EYE_PLANE
) {
2226 COPY_4V( params
, texUnit
->EyePlaneT
);
2229 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGenfv(pname)" );
2234 if (pname
==GL_TEXTURE_GEN_MODE
) {
2235 params
[0] = ENUM_TO_FLOAT(texUnit
->GenModeR
);
2237 else if (pname
==GL_OBJECT_PLANE
) {
2238 COPY_4V( params
, texUnit
->ObjectPlaneR
);
2240 else if (pname
==GL_EYE_PLANE
) {
2241 COPY_4V( params
, texUnit
->EyePlaneR
);
2244 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGenfv(pname)" );
2249 if (pname
==GL_TEXTURE_GEN_MODE
) {
2250 params
[0] = ENUM_TO_FLOAT(texUnit
->GenModeQ
);
2252 else if (pname
==GL_OBJECT_PLANE
) {
2253 COPY_4V( params
, texUnit
->ObjectPlaneQ
);
2255 else if (pname
==GL_EYE_PLANE
) {
2256 COPY_4V( params
, texUnit
->EyePlaneQ
);
2259 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGenfv(pname)" );
2264 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGenfv(coord)" );
2272 _mesa_GetTexGeniv( GLenum coord
, GLenum pname
, GLint
*params
)
2274 GET_CURRENT_CONTEXT(ctx
);
2275 GLuint tUnit
= ctx
->Texture
.CurrentUnit
;
2276 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[tUnit
];
2277 ASSERT_OUTSIDE_BEGIN_END(ctx
);
2281 if (pname
==GL_TEXTURE_GEN_MODE
) {
2282 params
[0] = texUnit
->GenModeS
;
2284 else if (pname
==GL_OBJECT_PLANE
) {
2285 params
[0] = (GLint
) texUnit
->ObjectPlaneS
[0];
2286 params
[1] = (GLint
) texUnit
->ObjectPlaneS
[1];
2287 params
[2] = (GLint
) texUnit
->ObjectPlaneS
[2];
2288 params
[3] = (GLint
) texUnit
->ObjectPlaneS
[3];
2290 else if (pname
==GL_EYE_PLANE
) {
2291 params
[0] = (GLint
) texUnit
->EyePlaneS
[0];
2292 params
[1] = (GLint
) texUnit
->EyePlaneS
[1];
2293 params
[2] = (GLint
) texUnit
->EyePlaneS
[2];
2294 params
[3] = (GLint
) texUnit
->EyePlaneS
[3];
2297 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGeniv(pname)" );
2302 if (pname
==GL_TEXTURE_GEN_MODE
) {
2303 params
[0] = texUnit
->GenModeT
;
2305 else if (pname
==GL_OBJECT_PLANE
) {
2306 params
[0] = (GLint
) texUnit
->ObjectPlaneT
[0];
2307 params
[1] = (GLint
) texUnit
->ObjectPlaneT
[1];
2308 params
[2] = (GLint
) texUnit
->ObjectPlaneT
[2];
2309 params
[3] = (GLint
) texUnit
->ObjectPlaneT
[3];
2311 else if (pname
==GL_EYE_PLANE
) {
2312 params
[0] = (GLint
) texUnit
->EyePlaneT
[0];
2313 params
[1] = (GLint
) texUnit
->EyePlaneT
[1];
2314 params
[2] = (GLint
) texUnit
->EyePlaneT
[2];
2315 params
[3] = (GLint
) texUnit
->EyePlaneT
[3];
2318 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGeniv(pname)" );
2323 if (pname
==GL_TEXTURE_GEN_MODE
) {
2324 params
[0] = texUnit
->GenModeR
;
2326 else if (pname
==GL_OBJECT_PLANE
) {
2327 params
[0] = (GLint
) texUnit
->ObjectPlaneR
[0];
2328 params
[1] = (GLint
) texUnit
->ObjectPlaneR
[1];
2329 params
[2] = (GLint
) texUnit
->ObjectPlaneR
[2];
2330 params
[3] = (GLint
) texUnit
->ObjectPlaneR
[3];
2332 else if (pname
==GL_EYE_PLANE
) {
2333 params
[0] = (GLint
) texUnit
->EyePlaneR
[0];
2334 params
[1] = (GLint
) texUnit
->EyePlaneR
[1];
2335 params
[2] = (GLint
) texUnit
->EyePlaneR
[2];
2336 params
[3] = (GLint
) texUnit
->EyePlaneR
[3];
2339 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGeniv(pname)" );
2344 if (pname
==GL_TEXTURE_GEN_MODE
) {
2345 params
[0] = texUnit
->GenModeQ
;
2347 else if (pname
==GL_OBJECT_PLANE
) {
2348 params
[0] = (GLint
) texUnit
->ObjectPlaneQ
[0];
2349 params
[1] = (GLint
) texUnit
->ObjectPlaneQ
[1];
2350 params
[2] = (GLint
) texUnit
->ObjectPlaneQ
[2];
2351 params
[3] = (GLint
) texUnit
->ObjectPlaneQ
[3];
2353 else if (pname
==GL_EYE_PLANE
) {
2354 params
[0] = (GLint
) texUnit
->EyePlaneQ
[0];
2355 params
[1] = (GLint
) texUnit
->EyePlaneQ
[1];
2356 params
[2] = (GLint
) texUnit
->EyePlaneQ
[2];
2357 params
[3] = (GLint
) texUnit
->EyePlaneQ
[3];
2360 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGeniv(pname)" );
2365 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGeniv(coord)" );
2371 /* GL_ARB_multitexture */
2373 _mesa_ActiveTextureARB( GLenum target
)
2375 GET_CURRENT_CONTEXT(ctx
);
2376 GLuint texUnit
= target
- GL_TEXTURE0_ARB
;
2377 ASSERT_OUTSIDE_BEGIN_END(ctx
);
2379 if (MESA_VERBOSE
& (VERBOSE_API
|VERBOSE_TEXTURE
))
2380 _mesa_debug(ctx
, "glActiveTexture %s\n",
2381 _mesa_lookup_enum_by_nr(target
));
2383 if (texUnit
> ctx
->Const
.MaxTextureUnits
) {
2384 _mesa_error(ctx
, GL_INVALID_ENUM
, "glActiveTextureARB(target)");
2388 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
2389 ctx
->Texture
.CurrentUnit
= texUnit
;
2390 if (ctx
->Driver
.ActiveTexture
) {
2391 (*ctx
->Driver
.ActiveTexture
)( ctx
, (GLuint
) texUnit
);
2396 /* GL_ARB_multitexture */
2398 _mesa_ClientActiveTextureARB( GLenum target
)
2400 GET_CURRENT_CONTEXT(ctx
);
2401 GLuint texUnit
= target
- GL_TEXTURE0_ARB
;
2402 ASSERT_OUTSIDE_BEGIN_END(ctx
);
2404 if (texUnit
> ctx
->Const
.MaxTextureUnits
) {
2405 _mesa_error(ctx
, GL_INVALID_ENUM
, "glClientActiveTextureARB(target)");
2409 FLUSH_VERTICES(ctx
, _NEW_ARRAY
);
2410 ctx
->Array
.ActiveTexture
= texUnit
;
2415 /**********************************************************************/
2416 /* Pixel Texgen Extensions */
2417 /**********************************************************************/
2420 _mesa_PixelTexGenSGIX(GLenum mode
)
2422 GLenum newRgbSource
, newAlphaSource
;
2423 GET_CURRENT_CONTEXT(ctx
);
2424 ASSERT_OUTSIDE_BEGIN_END(ctx
);
2428 newRgbSource
= GL_PIXEL_GROUP_COLOR_SGIS
;
2429 newAlphaSource
= GL_PIXEL_GROUP_COLOR_SGIS
;
2432 newRgbSource
= GL_PIXEL_GROUP_COLOR_SGIS
;
2433 newAlphaSource
= GL_CURRENT_RASTER_COLOR
;
2436 newRgbSource
= GL_CURRENT_RASTER_COLOR
;
2437 newAlphaSource
= GL_PIXEL_GROUP_COLOR_SGIS
;
2440 newRgbSource
= GL_CURRENT_RASTER_COLOR
;
2441 newAlphaSource
= GL_CURRENT_RASTER_COLOR
;
2444 _mesa_error(ctx
, GL_INVALID_ENUM
, "glPixelTexGenSGIX(mode)");
2448 if (newRgbSource
== ctx
->Pixel
.FragmentRgbSource
&&
2449 newAlphaSource
== ctx
->Pixel
.FragmentAlphaSource
)
2452 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
2453 ctx
->Pixel
.FragmentRgbSource
= newRgbSource
;
2454 ctx
->Pixel
.FragmentAlphaSource
= newAlphaSource
;
2459 _mesa_PixelTexGenParameterfSGIS(GLenum target
, GLfloat value
)
2461 _mesa_PixelTexGenParameteriSGIS(target
, (GLint
) value
);
2466 _mesa_PixelTexGenParameterfvSGIS(GLenum target
, const GLfloat
*value
)
2468 _mesa_PixelTexGenParameteriSGIS(target
, (GLint
) *value
);
2473 _mesa_PixelTexGenParameteriSGIS(GLenum target
, GLint value
)
2475 GET_CURRENT_CONTEXT(ctx
);
2476 ASSERT_OUTSIDE_BEGIN_END(ctx
);
2478 if (value
!= GL_CURRENT_RASTER_COLOR
&& value
!= GL_PIXEL_GROUP_COLOR_SGIS
) {
2479 _mesa_error(ctx
, GL_INVALID_ENUM
, "glPixelTexGenParameterSGIS(value)");
2484 case GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS
:
2485 if (ctx
->Pixel
.FragmentRgbSource
== (GLenum
) value
)
2487 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
2488 ctx
->Pixel
.FragmentRgbSource
= (GLenum
) value
;
2490 case GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS
:
2491 if (ctx
->Pixel
.FragmentAlphaSource
== (GLenum
) value
)
2493 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
2494 ctx
->Pixel
.FragmentAlphaSource
= (GLenum
) value
;
2497 _mesa_error(ctx
, GL_INVALID_ENUM
, "glPixelTexGenParameterSGIS(target)");
2504 _mesa_PixelTexGenParameterivSGIS(GLenum target
, const GLint
*value
)
2506 _mesa_PixelTexGenParameteriSGIS(target
, *value
);
2511 _mesa_GetPixelTexGenParameterfvSGIS(GLenum target
, GLfloat
*value
)
2513 GET_CURRENT_CONTEXT(ctx
);
2514 ASSERT_OUTSIDE_BEGIN_END(ctx
);
2516 if (target
== GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS
) {
2517 *value
= (GLfloat
) ctx
->Pixel
.FragmentRgbSource
;
2519 else if (target
== GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS
) {
2520 *value
= (GLfloat
) ctx
->Pixel
.FragmentAlphaSource
;
2523 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetPixelTexGenParameterfvSGIS(target)");
2529 _mesa_GetPixelTexGenParameterivSGIS(GLenum target
, GLint
*value
)
2531 GET_CURRENT_CONTEXT(ctx
);
2532 ASSERT_OUTSIDE_BEGIN_END(ctx
);
2534 if (target
== GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS
) {
2535 *value
= (GLint
) ctx
->Pixel
.FragmentRgbSource
;
2537 else if (target
== GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS
) {
2538 *value
= (GLint
) ctx
->Pixel
.FragmentAlphaSource
;
2541 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetPixelTexGenParameterivSGIS(target)");