1 /* $Id: colortab.c,v 1.49 2003/03/01 01:50:20 brianp Exp $ */
4 * Mesa 3-D graphics library
7 * Copyright (C) 1999-2003 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.
38 * Given an internalFormat token passed to glColorTable,
39 * return the corresponding base format.
40 * Return -1 if invalid token.
43 base_colortab_format( GLenum format
)
58 case GL_LUMINANCE_ALPHA
:
59 case GL_LUMINANCE4_ALPHA4
:
60 case GL_LUMINANCE6_ALPHA2
:
61 case GL_LUMINANCE8_ALPHA8
:
62 case GL_LUMINANCE12_ALPHA4
:
63 case GL_LUMINANCE12_ALPHA12
:
64 case GL_LUMINANCE16_ALPHA16
:
65 return GL_LUMINANCE_ALPHA
;
91 return -1; /* error */
97 _mesa_init_colortable( struct gl_color_table
*p
)
99 p
->FloatTable
= GL_FALSE
;
102 p
->IntFormat
= GL_RGBA
;
108 _mesa_free_colortable_data( struct gl_color_table
*p
)
118 * Examine table's format and set the component sizes accordingly.
121 set_component_sizes( struct gl_color_table
*table
)
123 switch (table
->Format
) {
126 table
->GreenSize
= 0;
128 table
->AlphaSize
= CHAN_BITS
;
129 table
->IntensitySize
= 0;
130 table
->LuminanceSize
= 0;
134 table
->GreenSize
= 0;
136 table
->AlphaSize
= 0;
137 table
->IntensitySize
= 0;
138 table
->LuminanceSize
= CHAN_BITS
;
140 case GL_LUMINANCE_ALPHA
:
142 table
->GreenSize
= 0;
144 table
->AlphaSize
= CHAN_BITS
;
145 table
->IntensitySize
= 0;
146 table
->LuminanceSize
= CHAN_BITS
;
150 table
->GreenSize
= 0;
152 table
->AlphaSize
= 0;
153 table
->IntensitySize
= CHAN_BITS
;
154 table
->LuminanceSize
= 0;
157 table
->RedSize
= CHAN_BITS
;
158 table
->GreenSize
= CHAN_BITS
;
159 table
->BlueSize
= CHAN_BITS
;
160 table
->AlphaSize
= 0;
161 table
->IntensitySize
= 0;
162 table
->LuminanceSize
= 0;
165 table
->RedSize
= CHAN_BITS
;
166 table
->GreenSize
= CHAN_BITS
;
167 table
->BlueSize
= CHAN_BITS
;
168 table
->AlphaSize
= CHAN_BITS
;
169 table
->IntensitySize
= 0;
170 table
->LuminanceSize
= 0;
173 _mesa_problem(NULL
, "unexpected format in set_component_sizes");
180 _mesa_ColorTable( GLenum target
, GLenum internalFormat
,
181 GLsizei width
, GLenum format
, GLenum type
,
184 GET_CURRENT_CONTEXT(ctx
);
185 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
186 struct gl_texture_object
*texObj
= NULL
;
187 struct gl_color_table
*table
= NULL
;
188 GLboolean proxy
= GL_FALSE
;
190 GLfloat rScale
= 1.0, gScale
= 1.0, bScale
= 1.0, aScale
= 1.0;
191 GLfloat rBias
= 0.0, gBias
= 0.0, bBias
= 0.0, aBias
= 0.0;
192 GLboolean floatTable
= GL_FALSE
;
194 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
); /* too complex */
198 texObj
= texUnit
->Current1D
;
199 table
= &texObj
->Palette
;
202 texObj
= texUnit
->Current2D
;
203 table
= &texObj
->Palette
;
206 texObj
= texUnit
->Current3D
;
207 table
= &texObj
->Palette
;
209 case GL_TEXTURE_CUBE_MAP_ARB
:
210 if (!ctx
->Extensions
.ARB_texture_cube_map
) {
211 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTable(target)");
214 texObj
= texUnit
->CurrentCubeMap
;
215 table
= &texObj
->Palette
;
217 case GL_PROXY_TEXTURE_1D
:
218 texObj
= ctx
->Texture
.Proxy1D
;
219 table
= &texObj
->Palette
;
222 case GL_PROXY_TEXTURE_2D
:
223 texObj
= ctx
->Texture
.Proxy2D
;
224 table
= &texObj
->Palette
;
227 case GL_PROXY_TEXTURE_3D
:
228 texObj
= ctx
->Texture
.Proxy3D
;
229 table
= &texObj
->Palette
;
232 case GL_PROXY_TEXTURE_CUBE_MAP_ARB
:
233 if (!ctx
->Extensions
.ARB_texture_cube_map
) {
234 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTable(target)");
237 texObj
= ctx
->Texture
.ProxyCubeMap
;
238 table
= &texObj
->Palette
;
240 case GL_SHARED_TEXTURE_PALETTE_EXT
:
241 table
= &ctx
->Texture
.Palette
;
244 table
= &ctx
->ColorTable
;
245 floatTable
= GL_TRUE
;
246 rScale
= ctx
->Pixel
.ColorTableScale
[0];
247 gScale
= ctx
->Pixel
.ColorTableScale
[1];
248 bScale
= ctx
->Pixel
.ColorTableScale
[2];
249 aScale
= ctx
->Pixel
.ColorTableScale
[3];
250 rBias
= ctx
->Pixel
.ColorTableBias
[0];
251 gBias
= ctx
->Pixel
.ColorTableBias
[1];
252 bBias
= ctx
->Pixel
.ColorTableBias
[2];
253 aBias
= ctx
->Pixel
.ColorTableBias
[3];
255 case GL_PROXY_COLOR_TABLE
:
256 table
= &ctx
->ProxyColorTable
;
259 case GL_TEXTURE_COLOR_TABLE_SGI
:
260 if (!ctx
->Extensions
.SGI_texture_color_table
) {
261 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTable(target)");
264 table
= &(texUnit
->ColorTable
);
265 floatTable
= GL_TRUE
;
266 rScale
= ctx
->Pixel
.TextureColorTableScale
[0];
267 gScale
= ctx
->Pixel
.TextureColorTableScale
[1];
268 bScale
= ctx
->Pixel
.TextureColorTableScale
[2];
269 aScale
= ctx
->Pixel
.TextureColorTableScale
[3];
270 rBias
= ctx
->Pixel
.TextureColorTableBias
[0];
271 gBias
= ctx
->Pixel
.TextureColorTableBias
[1];
272 bBias
= ctx
->Pixel
.TextureColorTableBias
[2];
273 aBias
= ctx
->Pixel
.TextureColorTableBias
[3];
275 case GL_PROXY_TEXTURE_COLOR_TABLE_SGI
:
276 if (!ctx
->Extensions
.SGI_texture_color_table
) {
277 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTable(target)");
280 table
= &(texUnit
->ProxyColorTable
);
283 case GL_POST_CONVOLUTION_COLOR_TABLE
:
284 table
= &ctx
->PostConvolutionColorTable
;
285 floatTable
= GL_TRUE
;
286 rScale
= ctx
->Pixel
.PCCTscale
[0];
287 gScale
= ctx
->Pixel
.PCCTscale
[1];
288 bScale
= ctx
->Pixel
.PCCTscale
[2];
289 aScale
= ctx
->Pixel
.PCCTscale
[3];
290 rBias
= ctx
->Pixel
.PCCTbias
[0];
291 gBias
= ctx
->Pixel
.PCCTbias
[1];
292 bBias
= ctx
->Pixel
.PCCTbias
[2];
293 aBias
= ctx
->Pixel
.PCCTbias
[3];
295 case GL_PROXY_POST_CONVOLUTION_COLOR_TABLE
:
296 table
= &ctx
->ProxyPostConvolutionColorTable
;
299 case GL_POST_COLOR_MATRIX_COLOR_TABLE
:
300 table
= &ctx
->PostColorMatrixColorTable
;
301 floatTable
= GL_TRUE
;
302 rScale
= ctx
->Pixel
.PCMCTscale
[0];
303 gScale
= ctx
->Pixel
.PCMCTscale
[1];
304 bScale
= ctx
->Pixel
.PCMCTscale
[2];
305 aScale
= ctx
->Pixel
.PCMCTscale
[3];
306 rBias
= ctx
->Pixel
.PCMCTbias
[0];
307 gBias
= ctx
->Pixel
.PCMCTbias
[1];
308 bBias
= ctx
->Pixel
.PCMCTbias
[2];
309 aBias
= ctx
->Pixel
.PCMCTbias
[3];
311 case GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE
:
312 table
= &ctx
->ProxyPostColorMatrixColorTable
;
316 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTable(target)");
322 if (!_mesa_is_legal_format_and_type(format
, type
) ||
323 format
== GL_INTENSITY
) {
324 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glColorTable(format or type)");
328 baseFormat
= base_colortab_format(internalFormat
);
329 if (baseFormat
< 0 || baseFormat
== GL_COLOR_INDEX
) {
330 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTable(internalFormat)");
334 if (width
< 0 || (width
!= 0 && _mesa_bitcount(width
) != 1)) {
338 table
->IntFormat
= (GLenum
) 0;
339 table
->Format
= (GLenum
) 0;
342 _mesa_error(ctx
, GL_INVALID_VALUE
, "glColorTable(width=%d)", width
);
347 if (width
> (GLsizei
) ctx
->Const
.MaxColorTableSize
) {
350 table
->IntFormat
= (GLenum
) 0;
351 table
->Format
= (GLenum
) 0;
354 _mesa_error(ctx
, GL_TABLE_TOO_LARGE
, "glColorTable(width)");
360 table
->IntFormat
= internalFormat
;
361 table
->Format
= (GLenum
) baseFormat
;
362 set_component_sizes(table
);
364 comps
= _mesa_components_in_format(table
->Format
);
365 assert(comps
> 0); /* error should have been caught sooner */
368 /* free old table, if any */
375 GLfloat tempTab
[MAX_COLOR_TABLE_SIZE
* 4];
379 _mesa_unpack_float_color_span(ctx
, width
, table
->Format
,
381 format
, type
, data
, &ctx
->Unpack
,
384 table
->FloatTable
= GL_TRUE
;
385 table
->Table
= MALLOC(comps
* width
* sizeof(GLfloat
));
387 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glColorTable");
391 tableF
= (GLfloat
*) table
->Table
;
393 switch (table
->Format
) {
395 for (i
= 0; i
< width
; i
++) {
396 tableF
[i
] = CLAMP(tempTab
[i
] * rScale
+ rBias
, 0.0F
, 1.0F
);
400 for (i
= 0; i
< width
; i
++) {
401 tableF
[i
] = CLAMP(tempTab
[i
] * rScale
+ rBias
, 0.0F
, 1.0F
);
405 for (i
= 0; i
< width
; i
++) {
406 tableF
[i
] = CLAMP(tempTab
[i
] * aScale
+ aBias
, 0.0F
, 1.0F
);
409 case GL_LUMINANCE_ALPHA
:
410 for (i
= 0; i
< width
; i
++) {
411 tableF
[i
*2+0] = CLAMP(tempTab
[i
*2+0] * rScale
+ rBias
, 0.0F
, 1.0F
);
412 tableF
[i
*2+1] = CLAMP(tempTab
[i
*2+1] * aScale
+ aBias
, 0.0F
, 1.0F
);
416 for (i
= 0; i
< width
; i
++) {
417 tableF
[i
*3+0] = CLAMP(tempTab
[i
*3+0] * rScale
+ rBias
, 0.0F
, 1.0F
);
418 tableF
[i
*3+1] = CLAMP(tempTab
[i
*3+1] * gScale
+ gBias
, 0.0F
, 1.0F
);
419 tableF
[i
*3+2] = CLAMP(tempTab
[i
*3+2] * bScale
+ bBias
, 0.0F
, 1.0F
);
423 for (i
= 0; i
< width
; i
++) {
424 tableF
[i
*4+0] = CLAMP(tempTab
[i
*4+0] * rScale
+ rBias
, 0.0F
, 1.0F
);
425 tableF
[i
*4+1] = CLAMP(tempTab
[i
*4+1] * gScale
+ gBias
, 0.0F
, 1.0F
);
426 tableF
[i
*4+2] = CLAMP(tempTab
[i
*4+2] * bScale
+ bBias
, 0.0F
, 1.0F
);
427 tableF
[i
*4+3] = CLAMP(tempTab
[i
*4+3] * aScale
+ aBias
, 0.0F
, 1.0F
);
431 _mesa_problem(ctx
, "Bad format in _mesa_ColorTable");
436 /* store GLchan table */
437 table
->FloatTable
= GL_FALSE
;
438 table
->Table
= MALLOC(comps
* width
* sizeof(GLchan
));
440 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glColorTable");
443 _mesa_unpack_chan_color_span(ctx
, width
, table
->Format
,
444 (GLchan
*) table
->Table
, /* dest */
451 if (texObj
|| target
== GL_SHARED_TEXTURE_PALETTE_EXT
) {
452 /* texture object palette, texObj==NULL means the shared palette */
453 if (ctx
->Driver
.UpdateTexturePalette
) {
454 (*ctx
->Driver
.UpdateTexturePalette
)( ctx
, texObj
);
458 ctx
->NewState
|= _NEW_PIXEL
;
464 _mesa_ColorSubTable( GLenum target
, GLsizei start
,
465 GLsizei count
, GLenum format
, GLenum type
,
468 GET_CURRENT_CONTEXT(ctx
);
469 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
470 struct gl_texture_object
*texObj
= NULL
;
471 struct gl_color_table
*table
= NULL
;
472 GLfloat rScale
= 1.0, gScale
= 1.0, bScale
= 1.0, aScale
= 1.0;
473 GLfloat rBias
= 0.0, gBias
= 0.0, bBias
= 0.0, aBias
= 0.0;
475 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
479 texObj
= texUnit
->Current1D
;
480 table
= &texObj
->Palette
;
483 texObj
= texUnit
->Current2D
;
484 table
= &texObj
->Palette
;
487 texObj
= texUnit
->Current3D
;
488 table
= &texObj
->Palette
;
490 case GL_TEXTURE_CUBE_MAP_ARB
:
491 if (!ctx
->Extensions
.ARB_texture_cube_map
) {
492 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorSubTable(target)");
495 texObj
= texUnit
->CurrentCubeMap
;
496 table
= &texObj
->Palette
;
498 case GL_SHARED_TEXTURE_PALETTE_EXT
:
499 table
= &ctx
->Texture
.Palette
;
502 table
= &ctx
->ColorTable
;
503 rScale
= ctx
->Pixel
.ColorTableScale
[0];
504 gScale
= ctx
->Pixel
.ColorTableScale
[1];
505 bScale
= ctx
->Pixel
.ColorTableScale
[2];
506 aScale
= ctx
->Pixel
.ColorTableScale
[3];
507 rBias
= ctx
->Pixel
.ColorTableBias
[0];
508 gBias
= ctx
->Pixel
.ColorTableBias
[1];
509 bBias
= ctx
->Pixel
.ColorTableBias
[2];
510 aBias
= ctx
->Pixel
.ColorTableBias
[3];
512 case GL_TEXTURE_COLOR_TABLE_SGI
:
513 if (!ctx
->Extensions
.SGI_texture_color_table
) {
514 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorSubTable(target)");
517 table
= &(texUnit
->ColorTable
);
518 rScale
= ctx
->Pixel
.TextureColorTableScale
[0];
519 gScale
= ctx
->Pixel
.TextureColorTableScale
[1];
520 bScale
= ctx
->Pixel
.TextureColorTableScale
[2];
521 aScale
= ctx
->Pixel
.TextureColorTableScale
[3];
522 rBias
= ctx
->Pixel
.TextureColorTableBias
[0];
523 gBias
= ctx
->Pixel
.TextureColorTableBias
[1];
524 bBias
= ctx
->Pixel
.TextureColorTableBias
[2];
525 aBias
= ctx
->Pixel
.TextureColorTableBias
[3];
527 case GL_POST_CONVOLUTION_COLOR_TABLE
:
528 table
= &ctx
->PostConvolutionColorTable
;
529 rScale
= ctx
->Pixel
.PCCTscale
[0];
530 gScale
= ctx
->Pixel
.PCCTscale
[1];
531 bScale
= ctx
->Pixel
.PCCTscale
[2];
532 aScale
= ctx
->Pixel
.PCCTscale
[3];
533 rBias
= ctx
->Pixel
.PCCTbias
[0];
534 gBias
= ctx
->Pixel
.PCCTbias
[1];
535 bBias
= ctx
->Pixel
.PCCTbias
[2];
536 aBias
= ctx
->Pixel
.PCCTbias
[3];
538 case GL_POST_COLOR_MATRIX_COLOR_TABLE
:
539 table
= &ctx
->PostColorMatrixColorTable
;
540 rScale
= ctx
->Pixel
.PCMCTscale
[0];
541 gScale
= ctx
->Pixel
.PCMCTscale
[1];
542 bScale
= ctx
->Pixel
.PCMCTscale
[2];
543 aScale
= ctx
->Pixel
.PCMCTscale
[3];
544 rBias
= ctx
->Pixel
.PCMCTbias
[0];
545 gBias
= ctx
->Pixel
.PCMCTbias
[1];
546 bBias
= ctx
->Pixel
.PCMCTbias
[2];
547 aBias
= ctx
->Pixel
.PCMCTbias
[3];
550 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorSubTable(target)");
556 if (!_mesa_is_legal_format_and_type(format
, type
) ||
557 format
== GL_INTENSITY
) {
558 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glColorSubTable(format or type)");
563 _mesa_error(ctx
, GL_INVALID_VALUE
, "glColorSubTable(count)");
567 comps
= _mesa_components_in_format(table
->Format
);
568 assert(comps
> 0); /* error should have been caught sooner */
570 if (start
+ count
> (GLint
) table
->Size
) {
571 _mesa_error(ctx
, GL_INVALID_VALUE
, "glColorSubTable(count)");
576 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glColorSubTable");
580 if (!table
->FloatTable
) {
581 GLchan
*dest
= (GLchan
*) table
->Table
+ start
* comps
* sizeof(GLchan
);
582 _mesa_unpack_chan_color_span(ctx
, count
, table
->Format
, dest
,
583 format
, type
, data
, &ctx
->Unpack
, 0);
586 GLfloat tempTab
[MAX_COLOR_TABLE_SIZE
* 4];
590 ASSERT(table
->FloatTable
);
592 _mesa_unpack_float_color_span(ctx
, count
, table
->Format
,
594 format
, type
, data
, &ctx
->Unpack
,
597 tableF
= (GLfloat
*) table
->Table
;
599 switch (table
->Format
) {
601 for (i
= 0; i
< count
; i
++) {
602 GLuint j
= start
+ i
;
603 tableF
[j
] = CLAMP(tempTab
[i
] * rScale
+ rBias
, 0.0F
, 1.0F
);
607 for (i
= 0; i
< count
; i
++) {
608 GLuint j
= start
+ i
;
609 tableF
[j
] = CLAMP(tempTab
[i
] * rScale
+ rBias
, 0.0F
, 1.0F
);
613 for (i
= 0; i
< count
; i
++) {
614 GLuint j
= start
+ i
;
615 tableF
[j
] = CLAMP(tempTab
[i
] * aScale
+ aBias
, 0.0F
, 1.0F
);
618 case GL_LUMINANCE_ALPHA
:
619 for (i
= 0; i
< count
; i
++) {
620 GLuint j
= start
+ i
;
621 tableF
[j
*2+0] = CLAMP(tempTab
[i
*2+0] * rScale
+ rBias
, 0.0F
, 1.0F
);
622 tableF
[j
*2+1] = CLAMP(tempTab
[i
*2+1] * aScale
+ aBias
, 0.0F
, 1.0F
);
626 for (i
= 0; i
< count
; i
++) {
627 GLuint j
= start
+ i
;
628 tableF
[j
*3+0] = CLAMP(tempTab
[i
*3+0] * rScale
+ rBias
, 0.0F
, 1.0F
);
629 tableF
[j
*3+1] = CLAMP(tempTab
[i
*3+1] * gScale
+ gBias
, 0.0F
, 1.0F
);
630 tableF
[j
*3+2] = CLAMP(tempTab
[i
*3+2] * bScale
+ bBias
, 0.0F
, 1.0F
);
634 for (i
= 0; i
< count
; i
++) {
635 GLuint j
= start
+ i
;
636 tableF
[j
*4+0] = CLAMP(tempTab
[i
*4+0] * rScale
+ rBias
, 0.0F
, 1.0F
);
637 tableF
[j
*4+1] = CLAMP(tempTab
[i
*4+1] * gScale
+ gBias
, 0.0F
, 1.0F
);
638 tableF
[j
*4+2] = CLAMP(tempTab
[i
*4+2] * bScale
+ bBias
, 0.0F
, 1.0F
);
639 tableF
[j
*4+3] = CLAMP(tempTab
[i
*4+3] * aScale
+ aBias
, 0.0F
, 1.0F
);
643 _mesa_problem(ctx
, "Bad format in _mesa_ColorSubTable");
648 if (texObj
|| target
== GL_SHARED_TEXTURE_PALETTE_EXT
) {
649 /* per-texture object palette */
650 if (ctx
->Driver
.UpdateTexturePalette
) {
651 (*ctx
->Driver
.UpdateTexturePalette
)( ctx
, texObj
);
655 ctx
->NewState
|= _NEW_PIXEL
;
662 _mesa_CopyColorTable(GLenum target
, GLenum internalformat
,
663 GLint x
, GLint y
, GLsizei width
)
665 GET_CURRENT_CONTEXT(ctx
);
666 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
668 /* Select buffer to read from */
669 ctx
->Driver
.CopyColorTable( ctx
, target
, internalformat
, x
, y
, width
);
676 _mesa_CopyColorSubTable(GLenum target
, GLsizei start
,
677 GLint x
, GLint y
, GLsizei width
)
679 GET_CURRENT_CONTEXT(ctx
);
680 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
682 ctx
->Driver
.CopyColorSubTable( ctx
, target
, start
, x
, y
, width
);
688 _mesa_GetColorTable( GLenum target
, GLenum format
,
689 GLenum type
, GLvoid
*data
)
691 GET_CURRENT_CONTEXT(ctx
);
692 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
693 struct gl_color_table
*table
= NULL
;
694 GLchan rgba
[MAX_COLOR_TABLE_SIZE
][4];
695 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
698 _mesa_update_state(ctx
);
703 table
= &texUnit
->Current1D
->Palette
;
706 table
= &texUnit
->Current2D
->Palette
;
709 table
= &texUnit
->Current3D
->Palette
;
711 case GL_TEXTURE_CUBE_MAP_ARB
:
712 if (!ctx
->Extensions
.ARB_texture_cube_map
) {
713 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTable(target)");
716 table
= &texUnit
->CurrentCubeMap
->Palette
;
718 case GL_SHARED_TEXTURE_PALETTE_EXT
:
719 table
= &ctx
->Texture
.Palette
;
722 table
= &ctx
->ColorTable
;
724 case GL_TEXTURE_COLOR_TABLE_SGI
:
725 if (!ctx
->Extensions
.SGI_texture_color_table
) {
726 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTable(target)");
729 table
= &(texUnit
->ColorTable
);
731 case GL_POST_CONVOLUTION_COLOR_TABLE
:
732 table
= &ctx
->PostConvolutionColorTable
;
734 case GL_POST_COLOR_MATRIX_COLOR_TABLE
:
735 table
= &ctx
->PostColorMatrixColorTable
;
738 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTable(target)");
744 switch (table
->Format
) {
746 if (table
->FloatTable
) {
747 const GLfloat
*tableF
= (const GLfloat
*) table
->Table
;
749 for (i
= 0; i
< table
->Size
; i
++) {
753 rgba
[i
][ACOMP
] = IROUND_POS(tableF
[i
] * CHAN_MAXF
);
757 const GLchan
*tableUB
= (const GLchan
*) table
->Table
;
759 for (i
= 0; i
< table
->Size
; i
++) {
763 rgba
[i
][ACOMP
] = tableUB
[i
];
768 if (table
->FloatTable
) {
769 const GLfloat
*tableF
= (const GLfloat
*) table
->Table
;
771 for (i
= 0; i
< table
->Size
; i
++) {
772 rgba
[i
][RCOMP
] = IROUND_POS(tableF
[i
] * CHAN_MAXF
);
773 rgba
[i
][GCOMP
] = IROUND_POS(tableF
[i
] * CHAN_MAXF
);
774 rgba
[i
][BCOMP
] = IROUND_POS(tableF
[i
] * CHAN_MAXF
);
775 rgba
[i
][ACOMP
] = CHAN_MAX
;
779 const GLchan
*tableUB
= (const GLchan
*) table
->Table
;
781 for (i
= 0; i
< table
->Size
; i
++) {
782 rgba
[i
][RCOMP
] = tableUB
[i
];
783 rgba
[i
][GCOMP
] = tableUB
[i
];
784 rgba
[i
][BCOMP
] = tableUB
[i
];
785 rgba
[i
][ACOMP
] = CHAN_MAX
;
789 case GL_LUMINANCE_ALPHA
:
790 if (table
->FloatTable
) {
791 const GLfloat
*tableF
= (const GLfloat
*) table
->Table
;
793 for (i
= 0; i
< table
->Size
; i
++) {
794 rgba
[i
][RCOMP
] = IROUND_POS(tableF
[i
*2+0] * CHAN_MAXF
);
795 rgba
[i
][GCOMP
] = IROUND_POS(tableF
[i
*2+0] * CHAN_MAXF
);
796 rgba
[i
][BCOMP
] = IROUND_POS(tableF
[i
*2+0] * CHAN_MAXF
);
797 rgba
[i
][ACOMP
] = IROUND_POS(tableF
[i
*2+1] * CHAN_MAXF
);
801 const GLchan
*tableUB
= (const GLchan
*) table
->Table
;
803 for (i
= 0; i
< table
->Size
; i
++) {
804 rgba
[i
][RCOMP
] = tableUB
[i
*2+0];
805 rgba
[i
][GCOMP
] = tableUB
[i
*2+0];
806 rgba
[i
][BCOMP
] = tableUB
[i
*2+0];
807 rgba
[i
][ACOMP
] = tableUB
[i
*2+1];
812 if (table
->FloatTable
) {
813 const GLfloat
*tableF
= (const GLfloat
*) table
->Table
;
815 for (i
= 0; i
< table
->Size
; i
++) {
816 rgba
[i
][RCOMP
] = IROUND_POS(tableF
[i
] * CHAN_MAXF
);
817 rgba
[i
][GCOMP
] = IROUND_POS(tableF
[i
] * CHAN_MAXF
);
818 rgba
[i
][BCOMP
] = IROUND_POS(tableF
[i
] * CHAN_MAXF
);
819 rgba
[i
][ACOMP
] = IROUND_POS(tableF
[i
] * CHAN_MAXF
);
823 const GLchan
*tableUB
= (const GLchan
*) table
->Table
;
825 for (i
= 0; i
< table
->Size
; i
++) {
826 rgba
[i
][RCOMP
] = tableUB
[i
];
827 rgba
[i
][GCOMP
] = tableUB
[i
];
828 rgba
[i
][BCOMP
] = tableUB
[i
];
829 rgba
[i
][ACOMP
] = tableUB
[i
];
834 if (table
->FloatTable
) {
835 const GLfloat
*tableF
= (const GLfloat
*) table
->Table
;
837 for (i
= 0; i
< table
->Size
; i
++) {
838 rgba
[i
][RCOMP
] = IROUND_POS(tableF
[i
*3+0] * CHAN_MAXF
);
839 rgba
[i
][GCOMP
] = IROUND_POS(tableF
[i
*3+1] * CHAN_MAXF
);
840 rgba
[i
][BCOMP
] = IROUND_POS(tableF
[i
*3+2] * CHAN_MAXF
);
841 rgba
[i
][ACOMP
] = CHAN_MAX
;
845 const GLchan
*tableUB
= (const GLchan
*) table
->Table
;
847 for (i
= 0; i
< table
->Size
; i
++) {
848 rgba
[i
][RCOMP
] = tableUB
[i
*3+0];
849 rgba
[i
][GCOMP
] = tableUB
[i
*3+1];
850 rgba
[i
][BCOMP
] = tableUB
[i
*3+2];
851 rgba
[i
][ACOMP
] = CHAN_MAX
;
856 if (table
->FloatTable
) {
857 const GLfloat
*tableF
= (const GLfloat
*) table
->Table
;
859 for (i
= 0; i
< table
->Size
; i
++) {
860 rgba
[i
][RCOMP
] = IROUND_POS(tableF
[i
*4+0] * CHAN_MAXF
);
861 rgba
[i
][GCOMP
] = IROUND_POS(tableF
[i
*4+1] * CHAN_MAXF
);
862 rgba
[i
][BCOMP
] = IROUND_POS(tableF
[i
*4+2] * CHAN_MAXF
);
863 rgba
[i
][ACOMP
] = IROUND_POS(tableF
[i
*4+3] * CHAN_MAXF
);
867 const GLchan
*tableUB
= (const GLchan
*) table
->Table
;
869 for (i
= 0; i
< table
->Size
; i
++) {
870 rgba
[i
][RCOMP
] = tableUB
[i
*4+0];
871 rgba
[i
][GCOMP
] = tableUB
[i
*4+1];
872 rgba
[i
][BCOMP
] = tableUB
[i
*4+2];
873 rgba
[i
][ACOMP
] = tableUB
[i
*4+3];
878 _mesa_problem(ctx
, "bad table format in glGetColorTable");
882 _mesa_pack_rgba_span(ctx
, table
->Size
, (const GLchan (*)[4]) rgba
,
883 format
, type
, data
, &ctx
->Pack
, GL_FALSE
);
889 _mesa_ColorTableParameterfv(GLenum target
, GLenum pname
, const GLfloat
*params
)
891 GET_CURRENT_CONTEXT(ctx
);
892 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
895 case GL_COLOR_TABLE_SGI
:
896 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
897 ctx
->Pixel
.ColorTableScale
[0] = params
[0];
898 ctx
->Pixel
.ColorTableScale
[1] = params
[1];
899 ctx
->Pixel
.ColorTableScale
[2] = params
[2];
900 ctx
->Pixel
.ColorTableScale
[3] = params
[3];
902 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
903 ctx
->Pixel
.ColorTableBias
[0] = params
[0];
904 ctx
->Pixel
.ColorTableBias
[1] = params
[1];
905 ctx
->Pixel
.ColorTableBias
[2] = params
[2];
906 ctx
->Pixel
.ColorTableBias
[3] = params
[3];
909 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTableParameterfv(pname)");
913 case GL_TEXTURE_COLOR_TABLE_SGI
:
914 if (!ctx
->Extensions
.SGI_texture_color_table
) {
915 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTableParameter(target)");
918 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
919 ctx
->Pixel
.TextureColorTableScale
[0] = params
[0];
920 ctx
->Pixel
.TextureColorTableScale
[1] = params
[1];
921 ctx
->Pixel
.TextureColorTableScale
[2] = params
[2];
922 ctx
->Pixel
.TextureColorTableScale
[3] = params
[3];
924 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
925 ctx
->Pixel
.TextureColorTableBias
[0] = params
[0];
926 ctx
->Pixel
.TextureColorTableBias
[1] = params
[1];
927 ctx
->Pixel
.TextureColorTableBias
[2] = params
[2];
928 ctx
->Pixel
.TextureColorTableBias
[3] = params
[3];
931 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTableParameterfv(pname)");
935 case GL_POST_CONVOLUTION_COLOR_TABLE_SGI
:
936 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
937 ctx
->Pixel
.PCCTscale
[0] = params
[0];
938 ctx
->Pixel
.PCCTscale
[1] = params
[1];
939 ctx
->Pixel
.PCCTscale
[2] = params
[2];
940 ctx
->Pixel
.PCCTscale
[3] = params
[3];
942 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
943 ctx
->Pixel
.PCCTbias
[0] = params
[0];
944 ctx
->Pixel
.PCCTbias
[1] = params
[1];
945 ctx
->Pixel
.PCCTbias
[2] = params
[2];
946 ctx
->Pixel
.PCCTbias
[3] = params
[3];
949 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTableParameterfv(pname)");
953 case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI
:
954 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
955 ctx
->Pixel
.PCMCTscale
[0] = params
[0];
956 ctx
->Pixel
.PCMCTscale
[1] = params
[1];
957 ctx
->Pixel
.PCMCTscale
[2] = params
[2];
958 ctx
->Pixel
.PCMCTscale
[3] = params
[3];
960 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
961 ctx
->Pixel
.PCMCTbias
[0] = params
[0];
962 ctx
->Pixel
.PCMCTbias
[1] = params
[1];
963 ctx
->Pixel
.PCMCTbias
[2] = params
[2];
964 ctx
->Pixel
.PCMCTbias
[3] = params
[3];
967 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTableParameterfv(pname)");
972 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTableParameter(target)");
976 ctx
->NewState
|= _NEW_PIXEL
;
982 _mesa_ColorTableParameteriv(GLenum target
, GLenum pname
, const GLint
*params
)
985 if (pname
== GL_COLOR_TABLE_SGI
||
986 pname
== GL_TEXTURE_COLOR_TABLE_SGI
||
987 pname
== GL_POST_CONVOLUTION_COLOR_TABLE_SGI
||
988 pname
== GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI
) {
990 fparams
[0] = (GLfloat
) params
[0];
991 fparams
[1] = (GLfloat
) params
[1];
992 fparams
[2] = (GLfloat
) params
[2];
993 fparams
[3] = (GLfloat
) params
[3];
997 fparams
[0] = (GLfloat
) params
[0];
999 _mesa_ColorTableParameterfv(target
, pname
, fparams
);
1005 _mesa_GetColorTableParameterfv( GLenum target
, GLenum pname
, GLfloat
*params
)
1007 GET_CURRENT_CONTEXT(ctx
);
1008 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1009 struct gl_color_table
*table
= NULL
;
1010 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1014 table
= &texUnit
->Current1D
->Palette
;
1017 table
= &texUnit
->Current2D
->Palette
;
1020 table
= &texUnit
->Current3D
->Palette
;
1022 case GL_TEXTURE_CUBE_MAP_ARB
:
1023 if (!ctx
->Extensions
.ARB_texture_cube_map
) {
1024 _mesa_error(ctx
, GL_INVALID_ENUM
,
1025 "glGetColorTableParameterfv(target)");
1028 table
= &texUnit
->CurrentCubeMap
->Palette
;
1030 case GL_PROXY_TEXTURE_1D
:
1031 table
= &ctx
->Texture
.Proxy1D
->Palette
;
1033 case GL_PROXY_TEXTURE_2D
:
1034 table
= &ctx
->Texture
.Proxy2D
->Palette
;
1036 case GL_PROXY_TEXTURE_3D
:
1037 table
= &ctx
->Texture
.Proxy3D
->Palette
;
1039 case GL_PROXY_TEXTURE_CUBE_MAP_ARB
:
1040 if (!ctx
->Extensions
.ARB_texture_cube_map
) {
1041 _mesa_error(ctx
, GL_INVALID_ENUM
,
1042 "glGetColorTableParameterfv(target)");
1045 table
= &ctx
->Texture
.ProxyCubeMap
->Palette
;
1047 case GL_SHARED_TEXTURE_PALETTE_EXT
:
1048 table
= &ctx
->Texture
.Palette
;
1050 case GL_COLOR_TABLE
:
1051 table
= &ctx
->ColorTable
;
1052 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
1053 params
[0] = ctx
->Pixel
.ColorTableScale
[0];
1054 params
[1] = ctx
->Pixel
.ColorTableScale
[1];
1055 params
[2] = ctx
->Pixel
.ColorTableScale
[2];
1056 params
[3] = ctx
->Pixel
.ColorTableScale
[3];
1059 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
1060 params
[0] = ctx
->Pixel
.ColorTableBias
[0];
1061 params
[1] = ctx
->Pixel
.ColorTableBias
[1];
1062 params
[2] = ctx
->Pixel
.ColorTableBias
[2];
1063 params
[3] = ctx
->Pixel
.ColorTableBias
[3];
1067 case GL_PROXY_COLOR_TABLE
:
1068 table
= &ctx
->ProxyColorTable
;
1070 case GL_TEXTURE_COLOR_TABLE_SGI
:
1071 if (!ctx
->Extensions
.SGI_texture_color_table
) {
1072 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameter(target)");
1075 table
= &(texUnit
->ColorTable
);
1076 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
1077 params
[0] = ctx
->Pixel
.TextureColorTableScale
[0];
1078 params
[1] = ctx
->Pixel
.TextureColorTableScale
[1];
1079 params
[2] = ctx
->Pixel
.TextureColorTableScale
[2];
1080 params
[3] = ctx
->Pixel
.TextureColorTableScale
[3];
1083 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
1084 params
[0] = ctx
->Pixel
.TextureColorTableBias
[0];
1085 params
[1] = ctx
->Pixel
.TextureColorTableBias
[1];
1086 params
[2] = ctx
->Pixel
.TextureColorTableBias
[2];
1087 params
[3] = ctx
->Pixel
.TextureColorTableBias
[3];
1091 case GL_PROXY_TEXTURE_COLOR_TABLE_SGI
:
1092 if (!ctx
->Extensions
.SGI_texture_color_table
) {
1093 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameter(target)");
1096 table
= &(texUnit
->ProxyColorTable
);
1098 case GL_POST_CONVOLUTION_COLOR_TABLE
:
1099 table
= &ctx
->PostConvolutionColorTable
;
1100 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
1101 params
[0] = ctx
->Pixel
.PCCTscale
[0];
1102 params
[1] = ctx
->Pixel
.PCCTscale
[1];
1103 params
[2] = ctx
->Pixel
.PCCTscale
[2];
1104 params
[3] = ctx
->Pixel
.PCCTscale
[3];
1107 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
1108 params
[0] = ctx
->Pixel
.PCCTbias
[0];
1109 params
[1] = ctx
->Pixel
.PCCTbias
[1];
1110 params
[2] = ctx
->Pixel
.PCCTbias
[2];
1111 params
[3] = ctx
->Pixel
.PCCTbias
[3];
1115 case GL_PROXY_POST_CONVOLUTION_COLOR_TABLE
:
1116 table
= &ctx
->ProxyPostConvolutionColorTable
;
1118 case GL_POST_COLOR_MATRIX_COLOR_TABLE
:
1119 table
= &ctx
->PostColorMatrixColorTable
;
1120 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
1121 params
[0] = ctx
->Pixel
.PCMCTscale
[0];
1122 params
[1] = ctx
->Pixel
.PCMCTscale
[1];
1123 params
[2] = ctx
->Pixel
.PCMCTscale
[2];
1124 params
[3] = ctx
->Pixel
.PCMCTscale
[3];
1127 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
1128 params
[0] = ctx
->Pixel
.PCMCTbias
[0];
1129 params
[1] = ctx
->Pixel
.PCMCTbias
[1];
1130 params
[2] = ctx
->Pixel
.PCMCTbias
[2];
1131 params
[3] = ctx
->Pixel
.PCMCTbias
[3];
1135 case GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE
:
1136 table
= &ctx
->ProxyPostColorMatrixColorTable
;
1139 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameterfv(target)");
1146 case GL_COLOR_TABLE_FORMAT
:
1147 *params
= (GLfloat
) table
->IntFormat
;
1149 case GL_COLOR_TABLE_WIDTH
:
1150 *params
= (GLfloat
) table
->Size
;
1152 case GL_COLOR_TABLE_RED_SIZE
:
1153 *params
= (GLfloat
) table
->RedSize
;
1155 case GL_COLOR_TABLE_GREEN_SIZE
:
1156 *params
= (GLfloat
) table
->GreenSize
;
1158 case GL_COLOR_TABLE_BLUE_SIZE
:
1159 *params
= (GLfloat
) table
->BlueSize
;
1161 case GL_COLOR_TABLE_ALPHA_SIZE
:
1162 *params
= (GLfloat
) table
->AlphaSize
;
1164 case GL_COLOR_TABLE_LUMINANCE_SIZE
:
1165 *params
= (GLfloat
) table
->LuminanceSize
;
1167 case GL_COLOR_TABLE_INTENSITY_SIZE
:
1168 *params
= (GLfloat
) table
->IntensitySize
;
1171 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameterfv(pname)" );
1179 _mesa_GetColorTableParameteriv( GLenum target
, GLenum pname
, GLint
*params
)
1181 GET_CURRENT_CONTEXT(ctx
);
1182 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1183 struct gl_color_table
*table
= NULL
;
1184 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1188 table
= &texUnit
->Current1D
->Palette
;
1191 table
= &texUnit
->Current2D
->Palette
;
1194 table
= &texUnit
->Current3D
->Palette
;
1196 case GL_TEXTURE_CUBE_MAP_ARB
:
1197 if (!ctx
->Extensions
.ARB_texture_cube_map
) {
1198 _mesa_error(ctx
, GL_INVALID_ENUM
,
1199 "glGetColorTableParameteriv(target)");
1202 table
= &texUnit
->CurrentCubeMap
->Palette
;
1204 case GL_PROXY_TEXTURE_1D
:
1205 table
= &ctx
->Texture
.Proxy1D
->Palette
;
1207 case GL_PROXY_TEXTURE_2D
:
1208 table
= &ctx
->Texture
.Proxy2D
->Palette
;
1210 case GL_PROXY_TEXTURE_3D
:
1211 table
= &ctx
->Texture
.Proxy3D
->Palette
;
1213 case GL_PROXY_TEXTURE_CUBE_MAP_ARB
:
1214 if (!ctx
->Extensions
.ARB_texture_cube_map
) {
1215 _mesa_error(ctx
, GL_INVALID_ENUM
,
1216 "glGetColorTableParameteriv(target)");
1219 table
= &ctx
->Texture
.ProxyCubeMap
->Palette
;
1221 case GL_SHARED_TEXTURE_PALETTE_EXT
:
1222 table
= &ctx
->Texture
.Palette
;
1224 case GL_COLOR_TABLE
:
1225 table
= &ctx
->ColorTable
;
1226 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
1227 params
[0] = (GLint
) ctx
->Pixel
.ColorTableScale
[0];
1228 params
[1] = (GLint
) ctx
->Pixel
.ColorTableScale
[1];
1229 params
[2] = (GLint
) ctx
->Pixel
.ColorTableScale
[2];
1230 params
[3] = (GLint
) ctx
->Pixel
.ColorTableScale
[3];
1233 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
1234 params
[0] = (GLint
) ctx
->Pixel
.ColorTableBias
[0];
1235 params
[1] = (GLint
) ctx
->Pixel
.ColorTableBias
[1];
1236 params
[2] = (GLint
) ctx
->Pixel
.ColorTableBias
[2];
1237 params
[3] = (GLint
) ctx
->Pixel
.ColorTableBias
[3];
1241 case GL_PROXY_COLOR_TABLE
:
1242 table
= &ctx
->ProxyColorTable
;
1244 case GL_TEXTURE_COLOR_TABLE_SGI
:
1245 if (!ctx
->Extensions
.SGI_texture_color_table
) {
1246 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameter(target)");
1249 table
= &(texUnit
->ColorTable
);
1250 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
1251 params
[0] = (GLint
) ctx
->Pixel
.TextureColorTableScale
[0];
1252 params
[1] = (GLint
) ctx
->Pixel
.TextureColorTableScale
[1];
1253 params
[2] = (GLint
) ctx
->Pixel
.TextureColorTableScale
[2];
1254 params
[3] = (GLint
) ctx
->Pixel
.TextureColorTableScale
[3];
1257 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
1258 params
[0] = (GLint
) ctx
->Pixel
.TextureColorTableBias
[0];
1259 params
[1] = (GLint
) ctx
->Pixel
.TextureColorTableBias
[1];
1260 params
[2] = (GLint
) ctx
->Pixel
.TextureColorTableBias
[2];
1261 params
[3] = (GLint
) ctx
->Pixel
.TextureColorTableBias
[3];
1265 case GL_PROXY_TEXTURE_COLOR_TABLE_SGI
:
1266 if (!ctx
->Extensions
.SGI_texture_color_table
) {
1267 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameter(target)");
1270 table
= &(texUnit
->ProxyColorTable
);
1272 case GL_POST_CONVOLUTION_COLOR_TABLE
:
1273 table
= &ctx
->PostConvolutionColorTable
;
1274 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
1275 params
[0] = (GLint
) ctx
->Pixel
.PCCTscale
[0];
1276 params
[1] = (GLint
) ctx
->Pixel
.PCCTscale
[1];
1277 params
[2] = (GLint
) ctx
->Pixel
.PCCTscale
[2];
1278 params
[3] = (GLint
) ctx
->Pixel
.PCCTscale
[3];
1281 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
1282 params
[0] = (GLint
) ctx
->Pixel
.PCCTbias
[0];
1283 params
[1] = (GLint
) ctx
->Pixel
.PCCTbias
[1];
1284 params
[2] = (GLint
) ctx
->Pixel
.PCCTbias
[2];
1285 params
[3] = (GLint
) ctx
->Pixel
.PCCTbias
[3];
1289 case GL_PROXY_POST_CONVOLUTION_COLOR_TABLE
:
1290 table
= &ctx
->ProxyPostConvolutionColorTable
;
1292 case GL_POST_COLOR_MATRIX_COLOR_TABLE
:
1293 table
= &ctx
->PostColorMatrixColorTable
;
1294 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
1295 params
[0] = (GLint
) ctx
->Pixel
.PCMCTscale
[0];
1296 params
[1] = (GLint
) ctx
->Pixel
.PCMCTscale
[1];
1297 params
[2] = (GLint
) ctx
->Pixel
.PCMCTscale
[2];
1298 params
[3] = (GLint
) ctx
->Pixel
.PCMCTscale
[3];
1301 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
1302 params
[0] = (GLint
) ctx
->Pixel
.PCMCTbias
[0];
1303 params
[1] = (GLint
) ctx
->Pixel
.PCMCTbias
[1];
1304 params
[2] = (GLint
) ctx
->Pixel
.PCMCTbias
[2];
1305 params
[3] = (GLint
) ctx
->Pixel
.PCMCTbias
[3];
1309 case GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE
:
1310 table
= &ctx
->ProxyPostColorMatrixColorTable
;
1313 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameteriv(target)");
1320 case GL_COLOR_TABLE_FORMAT
:
1321 *params
= table
->IntFormat
;
1323 case GL_COLOR_TABLE_WIDTH
:
1324 *params
= table
->Size
;
1326 case GL_COLOR_TABLE_RED_SIZE
:
1327 *params
= table
->RedSize
;
1329 case GL_COLOR_TABLE_GREEN_SIZE
:
1330 *params
= table
->GreenSize
;
1332 case GL_COLOR_TABLE_BLUE_SIZE
:
1333 *params
= table
->BlueSize
;
1335 case GL_COLOR_TABLE_ALPHA_SIZE
:
1336 *params
= table
->AlphaSize
;
1338 case GL_COLOR_TABLE_LUMINANCE_SIZE
:
1339 *params
= table
->LuminanceSize
;
1341 case GL_COLOR_TABLE_INTENSITY_SIZE
:
1342 *params
= table
->IntensitySize
;
1345 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameteriv(pname)" );