3 * Mesa 3-D graphics library
6 * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
8 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this software and associated documentation files (the "Software"),
10 * to deal in the Software without restriction, including without limitation
11 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 * and/or sell copies of the Software, and to permit persons to whom the
13 * Software is furnished to do so, subject to the following conditions:
15 * The above copyright notice and this permission notice shall be included
16 * in all copies or substantial portions of the Software.
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
22 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
37 * Given an internalFormat token passed to glColorTable,
38 * return the corresponding base format.
39 * Return -1 if invalid token.
42 base_colortab_format( GLenum format
)
57 case GL_LUMINANCE_ALPHA
:
58 case GL_LUMINANCE4_ALPHA4
:
59 case GL_LUMINANCE6_ALPHA2
:
60 case GL_LUMINANCE8_ALPHA8
:
61 case GL_LUMINANCE12_ALPHA4
:
62 case GL_LUMINANCE12_ALPHA12
:
63 case GL_LUMINANCE16_ALPHA16
:
64 return GL_LUMINANCE_ALPHA
;
90 return -1; /* error */
97 * Examine table's format and set the component sizes accordingly.
100 set_component_sizes( struct gl_color_table
*table
)
102 switch (table
->Format
) {
105 table
->GreenSize
= 0;
107 table
->AlphaSize
= CHAN_BITS
;
108 table
->IntensitySize
= 0;
109 table
->LuminanceSize
= 0;
113 table
->GreenSize
= 0;
115 table
->AlphaSize
= 0;
116 table
->IntensitySize
= 0;
117 table
->LuminanceSize
= CHAN_BITS
;
119 case GL_LUMINANCE_ALPHA
:
121 table
->GreenSize
= 0;
123 table
->AlphaSize
= CHAN_BITS
;
124 table
->IntensitySize
= 0;
125 table
->LuminanceSize
= CHAN_BITS
;
129 table
->GreenSize
= 0;
131 table
->AlphaSize
= 0;
132 table
->IntensitySize
= CHAN_BITS
;
133 table
->LuminanceSize
= 0;
136 table
->RedSize
= CHAN_BITS
;
137 table
->GreenSize
= CHAN_BITS
;
138 table
->BlueSize
= CHAN_BITS
;
139 table
->AlphaSize
= 0;
140 table
->IntensitySize
= 0;
141 table
->LuminanceSize
= 0;
144 table
->RedSize
= CHAN_BITS
;
145 table
->GreenSize
= CHAN_BITS
;
146 table
->BlueSize
= CHAN_BITS
;
147 table
->AlphaSize
= CHAN_BITS
;
148 table
->IntensitySize
= 0;
149 table
->LuminanceSize
= 0;
152 _mesa_problem(NULL
, "unexpected format in set_component_sizes");
159 _mesa_ColorTable( GLenum target
, GLenum internalFormat
,
160 GLsizei width
, GLenum format
, GLenum type
,
163 GET_CURRENT_CONTEXT(ctx
);
164 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
165 struct gl_texture_object
*texObj
= NULL
;
166 struct gl_color_table
*table
= NULL
;
167 GLboolean proxy
= GL_FALSE
;
169 GLfloat rScale
= 1.0, gScale
= 1.0, bScale
= 1.0, aScale
= 1.0;
170 GLfloat rBias
= 0.0, gBias
= 0.0, bBias
= 0.0, aBias
= 0.0;
171 GLboolean floatTable
= GL_FALSE
;
173 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
); /* too complex */
177 texObj
= texUnit
->Current1D
;
178 table
= &texObj
->Palette
;
181 texObj
= texUnit
->Current2D
;
182 table
= &texObj
->Palette
;
185 texObj
= texUnit
->Current3D
;
186 table
= &texObj
->Palette
;
188 case GL_TEXTURE_CUBE_MAP_ARB
:
189 if (!ctx
->Extensions
.ARB_texture_cube_map
) {
190 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTable(target)");
193 texObj
= texUnit
->CurrentCubeMap
;
194 table
= &texObj
->Palette
;
196 case GL_PROXY_TEXTURE_1D
:
197 texObj
= ctx
->Texture
.Proxy1D
;
198 table
= &texObj
->Palette
;
201 case GL_PROXY_TEXTURE_2D
:
202 texObj
= ctx
->Texture
.Proxy2D
;
203 table
= &texObj
->Palette
;
206 case GL_PROXY_TEXTURE_3D
:
207 texObj
= ctx
->Texture
.Proxy3D
;
208 table
= &texObj
->Palette
;
211 case GL_PROXY_TEXTURE_CUBE_MAP_ARB
:
212 if (!ctx
->Extensions
.ARB_texture_cube_map
) {
213 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTable(target)");
216 texObj
= ctx
->Texture
.ProxyCubeMap
;
217 table
= &texObj
->Palette
;
219 case GL_SHARED_TEXTURE_PALETTE_EXT
:
220 table
= &ctx
->Texture
.Palette
;
223 table
= &ctx
->ColorTable
;
224 floatTable
= GL_TRUE
;
225 rScale
= ctx
->Pixel
.ColorTableScale
[0];
226 gScale
= ctx
->Pixel
.ColorTableScale
[1];
227 bScale
= ctx
->Pixel
.ColorTableScale
[2];
228 aScale
= ctx
->Pixel
.ColorTableScale
[3];
229 rBias
= ctx
->Pixel
.ColorTableBias
[0];
230 gBias
= ctx
->Pixel
.ColorTableBias
[1];
231 bBias
= ctx
->Pixel
.ColorTableBias
[2];
232 aBias
= ctx
->Pixel
.ColorTableBias
[3];
234 case GL_PROXY_COLOR_TABLE
:
235 table
= &ctx
->ProxyColorTable
;
238 case GL_TEXTURE_COLOR_TABLE_SGI
:
239 if (!ctx
->Extensions
.SGI_texture_color_table
) {
240 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTable(target)");
243 table
= &(texUnit
->ColorTable
);
244 floatTable
= GL_TRUE
;
245 rScale
= ctx
->Pixel
.TextureColorTableScale
[0];
246 gScale
= ctx
->Pixel
.TextureColorTableScale
[1];
247 bScale
= ctx
->Pixel
.TextureColorTableScale
[2];
248 aScale
= ctx
->Pixel
.TextureColorTableScale
[3];
249 rBias
= ctx
->Pixel
.TextureColorTableBias
[0];
250 gBias
= ctx
->Pixel
.TextureColorTableBias
[1];
251 bBias
= ctx
->Pixel
.TextureColorTableBias
[2];
252 aBias
= ctx
->Pixel
.TextureColorTableBias
[3];
254 case GL_PROXY_TEXTURE_COLOR_TABLE_SGI
:
255 if (!ctx
->Extensions
.SGI_texture_color_table
) {
256 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTable(target)");
259 table
= &(texUnit
->ProxyColorTable
);
262 case GL_POST_CONVOLUTION_COLOR_TABLE
:
263 table
= &ctx
->PostConvolutionColorTable
;
264 floatTable
= GL_TRUE
;
265 rScale
= ctx
->Pixel
.PCCTscale
[0];
266 gScale
= ctx
->Pixel
.PCCTscale
[1];
267 bScale
= ctx
->Pixel
.PCCTscale
[2];
268 aScale
= ctx
->Pixel
.PCCTscale
[3];
269 rBias
= ctx
->Pixel
.PCCTbias
[0];
270 gBias
= ctx
->Pixel
.PCCTbias
[1];
271 bBias
= ctx
->Pixel
.PCCTbias
[2];
272 aBias
= ctx
->Pixel
.PCCTbias
[3];
274 case GL_PROXY_POST_CONVOLUTION_COLOR_TABLE
:
275 table
= &ctx
->ProxyPostConvolutionColorTable
;
278 case GL_POST_COLOR_MATRIX_COLOR_TABLE
:
279 table
= &ctx
->PostColorMatrixColorTable
;
280 floatTable
= GL_TRUE
;
281 rScale
= ctx
->Pixel
.PCMCTscale
[0];
282 gScale
= ctx
->Pixel
.PCMCTscale
[1];
283 bScale
= ctx
->Pixel
.PCMCTscale
[2];
284 aScale
= ctx
->Pixel
.PCMCTscale
[3];
285 rBias
= ctx
->Pixel
.PCMCTbias
[0];
286 gBias
= ctx
->Pixel
.PCMCTbias
[1];
287 bBias
= ctx
->Pixel
.PCMCTbias
[2];
288 aBias
= ctx
->Pixel
.PCMCTbias
[3];
290 case GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE
:
291 table
= &ctx
->ProxyPostColorMatrixColorTable
;
295 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTable(target)");
301 if (!_mesa_is_legal_format_and_type(format
, type
) ||
302 format
== GL_INTENSITY
) {
303 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glColorTable(format or type)");
307 baseFormat
= base_colortab_format(internalFormat
);
308 if (baseFormat
< 0 || baseFormat
== GL_COLOR_INDEX
) {
309 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTable(internalFormat)");
313 if (width
< 0 || (width
!= 0 && _mesa_bitcount(width
) != 1)) {
317 table
->IntFormat
= (GLenum
) 0;
318 table
->Format
= (GLenum
) 0;
321 _mesa_error(ctx
, GL_INVALID_VALUE
, "glColorTable(width=%d)", width
);
326 if (width
> (GLsizei
) ctx
->Const
.MaxColorTableSize
) {
329 table
->IntFormat
= (GLenum
) 0;
330 table
->Format
= (GLenum
) 0;
333 _mesa_error(ctx
, GL_TABLE_TOO_LARGE
, "glColorTable(width)");
339 table
->IntFormat
= internalFormat
;
340 table
->Format
= (GLenum
) baseFormat
;
341 set_component_sizes(table
);
343 comps
= _mesa_components_in_format(table
->Format
);
344 assert(comps
> 0); /* error should have been caught sooner */
347 /* free old table, if any */
354 GLfloat tempTab
[MAX_COLOR_TABLE_SIZE
* 4];
358 _mesa_unpack_float_color_span(ctx
, width
, table
->Format
,
360 format
, type
, data
, &ctx
->Unpack
,
363 table
->FloatTable
= GL_TRUE
;
364 table
->Table
= MALLOC(comps
* width
* sizeof(GLfloat
));
366 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glColorTable");
370 tableF
= (GLfloat
*) table
->Table
;
372 switch (table
->Format
) {
374 for (i
= 0; i
< width
; i
++) {
375 tableF
[i
] = CLAMP(tempTab
[i
] * rScale
+ rBias
, 0.0F
, 1.0F
);
379 for (i
= 0; i
< width
; i
++) {
380 tableF
[i
] = CLAMP(tempTab
[i
] * rScale
+ rBias
, 0.0F
, 1.0F
);
384 for (i
= 0; i
< width
; i
++) {
385 tableF
[i
] = CLAMP(tempTab
[i
] * aScale
+ aBias
, 0.0F
, 1.0F
);
388 case GL_LUMINANCE_ALPHA
:
389 for (i
= 0; i
< width
; i
++) {
390 tableF
[i
*2+0] = CLAMP(tempTab
[i
*2+0] * rScale
+ rBias
, 0.0F
, 1.0F
);
391 tableF
[i
*2+1] = CLAMP(tempTab
[i
*2+1] * aScale
+ aBias
, 0.0F
, 1.0F
);
395 for (i
= 0; i
< width
; i
++) {
396 tableF
[i
*3+0] = CLAMP(tempTab
[i
*3+0] * rScale
+ rBias
, 0.0F
, 1.0F
);
397 tableF
[i
*3+1] = CLAMP(tempTab
[i
*3+1] * gScale
+ gBias
, 0.0F
, 1.0F
);
398 tableF
[i
*3+2] = CLAMP(tempTab
[i
*3+2] * bScale
+ bBias
, 0.0F
, 1.0F
);
402 for (i
= 0; i
< width
; i
++) {
403 tableF
[i
*4+0] = CLAMP(tempTab
[i
*4+0] * rScale
+ rBias
, 0.0F
, 1.0F
);
404 tableF
[i
*4+1] = CLAMP(tempTab
[i
*4+1] * gScale
+ gBias
, 0.0F
, 1.0F
);
405 tableF
[i
*4+2] = CLAMP(tempTab
[i
*4+2] * bScale
+ bBias
, 0.0F
, 1.0F
);
406 tableF
[i
*4+3] = CLAMP(tempTab
[i
*4+3] * aScale
+ aBias
, 0.0F
, 1.0F
);
410 _mesa_problem(ctx
, "Bad format in _mesa_ColorTable");
415 /* store GLchan table */
416 table
->FloatTable
= GL_FALSE
;
417 table
->Table
= MALLOC(comps
* width
* sizeof(GLchan
));
419 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glColorTable");
422 _mesa_unpack_chan_color_span(ctx
, width
, table
->Format
,
423 (GLchan
*) table
->Table
, /* dest */
430 if (texObj
|| target
== GL_SHARED_TEXTURE_PALETTE_EXT
) {
431 /* texture object palette, texObj==NULL means the shared palette */
432 if (ctx
->Driver
.UpdateTexturePalette
) {
433 (*ctx
->Driver
.UpdateTexturePalette
)( ctx
, texObj
);
437 ctx
->NewState
|= _NEW_PIXEL
;
443 _mesa_ColorSubTable( GLenum target
, GLsizei start
,
444 GLsizei count
, GLenum format
, GLenum type
,
447 GET_CURRENT_CONTEXT(ctx
);
448 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
449 struct gl_texture_object
*texObj
= NULL
;
450 struct gl_color_table
*table
= NULL
;
451 GLfloat rScale
= 1.0, gScale
= 1.0, bScale
= 1.0, aScale
= 1.0;
452 GLfloat rBias
= 0.0, gBias
= 0.0, bBias
= 0.0, aBias
= 0.0;
454 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
458 texObj
= texUnit
->Current1D
;
459 table
= &texObj
->Palette
;
462 texObj
= texUnit
->Current2D
;
463 table
= &texObj
->Palette
;
466 texObj
= texUnit
->Current3D
;
467 table
= &texObj
->Palette
;
469 case GL_TEXTURE_CUBE_MAP_ARB
:
470 if (!ctx
->Extensions
.ARB_texture_cube_map
) {
471 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorSubTable(target)");
474 texObj
= texUnit
->CurrentCubeMap
;
475 table
= &texObj
->Palette
;
477 case GL_SHARED_TEXTURE_PALETTE_EXT
:
478 table
= &ctx
->Texture
.Palette
;
481 table
= &ctx
->ColorTable
;
482 rScale
= ctx
->Pixel
.ColorTableScale
[0];
483 gScale
= ctx
->Pixel
.ColorTableScale
[1];
484 bScale
= ctx
->Pixel
.ColorTableScale
[2];
485 aScale
= ctx
->Pixel
.ColorTableScale
[3];
486 rBias
= ctx
->Pixel
.ColorTableBias
[0];
487 gBias
= ctx
->Pixel
.ColorTableBias
[1];
488 bBias
= ctx
->Pixel
.ColorTableBias
[2];
489 aBias
= ctx
->Pixel
.ColorTableBias
[3];
491 case GL_TEXTURE_COLOR_TABLE_SGI
:
492 if (!ctx
->Extensions
.SGI_texture_color_table
) {
493 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorSubTable(target)");
496 table
= &(texUnit
->ColorTable
);
497 rScale
= ctx
->Pixel
.TextureColorTableScale
[0];
498 gScale
= ctx
->Pixel
.TextureColorTableScale
[1];
499 bScale
= ctx
->Pixel
.TextureColorTableScale
[2];
500 aScale
= ctx
->Pixel
.TextureColorTableScale
[3];
501 rBias
= ctx
->Pixel
.TextureColorTableBias
[0];
502 gBias
= ctx
->Pixel
.TextureColorTableBias
[1];
503 bBias
= ctx
->Pixel
.TextureColorTableBias
[2];
504 aBias
= ctx
->Pixel
.TextureColorTableBias
[3];
506 case GL_POST_CONVOLUTION_COLOR_TABLE
:
507 table
= &ctx
->PostConvolutionColorTable
;
508 rScale
= ctx
->Pixel
.PCCTscale
[0];
509 gScale
= ctx
->Pixel
.PCCTscale
[1];
510 bScale
= ctx
->Pixel
.PCCTscale
[2];
511 aScale
= ctx
->Pixel
.PCCTscale
[3];
512 rBias
= ctx
->Pixel
.PCCTbias
[0];
513 gBias
= ctx
->Pixel
.PCCTbias
[1];
514 bBias
= ctx
->Pixel
.PCCTbias
[2];
515 aBias
= ctx
->Pixel
.PCCTbias
[3];
517 case GL_POST_COLOR_MATRIX_COLOR_TABLE
:
518 table
= &ctx
->PostColorMatrixColorTable
;
519 rScale
= ctx
->Pixel
.PCMCTscale
[0];
520 gScale
= ctx
->Pixel
.PCMCTscale
[1];
521 bScale
= ctx
->Pixel
.PCMCTscale
[2];
522 aScale
= ctx
->Pixel
.PCMCTscale
[3];
523 rBias
= ctx
->Pixel
.PCMCTbias
[0];
524 gBias
= ctx
->Pixel
.PCMCTbias
[1];
525 bBias
= ctx
->Pixel
.PCMCTbias
[2];
526 aBias
= ctx
->Pixel
.PCMCTbias
[3];
529 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorSubTable(target)");
535 if (!_mesa_is_legal_format_and_type(format
, type
) ||
536 format
== GL_INTENSITY
) {
537 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glColorSubTable(format or type)");
542 _mesa_error(ctx
, GL_INVALID_VALUE
, "glColorSubTable(count)");
546 comps
= _mesa_components_in_format(table
->Format
);
547 assert(comps
> 0); /* error should have been caught sooner */
549 if (start
+ count
> (GLint
) table
->Size
) {
550 _mesa_error(ctx
, GL_INVALID_VALUE
, "glColorSubTable(count)");
555 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glColorSubTable");
559 if (!table
->FloatTable
) {
560 GLchan
*dest
= (GLchan
*) table
->Table
+ start
* comps
* sizeof(GLchan
);
561 _mesa_unpack_chan_color_span(ctx
, count
, table
->Format
, dest
,
562 format
, type
, data
, &ctx
->Unpack
, 0);
565 GLfloat tempTab
[MAX_COLOR_TABLE_SIZE
* 4];
569 ASSERT(table
->FloatTable
);
571 _mesa_unpack_float_color_span(ctx
, count
, table
->Format
,
573 format
, type
, data
, &ctx
->Unpack
,
576 tableF
= (GLfloat
*) table
->Table
;
578 switch (table
->Format
) {
580 for (i
= 0; i
< count
; i
++) {
581 GLuint j
= start
+ i
;
582 tableF
[j
] = CLAMP(tempTab
[i
] * rScale
+ rBias
, 0.0F
, 1.0F
);
586 for (i
= 0; i
< count
; i
++) {
587 GLuint j
= start
+ i
;
588 tableF
[j
] = CLAMP(tempTab
[i
] * rScale
+ rBias
, 0.0F
, 1.0F
);
592 for (i
= 0; i
< count
; i
++) {
593 GLuint j
= start
+ i
;
594 tableF
[j
] = CLAMP(tempTab
[i
] * aScale
+ aBias
, 0.0F
, 1.0F
);
597 case GL_LUMINANCE_ALPHA
:
598 for (i
= 0; i
< count
; i
++) {
599 GLuint j
= start
+ i
;
600 tableF
[j
*2+0] = CLAMP(tempTab
[i
*2+0] * rScale
+ rBias
, 0.0F
, 1.0F
);
601 tableF
[j
*2+1] = CLAMP(tempTab
[i
*2+1] * aScale
+ aBias
, 0.0F
, 1.0F
);
605 for (i
= 0; i
< count
; i
++) {
606 GLuint j
= start
+ i
;
607 tableF
[j
*3+0] = CLAMP(tempTab
[i
*3+0] * rScale
+ rBias
, 0.0F
, 1.0F
);
608 tableF
[j
*3+1] = CLAMP(tempTab
[i
*3+1] * gScale
+ gBias
, 0.0F
, 1.0F
);
609 tableF
[j
*3+2] = CLAMP(tempTab
[i
*3+2] * bScale
+ bBias
, 0.0F
, 1.0F
);
613 for (i
= 0; i
< count
; i
++) {
614 GLuint j
= start
+ i
;
615 tableF
[j
*4+0] = CLAMP(tempTab
[i
*4+0] * rScale
+ rBias
, 0.0F
, 1.0F
);
616 tableF
[j
*4+1] = CLAMP(tempTab
[i
*4+1] * gScale
+ gBias
, 0.0F
, 1.0F
);
617 tableF
[j
*4+2] = CLAMP(tempTab
[i
*4+2] * bScale
+ bBias
, 0.0F
, 1.0F
);
618 tableF
[j
*4+3] = CLAMP(tempTab
[i
*4+3] * aScale
+ aBias
, 0.0F
, 1.0F
);
622 _mesa_problem(ctx
, "Bad format in _mesa_ColorSubTable");
627 if (texObj
|| target
== GL_SHARED_TEXTURE_PALETTE_EXT
) {
628 /* per-texture object palette */
629 if (ctx
->Driver
.UpdateTexturePalette
) {
630 (*ctx
->Driver
.UpdateTexturePalette
)( ctx
, texObj
);
634 ctx
->NewState
|= _NEW_PIXEL
;
641 _mesa_CopyColorTable(GLenum target
, GLenum internalformat
,
642 GLint x
, GLint y
, GLsizei width
)
644 GET_CURRENT_CONTEXT(ctx
);
645 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
647 /* Select buffer to read from */
648 ctx
->Driver
.CopyColorTable( ctx
, target
, internalformat
, x
, y
, width
);
655 _mesa_CopyColorSubTable(GLenum target
, GLsizei start
,
656 GLint x
, GLint y
, GLsizei width
)
658 GET_CURRENT_CONTEXT(ctx
);
659 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
661 ctx
->Driver
.CopyColorSubTable( ctx
, target
, start
, x
, y
, width
);
667 _mesa_GetColorTable( GLenum target
, GLenum format
,
668 GLenum type
, GLvoid
*data
)
670 GET_CURRENT_CONTEXT(ctx
);
671 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
672 struct gl_color_table
*table
= NULL
;
673 GLchan rgba
[MAX_COLOR_TABLE_SIZE
][4];
674 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
677 _mesa_update_state(ctx
);
682 table
= &texUnit
->Current1D
->Palette
;
685 table
= &texUnit
->Current2D
->Palette
;
688 table
= &texUnit
->Current3D
->Palette
;
690 case GL_TEXTURE_CUBE_MAP_ARB
:
691 if (!ctx
->Extensions
.ARB_texture_cube_map
) {
692 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTable(target)");
695 table
= &texUnit
->CurrentCubeMap
->Palette
;
697 case GL_SHARED_TEXTURE_PALETTE_EXT
:
698 table
= &ctx
->Texture
.Palette
;
701 table
= &ctx
->ColorTable
;
703 case GL_TEXTURE_COLOR_TABLE_SGI
:
704 if (!ctx
->Extensions
.SGI_texture_color_table
) {
705 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTable(target)");
708 table
= &(texUnit
->ColorTable
);
710 case GL_POST_CONVOLUTION_COLOR_TABLE
:
711 table
= &ctx
->PostConvolutionColorTable
;
713 case GL_POST_COLOR_MATRIX_COLOR_TABLE
:
714 table
= &ctx
->PostColorMatrixColorTable
;
717 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTable(target)");
723 switch (table
->Format
) {
725 if (table
->FloatTable
) {
726 const GLfloat
*tableF
= (const GLfloat
*) table
->Table
;
728 for (i
= 0; i
< table
->Size
; i
++) {
732 rgba
[i
][ACOMP
] = IROUND_POS(tableF
[i
] * CHAN_MAXF
);
736 const GLchan
*tableUB
= (const GLchan
*) table
->Table
;
738 for (i
= 0; i
< table
->Size
; i
++) {
742 rgba
[i
][ACOMP
] = tableUB
[i
];
747 if (table
->FloatTable
) {
748 const GLfloat
*tableF
= (const GLfloat
*) table
->Table
;
750 for (i
= 0; i
< table
->Size
; i
++) {
751 rgba
[i
][RCOMP
] = IROUND_POS(tableF
[i
] * CHAN_MAXF
);
752 rgba
[i
][GCOMP
] = IROUND_POS(tableF
[i
] * CHAN_MAXF
);
753 rgba
[i
][BCOMP
] = IROUND_POS(tableF
[i
] * CHAN_MAXF
);
754 rgba
[i
][ACOMP
] = CHAN_MAX
;
758 const GLchan
*tableUB
= (const GLchan
*) table
->Table
;
760 for (i
= 0; i
< table
->Size
; i
++) {
761 rgba
[i
][RCOMP
] = tableUB
[i
];
762 rgba
[i
][GCOMP
] = tableUB
[i
];
763 rgba
[i
][BCOMP
] = tableUB
[i
];
764 rgba
[i
][ACOMP
] = CHAN_MAX
;
768 case GL_LUMINANCE_ALPHA
:
769 if (table
->FloatTable
) {
770 const GLfloat
*tableF
= (const GLfloat
*) table
->Table
;
772 for (i
= 0; i
< table
->Size
; i
++) {
773 rgba
[i
][RCOMP
] = IROUND_POS(tableF
[i
*2+0] * CHAN_MAXF
);
774 rgba
[i
][GCOMP
] = IROUND_POS(tableF
[i
*2+0] * CHAN_MAXF
);
775 rgba
[i
][BCOMP
] = IROUND_POS(tableF
[i
*2+0] * CHAN_MAXF
);
776 rgba
[i
][ACOMP
] = IROUND_POS(tableF
[i
*2+1] * CHAN_MAXF
);
780 const GLchan
*tableUB
= (const GLchan
*) table
->Table
;
782 for (i
= 0; i
< table
->Size
; i
++) {
783 rgba
[i
][RCOMP
] = tableUB
[i
*2+0];
784 rgba
[i
][GCOMP
] = tableUB
[i
*2+0];
785 rgba
[i
][BCOMP
] = tableUB
[i
*2+0];
786 rgba
[i
][ACOMP
] = tableUB
[i
*2+1];
791 if (table
->FloatTable
) {
792 const GLfloat
*tableF
= (const GLfloat
*) table
->Table
;
794 for (i
= 0; i
< table
->Size
; i
++) {
795 rgba
[i
][RCOMP
] = IROUND_POS(tableF
[i
] * CHAN_MAXF
);
796 rgba
[i
][GCOMP
] = IROUND_POS(tableF
[i
] * CHAN_MAXF
);
797 rgba
[i
][BCOMP
] = IROUND_POS(tableF
[i
] * CHAN_MAXF
);
798 rgba
[i
][ACOMP
] = IROUND_POS(tableF
[i
] * CHAN_MAXF
);
802 const GLchan
*tableUB
= (const GLchan
*) table
->Table
;
804 for (i
= 0; i
< table
->Size
; i
++) {
805 rgba
[i
][RCOMP
] = tableUB
[i
];
806 rgba
[i
][GCOMP
] = tableUB
[i
];
807 rgba
[i
][BCOMP
] = tableUB
[i
];
808 rgba
[i
][ACOMP
] = tableUB
[i
];
813 if (table
->FloatTable
) {
814 const GLfloat
*tableF
= (const GLfloat
*) table
->Table
;
816 for (i
= 0; i
< table
->Size
; i
++) {
817 rgba
[i
][RCOMP
] = IROUND_POS(tableF
[i
*3+0] * CHAN_MAXF
);
818 rgba
[i
][GCOMP
] = IROUND_POS(tableF
[i
*3+1] * CHAN_MAXF
);
819 rgba
[i
][BCOMP
] = IROUND_POS(tableF
[i
*3+2] * CHAN_MAXF
);
820 rgba
[i
][ACOMP
] = CHAN_MAX
;
824 const GLchan
*tableUB
= (const GLchan
*) table
->Table
;
826 for (i
= 0; i
< table
->Size
; i
++) {
827 rgba
[i
][RCOMP
] = tableUB
[i
*3+0];
828 rgba
[i
][GCOMP
] = tableUB
[i
*3+1];
829 rgba
[i
][BCOMP
] = tableUB
[i
*3+2];
830 rgba
[i
][ACOMP
] = CHAN_MAX
;
835 if (table
->FloatTable
) {
836 const GLfloat
*tableF
= (const GLfloat
*) table
->Table
;
838 for (i
= 0; i
< table
->Size
; i
++) {
839 rgba
[i
][RCOMP
] = IROUND_POS(tableF
[i
*4+0] * CHAN_MAXF
);
840 rgba
[i
][GCOMP
] = IROUND_POS(tableF
[i
*4+1] * CHAN_MAXF
);
841 rgba
[i
][BCOMP
] = IROUND_POS(tableF
[i
*4+2] * CHAN_MAXF
);
842 rgba
[i
][ACOMP
] = IROUND_POS(tableF
[i
*4+3] * CHAN_MAXF
);
846 const GLchan
*tableUB
= (const GLchan
*) table
->Table
;
848 for (i
= 0; i
< table
->Size
; i
++) {
849 rgba
[i
][RCOMP
] = tableUB
[i
*4+0];
850 rgba
[i
][GCOMP
] = tableUB
[i
*4+1];
851 rgba
[i
][BCOMP
] = tableUB
[i
*4+2];
852 rgba
[i
][ACOMP
] = tableUB
[i
*4+3];
857 _mesa_problem(ctx
, "bad table format in glGetColorTable");
861 _mesa_pack_rgba_span(ctx
, table
->Size
, (const GLchan (*)[4]) rgba
,
862 format
, type
, data
, &ctx
->Pack
, GL_FALSE
);
868 _mesa_ColorTableParameterfv(GLenum target
, GLenum pname
, const GLfloat
*params
)
870 GET_CURRENT_CONTEXT(ctx
);
871 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
874 case GL_COLOR_TABLE_SGI
:
875 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
876 ctx
->Pixel
.ColorTableScale
[0] = params
[0];
877 ctx
->Pixel
.ColorTableScale
[1] = params
[1];
878 ctx
->Pixel
.ColorTableScale
[2] = params
[2];
879 ctx
->Pixel
.ColorTableScale
[3] = params
[3];
881 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
882 ctx
->Pixel
.ColorTableBias
[0] = params
[0];
883 ctx
->Pixel
.ColorTableBias
[1] = params
[1];
884 ctx
->Pixel
.ColorTableBias
[2] = params
[2];
885 ctx
->Pixel
.ColorTableBias
[3] = params
[3];
888 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTableParameterfv(pname)");
892 case GL_TEXTURE_COLOR_TABLE_SGI
:
893 if (!ctx
->Extensions
.SGI_texture_color_table
) {
894 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTableParameter(target)");
897 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
898 ctx
->Pixel
.TextureColorTableScale
[0] = params
[0];
899 ctx
->Pixel
.TextureColorTableScale
[1] = params
[1];
900 ctx
->Pixel
.TextureColorTableScale
[2] = params
[2];
901 ctx
->Pixel
.TextureColorTableScale
[3] = params
[3];
903 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
904 ctx
->Pixel
.TextureColorTableBias
[0] = params
[0];
905 ctx
->Pixel
.TextureColorTableBias
[1] = params
[1];
906 ctx
->Pixel
.TextureColorTableBias
[2] = params
[2];
907 ctx
->Pixel
.TextureColorTableBias
[3] = params
[3];
910 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTableParameterfv(pname)");
914 case GL_POST_CONVOLUTION_COLOR_TABLE_SGI
:
915 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
916 ctx
->Pixel
.PCCTscale
[0] = params
[0];
917 ctx
->Pixel
.PCCTscale
[1] = params
[1];
918 ctx
->Pixel
.PCCTscale
[2] = params
[2];
919 ctx
->Pixel
.PCCTscale
[3] = params
[3];
921 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
922 ctx
->Pixel
.PCCTbias
[0] = params
[0];
923 ctx
->Pixel
.PCCTbias
[1] = params
[1];
924 ctx
->Pixel
.PCCTbias
[2] = params
[2];
925 ctx
->Pixel
.PCCTbias
[3] = params
[3];
928 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTableParameterfv(pname)");
932 case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI
:
933 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
934 ctx
->Pixel
.PCMCTscale
[0] = params
[0];
935 ctx
->Pixel
.PCMCTscale
[1] = params
[1];
936 ctx
->Pixel
.PCMCTscale
[2] = params
[2];
937 ctx
->Pixel
.PCMCTscale
[3] = params
[3];
939 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
940 ctx
->Pixel
.PCMCTbias
[0] = params
[0];
941 ctx
->Pixel
.PCMCTbias
[1] = params
[1];
942 ctx
->Pixel
.PCMCTbias
[2] = params
[2];
943 ctx
->Pixel
.PCMCTbias
[3] = params
[3];
946 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTableParameterfv(pname)");
951 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTableParameter(target)");
955 ctx
->NewState
|= _NEW_PIXEL
;
961 _mesa_ColorTableParameteriv(GLenum target
, GLenum pname
, const GLint
*params
)
964 if (pname
== GL_COLOR_TABLE_SGI
||
965 pname
== GL_TEXTURE_COLOR_TABLE_SGI
||
966 pname
== GL_POST_CONVOLUTION_COLOR_TABLE_SGI
||
967 pname
== GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI
) {
969 fparams
[0] = (GLfloat
) params
[0];
970 fparams
[1] = (GLfloat
) params
[1];
971 fparams
[2] = (GLfloat
) params
[2];
972 fparams
[3] = (GLfloat
) params
[3];
976 fparams
[0] = (GLfloat
) params
[0];
978 _mesa_ColorTableParameterfv(target
, pname
, fparams
);
984 _mesa_GetColorTableParameterfv( GLenum target
, GLenum pname
, GLfloat
*params
)
986 GET_CURRENT_CONTEXT(ctx
);
987 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
988 struct gl_color_table
*table
= NULL
;
989 ASSERT_OUTSIDE_BEGIN_END(ctx
);
993 table
= &texUnit
->Current1D
->Palette
;
996 table
= &texUnit
->Current2D
->Palette
;
999 table
= &texUnit
->Current3D
->Palette
;
1001 case GL_TEXTURE_CUBE_MAP_ARB
:
1002 if (!ctx
->Extensions
.ARB_texture_cube_map
) {
1003 _mesa_error(ctx
, GL_INVALID_ENUM
,
1004 "glGetColorTableParameterfv(target)");
1007 table
= &texUnit
->CurrentCubeMap
->Palette
;
1009 case GL_PROXY_TEXTURE_1D
:
1010 table
= &ctx
->Texture
.Proxy1D
->Palette
;
1012 case GL_PROXY_TEXTURE_2D
:
1013 table
= &ctx
->Texture
.Proxy2D
->Palette
;
1015 case GL_PROXY_TEXTURE_3D
:
1016 table
= &ctx
->Texture
.Proxy3D
->Palette
;
1018 case GL_PROXY_TEXTURE_CUBE_MAP_ARB
:
1019 if (!ctx
->Extensions
.ARB_texture_cube_map
) {
1020 _mesa_error(ctx
, GL_INVALID_ENUM
,
1021 "glGetColorTableParameterfv(target)");
1024 table
= &ctx
->Texture
.ProxyCubeMap
->Palette
;
1026 case GL_SHARED_TEXTURE_PALETTE_EXT
:
1027 table
= &ctx
->Texture
.Palette
;
1029 case GL_COLOR_TABLE
:
1030 table
= &ctx
->ColorTable
;
1031 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
1032 params
[0] = ctx
->Pixel
.ColorTableScale
[0];
1033 params
[1] = ctx
->Pixel
.ColorTableScale
[1];
1034 params
[2] = ctx
->Pixel
.ColorTableScale
[2];
1035 params
[3] = ctx
->Pixel
.ColorTableScale
[3];
1038 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
1039 params
[0] = ctx
->Pixel
.ColorTableBias
[0];
1040 params
[1] = ctx
->Pixel
.ColorTableBias
[1];
1041 params
[2] = ctx
->Pixel
.ColorTableBias
[2];
1042 params
[3] = ctx
->Pixel
.ColorTableBias
[3];
1046 case GL_PROXY_COLOR_TABLE
:
1047 table
= &ctx
->ProxyColorTable
;
1049 case GL_TEXTURE_COLOR_TABLE_SGI
:
1050 if (!ctx
->Extensions
.SGI_texture_color_table
) {
1051 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameter(target)");
1054 table
= &(texUnit
->ColorTable
);
1055 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
1056 params
[0] = ctx
->Pixel
.TextureColorTableScale
[0];
1057 params
[1] = ctx
->Pixel
.TextureColorTableScale
[1];
1058 params
[2] = ctx
->Pixel
.TextureColorTableScale
[2];
1059 params
[3] = ctx
->Pixel
.TextureColorTableScale
[3];
1062 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
1063 params
[0] = ctx
->Pixel
.TextureColorTableBias
[0];
1064 params
[1] = ctx
->Pixel
.TextureColorTableBias
[1];
1065 params
[2] = ctx
->Pixel
.TextureColorTableBias
[2];
1066 params
[3] = ctx
->Pixel
.TextureColorTableBias
[3];
1070 case GL_PROXY_TEXTURE_COLOR_TABLE_SGI
:
1071 if (!ctx
->Extensions
.SGI_texture_color_table
) {
1072 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameter(target)");
1075 table
= &(texUnit
->ProxyColorTable
);
1077 case GL_POST_CONVOLUTION_COLOR_TABLE
:
1078 table
= &ctx
->PostConvolutionColorTable
;
1079 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
1080 params
[0] = ctx
->Pixel
.PCCTscale
[0];
1081 params
[1] = ctx
->Pixel
.PCCTscale
[1];
1082 params
[2] = ctx
->Pixel
.PCCTscale
[2];
1083 params
[3] = ctx
->Pixel
.PCCTscale
[3];
1086 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
1087 params
[0] = ctx
->Pixel
.PCCTbias
[0];
1088 params
[1] = ctx
->Pixel
.PCCTbias
[1];
1089 params
[2] = ctx
->Pixel
.PCCTbias
[2];
1090 params
[3] = ctx
->Pixel
.PCCTbias
[3];
1094 case GL_PROXY_POST_CONVOLUTION_COLOR_TABLE
:
1095 table
= &ctx
->ProxyPostConvolutionColorTable
;
1097 case GL_POST_COLOR_MATRIX_COLOR_TABLE
:
1098 table
= &ctx
->PostColorMatrixColorTable
;
1099 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
1100 params
[0] = ctx
->Pixel
.PCMCTscale
[0];
1101 params
[1] = ctx
->Pixel
.PCMCTscale
[1];
1102 params
[2] = ctx
->Pixel
.PCMCTscale
[2];
1103 params
[3] = ctx
->Pixel
.PCMCTscale
[3];
1106 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
1107 params
[0] = ctx
->Pixel
.PCMCTbias
[0];
1108 params
[1] = ctx
->Pixel
.PCMCTbias
[1];
1109 params
[2] = ctx
->Pixel
.PCMCTbias
[2];
1110 params
[3] = ctx
->Pixel
.PCMCTbias
[3];
1114 case GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE
:
1115 table
= &ctx
->ProxyPostColorMatrixColorTable
;
1118 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameterfv(target)");
1125 case GL_COLOR_TABLE_FORMAT
:
1126 *params
= (GLfloat
) table
->IntFormat
;
1128 case GL_COLOR_TABLE_WIDTH
:
1129 *params
= (GLfloat
) table
->Size
;
1131 case GL_COLOR_TABLE_RED_SIZE
:
1132 *params
= (GLfloat
) table
->RedSize
;
1134 case GL_COLOR_TABLE_GREEN_SIZE
:
1135 *params
= (GLfloat
) table
->GreenSize
;
1137 case GL_COLOR_TABLE_BLUE_SIZE
:
1138 *params
= (GLfloat
) table
->BlueSize
;
1140 case GL_COLOR_TABLE_ALPHA_SIZE
:
1141 *params
= (GLfloat
) table
->AlphaSize
;
1143 case GL_COLOR_TABLE_LUMINANCE_SIZE
:
1144 *params
= (GLfloat
) table
->LuminanceSize
;
1146 case GL_COLOR_TABLE_INTENSITY_SIZE
:
1147 *params
= (GLfloat
) table
->IntensitySize
;
1150 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameterfv(pname)" );
1158 _mesa_GetColorTableParameteriv( GLenum target
, GLenum pname
, GLint
*params
)
1160 GET_CURRENT_CONTEXT(ctx
);
1161 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1162 struct gl_color_table
*table
= NULL
;
1163 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1167 table
= &texUnit
->Current1D
->Palette
;
1170 table
= &texUnit
->Current2D
->Palette
;
1173 table
= &texUnit
->Current3D
->Palette
;
1175 case GL_TEXTURE_CUBE_MAP_ARB
:
1176 if (!ctx
->Extensions
.ARB_texture_cube_map
) {
1177 _mesa_error(ctx
, GL_INVALID_ENUM
,
1178 "glGetColorTableParameteriv(target)");
1181 table
= &texUnit
->CurrentCubeMap
->Palette
;
1183 case GL_PROXY_TEXTURE_1D
:
1184 table
= &ctx
->Texture
.Proxy1D
->Palette
;
1186 case GL_PROXY_TEXTURE_2D
:
1187 table
= &ctx
->Texture
.Proxy2D
->Palette
;
1189 case GL_PROXY_TEXTURE_3D
:
1190 table
= &ctx
->Texture
.Proxy3D
->Palette
;
1192 case GL_PROXY_TEXTURE_CUBE_MAP_ARB
:
1193 if (!ctx
->Extensions
.ARB_texture_cube_map
) {
1194 _mesa_error(ctx
, GL_INVALID_ENUM
,
1195 "glGetColorTableParameteriv(target)");
1198 table
= &ctx
->Texture
.ProxyCubeMap
->Palette
;
1200 case GL_SHARED_TEXTURE_PALETTE_EXT
:
1201 table
= &ctx
->Texture
.Palette
;
1203 case GL_COLOR_TABLE
:
1204 table
= &ctx
->ColorTable
;
1205 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
1206 params
[0] = (GLint
) ctx
->Pixel
.ColorTableScale
[0];
1207 params
[1] = (GLint
) ctx
->Pixel
.ColorTableScale
[1];
1208 params
[2] = (GLint
) ctx
->Pixel
.ColorTableScale
[2];
1209 params
[3] = (GLint
) ctx
->Pixel
.ColorTableScale
[3];
1212 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
1213 params
[0] = (GLint
) ctx
->Pixel
.ColorTableBias
[0];
1214 params
[1] = (GLint
) ctx
->Pixel
.ColorTableBias
[1];
1215 params
[2] = (GLint
) ctx
->Pixel
.ColorTableBias
[2];
1216 params
[3] = (GLint
) ctx
->Pixel
.ColorTableBias
[3];
1220 case GL_PROXY_COLOR_TABLE
:
1221 table
= &ctx
->ProxyColorTable
;
1223 case GL_TEXTURE_COLOR_TABLE_SGI
:
1224 if (!ctx
->Extensions
.SGI_texture_color_table
) {
1225 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameter(target)");
1228 table
= &(texUnit
->ColorTable
);
1229 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
1230 params
[0] = (GLint
) ctx
->Pixel
.TextureColorTableScale
[0];
1231 params
[1] = (GLint
) ctx
->Pixel
.TextureColorTableScale
[1];
1232 params
[2] = (GLint
) ctx
->Pixel
.TextureColorTableScale
[2];
1233 params
[3] = (GLint
) ctx
->Pixel
.TextureColorTableScale
[3];
1236 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
1237 params
[0] = (GLint
) ctx
->Pixel
.TextureColorTableBias
[0];
1238 params
[1] = (GLint
) ctx
->Pixel
.TextureColorTableBias
[1];
1239 params
[2] = (GLint
) ctx
->Pixel
.TextureColorTableBias
[2];
1240 params
[3] = (GLint
) ctx
->Pixel
.TextureColorTableBias
[3];
1244 case GL_PROXY_TEXTURE_COLOR_TABLE_SGI
:
1245 if (!ctx
->Extensions
.SGI_texture_color_table
) {
1246 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameter(target)");
1249 table
= &(texUnit
->ProxyColorTable
);
1251 case GL_POST_CONVOLUTION_COLOR_TABLE
:
1252 table
= &ctx
->PostConvolutionColorTable
;
1253 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
1254 params
[0] = (GLint
) ctx
->Pixel
.PCCTscale
[0];
1255 params
[1] = (GLint
) ctx
->Pixel
.PCCTscale
[1];
1256 params
[2] = (GLint
) ctx
->Pixel
.PCCTscale
[2];
1257 params
[3] = (GLint
) ctx
->Pixel
.PCCTscale
[3];
1260 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
1261 params
[0] = (GLint
) ctx
->Pixel
.PCCTbias
[0];
1262 params
[1] = (GLint
) ctx
->Pixel
.PCCTbias
[1];
1263 params
[2] = (GLint
) ctx
->Pixel
.PCCTbias
[2];
1264 params
[3] = (GLint
) ctx
->Pixel
.PCCTbias
[3];
1268 case GL_PROXY_POST_CONVOLUTION_COLOR_TABLE
:
1269 table
= &ctx
->ProxyPostConvolutionColorTable
;
1271 case GL_POST_COLOR_MATRIX_COLOR_TABLE
:
1272 table
= &ctx
->PostColorMatrixColorTable
;
1273 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
1274 params
[0] = (GLint
) ctx
->Pixel
.PCMCTscale
[0];
1275 params
[1] = (GLint
) ctx
->Pixel
.PCMCTscale
[1];
1276 params
[2] = (GLint
) ctx
->Pixel
.PCMCTscale
[2];
1277 params
[3] = (GLint
) ctx
->Pixel
.PCMCTscale
[3];
1280 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
1281 params
[0] = (GLint
) ctx
->Pixel
.PCMCTbias
[0];
1282 params
[1] = (GLint
) ctx
->Pixel
.PCMCTbias
[1];
1283 params
[2] = (GLint
) ctx
->Pixel
.PCMCTbias
[2];
1284 params
[3] = (GLint
) ctx
->Pixel
.PCMCTbias
[3];
1288 case GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE
:
1289 table
= &ctx
->ProxyPostColorMatrixColorTable
;
1292 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameteriv(target)");
1299 case GL_COLOR_TABLE_FORMAT
:
1300 *params
= table
->IntFormat
;
1302 case GL_COLOR_TABLE_WIDTH
:
1303 *params
= table
->Size
;
1305 case GL_COLOR_TABLE_RED_SIZE
:
1306 *params
= table
->RedSize
;
1308 case GL_COLOR_TABLE_GREEN_SIZE
:
1309 *params
= table
->GreenSize
;
1311 case GL_COLOR_TABLE_BLUE_SIZE
:
1312 *params
= table
->BlueSize
;
1314 case GL_COLOR_TABLE_ALPHA_SIZE
:
1315 *params
= table
->AlphaSize
;
1317 case GL_COLOR_TABLE_LUMINANCE_SIZE
:
1318 *params
= table
->LuminanceSize
;
1320 case GL_COLOR_TABLE_INTENSITY_SIZE
:
1321 *params
= table
->IntensitySize
;
1324 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameteriv(pname)" );
1329 /**********************************************************************/
1330 /***** Initialization *****/
1331 /**********************************************************************/
1335 _mesa_init_colortable( struct gl_color_table
*p
)
1337 p
->FloatTable
= GL_FALSE
;
1340 p
->IntFormat
= GL_RGBA
;
1346 _mesa_free_colortable_data( struct gl_color_table
*p
)
1356 * Initialize all colortables for a context.
1358 void _mesa_init_colortables( GLcontext
* ctx
)
1361 _mesa_init_colortable(&ctx
->ColorTable
);
1362 _mesa_init_colortable(&ctx
->ProxyColorTable
);
1363 _mesa_init_colortable(&ctx
->PostConvolutionColorTable
);
1364 _mesa_init_colortable(&ctx
->ProxyPostConvolutionColorTable
);
1365 _mesa_init_colortable(&ctx
->PostColorMatrixColorTable
);
1366 _mesa_init_colortable(&ctx
->ProxyPostColorMatrixColorTable
);
1371 * Free all colortable data for a context
1373 void _mesa_free_colortables_data( GLcontext
*ctx
)
1375 _mesa_free_colortable_data(&ctx
->ColorTable
);
1376 _mesa_free_colortable_data(&ctx
->ProxyColorTable
);
1377 _mesa_free_colortable_data(&ctx
->PostConvolutionColorTable
);
1378 _mesa_free_colortable_data(&ctx
->ProxyPostConvolutionColorTable
);
1379 _mesa_free_colortable_data(&ctx
->PostColorMatrixColorTable
);
1380 _mesa_free_colortable_data(&ctx
->ProxyPostColorMatrixColorTable
);