2 * Mesa 3-D graphics library
5 * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 * Texture state handling.
40 #include "texenvprogram.h"
42 #include "math/m_xform.h"
46 #define ENUM_TO_FLOAT(X) ((GLfloat)(GLint)(X))
47 #define ENUM_TO_DOUBLE(X) ((GLdouble)(GLint)(X))
51 * Default texture combine environment state. This is used to initialize
52 * a context's texture units and as the basis for converting "classic"
53 * texture environmnets to ARB_texture_env_combine style values.
55 static const struct gl_tex_env_combine_state default_combine_state
= {
56 GL_MODULATE
, GL_MODULATE
,
57 { GL_TEXTURE
, GL_PREVIOUS
, GL_CONSTANT
},
58 { GL_TEXTURE
, GL_PREVIOUS
, GL_CONSTANT
},
59 { GL_SRC_COLOR
, GL_SRC_COLOR
, GL_SRC_ALPHA
},
60 { GL_SRC_ALPHA
, GL_SRC_ALPHA
, GL_SRC_ALPHA
},
67 _mesa_copy_texture_state( const GLcontext
*src
, GLcontext
*dst
)
74 dst
->Texture
.CurrentUnit
= src
->Texture
.CurrentUnit
;
75 dst
->Texture
._GenFlags
= src
->Texture
._GenFlags
;
76 dst
->Texture
._TexGenEnabled
= src
->Texture
._TexGenEnabled
;
77 dst
->Texture
._TexMatEnabled
= src
->Texture
._TexMatEnabled
;
78 dst
->Texture
.SharedPalette
= src
->Texture
.SharedPalette
;
81 for (i
= 0; i
< src
->Const
.MaxTextureUnits
; i
++) {
82 dst
->Texture
.Unit
[i
].Enabled
= src
->Texture
.Unit
[i
].Enabled
;
83 dst
->Texture
.Unit
[i
].EnvMode
= src
->Texture
.Unit
[i
].EnvMode
;
84 COPY_4V(dst
->Texture
.Unit
[i
].EnvColor
, src
->Texture
.Unit
[i
].EnvColor
);
85 dst
->Texture
.Unit
[i
].TexGenEnabled
= src
->Texture
.Unit
[i
].TexGenEnabled
;
86 dst
->Texture
.Unit
[i
].GenModeS
= src
->Texture
.Unit
[i
].GenModeS
;
87 dst
->Texture
.Unit
[i
].GenModeT
= src
->Texture
.Unit
[i
].GenModeT
;
88 dst
->Texture
.Unit
[i
].GenModeR
= src
->Texture
.Unit
[i
].GenModeR
;
89 dst
->Texture
.Unit
[i
].GenModeQ
= src
->Texture
.Unit
[i
].GenModeQ
;
90 dst
->Texture
.Unit
[i
]._GenBitS
= src
->Texture
.Unit
[i
]._GenBitS
;
91 dst
->Texture
.Unit
[i
]._GenBitT
= src
->Texture
.Unit
[i
]._GenBitT
;
92 dst
->Texture
.Unit
[i
]._GenBitR
= src
->Texture
.Unit
[i
]._GenBitR
;
93 dst
->Texture
.Unit
[i
]._GenBitQ
= src
->Texture
.Unit
[i
]._GenBitQ
;
94 dst
->Texture
.Unit
[i
]._GenFlags
= src
->Texture
.Unit
[i
]._GenFlags
;
95 COPY_4V(dst
->Texture
.Unit
[i
].ObjectPlaneS
, src
->Texture
.Unit
[i
].ObjectPlaneS
);
96 COPY_4V(dst
->Texture
.Unit
[i
].ObjectPlaneT
, src
->Texture
.Unit
[i
].ObjectPlaneT
);
97 COPY_4V(dst
->Texture
.Unit
[i
].ObjectPlaneR
, src
->Texture
.Unit
[i
].ObjectPlaneR
);
98 COPY_4V(dst
->Texture
.Unit
[i
].ObjectPlaneQ
, src
->Texture
.Unit
[i
].ObjectPlaneQ
);
99 COPY_4V(dst
->Texture
.Unit
[i
].EyePlaneS
, src
->Texture
.Unit
[i
].EyePlaneS
);
100 COPY_4V(dst
->Texture
.Unit
[i
].EyePlaneT
, src
->Texture
.Unit
[i
].EyePlaneT
);
101 COPY_4V(dst
->Texture
.Unit
[i
].EyePlaneR
, src
->Texture
.Unit
[i
].EyePlaneR
);
102 COPY_4V(dst
->Texture
.Unit
[i
].EyePlaneQ
, src
->Texture
.Unit
[i
].EyePlaneQ
);
103 dst
->Texture
.Unit
[i
].LodBias
= src
->Texture
.Unit
[i
].LodBias
;
105 /* GL_EXT_texture_env_combine */
106 dst
->Texture
.Unit
[i
].Combine
.ModeRGB
= src
->Texture
.Unit
[i
].Combine
.ModeRGB
;
107 dst
->Texture
.Unit
[i
].Combine
.ModeA
= src
->Texture
.Unit
[i
].Combine
.ModeA
;
108 COPY_3V(dst
->Texture
.Unit
[i
].Combine
.SourceRGB
, src
->Texture
.Unit
[i
].Combine
.SourceRGB
);
109 COPY_3V(dst
->Texture
.Unit
[i
].Combine
.SourceA
, src
->Texture
.Unit
[i
].Combine
.SourceA
);
110 COPY_3V(dst
->Texture
.Unit
[i
].Combine
.OperandRGB
, src
->Texture
.Unit
[i
].Combine
.OperandRGB
);
111 COPY_3V(dst
->Texture
.Unit
[i
].Combine
.OperandA
, src
->Texture
.Unit
[i
].Combine
.OperandA
);
112 dst
->Texture
.Unit
[i
].Combine
.ScaleShiftRGB
= src
->Texture
.Unit
[i
].Combine
.ScaleShiftRGB
;
113 dst
->Texture
.Unit
[i
].Combine
.ScaleShiftA
= src
->Texture
.Unit
[i
].Combine
.ScaleShiftA
;
115 /* texture object state */
116 _mesa_copy_texture_object(dst
->Texture
.Unit
[i
].Current1D
,
117 src
->Texture
.Unit
[i
].Current1D
);
118 _mesa_copy_texture_object(dst
->Texture
.Unit
[i
].Current2D
,
119 src
->Texture
.Unit
[i
].Current2D
);
120 _mesa_copy_texture_object(dst
->Texture
.Unit
[i
].Current3D
,
121 src
->Texture
.Unit
[i
].Current3D
);
122 _mesa_copy_texture_object(dst
->Texture
.Unit
[i
].CurrentCubeMap
,
123 src
->Texture
.Unit
[i
].CurrentCubeMap
);
124 _mesa_copy_texture_object(dst
->Texture
.Unit
[i
].CurrentRect
,
125 src
->Texture
.Unit
[i
].CurrentRect
);
134 _mesa_print_texunit_state( GLcontext
*ctx
, GLuint unit
)
136 const struct gl_texture_unit
*texUnit
= ctx
->Texture
.Unit
+ unit
;
137 _mesa_printf("Texture Unit %d\n", unit
);
138 _mesa_printf(" GL_TEXTURE_ENV_MODE = %s\n", _mesa_lookup_enum_by_nr(texUnit
->EnvMode
));
139 _mesa_printf(" GL_COMBINE_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit
->Combine
.ModeRGB
));
140 _mesa_printf(" GL_COMBINE_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit
->Combine
.ModeA
));
141 _mesa_printf(" GL_SOURCE0_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit
->Combine
.SourceRGB
[0]));
142 _mesa_printf(" GL_SOURCE1_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit
->Combine
.SourceRGB
[1]));
143 _mesa_printf(" GL_SOURCE2_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit
->Combine
.SourceRGB
[2]));
144 _mesa_printf(" GL_SOURCE0_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit
->Combine
.SourceA
[0]));
145 _mesa_printf(" GL_SOURCE1_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit
->Combine
.SourceA
[1]));
146 _mesa_printf(" GL_SOURCE2_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit
->Combine
.SourceA
[2]));
147 _mesa_printf(" GL_OPERAND0_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit
->Combine
.OperandRGB
[0]));
148 _mesa_printf(" GL_OPERAND1_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit
->Combine
.OperandRGB
[1]));
149 _mesa_printf(" GL_OPERAND2_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit
->Combine
.OperandRGB
[2]));
150 _mesa_printf(" GL_OPERAND0_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit
->Combine
.OperandA
[0]));
151 _mesa_printf(" GL_OPERAND1_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit
->Combine
.OperandA
[1]));
152 _mesa_printf(" GL_OPERAND2_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit
->Combine
.OperandA
[2]));
153 _mesa_printf(" GL_RGB_SCALE = %d\n", 1 << texUnit
->Combine
.ScaleShiftRGB
);
154 _mesa_printf(" GL_ALPHA_SCALE = %d\n", 1 << texUnit
->Combine
.ScaleShiftA
);
155 _mesa_printf(" GL_TEXTURE_ENV_COLOR = (%f, %f, %f, %f)\n", texUnit
->EnvColor
[0], texUnit
->EnvColor
[1], texUnit
->EnvColor
[2], texUnit
->EnvColor
[3]);
160 /**********************************************************************/
161 /* Texture Environment */
162 /**********************************************************************/
165 * Convert "classic" texture environment to ARB_texture_env_combine style
168 * \param state texture_env_combine state vector to be filled-in.
169 * \param mode Classic texture environment mode (i.e., \c GL_REPLACE,
170 * \c GL_BLEND, \c GL_DECAL, etc.).
171 * \param texBaseFormat Base format of the texture associated with the
175 calculate_derived_texenv( struct gl_tex_env_combine_state
*state
,
176 GLenum mode
, GLenum texBaseFormat
)
181 *state
= default_combine_state
;
183 switch (texBaseFormat
) {
185 state
->SourceRGB
[0] = GL_PREVIOUS
;
188 case GL_LUMINANCE_ALPHA
:
196 state
->SourceA
[0] = GL_PREVIOUS
;
200 _mesa_problem(NULL
, "Invalid texBaseFormat in calculate_derived_texenv");
207 mode_rgb
= (texBaseFormat
== GL_ALPHA
) ? GL_REPLACE
: mode
;
212 mode_rgb
= GL_INTERPOLATE
;
215 state
->SourceA
[0] = GL_PREVIOUS
;
217 /* Having alpha / luminance / intensity textures replace using the
218 * incoming fragment color matches the definition in NV_texture_shader.
219 * The 1.5 spec simply marks these as "undefined".
221 switch (texBaseFormat
) {
224 case GL_LUMINANCE_ALPHA
:
226 state
->SourceRGB
[0] = GL_PREVIOUS
;
230 mode_rgb
= GL_REPLACE
;
233 state
->SourceRGB
[2] = GL_TEXTURE
;
239 mode_rgb
= GL_INTERPOLATE
;
240 mode_a
= GL_MODULATE
;
242 switch (texBaseFormat
) {
244 mode_rgb
= GL_REPLACE
;
247 mode_a
= GL_INTERPOLATE
;
248 state
->SourceA
[0] = GL_CONSTANT
;
249 state
->OperandA
[2] = GL_SRC_ALPHA
;
253 case GL_LUMINANCE_ALPHA
:
256 state
->SourceRGB
[2] = GL_TEXTURE
;
257 state
->SourceA
[2] = GL_TEXTURE
;
258 state
->SourceRGB
[0] = GL_CONSTANT
;
259 state
->OperandRGB
[2] = GL_SRC_COLOR
;
265 mode_rgb
= (texBaseFormat
== GL_ALPHA
) ? GL_REPLACE
: GL_ADD
;
266 mode_a
= (texBaseFormat
== GL_INTENSITY
) ? GL_ADD
: GL_MODULATE
;
271 "Invalid texture env mode in calculate_derived_texenv");
275 state
->ModeRGB
= (state
->SourceRGB
[0] != GL_PREVIOUS
)
276 ? mode_rgb
: GL_REPLACE
;
277 state
->ModeA
= (state
->SourceA
[0] != GL_PREVIOUS
)
278 ? mode_a
: GL_REPLACE
;
283 _mesa_TexEnvfv( GLenum target
, GLenum pname
, const GLfloat
*param
)
285 GET_CURRENT_CONTEXT(ctx
);
286 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
287 ASSERT_OUTSIDE_BEGIN_END(ctx
);
289 #define TE_ERROR(errCode, msg, value) \
290 _mesa_error(ctx, errCode, msg, _mesa_lookup_enum_by_nr(value));
292 if (target
== GL_TEXTURE_ENV
) {
294 case GL_TEXTURE_ENV_MODE
:
296 const GLenum mode
= (GLenum
) (GLint
) *param
;
297 if (texUnit
->EnvMode
== mode
)
299 if (mode
== GL_MODULATE
||
302 mode
== GL_REPLACE
||
303 (mode
== GL_ADD
&& ctx
->Extensions
.EXT_texture_env_add
) ||
304 (mode
== GL_COMBINE
&&
305 (ctx
->Extensions
.EXT_texture_env_combine
||
306 ctx
->Extensions
.ARB_texture_env_combine
))) {
308 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
309 texUnit
->EnvMode
= mode
;
312 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", mode
);
317 case GL_TEXTURE_ENV_COLOR
:
320 tmp
[0] = CLAMP( param
[0], 0.0F
, 1.0F
);
321 tmp
[1] = CLAMP( param
[1], 0.0F
, 1.0F
);
322 tmp
[2] = CLAMP( param
[2], 0.0F
, 1.0F
);
323 tmp
[3] = CLAMP( param
[3], 0.0F
, 1.0F
);
324 if (TEST_EQ_4V(tmp
, texUnit
->EnvColor
))
326 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
327 COPY_4FV(texUnit
->EnvColor
, tmp
);
331 if (ctx
->Extensions
.EXT_texture_env_combine
||
332 ctx
->Extensions
.ARB_texture_env_combine
) {
333 const GLenum mode
= (GLenum
) (GLint
) *param
;
334 if (texUnit
->Combine
.ModeRGB
== mode
)
345 if (!ctx
->Extensions
.ARB_texture_env_combine
) {
346 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", mode
);
350 case GL_DOT3_RGB_EXT
:
351 case GL_DOT3_RGBA_EXT
:
352 if (!ctx
->Extensions
.EXT_texture_env_dot3
) {
353 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", mode
);
359 if (!ctx
->Extensions
.ARB_texture_env_dot3
) {
360 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", mode
);
364 case GL_MODULATE_ADD_ATI
:
365 case GL_MODULATE_SIGNED_ADD_ATI
:
366 case GL_MODULATE_SUBTRACT_ATI
:
367 if (!ctx
->Extensions
.ATI_texture_env_combine3
) {
368 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", mode
);
373 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", mode
);
376 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
377 texUnit
->Combine
.ModeRGB
= mode
;
380 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(pname=%s)", pname
);
384 case GL_COMBINE_ALPHA
:
385 if (ctx
->Extensions
.EXT_texture_env_combine
||
386 ctx
->Extensions
.ARB_texture_env_combine
) {
387 const GLenum mode
= (GLenum
) (GLint
) *param
;
388 if (texUnit
->Combine
.ModeA
== mode
)
399 if (!ctx
->Extensions
.ARB_texture_env_combine
) {
400 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", mode
);
404 case GL_MODULATE_ADD_ATI
:
405 case GL_MODULATE_SIGNED_ADD_ATI
:
406 case GL_MODULATE_SUBTRACT_ATI
:
407 if (!ctx
->Extensions
.ATI_texture_env_combine3
) {
408 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", mode
);
413 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", mode
);
416 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
417 texUnit
->Combine
.ModeA
= mode
;
420 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(pname=%s)", pname
);
427 if (ctx
->Extensions
.EXT_texture_env_combine
||
428 ctx
->Extensions
.ARB_texture_env_combine
) {
429 const GLenum source
= (GLenum
) (GLint
) *param
;
430 const GLuint s
= pname
- GL_SOURCE0_RGB
;
431 if (texUnit
->Combine
.SourceRGB
[s
] == source
)
433 if (source
== GL_TEXTURE
||
434 source
== GL_CONSTANT
||
435 source
== GL_PRIMARY_COLOR
||
436 source
== GL_PREVIOUS
||
437 (ctx
->Extensions
.ARB_texture_env_crossbar
&&
438 source
>= GL_TEXTURE0
&&
439 source
< GL_TEXTURE0
+ ctx
->Const
.MaxTextureUnits
) ||
440 (ctx
->Extensions
.ATI_texture_env_combine3
&&
441 (source
== GL_ZERO
|| source
== GL_ONE
))) {
443 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
444 texUnit
->Combine
.SourceRGB
[s
] = source
;
447 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", source
);
452 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(pname=%s)", pname
);
456 case GL_SOURCE0_ALPHA
:
457 case GL_SOURCE1_ALPHA
:
458 case GL_SOURCE2_ALPHA
:
459 if (ctx
->Extensions
.EXT_texture_env_combine
||
460 ctx
->Extensions
.ARB_texture_env_combine
) {
461 const GLenum source
= (GLenum
) (GLint
) *param
;
462 const GLuint s
= pname
- GL_SOURCE0_ALPHA
;
463 if (texUnit
->Combine
.SourceA
[s
] == source
)
465 if (source
== GL_TEXTURE
||
466 source
== GL_CONSTANT
||
467 source
== GL_PRIMARY_COLOR
||
468 source
== GL_PREVIOUS
||
469 (ctx
->Extensions
.ARB_texture_env_crossbar
&&
470 source
>= GL_TEXTURE0
&&
471 source
< GL_TEXTURE0
+ ctx
->Const
.MaxTextureUnits
) ||
472 (ctx
->Extensions
.ATI_texture_env_combine3
&&
473 (source
== GL_ZERO
|| source
== GL_ONE
))) {
475 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
476 texUnit
->Combine
.SourceA
[s
] = source
;
479 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", source
);
484 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(pname=%s)", pname
);
488 case GL_OPERAND0_RGB
:
489 case GL_OPERAND1_RGB
:
490 if (ctx
->Extensions
.EXT_texture_env_combine
||
491 ctx
->Extensions
.ARB_texture_env_combine
) {
492 const GLenum operand
= (GLenum
) (GLint
) *param
;
493 const GLuint s
= pname
- GL_OPERAND0_RGB
;
494 if (texUnit
->Combine
.OperandRGB
[s
] == operand
)
498 case GL_ONE_MINUS_SRC_COLOR
:
500 case GL_ONE_MINUS_SRC_ALPHA
:
501 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
502 texUnit
->Combine
.OperandRGB
[s
] = operand
;
505 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", operand
);
510 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(pname=%s)", pname
);
514 case GL_OPERAND0_ALPHA
:
515 case GL_OPERAND1_ALPHA
:
516 if (ctx
->Extensions
.EXT_texture_env_combine
||
517 ctx
->Extensions
.ARB_texture_env_combine
) {
518 const GLenum operand
= (GLenum
) (GLint
) *param
;
519 if (texUnit
->Combine
.OperandA
[pname
-GL_OPERAND0_ALPHA
] == operand
)
523 case GL_ONE_MINUS_SRC_ALPHA
:
524 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
525 texUnit
->Combine
.OperandA
[pname
-GL_OPERAND0_ALPHA
] = operand
;
528 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", operand
);
533 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(pname=%s)", pname
);
537 case GL_OPERAND2_RGB
:
538 if (ctx
->Extensions
.ARB_texture_env_combine
) {
539 const GLenum operand
= (GLenum
) (GLint
) *param
;
540 if (texUnit
->Combine
.OperandRGB
[2] == operand
)
543 case GL_SRC_COLOR
: /* ARB combine only */
544 case GL_ONE_MINUS_SRC_COLOR
: /* ARB combine only */
546 case GL_ONE_MINUS_SRC_ALPHA
: /* ARB combine only */
547 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
548 texUnit
->Combine
.OperandRGB
[2] = operand
;
551 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", operand
);
555 else if (ctx
->Extensions
.EXT_texture_env_combine
) {
556 const GLenum operand
= (GLenum
) (GLint
) *param
;
557 if (texUnit
->Combine
.OperandRGB
[2] == operand
)
559 /* operand must be GL_SRC_ALPHA which is the initial value - thus
560 don't need to actually compare the operand to the possible value */
562 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", operand
);
567 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(pname=%s)", pname
);
571 case GL_OPERAND2_ALPHA
:
572 if (ctx
->Extensions
.ARB_texture_env_combine
) {
573 const GLenum operand
= (GLenum
) (GLint
) *param
;
574 if (texUnit
->Combine
.OperandA
[2] == operand
)
578 case GL_ONE_MINUS_SRC_ALPHA
: /* ARB combine only */
579 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
580 texUnit
->Combine
.OperandA
[2] = operand
;
583 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", operand
);
587 else if (ctx
->Extensions
.EXT_texture_env_combine
) {
588 const GLenum operand
= (GLenum
) (GLint
) *param
;
589 if (texUnit
->Combine
.OperandA
[2] == operand
)
591 /* operand must be GL_SRC_ALPHA which is the initial value - thus
592 don't need to actually compare the operand to the possible value */
594 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(param=%s)", operand
);
599 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(pname=%s)", pname
);
604 if (ctx
->Extensions
.EXT_texture_env_combine
||
605 ctx
->Extensions
.ARB_texture_env_combine
) {
610 else if (*param
== 2.0) {
613 else if (*param
== 4.0) {
617 _mesa_error( ctx
, GL_INVALID_VALUE
,
618 "glTexEnv(GL_RGB_SCALE not 1, 2 or 4)" );
621 if (texUnit
->Combine
.ScaleShiftRGB
== newshift
)
623 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
624 texUnit
->Combine
.ScaleShiftRGB
= newshift
;
627 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(pname=%s)", pname
);
632 if (ctx
->Extensions
.EXT_texture_env_combine
||
633 ctx
->Extensions
.ARB_texture_env_combine
) {
638 else if (*param
== 2.0) {
641 else if (*param
== 4.0) {
645 _mesa_error( ctx
, GL_INVALID_VALUE
,
646 "glTexEnv(GL_ALPHA_SCALE not 1, 2 or 4)" );
649 if (texUnit
->Combine
.ScaleShiftA
== newshift
)
651 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
652 texUnit
->Combine
.ScaleShiftA
= newshift
;
655 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(pname=%s)", pname
);
660 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexEnv(pname)" );
664 else if (target
== GL_TEXTURE_FILTER_CONTROL_EXT
) {
665 /* GL_EXT_texture_lod_bias */
666 if (!ctx
->Extensions
.EXT_texture_lod_bias
) {
667 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexEnv(target=0x%x)", target
);
670 if (pname
== GL_TEXTURE_LOD_BIAS_EXT
) {
671 if (texUnit
->LodBias
== param
[0])
673 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
674 texUnit
->LodBias
= param
[0];
677 TE_ERROR(GL_INVALID_ENUM
, "glTexEnv(pname=%s)", pname
);
681 else if (target
== GL_POINT_SPRITE_NV
) {
682 /* GL_ARB_point_sprite / GL_NV_point_sprite */
683 if (!ctx
->Extensions
.NV_point_sprite
684 && !ctx
->Extensions
.ARB_point_sprite
) {
685 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexEnv(target=0x%x)", target
);
688 if (pname
== GL_COORD_REPLACE_NV
) {
689 const GLenum value
= (GLenum
) param
[0];
690 if (value
== GL_TRUE
|| value
== GL_FALSE
) {
691 /* It's kind of weird to set point state via glTexEnv,
692 * but that's what the spec calls for.
694 const GLboolean state
= (GLboolean
) value
;
695 if (ctx
->Point
.CoordReplace
[ctx
->Texture
.CurrentUnit
] == state
)
697 FLUSH_VERTICES(ctx
, _NEW_POINT
);
698 ctx
->Point
.CoordReplace
[ctx
->Texture
.CurrentUnit
] = state
;
701 _mesa_error( ctx
, GL_INVALID_VALUE
, "glTexEnv(param=0x%x)", value
);
706 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexEnv(pname=0x%x)", pname
);
711 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexEnv(target=0x%x)",target
);
715 if (MESA_VERBOSE
&(VERBOSE_API
|VERBOSE_TEXTURE
))
716 _mesa_debug(ctx
, "glTexEnv %s %s %.1f(%s) ...\n",
717 _mesa_lookup_enum_by_nr(target
),
718 _mesa_lookup_enum_by_nr(pname
),
720 _mesa_lookup_enum_by_nr((GLenum
) (GLint
) *param
));
722 /* Tell device driver about the new texture environment */
723 if (ctx
->Driver
.TexEnv
) {
724 (*ctx
->Driver
.TexEnv
)( ctx
, target
, pname
, param
);
730 _mesa_TexEnvf( GLenum target
, GLenum pname
, GLfloat param
)
732 _mesa_TexEnvfv( target
, pname
, ¶m
);
738 _mesa_TexEnvi( GLenum target
, GLenum pname
, GLint param
)
741 p
[0] = (GLfloat
) param
;
742 p
[1] = p
[2] = p
[3] = 0.0;
743 _mesa_TexEnvfv( target
, pname
, p
);
748 _mesa_TexEnviv( GLenum target
, GLenum pname
, const GLint
*param
)
751 if (pname
== GL_TEXTURE_ENV_COLOR
) {
752 p
[0] = INT_TO_FLOAT( param
[0] );
753 p
[1] = INT_TO_FLOAT( param
[1] );
754 p
[2] = INT_TO_FLOAT( param
[2] );
755 p
[3] = INT_TO_FLOAT( param
[3] );
758 p
[0] = (GLfloat
) param
[0];
759 p
[1] = p
[2] = p
[3] = 0; /* init to zero, just to be safe */
761 _mesa_TexEnvfv( target
, pname
, p
);
766 _mesa_GetTexEnvfv( GLenum target
, GLenum pname
, GLfloat
*params
)
768 GET_CURRENT_CONTEXT(ctx
);
769 const struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
770 ASSERT_OUTSIDE_BEGIN_END(ctx
);
772 if (target
== GL_TEXTURE_ENV
) {
774 case GL_TEXTURE_ENV_MODE
:
775 *params
= ENUM_TO_FLOAT(texUnit
->EnvMode
);
777 case GL_TEXTURE_ENV_COLOR
:
778 COPY_4FV( params
, texUnit
->EnvColor
);
781 if (ctx
->Extensions
.EXT_texture_env_combine
||
782 ctx
->Extensions
.ARB_texture_env_combine
) {
783 *params
= (GLfloat
) texUnit
->Combine
.ModeRGB
;
786 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
789 case GL_COMBINE_ALPHA
:
790 if (ctx
->Extensions
.EXT_texture_env_combine
||
791 ctx
->Extensions
.ARB_texture_env_combine
) {
792 *params
= (GLfloat
) texUnit
->Combine
.ModeA
;
795 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
799 if (ctx
->Extensions
.EXT_texture_env_combine
||
800 ctx
->Extensions
.ARB_texture_env_combine
) {
801 *params
= (GLfloat
) texUnit
->Combine
.SourceRGB
[0];
804 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
808 if (ctx
->Extensions
.EXT_texture_env_combine
||
809 ctx
->Extensions
.ARB_texture_env_combine
) {
810 *params
= (GLfloat
) texUnit
->Combine
.SourceRGB
[1];
813 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
817 if (ctx
->Extensions
.EXT_texture_env_combine
||
818 ctx
->Extensions
.ARB_texture_env_combine
) {
819 *params
= (GLfloat
) texUnit
->Combine
.SourceRGB
[2];
822 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
825 case GL_SOURCE0_ALPHA
:
826 if (ctx
->Extensions
.EXT_texture_env_combine
||
827 ctx
->Extensions
.ARB_texture_env_combine
) {
828 *params
= (GLfloat
) texUnit
->Combine
.SourceA
[0];
831 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
834 case GL_SOURCE1_ALPHA
:
835 if (ctx
->Extensions
.EXT_texture_env_combine
||
836 ctx
->Extensions
.ARB_texture_env_combine
) {
837 *params
= (GLfloat
) texUnit
->Combine
.SourceA
[1];
840 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
843 case GL_SOURCE2_ALPHA
:
844 if (ctx
->Extensions
.EXT_texture_env_combine
||
845 ctx
->Extensions
.ARB_texture_env_combine
) {
846 *params
= (GLfloat
) texUnit
->Combine
.SourceA
[2];
849 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
852 case GL_OPERAND0_RGB
:
853 if (ctx
->Extensions
.EXT_texture_env_combine
||
854 ctx
->Extensions
.ARB_texture_env_combine
) {
855 *params
= (GLfloat
) texUnit
->Combine
.OperandRGB
[0];
858 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
861 case GL_OPERAND1_RGB
:
862 if (ctx
->Extensions
.EXT_texture_env_combine
||
863 ctx
->Extensions
.ARB_texture_env_combine
) {
864 *params
= (GLfloat
) texUnit
->Combine
.OperandRGB
[1];
867 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
870 case GL_OPERAND2_RGB
:
871 if (ctx
->Extensions
.EXT_texture_env_combine
||
872 ctx
->Extensions
.ARB_texture_env_combine
) {
873 *params
= (GLfloat
) texUnit
->Combine
.OperandRGB
[2];
876 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
879 case GL_OPERAND0_ALPHA
:
880 if (ctx
->Extensions
.EXT_texture_env_combine
||
881 ctx
->Extensions
.ARB_texture_env_combine
) {
882 *params
= (GLfloat
) texUnit
->Combine
.OperandA
[0];
885 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
888 case GL_OPERAND1_ALPHA
:
889 if (ctx
->Extensions
.EXT_texture_env_combine
||
890 ctx
->Extensions
.ARB_texture_env_combine
) {
891 *params
= (GLfloat
) texUnit
->Combine
.OperandA
[1];
894 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
897 case GL_OPERAND2_ALPHA
:
898 if (ctx
->Extensions
.EXT_texture_env_combine
||
899 ctx
->Extensions
.ARB_texture_env_combine
) {
900 *params
= (GLfloat
) texUnit
->Combine
.OperandA
[2];
903 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
907 if (ctx
->Extensions
.EXT_texture_env_combine
||
908 ctx
->Extensions
.ARB_texture_env_combine
) {
909 if (texUnit
->Combine
.ScaleShiftRGB
== 0)
911 else if (texUnit
->Combine
.ScaleShiftRGB
== 1)
917 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
922 if (ctx
->Extensions
.EXT_texture_env_combine
||
923 ctx
->Extensions
.ARB_texture_env_combine
) {
924 if (texUnit
->Combine
.ScaleShiftA
== 0)
926 else if (texUnit
->Combine
.ScaleShiftA
== 1)
932 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)");
937 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname=0x%x)", pname
);
940 else if (target
== GL_TEXTURE_FILTER_CONTROL_EXT
) {
941 /* GL_EXT_texture_lod_bias */
942 if (!ctx
->Extensions
.EXT_texture_lod_bias
) {
943 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(target)" );
946 if (pname
== GL_TEXTURE_LOD_BIAS_EXT
) {
947 *params
= texUnit
->LodBias
;
950 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)" );
954 else if (target
== GL_POINT_SPRITE_NV
) {
955 /* GL_ARB_point_sprite / GL_NV_point_sprite */
956 if (!ctx
->Extensions
.NV_point_sprite
957 && !ctx
->Extensions
.ARB_point_sprite
) {
958 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(target)" );
961 if (pname
== GL_COORD_REPLACE_NV
) {
962 *params
= (GLfloat
) ctx
->Point
.CoordReplace
[ctx
->Texture
.CurrentUnit
];
965 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(pname)" );
970 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexEnvfv(target)" );
977 _mesa_GetTexEnviv( GLenum target
, GLenum pname
, GLint
*params
)
979 GET_CURRENT_CONTEXT(ctx
);
980 const struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
981 ASSERT_OUTSIDE_BEGIN_END(ctx
);
983 if (target
== GL_TEXTURE_ENV
) {
985 case GL_TEXTURE_ENV_MODE
:
986 *params
= (GLint
) texUnit
->EnvMode
;
988 case GL_TEXTURE_ENV_COLOR
:
989 params
[0] = FLOAT_TO_INT( texUnit
->EnvColor
[0] );
990 params
[1] = FLOAT_TO_INT( texUnit
->EnvColor
[1] );
991 params
[2] = FLOAT_TO_INT( texUnit
->EnvColor
[2] );
992 params
[3] = FLOAT_TO_INT( texUnit
->EnvColor
[3] );
995 if (ctx
->Extensions
.EXT_texture_env_combine
||
996 ctx
->Extensions
.ARB_texture_env_combine
) {
997 *params
= (GLint
) texUnit
->Combine
.ModeRGB
;
1000 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
1003 case GL_COMBINE_ALPHA
:
1004 if (ctx
->Extensions
.EXT_texture_env_combine
||
1005 ctx
->Extensions
.ARB_texture_env_combine
) {
1006 *params
= (GLint
) texUnit
->Combine
.ModeA
;
1009 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
1012 case GL_SOURCE0_RGB
:
1013 if (ctx
->Extensions
.EXT_texture_env_combine
||
1014 ctx
->Extensions
.ARB_texture_env_combine
) {
1015 *params
= (GLint
) texUnit
->Combine
.SourceRGB
[0];
1018 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
1021 case GL_SOURCE1_RGB
:
1022 if (ctx
->Extensions
.EXT_texture_env_combine
||
1023 ctx
->Extensions
.ARB_texture_env_combine
) {
1024 *params
= (GLint
) texUnit
->Combine
.SourceRGB
[1];
1027 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
1030 case GL_SOURCE2_RGB
:
1031 if (ctx
->Extensions
.EXT_texture_env_combine
||
1032 ctx
->Extensions
.ARB_texture_env_combine
) {
1033 *params
= (GLint
) texUnit
->Combine
.SourceRGB
[2];
1036 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
1039 case GL_SOURCE0_ALPHA
:
1040 if (ctx
->Extensions
.EXT_texture_env_combine
||
1041 ctx
->Extensions
.ARB_texture_env_combine
) {
1042 *params
= (GLint
) texUnit
->Combine
.SourceA
[0];
1045 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
1048 case GL_SOURCE1_ALPHA
:
1049 if (ctx
->Extensions
.EXT_texture_env_combine
||
1050 ctx
->Extensions
.ARB_texture_env_combine
) {
1051 *params
= (GLint
) texUnit
->Combine
.SourceA
[1];
1054 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
1057 case GL_SOURCE2_ALPHA
:
1058 if (ctx
->Extensions
.EXT_texture_env_combine
||
1059 ctx
->Extensions
.ARB_texture_env_combine
) {
1060 *params
= (GLint
) texUnit
->Combine
.SourceA
[2];
1063 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
1066 case GL_OPERAND0_RGB
:
1067 if (ctx
->Extensions
.EXT_texture_env_combine
||
1068 ctx
->Extensions
.ARB_texture_env_combine
) {
1069 *params
= (GLint
) texUnit
->Combine
.OperandRGB
[0];
1072 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
1075 case GL_OPERAND1_RGB
:
1076 if (ctx
->Extensions
.EXT_texture_env_combine
||
1077 ctx
->Extensions
.ARB_texture_env_combine
) {
1078 *params
= (GLint
) texUnit
->Combine
.OperandRGB
[1];
1081 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
1084 case GL_OPERAND2_RGB
:
1085 if (ctx
->Extensions
.EXT_texture_env_combine
||
1086 ctx
->Extensions
.ARB_texture_env_combine
) {
1087 *params
= (GLint
) texUnit
->Combine
.OperandRGB
[2];
1090 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
1093 case GL_OPERAND0_ALPHA
:
1094 if (ctx
->Extensions
.EXT_texture_env_combine
||
1095 ctx
->Extensions
.ARB_texture_env_combine
) {
1096 *params
= (GLint
) texUnit
->Combine
.OperandA
[0];
1099 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
1102 case GL_OPERAND1_ALPHA
:
1103 if (ctx
->Extensions
.EXT_texture_env_combine
||
1104 ctx
->Extensions
.ARB_texture_env_combine
) {
1105 *params
= (GLint
) texUnit
->Combine
.OperandA
[1];
1108 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
1111 case GL_OPERAND2_ALPHA
:
1112 if (ctx
->Extensions
.EXT_texture_env_combine
||
1113 ctx
->Extensions
.ARB_texture_env_combine
) {
1114 *params
= (GLint
) texUnit
->Combine
.OperandA
[2];
1117 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
1121 if (ctx
->Extensions
.EXT_texture_env_combine
||
1122 ctx
->Extensions
.ARB_texture_env_combine
) {
1123 if (texUnit
->Combine
.ScaleShiftRGB
== 0)
1125 else if (texUnit
->Combine
.ScaleShiftRGB
== 1)
1131 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
1135 case GL_ALPHA_SCALE
:
1136 if (ctx
->Extensions
.EXT_texture_env_combine
||
1137 ctx
->Extensions
.ARB_texture_env_combine
) {
1138 if (texUnit
->Combine
.ScaleShiftA
== 0)
1140 else if (texUnit
->Combine
.ScaleShiftA
== 1)
1146 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)");
1151 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname=0x%x)",
1155 else if (target
== GL_TEXTURE_FILTER_CONTROL_EXT
) {
1156 /* GL_EXT_texture_lod_bias */
1157 if (!ctx
->Extensions
.EXT_texture_lod_bias
) {
1158 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(target)" );
1161 if (pname
== GL_TEXTURE_LOD_BIAS_EXT
) {
1162 *params
= (GLint
) texUnit
->LodBias
;
1165 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)" );
1169 else if (target
== GL_POINT_SPRITE_NV
) {
1170 /* GL_ARB_point_sprite / GL_NV_point_sprite */
1171 if (!ctx
->Extensions
.NV_point_sprite
1172 && !ctx
->Extensions
.ARB_point_sprite
) {
1173 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(target)" );
1176 if (pname
== GL_COORD_REPLACE_NV
) {
1177 *params
= (GLint
) ctx
->Point
.CoordReplace
[ctx
->Texture
.CurrentUnit
];
1180 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(pname)" );
1185 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexEnviv(target)" );
1193 /**********************************************************************/
1194 /* Texture Parameters */
1195 /**********************************************************************/
1198 _mesa_validate_texture_wrap_mode(GLcontext
* ctx
,
1199 GLenum target
, GLenum eparam
)
1201 const struct gl_extensions
* const e
= & ctx
->Extensions
;
1203 if (eparam
== GL_CLAMP
|| eparam
== GL_CLAMP_TO_EDGE
||
1204 (eparam
== GL_CLAMP_TO_BORDER
&& e
->ARB_texture_border_clamp
)) {
1205 /* any texture target */
1208 else if (target
!= GL_TEXTURE_RECTANGLE_NV
&&
1209 (eparam
== GL_REPEAT
||
1210 (eparam
== GL_MIRRORED_REPEAT
&&
1211 e
->ARB_texture_mirrored_repeat
) ||
1212 (eparam
== GL_MIRROR_CLAMP_EXT
&&
1213 (e
->ATI_texture_mirror_once
|| e
->EXT_texture_mirror_clamp
)) ||
1214 (eparam
== GL_MIRROR_CLAMP_TO_EDGE_EXT
&&
1215 (e
->ATI_texture_mirror_once
|| e
->EXT_texture_mirror_clamp
)) ||
1216 (eparam
== GL_MIRROR_CLAMP_TO_BORDER_EXT
&&
1217 (e
->EXT_texture_mirror_clamp
)))) {
1218 /* non-rectangle texture */
1222 _mesa_error( ctx
, GL_INVALID_VALUE
, "glTexParameter(param)" );
1228 _mesa_TexParameterf( GLenum target
, GLenum pname
, GLfloat param
)
1230 _mesa_TexParameterfv(target
, pname
, ¶m
);
1235 _mesa_TexParameterfv( GLenum target
, GLenum pname
, const GLfloat
*params
)
1237 GET_CURRENT_CONTEXT(ctx
);
1238 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1239 GLenum eparam
= (GLenum
) (GLint
) params
[0];
1240 struct gl_texture_object
*texObj
;
1241 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1243 if (MESA_VERBOSE
&(VERBOSE_API
|VERBOSE_TEXTURE
))
1244 _mesa_debug(ctx
, "glTexParameter %s %s %.1f(%s)...\n",
1245 _mesa_lookup_enum_by_nr(target
),
1246 _mesa_lookup_enum_by_nr(pname
),
1248 _mesa_lookup_enum_by_nr(eparam
));
1253 texObj
= texUnit
->Current1D
;
1256 texObj
= texUnit
->Current2D
;
1259 texObj
= texUnit
->Current3D
;
1261 case GL_TEXTURE_CUBE_MAP
:
1262 if (!ctx
->Extensions
.ARB_texture_cube_map
) {
1263 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexParameter(target)" );
1266 texObj
= texUnit
->CurrentCubeMap
;
1268 case GL_TEXTURE_RECTANGLE_NV
:
1269 if (!ctx
->Extensions
.NV_texture_rectangle
) {
1270 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexParameter(target)" );
1273 texObj
= texUnit
->CurrentRect
;
1276 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexParameter(target)" );
1281 case GL_TEXTURE_MIN_FILTER
:
1282 /* A small optimization */
1283 if (texObj
->MinFilter
== eparam
)
1285 if (eparam
==GL_NEAREST
|| eparam
==GL_LINEAR
) {
1286 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1287 texObj
->MinFilter
= eparam
;
1289 else if ((eparam
==GL_NEAREST_MIPMAP_NEAREST
||
1290 eparam
==GL_LINEAR_MIPMAP_NEAREST
||
1291 eparam
==GL_NEAREST_MIPMAP_LINEAR
||
1292 eparam
==GL_LINEAR_MIPMAP_LINEAR
) &&
1293 texObj
->Target
!= GL_TEXTURE_RECTANGLE_NV
) {
1294 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1295 texObj
->MinFilter
= eparam
;
1298 _mesa_error( ctx
, GL_INVALID_VALUE
, "glTexParameter(param)" );
1302 case GL_TEXTURE_MAG_FILTER
:
1303 /* A small optimization */
1304 if (texObj
->MagFilter
== eparam
)
1307 if (eparam
==GL_NEAREST
|| eparam
==GL_LINEAR
) {
1308 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1309 texObj
->MagFilter
= eparam
;
1312 _mesa_error( ctx
, GL_INVALID_VALUE
, "glTexParameter(param)" );
1316 case GL_TEXTURE_WRAP_S
:
1317 if (texObj
->WrapS
== eparam
)
1319 if (_mesa_validate_texture_wrap_mode(ctx
, texObj
->Target
, eparam
)) {
1320 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1321 texObj
->WrapS
= eparam
;
1327 case GL_TEXTURE_WRAP_T
:
1328 if (texObj
->WrapT
== eparam
)
1330 if (_mesa_validate_texture_wrap_mode(ctx
, texObj
->Target
, eparam
)) {
1331 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1332 texObj
->WrapT
= eparam
;
1338 case GL_TEXTURE_WRAP_R
:
1339 if (texObj
->WrapR
== eparam
)
1341 if (_mesa_validate_texture_wrap_mode(ctx
, texObj
->Target
, eparam
)) {
1342 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1343 texObj
->WrapR
= eparam
;
1349 case GL_TEXTURE_BORDER_COLOR
:
1350 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1351 texObj
->BorderColor
[RCOMP
] = params
[0];
1352 texObj
->BorderColor
[GCOMP
] = params
[1];
1353 texObj
->BorderColor
[BCOMP
] = params
[2];
1354 texObj
->BorderColor
[ACOMP
] = params
[3];
1355 UNCLAMPED_FLOAT_TO_CHAN(texObj
->_BorderChan
[RCOMP
], params
[0]);
1356 UNCLAMPED_FLOAT_TO_CHAN(texObj
->_BorderChan
[GCOMP
], params
[1]);
1357 UNCLAMPED_FLOAT_TO_CHAN(texObj
->_BorderChan
[BCOMP
], params
[2]);
1358 UNCLAMPED_FLOAT_TO_CHAN(texObj
->_BorderChan
[ACOMP
], params
[3]);
1360 case GL_TEXTURE_MIN_LOD
:
1361 if (texObj
->MinLod
== params
[0])
1363 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1364 texObj
->MinLod
= params
[0];
1366 case GL_TEXTURE_MAX_LOD
:
1367 if (texObj
->MaxLod
== params
[0])
1369 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1370 texObj
->MaxLod
= params
[0];
1372 case GL_TEXTURE_BASE_LEVEL
:
1373 if (params
[0] < 0.0) {
1374 _mesa_error(ctx
, GL_INVALID_VALUE
, "glTexParameter(param)" );
1377 if (target
== GL_TEXTURE_RECTANGLE_NV
&& params
[0] != 0.0) {
1378 _mesa_error(ctx
, GL_INVALID_VALUE
, "glTexParameter(param)" );
1381 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1382 texObj
->BaseLevel
= (GLint
) params
[0];
1384 case GL_TEXTURE_MAX_LEVEL
:
1385 if (params
[0] < 0.0) {
1386 _mesa_error(ctx
, GL_INVALID_VALUE
, "glTexParameter(param)" );
1389 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1390 texObj
->MaxLevel
= (GLint
) params
[0];
1392 case GL_TEXTURE_PRIORITY
:
1393 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1394 texObj
->Priority
= CLAMP( params
[0], 0.0F
, 1.0F
);
1396 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1397 if (ctx
->Extensions
.EXT_texture_filter_anisotropic
) {
1398 if (params
[0] < 1.0) {
1399 _mesa_error(ctx
, GL_INVALID_VALUE
, "glTexParameter(param)" );
1402 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1403 /* clamp to max, that's what NVIDIA does */
1404 texObj
->MaxAnisotropy
= MIN2(params
[0],
1405 ctx
->Const
.MaxTextureMaxAnisotropy
);
1408 _mesa_error(ctx
, GL_INVALID_ENUM
,
1409 "glTexParameter(pname=GL_TEXTURE_MAX_ANISOTROPY_EXT)");
1413 case GL_TEXTURE_COMPARE_SGIX
:
1414 if (ctx
->Extensions
.SGIX_shadow
) {
1415 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1416 texObj
->CompareFlag
= params
[0] ? GL_TRUE
: GL_FALSE
;
1419 _mesa_error(ctx
, GL_INVALID_ENUM
,
1420 "glTexParameter(pname=GL_TEXTURE_COMPARE_SGIX)");
1424 case GL_TEXTURE_COMPARE_OPERATOR_SGIX
:
1425 if (ctx
->Extensions
.SGIX_shadow
) {
1426 GLenum op
= (GLenum
) params
[0];
1427 if (op
== GL_TEXTURE_LEQUAL_R_SGIX
||
1428 op
== GL_TEXTURE_GEQUAL_R_SGIX
) {
1429 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1430 texObj
->CompareOperator
= op
;
1433 _mesa_error(ctx
, GL_INVALID_ENUM
, "glTexParameter(param)");
1437 _mesa_error(ctx
, GL_INVALID_ENUM
,
1438 "glTexParameter(pname=GL_TEXTURE_COMPARE_OPERATOR_SGIX)");
1442 case GL_SHADOW_AMBIENT_SGIX
: /* aka GL_TEXTURE_COMPARE_FAIL_VALUE_ARB */
1443 if (ctx
->Extensions
.SGIX_shadow_ambient
) {
1444 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1445 texObj
->ShadowAmbient
= CLAMP(params
[0], 0.0F
, 1.0F
);
1448 _mesa_error(ctx
, GL_INVALID_ENUM
,
1449 "glTexParameter(pname=GL_SHADOW_AMBIENT_SGIX)");
1453 case GL_GENERATE_MIPMAP_SGIS
:
1454 if (ctx
->Extensions
.SGIS_generate_mipmap
) {
1455 texObj
->GenerateMipmap
= params
[0] ? GL_TRUE
: GL_FALSE
;
1458 _mesa_error(ctx
, GL_INVALID_ENUM
,
1459 "glTexParameter(pname=GL_GENERATE_MIPMAP_SGIS)");
1463 case GL_TEXTURE_COMPARE_MODE_ARB
:
1464 if (ctx
->Extensions
.ARB_shadow
) {
1465 const GLenum mode
= (GLenum
) params
[0];
1466 if (mode
== GL_NONE
|| mode
== GL_COMPARE_R_TO_TEXTURE_ARB
) {
1467 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1468 texObj
->CompareMode
= mode
;
1471 _mesa_error(ctx
, GL_INVALID_ENUM
,
1472 "glTexParameter(bad GL_TEXTURE_COMPARE_MODE_ARB: 0x%x)", mode
);
1477 _mesa_error(ctx
, GL_INVALID_ENUM
,
1478 "glTexParameter(pname=GL_TEXTURE_COMPARE_MODE_ARB)");
1482 case GL_TEXTURE_COMPARE_FUNC_ARB
:
1483 if (ctx
->Extensions
.ARB_shadow
) {
1484 const GLenum func
= (GLenum
) params
[0];
1485 if (func
== GL_LEQUAL
|| func
== GL_GEQUAL
) {
1486 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1487 texObj
->CompareFunc
= func
;
1489 else if (ctx
->Extensions
.EXT_shadow_funcs
&&
1490 (func
== GL_EQUAL
||
1491 func
== GL_NOTEQUAL
||
1493 func
== GL_GREATER
||
1494 func
== GL_ALWAYS
||
1495 func
== GL_NEVER
)) {
1496 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1497 texObj
->CompareFunc
= func
;
1500 _mesa_error(ctx
, GL_INVALID_ENUM
,
1501 "glTexParameter(bad GL_TEXTURE_COMPARE_FUNC_ARB)");
1506 _mesa_error(ctx
, GL_INVALID_ENUM
,
1507 "glTexParameter(pname=GL_TEXTURE_COMPARE_FUNC_ARB)");
1511 case GL_DEPTH_TEXTURE_MODE_ARB
:
1512 if (ctx
->Extensions
.ARB_depth_texture
) {
1513 const GLenum result
= (GLenum
) params
[0];
1514 if (result
== GL_LUMINANCE
|| result
== GL_INTENSITY
1515 || result
== GL_ALPHA
) {
1516 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1517 texObj
->DepthMode
= result
;
1520 _mesa_error(ctx
, GL_INVALID_ENUM
,
1521 "glTexParameter(bad GL_DEPTH_TEXTURE_MODE_ARB)");
1526 _mesa_error(ctx
, GL_INVALID_ENUM
,
1527 "glTexParameter(pname=GL_DEPTH_TEXTURE_MODE_ARB)");
1531 case GL_TEXTURE_LOD_BIAS
:
1532 /* NOTE: this is really part of OpenGL 1.4, not EXT_texture_lod_bias*/
1533 if (ctx
->Extensions
.EXT_texture_lod_bias
) {
1534 if (texObj
->LodBias
!= params
[0]) {
1535 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1536 texObj
->LodBias
= params
[0];
1542 _mesa_error(ctx
, GL_INVALID_ENUM
,
1543 "glTexParameter(pname=0x%x)", pname
);
1547 texObj
->Complete
= GL_FALSE
;
1549 if (ctx
->Driver
.TexParameter
) {
1550 (*ctx
->Driver
.TexParameter
)( ctx
, target
, texObj
, pname
, params
);
1556 _mesa_TexParameteri( GLenum target
, GLenum pname
, GLint param
)
1559 if (pname
== GL_TEXTURE_PRIORITY
)
1560 fparam
[0] = INT_TO_FLOAT(param
);
1562 fparam
[0] = (GLfloat
) param
;
1563 fparam
[1] = fparam
[2] = fparam
[3] = 0.0;
1564 _mesa_TexParameterfv(target
, pname
, fparam
);
1569 _mesa_TexParameteriv( GLenum target
, GLenum pname
, const GLint
*params
)
1572 if (pname
== GL_TEXTURE_BORDER_COLOR
) {
1573 fparam
[0] = INT_TO_FLOAT(params
[0]);
1574 fparam
[1] = INT_TO_FLOAT(params
[1]);
1575 fparam
[2] = INT_TO_FLOAT(params
[2]);
1576 fparam
[3] = INT_TO_FLOAT(params
[3]);
1579 if (pname
== GL_TEXTURE_PRIORITY
)
1580 fparam
[0] = INT_TO_FLOAT(params
[0]);
1582 fparam
[0] = (GLfloat
) params
[0];
1583 fparam
[1] = fparam
[2] = fparam
[3] = 0.0F
;
1585 _mesa_TexParameterfv(target
, pname
, fparam
);
1590 _mesa_GetTexLevelParameterfv( GLenum target
, GLint level
,
1591 GLenum pname
, GLfloat
*params
)
1594 _mesa_GetTexLevelParameteriv( target
, level
, pname
, &iparam
);
1595 *params
= (GLfloat
) iparam
;
1600 tex_image_dimensions(GLcontext
*ctx
, GLenum target
)
1604 case GL_PROXY_TEXTURE_1D
:
1607 case GL_PROXY_TEXTURE_2D
:
1610 case GL_PROXY_TEXTURE_3D
:
1612 case GL_TEXTURE_CUBE_MAP
:
1613 case GL_PROXY_TEXTURE_CUBE_MAP
:
1614 case GL_TEXTURE_CUBE_MAP_POSITIVE_X
:
1615 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X
:
1616 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y
:
1617 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y
:
1618 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z
:
1619 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z
:
1620 return ctx
->Extensions
.ARB_texture_cube_map
? 2 : 0;
1621 case GL_TEXTURE_RECTANGLE_NV
:
1622 case GL_PROXY_TEXTURE_RECTANGLE_NV
:
1623 return ctx
->Extensions
.NV_texture_rectangle
? 2 : 0;
1625 _mesa_problem(ctx
, "bad target in _mesa_tex_target_dimensions()");
1632 _mesa_GetTexLevelParameteriv( GLenum target
, GLint level
,
1633 GLenum pname
, GLint
*params
)
1635 GET_CURRENT_CONTEXT(ctx
);
1636 const struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1637 const struct gl_texture_image
*img
= NULL
;
1641 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1643 /* this will catch bad target values */
1644 dimensions
= tex_image_dimensions(ctx
, target
); /* 1, 2 or 3 */
1645 if (dimensions
== 0) {
1646 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexLevelParameter[if]v(target)");
1650 maxLevels
= _mesa_max_texture_levels(ctx
, target
);
1651 if (maxLevels
== 0) {
1652 /* should not happen since <target> was just checked above */
1653 _mesa_problem(ctx
, "maxLevels=0 in _mesa_GetTexLevelParameter");
1657 if (level
< 0 || level
>= maxLevels
) {
1658 _mesa_error( ctx
, GL_INVALID_VALUE
, "glGetTexLevelParameter[if]v" );
1662 img
= _mesa_select_tex_image(ctx
, texUnit
, target
, level
);
1663 if (!img
|| !img
->TexFormat
) {
1664 /* undefined texture image */
1665 if (pname
== GL_TEXTURE_COMPONENTS
)
1672 isProxy
= _mesa_is_proxy_texture(target
);
1675 case GL_TEXTURE_WIDTH
:
1676 *params
= img
->Width
;
1678 case GL_TEXTURE_HEIGHT
:
1679 *params
= img
->Height
;
1681 case GL_TEXTURE_DEPTH
:
1682 *params
= img
->Depth
;
1684 case GL_TEXTURE_INTERNAL_FORMAT
:
1685 *params
= img
->InternalFormat
;
1687 case GL_TEXTURE_BORDER
:
1688 *params
= img
->Border
;
1690 case GL_TEXTURE_RED_SIZE
:
1691 if (img
->_BaseFormat
== GL_RGB
|| img
->_BaseFormat
== GL_RGBA
)
1692 *params
= img
->TexFormat
->RedBits
;
1696 case GL_TEXTURE_GREEN_SIZE
:
1697 if (img
->_BaseFormat
== GL_RGB
|| img
->_BaseFormat
== GL_RGBA
)
1698 *params
= img
->TexFormat
->GreenBits
;
1702 case GL_TEXTURE_BLUE_SIZE
:
1703 if (img
->_BaseFormat
== GL_RGB
|| img
->_BaseFormat
== GL_RGBA
)
1704 *params
= img
->TexFormat
->BlueBits
;
1708 case GL_TEXTURE_ALPHA_SIZE
:
1709 if (img
->_BaseFormat
== GL_ALPHA
||
1710 img
->_BaseFormat
== GL_LUMINANCE_ALPHA
||
1711 img
->_BaseFormat
== GL_RGBA
)
1712 *params
= img
->TexFormat
->AlphaBits
;
1716 case GL_TEXTURE_INTENSITY_SIZE
:
1717 if (img
->_BaseFormat
!= GL_INTENSITY
)
1719 else if (img
->TexFormat
->IntensityBits
> 0)
1720 *params
= img
->TexFormat
->IntensityBits
;
1721 else /* intensity probably stored as rgb texture */
1722 *params
= MIN2(img
->TexFormat
->RedBits
, img
->TexFormat
->GreenBits
);
1724 case GL_TEXTURE_LUMINANCE_SIZE
:
1725 if (img
->_BaseFormat
!= GL_LUMINANCE
&&
1726 img
->_BaseFormat
!= GL_LUMINANCE_ALPHA
)
1728 else if (img
->TexFormat
->LuminanceBits
> 0)
1729 *params
= img
->TexFormat
->LuminanceBits
;
1730 else /* luminance probably stored as rgb texture */
1731 *params
= MIN2(img
->TexFormat
->RedBits
, img
->TexFormat
->GreenBits
);
1733 case GL_TEXTURE_INDEX_SIZE_EXT
:
1734 if (img
->_BaseFormat
== GL_COLOR_INDEX
)
1735 *params
= img
->TexFormat
->IndexBits
;
1739 case GL_TEXTURE_DEPTH_SIZE_ARB
:
1740 if (ctx
->Extensions
.SGIX_depth_texture
||
1741 ctx
->Extensions
.ARB_depth_texture
)
1742 *params
= img
->TexFormat
->DepthBits
;
1744 _mesa_error(ctx
, GL_INVALID_ENUM
,
1745 "glGetTexLevelParameter[if]v(pname)");
1747 case GL_TEXTURE_STENCIL_SIZE_EXT
:
1748 if (ctx
->Extensions
.EXT_packed_depth_stencil
) {
1749 *params
= img
->TexFormat
->StencilBits
;
1752 _mesa_error(ctx
, GL_INVALID_ENUM
,
1753 "glGetTexLevelParameter[if]v(pname)");
1757 /* GL_ARB_texture_compression */
1758 case GL_TEXTURE_COMPRESSED_IMAGE_SIZE
:
1759 if (ctx
->Extensions
.ARB_texture_compression
) {
1760 if (img
->IsCompressed
&& !isProxy
)
1761 *params
= img
->CompressedSize
;
1763 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1764 "glGetTexLevelParameter[if]v(pname)");
1767 _mesa_error(ctx
, GL_INVALID_ENUM
,
1768 "glGetTexLevelParameter[if]v(pname)");
1771 case GL_TEXTURE_COMPRESSED
:
1772 if (ctx
->Extensions
.ARB_texture_compression
) {
1773 *params
= (GLint
) img
->IsCompressed
;
1776 _mesa_error(ctx
, GL_INVALID_ENUM
,
1777 "glGetTexLevelParameter[if]v(pname)");
1781 /* GL_ARB_texture_float */
1782 case GL_TEXTURE_RED_TYPE_ARB
:
1783 if (ctx
->Extensions
.ARB_texture_float
) {
1784 *params
= img
->TexFormat
->RedBits
? img
->TexFormat
->DataType
: GL_NONE
;
1787 _mesa_error(ctx
, GL_INVALID_ENUM
,
1788 "glGetTexLevelParameter[if]v(pname)");
1791 case GL_TEXTURE_GREEN_TYPE_ARB
:
1792 if (ctx
->Extensions
.ARB_texture_float
) {
1793 *params
= img
->TexFormat
->GreenBits
? img
->TexFormat
->DataType
: GL_NONE
;
1796 _mesa_error(ctx
, GL_INVALID_ENUM
,
1797 "glGetTexLevelParameter[if]v(pname)");
1800 case GL_TEXTURE_BLUE_TYPE_ARB
:
1801 if (ctx
->Extensions
.ARB_texture_float
) {
1802 *params
= img
->TexFormat
->BlueBits
? img
->TexFormat
->DataType
: GL_NONE
;
1805 _mesa_error(ctx
, GL_INVALID_ENUM
,
1806 "glGetTexLevelParameter[if]v(pname)");
1809 case GL_TEXTURE_ALPHA_TYPE_ARB
:
1810 if (ctx
->Extensions
.ARB_texture_float
) {
1811 *params
= img
->TexFormat
->AlphaBits
? img
->TexFormat
->DataType
: GL_NONE
;
1814 _mesa_error(ctx
, GL_INVALID_ENUM
,
1815 "glGetTexLevelParameter[if]v(pname)");
1818 case GL_TEXTURE_LUMINANCE_TYPE_ARB
:
1819 if (ctx
->Extensions
.ARB_texture_float
) {
1820 *params
= img
->TexFormat
->LuminanceBits
? img
->TexFormat
->DataType
: GL_NONE
;
1823 _mesa_error(ctx
, GL_INVALID_ENUM
,
1824 "glGetTexLevelParameter[if]v(pname)");
1827 case GL_TEXTURE_INTENSITY_TYPE_ARB
:
1828 if (ctx
->Extensions
.ARB_texture_float
) {
1829 *params
= img
->TexFormat
->IntensityBits
? img
->TexFormat
->DataType
: GL_NONE
;
1832 _mesa_error(ctx
, GL_INVALID_ENUM
,
1833 "glGetTexLevelParameter[if]v(pname)");
1836 case GL_TEXTURE_DEPTH_TYPE_ARB
:
1837 if (ctx
->Extensions
.ARB_texture_float
) {
1838 *params
= img
->TexFormat
->DepthBits
? img
->TexFormat
->DataType
: GL_NONE
;
1841 _mesa_error(ctx
, GL_INVALID_ENUM
,
1842 "glGetTexLevelParameter[if]v(pname)");
1847 _mesa_error(ctx
, GL_INVALID_ENUM
,
1848 "glGetTexLevelParameter[if]v(pname)");
1855 _mesa_GetTexParameterfv( GLenum target
, GLenum pname
, GLfloat
*params
)
1857 GET_CURRENT_CONTEXT(ctx
);
1858 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1859 struct gl_texture_object
*obj
;
1860 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1862 obj
= _mesa_select_tex_object(ctx
, texUnit
, target
);
1864 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexParameterfv(target)");
1869 case GL_TEXTURE_MAG_FILTER
:
1870 *params
= ENUM_TO_FLOAT(obj
->MagFilter
);
1872 case GL_TEXTURE_MIN_FILTER
:
1873 *params
= ENUM_TO_FLOAT(obj
->MinFilter
);
1875 case GL_TEXTURE_WRAP_S
:
1876 *params
= ENUM_TO_FLOAT(obj
->WrapS
);
1878 case GL_TEXTURE_WRAP_T
:
1879 *params
= ENUM_TO_FLOAT(obj
->WrapT
);
1881 case GL_TEXTURE_WRAP_R
:
1882 *params
= ENUM_TO_FLOAT(obj
->WrapR
);
1884 case GL_TEXTURE_BORDER_COLOR
:
1885 params
[0] = CLAMP(obj
->BorderColor
[0], 0.0F
, 1.0F
);
1886 params
[1] = CLAMP(obj
->BorderColor
[1], 0.0F
, 1.0F
);
1887 params
[2] = CLAMP(obj
->BorderColor
[2], 0.0F
, 1.0F
);
1888 params
[3] = CLAMP(obj
->BorderColor
[3], 0.0F
, 1.0F
);
1890 case GL_TEXTURE_RESIDENT
:
1893 if (ctx
->Driver
.IsTextureResident
)
1894 resident
= ctx
->Driver
.IsTextureResident(ctx
, obj
);
1897 *params
= ENUM_TO_FLOAT(resident
);
1900 case GL_TEXTURE_PRIORITY
:
1901 *params
= obj
->Priority
;
1903 case GL_TEXTURE_MIN_LOD
:
1904 *params
= obj
->MinLod
;
1906 case GL_TEXTURE_MAX_LOD
:
1907 *params
= obj
->MaxLod
;
1909 case GL_TEXTURE_BASE_LEVEL
:
1910 *params
= (GLfloat
) obj
->BaseLevel
;
1912 case GL_TEXTURE_MAX_LEVEL
:
1913 *params
= (GLfloat
) obj
->MaxLevel
;
1915 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
1916 if (ctx
->Extensions
.EXT_texture_filter_anisotropic
) {
1917 *params
= obj
->MaxAnisotropy
;
1921 case GL_TEXTURE_COMPARE_SGIX
:
1922 if (ctx
->Extensions
.SGIX_shadow
) {
1923 *params
= (GLfloat
) obj
->CompareFlag
;
1927 case GL_TEXTURE_COMPARE_OPERATOR_SGIX
:
1928 if (ctx
->Extensions
.SGIX_shadow
) {
1929 *params
= (GLfloat
) obj
->CompareOperator
;
1933 case GL_SHADOW_AMBIENT_SGIX
: /* aka GL_TEXTURE_COMPARE_FAIL_VALUE_ARB */
1934 if (ctx
->Extensions
.SGIX_shadow_ambient
) {
1935 *params
= obj
->ShadowAmbient
;
1939 case GL_GENERATE_MIPMAP_SGIS
:
1940 if (ctx
->Extensions
.SGIS_generate_mipmap
) {
1941 *params
= (GLfloat
) obj
->GenerateMipmap
;
1945 case GL_TEXTURE_COMPARE_MODE_ARB
:
1946 if (ctx
->Extensions
.ARB_shadow
) {
1947 *params
= (GLfloat
) obj
->CompareMode
;
1951 case GL_TEXTURE_COMPARE_FUNC_ARB
:
1952 if (ctx
->Extensions
.ARB_shadow
) {
1953 *params
= (GLfloat
) obj
->CompareFunc
;
1957 case GL_DEPTH_TEXTURE_MODE_ARB
:
1958 if (ctx
->Extensions
.ARB_depth_texture
) {
1959 *params
= (GLfloat
) obj
->DepthMode
;
1963 case GL_TEXTURE_LOD_BIAS
:
1964 if (ctx
->Extensions
.EXT_texture_lod_bias
) {
1965 *params
= obj
->LodBias
;
1970 ; /* silence warnings */
1972 /* If we get here, pname was an unrecognized enum */
1973 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexParameterfv(pname=0x%x)",
1979 _mesa_GetTexParameteriv( GLenum target
, GLenum pname
, GLint
*params
)
1981 GET_CURRENT_CONTEXT(ctx
);
1982 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1983 struct gl_texture_object
*obj
;
1984 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1986 obj
= _mesa_select_tex_object(ctx
, texUnit
, target
);
1988 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexParameteriv(target)");
1993 case GL_TEXTURE_MAG_FILTER
:
1994 *params
= (GLint
) obj
->MagFilter
;
1996 case GL_TEXTURE_MIN_FILTER
:
1997 *params
= (GLint
) obj
->MinFilter
;
1999 case GL_TEXTURE_WRAP_S
:
2000 *params
= (GLint
) obj
->WrapS
;
2002 case GL_TEXTURE_WRAP_T
:
2003 *params
= (GLint
) obj
->WrapT
;
2005 case GL_TEXTURE_WRAP_R
:
2006 *params
= (GLint
) obj
->WrapR
;
2008 case GL_TEXTURE_BORDER_COLOR
:
2011 b
[0] = CLAMP(obj
->BorderColor
[0], 0.0F
, 1.0F
);
2012 b
[1] = CLAMP(obj
->BorderColor
[1], 0.0F
, 1.0F
);
2013 b
[2] = CLAMP(obj
->BorderColor
[2], 0.0F
, 1.0F
);
2014 b
[3] = CLAMP(obj
->BorderColor
[3], 0.0F
, 1.0F
);
2015 params
[0] = FLOAT_TO_INT(b
[0]);
2016 params
[1] = FLOAT_TO_INT(b
[1]);
2017 params
[2] = FLOAT_TO_INT(b
[2]);
2018 params
[3] = FLOAT_TO_INT(b
[3]);
2021 case GL_TEXTURE_RESIDENT
:
2024 if (ctx
->Driver
.IsTextureResident
)
2025 resident
= ctx
->Driver
.IsTextureResident(ctx
, obj
);
2028 *params
= (GLint
) resident
;
2031 case GL_TEXTURE_PRIORITY
:
2032 *params
= FLOAT_TO_INT(obj
->Priority
);
2034 case GL_TEXTURE_MIN_LOD
:
2035 *params
= (GLint
) obj
->MinLod
;
2037 case GL_TEXTURE_MAX_LOD
:
2038 *params
= (GLint
) obj
->MaxLod
;
2040 case GL_TEXTURE_BASE_LEVEL
:
2041 *params
= obj
->BaseLevel
;
2043 case GL_TEXTURE_MAX_LEVEL
:
2044 *params
= obj
->MaxLevel
;
2046 case GL_TEXTURE_MAX_ANISOTROPY_EXT
:
2047 if (ctx
->Extensions
.EXT_texture_filter_anisotropic
) {
2048 *params
= (GLint
) obj
->MaxAnisotropy
;
2052 case GL_TEXTURE_COMPARE_SGIX
:
2053 if (ctx
->Extensions
.SGIX_shadow
) {
2054 *params
= (GLint
) obj
->CompareFlag
;
2058 case GL_TEXTURE_COMPARE_OPERATOR_SGIX
:
2059 if (ctx
->Extensions
.SGIX_shadow
) {
2060 *params
= (GLint
) obj
->CompareOperator
;
2064 case GL_SHADOW_AMBIENT_SGIX
: /* aka GL_TEXTURE_COMPARE_FAIL_VALUE_ARB */
2065 if (ctx
->Extensions
.SGIX_shadow_ambient
) {
2066 *params
= (GLint
) FLOAT_TO_INT(obj
->ShadowAmbient
);
2070 case GL_GENERATE_MIPMAP_SGIS
:
2071 if (ctx
->Extensions
.SGIS_generate_mipmap
) {
2072 *params
= (GLint
) obj
->GenerateMipmap
;
2076 case GL_TEXTURE_COMPARE_MODE_ARB
:
2077 if (ctx
->Extensions
.ARB_shadow
) {
2078 *params
= (GLint
) obj
->CompareMode
;
2082 case GL_TEXTURE_COMPARE_FUNC_ARB
:
2083 if (ctx
->Extensions
.ARB_shadow
) {
2084 *params
= (GLint
) obj
->CompareFunc
;
2088 case GL_DEPTH_TEXTURE_MODE_ARB
:
2089 if (ctx
->Extensions
.ARB_depth_texture
) {
2090 *params
= (GLint
) obj
->DepthMode
;
2094 case GL_TEXTURE_LOD_BIAS
:
2095 if (ctx
->Extensions
.EXT_texture_lod_bias
) {
2096 *params
= (GLint
) obj
->LodBias
;
2101 ; /* silence warnings */
2103 /* If we get here, pname was an unrecognized enum */
2104 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTexParameteriv(pname=0x%x)", pname
);
2110 /**********************************************************************/
2111 /* Texture Coord Generation */
2112 /**********************************************************************/
2116 _mesa_TexGenfv( GLenum coord
, GLenum pname
, const GLfloat
*params
)
2118 GET_CURRENT_CONTEXT(ctx
);
2119 GLuint tUnit
= ctx
->Texture
.CurrentUnit
;
2120 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[tUnit
];
2121 ASSERT_OUTSIDE_BEGIN_END(ctx
);
2123 if (MESA_VERBOSE
&(VERBOSE_API
|VERBOSE_TEXTURE
))
2124 _mesa_debug(ctx
, "glTexGen %s %s %.1f(%s)...\n",
2125 _mesa_lookup_enum_by_nr(coord
),
2126 _mesa_lookup_enum_by_nr(pname
),
2128 _mesa_lookup_enum_by_nr((GLenum
) (GLint
) *params
));
2132 if (pname
==GL_TEXTURE_GEN_MODE
) {
2133 GLenum mode
= (GLenum
) (GLint
) *params
;
2136 case GL_OBJECT_LINEAR
:
2137 bits
= TEXGEN_OBJ_LINEAR
;
2140 bits
= TEXGEN_EYE_LINEAR
;
2142 case GL_REFLECTION_MAP_NV
:
2143 bits
= TEXGEN_REFLECTION_MAP_NV
;
2145 case GL_NORMAL_MAP_NV
:
2146 bits
= TEXGEN_NORMAL_MAP_NV
;
2149 bits
= TEXGEN_SPHERE_MAP
;
2152 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(param)" );
2155 if (texUnit
->GenModeS
== mode
)
2157 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
2158 texUnit
->GenModeS
= mode
;
2159 texUnit
->_GenBitS
= bits
;
2161 else if (pname
==GL_OBJECT_PLANE
) {
2162 if (TEST_EQ_4V(texUnit
->ObjectPlaneS
, params
))
2164 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
2165 COPY_4FV(texUnit
->ObjectPlaneS
, params
);
2167 else if (pname
==GL_EYE_PLANE
) {
2169 /* Transform plane equation by the inverse modelview matrix */
2170 if (_math_matrix_is_dirty(ctx
->ModelviewMatrixStack
.Top
)) {
2171 _math_matrix_analyse( ctx
->ModelviewMatrixStack
.Top
);
2173 _mesa_transform_vector( tmp
, params
, ctx
->ModelviewMatrixStack
.Top
->inv
);
2174 if (TEST_EQ_4V(texUnit
->EyePlaneS
, tmp
))
2176 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
2177 COPY_4FV(texUnit
->EyePlaneS
, tmp
);
2180 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(pname)" );
2185 if (pname
==GL_TEXTURE_GEN_MODE
) {
2186 GLenum mode
= (GLenum
) (GLint
) *params
;
2189 case GL_OBJECT_LINEAR
:
2190 bitt
= TEXGEN_OBJ_LINEAR
;
2193 bitt
= TEXGEN_EYE_LINEAR
;
2195 case GL_REFLECTION_MAP_NV
:
2196 bitt
= TEXGEN_REFLECTION_MAP_NV
;
2198 case GL_NORMAL_MAP_NV
:
2199 bitt
= TEXGEN_NORMAL_MAP_NV
;
2202 bitt
= TEXGEN_SPHERE_MAP
;
2205 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(param)" );
2208 if (texUnit
->GenModeT
== mode
)
2210 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
2211 texUnit
->GenModeT
= mode
;
2212 texUnit
->_GenBitT
= bitt
;
2214 else if (pname
==GL_OBJECT_PLANE
) {
2215 if (TEST_EQ_4V(texUnit
->ObjectPlaneT
, params
))
2217 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
2218 COPY_4FV(texUnit
->ObjectPlaneT
, params
);
2220 else if (pname
==GL_EYE_PLANE
) {
2222 /* Transform plane equation by the inverse modelview matrix */
2223 if (_math_matrix_is_dirty(ctx
->ModelviewMatrixStack
.Top
)) {
2224 _math_matrix_analyse( ctx
->ModelviewMatrixStack
.Top
);
2226 _mesa_transform_vector( tmp
, params
, ctx
->ModelviewMatrixStack
.Top
->inv
);
2227 if (TEST_EQ_4V(texUnit
->EyePlaneT
, tmp
))
2229 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
2230 COPY_4FV(texUnit
->EyePlaneT
, tmp
);
2233 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(pname)" );
2238 if (pname
==GL_TEXTURE_GEN_MODE
) {
2239 GLenum mode
= (GLenum
) (GLint
) *params
;
2242 case GL_OBJECT_LINEAR
:
2243 bitr
= TEXGEN_OBJ_LINEAR
;
2245 case GL_REFLECTION_MAP_NV
:
2246 bitr
= TEXGEN_REFLECTION_MAP_NV
;
2248 case GL_NORMAL_MAP_NV
:
2249 bitr
= TEXGEN_NORMAL_MAP_NV
;
2252 bitr
= TEXGEN_EYE_LINEAR
;
2255 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(param)" );
2258 if (texUnit
->GenModeR
== mode
)
2260 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
2261 texUnit
->GenModeR
= mode
;
2262 texUnit
->_GenBitR
= bitr
;
2264 else if (pname
==GL_OBJECT_PLANE
) {
2265 if (TEST_EQ_4V(texUnit
->ObjectPlaneR
, params
))
2267 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
2268 COPY_4FV(texUnit
->ObjectPlaneR
, params
);
2270 else if (pname
==GL_EYE_PLANE
) {
2272 /* Transform plane equation by the inverse modelview matrix */
2273 if (_math_matrix_is_dirty(ctx
->ModelviewMatrixStack
.Top
)) {
2274 _math_matrix_analyse( ctx
->ModelviewMatrixStack
.Top
);
2276 _mesa_transform_vector( tmp
, params
, ctx
->ModelviewMatrixStack
.Top
->inv
);
2277 if (TEST_EQ_4V(texUnit
->EyePlaneR
, tmp
))
2279 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
2280 COPY_4FV(texUnit
->EyePlaneR
, tmp
);
2283 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(pname)" );
2288 if (pname
==GL_TEXTURE_GEN_MODE
) {
2289 GLenum mode
= (GLenum
) (GLint
) *params
;
2292 case GL_OBJECT_LINEAR
:
2293 bitq
= TEXGEN_OBJ_LINEAR
;
2296 bitq
= TEXGEN_EYE_LINEAR
;
2299 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(param)" );
2302 if (texUnit
->GenModeQ
== mode
)
2304 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
2305 texUnit
->GenModeQ
= mode
;
2306 texUnit
->_GenBitQ
= bitq
;
2308 else if (pname
==GL_OBJECT_PLANE
) {
2309 if (TEST_EQ_4V(texUnit
->ObjectPlaneQ
, params
))
2311 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
2312 COPY_4FV(texUnit
->ObjectPlaneQ
, params
);
2314 else if (pname
==GL_EYE_PLANE
) {
2316 /* Transform plane equation by the inverse modelview matrix */
2317 if (_math_matrix_is_dirty(ctx
->ModelviewMatrixStack
.Top
)) {
2318 _math_matrix_analyse( ctx
->ModelviewMatrixStack
.Top
);
2320 _mesa_transform_vector( tmp
, params
, ctx
->ModelviewMatrixStack
.Top
->inv
);
2321 if (TEST_EQ_4V(texUnit
->EyePlaneQ
, tmp
))
2323 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
2324 COPY_4FV(texUnit
->EyePlaneQ
, tmp
);
2327 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(pname)" );
2332 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexGenfv(coord)" );
2336 if (ctx
->Driver
.TexGen
)
2337 ctx
->Driver
.TexGen( ctx
, coord
, pname
, params
);
2342 _mesa_TexGeniv(GLenum coord
, GLenum pname
, const GLint
*params
)
2345 p
[0] = (GLfloat
) params
[0];
2346 if (pname
== GL_TEXTURE_GEN_MODE
) {
2347 p
[1] = p
[2] = p
[3] = 0.0F
;
2350 p
[1] = (GLfloat
) params
[1];
2351 p
[2] = (GLfloat
) params
[2];
2352 p
[3] = (GLfloat
) params
[3];
2354 _mesa_TexGenfv(coord
, pname
, p
);
2359 _mesa_TexGend(GLenum coord
, GLenum pname
, GLdouble param
)
2361 GLfloat p
= (GLfloat
) param
;
2362 _mesa_TexGenfv( coord
, pname
, &p
);
2367 _mesa_TexGendv(GLenum coord
, GLenum pname
, const GLdouble
*params
)
2370 p
[0] = (GLfloat
) params
[0];
2371 if (pname
== GL_TEXTURE_GEN_MODE
) {
2372 p
[1] = p
[2] = p
[3] = 0.0F
;
2375 p
[1] = (GLfloat
) params
[1];
2376 p
[2] = (GLfloat
) params
[2];
2377 p
[3] = (GLfloat
) params
[3];
2379 _mesa_TexGenfv( coord
, pname
, p
);
2384 _mesa_TexGenf( GLenum coord
, GLenum pname
, GLfloat param
)
2386 _mesa_TexGenfv(coord
, pname
, ¶m
);
2391 _mesa_TexGeni( GLenum coord
, GLenum pname
, GLint param
)
2393 _mesa_TexGeniv( coord
, pname
, ¶m
);
2399 _mesa_GetTexGendv( GLenum coord
, GLenum pname
, GLdouble
*params
)
2401 GET_CURRENT_CONTEXT(ctx
);
2402 GLuint tUnit
= ctx
->Texture
.CurrentUnit
;
2403 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[tUnit
];
2404 ASSERT_OUTSIDE_BEGIN_END(ctx
);
2408 if (pname
==GL_TEXTURE_GEN_MODE
) {
2409 params
[0] = ENUM_TO_DOUBLE(texUnit
->GenModeS
);
2411 else if (pname
==GL_OBJECT_PLANE
) {
2412 COPY_4V( params
, texUnit
->ObjectPlaneS
);
2414 else if (pname
==GL_EYE_PLANE
) {
2415 COPY_4V( params
, texUnit
->EyePlaneS
);
2418 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGendv(pname)" );
2423 if (pname
==GL_TEXTURE_GEN_MODE
) {
2424 params
[0] = ENUM_TO_DOUBLE(texUnit
->GenModeT
);
2426 else if (pname
==GL_OBJECT_PLANE
) {
2427 COPY_4V( params
, texUnit
->ObjectPlaneT
);
2429 else if (pname
==GL_EYE_PLANE
) {
2430 COPY_4V( params
, texUnit
->EyePlaneT
);
2433 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGendv(pname)" );
2438 if (pname
==GL_TEXTURE_GEN_MODE
) {
2439 params
[0] = ENUM_TO_DOUBLE(texUnit
->GenModeR
);
2441 else if (pname
==GL_OBJECT_PLANE
) {
2442 COPY_4V( params
, texUnit
->ObjectPlaneR
);
2444 else if (pname
==GL_EYE_PLANE
) {
2445 COPY_4V( params
, texUnit
->EyePlaneR
);
2448 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGendv(pname)" );
2453 if (pname
==GL_TEXTURE_GEN_MODE
) {
2454 params
[0] = ENUM_TO_DOUBLE(texUnit
->GenModeQ
);
2456 else if (pname
==GL_OBJECT_PLANE
) {
2457 COPY_4V( params
, texUnit
->ObjectPlaneQ
);
2459 else if (pname
==GL_EYE_PLANE
) {
2460 COPY_4V( params
, texUnit
->EyePlaneQ
);
2463 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGendv(pname)" );
2468 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGendv(coord)" );
2476 _mesa_GetTexGenfv( GLenum coord
, GLenum pname
, GLfloat
*params
)
2478 GET_CURRENT_CONTEXT(ctx
);
2479 GLuint tUnit
= ctx
->Texture
.CurrentUnit
;
2480 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[tUnit
];
2481 ASSERT_OUTSIDE_BEGIN_END(ctx
);
2485 if (pname
==GL_TEXTURE_GEN_MODE
) {
2486 params
[0] = ENUM_TO_FLOAT(texUnit
->GenModeS
);
2488 else if (pname
==GL_OBJECT_PLANE
) {
2489 COPY_4V( params
, texUnit
->ObjectPlaneS
);
2491 else if (pname
==GL_EYE_PLANE
) {
2492 COPY_4V( params
, texUnit
->EyePlaneS
);
2495 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGenfv(pname)" );
2500 if (pname
==GL_TEXTURE_GEN_MODE
) {
2501 params
[0] = ENUM_TO_FLOAT(texUnit
->GenModeT
);
2503 else if (pname
==GL_OBJECT_PLANE
) {
2504 COPY_4V( params
, texUnit
->ObjectPlaneT
);
2506 else if (pname
==GL_EYE_PLANE
) {
2507 COPY_4V( params
, texUnit
->EyePlaneT
);
2510 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGenfv(pname)" );
2515 if (pname
==GL_TEXTURE_GEN_MODE
) {
2516 params
[0] = ENUM_TO_FLOAT(texUnit
->GenModeR
);
2518 else if (pname
==GL_OBJECT_PLANE
) {
2519 COPY_4V( params
, texUnit
->ObjectPlaneR
);
2521 else if (pname
==GL_EYE_PLANE
) {
2522 COPY_4V( params
, texUnit
->EyePlaneR
);
2525 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGenfv(pname)" );
2530 if (pname
==GL_TEXTURE_GEN_MODE
) {
2531 params
[0] = ENUM_TO_FLOAT(texUnit
->GenModeQ
);
2533 else if (pname
==GL_OBJECT_PLANE
) {
2534 COPY_4V( params
, texUnit
->ObjectPlaneQ
);
2536 else if (pname
==GL_EYE_PLANE
) {
2537 COPY_4V( params
, texUnit
->EyePlaneQ
);
2540 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGenfv(pname)" );
2545 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGenfv(coord)" );
2553 _mesa_GetTexGeniv( GLenum coord
, GLenum pname
, GLint
*params
)
2555 GET_CURRENT_CONTEXT(ctx
);
2556 GLuint tUnit
= ctx
->Texture
.CurrentUnit
;
2557 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[tUnit
];
2558 ASSERT_OUTSIDE_BEGIN_END(ctx
);
2562 if (pname
==GL_TEXTURE_GEN_MODE
) {
2563 params
[0] = texUnit
->GenModeS
;
2565 else if (pname
==GL_OBJECT_PLANE
) {
2566 params
[0] = (GLint
) texUnit
->ObjectPlaneS
[0];
2567 params
[1] = (GLint
) texUnit
->ObjectPlaneS
[1];
2568 params
[2] = (GLint
) texUnit
->ObjectPlaneS
[2];
2569 params
[3] = (GLint
) texUnit
->ObjectPlaneS
[3];
2571 else if (pname
==GL_EYE_PLANE
) {
2572 params
[0] = (GLint
) texUnit
->EyePlaneS
[0];
2573 params
[1] = (GLint
) texUnit
->EyePlaneS
[1];
2574 params
[2] = (GLint
) texUnit
->EyePlaneS
[2];
2575 params
[3] = (GLint
) texUnit
->EyePlaneS
[3];
2578 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGeniv(pname)" );
2583 if (pname
==GL_TEXTURE_GEN_MODE
) {
2584 params
[0] = texUnit
->GenModeT
;
2586 else if (pname
==GL_OBJECT_PLANE
) {
2587 params
[0] = (GLint
) texUnit
->ObjectPlaneT
[0];
2588 params
[1] = (GLint
) texUnit
->ObjectPlaneT
[1];
2589 params
[2] = (GLint
) texUnit
->ObjectPlaneT
[2];
2590 params
[3] = (GLint
) texUnit
->ObjectPlaneT
[3];
2592 else if (pname
==GL_EYE_PLANE
) {
2593 params
[0] = (GLint
) texUnit
->EyePlaneT
[0];
2594 params
[1] = (GLint
) texUnit
->EyePlaneT
[1];
2595 params
[2] = (GLint
) texUnit
->EyePlaneT
[2];
2596 params
[3] = (GLint
) texUnit
->EyePlaneT
[3];
2599 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGeniv(pname)" );
2604 if (pname
==GL_TEXTURE_GEN_MODE
) {
2605 params
[0] = texUnit
->GenModeR
;
2607 else if (pname
==GL_OBJECT_PLANE
) {
2608 params
[0] = (GLint
) texUnit
->ObjectPlaneR
[0];
2609 params
[1] = (GLint
) texUnit
->ObjectPlaneR
[1];
2610 params
[2] = (GLint
) texUnit
->ObjectPlaneR
[2];
2611 params
[3] = (GLint
) texUnit
->ObjectPlaneR
[3];
2613 else if (pname
==GL_EYE_PLANE
) {
2614 params
[0] = (GLint
) texUnit
->EyePlaneR
[0];
2615 params
[1] = (GLint
) texUnit
->EyePlaneR
[1];
2616 params
[2] = (GLint
) texUnit
->EyePlaneR
[2];
2617 params
[3] = (GLint
) texUnit
->EyePlaneR
[3];
2620 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGeniv(pname)" );
2625 if (pname
==GL_TEXTURE_GEN_MODE
) {
2626 params
[0] = texUnit
->GenModeQ
;
2628 else if (pname
==GL_OBJECT_PLANE
) {
2629 params
[0] = (GLint
) texUnit
->ObjectPlaneQ
[0];
2630 params
[1] = (GLint
) texUnit
->ObjectPlaneQ
[1];
2631 params
[2] = (GLint
) texUnit
->ObjectPlaneQ
[2];
2632 params
[3] = (GLint
) texUnit
->ObjectPlaneQ
[3];
2634 else if (pname
==GL_EYE_PLANE
) {
2635 params
[0] = (GLint
) texUnit
->EyePlaneQ
[0];
2636 params
[1] = (GLint
) texUnit
->EyePlaneQ
[1];
2637 params
[2] = (GLint
) texUnit
->EyePlaneQ
[2];
2638 params
[3] = (GLint
) texUnit
->EyePlaneQ
[3];
2641 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGeniv(pname)" );
2646 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetTexGeniv(coord)" );
2652 /* GL_ARB_multitexture */
2654 _mesa_ActiveTextureARB( GLenum target
)
2656 GET_CURRENT_CONTEXT(ctx
);
2657 const GLuint texUnit
= target
- GL_TEXTURE0
;
2658 ASSERT_OUTSIDE_BEGIN_END(ctx
);
2660 if (MESA_VERBOSE
& (VERBOSE_API
|VERBOSE_TEXTURE
))
2661 _mesa_debug(ctx
, "glActiveTexture %s\n",
2662 _mesa_lookup_enum_by_nr(target
));
2664 /* Cater for texture unit 0 is first, therefore use >= */
2665 if (texUnit
>= ctx
->Const
.MaxTextureUnits
) {
2666 _mesa_error(ctx
, GL_INVALID_ENUM
, "glActiveTexture(target)");
2670 if (ctx
->Texture
.CurrentUnit
== texUnit
)
2673 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
2675 ctx
->Texture
.CurrentUnit
= texUnit
;
2676 if (ctx
->Transform
.MatrixMode
== GL_TEXTURE
) {
2677 /* update current stack pointer */
2678 ctx
->CurrentStack
= &ctx
->TextureMatrixStack
[texUnit
];
2681 if (ctx
->Driver
.ActiveTexture
) {
2682 (*ctx
->Driver
.ActiveTexture
)( ctx
, (GLuint
) texUnit
);
2687 /* GL_ARB_multitexture */
2689 _mesa_ClientActiveTextureARB( GLenum target
)
2691 GET_CURRENT_CONTEXT(ctx
);
2692 GLuint texUnit
= target
- GL_TEXTURE0
;
2693 ASSERT_OUTSIDE_BEGIN_END(ctx
);
2695 if (texUnit
> ctx
->Const
.MaxTextureUnits
) {
2696 _mesa_error(ctx
, GL_INVALID_ENUM
, "glClientActiveTexture(target)");
2700 FLUSH_VERTICES(ctx
, _NEW_ARRAY
);
2701 ctx
->Array
.ActiveTexture
= texUnit
;
2706 /**********************************************************************/
2707 /***** State management *****/
2708 /**********************************************************************/
2712 * \note This routine refers to derived texture attribute values to
2713 * compute the ENABLE_TEXMAT flags, but is only called on
2714 * _NEW_TEXTURE_MATRIX. On changes to _NEW_TEXTURE, the ENABLE_TEXMAT
2715 * flags are updated by _mesa_update_textures(), below.
2717 * \param ctx GL context.
2720 update_texture_matrices( GLcontext
*ctx
)
2724 ctx
->Texture
._TexMatEnabled
= 0;
2726 for (i
=0; i
< ctx
->Const
.MaxTextureUnits
; i
++) {
2727 if (_math_matrix_is_dirty(ctx
->TextureMatrixStack
[i
].Top
)) {
2728 _math_matrix_analyse( ctx
->TextureMatrixStack
[i
].Top
);
2730 if (ctx
->Texture
.Unit
[i
]._ReallyEnabled
&&
2731 ctx
->TextureMatrixStack
[i
].Top
->type
!= MATRIX_IDENTITY
)
2732 ctx
->Texture
._TexMatEnabled
|= ENABLE_TEXMAT(i
);
2734 if (ctx
->Driver
.TextureMatrix
)
2735 ctx
->Driver
.TextureMatrix( ctx
, i
, ctx
->TextureMatrixStack
[i
].Top
);
2742 * \note This routine refers to derived texture matrix values to
2743 * compute the ENABLE_TEXMAT flags, but is only called on
2744 * _NEW_TEXTURE. On changes to _NEW_TEXTURE_MATRIX, the ENABLE_TEXMAT
2745 * flags are updated by _mesa_update_texture_matrices, above.
2747 * \param ctx GL context.
2750 update_texture_state( GLcontext
*ctx
)
2754 ctx
->NewState
|= _NEW_TEXTURE
; /* TODO: only set this if there are
2758 ctx
->Texture
._EnabledUnits
= 0;
2759 ctx
->Texture
._GenFlags
= 0;
2760 ctx
->Texture
._TexMatEnabled
= 0;
2761 ctx
->Texture
._TexGenEnabled
= 0;
2763 /* Update texture unit state.
2764 * XXX this loop should probably be broken into separate loops for
2765 * texture coord units and texture image units.
2767 for (unit
= 0; unit
< ctx
->Const
.MaxTextureUnits
; unit
++) {
2768 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[unit
];
2769 GLbitfield enableBits
;
2771 texUnit
->_Current
= NULL
;
2772 texUnit
->_ReallyEnabled
= 0;
2773 texUnit
->_GenFlags
= 0;
2775 /* Get the bitmask of texture enables */
2776 if (ctx
->FragmentProgram
._Enabled
) {
2777 enableBits
= ctx
->FragmentProgram
.Current
->TexturesUsed
[unit
];
2780 if (!texUnit
->Enabled
)
2782 enableBits
= texUnit
->Enabled
;
2785 /* Look for the highest-priority texture target that's enabled and
2786 * complete. That's the one we'll use for texturing. If we're using
2787 * a fragment program we're guaranteed that bitcount(enabledBits) <= 1.
2789 if (enableBits
& TEXTURE_CUBE_BIT
) {
2790 struct gl_texture_object
*texObj
= texUnit
->CurrentCubeMap
;
2791 if (!texObj
->Complete
) {
2792 _mesa_test_texobj_completeness(ctx
, texObj
);
2794 if (texObj
->Complete
) {
2795 texUnit
->_ReallyEnabled
= TEXTURE_CUBE_BIT
;
2796 texUnit
->_Current
= texObj
;
2800 if (!texUnit
->_ReallyEnabled
&& (enableBits
& TEXTURE_3D_BIT
)) {
2801 struct gl_texture_object
*texObj
= texUnit
->Current3D
;
2802 if (!texObj
->Complete
) {
2803 _mesa_test_texobj_completeness(ctx
, texObj
);
2805 if (texObj
->Complete
) {
2806 texUnit
->_ReallyEnabled
= TEXTURE_3D_BIT
;
2807 texUnit
->_Current
= texObj
;
2811 if (!texUnit
->_ReallyEnabled
&& (enableBits
& TEXTURE_RECT_BIT
)) {
2812 struct gl_texture_object
*texObj
= texUnit
->CurrentRect
;
2813 if (!texObj
->Complete
) {
2814 _mesa_test_texobj_completeness(ctx
, texObj
);
2816 if (texObj
->Complete
) {
2817 texUnit
->_ReallyEnabled
= TEXTURE_RECT_BIT
;
2818 texUnit
->_Current
= texObj
;
2822 if (!texUnit
->_ReallyEnabled
&& (enableBits
& TEXTURE_2D_BIT
)) {
2823 struct gl_texture_object
*texObj
= texUnit
->Current2D
;
2824 if (!texObj
->Complete
) {
2825 _mesa_test_texobj_completeness(ctx
, texObj
);
2827 if (texObj
->Complete
) {
2828 texUnit
->_ReallyEnabled
= TEXTURE_2D_BIT
;
2829 texUnit
->_Current
= texObj
;
2833 if (!texUnit
->_ReallyEnabled
&& (enableBits
& TEXTURE_1D_BIT
)) {
2834 struct gl_texture_object
*texObj
= texUnit
->Current1D
;
2835 if (!texObj
->Complete
) {
2836 _mesa_test_texobj_completeness(ctx
, texObj
);
2838 if (texObj
->Complete
) {
2839 texUnit
->_ReallyEnabled
= TEXTURE_1D_BIT
;
2840 texUnit
->_Current
= texObj
;
2844 if (!texUnit
->_ReallyEnabled
) {
2848 if (texUnit
->_ReallyEnabled
)
2849 ctx
->Texture
._EnabledUnits
|= (1 << unit
);
2851 if (texUnit
->EnvMode
== GL_COMBINE
) {
2852 texUnit
->_CurrentCombine
= & texUnit
->Combine
;
2855 GLenum format
= texUnit
->_Current
->Image
[0][0]->_BaseFormat
;
2856 if (format
== GL_COLOR_INDEX
) {
2857 format
= GL_RGBA
; /* a bit of a hack */
2859 else if (format
== GL_DEPTH_COMPONENT
2860 || format
== GL_DEPTH_STENCIL_EXT
) {
2861 format
= texUnit
->_Current
->DepthMode
;
2863 calculate_derived_texenv(&texUnit
->_EnvMode
, texUnit
->EnvMode
, format
);
2864 texUnit
->_CurrentCombine
= & texUnit
->_EnvMode
;
2867 switch (texUnit
->_CurrentCombine
->ModeRGB
) {
2869 texUnit
->_CurrentCombine
->_NumArgsRGB
= 1;
2877 case GL_DOT3_RGB_EXT
:
2878 case GL_DOT3_RGBA_EXT
:
2879 texUnit
->_CurrentCombine
->_NumArgsRGB
= 2;
2881 case GL_INTERPOLATE
:
2882 case GL_MODULATE_ADD_ATI
:
2883 case GL_MODULATE_SIGNED_ADD_ATI
:
2884 case GL_MODULATE_SUBTRACT_ATI
:
2885 texUnit
->_CurrentCombine
->_NumArgsRGB
= 3;
2888 texUnit
->_CurrentCombine
->_NumArgsRGB
= 0;
2889 _mesa_problem(ctx
, "invalid RGB combine mode in update_texture_state");
2893 switch (texUnit
->_CurrentCombine
->ModeA
) {
2895 texUnit
->_CurrentCombine
->_NumArgsA
= 1;
2901 texUnit
->_CurrentCombine
->_NumArgsA
= 2;
2903 case GL_INTERPOLATE
:
2904 case GL_MODULATE_ADD_ATI
:
2905 case GL_MODULATE_SIGNED_ADD_ATI
:
2906 case GL_MODULATE_SUBTRACT_ATI
:
2907 texUnit
->_CurrentCombine
->_NumArgsA
= 3;
2910 texUnit
->_CurrentCombine
->_NumArgsA
= 0;
2911 _mesa_problem(ctx
, "invalid Alpha combine mode in update_texture_state");
2915 if (texUnit
->TexGenEnabled
) {
2916 if (texUnit
->TexGenEnabled
& S_BIT
) {
2917 texUnit
->_GenFlags
|= texUnit
->_GenBitS
;
2919 if (texUnit
->TexGenEnabled
& T_BIT
) {
2920 texUnit
->_GenFlags
|= texUnit
->_GenBitT
;
2922 if (texUnit
->TexGenEnabled
& Q_BIT
) {
2923 texUnit
->_GenFlags
|= texUnit
->_GenBitQ
;
2925 if (texUnit
->TexGenEnabled
& R_BIT
) {
2926 texUnit
->_GenFlags
|= texUnit
->_GenBitR
;
2929 ctx
->Texture
._TexGenEnabled
|= ENABLE_TEXGEN(unit
);
2930 ctx
->Texture
._GenFlags
|= texUnit
->_GenFlags
;
2933 if (ctx
->TextureMatrixStack
[unit
].Top
->type
!= MATRIX_IDENTITY
)
2934 ctx
->Texture
._TexMatEnabled
|= ENABLE_TEXMAT(unit
);
2937 ctx
->Texture
._EnabledCoordUnits
= ctx
->Texture
._EnabledUnits
;
2938 /* Fragment programs may need texture coordinates but not the
2939 * corresponding texture images.
2941 if (ctx
->FragmentProgram
._Enabled
) {
2942 ctx
->Texture
._EnabledCoordUnits
|=
2943 (ctx
->FragmentProgram
.Current
->Base
.InputsRead
>> FRAG_ATTRIB_TEX0
);
2948 void _mesa_update_texture( GLcontext
*ctx
, GLuint new_state
)
2950 if (new_state
& _NEW_TEXTURE_MATRIX
)
2951 update_texture_matrices( ctx
);
2953 if (new_state
& (_NEW_TEXTURE
| _NEW_PROGRAM
))
2954 update_texture_state( ctx
);
2958 /**********************************************************************/
2959 /***** Initialization *****/
2960 /**********************************************************************/
2963 * Allocate the proxy textures for the given context.
2965 * \param ctx the context to allocate proxies for.
2967 * \return GL_TRUE on success, or GL_FALSE on failure
2969 * If run out of memory part way through the allocations, clean up and return
2973 alloc_proxy_textures( GLcontext
*ctx
)
2975 ctx
->Texture
.Proxy1D
= (*ctx
->Driver
.NewTextureObject
)(ctx
, 0, GL_TEXTURE_1D
);
2976 if (!ctx
->Texture
.Proxy1D
)
2979 ctx
->Texture
.Proxy2D
= (*ctx
->Driver
.NewTextureObject
)(ctx
, 0, GL_TEXTURE_2D
);
2980 if (!ctx
->Texture
.Proxy2D
)
2983 ctx
->Texture
.Proxy3D
= (*ctx
->Driver
.NewTextureObject
)(ctx
, 0, GL_TEXTURE_3D
);
2984 if (!ctx
->Texture
.Proxy3D
)
2987 ctx
->Texture
.ProxyCubeMap
= (*ctx
->Driver
.NewTextureObject
)(ctx
, 0, GL_TEXTURE_CUBE_MAP_ARB
);
2988 if (!ctx
->Texture
.ProxyCubeMap
)
2991 ctx
->Texture
.ProxyRect
= (*ctx
->Driver
.NewTextureObject
)(ctx
, 0, GL_TEXTURE_RECTANGLE_NV
);
2992 if (!ctx
->Texture
.ProxyRect
)
2998 if (ctx
->Texture
.Proxy1D
)
2999 (ctx
->Driver
.DeleteTexture
)(ctx
, ctx
->Texture
.Proxy1D
);
3000 if (ctx
->Texture
.Proxy2D
)
3001 (ctx
->Driver
.DeleteTexture
)(ctx
, ctx
->Texture
.Proxy2D
);
3002 if (ctx
->Texture
.Proxy3D
)
3003 (ctx
->Driver
.DeleteTexture
)(ctx
, ctx
->Texture
.Proxy3D
);
3004 if (ctx
->Texture
.ProxyCubeMap
)
3005 (ctx
->Driver
.DeleteTexture
)(ctx
, ctx
->Texture
.ProxyCubeMap
);
3006 if (ctx
->Texture
.ProxyRect
)
3007 (ctx
->Driver
.DeleteTexture
)(ctx
, ctx
->Texture
.ProxyRect
);
3013 * Initialize a texture unit.
3015 * \param ctx GL context.
3016 * \param unit texture unit number to be initialized.
3019 init_texture_unit( GLcontext
*ctx
, GLuint unit
)
3021 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[unit
];
3023 texUnit
->EnvMode
= GL_MODULATE
;
3024 ASSIGN_4V( texUnit
->EnvColor
, 0.0, 0.0, 0.0, 0.0 );
3026 texUnit
->Combine
= default_combine_state
;
3027 texUnit
->_EnvMode
= default_combine_state
;
3028 texUnit
->_CurrentCombine
= & texUnit
->_EnvMode
;
3030 texUnit
->TexGenEnabled
= 0;
3031 texUnit
->GenModeS
= GL_EYE_LINEAR
;
3032 texUnit
->GenModeT
= GL_EYE_LINEAR
;
3033 texUnit
->GenModeR
= GL_EYE_LINEAR
;
3034 texUnit
->GenModeQ
= GL_EYE_LINEAR
;
3035 texUnit
->_GenBitS
= TEXGEN_EYE_LINEAR
;
3036 texUnit
->_GenBitT
= TEXGEN_EYE_LINEAR
;
3037 texUnit
->_GenBitR
= TEXGEN_EYE_LINEAR
;
3038 texUnit
->_GenBitQ
= TEXGEN_EYE_LINEAR
;
3040 /* Yes, these plane coefficients are correct! */
3041 ASSIGN_4V( texUnit
->ObjectPlaneS
, 1.0, 0.0, 0.0, 0.0 );
3042 ASSIGN_4V( texUnit
->ObjectPlaneT
, 0.0, 1.0, 0.0, 0.0 );
3043 ASSIGN_4V( texUnit
->ObjectPlaneR
, 0.0, 0.0, 0.0, 0.0 );
3044 ASSIGN_4V( texUnit
->ObjectPlaneQ
, 0.0, 0.0, 0.0, 0.0 );
3045 ASSIGN_4V( texUnit
->EyePlaneS
, 1.0, 0.0, 0.0, 0.0 );
3046 ASSIGN_4V( texUnit
->EyePlaneT
, 0.0, 1.0, 0.0, 0.0 );
3047 ASSIGN_4V( texUnit
->EyePlaneR
, 0.0, 0.0, 0.0, 0.0 );
3048 ASSIGN_4V( texUnit
->EyePlaneQ
, 0.0, 0.0, 0.0, 0.0 );
3050 texUnit
->Current1D
= ctx
->Shared
->Default1D
;
3051 texUnit
->Current2D
= ctx
->Shared
->Default2D
;
3052 texUnit
->Current3D
= ctx
->Shared
->Default3D
;
3053 texUnit
->CurrentCubeMap
= ctx
->Shared
->DefaultCubeMap
;
3054 texUnit
->CurrentRect
= ctx
->Shared
->DefaultRect
;
3059 * Initialize texture state for the given context.
3062 _mesa_init_texture(GLcontext
*ctx
)
3066 assert(MAX_TEXTURE_LEVELS
>= MAX_3D_TEXTURE_LEVELS
);
3067 assert(MAX_TEXTURE_LEVELS
>= MAX_CUBE_TEXTURE_LEVELS
);
3069 /* Effectively bind the default textures to all texture units */
3070 ctx
->Shared
->Default1D
->RefCount
+= MAX_TEXTURE_UNITS
;
3071 ctx
->Shared
->Default2D
->RefCount
+= MAX_TEXTURE_UNITS
;
3072 ctx
->Shared
->Default3D
->RefCount
+= MAX_TEXTURE_UNITS
;
3073 ctx
->Shared
->DefaultCubeMap
->RefCount
+= MAX_TEXTURE_UNITS
;
3074 ctx
->Shared
->DefaultRect
->RefCount
+= MAX_TEXTURE_UNITS
;
3077 ctx
->Texture
.CurrentUnit
= 0; /* multitexture */
3078 ctx
->Texture
._EnabledUnits
= 0;
3079 for (i
=0; i
<MAX_TEXTURE_UNITS
; i
++)
3080 init_texture_unit( ctx
, i
);
3081 ctx
->Texture
.SharedPalette
= GL_FALSE
;
3082 _mesa_init_colortable(&ctx
->Texture
.Palette
);
3084 /* Allocate proxy textures */
3085 if (!alloc_proxy_textures( ctx
))
3093 * Free dynamically-allocted texture data attached to the given context.
3096 _mesa_free_texture_data(GLcontext
*ctx
)
3100 /* Free proxy texture objects */
3101 (ctx
->Driver
.DeleteTexture
)(ctx
, ctx
->Texture
.Proxy1D
);
3102 (ctx
->Driver
.DeleteTexture
)(ctx
, ctx
->Texture
.Proxy2D
);
3103 (ctx
->Driver
.DeleteTexture
)(ctx
, ctx
->Texture
.Proxy3D
);
3104 (ctx
->Driver
.DeleteTexture
)(ctx
, ctx
->Texture
.ProxyCubeMap
);
3105 (ctx
->Driver
.DeleteTexture
)(ctx
, ctx
->Texture
.ProxyRect
);
3107 for (i
= 0; i
< MAX_TEXTURE_IMAGE_UNITS
; i
++)
3108 _mesa_free_colortable_data( &ctx
->Texture
.Unit
[i
].ColorTable
);
3110 _mesa_TexEnvProgramCacheDestroy( ctx
);