1 /* $Id: colortab.c,v 1.13 2000/04/12 00:27:37 brianp Exp $ */
4 * Mesa 3-D graphics library
7 * Copyright (C) 1999-2000 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.
44 * Examine table's format and set the component sizes accordingly.
47 set_component_sizes( struct gl_color_table
*table
)
49 switch (table
->Format
) {
55 table
->IntensitySize
= 0;
56 table
->LuminanceSize
= 0;
63 table
->IntensitySize
= 0;
64 table
->LuminanceSize
= 8;
66 case GL_LUMINANCE_ALPHA
:
71 table
->IntensitySize
= 0;
72 table
->LuminanceSize
= 8;
79 table
->IntensitySize
= 8;
80 table
->LuminanceSize
= 0;
87 table
->IntensitySize
= 0;
88 table
->LuminanceSize
= 0;
95 table
->IntensitySize
= 0;
96 table
->LuminanceSize
= 0;
99 gl_problem(NULL
, "unexpected format in set_component_sizes");
106 _mesa_ColorTable( GLenum target
, GLenum internalFormat
,
107 GLsizei width
, GLenum format
, GLenum type
,
110 GET_CURRENT_CONTEXT(ctx
);
111 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
112 struct gl_texture_object
*texObj
= NULL
;
113 struct gl_color_table
*table
= NULL
;
114 GLboolean proxy
= GL_FALSE
;
116 GLfloat rScale
= 1.0, gScale
= 1.0, bScale
= 1.0, aScale
= 1.0;
117 GLfloat rBias
= 0.0, gBias
= 0.0, bBias
= 0.0, aBias
= 0.0;
119 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
, "glColorTable");
123 texObj
= texUnit
->CurrentD
[1];
124 table
= &texObj
->Palette
;
127 texObj
= texUnit
->CurrentD
[2];
128 table
= &texObj
->Palette
;
131 texObj
= texUnit
->CurrentD
[3];
132 table
= &texObj
->Palette
;
134 case GL_PROXY_TEXTURE_1D
:
135 texObj
= ctx
->Texture
.Proxy1D
;
136 table
= &texObj
->Palette
;
139 case GL_PROXY_TEXTURE_2D
:
140 texObj
= ctx
->Texture
.Proxy2D
;
141 table
= &texObj
->Palette
;
144 case GL_PROXY_TEXTURE_3D
:
145 texObj
= ctx
->Texture
.Proxy3D
;
146 table
= &texObj
->Palette
;
149 case GL_SHARED_TEXTURE_PALETTE_EXT
:
150 table
= &ctx
->Texture
.Palette
;
153 table
= &ctx
->ColorTable
;
154 rScale
= ctx
->Pixel
.ColorTableScale
[0];
155 gScale
= ctx
->Pixel
.ColorTableScale
[1];
156 bScale
= ctx
->Pixel
.ColorTableScale
[2];
157 aScale
= ctx
->Pixel
.ColorTableScale
[3];
158 rBias
= ctx
->Pixel
.ColorTableBias
[0];
159 gBias
= ctx
->Pixel
.ColorTableBias
[1];
160 bBias
= ctx
->Pixel
.ColorTableBias
[2];
161 aBias
= ctx
->Pixel
.ColorTableBias
[3];
163 case GL_PROXY_COLOR_TABLE
:
164 table
= &ctx
->ProxyColorTable
;
167 case GL_POST_CONVOLUTION_COLOR_TABLE
:
168 table
= &ctx
->PostConvolutionColorTable
;
169 rScale
= ctx
->Pixel
.PCCTscale
[0];
170 gScale
= ctx
->Pixel
.PCCTscale
[1];
171 bScale
= ctx
->Pixel
.PCCTscale
[2];
172 aScale
= ctx
->Pixel
.PCCTscale
[3];
173 rBias
= ctx
->Pixel
.PCCTbias
[0];
174 gBias
= ctx
->Pixel
.PCCTbias
[1];
175 bBias
= ctx
->Pixel
.PCCTbias
[2];
176 aBias
= ctx
->Pixel
.PCCTbias
[3];
178 case GL_PROXY_POST_CONVOLUTION_COLOR_TABLE
:
179 table
= &ctx
->ProxyPostConvolutionColorTable
;
182 case GL_POST_COLOR_MATRIX_COLOR_TABLE
:
183 table
= &ctx
->PostColorMatrixColorTable
;
184 rScale
= ctx
->Pixel
.PCMCTscale
[0];
185 gScale
= ctx
->Pixel
.PCMCTscale
[1];
186 bScale
= ctx
->Pixel
.PCMCTscale
[2];
187 aScale
= ctx
->Pixel
.PCMCTscale
[3];
188 rBias
= ctx
->Pixel
.PCMCTbias
[0];
189 gBias
= ctx
->Pixel
.PCMCTbias
[1];
190 bBias
= ctx
->Pixel
.PCMCTbias
[2];
191 aBias
= ctx
->Pixel
.PCMCTbias
[3];
193 case GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE
:
194 table
= &ctx
->ProxyPostColorMatrixColorTable
;
198 gl_error(ctx
, GL_INVALID_ENUM
, "glColorTable(target)");
204 if (!_mesa_is_legal_format_and_type(format
, type
)) {
205 gl_error(ctx
, GL_INVALID_ENUM
, "glColorTable(format or type)");
209 baseFormat
= _mesa_base_tex_format(internalFormat
);
210 if (baseFormat
< 0 || baseFormat
== GL_COLOR_INDEX
) {
211 gl_error(ctx
, GL_INVALID_ENUM
, "glColorTable(internalFormat)");
215 if (width
< 1 || width
> MAX_COLOR_TABLE_SIZE
216 || _mesa_bitcount(width
) != 1) {
217 if (width
> MAX_COLOR_TABLE_SIZE
)
218 gl_error(ctx
, GL_TABLE_TOO_LARGE
, "glColorTable(width)");
220 gl_error(ctx
, GL_INVALID_VALUE
, "glColorTable(width)");
223 table
->IntFormat
= (GLenum
) 0;
224 table
->Format
= (GLenum
) 0;
231 table
->IntFormat
= internalFormat
;
232 table
->Format
= (GLenum
) baseFormat
;
233 set_component_sizes(table
);
236 _mesa_unpack_ubyte_color_span(ctx
, width
, table
->Format
,
237 table
->Table
, /* dest */
239 &ctx
->Unpack
, GL_TRUE
);
240 if (rScale
!= 1.0 || gScale
!= 1.0 || bScale
!= 1.0 || aScale
!= 1.0 ||
241 rBias
!= 0.0 || gBias
!= 0.0 || bBias
!= 0.0 || aBias
!= 0.0) {
242 /* XXX apply scale and bias */
247 if (texObj
|| target
== GL_SHARED_TEXTURE_PALETTE_EXT
) {
248 /* texture object palette, texObj==NULL means the shared palette */
249 if (ctx
->Driver
.UpdateTexturePalette
) {
250 (*ctx
->Driver
.UpdateTexturePalette
)( ctx
, texObj
);
259 _mesa_ColorSubTable( GLenum target
, GLsizei start
,
260 GLsizei count
, GLenum format
, GLenum type
,
263 GET_CURRENT_CONTEXT(ctx
);
264 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
265 struct gl_texture_object
*texObj
= NULL
;
266 struct gl_color_table
*table
= NULL
;
270 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
, "glColorSubTable");
274 texObj
= texUnit
->CurrentD
[1];
275 table
= &texObj
->Palette
;
278 texObj
= texUnit
->CurrentD
[2];
279 table
= &texObj
->Palette
;
282 texObj
= texUnit
->CurrentD
[3];
283 table
= &texObj
->Palette
;
285 case GL_SHARED_TEXTURE_PALETTE_EXT
:
286 table
= &ctx
->Texture
.Palette
;
289 table
= &ctx
->ColorTable
;
291 case GL_POST_CONVOLUTION_COLOR_TABLE
:
292 table
= &ctx
->PostConvolutionColorTable
;
294 case GL_POST_COLOR_MATRIX_COLOR_TABLE
:
295 table
= &ctx
->PostColorMatrixColorTable
;
298 gl_error(ctx
, GL_INVALID_ENUM
, "glColorSubTable(target)");
304 if (!_mesa_is_legal_format_and_type(format
, type
)) {
305 gl_error(ctx
, GL_INVALID_ENUM
, "glColorSubTable(format or type)");
310 gl_error(ctx
, GL_INVALID_VALUE
, "glColorSubTable(count)");
314 comps
= _mesa_components_in_format(table
->Format
);
315 assert(comps
> 0); /* error should have been caught sooner */
317 if (start
+ count
> table
->Size
) {
318 gl_error(ctx
, GL_INVALID_VALUE
, "glColorSubTable(count)");
322 dest
= table
->Table
+ start
* comps
* sizeof(GLubyte
);
323 _mesa_unpack_ubyte_color_span(ctx
, count
, table
->Format
, dest
,
325 &ctx
->Unpack
, GL_TRUE
);
327 if (texObj
|| target
== GL_SHARED_TEXTURE_PALETTE_EXT
) {
328 /* per-texture object palette */
329 if (ctx
->Driver
.UpdateTexturePalette
) {
330 (*ctx
->Driver
.UpdateTexturePalette
)( ctx
, texObj
);
339 _mesa_CopyColorTable(GLenum target
, GLenum internalformat
,
340 GLint x
, GLint y
, GLsizei width
)
342 GLubyte data
[MAX_WIDTH
][4];
343 GET_CURRENT_CONTEXT(ctx
);
344 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
, "glCopyColorTable");
346 /* Select buffer to read from */
347 (*ctx
->Driver
.SetReadBuffer
)( ctx
, ctx
->ReadBuffer
,
348 ctx
->Pixel
.DriverReadBuffer
);
350 if (width
> MAX_WIDTH
)
353 /* read the data from framebuffer */
354 gl_read_rgba_span( ctx
, ctx
->ReadBuffer
, width
, x
, y
, data
);
356 /* Restore reading from draw buffer (the default) */
357 (*ctx
->Driver
.SetReadBuffer
)( ctx
, ctx
->DrawBuffer
,
358 ctx
->Color
.DriverDrawBuffer
);
360 _mesa_ColorTable(target
, internalformat
, width
,
361 GL_RGBA
, GL_UNSIGNED_BYTE
, data
);
368 _mesa_CopyColorSubTable(GLenum target
, GLsizei start
,
369 GLint x
, GLint y
, GLsizei width
)
371 GLubyte data
[MAX_WIDTH
][4];
372 GET_CURRENT_CONTEXT(ctx
);
373 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
, "glCopyColorSubTable");
375 /* Select buffer to read from */
376 (*ctx
->Driver
.SetReadBuffer
)( ctx
, ctx
->ReadBuffer
,
377 ctx
->Pixel
.DriverReadBuffer
);
379 if (width
> MAX_WIDTH
)
382 /* read the data from framebuffer */
383 gl_read_rgba_span( ctx
, ctx
->ReadBuffer
, width
, x
, y
, data
);
385 /* Restore reading from draw buffer (the default) */
386 (*ctx
->Driver
.SetReadBuffer
)( ctx
, ctx
->DrawBuffer
,
387 ctx
->Color
.DriverDrawBuffer
);
389 _mesa_ColorSubTable(target
, start
, width
, GL_RGBA
, GL_UNSIGNED_BYTE
, data
);
395 _mesa_GetColorTable( GLenum target
, GLenum format
,
396 GLenum type
, GLvoid
*data
)
398 GET_CURRENT_CONTEXT(ctx
);
399 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
400 struct gl_color_table
*table
= NULL
;
401 GLubyte rgba
[MAX_COLOR_TABLE_SIZE
][4];
404 ASSERT_OUTSIDE_BEGIN_END(ctx
, "glGetColorTable");
408 table
= &texUnit
->CurrentD
[1]->Palette
;
411 table
= &texUnit
->CurrentD
[2]->Palette
;
414 table
= &texUnit
->CurrentD
[3]->Palette
;
416 case GL_SHARED_TEXTURE_PALETTE_EXT
:
417 table
= &ctx
->Texture
.Palette
;
420 table
= &ctx
->ColorTable
;
422 case GL_POST_CONVOLUTION_COLOR_TABLE
:
423 table
= &ctx
->PostConvolutionColorTable
;
425 case GL_POST_COLOR_MATRIX_COLOR_TABLE
:
426 table
= &ctx
->PostColorMatrixColorTable
;
429 gl_error(ctx
, GL_INVALID_ENUM
, "glGetColorTable(target)");
435 switch (table
->Format
) {
437 for (i
= 0; i
< table
->Size
; i
++) {
441 rgba
[i
][ACOMP
] = table
->Table
[i
];
445 for (i
= 0; i
< table
->Size
; i
++) {
446 rgba
[i
][RCOMP
] = table
->Table
[i
];
447 rgba
[i
][GCOMP
] = table
->Table
[i
];
448 rgba
[i
][BCOMP
] = table
->Table
[i
];
449 rgba
[i
][ACOMP
] = 255;
452 case GL_LUMINANCE_ALPHA
:
453 for (i
= 0; i
< table
->Size
; i
++) {
454 rgba
[i
][RCOMP
] = table
->Table
[i
*2+0];
455 rgba
[i
][GCOMP
] = table
->Table
[i
*2+0];
456 rgba
[i
][BCOMP
] = table
->Table
[i
*2+0];
457 rgba
[i
][ACOMP
] = table
->Table
[i
*2+1];
461 for (i
= 0; i
< table
->Size
; i
++) {
462 rgba
[i
][RCOMP
] = table
->Table
[i
];
463 rgba
[i
][GCOMP
] = table
->Table
[i
];
464 rgba
[i
][BCOMP
] = table
->Table
[i
];
465 rgba
[i
][ACOMP
] = 255;
469 for (i
= 0; i
< table
->Size
; i
++) {
470 rgba
[i
][RCOMP
] = table
->Table
[i
*3+0];
471 rgba
[i
][GCOMP
] = table
->Table
[i
*3+1];
472 rgba
[i
][BCOMP
] = table
->Table
[i
*3+2];
473 rgba
[i
][ACOMP
] = 255;
477 for (i
= 0; i
< table
->Size
; i
++) {
478 rgba
[i
][RCOMP
] = table
->Table
[i
*4+0];
479 rgba
[i
][GCOMP
] = table
->Table
[i
*4+1];
480 rgba
[i
][BCOMP
] = table
->Table
[i
*4+2];
481 rgba
[i
][ACOMP
] = table
->Table
[i
*4+3];
485 gl_problem(ctx
, "bad table format in glGetColorTable");
489 _mesa_pack_rgba_span(ctx
, table
->Size
, (const GLubyte (*)[]) rgba
,
490 format
, type
, data
, &ctx
->Pack
, GL_FALSE
);
496 _mesa_ColorTableParameterfv(GLenum target
, GLenum pname
, const GLfloat
*params
)
498 GET_CURRENT_CONTEXT(ctx
);
499 ASSERT_OUTSIDE_BEGIN_END(ctx
, "glColorTableParameterfv");
502 case GL_COLOR_TABLE_SGI
:
503 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
504 ctx
->Pixel
.ColorTableScale
[0] = params
[0];
505 ctx
->Pixel
.ColorTableScale
[1] = params
[1];
506 ctx
->Pixel
.ColorTableScale
[2] = params
[2];
507 ctx
->Pixel
.ColorTableScale
[3] = params
[3];
509 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
510 ctx
->Pixel
.ColorTableBias
[0] = params
[0];
511 ctx
->Pixel
.ColorTableBias
[1] = params
[1];
512 ctx
->Pixel
.ColorTableBias
[2] = params
[2];
513 ctx
->Pixel
.ColorTableBias
[3] = params
[3];
516 gl_error(ctx
, GL_INVALID_ENUM
, "glColorTableParameterfv(pname)");
520 case GL_POST_CONVOLUTION_COLOR_TABLE_SGI
:
521 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
522 ctx
->Pixel
.PCCTscale
[0] = params
[0];
523 ctx
->Pixel
.PCCTscale
[1] = params
[1];
524 ctx
->Pixel
.PCCTscale
[2] = params
[2];
525 ctx
->Pixel
.PCCTscale
[3] = params
[3];
527 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
528 ctx
->Pixel
.PCCTbias
[0] = params
[0];
529 ctx
->Pixel
.PCCTbias
[1] = params
[1];
530 ctx
->Pixel
.PCCTbias
[2] = params
[2];
531 ctx
->Pixel
.PCCTbias
[3] = params
[3];
534 gl_error(ctx
, GL_INVALID_ENUM
, "glColorTableParameterfv(pname)");
538 case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI
:
539 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
540 ctx
->Pixel
.PCMCTscale
[0] = params
[0];
541 ctx
->Pixel
.PCMCTscale
[1] = params
[1];
542 ctx
->Pixel
.PCMCTscale
[2] = params
[2];
543 ctx
->Pixel
.PCMCTscale
[3] = params
[3];
545 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
546 ctx
->Pixel
.PCMCTbias
[0] = params
[0];
547 ctx
->Pixel
.PCMCTbias
[1] = params
[1];
548 ctx
->Pixel
.PCMCTbias
[2] = params
[2];
549 ctx
->Pixel
.PCMCTbias
[3] = params
[3];
552 gl_error(ctx
, GL_INVALID_ENUM
, "glColorTableParameterfv(pname)");
557 gl_error(ctx
, GL_INVALID_ENUM
, "glColorTableParameter(target)");
565 _mesa_ColorTableParameteriv(GLenum target
, GLenum pname
, const GLint
*params
)
568 if (pname
== GL_COLOR_TABLE_SGI
||
569 pname
== GL_POST_CONVOLUTION_COLOR_TABLE_SGI
||
570 pname
== GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI
) {
572 fparams
[0] = (GLfloat
) params
[0];
573 fparams
[1] = (GLfloat
) params
[1];
574 fparams
[2] = (GLfloat
) params
[2];
575 fparams
[3] = (GLfloat
) params
[3];
579 fparams
[0] = (GLfloat
) params
[0];
581 _mesa_ColorTableParameterfv(target
, pname
, fparams
);
587 _mesa_GetColorTableParameterfv( GLenum target
, GLenum pname
, GLfloat
*params
)
589 GET_CURRENT_CONTEXT(ctx
);
590 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
591 struct gl_color_table
*table
= NULL
;
593 ASSERT_OUTSIDE_BEGIN_END(ctx
, "glGetColorTableParameterfv");
597 table
= &texUnit
->CurrentD
[1]->Palette
;
600 table
= &texUnit
->CurrentD
[2]->Palette
;
603 table
= &texUnit
->CurrentD
[3]->Palette
;
605 case GL_PROXY_TEXTURE_1D
:
606 table
= &ctx
->Texture
.Proxy1D
->Palette
;
608 case GL_PROXY_TEXTURE_2D
:
609 table
= &ctx
->Texture
.Proxy2D
->Palette
;
611 case GL_PROXY_TEXTURE_3D
:
612 table
= &ctx
->Texture
.Proxy3D
->Palette
;
614 case GL_SHARED_TEXTURE_PALETTE_EXT
:
615 table
= &ctx
->Texture
.Palette
;
618 table
= &ctx
->ColorTable
;
619 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
620 params
[0] = ctx
->Pixel
.ColorTableScale
[0];
621 params
[1] = ctx
->Pixel
.ColorTableScale
[1];
622 params
[2] = ctx
->Pixel
.ColorTableScale
[2];
623 params
[3] = ctx
->Pixel
.ColorTableScale
[3];
626 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
627 params
[0] = ctx
->Pixel
.ColorTableBias
[0];
628 params
[1] = ctx
->Pixel
.ColorTableBias
[1];
629 params
[2] = ctx
->Pixel
.ColorTableBias
[2];
630 params
[3] = ctx
->Pixel
.ColorTableBias
[3];
634 case GL_PROXY_COLOR_TABLE
:
635 table
= &ctx
->ProxyColorTable
;
637 case GL_POST_CONVOLUTION_COLOR_TABLE
:
638 table
= &ctx
->PostConvolutionColorTable
;
639 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
640 params
[0] = ctx
->Pixel
.PCCTscale
[0];
641 params
[1] = ctx
->Pixel
.PCCTscale
[1];
642 params
[2] = ctx
->Pixel
.PCCTscale
[2];
643 params
[3] = ctx
->Pixel
.PCCTscale
[3];
646 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
647 params
[0] = ctx
->Pixel
.PCCTbias
[0];
648 params
[1] = ctx
->Pixel
.PCCTbias
[1];
649 params
[2] = ctx
->Pixel
.PCCTbias
[2];
650 params
[3] = ctx
->Pixel
.PCCTbias
[3];
654 case GL_PROXY_POST_CONVOLUTION_COLOR_TABLE
:
655 table
= &ctx
->ProxyPostConvolutionColorTable
;
657 case GL_POST_COLOR_MATRIX_COLOR_TABLE
:
658 table
= &ctx
->PostColorMatrixColorTable
;
659 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
660 params
[0] = ctx
->Pixel
.PCMCTscale
[0];
661 params
[1] = ctx
->Pixel
.PCMCTscale
[1];
662 params
[2] = ctx
->Pixel
.PCMCTscale
[2];
663 params
[3] = ctx
->Pixel
.PCMCTscale
[3];
666 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
667 params
[0] = ctx
->Pixel
.PCMCTbias
[0];
668 params
[1] = ctx
->Pixel
.PCMCTbias
[1];
669 params
[2] = ctx
->Pixel
.PCMCTbias
[2];
670 params
[3] = ctx
->Pixel
.PCMCTbias
[3];
674 case GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE
:
675 table
= &ctx
->ProxyPostColorMatrixColorTable
;
678 gl_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameterfv(target)");
685 case GL_COLOR_TABLE_FORMAT
:
686 *params
= table
->IntFormat
;
688 case GL_COLOR_TABLE_WIDTH
:
689 *params
= table
->Size
;
691 case GL_COLOR_TABLE_RED_SIZE
:
692 *params
= table
->RedSize
;
694 case GL_COLOR_TABLE_GREEN_SIZE
:
695 *params
= table
->GreenSize
;
697 case GL_COLOR_TABLE_BLUE_SIZE
:
698 *params
= table
->BlueSize
;
700 case GL_COLOR_TABLE_ALPHA_SIZE
:
701 *params
= table
->AlphaSize
;
703 case GL_COLOR_TABLE_LUMINANCE_SIZE
:
704 *params
= table
->LuminanceSize
;
706 case GL_COLOR_TABLE_INTENSITY_SIZE
:
707 *params
= table
->IntensitySize
;
710 gl_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameterfv(pname)" );
718 _mesa_GetColorTableParameteriv( GLenum target
, GLenum pname
, GLint
*params
)
720 GET_CURRENT_CONTEXT(ctx
);
721 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
722 struct gl_color_table
*table
= NULL
;
724 ASSERT_OUTSIDE_BEGIN_END(ctx
, "glGetColorTableParameteriv");
728 table
= &texUnit
->CurrentD
[1]->Palette
;
731 table
= &texUnit
->CurrentD
[2]->Palette
;
734 table
= &texUnit
->CurrentD
[3]->Palette
;
736 case GL_PROXY_TEXTURE_1D
:
737 table
= &ctx
->Texture
.Proxy1D
->Palette
;
739 case GL_PROXY_TEXTURE_2D
:
740 table
= &ctx
->Texture
.Proxy2D
->Palette
;
742 case GL_PROXY_TEXTURE_3D
:
743 table
= &ctx
->Texture
.Proxy3D
->Palette
;
745 case GL_SHARED_TEXTURE_PALETTE_EXT
:
746 table
= &ctx
->Texture
.Palette
;
749 table
= &ctx
->ColorTable
;
750 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
751 params
[0] = (GLint
) ctx
->Pixel
.ColorTableScale
[0];
752 params
[1] = (GLint
) ctx
->Pixel
.ColorTableScale
[1];
753 params
[2] = (GLint
) ctx
->Pixel
.ColorTableScale
[2];
754 params
[3] = (GLint
) ctx
->Pixel
.ColorTableScale
[3];
757 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
758 params
[0] = (GLint
) ctx
->Pixel
.ColorTableBias
[0];
759 params
[1] = (GLint
) ctx
->Pixel
.ColorTableBias
[1];
760 params
[2] = (GLint
) ctx
->Pixel
.ColorTableBias
[2];
761 params
[3] = (GLint
) ctx
->Pixel
.ColorTableBias
[3];
765 case GL_PROXY_COLOR_TABLE
:
766 table
= &ctx
->ProxyColorTable
;
768 case GL_POST_CONVOLUTION_COLOR_TABLE
:
769 table
= &ctx
->PostConvolutionColorTable
;
770 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
771 params
[0] = (GLint
) ctx
->Pixel
.PCCTscale
[0];
772 params
[1] = (GLint
) ctx
->Pixel
.PCCTscale
[1];
773 params
[2] = (GLint
) ctx
->Pixel
.PCCTscale
[2];
774 params
[3] = (GLint
) ctx
->Pixel
.PCCTscale
[3];
777 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
778 params
[0] = (GLint
) ctx
->Pixel
.PCCTbias
[0];
779 params
[1] = (GLint
) ctx
->Pixel
.PCCTbias
[1];
780 params
[2] = (GLint
) ctx
->Pixel
.PCCTbias
[2];
781 params
[3] = (GLint
) ctx
->Pixel
.PCCTbias
[3];
785 case GL_PROXY_POST_CONVOLUTION_COLOR_TABLE
:
786 table
= &ctx
->ProxyPostConvolutionColorTable
;
788 case GL_POST_COLOR_MATRIX_COLOR_TABLE
:
789 table
= &ctx
->PostColorMatrixColorTable
;
790 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
791 params
[0] = (GLint
) ctx
->Pixel
.PCMCTscale
[0];
792 params
[1] = (GLint
) ctx
->Pixel
.PCMCTscale
[1];
793 params
[2] = (GLint
) ctx
->Pixel
.PCMCTscale
[2];
794 params
[3] = (GLint
) ctx
->Pixel
.PCMCTscale
[3];
797 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
798 params
[0] = (GLint
) ctx
->Pixel
.PCMCTbias
[0];
799 params
[1] = (GLint
) ctx
->Pixel
.PCMCTbias
[1];
800 params
[2] = (GLint
) ctx
->Pixel
.PCMCTbias
[2];
801 params
[3] = (GLint
) ctx
->Pixel
.PCMCTbias
[3];
805 case GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE
:
806 table
= &ctx
->ProxyPostColorMatrixColorTable
;
809 gl_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameteriv(target)");
816 case GL_COLOR_TABLE_FORMAT
:
817 *params
= table
->IntFormat
;
819 case GL_COLOR_TABLE_WIDTH
:
820 *params
= table
->Size
;
822 case GL_COLOR_TABLE_RED_SIZE
:
823 *params
= table
->RedSize
;
825 case GL_COLOR_TABLE_GREEN_SIZE
:
826 *params
= table
->GreenSize
;
828 case GL_COLOR_TABLE_BLUE_SIZE
:
829 *params
= table
->BlueSize
;
831 case GL_COLOR_TABLE_ALPHA_SIZE
:
832 *params
= table
->AlphaSize
;
834 case GL_COLOR_TABLE_LUMINANCE_SIZE
:
835 *params
= table
->LuminanceSize
;
837 case GL_COLOR_TABLE_INTENSITY_SIZE
:
838 *params
= table
->IntensitySize
;
841 gl_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameteriv(pname)" );