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_color_span_float(ctx
,
202 count
, /* number of pixels */
203 table
->Format
, /* dest format */
204 tempTab
, /* dest address */
205 format
, type
, data
, /* src data */
207 IMAGE_CLAMP_BIT
); /* transfer ops */
209 tableF
= (GLfloat
*) table
->Table
;
211 switch (table
->Format
) {
213 for (i
= 0; i
< count
; i
++) {
214 GLuint j
= start
+ i
;
215 tableF
[j
] = CLAMP(tempTab
[i
] * rScale
+ rBias
, 0.0F
, 1.0F
);
219 for (i
= 0; i
< count
; i
++) {
220 GLuint j
= start
+ i
;
221 tableF
[j
] = CLAMP(tempTab
[i
] * rScale
+ rBias
, 0.0F
, 1.0F
);
225 for (i
= 0; i
< count
; i
++) {
226 GLuint j
= start
+ i
;
227 tableF
[j
] = CLAMP(tempTab
[i
] * aScale
+ aBias
, 0.0F
, 1.0F
);
230 case GL_LUMINANCE_ALPHA
:
231 for (i
= 0; i
< count
; i
++) {
232 GLuint j
= start
+ i
;
233 tableF
[j
*2+0] = CLAMP(tempTab
[i
*2+0] * rScale
+ rBias
, 0.0F
, 1.0F
);
234 tableF
[j
*2+1] = CLAMP(tempTab
[i
*2+1] * aScale
+ aBias
, 0.0F
, 1.0F
);
238 for (i
= 0; i
< count
; i
++) {
239 GLuint j
= start
+ i
;
240 tableF
[j
*3+0] = CLAMP(tempTab
[i
*3+0] * rScale
+ rBias
, 0.0F
, 1.0F
);
241 tableF
[j
*3+1] = CLAMP(tempTab
[i
*3+1] * gScale
+ gBias
, 0.0F
, 1.0F
);
242 tableF
[j
*3+2] = CLAMP(tempTab
[i
*3+2] * bScale
+ bBias
, 0.0F
, 1.0F
);
246 for (i
= 0; i
< count
; i
++) {
247 GLuint j
= start
+ i
;
248 tableF
[j
*4+0] = CLAMP(tempTab
[i
*4+0] * rScale
+ rBias
, 0.0F
, 1.0F
);
249 tableF
[j
*4+1] = CLAMP(tempTab
[i
*4+1] * gScale
+ gBias
, 0.0F
, 1.0F
);
250 tableF
[j
*4+2] = CLAMP(tempTab
[i
*4+2] * bScale
+ bBias
, 0.0F
, 1.0F
);
251 tableF
[j
*4+3] = CLAMP(tempTab
[i
*4+3] * aScale
+ aBias
, 0.0F
, 1.0F
);
255 _mesa_problem(ctx
, "Bad format in store_colortable_entries");
260 /* non-float (GLchan) */
261 const GLint comps
= _mesa_components_in_format(table
->Format
);
262 GLchan
*dest
= (GLchan
*) table
->Table
+ start
* comps
;
263 _mesa_unpack_color_span_chan(ctx
, count
, /* number of entries */
264 table
->Format
, /* dest format */
265 dest
, /* dest address */
266 format
, type
, data
, /* src data */
268 0); /* transfer ops */
275 _mesa_ColorTable( GLenum target
, GLenum internalFormat
,
276 GLsizei width
, GLenum format
, GLenum type
,
279 GET_CURRENT_CONTEXT(ctx
);
280 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
281 struct gl_texture_object
*texObj
= NULL
;
282 struct gl_color_table
*table
= NULL
;
283 GLboolean proxy
= GL_FALSE
;
285 GLfloat rScale
= 1.0, gScale
= 1.0, bScale
= 1.0, aScale
= 1.0;
286 GLfloat rBias
= 0.0, gBias
= 0.0, bBias
= 0.0, aBias
= 0.0;
287 GLenum tableType
= CHAN_TYPE
;
289 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
); /* too complex */
293 texObj
= texUnit
->Current1D
;
294 table
= &texObj
->Palette
;
297 texObj
= texUnit
->Current2D
;
298 table
= &texObj
->Palette
;
301 texObj
= texUnit
->Current3D
;
302 table
= &texObj
->Palette
;
304 case GL_TEXTURE_CUBE_MAP_ARB
:
305 if (!ctx
->Extensions
.ARB_texture_cube_map
) {
306 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTable(target)");
309 texObj
= texUnit
->CurrentCubeMap
;
310 table
= &texObj
->Palette
;
312 case GL_PROXY_TEXTURE_1D
:
313 texObj
= ctx
->Texture
.Proxy1D
;
314 table
= &texObj
->Palette
;
317 case GL_PROXY_TEXTURE_2D
:
318 texObj
= ctx
->Texture
.Proxy2D
;
319 table
= &texObj
->Palette
;
322 case GL_PROXY_TEXTURE_3D
:
323 texObj
= ctx
->Texture
.Proxy3D
;
324 table
= &texObj
->Palette
;
327 case GL_PROXY_TEXTURE_CUBE_MAP_ARB
:
328 if (!ctx
->Extensions
.ARB_texture_cube_map
) {
329 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTable(target)");
332 texObj
= ctx
->Texture
.ProxyCubeMap
;
333 table
= &texObj
->Palette
;
335 case GL_SHARED_TEXTURE_PALETTE_EXT
:
336 table
= &ctx
->Texture
.Palette
;
339 table
= &ctx
->ColorTable
;
340 tableType
= GL_FLOAT
;
341 rScale
= ctx
->Pixel
.ColorTableScale
[0];
342 gScale
= ctx
->Pixel
.ColorTableScale
[1];
343 bScale
= ctx
->Pixel
.ColorTableScale
[2];
344 aScale
= ctx
->Pixel
.ColorTableScale
[3];
345 rBias
= ctx
->Pixel
.ColorTableBias
[0];
346 gBias
= ctx
->Pixel
.ColorTableBias
[1];
347 bBias
= ctx
->Pixel
.ColorTableBias
[2];
348 aBias
= ctx
->Pixel
.ColorTableBias
[3];
350 case GL_PROXY_COLOR_TABLE
:
351 table
= &ctx
->ProxyColorTable
;
354 case GL_TEXTURE_COLOR_TABLE_SGI
:
355 if (!ctx
->Extensions
.SGI_texture_color_table
) {
356 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTable(target)");
359 table
= &(texUnit
->ColorTable
);
360 tableType
= GL_FLOAT
;
361 rScale
= ctx
->Pixel
.TextureColorTableScale
[0];
362 gScale
= ctx
->Pixel
.TextureColorTableScale
[1];
363 bScale
= ctx
->Pixel
.TextureColorTableScale
[2];
364 aScale
= ctx
->Pixel
.TextureColorTableScale
[3];
365 rBias
= ctx
->Pixel
.TextureColorTableBias
[0];
366 gBias
= ctx
->Pixel
.TextureColorTableBias
[1];
367 bBias
= ctx
->Pixel
.TextureColorTableBias
[2];
368 aBias
= ctx
->Pixel
.TextureColorTableBias
[3];
370 case GL_PROXY_TEXTURE_COLOR_TABLE_SGI
:
371 if (!ctx
->Extensions
.SGI_texture_color_table
) {
372 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTable(target)");
375 table
= &(texUnit
->ProxyColorTable
);
378 case GL_POST_CONVOLUTION_COLOR_TABLE
:
379 table
= &ctx
->PostConvolutionColorTable
;
380 tableType
= GL_FLOAT
;
381 rScale
= ctx
->Pixel
.PCCTscale
[0];
382 gScale
= ctx
->Pixel
.PCCTscale
[1];
383 bScale
= ctx
->Pixel
.PCCTscale
[2];
384 aScale
= ctx
->Pixel
.PCCTscale
[3];
385 rBias
= ctx
->Pixel
.PCCTbias
[0];
386 gBias
= ctx
->Pixel
.PCCTbias
[1];
387 bBias
= ctx
->Pixel
.PCCTbias
[2];
388 aBias
= ctx
->Pixel
.PCCTbias
[3];
390 case GL_PROXY_POST_CONVOLUTION_COLOR_TABLE
:
391 table
= &ctx
->ProxyPostConvolutionColorTable
;
394 case GL_POST_COLOR_MATRIX_COLOR_TABLE
:
395 table
= &ctx
->PostColorMatrixColorTable
;
396 tableType
= GL_FLOAT
;
397 rScale
= ctx
->Pixel
.PCMCTscale
[0];
398 gScale
= ctx
->Pixel
.PCMCTscale
[1];
399 bScale
= ctx
->Pixel
.PCMCTscale
[2];
400 aScale
= ctx
->Pixel
.PCMCTscale
[3];
401 rBias
= ctx
->Pixel
.PCMCTbias
[0];
402 gBias
= ctx
->Pixel
.PCMCTbias
[1];
403 bBias
= ctx
->Pixel
.PCMCTbias
[2];
404 aBias
= ctx
->Pixel
.PCMCTbias
[3];
406 case GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE
:
407 table
= &ctx
->ProxyPostColorMatrixColorTable
;
411 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTable(target)");
417 if (!_mesa_is_legal_format_and_type(ctx
, format
, type
) ||
418 format
== GL_INTENSITY
) {
419 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glColorTable(format or type)");
423 baseFormat
= base_colortab_format(internalFormat
);
424 if (baseFormat
< 0 || baseFormat
== GL_COLOR_INDEX
) {
425 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTable(internalFormat)");
429 if (width
< 0 || (width
!= 0 && _mesa_bitcount(width
) != 1)) {
433 table
->IntFormat
= (GLenum
) 0;
434 table
->Format
= (GLenum
) 0;
437 _mesa_error(ctx
, GL_INVALID_VALUE
, "glColorTable(width=%d)", width
);
442 if (width
> (GLsizei
) ctx
->Const
.MaxColorTableSize
) {
445 table
->IntFormat
= (GLenum
) 0;
446 table
->Format
= (GLenum
) 0;
449 _mesa_error(ctx
, GL_TABLE_TOO_LARGE
, "glColorTable(width)");
455 table
->IntFormat
= internalFormat
;
456 table
->Format
= (GLenum
) baseFormat
;
457 set_component_sizes(table
);
459 comps
= _mesa_components_in_format(table
->Format
);
460 assert(comps
> 0); /* error should have been caught sooner */
463 /* free old table, if any */
470 if (tableType
== GL_FLOAT
) {
471 table
->Type
= GL_FLOAT
;
472 table
->Table
= MALLOC(comps
* width
* sizeof(GLfloat
));
475 table
->Type
= CHAN_TYPE
;
476 table
->Table
= MALLOC(comps
* width
* sizeof(GLchan
));
480 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glColorTable");
484 store_colortable_entries(ctx
, table
,
485 0, width
, /* start, count */
494 if (texObj
|| target
== GL_SHARED_TEXTURE_PALETTE_EXT
) {
495 /* texture object palette, texObj==NULL means the shared palette */
496 if (ctx
->Driver
.UpdateTexturePalette
) {
497 (*ctx
->Driver
.UpdateTexturePalette
)( ctx
, texObj
);
501 ctx
->NewState
|= _NEW_PIXEL
;
507 _mesa_ColorSubTable( GLenum target
, GLsizei start
,
508 GLsizei count
, GLenum format
, GLenum type
,
511 GET_CURRENT_CONTEXT(ctx
);
512 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
513 struct gl_texture_object
*texObj
= NULL
;
514 struct gl_color_table
*table
= NULL
;
515 GLfloat rScale
= 1.0, gScale
= 1.0, bScale
= 1.0, aScale
= 1.0;
516 GLfloat rBias
= 0.0, gBias
= 0.0, bBias
= 0.0, aBias
= 0.0;
518 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
522 texObj
= texUnit
->Current1D
;
523 table
= &texObj
->Palette
;
526 texObj
= texUnit
->Current2D
;
527 table
= &texObj
->Palette
;
530 texObj
= texUnit
->Current3D
;
531 table
= &texObj
->Palette
;
533 case GL_TEXTURE_CUBE_MAP_ARB
:
534 if (!ctx
->Extensions
.ARB_texture_cube_map
) {
535 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorSubTable(target)");
538 texObj
= texUnit
->CurrentCubeMap
;
539 table
= &texObj
->Palette
;
541 case GL_SHARED_TEXTURE_PALETTE_EXT
:
542 table
= &ctx
->Texture
.Palette
;
545 table
= &ctx
->ColorTable
;
546 rScale
= ctx
->Pixel
.ColorTableScale
[0];
547 gScale
= ctx
->Pixel
.ColorTableScale
[1];
548 bScale
= ctx
->Pixel
.ColorTableScale
[2];
549 aScale
= ctx
->Pixel
.ColorTableScale
[3];
550 rBias
= ctx
->Pixel
.ColorTableBias
[0];
551 gBias
= ctx
->Pixel
.ColorTableBias
[1];
552 bBias
= ctx
->Pixel
.ColorTableBias
[2];
553 aBias
= ctx
->Pixel
.ColorTableBias
[3];
555 case GL_TEXTURE_COLOR_TABLE_SGI
:
556 if (!ctx
->Extensions
.SGI_texture_color_table
) {
557 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorSubTable(target)");
560 table
= &(texUnit
->ColorTable
);
561 rScale
= ctx
->Pixel
.TextureColorTableScale
[0];
562 gScale
= ctx
->Pixel
.TextureColorTableScale
[1];
563 bScale
= ctx
->Pixel
.TextureColorTableScale
[2];
564 aScale
= ctx
->Pixel
.TextureColorTableScale
[3];
565 rBias
= ctx
->Pixel
.TextureColorTableBias
[0];
566 gBias
= ctx
->Pixel
.TextureColorTableBias
[1];
567 bBias
= ctx
->Pixel
.TextureColorTableBias
[2];
568 aBias
= ctx
->Pixel
.TextureColorTableBias
[3];
570 case GL_POST_CONVOLUTION_COLOR_TABLE
:
571 table
= &ctx
->PostConvolutionColorTable
;
572 rScale
= ctx
->Pixel
.PCCTscale
[0];
573 gScale
= ctx
->Pixel
.PCCTscale
[1];
574 bScale
= ctx
->Pixel
.PCCTscale
[2];
575 aScale
= ctx
->Pixel
.PCCTscale
[3];
576 rBias
= ctx
->Pixel
.PCCTbias
[0];
577 gBias
= ctx
->Pixel
.PCCTbias
[1];
578 bBias
= ctx
->Pixel
.PCCTbias
[2];
579 aBias
= ctx
->Pixel
.PCCTbias
[3];
581 case GL_POST_COLOR_MATRIX_COLOR_TABLE
:
582 table
= &ctx
->PostColorMatrixColorTable
;
583 rScale
= ctx
->Pixel
.PCMCTscale
[0];
584 gScale
= ctx
->Pixel
.PCMCTscale
[1];
585 bScale
= ctx
->Pixel
.PCMCTscale
[2];
586 aScale
= ctx
->Pixel
.PCMCTscale
[3];
587 rBias
= ctx
->Pixel
.PCMCTbias
[0];
588 gBias
= ctx
->Pixel
.PCMCTbias
[1];
589 bBias
= ctx
->Pixel
.PCMCTbias
[2];
590 aBias
= ctx
->Pixel
.PCMCTbias
[3];
593 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorSubTable(target)");
599 if (!_mesa_is_legal_format_and_type(ctx
, format
, type
) ||
600 format
== GL_INTENSITY
) {
601 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glColorSubTable(format or type)");
606 _mesa_error(ctx
, GL_INVALID_VALUE
, "glColorSubTable(count)");
610 comps
= _mesa_components_in_format(table
->Format
);
611 assert(comps
> 0); /* error should have been caught sooner */
613 if (start
+ count
> (GLint
) table
->Size
) {
614 _mesa_error(ctx
, GL_INVALID_VALUE
, "glColorSubTable(count)");
619 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glColorSubTable");
623 store_colortable_entries(ctx
, table
, start
, count
,
630 if (texObj
|| target
== GL_SHARED_TEXTURE_PALETTE_EXT
) {
631 /* per-texture object palette */
632 if (ctx
->Driver
.UpdateTexturePalette
) {
633 (*ctx
->Driver
.UpdateTexturePalette
)( ctx
, texObj
);
637 ctx
->NewState
|= _NEW_PIXEL
;
644 _mesa_CopyColorTable(GLenum target
, GLenum internalformat
,
645 GLint x
, GLint y
, GLsizei width
)
647 GET_CURRENT_CONTEXT(ctx
);
648 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
650 /* Select buffer to read from */
651 ctx
->Driver
.CopyColorTable( ctx
, target
, internalformat
, x
, y
, width
);
658 _mesa_CopyColorSubTable(GLenum target
, GLsizei start
,
659 GLint x
, GLint y
, GLsizei width
)
661 GET_CURRENT_CONTEXT(ctx
);
662 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
664 ctx
->Driver
.CopyColorSubTable( ctx
, target
, start
, x
, y
, width
);
670 _mesa_GetColorTable( GLenum target
, GLenum format
,
671 GLenum type
, GLvoid
*data
)
673 GET_CURRENT_CONTEXT(ctx
);
674 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
675 struct gl_color_table
*table
= NULL
;
676 GLchan rgba
[MAX_COLOR_TABLE_SIZE
][4];
677 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
680 _mesa_update_state(ctx
);
685 table
= &texUnit
->Current1D
->Palette
;
688 table
= &texUnit
->Current2D
->Palette
;
691 table
= &texUnit
->Current3D
->Palette
;
693 case GL_TEXTURE_CUBE_MAP_ARB
:
694 if (!ctx
->Extensions
.ARB_texture_cube_map
) {
695 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTable(target)");
698 table
= &texUnit
->CurrentCubeMap
->Palette
;
700 case GL_SHARED_TEXTURE_PALETTE_EXT
:
701 table
= &ctx
->Texture
.Palette
;
704 table
= &ctx
->ColorTable
;
706 case GL_TEXTURE_COLOR_TABLE_SGI
:
707 if (!ctx
->Extensions
.SGI_texture_color_table
) {
708 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTable(target)");
711 table
= &(texUnit
->ColorTable
);
713 case GL_POST_CONVOLUTION_COLOR_TABLE
:
714 table
= &ctx
->PostConvolutionColorTable
;
716 case GL_POST_COLOR_MATRIX_COLOR_TABLE
:
717 table
= &ctx
->PostColorMatrixColorTable
;
720 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTable(target)");
726 switch (table
->Format
) {
728 if (table
->Type
== GL_FLOAT
) {
729 const GLfloat
*tableF
= (const GLfloat
*) table
->Table
;
731 for (i
= 0; i
< table
->Size
; i
++) {
735 rgba
[i
][ACOMP
] = IROUND_POS(tableF
[i
] * CHAN_MAXF
);
739 const GLchan
*tableUB
= (const GLchan
*) table
->Table
;
741 for (i
= 0; i
< table
->Size
; i
++) {
745 rgba
[i
][ACOMP
] = tableUB
[i
];
750 if (table
->Type
== GL_FLOAT
) {
751 const GLfloat
*tableF
= (const GLfloat
*) table
->Table
;
753 for (i
= 0; i
< table
->Size
; i
++) {
754 rgba
[i
][RCOMP
] = IROUND_POS(tableF
[i
] * CHAN_MAXF
);
755 rgba
[i
][GCOMP
] = IROUND_POS(tableF
[i
] * CHAN_MAXF
);
756 rgba
[i
][BCOMP
] = IROUND_POS(tableF
[i
] * CHAN_MAXF
);
757 rgba
[i
][ACOMP
] = CHAN_MAX
;
761 const GLchan
*tableUB
= (const GLchan
*) table
->Table
;
763 for (i
= 0; i
< table
->Size
; i
++) {
764 rgba
[i
][RCOMP
] = tableUB
[i
];
765 rgba
[i
][GCOMP
] = tableUB
[i
];
766 rgba
[i
][BCOMP
] = tableUB
[i
];
767 rgba
[i
][ACOMP
] = CHAN_MAX
;
771 case GL_LUMINANCE_ALPHA
:
772 if (table
->Type
== GL_FLOAT
) {
773 const GLfloat
*tableF
= (const GLfloat
*) table
->Table
;
775 for (i
= 0; i
< table
->Size
; i
++) {
776 rgba
[i
][RCOMP
] = IROUND_POS(tableF
[i
*2+0] * CHAN_MAXF
);
777 rgba
[i
][GCOMP
] = IROUND_POS(tableF
[i
*2+0] * CHAN_MAXF
);
778 rgba
[i
][BCOMP
] = IROUND_POS(tableF
[i
*2+0] * CHAN_MAXF
);
779 rgba
[i
][ACOMP
] = IROUND_POS(tableF
[i
*2+1] * CHAN_MAXF
);
783 const GLchan
*tableUB
= (const GLchan
*) table
->Table
;
785 for (i
= 0; i
< table
->Size
; i
++) {
786 rgba
[i
][RCOMP
] = tableUB
[i
*2+0];
787 rgba
[i
][GCOMP
] = tableUB
[i
*2+0];
788 rgba
[i
][BCOMP
] = tableUB
[i
*2+0];
789 rgba
[i
][ACOMP
] = tableUB
[i
*2+1];
794 if (table
->Type
== GL_FLOAT
) {
795 const GLfloat
*tableF
= (const GLfloat
*) table
->Table
;
797 for (i
= 0; i
< table
->Size
; i
++) {
798 rgba
[i
][RCOMP
] = IROUND_POS(tableF
[i
] * CHAN_MAXF
);
799 rgba
[i
][GCOMP
] = IROUND_POS(tableF
[i
] * CHAN_MAXF
);
800 rgba
[i
][BCOMP
] = IROUND_POS(tableF
[i
] * CHAN_MAXF
);
801 rgba
[i
][ACOMP
] = IROUND_POS(tableF
[i
] * CHAN_MAXF
);
805 const GLchan
*tableUB
= (const GLchan
*) table
->Table
;
807 for (i
= 0; i
< table
->Size
; i
++) {
808 rgba
[i
][RCOMP
] = tableUB
[i
];
809 rgba
[i
][GCOMP
] = tableUB
[i
];
810 rgba
[i
][BCOMP
] = tableUB
[i
];
811 rgba
[i
][ACOMP
] = tableUB
[i
];
816 if (table
->Type
== GL_FLOAT
) {
817 const GLfloat
*tableF
= (const GLfloat
*) table
->Table
;
819 for (i
= 0; i
< table
->Size
; i
++) {
820 rgba
[i
][RCOMP
] = IROUND_POS(tableF
[i
*3+0] * CHAN_MAXF
);
821 rgba
[i
][GCOMP
] = IROUND_POS(tableF
[i
*3+1] * CHAN_MAXF
);
822 rgba
[i
][BCOMP
] = IROUND_POS(tableF
[i
*3+2] * CHAN_MAXF
);
823 rgba
[i
][ACOMP
] = CHAN_MAX
;
827 const GLchan
*tableUB
= (const GLchan
*) table
->Table
;
829 for (i
= 0; i
< table
->Size
; i
++) {
830 rgba
[i
][RCOMP
] = tableUB
[i
*3+0];
831 rgba
[i
][GCOMP
] = tableUB
[i
*3+1];
832 rgba
[i
][BCOMP
] = tableUB
[i
*3+2];
833 rgba
[i
][ACOMP
] = CHAN_MAX
;
838 if (table
->Type
== GL_FLOAT
) {
839 const GLfloat
*tableF
= (const GLfloat
*) table
->Table
;
841 for (i
= 0; i
< table
->Size
; i
++) {
842 rgba
[i
][RCOMP
] = IROUND_POS(tableF
[i
*4+0] * CHAN_MAXF
);
843 rgba
[i
][GCOMP
] = IROUND_POS(tableF
[i
*4+1] * CHAN_MAXF
);
844 rgba
[i
][BCOMP
] = IROUND_POS(tableF
[i
*4+2] * CHAN_MAXF
);
845 rgba
[i
][ACOMP
] = IROUND_POS(tableF
[i
*4+3] * CHAN_MAXF
);
849 const GLchan
*tableUB
= (const GLchan
*) table
->Table
;
851 for (i
= 0; i
< table
->Size
; i
++) {
852 rgba
[i
][RCOMP
] = tableUB
[i
*4+0];
853 rgba
[i
][GCOMP
] = tableUB
[i
*4+1];
854 rgba
[i
][BCOMP
] = tableUB
[i
*4+2];
855 rgba
[i
][ACOMP
] = tableUB
[i
*4+3];
860 _mesa_problem(ctx
, "bad table format in glGetColorTable");
864 _mesa_pack_rgba_span_chan(ctx
, table
->Size
, (const GLchan (*)[4]) rgba
,
865 format
, type
, data
, &ctx
->Pack
, GL_FALSE
);
871 _mesa_ColorTableParameterfv(GLenum target
, GLenum pname
, const GLfloat
*params
)
873 GET_CURRENT_CONTEXT(ctx
);
874 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
877 case GL_COLOR_TABLE_SGI
:
878 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
879 ctx
->Pixel
.ColorTableScale
[0] = params
[0];
880 ctx
->Pixel
.ColorTableScale
[1] = params
[1];
881 ctx
->Pixel
.ColorTableScale
[2] = params
[2];
882 ctx
->Pixel
.ColorTableScale
[3] = params
[3];
884 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
885 ctx
->Pixel
.ColorTableBias
[0] = params
[0];
886 ctx
->Pixel
.ColorTableBias
[1] = params
[1];
887 ctx
->Pixel
.ColorTableBias
[2] = params
[2];
888 ctx
->Pixel
.ColorTableBias
[3] = params
[3];
891 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTableParameterfv(pname)");
895 case GL_TEXTURE_COLOR_TABLE_SGI
:
896 if (!ctx
->Extensions
.SGI_texture_color_table
) {
897 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTableParameter(target)");
900 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
901 ctx
->Pixel
.TextureColorTableScale
[0] = params
[0];
902 ctx
->Pixel
.TextureColorTableScale
[1] = params
[1];
903 ctx
->Pixel
.TextureColorTableScale
[2] = params
[2];
904 ctx
->Pixel
.TextureColorTableScale
[3] = params
[3];
906 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
907 ctx
->Pixel
.TextureColorTableBias
[0] = params
[0];
908 ctx
->Pixel
.TextureColorTableBias
[1] = params
[1];
909 ctx
->Pixel
.TextureColorTableBias
[2] = params
[2];
910 ctx
->Pixel
.TextureColorTableBias
[3] = params
[3];
913 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTableParameterfv(pname)");
917 case GL_POST_CONVOLUTION_COLOR_TABLE_SGI
:
918 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
919 ctx
->Pixel
.PCCTscale
[0] = params
[0];
920 ctx
->Pixel
.PCCTscale
[1] = params
[1];
921 ctx
->Pixel
.PCCTscale
[2] = params
[2];
922 ctx
->Pixel
.PCCTscale
[3] = params
[3];
924 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
925 ctx
->Pixel
.PCCTbias
[0] = params
[0];
926 ctx
->Pixel
.PCCTbias
[1] = params
[1];
927 ctx
->Pixel
.PCCTbias
[2] = params
[2];
928 ctx
->Pixel
.PCCTbias
[3] = params
[3];
931 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTableParameterfv(pname)");
935 case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI
:
936 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
937 ctx
->Pixel
.PCMCTscale
[0] = params
[0];
938 ctx
->Pixel
.PCMCTscale
[1] = params
[1];
939 ctx
->Pixel
.PCMCTscale
[2] = params
[2];
940 ctx
->Pixel
.PCMCTscale
[3] = params
[3];
942 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
943 ctx
->Pixel
.PCMCTbias
[0] = params
[0];
944 ctx
->Pixel
.PCMCTbias
[1] = params
[1];
945 ctx
->Pixel
.PCMCTbias
[2] = params
[2];
946 ctx
->Pixel
.PCMCTbias
[3] = params
[3];
949 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTableParameterfv(pname)");
954 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTableParameter(target)");
958 ctx
->NewState
|= _NEW_PIXEL
;
964 _mesa_ColorTableParameteriv(GLenum target
, GLenum pname
, const GLint
*params
)
967 if (pname
== GL_COLOR_TABLE_SGI
||
968 pname
== GL_TEXTURE_COLOR_TABLE_SGI
||
969 pname
== GL_POST_CONVOLUTION_COLOR_TABLE_SGI
||
970 pname
== GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI
) {
972 fparams
[0] = (GLfloat
) params
[0];
973 fparams
[1] = (GLfloat
) params
[1];
974 fparams
[2] = (GLfloat
) params
[2];
975 fparams
[3] = (GLfloat
) params
[3];
979 fparams
[0] = (GLfloat
) params
[0];
981 _mesa_ColorTableParameterfv(target
, pname
, fparams
);
987 _mesa_GetColorTableParameterfv( GLenum target
, GLenum pname
, GLfloat
*params
)
989 GET_CURRENT_CONTEXT(ctx
);
990 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
991 struct gl_color_table
*table
= NULL
;
992 ASSERT_OUTSIDE_BEGIN_END(ctx
);
996 table
= &texUnit
->Current1D
->Palette
;
999 table
= &texUnit
->Current2D
->Palette
;
1002 table
= &texUnit
->Current3D
->Palette
;
1004 case GL_TEXTURE_CUBE_MAP_ARB
:
1005 if (!ctx
->Extensions
.ARB_texture_cube_map
) {
1006 _mesa_error(ctx
, GL_INVALID_ENUM
,
1007 "glGetColorTableParameterfv(target)");
1010 table
= &texUnit
->CurrentCubeMap
->Palette
;
1012 case GL_PROXY_TEXTURE_1D
:
1013 table
= &ctx
->Texture
.Proxy1D
->Palette
;
1015 case GL_PROXY_TEXTURE_2D
:
1016 table
= &ctx
->Texture
.Proxy2D
->Palette
;
1018 case GL_PROXY_TEXTURE_3D
:
1019 table
= &ctx
->Texture
.Proxy3D
->Palette
;
1021 case GL_PROXY_TEXTURE_CUBE_MAP_ARB
:
1022 if (!ctx
->Extensions
.ARB_texture_cube_map
) {
1023 _mesa_error(ctx
, GL_INVALID_ENUM
,
1024 "glGetColorTableParameterfv(target)");
1027 table
= &ctx
->Texture
.ProxyCubeMap
->Palette
;
1029 case GL_SHARED_TEXTURE_PALETTE_EXT
:
1030 table
= &ctx
->Texture
.Palette
;
1032 case GL_COLOR_TABLE
:
1033 table
= &ctx
->ColorTable
;
1034 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
1035 params
[0] = ctx
->Pixel
.ColorTableScale
[0];
1036 params
[1] = ctx
->Pixel
.ColorTableScale
[1];
1037 params
[2] = ctx
->Pixel
.ColorTableScale
[2];
1038 params
[3] = ctx
->Pixel
.ColorTableScale
[3];
1041 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
1042 params
[0] = ctx
->Pixel
.ColorTableBias
[0];
1043 params
[1] = ctx
->Pixel
.ColorTableBias
[1];
1044 params
[2] = ctx
->Pixel
.ColorTableBias
[2];
1045 params
[3] = ctx
->Pixel
.ColorTableBias
[3];
1049 case GL_PROXY_COLOR_TABLE
:
1050 table
= &ctx
->ProxyColorTable
;
1052 case GL_TEXTURE_COLOR_TABLE_SGI
:
1053 if (!ctx
->Extensions
.SGI_texture_color_table
) {
1054 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameter(target)");
1057 table
= &(texUnit
->ColorTable
);
1058 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
1059 params
[0] = ctx
->Pixel
.TextureColorTableScale
[0];
1060 params
[1] = ctx
->Pixel
.TextureColorTableScale
[1];
1061 params
[2] = ctx
->Pixel
.TextureColorTableScale
[2];
1062 params
[3] = ctx
->Pixel
.TextureColorTableScale
[3];
1065 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
1066 params
[0] = ctx
->Pixel
.TextureColorTableBias
[0];
1067 params
[1] = ctx
->Pixel
.TextureColorTableBias
[1];
1068 params
[2] = ctx
->Pixel
.TextureColorTableBias
[2];
1069 params
[3] = ctx
->Pixel
.TextureColorTableBias
[3];
1073 case GL_PROXY_TEXTURE_COLOR_TABLE_SGI
:
1074 if (!ctx
->Extensions
.SGI_texture_color_table
) {
1075 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameter(target)");
1078 table
= &(texUnit
->ProxyColorTable
);
1080 case GL_POST_CONVOLUTION_COLOR_TABLE
:
1081 table
= &ctx
->PostConvolutionColorTable
;
1082 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
1083 params
[0] = ctx
->Pixel
.PCCTscale
[0];
1084 params
[1] = ctx
->Pixel
.PCCTscale
[1];
1085 params
[2] = ctx
->Pixel
.PCCTscale
[2];
1086 params
[3] = ctx
->Pixel
.PCCTscale
[3];
1089 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
1090 params
[0] = ctx
->Pixel
.PCCTbias
[0];
1091 params
[1] = ctx
->Pixel
.PCCTbias
[1];
1092 params
[2] = ctx
->Pixel
.PCCTbias
[2];
1093 params
[3] = ctx
->Pixel
.PCCTbias
[3];
1097 case GL_PROXY_POST_CONVOLUTION_COLOR_TABLE
:
1098 table
= &ctx
->ProxyPostConvolutionColorTable
;
1100 case GL_POST_COLOR_MATRIX_COLOR_TABLE
:
1101 table
= &ctx
->PostColorMatrixColorTable
;
1102 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
1103 params
[0] = ctx
->Pixel
.PCMCTscale
[0];
1104 params
[1] = ctx
->Pixel
.PCMCTscale
[1];
1105 params
[2] = ctx
->Pixel
.PCMCTscale
[2];
1106 params
[3] = ctx
->Pixel
.PCMCTscale
[3];
1109 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
1110 params
[0] = ctx
->Pixel
.PCMCTbias
[0];
1111 params
[1] = ctx
->Pixel
.PCMCTbias
[1];
1112 params
[2] = ctx
->Pixel
.PCMCTbias
[2];
1113 params
[3] = ctx
->Pixel
.PCMCTbias
[3];
1117 case GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE
:
1118 table
= &ctx
->ProxyPostColorMatrixColorTable
;
1121 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameterfv(target)");
1128 case GL_COLOR_TABLE_FORMAT
:
1129 *params
= (GLfloat
) table
->IntFormat
;
1131 case GL_COLOR_TABLE_WIDTH
:
1132 *params
= (GLfloat
) table
->Size
;
1134 case GL_COLOR_TABLE_RED_SIZE
:
1135 *params
= (GLfloat
) table
->RedSize
;
1137 case GL_COLOR_TABLE_GREEN_SIZE
:
1138 *params
= (GLfloat
) table
->GreenSize
;
1140 case GL_COLOR_TABLE_BLUE_SIZE
:
1141 *params
= (GLfloat
) table
->BlueSize
;
1143 case GL_COLOR_TABLE_ALPHA_SIZE
:
1144 *params
= (GLfloat
) table
->AlphaSize
;
1146 case GL_COLOR_TABLE_LUMINANCE_SIZE
:
1147 *params
= (GLfloat
) table
->LuminanceSize
;
1149 case GL_COLOR_TABLE_INTENSITY_SIZE
:
1150 *params
= (GLfloat
) table
->IntensitySize
;
1153 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameterfv(pname)" );
1161 _mesa_GetColorTableParameteriv( GLenum target
, GLenum pname
, GLint
*params
)
1163 GET_CURRENT_CONTEXT(ctx
);
1164 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1165 struct gl_color_table
*table
= NULL
;
1166 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1170 table
= &texUnit
->Current1D
->Palette
;
1173 table
= &texUnit
->Current2D
->Palette
;
1176 table
= &texUnit
->Current3D
->Palette
;
1178 case GL_TEXTURE_CUBE_MAP_ARB
:
1179 if (!ctx
->Extensions
.ARB_texture_cube_map
) {
1180 _mesa_error(ctx
, GL_INVALID_ENUM
,
1181 "glGetColorTableParameteriv(target)");
1184 table
= &texUnit
->CurrentCubeMap
->Palette
;
1186 case GL_PROXY_TEXTURE_1D
:
1187 table
= &ctx
->Texture
.Proxy1D
->Palette
;
1189 case GL_PROXY_TEXTURE_2D
:
1190 table
= &ctx
->Texture
.Proxy2D
->Palette
;
1192 case GL_PROXY_TEXTURE_3D
:
1193 table
= &ctx
->Texture
.Proxy3D
->Palette
;
1195 case GL_PROXY_TEXTURE_CUBE_MAP_ARB
:
1196 if (!ctx
->Extensions
.ARB_texture_cube_map
) {
1197 _mesa_error(ctx
, GL_INVALID_ENUM
,
1198 "glGetColorTableParameteriv(target)");
1201 table
= &ctx
->Texture
.ProxyCubeMap
->Palette
;
1203 case GL_SHARED_TEXTURE_PALETTE_EXT
:
1204 table
= &ctx
->Texture
.Palette
;
1206 case GL_COLOR_TABLE
:
1207 table
= &ctx
->ColorTable
;
1208 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
1209 params
[0] = (GLint
) ctx
->Pixel
.ColorTableScale
[0];
1210 params
[1] = (GLint
) ctx
->Pixel
.ColorTableScale
[1];
1211 params
[2] = (GLint
) ctx
->Pixel
.ColorTableScale
[2];
1212 params
[3] = (GLint
) ctx
->Pixel
.ColorTableScale
[3];
1215 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
1216 params
[0] = (GLint
) ctx
->Pixel
.ColorTableBias
[0];
1217 params
[1] = (GLint
) ctx
->Pixel
.ColorTableBias
[1];
1218 params
[2] = (GLint
) ctx
->Pixel
.ColorTableBias
[2];
1219 params
[3] = (GLint
) ctx
->Pixel
.ColorTableBias
[3];
1223 case GL_PROXY_COLOR_TABLE
:
1224 table
= &ctx
->ProxyColorTable
;
1226 case GL_TEXTURE_COLOR_TABLE_SGI
:
1227 if (!ctx
->Extensions
.SGI_texture_color_table
) {
1228 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameter(target)");
1231 table
= &(texUnit
->ColorTable
);
1232 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
1233 params
[0] = (GLint
) ctx
->Pixel
.TextureColorTableScale
[0];
1234 params
[1] = (GLint
) ctx
->Pixel
.TextureColorTableScale
[1];
1235 params
[2] = (GLint
) ctx
->Pixel
.TextureColorTableScale
[2];
1236 params
[3] = (GLint
) ctx
->Pixel
.TextureColorTableScale
[3];
1239 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
1240 params
[0] = (GLint
) ctx
->Pixel
.TextureColorTableBias
[0];
1241 params
[1] = (GLint
) ctx
->Pixel
.TextureColorTableBias
[1];
1242 params
[2] = (GLint
) ctx
->Pixel
.TextureColorTableBias
[2];
1243 params
[3] = (GLint
) ctx
->Pixel
.TextureColorTableBias
[3];
1247 case GL_PROXY_TEXTURE_COLOR_TABLE_SGI
:
1248 if (!ctx
->Extensions
.SGI_texture_color_table
) {
1249 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameter(target)");
1252 table
= &(texUnit
->ProxyColorTable
);
1254 case GL_POST_CONVOLUTION_COLOR_TABLE
:
1255 table
= &ctx
->PostConvolutionColorTable
;
1256 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
1257 params
[0] = (GLint
) ctx
->Pixel
.PCCTscale
[0];
1258 params
[1] = (GLint
) ctx
->Pixel
.PCCTscale
[1];
1259 params
[2] = (GLint
) ctx
->Pixel
.PCCTscale
[2];
1260 params
[3] = (GLint
) ctx
->Pixel
.PCCTscale
[3];
1263 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
1264 params
[0] = (GLint
) ctx
->Pixel
.PCCTbias
[0];
1265 params
[1] = (GLint
) ctx
->Pixel
.PCCTbias
[1];
1266 params
[2] = (GLint
) ctx
->Pixel
.PCCTbias
[2];
1267 params
[3] = (GLint
) ctx
->Pixel
.PCCTbias
[3];
1271 case GL_PROXY_POST_CONVOLUTION_COLOR_TABLE
:
1272 table
= &ctx
->ProxyPostConvolutionColorTable
;
1274 case GL_POST_COLOR_MATRIX_COLOR_TABLE
:
1275 table
= &ctx
->PostColorMatrixColorTable
;
1276 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
1277 params
[0] = (GLint
) ctx
->Pixel
.PCMCTscale
[0];
1278 params
[1] = (GLint
) ctx
->Pixel
.PCMCTscale
[1];
1279 params
[2] = (GLint
) ctx
->Pixel
.PCMCTscale
[2];
1280 params
[3] = (GLint
) ctx
->Pixel
.PCMCTscale
[3];
1283 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
1284 params
[0] = (GLint
) ctx
->Pixel
.PCMCTbias
[0];
1285 params
[1] = (GLint
) ctx
->Pixel
.PCMCTbias
[1];
1286 params
[2] = (GLint
) ctx
->Pixel
.PCMCTbias
[2];
1287 params
[3] = (GLint
) ctx
->Pixel
.PCMCTbias
[3];
1291 case GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE
:
1292 table
= &ctx
->ProxyPostColorMatrixColorTable
;
1295 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameteriv(target)");
1302 case GL_COLOR_TABLE_FORMAT
:
1303 *params
= table
->IntFormat
;
1305 case GL_COLOR_TABLE_WIDTH
:
1306 *params
= table
->Size
;
1308 case GL_COLOR_TABLE_RED_SIZE
:
1309 *params
= table
->RedSize
;
1311 case GL_COLOR_TABLE_GREEN_SIZE
:
1312 *params
= table
->GreenSize
;
1314 case GL_COLOR_TABLE_BLUE_SIZE
:
1315 *params
= table
->BlueSize
;
1317 case GL_COLOR_TABLE_ALPHA_SIZE
:
1318 *params
= table
->AlphaSize
;
1320 case GL_COLOR_TABLE_LUMINANCE_SIZE
:
1321 *params
= table
->LuminanceSize
;
1323 case GL_COLOR_TABLE_INTENSITY_SIZE
:
1324 *params
= table
->IntensitySize
;
1327 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameteriv(pname)" );
1332 /**********************************************************************/
1333 /***** Initialization *****/
1334 /**********************************************************************/
1338 _mesa_init_colortable( struct gl_color_table
*p
)
1340 p
->Type
= CHAN_TYPE
;
1343 p
->IntFormat
= GL_RGBA
;
1349 _mesa_free_colortable_data( struct gl_color_table
*p
)
1359 * Initialize all colortables for a context.
1361 void _mesa_init_colortables( GLcontext
* ctx
)
1364 _mesa_init_colortable(&ctx
->ColorTable
);
1365 _mesa_init_colortable(&ctx
->ProxyColorTable
);
1366 _mesa_init_colortable(&ctx
->PostConvolutionColorTable
);
1367 _mesa_init_colortable(&ctx
->ProxyPostConvolutionColorTable
);
1368 _mesa_init_colortable(&ctx
->PostColorMatrixColorTable
);
1369 _mesa_init_colortable(&ctx
->ProxyPostColorMatrixColorTable
);
1374 * Free all colortable data for a context
1376 void _mesa_free_colortables_data( GLcontext
*ctx
)
1378 _mesa_free_colortable_data(&ctx
->ColorTable
);
1379 _mesa_free_colortable_data(&ctx
->ProxyColorTable
);
1380 _mesa_free_colortable_data(&ctx
->PostConvolutionColorTable
);
1381 _mesa_free_colortable_data(&ctx
->ProxyPostConvolutionColorTable
);
1382 _mesa_free_colortable_data(&ctx
->PostColorMatrixColorTable
);
1383 _mesa_free_colortable_data(&ctx
->ProxyPostColorMatrixColorTable
);