2 * Mesa 3-D graphics library
5 * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
36 * Given an internalFormat token passed to glColorTable,
37 * return the corresponding base format.
38 * Return -1 if invalid token.
41 base_colortab_format( GLenum format
)
56 case GL_LUMINANCE_ALPHA
:
57 case GL_LUMINANCE4_ALPHA4
:
58 case GL_LUMINANCE6_ALPHA2
:
59 case GL_LUMINANCE8_ALPHA8
:
60 case GL_LUMINANCE12_ALPHA4
:
61 case GL_LUMINANCE12_ALPHA12
:
62 case GL_LUMINANCE16_ALPHA16
:
63 return GL_LUMINANCE_ALPHA
;
89 return -1; /* error */
96 * Examine table's format and set the component sizes accordingly.
99 set_component_sizes( struct gl_color_table
*table
)
103 switch (table
->Type
) {
104 case GL_UNSIGNED_BYTE
:
105 sz
= sizeof(GLubyte
);
107 case GL_UNSIGNED_SHORT
:
108 sz
= sizeof(GLushort
);
111 sz
= sizeof(GLfloat
);
114 _mesa_problem(NULL
, "bad color table type in set_component_sizes 0x%x", table
->Type
);
118 switch (table
->Format
) {
121 table
->GreenSize
= 0;
123 table
->AlphaSize
= sz
;
124 table
->IntensitySize
= 0;
125 table
->LuminanceSize
= 0;
129 table
->GreenSize
= 0;
131 table
->AlphaSize
= 0;
132 table
->IntensitySize
= 0;
133 table
->LuminanceSize
= sz
;
135 case GL_LUMINANCE_ALPHA
:
137 table
->GreenSize
= 0;
139 table
->AlphaSize
= sz
;
140 table
->IntensitySize
= 0;
141 table
->LuminanceSize
= sz
;
145 table
->GreenSize
= 0;
147 table
->AlphaSize
= 0;
148 table
->IntensitySize
= sz
;
149 table
->LuminanceSize
= 0;
153 table
->GreenSize
= sz
;
154 table
->BlueSize
= sz
;
155 table
->AlphaSize
= 0;
156 table
->IntensitySize
= 0;
157 table
->LuminanceSize
= 0;
161 table
->GreenSize
= sz
;
162 table
->BlueSize
= sz
;
163 table
->AlphaSize
= sz
;
164 table
->IntensitySize
= 0;
165 table
->LuminanceSize
= 0;
168 _mesa_problem(NULL
, "unexpected format in set_component_sizes");
175 * Update/replace all or part of a color table. Helper function
176 * used by _mesa_ColorTable() and _mesa_ColorSubTable().
177 * The table->Table buffer should already be allocated.
178 * \param start - first entry to update
179 * \param count - number of entries to update
180 * \param format - format of user-provided table data
181 * \param type - datatype of user-provided table data
182 * \param data - user-provided table data
183 * \param [rgba]Scale - RGBA scale factors
184 * \param [rgba]Bias - RGBA bias factors
187 store_colortable_entries(GLcontext
*ctx
, struct gl_color_table
*table
,
188 GLsizei start
, GLsizei count
,
189 GLenum format
, GLenum type
, const GLvoid
*data
,
190 GLfloat rScale
, GLfloat rBias
,
191 GLfloat gScale
, GLfloat gBias
,
192 GLfloat bScale
, GLfloat bBias
,
193 GLfloat aScale
, GLfloat aBias
)
195 if (table
->Type
== GL_FLOAT
) {
196 /* convert user-provided data to GLfloat values */
197 GLfloat tempTab
[MAX_COLOR_TABLE_SIZE
* 4];
201 _mesa_unpack_float_color_span(ctx
,
202 count
, /* number of pixels */
203 table
->Format
, /* dest format */
204 tempTab
, /* dest address */
205 format
, type
, data
, /* src data */
207 0, /* transfer ops */
208 GL_FALSE
); /* clamping */
210 tableF
= (GLfloat
*) table
->Table
;
212 switch (table
->Format
) {
214 for (i
= 0; i
< count
; i
++) {
215 GLuint j
= start
+ i
;
216 tableF
[j
] = CLAMP(tempTab
[i
] * rScale
+ rBias
, 0.0F
, 1.0F
);
220 for (i
= 0; i
< count
; i
++) {
221 GLuint j
= start
+ i
;
222 tableF
[j
] = CLAMP(tempTab
[i
] * rScale
+ rBias
, 0.0F
, 1.0F
);
226 for (i
= 0; i
< count
; i
++) {
227 GLuint j
= start
+ i
;
228 tableF
[j
] = CLAMP(tempTab
[i
] * aScale
+ aBias
, 0.0F
, 1.0F
);
231 case GL_LUMINANCE_ALPHA
:
232 for (i
= 0; i
< count
; i
++) {
233 GLuint j
= start
+ i
;
234 tableF
[j
*2+0] = CLAMP(tempTab
[i
*2+0] * rScale
+ rBias
, 0.0F
, 1.0F
);
235 tableF
[j
*2+1] = CLAMP(tempTab
[i
*2+1] * aScale
+ aBias
, 0.0F
, 1.0F
);
239 for (i
= 0; i
< count
; i
++) {
240 GLuint j
= start
+ i
;
241 tableF
[j
*3+0] = CLAMP(tempTab
[i
*3+0] * rScale
+ rBias
, 0.0F
, 1.0F
);
242 tableF
[j
*3+1] = CLAMP(tempTab
[i
*3+1] * gScale
+ gBias
, 0.0F
, 1.0F
);
243 tableF
[j
*3+2] = CLAMP(tempTab
[i
*3+2] * bScale
+ bBias
, 0.0F
, 1.0F
);
247 for (i
= 0; i
< count
; i
++) {
248 GLuint j
= start
+ i
;
249 tableF
[j
*4+0] = CLAMP(tempTab
[i
*4+0] * rScale
+ rBias
, 0.0F
, 1.0F
);
250 tableF
[j
*4+1] = CLAMP(tempTab
[i
*4+1] * gScale
+ gBias
, 0.0F
, 1.0F
);
251 tableF
[j
*4+2] = CLAMP(tempTab
[i
*4+2] * bScale
+ bBias
, 0.0F
, 1.0F
);
252 tableF
[j
*4+3] = CLAMP(tempTab
[i
*4+3] * aScale
+ aBias
, 0.0F
, 1.0F
);
256 _mesa_problem(ctx
, "Bad format in store_colortable_entries");
261 /* non-float (GLchan) */
262 const GLint comps
= _mesa_components_in_format(table
->Format
);
263 GLchan
*dest
= (GLchan
*) table
->Table
+ start
* comps
;
264 _mesa_unpack_chan_color_span(ctx
, count
, /* number of entries */
265 table
->Format
, /* dest format */
266 dest
, /* dest address */
267 format
, type
, data
, /* src data */
269 0); /* transfer ops */
276 _mesa_ColorTable( GLenum target
, GLenum internalFormat
,
277 GLsizei width
, GLenum format
, GLenum type
,
280 GET_CURRENT_CONTEXT(ctx
);
281 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
282 struct gl_texture_object
*texObj
= NULL
;
283 struct gl_color_table
*table
= NULL
;
284 GLboolean proxy
= GL_FALSE
;
286 GLfloat rScale
= 1.0, gScale
= 1.0, bScale
= 1.0, aScale
= 1.0;
287 GLfloat rBias
= 0.0, gBias
= 0.0, bBias
= 0.0, aBias
= 0.0;
288 GLenum tableType
= CHAN_TYPE
;
290 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
); /* too complex */
294 texObj
= texUnit
->Current1D
;
295 table
= &texObj
->Palette
;
298 texObj
= texUnit
->Current2D
;
299 table
= &texObj
->Palette
;
302 texObj
= texUnit
->Current3D
;
303 table
= &texObj
->Palette
;
305 case GL_TEXTURE_CUBE_MAP_ARB
:
306 if (!ctx
->Extensions
.ARB_texture_cube_map
) {
307 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTable(target)");
310 texObj
= texUnit
->CurrentCubeMap
;
311 table
= &texObj
->Palette
;
313 case GL_PROXY_TEXTURE_1D
:
314 texObj
= ctx
->Texture
.Proxy1D
;
315 table
= &texObj
->Palette
;
318 case GL_PROXY_TEXTURE_2D
:
319 texObj
= ctx
->Texture
.Proxy2D
;
320 table
= &texObj
->Palette
;
323 case GL_PROXY_TEXTURE_3D
:
324 texObj
= ctx
->Texture
.Proxy3D
;
325 table
= &texObj
->Palette
;
328 case GL_PROXY_TEXTURE_CUBE_MAP_ARB
:
329 if (!ctx
->Extensions
.ARB_texture_cube_map
) {
330 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTable(target)");
333 texObj
= ctx
->Texture
.ProxyCubeMap
;
334 table
= &texObj
->Palette
;
336 case GL_SHARED_TEXTURE_PALETTE_EXT
:
337 table
= &ctx
->Texture
.Palette
;
340 table
= &ctx
->ColorTable
;
341 tableType
= GL_FLOAT
;
342 rScale
= ctx
->Pixel
.ColorTableScale
[0];
343 gScale
= ctx
->Pixel
.ColorTableScale
[1];
344 bScale
= ctx
->Pixel
.ColorTableScale
[2];
345 aScale
= ctx
->Pixel
.ColorTableScale
[3];
346 rBias
= ctx
->Pixel
.ColorTableBias
[0];
347 gBias
= ctx
->Pixel
.ColorTableBias
[1];
348 bBias
= ctx
->Pixel
.ColorTableBias
[2];
349 aBias
= ctx
->Pixel
.ColorTableBias
[3];
351 case GL_PROXY_COLOR_TABLE
:
352 table
= &ctx
->ProxyColorTable
;
355 case GL_TEXTURE_COLOR_TABLE_SGI
:
356 if (!ctx
->Extensions
.SGI_texture_color_table
) {
357 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTable(target)");
360 table
= &(texUnit
->ColorTable
);
361 tableType
= GL_FLOAT
;
362 rScale
= ctx
->Pixel
.TextureColorTableScale
[0];
363 gScale
= ctx
->Pixel
.TextureColorTableScale
[1];
364 bScale
= ctx
->Pixel
.TextureColorTableScale
[2];
365 aScale
= ctx
->Pixel
.TextureColorTableScale
[3];
366 rBias
= ctx
->Pixel
.TextureColorTableBias
[0];
367 gBias
= ctx
->Pixel
.TextureColorTableBias
[1];
368 bBias
= ctx
->Pixel
.TextureColorTableBias
[2];
369 aBias
= ctx
->Pixel
.TextureColorTableBias
[3];
371 case GL_PROXY_TEXTURE_COLOR_TABLE_SGI
:
372 if (!ctx
->Extensions
.SGI_texture_color_table
) {
373 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTable(target)");
376 table
= &(texUnit
->ProxyColorTable
);
379 case GL_POST_CONVOLUTION_COLOR_TABLE
:
380 table
= &ctx
->PostConvolutionColorTable
;
381 tableType
= GL_FLOAT
;
382 rScale
= ctx
->Pixel
.PCCTscale
[0];
383 gScale
= ctx
->Pixel
.PCCTscale
[1];
384 bScale
= ctx
->Pixel
.PCCTscale
[2];
385 aScale
= ctx
->Pixel
.PCCTscale
[3];
386 rBias
= ctx
->Pixel
.PCCTbias
[0];
387 gBias
= ctx
->Pixel
.PCCTbias
[1];
388 bBias
= ctx
->Pixel
.PCCTbias
[2];
389 aBias
= ctx
->Pixel
.PCCTbias
[3];
391 case GL_PROXY_POST_CONVOLUTION_COLOR_TABLE
:
392 table
= &ctx
->ProxyPostConvolutionColorTable
;
395 case GL_POST_COLOR_MATRIX_COLOR_TABLE
:
396 table
= &ctx
->PostColorMatrixColorTable
;
397 tableType
= GL_FLOAT
;
398 rScale
= ctx
->Pixel
.PCMCTscale
[0];
399 gScale
= ctx
->Pixel
.PCMCTscale
[1];
400 bScale
= ctx
->Pixel
.PCMCTscale
[2];
401 aScale
= ctx
->Pixel
.PCMCTscale
[3];
402 rBias
= ctx
->Pixel
.PCMCTbias
[0];
403 gBias
= ctx
->Pixel
.PCMCTbias
[1];
404 bBias
= ctx
->Pixel
.PCMCTbias
[2];
405 aBias
= ctx
->Pixel
.PCMCTbias
[3];
407 case GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE
:
408 table
= &ctx
->ProxyPostColorMatrixColorTable
;
412 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTable(target)");
418 if (!_mesa_is_legal_format_and_type(format
, type
) ||
419 format
== GL_INTENSITY
) {
420 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glColorTable(format or type)");
424 baseFormat
= base_colortab_format(internalFormat
);
425 if (baseFormat
< 0 || baseFormat
== GL_COLOR_INDEX
) {
426 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTable(internalFormat)");
430 if (width
< 0 || (width
!= 0 && _mesa_bitcount(width
) != 1)) {
434 table
->IntFormat
= (GLenum
) 0;
435 table
->Format
= (GLenum
) 0;
438 _mesa_error(ctx
, GL_INVALID_VALUE
, "glColorTable(width=%d)", width
);
443 if (width
> (GLsizei
) ctx
->Const
.MaxColorTableSize
) {
446 table
->IntFormat
= (GLenum
) 0;
447 table
->Format
= (GLenum
) 0;
450 _mesa_error(ctx
, GL_TABLE_TOO_LARGE
, "glColorTable(width)");
456 table
->IntFormat
= internalFormat
;
457 table
->Format
= (GLenum
) baseFormat
;
458 set_component_sizes(table
);
460 comps
= _mesa_components_in_format(table
->Format
);
461 assert(comps
> 0); /* error should have been caught sooner */
464 /* free old table, if any */
471 if (tableType
== GL_FLOAT
) {
472 table
->Type
= GL_FLOAT
;
473 table
->Table
= MALLOC(comps
* width
* sizeof(GLfloat
));
476 table
->Type
= CHAN_TYPE
;
477 table
->Table
= MALLOC(comps
* width
* sizeof(GLchan
));
481 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glColorTable");
485 store_colortable_entries(ctx
, table
,
486 0, width
, /* start, count */
495 if (texObj
|| target
== GL_SHARED_TEXTURE_PALETTE_EXT
) {
496 /* texture object palette, texObj==NULL means the shared palette */
497 if (ctx
->Driver
.UpdateTexturePalette
) {
498 (*ctx
->Driver
.UpdateTexturePalette
)( ctx
, texObj
);
502 ctx
->NewState
|= _NEW_PIXEL
;
508 _mesa_ColorSubTable( GLenum target
, GLsizei start
,
509 GLsizei count
, GLenum format
, GLenum type
,
512 GET_CURRENT_CONTEXT(ctx
);
513 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
514 struct gl_texture_object
*texObj
= NULL
;
515 struct gl_color_table
*table
= NULL
;
516 GLfloat rScale
= 1.0, gScale
= 1.0, bScale
= 1.0, aScale
= 1.0;
517 GLfloat rBias
= 0.0, gBias
= 0.0, bBias
= 0.0, aBias
= 0.0;
519 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
523 texObj
= texUnit
->Current1D
;
524 table
= &texObj
->Palette
;
527 texObj
= texUnit
->Current2D
;
528 table
= &texObj
->Palette
;
531 texObj
= texUnit
->Current3D
;
532 table
= &texObj
->Palette
;
534 case GL_TEXTURE_CUBE_MAP_ARB
:
535 if (!ctx
->Extensions
.ARB_texture_cube_map
) {
536 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorSubTable(target)");
539 texObj
= texUnit
->CurrentCubeMap
;
540 table
= &texObj
->Palette
;
542 case GL_SHARED_TEXTURE_PALETTE_EXT
:
543 table
= &ctx
->Texture
.Palette
;
546 table
= &ctx
->ColorTable
;
547 rScale
= ctx
->Pixel
.ColorTableScale
[0];
548 gScale
= ctx
->Pixel
.ColorTableScale
[1];
549 bScale
= ctx
->Pixel
.ColorTableScale
[2];
550 aScale
= ctx
->Pixel
.ColorTableScale
[3];
551 rBias
= ctx
->Pixel
.ColorTableBias
[0];
552 gBias
= ctx
->Pixel
.ColorTableBias
[1];
553 bBias
= ctx
->Pixel
.ColorTableBias
[2];
554 aBias
= ctx
->Pixel
.ColorTableBias
[3];
556 case GL_TEXTURE_COLOR_TABLE_SGI
:
557 if (!ctx
->Extensions
.SGI_texture_color_table
) {
558 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorSubTable(target)");
561 table
= &(texUnit
->ColorTable
);
562 rScale
= ctx
->Pixel
.TextureColorTableScale
[0];
563 gScale
= ctx
->Pixel
.TextureColorTableScale
[1];
564 bScale
= ctx
->Pixel
.TextureColorTableScale
[2];
565 aScale
= ctx
->Pixel
.TextureColorTableScale
[3];
566 rBias
= ctx
->Pixel
.TextureColorTableBias
[0];
567 gBias
= ctx
->Pixel
.TextureColorTableBias
[1];
568 bBias
= ctx
->Pixel
.TextureColorTableBias
[2];
569 aBias
= ctx
->Pixel
.TextureColorTableBias
[3];
571 case GL_POST_CONVOLUTION_COLOR_TABLE
:
572 table
= &ctx
->PostConvolutionColorTable
;
573 rScale
= ctx
->Pixel
.PCCTscale
[0];
574 gScale
= ctx
->Pixel
.PCCTscale
[1];
575 bScale
= ctx
->Pixel
.PCCTscale
[2];
576 aScale
= ctx
->Pixel
.PCCTscale
[3];
577 rBias
= ctx
->Pixel
.PCCTbias
[0];
578 gBias
= ctx
->Pixel
.PCCTbias
[1];
579 bBias
= ctx
->Pixel
.PCCTbias
[2];
580 aBias
= ctx
->Pixel
.PCCTbias
[3];
582 case GL_POST_COLOR_MATRIX_COLOR_TABLE
:
583 table
= &ctx
->PostColorMatrixColorTable
;
584 rScale
= ctx
->Pixel
.PCMCTscale
[0];
585 gScale
= ctx
->Pixel
.PCMCTscale
[1];
586 bScale
= ctx
->Pixel
.PCMCTscale
[2];
587 aScale
= ctx
->Pixel
.PCMCTscale
[3];
588 rBias
= ctx
->Pixel
.PCMCTbias
[0];
589 gBias
= ctx
->Pixel
.PCMCTbias
[1];
590 bBias
= ctx
->Pixel
.PCMCTbias
[2];
591 aBias
= ctx
->Pixel
.PCMCTbias
[3];
594 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorSubTable(target)");
600 if (!_mesa_is_legal_format_and_type(format
, type
) ||
601 format
== GL_INTENSITY
) {
602 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glColorSubTable(format or type)");
607 _mesa_error(ctx
, GL_INVALID_VALUE
, "glColorSubTable(count)");
611 comps
= _mesa_components_in_format(table
->Format
);
612 assert(comps
> 0); /* error should have been caught sooner */
614 if (start
+ count
> (GLint
) table
->Size
) {
615 _mesa_error(ctx
, GL_INVALID_VALUE
, "glColorSubTable(count)");
620 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glColorSubTable");
624 store_colortable_entries(ctx
, table
, start
, count
,
631 if (texObj
|| target
== GL_SHARED_TEXTURE_PALETTE_EXT
) {
632 /* per-texture object palette */
633 if (ctx
->Driver
.UpdateTexturePalette
) {
634 (*ctx
->Driver
.UpdateTexturePalette
)( ctx
, texObj
);
638 ctx
->NewState
|= _NEW_PIXEL
;
645 _mesa_CopyColorTable(GLenum target
, GLenum internalformat
,
646 GLint x
, GLint y
, GLsizei width
)
648 GET_CURRENT_CONTEXT(ctx
);
649 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
651 /* Select buffer to read from */
652 ctx
->Driver
.CopyColorTable( ctx
, target
, internalformat
, x
, y
, width
);
659 _mesa_CopyColorSubTable(GLenum target
, GLsizei start
,
660 GLint x
, GLint y
, GLsizei width
)
662 GET_CURRENT_CONTEXT(ctx
);
663 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
665 ctx
->Driver
.CopyColorSubTable( ctx
, target
, start
, x
, y
, width
);
671 _mesa_GetColorTable( GLenum target
, GLenum format
,
672 GLenum type
, GLvoid
*data
)
674 GET_CURRENT_CONTEXT(ctx
);
675 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
676 struct gl_color_table
*table
= NULL
;
677 GLchan rgba
[MAX_COLOR_TABLE_SIZE
][4];
678 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
681 _mesa_update_state(ctx
);
686 table
= &texUnit
->Current1D
->Palette
;
689 table
= &texUnit
->Current2D
->Palette
;
692 table
= &texUnit
->Current3D
->Palette
;
694 case GL_TEXTURE_CUBE_MAP_ARB
:
695 if (!ctx
->Extensions
.ARB_texture_cube_map
) {
696 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTable(target)");
699 table
= &texUnit
->CurrentCubeMap
->Palette
;
701 case GL_SHARED_TEXTURE_PALETTE_EXT
:
702 table
= &ctx
->Texture
.Palette
;
705 table
= &ctx
->ColorTable
;
707 case GL_TEXTURE_COLOR_TABLE_SGI
:
708 if (!ctx
->Extensions
.SGI_texture_color_table
) {
709 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTable(target)");
712 table
= &(texUnit
->ColorTable
);
714 case GL_POST_CONVOLUTION_COLOR_TABLE
:
715 table
= &ctx
->PostConvolutionColorTable
;
717 case GL_POST_COLOR_MATRIX_COLOR_TABLE
:
718 table
= &ctx
->PostColorMatrixColorTable
;
721 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTable(target)");
727 switch (table
->Format
) {
729 if (table
->Type
== GL_FLOAT
) {
730 const GLfloat
*tableF
= (const GLfloat
*) table
->Table
;
732 for (i
= 0; i
< table
->Size
; i
++) {
736 rgba
[i
][ACOMP
] = IROUND_POS(tableF
[i
] * CHAN_MAXF
);
740 const GLchan
*tableUB
= (const GLchan
*) table
->Table
;
742 for (i
= 0; i
< table
->Size
; i
++) {
746 rgba
[i
][ACOMP
] = tableUB
[i
];
751 if (table
->Type
== GL_FLOAT
) {
752 const GLfloat
*tableF
= (const GLfloat
*) table
->Table
;
754 for (i
= 0; i
< table
->Size
; i
++) {
755 rgba
[i
][RCOMP
] = IROUND_POS(tableF
[i
] * CHAN_MAXF
);
756 rgba
[i
][GCOMP
] = IROUND_POS(tableF
[i
] * CHAN_MAXF
);
757 rgba
[i
][BCOMP
] = IROUND_POS(tableF
[i
] * CHAN_MAXF
);
758 rgba
[i
][ACOMP
] = CHAN_MAX
;
762 const GLchan
*tableUB
= (const GLchan
*) table
->Table
;
764 for (i
= 0; i
< table
->Size
; i
++) {
765 rgba
[i
][RCOMP
] = tableUB
[i
];
766 rgba
[i
][GCOMP
] = tableUB
[i
];
767 rgba
[i
][BCOMP
] = tableUB
[i
];
768 rgba
[i
][ACOMP
] = CHAN_MAX
;
772 case GL_LUMINANCE_ALPHA
:
773 if (table
->Type
== GL_FLOAT
) {
774 const GLfloat
*tableF
= (const GLfloat
*) table
->Table
;
776 for (i
= 0; i
< table
->Size
; i
++) {
777 rgba
[i
][RCOMP
] = IROUND_POS(tableF
[i
*2+0] * CHAN_MAXF
);
778 rgba
[i
][GCOMP
] = IROUND_POS(tableF
[i
*2+0] * CHAN_MAXF
);
779 rgba
[i
][BCOMP
] = IROUND_POS(tableF
[i
*2+0] * CHAN_MAXF
);
780 rgba
[i
][ACOMP
] = IROUND_POS(tableF
[i
*2+1] * CHAN_MAXF
);
784 const GLchan
*tableUB
= (const GLchan
*) table
->Table
;
786 for (i
= 0; i
< table
->Size
; i
++) {
787 rgba
[i
][RCOMP
] = tableUB
[i
*2+0];
788 rgba
[i
][GCOMP
] = tableUB
[i
*2+0];
789 rgba
[i
][BCOMP
] = tableUB
[i
*2+0];
790 rgba
[i
][ACOMP
] = tableUB
[i
*2+1];
795 if (table
->Type
== GL_FLOAT
) {
796 const GLfloat
*tableF
= (const GLfloat
*) table
->Table
;
798 for (i
= 0; i
< table
->Size
; i
++) {
799 rgba
[i
][RCOMP
] = IROUND_POS(tableF
[i
] * CHAN_MAXF
);
800 rgba
[i
][GCOMP
] = IROUND_POS(tableF
[i
] * CHAN_MAXF
);
801 rgba
[i
][BCOMP
] = IROUND_POS(tableF
[i
] * CHAN_MAXF
);
802 rgba
[i
][ACOMP
] = IROUND_POS(tableF
[i
] * CHAN_MAXF
);
806 const GLchan
*tableUB
= (const GLchan
*) table
->Table
;
808 for (i
= 0; i
< table
->Size
; i
++) {
809 rgba
[i
][RCOMP
] = tableUB
[i
];
810 rgba
[i
][GCOMP
] = tableUB
[i
];
811 rgba
[i
][BCOMP
] = tableUB
[i
];
812 rgba
[i
][ACOMP
] = tableUB
[i
];
817 if (table
->Type
== GL_FLOAT
) {
818 const GLfloat
*tableF
= (const GLfloat
*) table
->Table
;
820 for (i
= 0; i
< table
->Size
; i
++) {
821 rgba
[i
][RCOMP
] = IROUND_POS(tableF
[i
*3+0] * CHAN_MAXF
);
822 rgba
[i
][GCOMP
] = IROUND_POS(tableF
[i
*3+1] * CHAN_MAXF
);
823 rgba
[i
][BCOMP
] = IROUND_POS(tableF
[i
*3+2] * CHAN_MAXF
);
824 rgba
[i
][ACOMP
] = CHAN_MAX
;
828 const GLchan
*tableUB
= (const GLchan
*) table
->Table
;
830 for (i
= 0; i
< table
->Size
; i
++) {
831 rgba
[i
][RCOMP
] = tableUB
[i
*3+0];
832 rgba
[i
][GCOMP
] = tableUB
[i
*3+1];
833 rgba
[i
][BCOMP
] = tableUB
[i
*3+2];
834 rgba
[i
][ACOMP
] = CHAN_MAX
;
839 if (table
->Type
== GL_FLOAT
) {
840 const GLfloat
*tableF
= (const GLfloat
*) table
->Table
;
842 for (i
= 0; i
< table
->Size
; i
++) {
843 rgba
[i
][RCOMP
] = IROUND_POS(tableF
[i
*4+0] * CHAN_MAXF
);
844 rgba
[i
][GCOMP
] = IROUND_POS(tableF
[i
*4+1] * CHAN_MAXF
);
845 rgba
[i
][BCOMP
] = IROUND_POS(tableF
[i
*4+2] * CHAN_MAXF
);
846 rgba
[i
][ACOMP
] = IROUND_POS(tableF
[i
*4+3] * CHAN_MAXF
);
850 const GLchan
*tableUB
= (const GLchan
*) table
->Table
;
852 for (i
= 0; i
< table
->Size
; i
++) {
853 rgba
[i
][RCOMP
] = tableUB
[i
*4+0];
854 rgba
[i
][GCOMP
] = tableUB
[i
*4+1];
855 rgba
[i
][BCOMP
] = tableUB
[i
*4+2];
856 rgba
[i
][ACOMP
] = tableUB
[i
*4+3];
861 _mesa_problem(ctx
, "bad table format in glGetColorTable");
865 _mesa_pack_rgba_span(ctx
, table
->Size
, (const GLchan (*)[4]) rgba
,
866 format
, type
, data
, &ctx
->Pack
, GL_FALSE
);
872 _mesa_ColorTableParameterfv(GLenum target
, GLenum pname
, const GLfloat
*params
)
874 GET_CURRENT_CONTEXT(ctx
);
875 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
878 case GL_COLOR_TABLE_SGI
:
879 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
880 ctx
->Pixel
.ColorTableScale
[0] = params
[0];
881 ctx
->Pixel
.ColorTableScale
[1] = params
[1];
882 ctx
->Pixel
.ColorTableScale
[2] = params
[2];
883 ctx
->Pixel
.ColorTableScale
[3] = params
[3];
885 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
886 ctx
->Pixel
.ColorTableBias
[0] = params
[0];
887 ctx
->Pixel
.ColorTableBias
[1] = params
[1];
888 ctx
->Pixel
.ColorTableBias
[2] = params
[2];
889 ctx
->Pixel
.ColorTableBias
[3] = params
[3];
892 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTableParameterfv(pname)");
896 case GL_TEXTURE_COLOR_TABLE_SGI
:
897 if (!ctx
->Extensions
.SGI_texture_color_table
) {
898 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTableParameter(target)");
901 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
902 ctx
->Pixel
.TextureColorTableScale
[0] = params
[0];
903 ctx
->Pixel
.TextureColorTableScale
[1] = params
[1];
904 ctx
->Pixel
.TextureColorTableScale
[2] = params
[2];
905 ctx
->Pixel
.TextureColorTableScale
[3] = params
[3];
907 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
908 ctx
->Pixel
.TextureColorTableBias
[0] = params
[0];
909 ctx
->Pixel
.TextureColorTableBias
[1] = params
[1];
910 ctx
->Pixel
.TextureColorTableBias
[2] = params
[2];
911 ctx
->Pixel
.TextureColorTableBias
[3] = params
[3];
914 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTableParameterfv(pname)");
918 case GL_POST_CONVOLUTION_COLOR_TABLE_SGI
:
919 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
920 ctx
->Pixel
.PCCTscale
[0] = params
[0];
921 ctx
->Pixel
.PCCTscale
[1] = params
[1];
922 ctx
->Pixel
.PCCTscale
[2] = params
[2];
923 ctx
->Pixel
.PCCTscale
[3] = params
[3];
925 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
926 ctx
->Pixel
.PCCTbias
[0] = params
[0];
927 ctx
->Pixel
.PCCTbias
[1] = params
[1];
928 ctx
->Pixel
.PCCTbias
[2] = params
[2];
929 ctx
->Pixel
.PCCTbias
[3] = params
[3];
932 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTableParameterfv(pname)");
936 case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI
:
937 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
938 ctx
->Pixel
.PCMCTscale
[0] = params
[0];
939 ctx
->Pixel
.PCMCTscale
[1] = params
[1];
940 ctx
->Pixel
.PCMCTscale
[2] = params
[2];
941 ctx
->Pixel
.PCMCTscale
[3] = params
[3];
943 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
944 ctx
->Pixel
.PCMCTbias
[0] = params
[0];
945 ctx
->Pixel
.PCMCTbias
[1] = params
[1];
946 ctx
->Pixel
.PCMCTbias
[2] = params
[2];
947 ctx
->Pixel
.PCMCTbias
[3] = params
[3];
950 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTableParameterfv(pname)");
955 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTableParameter(target)");
959 ctx
->NewState
|= _NEW_PIXEL
;
965 _mesa_ColorTableParameteriv(GLenum target
, GLenum pname
, const GLint
*params
)
968 if (pname
== GL_COLOR_TABLE_SGI
||
969 pname
== GL_TEXTURE_COLOR_TABLE_SGI
||
970 pname
== GL_POST_CONVOLUTION_COLOR_TABLE_SGI
||
971 pname
== GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI
) {
973 fparams
[0] = (GLfloat
) params
[0];
974 fparams
[1] = (GLfloat
) params
[1];
975 fparams
[2] = (GLfloat
) params
[2];
976 fparams
[3] = (GLfloat
) params
[3];
980 fparams
[0] = (GLfloat
) params
[0];
982 _mesa_ColorTableParameterfv(target
, pname
, fparams
);
988 _mesa_GetColorTableParameterfv( GLenum target
, GLenum pname
, GLfloat
*params
)
990 GET_CURRENT_CONTEXT(ctx
);
991 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
992 struct gl_color_table
*table
= NULL
;
993 ASSERT_OUTSIDE_BEGIN_END(ctx
);
997 table
= &texUnit
->Current1D
->Palette
;
1000 table
= &texUnit
->Current2D
->Palette
;
1003 table
= &texUnit
->Current3D
->Palette
;
1005 case GL_TEXTURE_CUBE_MAP_ARB
:
1006 if (!ctx
->Extensions
.ARB_texture_cube_map
) {
1007 _mesa_error(ctx
, GL_INVALID_ENUM
,
1008 "glGetColorTableParameterfv(target)");
1011 table
= &texUnit
->CurrentCubeMap
->Palette
;
1013 case GL_PROXY_TEXTURE_1D
:
1014 table
= &ctx
->Texture
.Proxy1D
->Palette
;
1016 case GL_PROXY_TEXTURE_2D
:
1017 table
= &ctx
->Texture
.Proxy2D
->Palette
;
1019 case GL_PROXY_TEXTURE_3D
:
1020 table
= &ctx
->Texture
.Proxy3D
->Palette
;
1022 case GL_PROXY_TEXTURE_CUBE_MAP_ARB
:
1023 if (!ctx
->Extensions
.ARB_texture_cube_map
) {
1024 _mesa_error(ctx
, GL_INVALID_ENUM
,
1025 "glGetColorTableParameterfv(target)");
1028 table
= &ctx
->Texture
.ProxyCubeMap
->Palette
;
1030 case GL_SHARED_TEXTURE_PALETTE_EXT
:
1031 table
= &ctx
->Texture
.Palette
;
1033 case GL_COLOR_TABLE
:
1034 table
= &ctx
->ColorTable
;
1035 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
1036 params
[0] = ctx
->Pixel
.ColorTableScale
[0];
1037 params
[1] = ctx
->Pixel
.ColorTableScale
[1];
1038 params
[2] = ctx
->Pixel
.ColorTableScale
[2];
1039 params
[3] = ctx
->Pixel
.ColorTableScale
[3];
1042 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
1043 params
[0] = ctx
->Pixel
.ColorTableBias
[0];
1044 params
[1] = ctx
->Pixel
.ColorTableBias
[1];
1045 params
[2] = ctx
->Pixel
.ColorTableBias
[2];
1046 params
[3] = ctx
->Pixel
.ColorTableBias
[3];
1050 case GL_PROXY_COLOR_TABLE
:
1051 table
= &ctx
->ProxyColorTable
;
1053 case GL_TEXTURE_COLOR_TABLE_SGI
:
1054 if (!ctx
->Extensions
.SGI_texture_color_table
) {
1055 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameter(target)");
1058 table
= &(texUnit
->ColorTable
);
1059 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
1060 params
[0] = ctx
->Pixel
.TextureColorTableScale
[0];
1061 params
[1] = ctx
->Pixel
.TextureColorTableScale
[1];
1062 params
[2] = ctx
->Pixel
.TextureColorTableScale
[2];
1063 params
[3] = ctx
->Pixel
.TextureColorTableScale
[3];
1066 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
1067 params
[0] = ctx
->Pixel
.TextureColorTableBias
[0];
1068 params
[1] = ctx
->Pixel
.TextureColorTableBias
[1];
1069 params
[2] = ctx
->Pixel
.TextureColorTableBias
[2];
1070 params
[3] = ctx
->Pixel
.TextureColorTableBias
[3];
1074 case GL_PROXY_TEXTURE_COLOR_TABLE_SGI
:
1075 if (!ctx
->Extensions
.SGI_texture_color_table
) {
1076 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameter(target)");
1079 table
= &(texUnit
->ProxyColorTable
);
1081 case GL_POST_CONVOLUTION_COLOR_TABLE
:
1082 table
= &ctx
->PostConvolutionColorTable
;
1083 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
1084 params
[0] = ctx
->Pixel
.PCCTscale
[0];
1085 params
[1] = ctx
->Pixel
.PCCTscale
[1];
1086 params
[2] = ctx
->Pixel
.PCCTscale
[2];
1087 params
[3] = ctx
->Pixel
.PCCTscale
[3];
1090 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
1091 params
[0] = ctx
->Pixel
.PCCTbias
[0];
1092 params
[1] = ctx
->Pixel
.PCCTbias
[1];
1093 params
[2] = ctx
->Pixel
.PCCTbias
[2];
1094 params
[3] = ctx
->Pixel
.PCCTbias
[3];
1098 case GL_PROXY_POST_CONVOLUTION_COLOR_TABLE
:
1099 table
= &ctx
->ProxyPostConvolutionColorTable
;
1101 case GL_POST_COLOR_MATRIX_COLOR_TABLE
:
1102 table
= &ctx
->PostColorMatrixColorTable
;
1103 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
1104 params
[0] = ctx
->Pixel
.PCMCTscale
[0];
1105 params
[1] = ctx
->Pixel
.PCMCTscale
[1];
1106 params
[2] = ctx
->Pixel
.PCMCTscale
[2];
1107 params
[3] = ctx
->Pixel
.PCMCTscale
[3];
1110 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
1111 params
[0] = ctx
->Pixel
.PCMCTbias
[0];
1112 params
[1] = ctx
->Pixel
.PCMCTbias
[1];
1113 params
[2] = ctx
->Pixel
.PCMCTbias
[2];
1114 params
[3] = ctx
->Pixel
.PCMCTbias
[3];
1118 case GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE
:
1119 table
= &ctx
->ProxyPostColorMatrixColorTable
;
1122 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameterfv(target)");
1129 case GL_COLOR_TABLE_FORMAT
:
1130 *params
= (GLfloat
) table
->IntFormat
;
1132 case GL_COLOR_TABLE_WIDTH
:
1133 *params
= (GLfloat
) table
->Size
;
1135 case GL_COLOR_TABLE_RED_SIZE
:
1136 *params
= (GLfloat
) table
->RedSize
;
1138 case GL_COLOR_TABLE_GREEN_SIZE
:
1139 *params
= (GLfloat
) table
->GreenSize
;
1141 case GL_COLOR_TABLE_BLUE_SIZE
:
1142 *params
= (GLfloat
) table
->BlueSize
;
1144 case GL_COLOR_TABLE_ALPHA_SIZE
:
1145 *params
= (GLfloat
) table
->AlphaSize
;
1147 case GL_COLOR_TABLE_LUMINANCE_SIZE
:
1148 *params
= (GLfloat
) table
->LuminanceSize
;
1150 case GL_COLOR_TABLE_INTENSITY_SIZE
:
1151 *params
= (GLfloat
) table
->IntensitySize
;
1154 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameterfv(pname)" );
1162 _mesa_GetColorTableParameteriv( GLenum target
, GLenum pname
, GLint
*params
)
1164 GET_CURRENT_CONTEXT(ctx
);
1165 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1166 struct gl_color_table
*table
= NULL
;
1167 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1171 table
= &texUnit
->Current1D
->Palette
;
1174 table
= &texUnit
->Current2D
->Palette
;
1177 table
= &texUnit
->Current3D
->Palette
;
1179 case GL_TEXTURE_CUBE_MAP_ARB
:
1180 if (!ctx
->Extensions
.ARB_texture_cube_map
) {
1181 _mesa_error(ctx
, GL_INVALID_ENUM
,
1182 "glGetColorTableParameteriv(target)");
1185 table
= &texUnit
->CurrentCubeMap
->Palette
;
1187 case GL_PROXY_TEXTURE_1D
:
1188 table
= &ctx
->Texture
.Proxy1D
->Palette
;
1190 case GL_PROXY_TEXTURE_2D
:
1191 table
= &ctx
->Texture
.Proxy2D
->Palette
;
1193 case GL_PROXY_TEXTURE_3D
:
1194 table
= &ctx
->Texture
.Proxy3D
->Palette
;
1196 case GL_PROXY_TEXTURE_CUBE_MAP_ARB
:
1197 if (!ctx
->Extensions
.ARB_texture_cube_map
) {
1198 _mesa_error(ctx
, GL_INVALID_ENUM
,
1199 "glGetColorTableParameteriv(target)");
1202 table
= &ctx
->Texture
.ProxyCubeMap
->Palette
;
1204 case GL_SHARED_TEXTURE_PALETTE_EXT
:
1205 table
= &ctx
->Texture
.Palette
;
1207 case GL_COLOR_TABLE
:
1208 table
= &ctx
->ColorTable
;
1209 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
1210 params
[0] = (GLint
) ctx
->Pixel
.ColorTableScale
[0];
1211 params
[1] = (GLint
) ctx
->Pixel
.ColorTableScale
[1];
1212 params
[2] = (GLint
) ctx
->Pixel
.ColorTableScale
[2];
1213 params
[3] = (GLint
) ctx
->Pixel
.ColorTableScale
[3];
1216 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
1217 params
[0] = (GLint
) ctx
->Pixel
.ColorTableBias
[0];
1218 params
[1] = (GLint
) ctx
->Pixel
.ColorTableBias
[1];
1219 params
[2] = (GLint
) ctx
->Pixel
.ColorTableBias
[2];
1220 params
[3] = (GLint
) ctx
->Pixel
.ColorTableBias
[3];
1224 case GL_PROXY_COLOR_TABLE
:
1225 table
= &ctx
->ProxyColorTable
;
1227 case GL_TEXTURE_COLOR_TABLE_SGI
:
1228 if (!ctx
->Extensions
.SGI_texture_color_table
) {
1229 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameter(target)");
1232 table
= &(texUnit
->ColorTable
);
1233 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
1234 params
[0] = (GLint
) ctx
->Pixel
.TextureColorTableScale
[0];
1235 params
[1] = (GLint
) ctx
->Pixel
.TextureColorTableScale
[1];
1236 params
[2] = (GLint
) ctx
->Pixel
.TextureColorTableScale
[2];
1237 params
[3] = (GLint
) ctx
->Pixel
.TextureColorTableScale
[3];
1240 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
1241 params
[0] = (GLint
) ctx
->Pixel
.TextureColorTableBias
[0];
1242 params
[1] = (GLint
) ctx
->Pixel
.TextureColorTableBias
[1];
1243 params
[2] = (GLint
) ctx
->Pixel
.TextureColorTableBias
[2];
1244 params
[3] = (GLint
) ctx
->Pixel
.TextureColorTableBias
[3];
1248 case GL_PROXY_TEXTURE_COLOR_TABLE_SGI
:
1249 if (!ctx
->Extensions
.SGI_texture_color_table
) {
1250 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameter(target)");
1253 table
= &(texUnit
->ProxyColorTable
);
1255 case GL_POST_CONVOLUTION_COLOR_TABLE
:
1256 table
= &ctx
->PostConvolutionColorTable
;
1257 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
1258 params
[0] = (GLint
) ctx
->Pixel
.PCCTscale
[0];
1259 params
[1] = (GLint
) ctx
->Pixel
.PCCTscale
[1];
1260 params
[2] = (GLint
) ctx
->Pixel
.PCCTscale
[2];
1261 params
[3] = (GLint
) ctx
->Pixel
.PCCTscale
[3];
1264 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
1265 params
[0] = (GLint
) ctx
->Pixel
.PCCTbias
[0];
1266 params
[1] = (GLint
) ctx
->Pixel
.PCCTbias
[1];
1267 params
[2] = (GLint
) ctx
->Pixel
.PCCTbias
[2];
1268 params
[3] = (GLint
) ctx
->Pixel
.PCCTbias
[3];
1272 case GL_PROXY_POST_CONVOLUTION_COLOR_TABLE
:
1273 table
= &ctx
->ProxyPostConvolutionColorTable
;
1275 case GL_POST_COLOR_MATRIX_COLOR_TABLE
:
1276 table
= &ctx
->PostColorMatrixColorTable
;
1277 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
1278 params
[0] = (GLint
) ctx
->Pixel
.PCMCTscale
[0];
1279 params
[1] = (GLint
) ctx
->Pixel
.PCMCTscale
[1];
1280 params
[2] = (GLint
) ctx
->Pixel
.PCMCTscale
[2];
1281 params
[3] = (GLint
) ctx
->Pixel
.PCMCTscale
[3];
1284 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
1285 params
[0] = (GLint
) ctx
->Pixel
.PCMCTbias
[0];
1286 params
[1] = (GLint
) ctx
->Pixel
.PCMCTbias
[1];
1287 params
[2] = (GLint
) ctx
->Pixel
.PCMCTbias
[2];
1288 params
[3] = (GLint
) ctx
->Pixel
.PCMCTbias
[3];
1292 case GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE
:
1293 table
= &ctx
->ProxyPostColorMatrixColorTable
;
1296 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameteriv(target)");
1303 case GL_COLOR_TABLE_FORMAT
:
1304 *params
= table
->IntFormat
;
1306 case GL_COLOR_TABLE_WIDTH
:
1307 *params
= table
->Size
;
1309 case GL_COLOR_TABLE_RED_SIZE
:
1310 *params
= table
->RedSize
;
1312 case GL_COLOR_TABLE_GREEN_SIZE
:
1313 *params
= table
->GreenSize
;
1315 case GL_COLOR_TABLE_BLUE_SIZE
:
1316 *params
= table
->BlueSize
;
1318 case GL_COLOR_TABLE_ALPHA_SIZE
:
1319 *params
= table
->AlphaSize
;
1321 case GL_COLOR_TABLE_LUMINANCE_SIZE
:
1322 *params
= table
->LuminanceSize
;
1324 case GL_COLOR_TABLE_INTENSITY_SIZE
:
1325 *params
= table
->IntensitySize
;
1328 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameteriv(pname)" );
1333 /**********************************************************************/
1334 /***** Initialization *****/
1335 /**********************************************************************/
1339 _mesa_init_colortable( struct gl_color_table
*p
)
1341 p
->Type
= CHAN_TYPE
;
1344 p
->IntFormat
= GL_RGBA
;
1350 _mesa_free_colortable_data( struct gl_color_table
*p
)
1360 * Initialize all colortables for a context.
1362 void _mesa_init_colortables( GLcontext
* ctx
)
1365 _mesa_init_colortable(&ctx
->ColorTable
);
1366 _mesa_init_colortable(&ctx
->ProxyColorTable
);
1367 _mesa_init_colortable(&ctx
->PostConvolutionColorTable
);
1368 _mesa_init_colortable(&ctx
->ProxyPostConvolutionColorTable
);
1369 _mesa_init_colortable(&ctx
->PostColorMatrixColorTable
);
1370 _mesa_init_colortable(&ctx
->ProxyPostColorMatrixColorTable
);
1375 * Free all colortable data for a context
1377 void _mesa_free_colortables_data( GLcontext
*ctx
)
1379 _mesa_free_colortable_data(&ctx
->ColorTable
);
1380 _mesa_free_colortable_data(&ctx
->ProxyColorTable
);
1381 _mesa_free_colortable_data(&ctx
->PostConvolutionColorTable
);
1382 _mesa_free_colortable_data(&ctx
->ProxyPostConvolutionColorTable
);
1383 _mesa_free_colortable_data(&ctx
->PostColorMatrixColorTable
);
1384 _mesa_free_colortable_data(&ctx
->ProxyPostColorMatrixColorTable
);