1 /* $Id: colortab.c,v 1.17 2000/05/10 14:39:53 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
;
158 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
, "glColorTable");
162 texObj
= texUnit
->CurrentD
[1];
163 table
= &texObj
->Palette
;
166 texObj
= texUnit
->CurrentD
[2];
167 table
= &texObj
->Palette
;
170 texObj
= texUnit
->CurrentD
[3];
171 table
= &texObj
->Palette
;
173 case GL_PROXY_TEXTURE_1D
:
174 texObj
= ctx
->Texture
.Proxy1D
;
175 table
= &texObj
->Palette
;
178 case GL_PROXY_TEXTURE_2D
:
179 texObj
= ctx
->Texture
.Proxy2D
;
180 table
= &texObj
->Palette
;
183 case GL_PROXY_TEXTURE_3D
:
184 texObj
= ctx
->Texture
.Proxy3D
;
185 table
= &texObj
->Palette
;
188 case GL_SHARED_TEXTURE_PALETTE_EXT
:
189 table
= &ctx
->Texture
.Palette
;
192 table
= &ctx
->ColorTable
;
193 floatTable
= GL_TRUE
;
194 rScale
= ctx
->Pixel
.ColorTableScale
[0];
195 gScale
= ctx
->Pixel
.ColorTableScale
[1];
196 bScale
= ctx
->Pixel
.ColorTableScale
[2];
197 aScale
= ctx
->Pixel
.ColorTableScale
[3];
198 rBias
= ctx
->Pixel
.ColorTableBias
[0];
199 gBias
= ctx
->Pixel
.ColorTableBias
[1];
200 bBias
= ctx
->Pixel
.ColorTableBias
[2];
201 aBias
= ctx
->Pixel
.ColorTableBias
[3];
203 case GL_PROXY_COLOR_TABLE
:
204 table
= &ctx
->ProxyColorTable
;
207 case GL_POST_CONVOLUTION_COLOR_TABLE
:
208 table
= &ctx
->PostConvolutionColorTable
;
209 floatTable
= GL_TRUE
;
210 rScale
= ctx
->Pixel
.PCCTscale
[0];
211 gScale
= ctx
->Pixel
.PCCTscale
[1];
212 bScale
= ctx
->Pixel
.PCCTscale
[2];
213 aScale
= ctx
->Pixel
.PCCTscale
[3];
214 rBias
= ctx
->Pixel
.PCCTbias
[0];
215 gBias
= ctx
->Pixel
.PCCTbias
[1];
216 bBias
= ctx
->Pixel
.PCCTbias
[2];
217 aBias
= ctx
->Pixel
.PCCTbias
[3];
219 case GL_PROXY_POST_CONVOLUTION_COLOR_TABLE
:
220 table
= &ctx
->ProxyPostConvolutionColorTable
;
223 case GL_POST_COLOR_MATRIX_COLOR_TABLE
:
224 table
= &ctx
->PostColorMatrixColorTable
;
225 floatTable
= GL_TRUE
;
226 rScale
= ctx
->Pixel
.PCMCTscale
[0];
227 gScale
= ctx
->Pixel
.PCMCTscale
[1];
228 bScale
= ctx
->Pixel
.PCMCTscale
[2];
229 aScale
= ctx
->Pixel
.PCMCTscale
[3];
230 rBias
= ctx
->Pixel
.PCMCTbias
[0];
231 gBias
= ctx
->Pixel
.PCMCTbias
[1];
232 bBias
= ctx
->Pixel
.PCMCTbias
[2];
233 aBias
= ctx
->Pixel
.PCMCTbias
[3];
235 case GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE
:
236 table
= &ctx
->ProxyPostColorMatrixColorTable
;
240 gl_error(ctx
, GL_INVALID_ENUM
, "glColorTable(target)");
246 if (!_mesa_is_legal_format_and_type(format
, type
)) {
247 gl_error(ctx
, GL_INVALID_ENUM
, "glColorTable(format or type)");
251 baseFormat
= _mesa_base_tex_format(internalFormat
);
252 if (baseFormat
< 0 || baseFormat
== GL_COLOR_INDEX
) {
253 gl_error(ctx
, GL_INVALID_ENUM
, "glColorTable(internalFormat)");
257 if (width
< 1 || width
> ctx
->Const
.MaxColorTableSize
258 || _mesa_bitcount(width
) != 1) {
259 if (width
> ctx
->Const
.MaxColorTableSize
)
260 gl_error(ctx
, GL_TABLE_TOO_LARGE
, "glColorTable(width)");
262 gl_error(ctx
, GL_INVALID_VALUE
, "glColorTable(width)");
265 table
->IntFormat
= (GLenum
) 0;
266 table
->Format
= (GLenum
) 0;
272 table
->IntFormat
= internalFormat
;
273 table
->Format
= (GLenum
) baseFormat
;
274 set_component_sizes(table
);
276 comps
= _mesa_components_in_format(table
->Format
);
277 assert(comps
> 0); /* error should have been caught sooner */
280 /* free old table, if any */
285 GLubyte tableUB
[MAX_COLOR_TABLE_SIZE
* 4];
289 _mesa_unpack_ubyte_color_span(ctx
, width
, table
->Format
,
292 &ctx
->Unpack
, GL_TRUE
);
294 table
->TableType
= GL_FLOAT
;
295 table
->Table
= MALLOC(comps
* width
* sizeof(GLfloat
));
297 gl_error(ctx
, GL_OUT_OF_MEMORY
, "glColorTable");
301 /* Apply scale and bias and convert GLubyte values to GLfloats
302 * in [0, 1]. Store results in the tableF[].
308 tableF
= (GLfloat
*) table
->Table
;
310 switch (table
->Format
) {
312 for (i
= 0; i
< width
; i
++) {
313 tableF
[i
] = tableUB
[i
] * rScale
+ rBias
;
317 for (i
= 0; i
< width
; i
++) {
318 tableF
[i
] = tableUB
[i
] * rScale
+ rBias
;
322 for (i
= 0; i
< width
; i
++) {
323 tableF
[i
] = tableUB
[i
] * aScale
+ aBias
;
326 case GL_LUMINANCE_ALPHA
:
327 for (i
= 0; i
< width
; i
++) {
328 tableF
[i
*2+0] = tableUB
[i
*2+0] * rScale
+ rBias
;
329 tableF
[i
*2+1] = tableUB
[i
*2+1] * aScale
+ aBias
;
333 for (i
= 0; i
< width
; i
++) {
334 tableF
[i
*3+0] = tableUB
[i
*3+0] * rScale
+ rBias
;
335 tableF
[i
*3+1] = tableUB
[i
*3+1] * gScale
+ gBias
;
336 tableF
[i
*3+2] = tableUB
[i
*3+2] * bScale
+ bBias
;
340 for (i
= 0; i
< width
; i
++) {
341 tableF
[i
*4+0] = tableUB
[i
*4+0] * rScale
+ rBias
;
342 tableF
[i
*4+1] = tableUB
[i
*4+1] * gScale
+ gBias
;
343 tableF
[i
*4+2] = tableUB
[i
*4+2] * bScale
+ bBias
;
344 tableF
[i
*4+3] = tableUB
[i
*4+3] * aScale
+ aBias
;
348 gl_problem(ctx
, "Bad format in _mesa_ColorTable");
353 /* store GLubyte table */
354 table
->TableType
= GL_UNSIGNED_BYTE
;
355 table
->Table
= MALLOC(comps
* width
* sizeof(GLubyte
));
357 gl_error(ctx
, GL_OUT_OF_MEMORY
, "glColorTable");
360 _mesa_unpack_ubyte_color_span(ctx
, width
, table
->Format
,
361 table
->Table
, /* dest */
363 &ctx
->Unpack
, GL_TRUE
);
367 if (texObj
|| target
== GL_SHARED_TEXTURE_PALETTE_EXT
) {
368 /* texture object palette, texObj==NULL means the shared palette */
369 if (ctx
->Driver
.UpdateTexturePalette
) {
370 (*ctx
->Driver
.UpdateTexturePalette
)( ctx
, texObj
);
378 _mesa_ColorSubTable( GLenum target
, GLsizei start
,
379 GLsizei count
, GLenum format
, GLenum type
,
382 GET_CURRENT_CONTEXT(ctx
);
383 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
384 struct gl_texture_object
*texObj
= NULL
;
385 struct gl_color_table
*table
= NULL
;
388 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
, "glColorSubTable");
392 texObj
= texUnit
->CurrentD
[1];
393 table
= &texObj
->Palette
;
396 texObj
= texUnit
->CurrentD
[2];
397 table
= &texObj
->Palette
;
400 texObj
= texUnit
->CurrentD
[3];
401 table
= &texObj
->Palette
;
403 case GL_SHARED_TEXTURE_PALETTE_EXT
:
404 table
= &ctx
->Texture
.Palette
;
407 table
= &ctx
->ColorTable
;
409 case GL_POST_CONVOLUTION_COLOR_TABLE
:
410 table
= &ctx
->PostConvolutionColorTable
;
412 case GL_POST_COLOR_MATRIX_COLOR_TABLE
:
413 table
= &ctx
->PostColorMatrixColorTable
;
416 gl_error(ctx
, GL_INVALID_ENUM
, "glColorSubTable(target)");
422 if (!_mesa_is_legal_format_and_type(format
, type
)) {
423 gl_error(ctx
, GL_INVALID_ENUM
, "glColorSubTable(format or type)");
428 gl_error(ctx
, GL_INVALID_VALUE
, "glColorSubTable(count)");
432 comps
= _mesa_components_in_format(table
->Format
);
433 assert(comps
> 0); /* error should have been caught sooner */
435 if (start
+ count
> table
->Size
) {
436 gl_error(ctx
, GL_INVALID_VALUE
, "glColorSubTable(count)");
441 gl_error(ctx
, GL_OUT_OF_MEMORY
, "glColorSubTable");
445 if (table
->TableType
== GL_UNSIGNED_BYTE
) {
446 GLubyte
*dest
= (GLubyte
*) table
->Table
+ start
* comps
* sizeof(GLubyte
);
447 _mesa_unpack_ubyte_color_span(ctx
, count
, table
->Format
, dest
,
448 format
, type
, data
, &ctx
->Unpack
, GL_TRUE
);
451 GLfloat
*dest
= (GLfloat
*) table
->Table
+ start
* comps
* sizeof(GLfloat
);
452 ASSERT(table
->TableType
== GL_FLOAT
);
453 _mesa_unpack_float_color_span(ctx
, count
, table
->Format
, dest
,
454 format
, type
, data
, &ctx
->Unpack
,
458 if (texObj
|| target
== GL_SHARED_TEXTURE_PALETTE_EXT
) {
459 /* per-texture object palette */
460 if (ctx
->Driver
.UpdateTexturePalette
) {
461 (*ctx
->Driver
.UpdateTexturePalette
)( ctx
, texObj
);
470 _mesa_CopyColorTable(GLenum target
, GLenum internalformat
,
471 GLint x
, GLint y
, GLsizei width
)
473 GLubyte data
[MAX_WIDTH
][4];
474 GET_CURRENT_CONTEXT(ctx
);
475 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
, "glCopyColorTable");
477 /* Select buffer to read from */
478 (*ctx
->Driver
.SetReadBuffer
)( ctx
, ctx
->ReadBuffer
,
479 ctx
->Pixel
.DriverReadBuffer
);
481 if (width
> MAX_WIDTH
)
484 /* read the data from framebuffer */
485 gl_read_rgba_span( ctx
, ctx
->ReadBuffer
, width
, x
, y
, data
);
487 /* Restore reading from draw buffer (the default) */
488 (*ctx
->Driver
.SetReadBuffer
)( ctx
, ctx
->DrawBuffer
,
489 ctx
->Color
.DriverDrawBuffer
);
491 _mesa_ColorTable(target
, internalformat
, width
,
492 GL_RGBA
, GL_UNSIGNED_BYTE
, data
);
499 _mesa_CopyColorSubTable(GLenum target
, GLsizei start
,
500 GLint x
, GLint y
, GLsizei width
)
502 GLubyte data
[MAX_WIDTH
][4];
503 GET_CURRENT_CONTEXT(ctx
);
504 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
, "glCopyColorSubTable");
506 /* Select buffer to read from */
507 (*ctx
->Driver
.SetReadBuffer
)( ctx
, ctx
->ReadBuffer
,
508 ctx
->Pixel
.DriverReadBuffer
);
510 if (width
> MAX_WIDTH
)
513 /* read the data from framebuffer */
514 gl_read_rgba_span( ctx
, ctx
->ReadBuffer
, width
, x
, y
, data
);
516 /* Restore reading from draw buffer (the default) */
517 (*ctx
->Driver
.SetReadBuffer
)( ctx
, ctx
->DrawBuffer
,
518 ctx
->Color
.DriverDrawBuffer
);
520 _mesa_ColorSubTable(target
, start
, width
, GL_RGBA
, GL_UNSIGNED_BYTE
, data
);
526 _mesa_GetColorTable( GLenum target
, GLenum format
,
527 GLenum type
, GLvoid
*data
)
529 GET_CURRENT_CONTEXT(ctx
);
530 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
531 struct gl_color_table
*table
= NULL
;
532 GLubyte rgba
[MAX_COLOR_TABLE_SIZE
][4];
535 ASSERT_OUTSIDE_BEGIN_END(ctx
, "glGetColorTable");
539 table
= &texUnit
->CurrentD
[1]->Palette
;
542 table
= &texUnit
->CurrentD
[2]->Palette
;
545 table
= &texUnit
->CurrentD
[3]->Palette
;
547 case GL_SHARED_TEXTURE_PALETTE_EXT
:
548 table
= &ctx
->Texture
.Palette
;
551 table
= &ctx
->ColorTable
;
553 case GL_POST_CONVOLUTION_COLOR_TABLE
:
554 table
= &ctx
->PostConvolutionColorTable
;
556 case GL_POST_COLOR_MATRIX_COLOR_TABLE
:
557 table
= &ctx
->PostColorMatrixColorTable
;
560 gl_error(ctx
, GL_INVALID_ENUM
, "glGetColorTable(target)");
566 switch (table
->Format
) {
568 if (table
->TableType
== GL_FLOAT
) {
569 const GLfloat
*tableF
= (const GLfloat
*) table
->Table
;
570 for (i
= 0; i
< table
->Size
; i
++) {
574 rgba
[i
][ACOMP
] = (GLint
) (tableF
[i
] * 255.0F
);
578 const GLubyte
*tableUB
= (const GLubyte
*) table
->Table
;
579 for (i
= 0; i
< table
->Size
; i
++) {
583 rgba
[i
][ACOMP
] = tableUB
[i
];
588 if (table
->TableType
== GL_FLOAT
) {
589 const GLfloat
*tableF
= (const GLfloat
*) table
->Table
;
590 for (i
= 0; i
< table
->Size
; i
++) {
591 rgba
[i
][RCOMP
] = (GLint
) (tableF
[i
] * 255.0F
);
592 rgba
[i
][GCOMP
] = (GLint
) (tableF
[i
] * 255.0F
);
593 rgba
[i
][BCOMP
] = (GLint
) (tableF
[i
] * 255.0F
);
594 rgba
[i
][ACOMP
] = 255;
598 const GLubyte
*tableUB
= (const GLubyte
*) table
->Table
;
599 for (i
= 0; i
< table
->Size
; i
++) {
600 rgba
[i
][RCOMP
] = tableUB
[i
];
601 rgba
[i
][GCOMP
] = tableUB
[i
];
602 rgba
[i
][BCOMP
] = tableUB
[i
];
603 rgba
[i
][ACOMP
] = 255;
607 case GL_LUMINANCE_ALPHA
:
608 if (table
->TableType
== GL_FLOAT
) {
609 const GLfloat
*tableF
= (const GLfloat
*) table
->Table
;
610 for (i
= 0; i
< table
->Size
; i
++) {
611 rgba
[i
][RCOMP
] = (GLint
) (tableF
[i
*2+0] * 255.0F
);
612 rgba
[i
][GCOMP
] = (GLint
) (tableF
[i
*2+0] * 255.0F
);
613 rgba
[i
][BCOMP
] = (GLint
) (tableF
[i
*2+0] * 255.0F
);
614 rgba
[i
][ACOMP
] = (GLint
) (tableF
[i
*2+1] * 255.0F
);
618 const GLubyte
*tableUB
= (const GLubyte
*) table
->Table
;
619 for (i
= 0; i
< table
->Size
; i
++) {
620 rgba
[i
][RCOMP
] = tableUB
[i
*2+0];
621 rgba
[i
][GCOMP
] = tableUB
[i
*2+0];
622 rgba
[i
][BCOMP
] = tableUB
[i
*2+0];
623 rgba
[i
][ACOMP
] = tableUB
[i
*2+1];
628 if (table
->TableType
== GL_FLOAT
) {
629 const GLfloat
*tableF
= (const GLfloat
*) table
->Table
;
630 for (i
= 0; i
< table
->Size
; i
++) {
631 rgba
[i
][RCOMP
] = (GLint
) (tableF
[i
] * 255.0F
);
632 rgba
[i
][GCOMP
] = (GLint
) (tableF
[i
] * 255.0F
);
633 rgba
[i
][BCOMP
] = (GLint
) (tableF
[i
] * 255.0F
);
634 rgba
[i
][ACOMP
] = (GLint
) (tableF
[i
] * 255.0F
);
638 const GLubyte
*tableUB
= (const GLubyte
*) table
->Table
;
639 for (i
= 0; i
< table
->Size
; i
++) {
640 rgba
[i
][RCOMP
] = tableUB
[i
];
641 rgba
[i
][GCOMP
] = tableUB
[i
];
642 rgba
[i
][BCOMP
] = tableUB
[i
];
643 rgba
[i
][ACOMP
] = tableUB
[i
];
648 if (table
->TableType
== GL_FLOAT
) {
649 const GLfloat
*tableF
= (const GLfloat
*) table
->Table
;
650 for (i
= 0; i
< table
->Size
; i
++) {
651 rgba
[i
][RCOMP
] = (GLint
) (tableF
[i
*3+0] * 255.0F
);
652 rgba
[i
][GCOMP
] = (GLint
) (tableF
[i
*3+1] * 255.0F
);
653 rgba
[i
][BCOMP
] = (GLint
) (tableF
[i
*3+2] * 255.0F
);
654 rgba
[i
][ACOMP
] = 255;
658 const GLubyte
*tableUB
= (const GLubyte
*) table
->Table
;
659 for (i
= 0; i
< table
->Size
; i
++) {
660 rgba
[i
][RCOMP
] = tableUB
[i
*3+0];
661 rgba
[i
][GCOMP
] = tableUB
[i
*3+1];
662 rgba
[i
][BCOMP
] = tableUB
[i
*3+2];
663 rgba
[i
][ACOMP
] = 255;
668 if (table
->TableType
== GL_FLOAT
) {
669 const GLfloat
*tableF
= (const GLfloat
*) table
->Table
;
670 for (i
= 0; i
< table
->Size
; i
++) {
671 rgba
[i
][RCOMP
] = (GLint
) (tableF
[i
*4+0] * 255.0F
);
672 rgba
[i
][GCOMP
] = (GLint
) (tableF
[i
*4+1] * 255.0F
);
673 rgba
[i
][BCOMP
] = (GLint
) (tableF
[i
*4+2] * 255.0F
);
674 rgba
[i
][ACOMP
] = (GLint
) (tableF
[i
*4+3] * 255.0F
);
678 const GLubyte
*tableUB
= (const GLubyte
*) table
->Table
;
679 for (i
= 0; i
< table
->Size
; i
++) {
680 rgba
[i
][RCOMP
] = tableUB
[i
*4+0];
681 rgba
[i
][GCOMP
] = tableUB
[i
*4+1];
682 rgba
[i
][BCOMP
] = tableUB
[i
*4+2];
683 rgba
[i
][ACOMP
] = tableUB
[i
*4+3];
688 gl_problem(ctx
, "bad table format in glGetColorTable");
692 _mesa_pack_rgba_span(ctx
, table
->Size
, (const GLubyte (*)[]) rgba
,
693 format
, type
, data
, &ctx
->Pack
, GL_FALSE
);
699 _mesa_ColorTableParameterfv(GLenum target
, GLenum pname
, const GLfloat
*params
)
701 GET_CURRENT_CONTEXT(ctx
);
702 ASSERT_OUTSIDE_BEGIN_END(ctx
, "glColorTableParameterfv");
705 case GL_COLOR_TABLE_SGI
:
706 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
707 ctx
->Pixel
.ColorTableScale
[0] = params
[0];
708 ctx
->Pixel
.ColorTableScale
[1] = params
[1];
709 ctx
->Pixel
.ColorTableScale
[2] = params
[2];
710 ctx
->Pixel
.ColorTableScale
[3] = params
[3];
712 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
713 ctx
->Pixel
.ColorTableBias
[0] = params
[0];
714 ctx
->Pixel
.ColorTableBias
[1] = params
[1];
715 ctx
->Pixel
.ColorTableBias
[2] = params
[2];
716 ctx
->Pixel
.ColorTableBias
[3] = params
[3];
719 gl_error(ctx
, GL_INVALID_ENUM
, "glColorTableParameterfv(pname)");
723 case GL_POST_CONVOLUTION_COLOR_TABLE_SGI
:
724 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
725 ctx
->Pixel
.PCCTscale
[0] = params
[0];
726 ctx
->Pixel
.PCCTscale
[1] = params
[1];
727 ctx
->Pixel
.PCCTscale
[2] = params
[2];
728 ctx
->Pixel
.PCCTscale
[3] = params
[3];
730 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
731 ctx
->Pixel
.PCCTbias
[0] = params
[0];
732 ctx
->Pixel
.PCCTbias
[1] = params
[1];
733 ctx
->Pixel
.PCCTbias
[2] = params
[2];
734 ctx
->Pixel
.PCCTbias
[3] = params
[3];
737 gl_error(ctx
, GL_INVALID_ENUM
, "glColorTableParameterfv(pname)");
741 case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI
:
742 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
743 ctx
->Pixel
.PCMCTscale
[0] = params
[0];
744 ctx
->Pixel
.PCMCTscale
[1] = params
[1];
745 ctx
->Pixel
.PCMCTscale
[2] = params
[2];
746 ctx
->Pixel
.PCMCTscale
[3] = params
[3];
748 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
749 ctx
->Pixel
.PCMCTbias
[0] = params
[0];
750 ctx
->Pixel
.PCMCTbias
[1] = params
[1];
751 ctx
->Pixel
.PCMCTbias
[2] = params
[2];
752 ctx
->Pixel
.PCMCTbias
[3] = params
[3];
755 gl_error(ctx
, GL_INVALID_ENUM
, "glColorTableParameterfv(pname)");
760 gl_error(ctx
, GL_INVALID_ENUM
, "glColorTableParameter(target)");
768 _mesa_ColorTableParameteriv(GLenum target
, GLenum pname
, const GLint
*params
)
771 if (pname
== GL_COLOR_TABLE_SGI
||
772 pname
== GL_POST_CONVOLUTION_COLOR_TABLE_SGI
||
773 pname
== GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI
) {
775 fparams
[0] = (GLfloat
) params
[0];
776 fparams
[1] = (GLfloat
) params
[1];
777 fparams
[2] = (GLfloat
) params
[2];
778 fparams
[3] = (GLfloat
) params
[3];
782 fparams
[0] = (GLfloat
) params
[0];
784 _mesa_ColorTableParameterfv(target
, pname
, fparams
);
790 _mesa_GetColorTableParameterfv( GLenum target
, GLenum pname
, GLfloat
*params
)
792 GET_CURRENT_CONTEXT(ctx
);
793 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
794 struct gl_color_table
*table
= NULL
;
796 ASSERT_OUTSIDE_BEGIN_END(ctx
, "glGetColorTableParameterfv");
800 table
= &texUnit
->CurrentD
[1]->Palette
;
803 table
= &texUnit
->CurrentD
[2]->Palette
;
806 table
= &texUnit
->CurrentD
[3]->Palette
;
808 case GL_PROXY_TEXTURE_1D
:
809 table
= &ctx
->Texture
.Proxy1D
->Palette
;
811 case GL_PROXY_TEXTURE_2D
:
812 table
= &ctx
->Texture
.Proxy2D
->Palette
;
814 case GL_PROXY_TEXTURE_3D
:
815 table
= &ctx
->Texture
.Proxy3D
->Palette
;
817 case GL_SHARED_TEXTURE_PALETTE_EXT
:
818 table
= &ctx
->Texture
.Palette
;
821 table
= &ctx
->ColorTable
;
822 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
823 params
[0] = ctx
->Pixel
.ColorTableScale
[0];
824 params
[1] = ctx
->Pixel
.ColorTableScale
[1];
825 params
[2] = ctx
->Pixel
.ColorTableScale
[2];
826 params
[3] = ctx
->Pixel
.ColorTableScale
[3];
829 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
830 params
[0] = ctx
->Pixel
.ColorTableBias
[0];
831 params
[1] = ctx
->Pixel
.ColorTableBias
[1];
832 params
[2] = ctx
->Pixel
.ColorTableBias
[2];
833 params
[3] = ctx
->Pixel
.ColorTableBias
[3];
837 case GL_PROXY_COLOR_TABLE
:
838 table
= &ctx
->ProxyColorTable
;
840 case GL_POST_CONVOLUTION_COLOR_TABLE
:
841 table
= &ctx
->PostConvolutionColorTable
;
842 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
843 params
[0] = ctx
->Pixel
.PCCTscale
[0];
844 params
[1] = ctx
->Pixel
.PCCTscale
[1];
845 params
[2] = ctx
->Pixel
.PCCTscale
[2];
846 params
[3] = ctx
->Pixel
.PCCTscale
[3];
849 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
850 params
[0] = ctx
->Pixel
.PCCTbias
[0];
851 params
[1] = ctx
->Pixel
.PCCTbias
[1];
852 params
[2] = ctx
->Pixel
.PCCTbias
[2];
853 params
[3] = ctx
->Pixel
.PCCTbias
[3];
857 case GL_PROXY_POST_CONVOLUTION_COLOR_TABLE
:
858 table
= &ctx
->ProxyPostConvolutionColorTable
;
860 case GL_POST_COLOR_MATRIX_COLOR_TABLE
:
861 table
= &ctx
->PostColorMatrixColorTable
;
862 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
863 params
[0] = ctx
->Pixel
.PCMCTscale
[0];
864 params
[1] = ctx
->Pixel
.PCMCTscale
[1];
865 params
[2] = ctx
->Pixel
.PCMCTscale
[2];
866 params
[3] = ctx
->Pixel
.PCMCTscale
[3];
869 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
870 params
[0] = ctx
->Pixel
.PCMCTbias
[0];
871 params
[1] = ctx
->Pixel
.PCMCTbias
[1];
872 params
[2] = ctx
->Pixel
.PCMCTbias
[2];
873 params
[3] = ctx
->Pixel
.PCMCTbias
[3];
877 case GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE
:
878 table
= &ctx
->ProxyPostColorMatrixColorTable
;
881 gl_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameterfv(target)");
888 case GL_COLOR_TABLE_FORMAT
:
889 *params
= table
->IntFormat
;
891 case GL_COLOR_TABLE_WIDTH
:
892 *params
= table
->Size
;
894 case GL_COLOR_TABLE_RED_SIZE
:
895 *params
= table
->RedSize
;
897 case GL_COLOR_TABLE_GREEN_SIZE
:
898 *params
= table
->GreenSize
;
900 case GL_COLOR_TABLE_BLUE_SIZE
:
901 *params
= table
->BlueSize
;
903 case GL_COLOR_TABLE_ALPHA_SIZE
:
904 *params
= table
->AlphaSize
;
906 case GL_COLOR_TABLE_LUMINANCE_SIZE
:
907 *params
= table
->LuminanceSize
;
909 case GL_COLOR_TABLE_INTENSITY_SIZE
:
910 *params
= table
->IntensitySize
;
913 gl_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameterfv(pname)" );
921 _mesa_GetColorTableParameteriv( GLenum target
, GLenum pname
, GLint
*params
)
923 GET_CURRENT_CONTEXT(ctx
);
924 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
925 struct gl_color_table
*table
= NULL
;
927 ASSERT_OUTSIDE_BEGIN_END(ctx
, "glGetColorTableParameteriv");
931 table
= &texUnit
->CurrentD
[1]->Palette
;
934 table
= &texUnit
->CurrentD
[2]->Palette
;
937 table
= &texUnit
->CurrentD
[3]->Palette
;
939 case GL_PROXY_TEXTURE_1D
:
940 table
= &ctx
->Texture
.Proxy1D
->Palette
;
942 case GL_PROXY_TEXTURE_2D
:
943 table
= &ctx
->Texture
.Proxy2D
->Palette
;
945 case GL_PROXY_TEXTURE_3D
:
946 table
= &ctx
->Texture
.Proxy3D
->Palette
;
948 case GL_SHARED_TEXTURE_PALETTE_EXT
:
949 table
= &ctx
->Texture
.Palette
;
952 table
= &ctx
->ColorTable
;
953 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
954 params
[0] = (GLint
) ctx
->Pixel
.ColorTableScale
[0];
955 params
[1] = (GLint
) ctx
->Pixel
.ColorTableScale
[1];
956 params
[2] = (GLint
) ctx
->Pixel
.ColorTableScale
[2];
957 params
[3] = (GLint
) ctx
->Pixel
.ColorTableScale
[3];
960 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
961 params
[0] = (GLint
) ctx
->Pixel
.ColorTableBias
[0];
962 params
[1] = (GLint
) ctx
->Pixel
.ColorTableBias
[1];
963 params
[2] = (GLint
) ctx
->Pixel
.ColorTableBias
[2];
964 params
[3] = (GLint
) ctx
->Pixel
.ColorTableBias
[3];
968 case GL_PROXY_COLOR_TABLE
:
969 table
= &ctx
->ProxyColorTable
;
971 case GL_POST_CONVOLUTION_COLOR_TABLE
:
972 table
= &ctx
->PostConvolutionColorTable
;
973 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
974 params
[0] = (GLint
) ctx
->Pixel
.PCCTscale
[0];
975 params
[1] = (GLint
) ctx
->Pixel
.PCCTscale
[1];
976 params
[2] = (GLint
) ctx
->Pixel
.PCCTscale
[2];
977 params
[3] = (GLint
) ctx
->Pixel
.PCCTscale
[3];
980 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
981 params
[0] = (GLint
) ctx
->Pixel
.PCCTbias
[0];
982 params
[1] = (GLint
) ctx
->Pixel
.PCCTbias
[1];
983 params
[2] = (GLint
) ctx
->Pixel
.PCCTbias
[2];
984 params
[3] = (GLint
) ctx
->Pixel
.PCCTbias
[3];
988 case GL_PROXY_POST_CONVOLUTION_COLOR_TABLE
:
989 table
= &ctx
->ProxyPostConvolutionColorTable
;
991 case GL_POST_COLOR_MATRIX_COLOR_TABLE
:
992 table
= &ctx
->PostColorMatrixColorTable
;
993 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
994 params
[0] = (GLint
) ctx
->Pixel
.PCMCTscale
[0];
995 params
[1] = (GLint
) ctx
->Pixel
.PCMCTscale
[1];
996 params
[2] = (GLint
) ctx
->Pixel
.PCMCTscale
[2];
997 params
[3] = (GLint
) ctx
->Pixel
.PCMCTscale
[3];
1000 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
1001 params
[0] = (GLint
) ctx
->Pixel
.PCMCTbias
[0];
1002 params
[1] = (GLint
) ctx
->Pixel
.PCMCTbias
[1];
1003 params
[2] = (GLint
) ctx
->Pixel
.PCMCTbias
[2];
1004 params
[3] = (GLint
) ctx
->Pixel
.PCMCTbias
[3];
1008 case GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE
:
1009 table
= &ctx
->ProxyPostColorMatrixColorTable
;
1012 gl_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameteriv(target)");
1019 case GL_COLOR_TABLE_FORMAT
:
1020 *params
= table
->IntFormat
;
1022 case GL_COLOR_TABLE_WIDTH
:
1023 *params
= table
->Size
;
1025 case GL_COLOR_TABLE_RED_SIZE
:
1026 *params
= table
->RedSize
;
1028 case GL_COLOR_TABLE_GREEN_SIZE
:
1029 *params
= table
->GreenSize
;
1031 case GL_COLOR_TABLE_BLUE_SIZE
:
1032 *params
= table
->BlueSize
;
1034 case GL_COLOR_TABLE_ALPHA_SIZE
:
1035 *params
= table
->AlphaSize
;
1037 case GL_COLOR_TABLE_LUMINANCE_SIZE
:
1038 *params
= table
->LuminanceSize
;
1040 case GL_COLOR_TABLE_INTENSITY_SIZE
:
1041 *params
= table
->IntensitySize
;
1044 gl_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameteriv(pname)" );