1 /* $Id: colortab.c,v 1.47 2003/01/21 21:47:45 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.
39 * Given an internalFormat token passed to glColorTable,
40 * return the corresponding base format.
41 * Return -1 if invalid token.
44 base_colortab_format( GLenum format
)
59 case GL_LUMINANCE_ALPHA
:
60 case GL_LUMINANCE4_ALPHA4
:
61 case GL_LUMINANCE6_ALPHA2
:
62 case GL_LUMINANCE8_ALPHA8
:
63 case GL_LUMINANCE12_ALPHA4
:
64 case GL_LUMINANCE12_ALPHA12
:
65 case GL_LUMINANCE16_ALPHA16
:
66 return GL_LUMINANCE_ALPHA
;
92 return -1; /* error */
98 _mesa_init_colortable( struct gl_color_table
*p
)
100 p
->FloatTable
= GL_FALSE
;
103 p
->IntFormat
= GL_RGBA
;
109 _mesa_free_colortable_data( struct gl_color_table
*p
)
119 * Examine table's format and set the component sizes accordingly.
122 set_component_sizes( struct gl_color_table
*table
)
124 switch (table
->Format
) {
127 table
->GreenSize
= 0;
129 table
->AlphaSize
= CHAN_BITS
;
130 table
->IntensitySize
= 0;
131 table
->LuminanceSize
= 0;
135 table
->GreenSize
= 0;
137 table
->AlphaSize
= 0;
138 table
->IntensitySize
= 0;
139 table
->LuminanceSize
= CHAN_BITS
;
141 case GL_LUMINANCE_ALPHA
:
143 table
->GreenSize
= 0;
145 table
->AlphaSize
= CHAN_BITS
;
146 table
->IntensitySize
= 0;
147 table
->LuminanceSize
= CHAN_BITS
;
151 table
->GreenSize
= 0;
153 table
->AlphaSize
= 0;
154 table
->IntensitySize
= CHAN_BITS
;
155 table
->LuminanceSize
= 0;
158 table
->RedSize
= CHAN_BITS
;
159 table
->GreenSize
= CHAN_BITS
;
160 table
->BlueSize
= CHAN_BITS
;
161 table
->AlphaSize
= 0;
162 table
->IntensitySize
= 0;
163 table
->LuminanceSize
= 0;
166 table
->RedSize
= CHAN_BITS
;
167 table
->GreenSize
= CHAN_BITS
;
168 table
->BlueSize
= CHAN_BITS
;
169 table
->AlphaSize
= CHAN_BITS
;
170 table
->IntensitySize
= 0;
171 table
->LuminanceSize
= 0;
174 _mesa_problem(NULL
, "unexpected format in set_component_sizes");
181 _mesa_ColorTable( GLenum target
, GLenum internalFormat
,
182 GLsizei width
, GLenum format
, GLenum type
,
185 GET_CURRENT_CONTEXT(ctx
);
186 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
187 struct gl_texture_object
*texObj
= NULL
;
188 struct gl_color_table
*table
= NULL
;
189 GLboolean proxy
= GL_FALSE
;
191 GLfloat rScale
= 1.0, gScale
= 1.0, bScale
= 1.0, aScale
= 1.0;
192 GLfloat rBias
= 0.0, gBias
= 0.0, bBias
= 0.0, aBias
= 0.0;
193 GLboolean floatTable
= GL_FALSE
;
195 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
); /* too complex */
199 texObj
= texUnit
->Current1D
;
200 table
= &texObj
->Palette
;
203 texObj
= texUnit
->Current2D
;
204 table
= &texObj
->Palette
;
207 texObj
= texUnit
->Current3D
;
208 table
= &texObj
->Palette
;
210 case GL_TEXTURE_CUBE_MAP_ARB
:
211 if (!ctx
->Extensions
.ARB_texture_cube_map
) {
212 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTable(target)");
215 texObj
= texUnit
->CurrentCubeMap
;
216 table
= &texObj
->Palette
;
218 case GL_PROXY_TEXTURE_1D
:
219 texObj
= ctx
->Texture
.Proxy1D
;
220 table
= &texObj
->Palette
;
223 case GL_PROXY_TEXTURE_2D
:
224 texObj
= ctx
->Texture
.Proxy2D
;
225 table
= &texObj
->Palette
;
228 case GL_PROXY_TEXTURE_3D
:
229 texObj
= ctx
->Texture
.Proxy3D
;
230 table
= &texObj
->Palette
;
233 case GL_PROXY_TEXTURE_CUBE_MAP_ARB
:
234 if (!ctx
->Extensions
.ARB_texture_cube_map
) {
235 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTable(target)");
238 texObj
= ctx
->Texture
.ProxyCubeMap
;
239 table
= &texObj
->Palette
;
241 case GL_SHARED_TEXTURE_PALETTE_EXT
:
242 table
= &ctx
->Texture
.Palette
;
245 table
= &ctx
->ColorTable
;
246 floatTable
= GL_TRUE
;
247 rScale
= ctx
->Pixel
.ColorTableScale
[0];
248 gScale
= ctx
->Pixel
.ColorTableScale
[1];
249 bScale
= ctx
->Pixel
.ColorTableScale
[2];
250 aScale
= ctx
->Pixel
.ColorTableScale
[3];
251 rBias
= ctx
->Pixel
.ColorTableBias
[0];
252 gBias
= ctx
->Pixel
.ColorTableBias
[1];
253 bBias
= ctx
->Pixel
.ColorTableBias
[2];
254 aBias
= ctx
->Pixel
.ColorTableBias
[3];
256 case GL_PROXY_COLOR_TABLE
:
257 table
= &ctx
->ProxyColorTable
;
260 case GL_TEXTURE_COLOR_TABLE_SGI
:
261 if (!ctx
->Extensions
.SGI_texture_color_table
) {
262 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTable(target)");
265 table
= &ctx
->TextureColorTable
;
266 floatTable
= GL_TRUE
;
267 rScale
= ctx
->Texture
.ColorTableScale
[0];
268 gScale
= ctx
->Texture
.ColorTableScale
[1];
269 bScale
= ctx
->Texture
.ColorTableScale
[2];
270 aScale
= ctx
->Texture
.ColorTableScale
[3];
271 rBias
= ctx
->Texture
.ColorTableBias
[0];
272 gBias
= ctx
->Texture
.ColorTableBias
[1];
273 bBias
= ctx
->Texture
.ColorTableBias
[2];
274 aBias
= ctx
->Texture
.ColorTableBias
[3];
276 case GL_PROXY_TEXTURE_COLOR_TABLE_SGI
:
277 if (!ctx
->Extensions
.SGI_texture_color_table
) {
278 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTable(target)");
281 table
= &ctx
->ProxyTextureColorTable
;
284 case GL_POST_CONVOLUTION_COLOR_TABLE
:
285 table
= &ctx
->PostConvolutionColorTable
;
286 floatTable
= GL_TRUE
;
287 rScale
= ctx
->Pixel
.PCCTscale
[0];
288 gScale
= ctx
->Pixel
.PCCTscale
[1];
289 bScale
= ctx
->Pixel
.PCCTscale
[2];
290 aScale
= ctx
->Pixel
.PCCTscale
[3];
291 rBias
= ctx
->Pixel
.PCCTbias
[0];
292 gBias
= ctx
->Pixel
.PCCTbias
[1];
293 bBias
= ctx
->Pixel
.PCCTbias
[2];
294 aBias
= ctx
->Pixel
.PCCTbias
[3];
296 case GL_PROXY_POST_CONVOLUTION_COLOR_TABLE
:
297 table
= &ctx
->ProxyPostConvolutionColorTable
;
300 case GL_POST_COLOR_MATRIX_COLOR_TABLE
:
301 table
= &ctx
->PostColorMatrixColorTable
;
302 floatTable
= GL_TRUE
;
303 rScale
= ctx
->Pixel
.PCMCTscale
[0];
304 gScale
= ctx
->Pixel
.PCMCTscale
[1];
305 bScale
= ctx
->Pixel
.PCMCTscale
[2];
306 aScale
= ctx
->Pixel
.PCMCTscale
[3];
307 rBias
= ctx
->Pixel
.PCMCTbias
[0];
308 gBias
= ctx
->Pixel
.PCMCTbias
[1];
309 bBias
= ctx
->Pixel
.PCMCTbias
[2];
310 aBias
= ctx
->Pixel
.PCMCTbias
[3];
312 case GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE
:
313 table
= &ctx
->ProxyPostColorMatrixColorTable
;
317 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTable(target)");
323 if (!_mesa_is_legal_format_and_type(format
, type
) ||
324 format
== GL_INTENSITY
) {
325 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glColorTable(format or type)");
329 baseFormat
= base_colortab_format(internalFormat
);
330 if (baseFormat
< 0 || baseFormat
== GL_COLOR_INDEX
) {
331 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTable(internalFormat)");
335 if (width
< 0 || (width
!= 0 && _mesa_bitcount(width
) != 1)) {
339 table
->IntFormat
= (GLenum
) 0;
340 table
->Format
= (GLenum
) 0;
343 _mesa_error(ctx
, GL_INVALID_VALUE
, "glColorTable(width=%d)", width
);
348 if (width
> (GLsizei
) ctx
->Const
.MaxColorTableSize
) {
351 table
->IntFormat
= (GLenum
) 0;
352 table
->Format
= (GLenum
) 0;
355 _mesa_error(ctx
, GL_TABLE_TOO_LARGE
, "glColorTable(width)");
361 table
->IntFormat
= internalFormat
;
362 table
->Format
= (GLenum
) baseFormat
;
363 set_component_sizes(table
);
365 comps
= _mesa_components_in_format(table
->Format
);
366 assert(comps
> 0); /* error should have been caught sooner */
369 /* free old table, if any */
376 GLfloat tempTab
[MAX_COLOR_TABLE_SIZE
* 4];
380 _mesa_unpack_float_color_span(ctx
, width
, table
->Format
,
382 format
, type
, data
, &ctx
->Unpack
,
385 table
->FloatTable
= GL_TRUE
;
386 table
->Table
= MALLOC(comps
* width
* sizeof(GLfloat
));
388 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glColorTable");
392 tableF
= (GLfloat
*) table
->Table
;
394 switch (table
->Format
) {
396 for (i
= 0; i
< width
; i
++) {
397 tableF
[i
] = CLAMP(tempTab
[i
] * rScale
+ rBias
, 0.0F
, 1.0F
);
401 for (i
= 0; i
< width
; i
++) {
402 tableF
[i
] = CLAMP(tempTab
[i
] * rScale
+ rBias
, 0.0F
, 1.0F
);
406 for (i
= 0; i
< width
; i
++) {
407 tableF
[i
] = CLAMP(tempTab
[i
] * aScale
+ aBias
, 0.0F
, 1.0F
);
410 case GL_LUMINANCE_ALPHA
:
411 for (i
= 0; i
< width
; i
++) {
412 tableF
[i
*2+0] = CLAMP(tempTab
[i
*2+0] * rScale
+ rBias
, 0.0F
, 1.0F
);
413 tableF
[i
*2+1] = CLAMP(tempTab
[i
*2+1] * aScale
+ aBias
, 0.0F
, 1.0F
);
417 for (i
= 0; i
< width
; i
++) {
418 tableF
[i
*3+0] = CLAMP(tempTab
[i
*3+0] * rScale
+ rBias
, 0.0F
, 1.0F
);
419 tableF
[i
*3+1] = CLAMP(tempTab
[i
*3+1] * gScale
+ gBias
, 0.0F
, 1.0F
);
420 tableF
[i
*3+2] = CLAMP(tempTab
[i
*3+2] * bScale
+ bBias
, 0.0F
, 1.0F
);
424 for (i
= 0; i
< width
; i
++) {
425 tableF
[i
*4+0] = CLAMP(tempTab
[i
*4+0] * rScale
+ rBias
, 0.0F
, 1.0F
);
426 tableF
[i
*4+1] = CLAMP(tempTab
[i
*4+1] * gScale
+ gBias
, 0.0F
, 1.0F
);
427 tableF
[i
*4+2] = CLAMP(tempTab
[i
*4+2] * bScale
+ bBias
, 0.0F
, 1.0F
);
428 tableF
[i
*4+3] = CLAMP(tempTab
[i
*4+3] * aScale
+ aBias
, 0.0F
, 1.0F
);
432 _mesa_problem(ctx
, "Bad format in _mesa_ColorTable");
437 /* store GLchan table */
438 table
->FloatTable
= GL_FALSE
;
439 table
->Table
= MALLOC(comps
* width
* sizeof(GLchan
));
441 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glColorTable");
444 _mesa_unpack_chan_color_span(ctx
, width
, table
->Format
,
445 (GLchan
*) table
->Table
, /* dest */
452 if (texObj
|| target
== GL_SHARED_TEXTURE_PALETTE_EXT
) {
453 /* texture object palette, texObj==NULL means the shared palette */
454 if (ctx
->Driver
.UpdateTexturePalette
) {
455 (*ctx
->Driver
.UpdateTexturePalette
)( ctx
, texObj
);
459 ctx
->NewState
|= _NEW_PIXEL
;
465 _mesa_ColorSubTable( GLenum target
, GLsizei start
,
466 GLsizei count
, GLenum format
, GLenum type
,
469 GET_CURRENT_CONTEXT(ctx
);
470 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
471 struct gl_texture_object
*texObj
= NULL
;
472 struct gl_color_table
*table
= NULL
;
473 GLfloat rScale
= 1.0, gScale
= 1.0, bScale
= 1.0, aScale
= 1.0;
474 GLfloat rBias
= 0.0, gBias
= 0.0, bBias
= 0.0, aBias
= 0.0;
476 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
480 texObj
= texUnit
->Current1D
;
481 table
= &texObj
->Palette
;
484 texObj
= texUnit
->Current2D
;
485 table
= &texObj
->Palette
;
488 texObj
= texUnit
->Current3D
;
489 table
= &texObj
->Palette
;
491 case GL_TEXTURE_CUBE_MAP_ARB
:
492 if (!ctx
->Extensions
.ARB_texture_cube_map
) {
493 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorSubTable(target)");
496 texObj
= texUnit
->CurrentCubeMap
;
497 table
= &texObj
->Palette
;
499 case GL_SHARED_TEXTURE_PALETTE_EXT
:
500 table
= &ctx
->Texture
.Palette
;
503 table
= &ctx
->ColorTable
;
504 rScale
= ctx
->Pixel
.ColorTableScale
[0];
505 gScale
= ctx
->Pixel
.ColorTableScale
[1];
506 bScale
= ctx
->Pixel
.ColorTableScale
[2];
507 aScale
= ctx
->Pixel
.ColorTableScale
[3];
508 rBias
= ctx
->Pixel
.ColorTableBias
[0];
509 gBias
= ctx
->Pixel
.ColorTableBias
[1];
510 bBias
= ctx
->Pixel
.ColorTableBias
[2];
511 aBias
= ctx
->Pixel
.ColorTableBias
[3];
513 case GL_TEXTURE_COLOR_TABLE_SGI
:
514 if (!ctx
->Extensions
.SGI_texture_color_table
) {
515 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorSubTable(target)");
518 table
= &ctx
->TextureColorTable
;
519 rScale
= ctx
->Texture
.ColorTableScale
[0];
520 gScale
= ctx
->Texture
.ColorTableScale
[1];
521 bScale
= ctx
->Texture
.ColorTableScale
[2];
522 aScale
= ctx
->Texture
.ColorTableScale
[3];
523 rBias
= ctx
->Texture
.ColorTableBias
[0];
524 gBias
= ctx
->Texture
.ColorTableBias
[1];
525 bBias
= ctx
->Texture
.ColorTableBias
[2];
526 aBias
= ctx
->Texture
.ColorTableBias
[3];
528 case GL_POST_CONVOLUTION_COLOR_TABLE
:
529 table
= &ctx
->PostConvolutionColorTable
;
530 rScale
= ctx
->Pixel
.PCCTscale
[0];
531 gScale
= ctx
->Pixel
.PCCTscale
[1];
532 bScale
= ctx
->Pixel
.PCCTscale
[2];
533 aScale
= ctx
->Pixel
.PCCTscale
[3];
534 rBias
= ctx
->Pixel
.PCCTbias
[0];
535 gBias
= ctx
->Pixel
.PCCTbias
[1];
536 bBias
= ctx
->Pixel
.PCCTbias
[2];
537 aBias
= ctx
->Pixel
.PCCTbias
[3];
539 case GL_POST_COLOR_MATRIX_COLOR_TABLE
:
540 table
= &ctx
->PostColorMatrixColorTable
;
541 rScale
= ctx
->Pixel
.PCMCTscale
[0];
542 gScale
= ctx
->Pixel
.PCMCTscale
[1];
543 bScale
= ctx
->Pixel
.PCMCTscale
[2];
544 aScale
= ctx
->Pixel
.PCMCTscale
[3];
545 rBias
= ctx
->Pixel
.PCMCTbias
[0];
546 gBias
= ctx
->Pixel
.PCMCTbias
[1];
547 bBias
= ctx
->Pixel
.PCMCTbias
[2];
548 aBias
= ctx
->Pixel
.PCMCTbias
[3];
551 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorSubTable(target)");
557 if (!_mesa_is_legal_format_and_type(format
, type
) ||
558 format
== GL_INTENSITY
) {
559 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glColorSubTable(format or type)");
564 _mesa_error(ctx
, GL_INVALID_VALUE
, "glColorSubTable(count)");
568 comps
= _mesa_components_in_format(table
->Format
);
569 assert(comps
> 0); /* error should have been caught sooner */
571 if (start
+ count
> (GLint
) table
->Size
) {
572 _mesa_error(ctx
, GL_INVALID_VALUE
, "glColorSubTable(count)");
577 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glColorSubTable");
581 if (!table
->FloatTable
) {
582 GLchan
*dest
= (GLchan
*) table
->Table
+ start
* comps
* sizeof(GLchan
);
583 _mesa_unpack_chan_color_span(ctx
, count
, table
->Format
, dest
,
584 format
, type
, data
, &ctx
->Unpack
, 0);
587 GLfloat tempTab
[MAX_COLOR_TABLE_SIZE
* 4];
591 ASSERT(table
->FloatTable
);
593 _mesa_unpack_float_color_span(ctx
, count
, table
->Format
,
595 format
, type
, data
, &ctx
->Unpack
,
598 tableF
= (GLfloat
*) table
->Table
;
600 switch (table
->Format
) {
602 for (i
= 0; i
< count
; i
++) {
603 GLuint j
= start
+ i
;
604 tableF
[j
] = CLAMP(tempTab
[i
] * rScale
+ rBias
, 0.0F
, 1.0F
);
608 for (i
= 0; i
< count
; i
++) {
609 GLuint j
= start
+ i
;
610 tableF
[j
] = CLAMP(tempTab
[i
] * rScale
+ rBias
, 0.0F
, 1.0F
);
614 for (i
= 0; i
< count
; i
++) {
615 GLuint j
= start
+ i
;
616 tableF
[j
] = CLAMP(tempTab
[i
] * aScale
+ aBias
, 0.0F
, 1.0F
);
619 case GL_LUMINANCE_ALPHA
:
620 for (i
= 0; i
< count
; i
++) {
621 GLuint j
= start
+ i
;
622 tableF
[j
*2+0] = CLAMP(tempTab
[i
*2+0] * rScale
+ rBias
, 0.0F
, 1.0F
);
623 tableF
[j
*2+1] = CLAMP(tempTab
[i
*2+1] * aScale
+ aBias
, 0.0F
, 1.0F
);
627 for (i
= 0; i
< count
; i
++) {
628 GLuint j
= start
+ i
;
629 tableF
[j
*3+0] = CLAMP(tempTab
[i
*3+0] * rScale
+ rBias
, 0.0F
, 1.0F
);
630 tableF
[j
*3+1] = CLAMP(tempTab
[i
*3+1] * gScale
+ gBias
, 0.0F
, 1.0F
);
631 tableF
[j
*3+2] = CLAMP(tempTab
[i
*3+2] * bScale
+ bBias
, 0.0F
, 1.0F
);
635 for (i
= 0; i
< count
; i
++) {
636 GLuint j
= start
+ i
;
637 tableF
[j
*4+0] = CLAMP(tempTab
[i
*4+0] * rScale
+ rBias
, 0.0F
, 1.0F
);
638 tableF
[j
*4+1] = CLAMP(tempTab
[i
*4+1] * gScale
+ gBias
, 0.0F
, 1.0F
);
639 tableF
[j
*4+2] = CLAMP(tempTab
[i
*4+2] * bScale
+ bBias
, 0.0F
, 1.0F
);
640 tableF
[j
*4+3] = CLAMP(tempTab
[i
*4+3] * aScale
+ aBias
, 0.0F
, 1.0F
);
644 _mesa_problem(ctx
, "Bad format in _mesa_ColorSubTable");
649 if (texObj
|| target
== GL_SHARED_TEXTURE_PALETTE_EXT
) {
650 /* per-texture object palette */
651 if (ctx
->Driver
.UpdateTexturePalette
) {
652 (*ctx
->Driver
.UpdateTexturePalette
)( ctx
, texObj
);
656 ctx
->NewState
|= _NEW_PIXEL
;
663 _mesa_CopyColorTable(GLenum target
, GLenum internalformat
,
664 GLint x
, GLint y
, GLsizei width
)
666 GET_CURRENT_CONTEXT(ctx
);
667 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
669 /* Select buffer to read from */
670 ctx
->Driver
.CopyColorTable( ctx
, target
, internalformat
, x
, y
, width
);
677 _mesa_CopyColorSubTable(GLenum target
, GLsizei start
,
678 GLint x
, GLint y
, GLsizei width
)
680 GET_CURRENT_CONTEXT(ctx
);
681 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
683 ctx
->Driver
.CopyColorSubTable( ctx
, target
, start
, x
, y
, width
);
689 _mesa_GetColorTable( GLenum target
, GLenum format
,
690 GLenum type
, GLvoid
*data
)
692 GET_CURRENT_CONTEXT(ctx
);
693 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
694 struct gl_color_table
*table
= NULL
;
695 GLchan rgba
[MAX_COLOR_TABLE_SIZE
][4];
696 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
699 _mesa_update_state(ctx
);
704 table
= &texUnit
->Current1D
->Palette
;
707 table
= &texUnit
->Current2D
->Palette
;
710 table
= &texUnit
->Current3D
->Palette
;
712 case GL_TEXTURE_CUBE_MAP_ARB
:
713 if (!ctx
->Extensions
.ARB_texture_cube_map
) {
714 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTable(target)");
717 table
= &texUnit
->CurrentCubeMap
->Palette
;
719 case GL_SHARED_TEXTURE_PALETTE_EXT
:
720 table
= &ctx
->Texture
.Palette
;
723 table
= &ctx
->ColorTable
;
725 case GL_TEXTURE_COLOR_TABLE_SGI
:
726 if (!ctx
->Extensions
.SGI_texture_color_table
) {
727 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTable(target)");
730 table
= &ctx
->TextureColorTable
;
732 case GL_POST_CONVOLUTION_COLOR_TABLE
:
733 table
= &ctx
->PostConvolutionColorTable
;
735 case GL_POST_COLOR_MATRIX_COLOR_TABLE
:
736 table
= &ctx
->PostColorMatrixColorTable
;
739 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTable(target)");
745 switch (table
->Format
) {
747 if (table
->FloatTable
) {
748 const GLfloat
*tableF
= (const GLfloat
*) table
->Table
;
750 for (i
= 0; i
< table
->Size
; i
++) {
754 rgba
[i
][ACOMP
] = IROUND_POS(tableF
[i
] * CHAN_MAXF
);
758 const GLchan
*tableUB
= (const GLchan
*) table
->Table
;
760 for (i
= 0; i
< table
->Size
; i
++) {
764 rgba
[i
][ACOMP
] = tableUB
[i
];
769 if (table
->FloatTable
) {
770 const GLfloat
*tableF
= (const GLfloat
*) table
->Table
;
772 for (i
= 0; i
< table
->Size
; i
++) {
773 rgba
[i
][RCOMP
] = IROUND_POS(tableF
[i
] * CHAN_MAXF
);
774 rgba
[i
][GCOMP
] = IROUND_POS(tableF
[i
] * CHAN_MAXF
);
775 rgba
[i
][BCOMP
] = IROUND_POS(tableF
[i
] * CHAN_MAXF
);
776 rgba
[i
][ACOMP
] = CHAN_MAX
;
780 const GLchan
*tableUB
= (const GLchan
*) table
->Table
;
782 for (i
= 0; i
< table
->Size
; i
++) {
783 rgba
[i
][RCOMP
] = tableUB
[i
];
784 rgba
[i
][GCOMP
] = tableUB
[i
];
785 rgba
[i
][BCOMP
] = tableUB
[i
];
786 rgba
[i
][ACOMP
] = CHAN_MAX
;
790 case GL_LUMINANCE_ALPHA
:
791 if (table
->FloatTable
) {
792 const GLfloat
*tableF
= (const GLfloat
*) table
->Table
;
794 for (i
= 0; i
< table
->Size
; i
++) {
795 rgba
[i
][RCOMP
] = IROUND_POS(tableF
[i
*2+0] * CHAN_MAXF
);
796 rgba
[i
][GCOMP
] = IROUND_POS(tableF
[i
*2+0] * CHAN_MAXF
);
797 rgba
[i
][BCOMP
] = IROUND_POS(tableF
[i
*2+0] * CHAN_MAXF
);
798 rgba
[i
][ACOMP
] = IROUND_POS(tableF
[i
*2+1] * CHAN_MAXF
);
802 const GLchan
*tableUB
= (const GLchan
*) table
->Table
;
804 for (i
= 0; i
< table
->Size
; i
++) {
805 rgba
[i
][RCOMP
] = tableUB
[i
*2+0];
806 rgba
[i
][GCOMP
] = tableUB
[i
*2+0];
807 rgba
[i
][BCOMP
] = tableUB
[i
*2+0];
808 rgba
[i
][ACOMP
] = tableUB
[i
*2+1];
813 if (table
->FloatTable
) {
814 const GLfloat
*tableF
= (const GLfloat
*) table
->Table
;
816 for (i
= 0; i
< table
->Size
; i
++) {
817 rgba
[i
][RCOMP
] = IROUND_POS(tableF
[i
] * CHAN_MAXF
);
818 rgba
[i
][GCOMP
] = IROUND_POS(tableF
[i
] * CHAN_MAXF
);
819 rgba
[i
][BCOMP
] = IROUND_POS(tableF
[i
] * CHAN_MAXF
);
820 rgba
[i
][ACOMP
] = IROUND_POS(tableF
[i
] * CHAN_MAXF
);
824 const GLchan
*tableUB
= (const GLchan
*) table
->Table
;
826 for (i
= 0; i
< table
->Size
; i
++) {
827 rgba
[i
][RCOMP
] = tableUB
[i
];
828 rgba
[i
][GCOMP
] = tableUB
[i
];
829 rgba
[i
][BCOMP
] = tableUB
[i
];
830 rgba
[i
][ACOMP
] = tableUB
[i
];
835 if (table
->FloatTable
) {
836 const GLfloat
*tableF
= (const GLfloat
*) table
->Table
;
838 for (i
= 0; i
< table
->Size
; i
++) {
839 rgba
[i
][RCOMP
] = IROUND_POS(tableF
[i
*3+0] * CHAN_MAXF
);
840 rgba
[i
][GCOMP
] = IROUND_POS(tableF
[i
*3+1] * CHAN_MAXF
);
841 rgba
[i
][BCOMP
] = IROUND_POS(tableF
[i
*3+2] * CHAN_MAXF
);
842 rgba
[i
][ACOMP
] = CHAN_MAX
;
846 const GLchan
*tableUB
= (const GLchan
*) table
->Table
;
848 for (i
= 0; i
< table
->Size
; i
++) {
849 rgba
[i
][RCOMP
] = tableUB
[i
*3+0];
850 rgba
[i
][GCOMP
] = tableUB
[i
*3+1];
851 rgba
[i
][BCOMP
] = tableUB
[i
*3+2];
852 rgba
[i
][ACOMP
] = CHAN_MAX
;
857 if (table
->FloatTable
) {
858 const GLfloat
*tableF
= (const GLfloat
*) table
->Table
;
860 for (i
= 0; i
< table
->Size
; i
++) {
861 rgba
[i
][RCOMP
] = IROUND_POS(tableF
[i
*4+0] * CHAN_MAXF
);
862 rgba
[i
][GCOMP
] = IROUND_POS(tableF
[i
*4+1] * CHAN_MAXF
);
863 rgba
[i
][BCOMP
] = IROUND_POS(tableF
[i
*4+2] * CHAN_MAXF
);
864 rgba
[i
][ACOMP
] = IROUND_POS(tableF
[i
*4+3] * CHAN_MAXF
);
868 const GLchan
*tableUB
= (const GLchan
*) table
->Table
;
870 for (i
= 0; i
< table
->Size
; i
++) {
871 rgba
[i
][RCOMP
] = tableUB
[i
*4+0];
872 rgba
[i
][GCOMP
] = tableUB
[i
*4+1];
873 rgba
[i
][BCOMP
] = tableUB
[i
*4+2];
874 rgba
[i
][ACOMP
] = tableUB
[i
*4+3];
879 _mesa_problem(ctx
, "bad table format in glGetColorTable");
883 _mesa_pack_rgba_span(ctx
, table
->Size
, (const GLchan (*)[4]) rgba
,
884 format
, type
, data
, &ctx
->Pack
, GL_FALSE
);
890 _mesa_ColorTableParameterfv(GLenum target
, GLenum pname
, const GLfloat
*params
)
892 GET_CURRENT_CONTEXT(ctx
);
893 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
896 case GL_COLOR_TABLE_SGI
:
897 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
898 ctx
->Pixel
.ColorTableScale
[0] = params
[0];
899 ctx
->Pixel
.ColorTableScale
[1] = params
[1];
900 ctx
->Pixel
.ColorTableScale
[2] = params
[2];
901 ctx
->Pixel
.ColorTableScale
[3] = params
[3];
903 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
904 ctx
->Pixel
.ColorTableBias
[0] = params
[0];
905 ctx
->Pixel
.ColorTableBias
[1] = params
[1];
906 ctx
->Pixel
.ColorTableBias
[2] = params
[2];
907 ctx
->Pixel
.ColorTableBias
[3] = params
[3];
910 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTableParameterfv(pname)");
914 case GL_TEXTURE_COLOR_TABLE_SGI
:
915 if (!ctx
->Extensions
.SGI_texture_color_table
) {
916 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTableParameter(target)");
919 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
920 ctx
->Texture
.ColorTableScale
[0] = params
[0];
921 ctx
->Texture
.ColorTableScale
[1] = params
[1];
922 ctx
->Texture
.ColorTableScale
[2] = params
[2];
923 ctx
->Texture
.ColorTableScale
[3] = params
[3];
925 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
926 ctx
->Texture
.ColorTableBias
[0] = params
[0];
927 ctx
->Texture
.ColorTableBias
[1] = params
[1];
928 ctx
->Texture
.ColorTableBias
[2] = params
[2];
929 ctx
->Texture
.ColorTableBias
[3] = params
[3];
932 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTableParameterfv(pname)");
936 case GL_POST_CONVOLUTION_COLOR_TABLE_SGI
:
937 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
938 ctx
->Pixel
.PCCTscale
[0] = params
[0];
939 ctx
->Pixel
.PCCTscale
[1] = params
[1];
940 ctx
->Pixel
.PCCTscale
[2] = params
[2];
941 ctx
->Pixel
.PCCTscale
[3] = params
[3];
943 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
944 ctx
->Pixel
.PCCTbias
[0] = params
[0];
945 ctx
->Pixel
.PCCTbias
[1] = params
[1];
946 ctx
->Pixel
.PCCTbias
[2] = params
[2];
947 ctx
->Pixel
.PCCTbias
[3] = params
[3];
950 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTableParameterfv(pname)");
954 case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI
:
955 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
956 ctx
->Pixel
.PCMCTscale
[0] = params
[0];
957 ctx
->Pixel
.PCMCTscale
[1] = params
[1];
958 ctx
->Pixel
.PCMCTscale
[2] = params
[2];
959 ctx
->Pixel
.PCMCTscale
[3] = params
[3];
961 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
962 ctx
->Pixel
.PCMCTbias
[0] = params
[0];
963 ctx
->Pixel
.PCMCTbias
[1] = params
[1];
964 ctx
->Pixel
.PCMCTbias
[2] = params
[2];
965 ctx
->Pixel
.PCMCTbias
[3] = params
[3];
968 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTableParameterfv(pname)");
973 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTableParameter(target)");
977 ctx
->NewState
|= _NEW_PIXEL
;
983 _mesa_ColorTableParameteriv(GLenum target
, GLenum pname
, const GLint
*params
)
986 if (pname
== GL_COLOR_TABLE_SGI
||
987 pname
== GL_TEXTURE_COLOR_TABLE_SGI
||
988 pname
== GL_POST_CONVOLUTION_COLOR_TABLE_SGI
||
989 pname
== GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI
) {
991 fparams
[0] = (GLfloat
) params
[0];
992 fparams
[1] = (GLfloat
) params
[1];
993 fparams
[2] = (GLfloat
) params
[2];
994 fparams
[3] = (GLfloat
) params
[3];
998 fparams
[0] = (GLfloat
) params
[0];
1000 _mesa_ColorTableParameterfv(target
, pname
, fparams
);
1006 _mesa_GetColorTableParameterfv( GLenum target
, GLenum pname
, GLfloat
*params
)
1008 GET_CURRENT_CONTEXT(ctx
);
1009 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1010 struct gl_color_table
*table
= NULL
;
1011 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1015 table
= &texUnit
->Current1D
->Palette
;
1018 table
= &texUnit
->Current2D
->Palette
;
1021 table
= &texUnit
->Current3D
->Palette
;
1023 case GL_TEXTURE_CUBE_MAP_ARB
:
1024 if (!ctx
->Extensions
.ARB_texture_cube_map
) {
1025 _mesa_error(ctx
, GL_INVALID_ENUM
,
1026 "glGetColorTableParameterfv(target)");
1029 table
= &texUnit
->CurrentCubeMap
->Palette
;
1031 case GL_PROXY_TEXTURE_1D
:
1032 table
= &ctx
->Texture
.Proxy1D
->Palette
;
1034 case GL_PROXY_TEXTURE_2D
:
1035 table
= &ctx
->Texture
.Proxy2D
->Palette
;
1037 case GL_PROXY_TEXTURE_3D
:
1038 table
= &ctx
->Texture
.Proxy3D
->Palette
;
1040 case GL_PROXY_TEXTURE_CUBE_MAP_ARB
:
1041 if (!ctx
->Extensions
.ARB_texture_cube_map
) {
1042 _mesa_error(ctx
, GL_INVALID_ENUM
,
1043 "glGetColorTableParameterfv(target)");
1046 table
= &ctx
->Texture
.ProxyCubeMap
->Palette
;
1048 case GL_SHARED_TEXTURE_PALETTE_EXT
:
1049 table
= &ctx
->Texture
.Palette
;
1051 case GL_COLOR_TABLE
:
1052 table
= &ctx
->ColorTable
;
1053 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
1054 params
[0] = ctx
->Pixel
.ColorTableScale
[0];
1055 params
[1] = ctx
->Pixel
.ColorTableScale
[1];
1056 params
[2] = ctx
->Pixel
.ColorTableScale
[2];
1057 params
[3] = ctx
->Pixel
.ColorTableScale
[3];
1060 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
1061 params
[0] = ctx
->Pixel
.ColorTableBias
[0];
1062 params
[1] = ctx
->Pixel
.ColorTableBias
[1];
1063 params
[2] = ctx
->Pixel
.ColorTableBias
[2];
1064 params
[3] = ctx
->Pixel
.ColorTableBias
[3];
1068 case GL_PROXY_COLOR_TABLE
:
1069 table
= &ctx
->ProxyColorTable
;
1071 case GL_TEXTURE_COLOR_TABLE_SGI
:
1072 if (!ctx
->Extensions
.SGI_texture_color_table
) {
1073 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameter(target)");
1076 table
= &ctx
->TextureColorTable
;
1077 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
1078 params
[0] = ctx
->Texture
.ColorTableScale
[0];
1079 params
[1] = ctx
->Texture
.ColorTableScale
[1];
1080 params
[2] = ctx
->Texture
.ColorTableScale
[2];
1081 params
[3] = ctx
->Texture
.ColorTableScale
[3];
1084 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
1085 params
[0] = ctx
->Texture
.ColorTableBias
[0];
1086 params
[1] = ctx
->Texture
.ColorTableBias
[1];
1087 params
[2] = ctx
->Texture
.ColorTableBias
[2];
1088 params
[3] = ctx
->Texture
.ColorTableBias
[3];
1092 case GL_PROXY_TEXTURE_COLOR_TABLE_SGI
:
1093 if (!ctx
->Extensions
.SGI_texture_color_table
) {
1094 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameter(target)");
1097 table
= &ctx
->ProxyTextureColorTable
;
1099 case GL_POST_CONVOLUTION_COLOR_TABLE
:
1100 table
= &ctx
->PostConvolutionColorTable
;
1101 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
1102 params
[0] = ctx
->Pixel
.PCCTscale
[0];
1103 params
[1] = ctx
->Pixel
.PCCTscale
[1];
1104 params
[2] = ctx
->Pixel
.PCCTscale
[2];
1105 params
[3] = ctx
->Pixel
.PCCTscale
[3];
1108 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
1109 params
[0] = ctx
->Pixel
.PCCTbias
[0];
1110 params
[1] = ctx
->Pixel
.PCCTbias
[1];
1111 params
[2] = ctx
->Pixel
.PCCTbias
[2];
1112 params
[3] = ctx
->Pixel
.PCCTbias
[3];
1116 case GL_PROXY_POST_CONVOLUTION_COLOR_TABLE
:
1117 table
= &ctx
->ProxyPostConvolutionColorTable
;
1119 case GL_POST_COLOR_MATRIX_COLOR_TABLE
:
1120 table
= &ctx
->PostColorMatrixColorTable
;
1121 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
1122 params
[0] = ctx
->Pixel
.PCMCTscale
[0];
1123 params
[1] = ctx
->Pixel
.PCMCTscale
[1];
1124 params
[2] = ctx
->Pixel
.PCMCTscale
[2];
1125 params
[3] = ctx
->Pixel
.PCMCTscale
[3];
1128 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
1129 params
[0] = ctx
->Pixel
.PCMCTbias
[0];
1130 params
[1] = ctx
->Pixel
.PCMCTbias
[1];
1131 params
[2] = ctx
->Pixel
.PCMCTbias
[2];
1132 params
[3] = ctx
->Pixel
.PCMCTbias
[3];
1136 case GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE
:
1137 table
= &ctx
->ProxyPostColorMatrixColorTable
;
1140 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameterfv(target)");
1147 case GL_COLOR_TABLE_FORMAT
:
1148 *params
= (GLfloat
) table
->IntFormat
;
1150 case GL_COLOR_TABLE_WIDTH
:
1151 *params
= (GLfloat
) table
->Size
;
1153 case GL_COLOR_TABLE_RED_SIZE
:
1154 *params
= (GLfloat
) table
->RedSize
;
1156 case GL_COLOR_TABLE_GREEN_SIZE
:
1157 *params
= (GLfloat
) table
->GreenSize
;
1159 case GL_COLOR_TABLE_BLUE_SIZE
:
1160 *params
= (GLfloat
) table
->BlueSize
;
1162 case GL_COLOR_TABLE_ALPHA_SIZE
:
1163 *params
= (GLfloat
) table
->AlphaSize
;
1165 case GL_COLOR_TABLE_LUMINANCE_SIZE
:
1166 *params
= (GLfloat
) table
->LuminanceSize
;
1168 case GL_COLOR_TABLE_INTENSITY_SIZE
:
1169 *params
= (GLfloat
) table
->IntensitySize
;
1172 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameterfv(pname)" );
1180 _mesa_GetColorTableParameteriv( GLenum target
, GLenum pname
, GLint
*params
)
1182 GET_CURRENT_CONTEXT(ctx
);
1183 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1184 struct gl_color_table
*table
= NULL
;
1185 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1189 table
= &texUnit
->Current1D
->Palette
;
1192 table
= &texUnit
->Current2D
->Palette
;
1195 table
= &texUnit
->Current3D
->Palette
;
1197 case GL_TEXTURE_CUBE_MAP_ARB
:
1198 if (!ctx
->Extensions
.ARB_texture_cube_map
) {
1199 _mesa_error(ctx
, GL_INVALID_ENUM
,
1200 "glGetColorTableParameteriv(target)");
1203 table
= &texUnit
->CurrentCubeMap
->Palette
;
1205 case GL_PROXY_TEXTURE_1D
:
1206 table
= &ctx
->Texture
.Proxy1D
->Palette
;
1208 case GL_PROXY_TEXTURE_2D
:
1209 table
= &ctx
->Texture
.Proxy2D
->Palette
;
1211 case GL_PROXY_TEXTURE_3D
:
1212 table
= &ctx
->Texture
.Proxy3D
->Palette
;
1214 case GL_PROXY_TEXTURE_CUBE_MAP_ARB
:
1215 if (!ctx
->Extensions
.ARB_texture_cube_map
) {
1216 _mesa_error(ctx
, GL_INVALID_ENUM
,
1217 "glGetColorTableParameteriv(target)");
1220 table
= &ctx
->Texture
.ProxyCubeMap
->Palette
;
1222 case GL_SHARED_TEXTURE_PALETTE_EXT
:
1223 table
= &ctx
->Texture
.Palette
;
1225 case GL_COLOR_TABLE
:
1226 table
= &ctx
->ColorTable
;
1227 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
1228 params
[0] = (GLint
) ctx
->Pixel
.ColorTableScale
[0];
1229 params
[1] = (GLint
) ctx
->Pixel
.ColorTableScale
[1];
1230 params
[2] = (GLint
) ctx
->Pixel
.ColorTableScale
[2];
1231 params
[3] = (GLint
) ctx
->Pixel
.ColorTableScale
[3];
1234 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
1235 params
[0] = (GLint
) ctx
->Pixel
.ColorTableBias
[0];
1236 params
[1] = (GLint
) ctx
->Pixel
.ColorTableBias
[1];
1237 params
[2] = (GLint
) ctx
->Pixel
.ColorTableBias
[2];
1238 params
[3] = (GLint
) ctx
->Pixel
.ColorTableBias
[3];
1242 case GL_PROXY_COLOR_TABLE
:
1243 table
= &ctx
->ProxyColorTable
;
1245 case GL_TEXTURE_COLOR_TABLE_SGI
:
1246 if (!ctx
->Extensions
.SGI_texture_color_table
) {
1247 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameter(target)");
1250 table
= &ctx
->TextureColorTable
;
1251 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
1252 params
[0] = (GLint
) ctx
->Texture
.ColorTableScale
[0];
1253 params
[1] = (GLint
) ctx
->Texture
.ColorTableScale
[1];
1254 params
[2] = (GLint
) ctx
->Texture
.ColorTableScale
[2];
1255 params
[3] = (GLint
) ctx
->Texture
.ColorTableScale
[3];
1258 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
1259 params
[0] = (GLint
) ctx
->Texture
.ColorTableBias
[0];
1260 params
[1] = (GLint
) ctx
->Texture
.ColorTableBias
[1];
1261 params
[2] = (GLint
) ctx
->Texture
.ColorTableBias
[2];
1262 params
[3] = (GLint
) ctx
->Texture
.ColorTableBias
[3];
1266 case GL_PROXY_TEXTURE_COLOR_TABLE_SGI
:
1267 if (!ctx
->Extensions
.SGI_texture_color_table
) {
1268 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameter(target)");
1271 table
= &ctx
->ProxyTextureColorTable
;
1273 case GL_POST_CONVOLUTION_COLOR_TABLE
:
1274 table
= &ctx
->PostConvolutionColorTable
;
1275 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
1276 params
[0] = (GLint
) ctx
->Pixel
.PCCTscale
[0];
1277 params
[1] = (GLint
) ctx
->Pixel
.PCCTscale
[1];
1278 params
[2] = (GLint
) ctx
->Pixel
.PCCTscale
[2];
1279 params
[3] = (GLint
) ctx
->Pixel
.PCCTscale
[3];
1282 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
1283 params
[0] = (GLint
) ctx
->Pixel
.PCCTbias
[0];
1284 params
[1] = (GLint
) ctx
->Pixel
.PCCTbias
[1];
1285 params
[2] = (GLint
) ctx
->Pixel
.PCCTbias
[2];
1286 params
[3] = (GLint
) ctx
->Pixel
.PCCTbias
[3];
1290 case GL_PROXY_POST_CONVOLUTION_COLOR_TABLE
:
1291 table
= &ctx
->ProxyPostConvolutionColorTable
;
1293 case GL_POST_COLOR_MATRIX_COLOR_TABLE
:
1294 table
= &ctx
->PostColorMatrixColorTable
;
1295 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
1296 params
[0] = (GLint
) ctx
->Pixel
.PCMCTscale
[0];
1297 params
[1] = (GLint
) ctx
->Pixel
.PCMCTscale
[1];
1298 params
[2] = (GLint
) ctx
->Pixel
.PCMCTscale
[2];
1299 params
[3] = (GLint
) ctx
->Pixel
.PCMCTscale
[3];
1302 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
1303 params
[0] = (GLint
) ctx
->Pixel
.PCMCTbias
[0];
1304 params
[1] = (GLint
) ctx
->Pixel
.PCMCTbias
[1];
1305 params
[2] = (GLint
) ctx
->Pixel
.PCMCTbias
[2];
1306 params
[3] = (GLint
) ctx
->Pixel
.PCMCTbias
[3];
1310 case GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE
:
1311 table
= &ctx
->ProxyPostColorMatrixColorTable
;
1314 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameteriv(target)");
1321 case GL_COLOR_TABLE_FORMAT
:
1322 *params
= table
->IntFormat
;
1324 case GL_COLOR_TABLE_WIDTH
:
1325 *params
= table
->Size
;
1327 case GL_COLOR_TABLE_RED_SIZE
:
1328 *params
= table
->RedSize
;
1330 case GL_COLOR_TABLE_GREEN_SIZE
:
1331 *params
= table
->GreenSize
;
1333 case GL_COLOR_TABLE_BLUE_SIZE
:
1334 *params
= table
->BlueSize
;
1336 case GL_COLOR_TABLE_ALPHA_SIZE
:
1337 *params
= table
->AlphaSize
;
1339 case GL_COLOR_TABLE_LUMINANCE_SIZE
:
1340 *params
= table
->LuminanceSize
;
1342 case GL_COLOR_TABLE_INTENSITY_SIZE
:
1343 *params
= table
->IntensitySize
;
1346 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameteriv(pname)" );