1 /* $Id: colortab.c,v 1.15 2000/04/17 17:57:04 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.
45 _mesa_init_colortable( struct gl_color_table
*p
)
47 p
->TableType
= GL_UNSIGNED_BYTE
;
48 /* allocate a width=1 table by default */
49 p
->Table
= CALLOC(4 * sizeof(GLubyte
));
51 GLubyte
*t
= (GLubyte
*) p
->Table
;
58 p
->IntFormat
= GL_RGBA
;
71 _mesa_free_colortable_data( struct gl_color_table
*p
)
81 * Examine table's format and set the component sizes accordingly.
84 set_component_sizes( struct gl_color_table
*table
)
86 switch (table
->Format
) {
92 table
->IntensitySize
= 0;
93 table
->LuminanceSize
= 0;
100 table
->IntensitySize
= 0;
101 table
->LuminanceSize
= 8;
103 case GL_LUMINANCE_ALPHA
:
105 table
->GreenSize
= 0;
107 table
->AlphaSize
= 8;
108 table
->IntensitySize
= 0;
109 table
->LuminanceSize
= 8;
113 table
->GreenSize
= 0;
115 table
->AlphaSize
= 0;
116 table
->IntensitySize
= 8;
117 table
->LuminanceSize
= 0;
121 table
->GreenSize
= 8;
123 table
->AlphaSize
= 0;
124 table
->IntensitySize
= 0;
125 table
->LuminanceSize
= 0;
129 table
->GreenSize
= 8;
131 table
->AlphaSize
= 8;
132 table
->IntensitySize
= 0;
133 table
->LuminanceSize
= 0;
136 gl_problem(NULL
, "unexpected format in set_component_sizes");
143 _mesa_ColorTable( GLenum target
, GLenum internalFormat
,
144 GLsizei width
, GLenum format
, GLenum type
,
147 GET_CURRENT_CONTEXT(ctx
);
148 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
149 struct gl_texture_object
*texObj
= NULL
;
150 struct gl_color_table
*table
= NULL
;
151 GLboolean proxy
= GL_FALSE
;
153 GLfloat rScale
= 1.0, gScale
= 1.0, bScale
= 1.0, aScale
= 1.0;
154 GLfloat rBias
= 0.0, gBias
= 0.0, bBias
= 0.0, aBias
= 0.0;
155 GLboolean floatTable
= GL_FALSE
;
157 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
, "glColorTable");
161 texObj
= texUnit
->CurrentD
[1];
162 table
= &texObj
->Palette
;
165 texObj
= texUnit
->CurrentD
[2];
166 table
= &texObj
->Palette
;
169 texObj
= texUnit
->CurrentD
[3];
170 table
= &texObj
->Palette
;
172 case GL_PROXY_TEXTURE_1D
:
173 texObj
= ctx
->Texture
.Proxy1D
;
174 table
= &texObj
->Palette
;
177 case GL_PROXY_TEXTURE_2D
:
178 texObj
= ctx
->Texture
.Proxy2D
;
179 table
= &texObj
->Palette
;
182 case GL_PROXY_TEXTURE_3D
:
183 texObj
= ctx
->Texture
.Proxy3D
;
184 table
= &texObj
->Palette
;
187 case GL_SHARED_TEXTURE_PALETTE_EXT
:
188 table
= &ctx
->Texture
.Palette
;
191 table
= &ctx
->ColorTable
;
192 floatTable
= GL_TRUE
;
193 rScale
= ctx
->Pixel
.ColorTableScale
[0];
194 gScale
= ctx
->Pixel
.ColorTableScale
[1];
195 bScale
= ctx
->Pixel
.ColorTableScale
[2];
196 aScale
= ctx
->Pixel
.ColorTableScale
[3];
197 rBias
= ctx
->Pixel
.ColorTableBias
[0];
198 gBias
= ctx
->Pixel
.ColorTableBias
[1];
199 bBias
= ctx
->Pixel
.ColorTableBias
[2];
200 aBias
= ctx
->Pixel
.ColorTableBias
[3];
202 case GL_PROXY_COLOR_TABLE
:
203 table
= &ctx
->ProxyColorTable
;
206 case GL_POST_CONVOLUTION_COLOR_TABLE
:
207 table
= &ctx
->PostConvolutionColorTable
;
208 floatTable
= GL_TRUE
;
209 rScale
= ctx
->Pixel
.PCCTscale
[0];
210 gScale
= ctx
->Pixel
.PCCTscale
[1];
211 bScale
= ctx
->Pixel
.PCCTscale
[2];
212 aScale
= ctx
->Pixel
.PCCTscale
[3];
213 rBias
= ctx
->Pixel
.PCCTbias
[0];
214 gBias
= ctx
->Pixel
.PCCTbias
[1];
215 bBias
= ctx
->Pixel
.PCCTbias
[2];
216 aBias
= ctx
->Pixel
.PCCTbias
[3];
218 case GL_PROXY_POST_CONVOLUTION_COLOR_TABLE
:
219 table
= &ctx
->ProxyPostConvolutionColorTable
;
222 case GL_POST_COLOR_MATRIX_COLOR_TABLE
:
223 table
= &ctx
->PostColorMatrixColorTable
;
224 floatTable
= GL_TRUE
;
225 rScale
= ctx
->Pixel
.PCMCTscale
[0];
226 gScale
= ctx
->Pixel
.PCMCTscale
[1];
227 bScale
= ctx
->Pixel
.PCMCTscale
[2];
228 aScale
= ctx
->Pixel
.PCMCTscale
[3];
229 rBias
= ctx
->Pixel
.PCMCTbias
[0];
230 gBias
= ctx
->Pixel
.PCMCTbias
[1];
231 bBias
= ctx
->Pixel
.PCMCTbias
[2];
232 aBias
= ctx
->Pixel
.PCMCTbias
[3];
234 case GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE
:
235 table
= &ctx
->ProxyPostColorMatrixColorTable
;
239 gl_error(ctx
, GL_INVALID_ENUM
, "glColorTable(target)");
245 if (!_mesa_is_legal_format_and_type(format
, type
)) {
246 gl_error(ctx
, GL_INVALID_ENUM
, "glColorTable(format or type)");
250 baseFormat
= _mesa_base_tex_format(internalFormat
);
251 if (baseFormat
< 0 || baseFormat
== GL_COLOR_INDEX
) {
252 gl_error(ctx
, GL_INVALID_ENUM
, "glColorTable(internalFormat)");
256 if (width
< 1 || width
> ctx
->Const
.MaxColorTableSize
257 || _mesa_bitcount(width
) != 1) {
258 if (width
> ctx
->Const
.MaxColorTableSize
)
259 gl_error(ctx
, GL_TABLE_TOO_LARGE
, "glColorTable(width)");
261 gl_error(ctx
, GL_INVALID_VALUE
, "glColorTable(width)");
264 table
->IntFormat
= (GLenum
) 0;
265 table
->Format
= (GLenum
) 0;
272 table
->IntFormat
= internalFormat
;
273 table
->Format
= (GLenum
) baseFormat
;
274 set_component_sizes(table
);
277 /* free old table, if any */
282 GLubyte tableUB
[MAX_COLOR_TABLE_SIZE
* 4];
286 _mesa_unpack_ubyte_color_span(ctx
, width
, table
->Format
,
289 &ctx
->Unpack
, GL_TRUE
);
291 table
->TableType
= GL_FLOAT
;
292 table
->Table
= MALLOC(4 * width
* sizeof(GLfloat
));
294 gl_error(ctx
, GL_OUT_OF_MEMORY
, "glColorTable");
298 /* Apply scale and bias and convert GLubyte values to GLfloats
299 * in [0, 1]. Store results in the tableF[].
305 tableF
= (GLfloat
*) table
->Table
;
307 switch (table
->Format
) {
309 for (i
= 0; i
< width
; i
++) {
310 tableF
[i
] = tableUB
[i
] * rScale
+ rBias
;
314 for (i
= 0; i
< width
; i
++) {
315 tableF
[i
] = tableUB
[i
] * rScale
+ rBias
;
319 for (i
= 0; i
< width
; i
++) {
320 tableF
[i
] = tableUB
[i
] * aScale
+ aBias
;
323 case GL_LUMINANCE_ALPHA
:
324 for (i
= 0; i
< width
; i
++) {
325 tableF
[i
*2+0] = tableUB
[i
*2+0] * rScale
+ rBias
;
326 tableF
[i
*2+1] = tableUB
[i
*2+1] * aScale
+ aBias
;
330 for (i
= 0; i
< width
; i
++) {
331 tableF
[i
*3+0] = tableUB
[i
*3+0] * rScale
+ rBias
;
332 tableF
[i
*3+1] = tableUB
[i
*3+1] * gScale
+ gBias
;
333 tableF
[i
*3+2] = tableUB
[i
*3+2] * bScale
+ bBias
;
337 for (i
= 0; i
< width
; i
++) {
338 tableF
[i
*4+0] = tableUB
[i
*4+0] * rScale
+ rBias
;
339 tableF
[i
*4+1] = tableUB
[i
*4+1] * gScale
+ gBias
;
340 tableF
[i
*4+2] = tableUB
[i
*4+2] * bScale
+ bBias
;
341 tableF
[i
*4+3] = tableUB
[i
*4+3] * aScale
+ aBias
;
345 gl_problem(ctx
, "Bad format in _mesa_ColorTable");
350 /* store GLubyte table */
351 table
->TableType
= GL_UNSIGNED_BYTE
;
352 table
->Table
= MALLOC(4 * width
* sizeof(GLubyte
));
354 gl_error(ctx
, GL_OUT_OF_MEMORY
, "glColorTable");
357 _mesa_unpack_ubyte_color_span(ctx
, width
, table
->Format
,
358 table
->Table
, /* dest */
360 &ctx
->Unpack
, GL_TRUE
);
364 if (texObj
|| target
== GL_SHARED_TEXTURE_PALETTE_EXT
) {
365 /* texture object palette, texObj==NULL means the shared palette */
366 if (ctx
->Driver
.UpdateTexturePalette
) {
367 (*ctx
->Driver
.UpdateTexturePalette
)( ctx
, texObj
);
376 _mesa_ColorSubTable( GLenum target
, GLsizei start
,
377 GLsizei count
, GLenum format
, GLenum type
,
380 GET_CURRENT_CONTEXT(ctx
);
381 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
382 struct gl_texture_object
*texObj
= NULL
;
383 struct gl_color_table
*table
= NULL
;
387 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
, "glColorSubTable");
391 texObj
= texUnit
->CurrentD
[1];
392 table
= &texObj
->Palette
;
395 texObj
= texUnit
->CurrentD
[2];
396 table
= &texObj
->Palette
;
399 texObj
= texUnit
->CurrentD
[3];
400 table
= &texObj
->Palette
;
402 case GL_SHARED_TEXTURE_PALETTE_EXT
:
403 table
= &ctx
->Texture
.Palette
;
406 table
= &ctx
->ColorTable
;
408 case GL_POST_CONVOLUTION_COLOR_TABLE
:
409 table
= &ctx
->PostConvolutionColorTable
;
411 case GL_POST_COLOR_MATRIX_COLOR_TABLE
:
412 table
= &ctx
->PostColorMatrixColorTable
;
415 gl_error(ctx
, GL_INVALID_ENUM
, "glColorSubTable(target)");
421 if (!_mesa_is_legal_format_and_type(format
, type
)) {
422 gl_error(ctx
, GL_INVALID_ENUM
, "glColorSubTable(format or type)");
427 gl_error(ctx
, GL_INVALID_VALUE
, "glColorSubTable(count)");
431 comps
= _mesa_components_in_format(table
->Format
);
432 assert(comps
> 0); /* error should have been caught sooner */
434 if (start
+ count
> table
->Size
) {
435 gl_error(ctx
, GL_INVALID_VALUE
, "glColorSubTable(count)");
440 gl_error(ctx
, GL_OUT_OF_MEMORY
, "glColorSubTable");
444 if (table
->TableType
== GL_UNSIGNED_BYTE
) {
445 dest
= (GLubyte
*) table
->Table
+ start
* comps
* sizeof(GLubyte
);
446 _mesa_unpack_ubyte_color_span(ctx
, count
, table
->Format
, dest
,
448 &ctx
->Unpack
, GL_TRUE
);
451 ASSERT(table
->TableType
== GL_FLOAT
);
456 if (texObj
|| target
== GL_SHARED_TEXTURE_PALETTE_EXT
) {
457 /* per-texture object palette */
458 if (ctx
->Driver
.UpdateTexturePalette
) {
459 (*ctx
->Driver
.UpdateTexturePalette
)( ctx
, texObj
);
468 _mesa_CopyColorTable(GLenum target
, GLenum internalformat
,
469 GLint x
, GLint y
, GLsizei width
)
471 GLubyte data
[MAX_WIDTH
][4];
472 GET_CURRENT_CONTEXT(ctx
);
473 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
, "glCopyColorTable");
475 /* Select buffer to read from */
476 (*ctx
->Driver
.SetReadBuffer
)( ctx
, ctx
->ReadBuffer
,
477 ctx
->Pixel
.DriverReadBuffer
);
479 if (width
> MAX_WIDTH
)
482 /* read the data from framebuffer */
483 gl_read_rgba_span( ctx
, ctx
->ReadBuffer
, width
, x
, y
, data
);
485 /* Restore reading from draw buffer (the default) */
486 (*ctx
->Driver
.SetReadBuffer
)( ctx
, ctx
->DrawBuffer
,
487 ctx
->Color
.DriverDrawBuffer
);
489 _mesa_ColorTable(target
, internalformat
, width
,
490 GL_RGBA
, GL_UNSIGNED_BYTE
, data
);
497 _mesa_CopyColorSubTable(GLenum target
, GLsizei start
,
498 GLint x
, GLint y
, GLsizei width
)
500 GLubyte data
[MAX_WIDTH
][4];
501 GET_CURRENT_CONTEXT(ctx
);
502 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
, "glCopyColorSubTable");
504 /* Select buffer to read from */
505 (*ctx
->Driver
.SetReadBuffer
)( ctx
, ctx
->ReadBuffer
,
506 ctx
->Pixel
.DriverReadBuffer
);
508 if (width
> MAX_WIDTH
)
511 /* read the data from framebuffer */
512 gl_read_rgba_span( ctx
, ctx
->ReadBuffer
, width
, x
, y
, data
);
514 /* Restore reading from draw buffer (the default) */
515 (*ctx
->Driver
.SetReadBuffer
)( ctx
, ctx
->DrawBuffer
,
516 ctx
->Color
.DriverDrawBuffer
);
518 _mesa_ColorSubTable(target
, start
, width
, GL_RGBA
, GL_UNSIGNED_BYTE
, data
);
524 _mesa_GetColorTable( GLenum target
, GLenum format
,
525 GLenum type
, GLvoid
*data
)
527 GET_CURRENT_CONTEXT(ctx
);
528 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
529 struct gl_color_table
*table
= NULL
;
530 GLubyte rgba
[MAX_COLOR_TABLE_SIZE
][4];
533 ASSERT_OUTSIDE_BEGIN_END(ctx
, "glGetColorTable");
537 table
= &texUnit
->CurrentD
[1]->Palette
;
540 table
= &texUnit
->CurrentD
[2]->Palette
;
543 table
= &texUnit
->CurrentD
[3]->Palette
;
545 case GL_SHARED_TEXTURE_PALETTE_EXT
:
546 table
= &ctx
->Texture
.Palette
;
549 table
= &ctx
->ColorTable
;
551 case GL_POST_CONVOLUTION_COLOR_TABLE
:
552 table
= &ctx
->PostConvolutionColorTable
;
554 case GL_POST_COLOR_MATRIX_COLOR_TABLE
:
555 table
= &ctx
->PostColorMatrixColorTable
;
558 gl_error(ctx
, GL_INVALID_ENUM
, "glGetColorTable(target)");
564 switch (table
->Format
) {
566 if (table
->TableType
== GL_FLOAT
) {
567 const GLfloat
*tableF
= (const GLfloat
*) table
->Table
;
568 for (i
= 0; i
< table
->Size
; i
++) {
572 rgba
[i
][ACOMP
] = (GLint
) (tableF
[i
] * 255.0F
);
576 const GLubyte
*tableUB
= (const GLubyte
*) table
->Table
;
577 for (i
= 0; i
< table
->Size
; i
++) {
581 rgba
[i
][ACOMP
] = tableUB
[i
];
586 if (table
->TableType
== GL_FLOAT
) {
587 const GLfloat
*tableF
= (const GLfloat
*) table
->Table
;
588 for (i
= 0; i
< table
->Size
; i
++) {
589 rgba
[i
][RCOMP
] = (GLint
) (tableF
[i
] * 255.0F
);
590 rgba
[i
][GCOMP
] = (GLint
) (tableF
[i
] * 255.0F
);
591 rgba
[i
][BCOMP
] = (GLint
) (tableF
[i
] * 255.0F
);
592 rgba
[i
][ACOMP
] = 255;
596 const GLubyte
*tableUB
= (const GLubyte
*) table
->Table
;
597 for (i
= 0; i
< table
->Size
; i
++) {
598 rgba
[i
][RCOMP
] = tableUB
[i
];
599 rgba
[i
][GCOMP
] = tableUB
[i
];
600 rgba
[i
][BCOMP
] = tableUB
[i
];
601 rgba
[i
][ACOMP
] = 255;
605 case GL_LUMINANCE_ALPHA
:
606 if (table
->TableType
== GL_FLOAT
) {
607 const GLfloat
*tableF
= (const GLfloat
*) table
->Table
;
608 for (i
= 0; i
< table
->Size
; i
++) {
609 rgba
[i
][RCOMP
] = (GLint
) (tableF
[i
*2+0] * 255.0F
);
610 rgba
[i
][GCOMP
] = (GLint
) (tableF
[i
*2+0] * 255.0F
);
611 rgba
[i
][BCOMP
] = (GLint
) (tableF
[i
*2+0] * 255.0F
);
612 rgba
[i
][ACOMP
] = (GLint
) (tableF
[i
*2+1] * 255.0F
);
616 const GLubyte
*tableUB
= (const GLubyte
*) table
->Table
;
617 for (i
= 0; i
< table
->Size
; i
++) {
618 rgba
[i
][RCOMP
] = tableUB
[i
*2+0];
619 rgba
[i
][GCOMP
] = tableUB
[i
*2+0];
620 rgba
[i
][BCOMP
] = tableUB
[i
*2+0];
621 rgba
[i
][ACOMP
] = tableUB
[i
*2+1];
626 if (table
->TableType
== GL_FLOAT
) {
627 const GLfloat
*tableF
= (const GLfloat
*) table
->Table
;
628 for (i
= 0; i
< table
->Size
; i
++) {
629 rgba
[i
][RCOMP
] = (GLint
) (tableF
[i
] * 255.0F
);
630 rgba
[i
][GCOMP
] = (GLint
) (tableF
[i
] * 255.0F
);
631 rgba
[i
][BCOMP
] = (GLint
) (tableF
[i
] * 255.0F
);
632 rgba
[i
][ACOMP
] = (GLint
) (tableF
[i
] * 255.0F
);
636 const GLubyte
*tableUB
= (const GLubyte
*) table
->Table
;
637 for (i
= 0; i
< table
->Size
; i
++) {
638 rgba
[i
][RCOMP
] = tableUB
[i
];
639 rgba
[i
][GCOMP
] = tableUB
[i
];
640 rgba
[i
][BCOMP
] = tableUB
[i
];
641 rgba
[i
][ACOMP
] = tableUB
[i
];
646 if (table
->TableType
== GL_FLOAT
) {
647 const GLfloat
*tableF
= (const GLfloat
*) table
->Table
;
648 for (i
= 0; i
< table
->Size
; i
++) {
649 rgba
[i
][RCOMP
] = (GLint
) (tableF
[i
*3+0] * 255.0F
);
650 rgba
[i
][GCOMP
] = (GLint
) (tableF
[i
*3+1] * 255.0F
);
651 rgba
[i
][BCOMP
] = (GLint
) (tableF
[i
*3+2] * 255.0F
);
652 rgba
[i
][ACOMP
] = 255;
656 const GLubyte
*tableUB
= (const GLubyte
*) table
->Table
;
657 for (i
= 0; i
< table
->Size
; i
++) {
658 rgba
[i
][RCOMP
] = tableUB
[i
*3+0];
659 rgba
[i
][GCOMP
] = tableUB
[i
*3+1];
660 rgba
[i
][BCOMP
] = tableUB
[i
*3+2];
661 rgba
[i
][ACOMP
] = 255;
666 if (table
->TableType
== GL_FLOAT
) {
667 const GLfloat
*tableF
= (const GLfloat
*) table
->Table
;
668 for (i
= 0; i
< table
->Size
; i
++) {
669 rgba
[i
][RCOMP
] = (GLint
) (tableF
[i
*4+0] * 255.0F
);
670 rgba
[i
][GCOMP
] = (GLint
) (tableF
[i
*4+1] * 255.0F
);
671 rgba
[i
][BCOMP
] = (GLint
) (tableF
[i
*4+2] * 255.0F
);
672 rgba
[i
][ACOMP
] = (GLint
) (tableF
[i
*4+3] * 255.0F
);
676 const GLubyte
*tableUB
= (const GLubyte
*) table
->Table
;
677 for (i
= 0; i
< table
->Size
; i
++) {
678 rgba
[i
][RCOMP
] = tableUB
[i
*4+0];
679 rgba
[i
][GCOMP
] = tableUB
[i
*4+1];
680 rgba
[i
][BCOMP
] = tableUB
[i
*4+2];
681 rgba
[i
][ACOMP
] = tableUB
[i
*4+3];
686 gl_problem(ctx
, "bad table format in glGetColorTable");
690 _mesa_pack_rgba_span(ctx
, table
->Size
, (const GLubyte (*)[]) rgba
,
691 format
, type
, data
, &ctx
->Pack
, GL_FALSE
);
697 _mesa_ColorTableParameterfv(GLenum target
, GLenum pname
, const GLfloat
*params
)
699 GET_CURRENT_CONTEXT(ctx
);
700 ASSERT_OUTSIDE_BEGIN_END(ctx
, "glColorTableParameterfv");
703 case GL_COLOR_TABLE_SGI
:
704 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
705 ctx
->Pixel
.ColorTableScale
[0] = params
[0];
706 ctx
->Pixel
.ColorTableScale
[1] = params
[1];
707 ctx
->Pixel
.ColorTableScale
[2] = params
[2];
708 ctx
->Pixel
.ColorTableScale
[3] = params
[3];
710 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
711 ctx
->Pixel
.ColorTableBias
[0] = params
[0];
712 ctx
->Pixel
.ColorTableBias
[1] = params
[1];
713 ctx
->Pixel
.ColorTableBias
[2] = params
[2];
714 ctx
->Pixel
.ColorTableBias
[3] = params
[3];
717 gl_error(ctx
, GL_INVALID_ENUM
, "glColorTableParameterfv(pname)");
721 case GL_POST_CONVOLUTION_COLOR_TABLE_SGI
:
722 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
723 ctx
->Pixel
.PCCTscale
[0] = params
[0];
724 ctx
->Pixel
.PCCTscale
[1] = params
[1];
725 ctx
->Pixel
.PCCTscale
[2] = params
[2];
726 ctx
->Pixel
.PCCTscale
[3] = params
[3];
728 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
729 ctx
->Pixel
.PCCTbias
[0] = params
[0];
730 ctx
->Pixel
.PCCTbias
[1] = params
[1];
731 ctx
->Pixel
.PCCTbias
[2] = params
[2];
732 ctx
->Pixel
.PCCTbias
[3] = params
[3];
735 gl_error(ctx
, GL_INVALID_ENUM
, "glColorTableParameterfv(pname)");
739 case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI
:
740 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
741 ctx
->Pixel
.PCMCTscale
[0] = params
[0];
742 ctx
->Pixel
.PCMCTscale
[1] = params
[1];
743 ctx
->Pixel
.PCMCTscale
[2] = params
[2];
744 ctx
->Pixel
.PCMCTscale
[3] = params
[3];
746 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
747 ctx
->Pixel
.PCMCTbias
[0] = params
[0];
748 ctx
->Pixel
.PCMCTbias
[1] = params
[1];
749 ctx
->Pixel
.PCMCTbias
[2] = params
[2];
750 ctx
->Pixel
.PCMCTbias
[3] = params
[3];
753 gl_error(ctx
, GL_INVALID_ENUM
, "glColorTableParameterfv(pname)");
758 gl_error(ctx
, GL_INVALID_ENUM
, "glColorTableParameter(target)");
766 _mesa_ColorTableParameteriv(GLenum target
, GLenum pname
, const GLint
*params
)
769 if (pname
== GL_COLOR_TABLE_SGI
||
770 pname
== GL_POST_CONVOLUTION_COLOR_TABLE_SGI
||
771 pname
== GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI
) {
773 fparams
[0] = (GLfloat
) params
[0];
774 fparams
[1] = (GLfloat
) params
[1];
775 fparams
[2] = (GLfloat
) params
[2];
776 fparams
[3] = (GLfloat
) params
[3];
780 fparams
[0] = (GLfloat
) params
[0];
782 _mesa_ColorTableParameterfv(target
, pname
, fparams
);
788 _mesa_GetColorTableParameterfv( GLenum target
, GLenum pname
, GLfloat
*params
)
790 GET_CURRENT_CONTEXT(ctx
);
791 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
792 struct gl_color_table
*table
= NULL
;
794 ASSERT_OUTSIDE_BEGIN_END(ctx
, "glGetColorTableParameterfv");
798 table
= &texUnit
->CurrentD
[1]->Palette
;
801 table
= &texUnit
->CurrentD
[2]->Palette
;
804 table
= &texUnit
->CurrentD
[3]->Palette
;
806 case GL_PROXY_TEXTURE_1D
:
807 table
= &ctx
->Texture
.Proxy1D
->Palette
;
809 case GL_PROXY_TEXTURE_2D
:
810 table
= &ctx
->Texture
.Proxy2D
->Palette
;
812 case GL_PROXY_TEXTURE_3D
:
813 table
= &ctx
->Texture
.Proxy3D
->Palette
;
815 case GL_SHARED_TEXTURE_PALETTE_EXT
:
816 table
= &ctx
->Texture
.Palette
;
819 table
= &ctx
->ColorTable
;
820 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
821 params
[0] = ctx
->Pixel
.ColorTableScale
[0];
822 params
[1] = ctx
->Pixel
.ColorTableScale
[1];
823 params
[2] = ctx
->Pixel
.ColorTableScale
[2];
824 params
[3] = ctx
->Pixel
.ColorTableScale
[3];
827 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
828 params
[0] = ctx
->Pixel
.ColorTableBias
[0];
829 params
[1] = ctx
->Pixel
.ColorTableBias
[1];
830 params
[2] = ctx
->Pixel
.ColorTableBias
[2];
831 params
[3] = ctx
->Pixel
.ColorTableBias
[3];
835 case GL_PROXY_COLOR_TABLE
:
836 table
= &ctx
->ProxyColorTable
;
838 case GL_POST_CONVOLUTION_COLOR_TABLE
:
839 table
= &ctx
->PostConvolutionColorTable
;
840 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
841 params
[0] = ctx
->Pixel
.PCCTscale
[0];
842 params
[1] = ctx
->Pixel
.PCCTscale
[1];
843 params
[2] = ctx
->Pixel
.PCCTscale
[2];
844 params
[3] = ctx
->Pixel
.PCCTscale
[3];
847 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
848 params
[0] = ctx
->Pixel
.PCCTbias
[0];
849 params
[1] = ctx
->Pixel
.PCCTbias
[1];
850 params
[2] = ctx
->Pixel
.PCCTbias
[2];
851 params
[3] = ctx
->Pixel
.PCCTbias
[3];
855 case GL_PROXY_POST_CONVOLUTION_COLOR_TABLE
:
856 table
= &ctx
->ProxyPostConvolutionColorTable
;
858 case GL_POST_COLOR_MATRIX_COLOR_TABLE
:
859 table
= &ctx
->PostColorMatrixColorTable
;
860 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
861 params
[0] = ctx
->Pixel
.PCMCTscale
[0];
862 params
[1] = ctx
->Pixel
.PCMCTscale
[1];
863 params
[2] = ctx
->Pixel
.PCMCTscale
[2];
864 params
[3] = ctx
->Pixel
.PCMCTscale
[3];
867 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
868 params
[0] = ctx
->Pixel
.PCMCTbias
[0];
869 params
[1] = ctx
->Pixel
.PCMCTbias
[1];
870 params
[2] = ctx
->Pixel
.PCMCTbias
[2];
871 params
[3] = ctx
->Pixel
.PCMCTbias
[3];
875 case GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE
:
876 table
= &ctx
->ProxyPostColorMatrixColorTable
;
879 gl_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameterfv(target)");
886 case GL_COLOR_TABLE_FORMAT
:
887 *params
= table
->IntFormat
;
889 case GL_COLOR_TABLE_WIDTH
:
890 *params
= table
->Size
;
892 case GL_COLOR_TABLE_RED_SIZE
:
893 *params
= table
->RedSize
;
895 case GL_COLOR_TABLE_GREEN_SIZE
:
896 *params
= table
->GreenSize
;
898 case GL_COLOR_TABLE_BLUE_SIZE
:
899 *params
= table
->BlueSize
;
901 case GL_COLOR_TABLE_ALPHA_SIZE
:
902 *params
= table
->AlphaSize
;
904 case GL_COLOR_TABLE_LUMINANCE_SIZE
:
905 *params
= table
->LuminanceSize
;
907 case GL_COLOR_TABLE_INTENSITY_SIZE
:
908 *params
= table
->IntensitySize
;
911 gl_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameterfv(pname)" );
919 _mesa_GetColorTableParameteriv( GLenum target
, GLenum pname
, GLint
*params
)
921 GET_CURRENT_CONTEXT(ctx
);
922 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
923 struct gl_color_table
*table
= NULL
;
925 ASSERT_OUTSIDE_BEGIN_END(ctx
, "glGetColorTableParameteriv");
929 table
= &texUnit
->CurrentD
[1]->Palette
;
932 table
= &texUnit
->CurrentD
[2]->Palette
;
935 table
= &texUnit
->CurrentD
[3]->Palette
;
937 case GL_PROXY_TEXTURE_1D
:
938 table
= &ctx
->Texture
.Proxy1D
->Palette
;
940 case GL_PROXY_TEXTURE_2D
:
941 table
= &ctx
->Texture
.Proxy2D
->Palette
;
943 case GL_PROXY_TEXTURE_3D
:
944 table
= &ctx
->Texture
.Proxy3D
->Palette
;
946 case GL_SHARED_TEXTURE_PALETTE_EXT
:
947 table
= &ctx
->Texture
.Palette
;
950 table
= &ctx
->ColorTable
;
951 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
952 params
[0] = (GLint
) ctx
->Pixel
.ColorTableScale
[0];
953 params
[1] = (GLint
) ctx
->Pixel
.ColorTableScale
[1];
954 params
[2] = (GLint
) ctx
->Pixel
.ColorTableScale
[2];
955 params
[3] = (GLint
) ctx
->Pixel
.ColorTableScale
[3];
958 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
959 params
[0] = (GLint
) ctx
->Pixel
.ColorTableBias
[0];
960 params
[1] = (GLint
) ctx
->Pixel
.ColorTableBias
[1];
961 params
[2] = (GLint
) ctx
->Pixel
.ColorTableBias
[2];
962 params
[3] = (GLint
) ctx
->Pixel
.ColorTableBias
[3];
966 case GL_PROXY_COLOR_TABLE
:
967 table
= &ctx
->ProxyColorTable
;
969 case GL_POST_CONVOLUTION_COLOR_TABLE
:
970 table
= &ctx
->PostConvolutionColorTable
;
971 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
972 params
[0] = (GLint
) ctx
->Pixel
.PCCTscale
[0];
973 params
[1] = (GLint
) ctx
->Pixel
.PCCTscale
[1];
974 params
[2] = (GLint
) ctx
->Pixel
.PCCTscale
[2];
975 params
[3] = (GLint
) ctx
->Pixel
.PCCTscale
[3];
978 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
979 params
[0] = (GLint
) ctx
->Pixel
.PCCTbias
[0];
980 params
[1] = (GLint
) ctx
->Pixel
.PCCTbias
[1];
981 params
[2] = (GLint
) ctx
->Pixel
.PCCTbias
[2];
982 params
[3] = (GLint
) ctx
->Pixel
.PCCTbias
[3];
986 case GL_PROXY_POST_CONVOLUTION_COLOR_TABLE
:
987 table
= &ctx
->ProxyPostConvolutionColorTable
;
989 case GL_POST_COLOR_MATRIX_COLOR_TABLE
:
990 table
= &ctx
->PostColorMatrixColorTable
;
991 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
992 params
[0] = (GLint
) ctx
->Pixel
.PCMCTscale
[0];
993 params
[1] = (GLint
) ctx
->Pixel
.PCMCTscale
[1];
994 params
[2] = (GLint
) ctx
->Pixel
.PCMCTscale
[2];
995 params
[3] = (GLint
) ctx
->Pixel
.PCMCTscale
[3];
998 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
999 params
[0] = (GLint
) ctx
->Pixel
.PCMCTbias
[0];
1000 params
[1] = (GLint
) ctx
->Pixel
.PCMCTbias
[1];
1001 params
[2] = (GLint
) ctx
->Pixel
.PCMCTbias
[2];
1002 params
[3] = (GLint
) ctx
->Pixel
.PCMCTbias
[3];
1006 case GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE
:
1007 table
= &ctx
->ProxyPostColorMatrixColorTable
;
1010 gl_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameteriv(target)");
1017 case GL_COLOR_TABLE_FORMAT
:
1018 *params
= table
->IntFormat
;
1020 case GL_COLOR_TABLE_WIDTH
:
1021 *params
= table
->Size
;
1023 case GL_COLOR_TABLE_RED_SIZE
:
1024 *params
= table
->RedSize
;
1026 case GL_COLOR_TABLE_GREEN_SIZE
:
1027 *params
= table
->GreenSize
;
1029 case GL_COLOR_TABLE_BLUE_SIZE
:
1030 *params
= table
->BlueSize
;
1032 case GL_COLOR_TABLE_ALPHA_SIZE
:
1033 *params
= table
->AlphaSize
;
1035 case GL_COLOR_TABLE_LUMINANCE_SIZE
:
1036 *params
= table
->LuminanceSize
;
1038 case GL_COLOR_TABLE_INTENSITY_SIZE
:
1039 *params
= table
->IntensitySize
;
1042 gl_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameteriv(pname)" );