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 _mesa_ColorTable( GLenum target
, GLenum internalFormat
,
176 GLsizei width
, GLenum format
, GLenum type
,
179 GET_CURRENT_CONTEXT(ctx
);
180 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
181 struct gl_texture_object
*texObj
= NULL
;
182 struct gl_color_table
*table
= NULL
;
183 GLboolean proxy
= GL_FALSE
;
185 GLfloat rScale
= 1.0, gScale
= 1.0, bScale
= 1.0, aScale
= 1.0;
186 GLfloat rBias
= 0.0, gBias
= 0.0, bBias
= 0.0, aBias
= 0.0;
187 GLenum tableType
= CHAN_TYPE
;
189 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
); /* too complex */
193 texObj
= texUnit
->Current1D
;
194 table
= &texObj
->Palette
;
197 texObj
= texUnit
->Current2D
;
198 table
= &texObj
->Palette
;
201 texObj
= texUnit
->Current3D
;
202 table
= &texObj
->Palette
;
204 case GL_TEXTURE_CUBE_MAP_ARB
:
205 if (!ctx
->Extensions
.ARB_texture_cube_map
) {
206 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTable(target)");
209 texObj
= texUnit
->CurrentCubeMap
;
210 table
= &texObj
->Palette
;
212 case GL_PROXY_TEXTURE_1D
:
213 texObj
= ctx
->Texture
.Proxy1D
;
214 table
= &texObj
->Palette
;
217 case GL_PROXY_TEXTURE_2D
:
218 texObj
= ctx
->Texture
.Proxy2D
;
219 table
= &texObj
->Palette
;
222 case GL_PROXY_TEXTURE_3D
:
223 texObj
= ctx
->Texture
.Proxy3D
;
224 table
= &texObj
->Palette
;
227 case GL_PROXY_TEXTURE_CUBE_MAP_ARB
:
228 if (!ctx
->Extensions
.ARB_texture_cube_map
) {
229 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTable(target)");
232 texObj
= ctx
->Texture
.ProxyCubeMap
;
233 table
= &texObj
->Palette
;
235 case GL_SHARED_TEXTURE_PALETTE_EXT
:
236 table
= &ctx
->Texture
.Palette
;
239 table
= &ctx
->ColorTable
;
240 tableType
= GL_FLOAT
;
241 rScale
= ctx
->Pixel
.ColorTableScale
[0];
242 gScale
= ctx
->Pixel
.ColorTableScale
[1];
243 bScale
= ctx
->Pixel
.ColorTableScale
[2];
244 aScale
= ctx
->Pixel
.ColorTableScale
[3];
245 rBias
= ctx
->Pixel
.ColorTableBias
[0];
246 gBias
= ctx
->Pixel
.ColorTableBias
[1];
247 bBias
= ctx
->Pixel
.ColorTableBias
[2];
248 aBias
= ctx
->Pixel
.ColorTableBias
[3];
250 case GL_PROXY_COLOR_TABLE
:
251 table
= &ctx
->ProxyColorTable
;
254 case GL_TEXTURE_COLOR_TABLE_SGI
:
255 if (!ctx
->Extensions
.SGI_texture_color_table
) {
256 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTable(target)");
259 table
= &(texUnit
->ColorTable
);
260 tableType
= GL_FLOAT
;
261 rScale
= ctx
->Pixel
.TextureColorTableScale
[0];
262 gScale
= ctx
->Pixel
.TextureColorTableScale
[1];
263 bScale
= ctx
->Pixel
.TextureColorTableScale
[2];
264 aScale
= ctx
->Pixel
.TextureColorTableScale
[3];
265 rBias
= ctx
->Pixel
.TextureColorTableBias
[0];
266 gBias
= ctx
->Pixel
.TextureColorTableBias
[1];
267 bBias
= ctx
->Pixel
.TextureColorTableBias
[2];
268 aBias
= ctx
->Pixel
.TextureColorTableBias
[3];
270 case GL_PROXY_TEXTURE_COLOR_TABLE_SGI
:
271 if (!ctx
->Extensions
.SGI_texture_color_table
) {
272 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTable(target)");
275 table
= &(texUnit
->ProxyColorTable
);
278 case GL_POST_CONVOLUTION_COLOR_TABLE
:
279 table
= &ctx
->PostConvolutionColorTable
;
280 tableType
= GL_FLOAT
;
281 rScale
= ctx
->Pixel
.PCCTscale
[0];
282 gScale
= ctx
->Pixel
.PCCTscale
[1];
283 bScale
= ctx
->Pixel
.PCCTscale
[2];
284 aScale
= ctx
->Pixel
.PCCTscale
[3];
285 rBias
= ctx
->Pixel
.PCCTbias
[0];
286 gBias
= ctx
->Pixel
.PCCTbias
[1];
287 bBias
= ctx
->Pixel
.PCCTbias
[2];
288 aBias
= ctx
->Pixel
.PCCTbias
[3];
290 case GL_PROXY_POST_CONVOLUTION_COLOR_TABLE
:
291 table
= &ctx
->ProxyPostConvolutionColorTable
;
294 case GL_POST_COLOR_MATRIX_COLOR_TABLE
:
295 table
= &ctx
->PostColorMatrixColorTable
;
296 tableType
= GL_FLOAT
;
297 rScale
= ctx
->Pixel
.PCMCTscale
[0];
298 gScale
= ctx
->Pixel
.PCMCTscale
[1];
299 bScale
= ctx
->Pixel
.PCMCTscale
[2];
300 aScale
= ctx
->Pixel
.PCMCTscale
[3];
301 rBias
= ctx
->Pixel
.PCMCTbias
[0];
302 gBias
= ctx
->Pixel
.PCMCTbias
[1];
303 bBias
= ctx
->Pixel
.PCMCTbias
[2];
304 aBias
= ctx
->Pixel
.PCMCTbias
[3];
306 case GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE
:
307 table
= &ctx
->ProxyPostColorMatrixColorTable
;
311 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTable(target)");
317 if (!_mesa_is_legal_format_and_type(format
, type
) ||
318 format
== GL_INTENSITY
) {
319 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glColorTable(format or type)");
323 baseFormat
= base_colortab_format(internalFormat
);
324 if (baseFormat
< 0 || baseFormat
== GL_COLOR_INDEX
) {
325 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTable(internalFormat)");
329 if (width
< 0 || (width
!= 0 && _mesa_bitcount(width
) != 1)) {
333 table
->IntFormat
= (GLenum
) 0;
334 table
->Format
= (GLenum
) 0;
337 _mesa_error(ctx
, GL_INVALID_VALUE
, "glColorTable(width=%d)", width
);
342 if (width
> (GLsizei
) ctx
->Const
.MaxColorTableSize
) {
345 table
->IntFormat
= (GLenum
) 0;
346 table
->Format
= (GLenum
) 0;
349 _mesa_error(ctx
, GL_TABLE_TOO_LARGE
, "glColorTable(width)");
355 table
->IntFormat
= internalFormat
;
356 table
->Format
= (GLenum
) baseFormat
;
357 set_component_sizes(table
);
359 comps
= _mesa_components_in_format(table
->Format
);
360 assert(comps
> 0); /* error should have been caught sooner */
363 /* free old table, if any */
369 if (tableType
== GL_FLOAT
) {
370 GLfloat tempTab
[MAX_COLOR_TABLE_SIZE
* 4];
374 _mesa_unpack_float_color_span(ctx
, width
, table
->Format
,
376 format
, type
, data
, &ctx
->Unpack
,
379 table
->Type
= GL_FLOAT
;
380 table
->Table
= MALLOC(comps
* width
* sizeof(GLfloat
));
382 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glColorTable");
386 tableF
= (GLfloat
*) table
->Table
;
388 switch (table
->Format
) {
390 for (i
= 0; i
< width
; i
++) {
391 tableF
[i
] = CLAMP(tempTab
[i
] * rScale
+ rBias
, 0.0F
, 1.0F
);
395 for (i
= 0; i
< width
; i
++) {
396 tableF
[i
] = CLAMP(tempTab
[i
] * rScale
+ rBias
, 0.0F
, 1.0F
);
400 for (i
= 0; i
< width
; i
++) {
401 tableF
[i
] = CLAMP(tempTab
[i
] * aScale
+ aBias
, 0.0F
, 1.0F
);
404 case GL_LUMINANCE_ALPHA
:
405 for (i
= 0; i
< width
; i
++) {
406 tableF
[i
*2+0] = CLAMP(tempTab
[i
*2+0] * rScale
+ rBias
, 0.0F
, 1.0F
);
407 tableF
[i
*2+1] = CLAMP(tempTab
[i
*2+1] * aScale
+ aBias
, 0.0F
, 1.0F
);
411 for (i
= 0; i
< width
; i
++) {
412 tableF
[i
*3+0] = CLAMP(tempTab
[i
*3+0] * rScale
+ rBias
, 0.0F
, 1.0F
);
413 tableF
[i
*3+1] = CLAMP(tempTab
[i
*3+1] * gScale
+ gBias
, 0.0F
, 1.0F
);
414 tableF
[i
*3+2] = CLAMP(tempTab
[i
*3+2] * bScale
+ bBias
, 0.0F
, 1.0F
);
418 for (i
= 0; i
< width
; i
++) {
419 tableF
[i
*4+0] = CLAMP(tempTab
[i
*4+0] * rScale
+ rBias
, 0.0F
, 1.0F
);
420 tableF
[i
*4+1] = CLAMP(tempTab
[i
*4+1] * gScale
+ gBias
, 0.0F
, 1.0F
);
421 tableF
[i
*4+2] = CLAMP(tempTab
[i
*4+2] * bScale
+ bBias
, 0.0F
, 1.0F
);
422 tableF
[i
*4+3] = CLAMP(tempTab
[i
*4+3] * aScale
+ aBias
, 0.0F
, 1.0F
);
426 _mesa_problem(ctx
, "Bad format in _mesa_ColorTable");
431 /* store GLchan table */
432 table
->Type
= CHAN_TYPE
;
433 table
->Table
= MALLOC(comps
* width
* sizeof(GLchan
));
435 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glColorTable");
438 _mesa_unpack_chan_color_span(ctx
, width
, table
->Format
,
439 (GLchan
*) table
->Table
, /* dest */
442 } /* type==GL_FLOAT */
446 if (texObj
|| target
== GL_SHARED_TEXTURE_PALETTE_EXT
) {
447 /* texture object palette, texObj==NULL means the shared palette */
448 if (ctx
->Driver
.UpdateTexturePalette
) {
449 (*ctx
->Driver
.UpdateTexturePalette
)( ctx
, texObj
);
453 ctx
->NewState
|= _NEW_PIXEL
;
459 _mesa_ColorSubTable( GLenum target
, GLsizei start
,
460 GLsizei count
, GLenum format
, GLenum type
,
463 GET_CURRENT_CONTEXT(ctx
);
464 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
465 struct gl_texture_object
*texObj
= NULL
;
466 struct gl_color_table
*table
= NULL
;
467 GLfloat rScale
= 1.0, gScale
= 1.0, bScale
= 1.0, aScale
= 1.0;
468 GLfloat rBias
= 0.0, gBias
= 0.0, bBias
= 0.0, aBias
= 0.0;
470 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
474 texObj
= texUnit
->Current1D
;
475 table
= &texObj
->Palette
;
478 texObj
= texUnit
->Current2D
;
479 table
= &texObj
->Palette
;
482 texObj
= texUnit
->Current3D
;
483 table
= &texObj
->Palette
;
485 case GL_TEXTURE_CUBE_MAP_ARB
:
486 if (!ctx
->Extensions
.ARB_texture_cube_map
) {
487 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorSubTable(target)");
490 texObj
= texUnit
->CurrentCubeMap
;
491 table
= &texObj
->Palette
;
493 case GL_SHARED_TEXTURE_PALETTE_EXT
:
494 table
= &ctx
->Texture
.Palette
;
497 table
= &ctx
->ColorTable
;
498 rScale
= ctx
->Pixel
.ColorTableScale
[0];
499 gScale
= ctx
->Pixel
.ColorTableScale
[1];
500 bScale
= ctx
->Pixel
.ColorTableScale
[2];
501 aScale
= ctx
->Pixel
.ColorTableScale
[3];
502 rBias
= ctx
->Pixel
.ColorTableBias
[0];
503 gBias
= ctx
->Pixel
.ColorTableBias
[1];
504 bBias
= ctx
->Pixel
.ColorTableBias
[2];
505 aBias
= ctx
->Pixel
.ColorTableBias
[3];
507 case GL_TEXTURE_COLOR_TABLE_SGI
:
508 if (!ctx
->Extensions
.SGI_texture_color_table
) {
509 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorSubTable(target)");
512 table
= &(texUnit
->ColorTable
);
513 rScale
= ctx
->Pixel
.TextureColorTableScale
[0];
514 gScale
= ctx
->Pixel
.TextureColorTableScale
[1];
515 bScale
= ctx
->Pixel
.TextureColorTableScale
[2];
516 aScale
= ctx
->Pixel
.TextureColorTableScale
[3];
517 rBias
= ctx
->Pixel
.TextureColorTableBias
[0];
518 gBias
= ctx
->Pixel
.TextureColorTableBias
[1];
519 bBias
= ctx
->Pixel
.TextureColorTableBias
[2];
520 aBias
= ctx
->Pixel
.TextureColorTableBias
[3];
522 case GL_POST_CONVOLUTION_COLOR_TABLE
:
523 table
= &ctx
->PostConvolutionColorTable
;
524 rScale
= ctx
->Pixel
.PCCTscale
[0];
525 gScale
= ctx
->Pixel
.PCCTscale
[1];
526 bScale
= ctx
->Pixel
.PCCTscale
[2];
527 aScale
= ctx
->Pixel
.PCCTscale
[3];
528 rBias
= ctx
->Pixel
.PCCTbias
[0];
529 gBias
= ctx
->Pixel
.PCCTbias
[1];
530 bBias
= ctx
->Pixel
.PCCTbias
[2];
531 aBias
= ctx
->Pixel
.PCCTbias
[3];
533 case GL_POST_COLOR_MATRIX_COLOR_TABLE
:
534 table
= &ctx
->PostColorMatrixColorTable
;
535 rScale
= ctx
->Pixel
.PCMCTscale
[0];
536 gScale
= ctx
->Pixel
.PCMCTscale
[1];
537 bScale
= ctx
->Pixel
.PCMCTscale
[2];
538 aScale
= ctx
->Pixel
.PCMCTscale
[3];
539 rBias
= ctx
->Pixel
.PCMCTbias
[0];
540 gBias
= ctx
->Pixel
.PCMCTbias
[1];
541 bBias
= ctx
->Pixel
.PCMCTbias
[2];
542 aBias
= ctx
->Pixel
.PCMCTbias
[3];
545 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorSubTable(target)");
551 if (!_mesa_is_legal_format_and_type(format
, type
) ||
552 format
== GL_INTENSITY
) {
553 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glColorSubTable(format or type)");
558 _mesa_error(ctx
, GL_INVALID_VALUE
, "glColorSubTable(count)");
562 comps
= _mesa_components_in_format(table
->Format
);
563 assert(comps
> 0); /* error should have been caught sooner */
565 if (start
+ count
> (GLint
) table
->Size
) {
566 _mesa_error(ctx
, GL_INVALID_VALUE
, "glColorSubTable(count)");
571 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glColorSubTable");
575 if (table
->Type
!= GL_FLOAT
) {
576 GLchan
*dest
= (GLchan
*) table
->Table
+ start
* comps
* sizeof(GLchan
);
577 _mesa_unpack_chan_color_span(ctx
, count
, table
->Format
, dest
,
578 format
, type
, data
, &ctx
->Unpack
, 0);
581 GLfloat tempTab
[MAX_COLOR_TABLE_SIZE
* 4];
585 ASSERT(table
->Type
== GL_FLOAT
);
587 _mesa_unpack_float_color_span(ctx
, count
, table
->Format
,
589 format
, type
, data
, &ctx
->Unpack
,
592 tableF
= (GLfloat
*) table
->Table
;
594 switch (table
->Format
) {
596 for (i
= 0; i
< count
; i
++) {
597 GLuint j
= start
+ i
;
598 tableF
[j
] = CLAMP(tempTab
[i
] * rScale
+ rBias
, 0.0F
, 1.0F
);
602 for (i
= 0; i
< count
; i
++) {
603 GLuint j
= start
+ i
;
604 tableF
[j
] = CLAMP(tempTab
[i
] * rScale
+ rBias
, 0.0F
, 1.0F
);
608 for (i
= 0; i
< count
; i
++) {
609 GLuint j
= start
+ i
;
610 tableF
[j
] = CLAMP(tempTab
[i
] * aScale
+ aBias
, 0.0F
, 1.0F
);
613 case GL_LUMINANCE_ALPHA
:
614 for (i
= 0; i
< count
; i
++) {
615 GLuint j
= start
+ i
;
616 tableF
[j
*2+0] = CLAMP(tempTab
[i
*2+0] * rScale
+ rBias
, 0.0F
, 1.0F
);
617 tableF
[j
*2+1] = CLAMP(tempTab
[i
*2+1] * aScale
+ aBias
, 0.0F
, 1.0F
);
621 for (i
= 0; i
< count
; i
++) {
622 GLuint j
= start
+ i
;
623 tableF
[j
*3+0] = CLAMP(tempTab
[i
*3+0] * rScale
+ rBias
, 0.0F
, 1.0F
);
624 tableF
[j
*3+1] = CLAMP(tempTab
[i
*3+1] * gScale
+ gBias
, 0.0F
, 1.0F
);
625 tableF
[j
*3+2] = CLAMP(tempTab
[i
*3+2] * bScale
+ bBias
, 0.0F
, 1.0F
);
629 for (i
= 0; i
< count
; i
++) {
630 GLuint j
= start
+ i
;
631 tableF
[j
*4+0] = CLAMP(tempTab
[i
*4+0] * rScale
+ rBias
, 0.0F
, 1.0F
);
632 tableF
[j
*4+1] = CLAMP(tempTab
[i
*4+1] * gScale
+ gBias
, 0.0F
, 1.0F
);
633 tableF
[j
*4+2] = CLAMP(tempTab
[i
*4+2] * bScale
+ bBias
, 0.0F
, 1.0F
);
634 tableF
[j
*4+3] = CLAMP(tempTab
[i
*4+3] * aScale
+ aBias
, 0.0F
, 1.0F
);
638 _mesa_problem(ctx
, "Bad format in _mesa_ColorSubTable");
643 if (texObj
|| target
== GL_SHARED_TEXTURE_PALETTE_EXT
) {
644 /* per-texture object palette */
645 if (ctx
->Driver
.UpdateTexturePalette
) {
646 (*ctx
->Driver
.UpdateTexturePalette
)( ctx
, texObj
);
650 ctx
->NewState
|= _NEW_PIXEL
;
657 _mesa_CopyColorTable(GLenum target
, GLenum internalformat
,
658 GLint x
, GLint y
, GLsizei width
)
660 GET_CURRENT_CONTEXT(ctx
);
661 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
663 /* Select buffer to read from */
664 ctx
->Driver
.CopyColorTable( ctx
, target
, internalformat
, x
, y
, width
);
671 _mesa_CopyColorSubTable(GLenum target
, GLsizei start
,
672 GLint x
, GLint y
, GLsizei width
)
674 GET_CURRENT_CONTEXT(ctx
);
675 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
677 ctx
->Driver
.CopyColorSubTable( ctx
, target
, start
, x
, y
, width
);
683 _mesa_GetColorTable( GLenum target
, GLenum format
,
684 GLenum type
, GLvoid
*data
)
686 GET_CURRENT_CONTEXT(ctx
);
687 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
688 struct gl_color_table
*table
= NULL
;
689 GLchan rgba
[MAX_COLOR_TABLE_SIZE
][4];
690 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
693 _mesa_update_state(ctx
);
698 table
= &texUnit
->Current1D
->Palette
;
701 table
= &texUnit
->Current2D
->Palette
;
704 table
= &texUnit
->Current3D
->Palette
;
706 case GL_TEXTURE_CUBE_MAP_ARB
:
707 if (!ctx
->Extensions
.ARB_texture_cube_map
) {
708 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTable(target)");
711 table
= &texUnit
->CurrentCubeMap
->Palette
;
713 case GL_SHARED_TEXTURE_PALETTE_EXT
:
714 table
= &ctx
->Texture
.Palette
;
717 table
= &ctx
->ColorTable
;
719 case GL_TEXTURE_COLOR_TABLE_SGI
:
720 if (!ctx
->Extensions
.SGI_texture_color_table
) {
721 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTable(target)");
724 table
= &(texUnit
->ColorTable
);
726 case GL_POST_CONVOLUTION_COLOR_TABLE
:
727 table
= &ctx
->PostConvolutionColorTable
;
729 case GL_POST_COLOR_MATRIX_COLOR_TABLE
:
730 table
= &ctx
->PostColorMatrixColorTable
;
733 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTable(target)");
739 switch (table
->Format
) {
741 if (table
->Type
== GL_FLOAT
) {
742 const GLfloat
*tableF
= (const GLfloat
*) table
->Table
;
744 for (i
= 0; i
< table
->Size
; i
++) {
748 rgba
[i
][ACOMP
] = IROUND_POS(tableF
[i
] * CHAN_MAXF
);
752 const GLchan
*tableUB
= (const GLchan
*) table
->Table
;
754 for (i
= 0; i
< table
->Size
; i
++) {
758 rgba
[i
][ACOMP
] = tableUB
[i
];
763 if (table
->Type
== GL_FLOAT
) {
764 const GLfloat
*tableF
= (const GLfloat
*) table
->Table
;
766 for (i
= 0; i
< table
->Size
; i
++) {
767 rgba
[i
][RCOMP
] = IROUND_POS(tableF
[i
] * CHAN_MAXF
);
768 rgba
[i
][GCOMP
] = IROUND_POS(tableF
[i
] * CHAN_MAXF
);
769 rgba
[i
][BCOMP
] = IROUND_POS(tableF
[i
] * CHAN_MAXF
);
770 rgba
[i
][ACOMP
] = CHAN_MAX
;
774 const GLchan
*tableUB
= (const GLchan
*) table
->Table
;
776 for (i
= 0; i
< table
->Size
; i
++) {
777 rgba
[i
][RCOMP
] = tableUB
[i
];
778 rgba
[i
][GCOMP
] = tableUB
[i
];
779 rgba
[i
][BCOMP
] = tableUB
[i
];
780 rgba
[i
][ACOMP
] = CHAN_MAX
;
784 case GL_LUMINANCE_ALPHA
:
785 if (table
->Type
== GL_FLOAT
) {
786 const GLfloat
*tableF
= (const GLfloat
*) table
->Table
;
788 for (i
= 0; i
< table
->Size
; i
++) {
789 rgba
[i
][RCOMP
] = IROUND_POS(tableF
[i
*2+0] * CHAN_MAXF
);
790 rgba
[i
][GCOMP
] = IROUND_POS(tableF
[i
*2+0] * CHAN_MAXF
);
791 rgba
[i
][BCOMP
] = IROUND_POS(tableF
[i
*2+0] * CHAN_MAXF
);
792 rgba
[i
][ACOMP
] = IROUND_POS(tableF
[i
*2+1] * CHAN_MAXF
);
796 const GLchan
*tableUB
= (const GLchan
*) table
->Table
;
798 for (i
= 0; i
< table
->Size
; i
++) {
799 rgba
[i
][RCOMP
] = tableUB
[i
*2+0];
800 rgba
[i
][GCOMP
] = tableUB
[i
*2+0];
801 rgba
[i
][BCOMP
] = tableUB
[i
*2+0];
802 rgba
[i
][ACOMP
] = tableUB
[i
*2+1];
807 if (table
->Type
== GL_FLOAT
) {
808 const GLfloat
*tableF
= (const GLfloat
*) table
->Table
;
810 for (i
= 0; i
< table
->Size
; i
++) {
811 rgba
[i
][RCOMP
] = IROUND_POS(tableF
[i
] * CHAN_MAXF
);
812 rgba
[i
][GCOMP
] = IROUND_POS(tableF
[i
] * CHAN_MAXF
);
813 rgba
[i
][BCOMP
] = IROUND_POS(tableF
[i
] * CHAN_MAXF
);
814 rgba
[i
][ACOMP
] = IROUND_POS(tableF
[i
] * CHAN_MAXF
);
818 const GLchan
*tableUB
= (const GLchan
*) table
->Table
;
820 for (i
= 0; i
< table
->Size
; i
++) {
821 rgba
[i
][RCOMP
] = tableUB
[i
];
822 rgba
[i
][GCOMP
] = tableUB
[i
];
823 rgba
[i
][BCOMP
] = tableUB
[i
];
824 rgba
[i
][ACOMP
] = tableUB
[i
];
829 if (table
->Type
== GL_FLOAT
) {
830 const GLfloat
*tableF
= (const GLfloat
*) table
->Table
;
832 for (i
= 0; i
< table
->Size
; i
++) {
833 rgba
[i
][RCOMP
] = IROUND_POS(tableF
[i
*3+0] * CHAN_MAXF
);
834 rgba
[i
][GCOMP
] = IROUND_POS(tableF
[i
*3+1] * CHAN_MAXF
);
835 rgba
[i
][BCOMP
] = IROUND_POS(tableF
[i
*3+2] * CHAN_MAXF
);
836 rgba
[i
][ACOMP
] = CHAN_MAX
;
840 const GLchan
*tableUB
= (const GLchan
*) table
->Table
;
842 for (i
= 0; i
< table
->Size
; i
++) {
843 rgba
[i
][RCOMP
] = tableUB
[i
*3+0];
844 rgba
[i
][GCOMP
] = tableUB
[i
*3+1];
845 rgba
[i
][BCOMP
] = tableUB
[i
*3+2];
846 rgba
[i
][ACOMP
] = CHAN_MAX
;
851 if (table
->Type
== GL_FLOAT
) {
852 const GLfloat
*tableF
= (const GLfloat
*) table
->Table
;
854 for (i
= 0; i
< table
->Size
; i
++) {
855 rgba
[i
][RCOMP
] = IROUND_POS(tableF
[i
*4+0] * CHAN_MAXF
);
856 rgba
[i
][GCOMP
] = IROUND_POS(tableF
[i
*4+1] * CHAN_MAXF
);
857 rgba
[i
][BCOMP
] = IROUND_POS(tableF
[i
*4+2] * CHAN_MAXF
);
858 rgba
[i
][ACOMP
] = IROUND_POS(tableF
[i
*4+3] * CHAN_MAXF
);
862 const GLchan
*tableUB
= (const GLchan
*) table
->Table
;
864 for (i
= 0; i
< table
->Size
; i
++) {
865 rgba
[i
][RCOMP
] = tableUB
[i
*4+0];
866 rgba
[i
][GCOMP
] = tableUB
[i
*4+1];
867 rgba
[i
][BCOMP
] = tableUB
[i
*4+2];
868 rgba
[i
][ACOMP
] = tableUB
[i
*4+3];
873 _mesa_problem(ctx
, "bad table format in glGetColorTable");
877 _mesa_pack_rgba_span(ctx
, table
->Size
, (const GLchan (*)[4]) rgba
,
878 format
, type
, data
, &ctx
->Pack
, GL_FALSE
);
884 _mesa_ColorTableParameterfv(GLenum target
, GLenum pname
, const GLfloat
*params
)
886 GET_CURRENT_CONTEXT(ctx
);
887 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
890 case GL_COLOR_TABLE_SGI
:
891 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
892 ctx
->Pixel
.ColorTableScale
[0] = params
[0];
893 ctx
->Pixel
.ColorTableScale
[1] = params
[1];
894 ctx
->Pixel
.ColorTableScale
[2] = params
[2];
895 ctx
->Pixel
.ColorTableScale
[3] = params
[3];
897 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
898 ctx
->Pixel
.ColorTableBias
[0] = params
[0];
899 ctx
->Pixel
.ColorTableBias
[1] = params
[1];
900 ctx
->Pixel
.ColorTableBias
[2] = params
[2];
901 ctx
->Pixel
.ColorTableBias
[3] = params
[3];
904 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTableParameterfv(pname)");
908 case GL_TEXTURE_COLOR_TABLE_SGI
:
909 if (!ctx
->Extensions
.SGI_texture_color_table
) {
910 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTableParameter(target)");
913 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
914 ctx
->Pixel
.TextureColorTableScale
[0] = params
[0];
915 ctx
->Pixel
.TextureColorTableScale
[1] = params
[1];
916 ctx
->Pixel
.TextureColorTableScale
[2] = params
[2];
917 ctx
->Pixel
.TextureColorTableScale
[3] = params
[3];
919 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
920 ctx
->Pixel
.TextureColorTableBias
[0] = params
[0];
921 ctx
->Pixel
.TextureColorTableBias
[1] = params
[1];
922 ctx
->Pixel
.TextureColorTableBias
[2] = params
[2];
923 ctx
->Pixel
.TextureColorTableBias
[3] = params
[3];
926 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTableParameterfv(pname)");
930 case GL_POST_CONVOLUTION_COLOR_TABLE_SGI
:
931 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
932 ctx
->Pixel
.PCCTscale
[0] = params
[0];
933 ctx
->Pixel
.PCCTscale
[1] = params
[1];
934 ctx
->Pixel
.PCCTscale
[2] = params
[2];
935 ctx
->Pixel
.PCCTscale
[3] = params
[3];
937 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
938 ctx
->Pixel
.PCCTbias
[0] = params
[0];
939 ctx
->Pixel
.PCCTbias
[1] = params
[1];
940 ctx
->Pixel
.PCCTbias
[2] = params
[2];
941 ctx
->Pixel
.PCCTbias
[3] = params
[3];
944 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTableParameterfv(pname)");
948 case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI
:
949 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
950 ctx
->Pixel
.PCMCTscale
[0] = params
[0];
951 ctx
->Pixel
.PCMCTscale
[1] = params
[1];
952 ctx
->Pixel
.PCMCTscale
[2] = params
[2];
953 ctx
->Pixel
.PCMCTscale
[3] = params
[3];
955 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
956 ctx
->Pixel
.PCMCTbias
[0] = params
[0];
957 ctx
->Pixel
.PCMCTbias
[1] = params
[1];
958 ctx
->Pixel
.PCMCTbias
[2] = params
[2];
959 ctx
->Pixel
.PCMCTbias
[3] = params
[3];
962 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTableParameterfv(pname)");
967 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTableParameter(target)");
971 ctx
->NewState
|= _NEW_PIXEL
;
977 _mesa_ColorTableParameteriv(GLenum target
, GLenum pname
, const GLint
*params
)
980 if (pname
== GL_COLOR_TABLE_SGI
||
981 pname
== GL_TEXTURE_COLOR_TABLE_SGI
||
982 pname
== GL_POST_CONVOLUTION_COLOR_TABLE_SGI
||
983 pname
== GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI
) {
985 fparams
[0] = (GLfloat
) params
[0];
986 fparams
[1] = (GLfloat
) params
[1];
987 fparams
[2] = (GLfloat
) params
[2];
988 fparams
[3] = (GLfloat
) params
[3];
992 fparams
[0] = (GLfloat
) params
[0];
994 _mesa_ColorTableParameterfv(target
, pname
, fparams
);
1000 _mesa_GetColorTableParameterfv( GLenum target
, GLenum pname
, GLfloat
*params
)
1002 GET_CURRENT_CONTEXT(ctx
);
1003 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1004 struct gl_color_table
*table
= NULL
;
1005 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1009 table
= &texUnit
->Current1D
->Palette
;
1012 table
= &texUnit
->Current2D
->Palette
;
1015 table
= &texUnit
->Current3D
->Palette
;
1017 case GL_TEXTURE_CUBE_MAP_ARB
:
1018 if (!ctx
->Extensions
.ARB_texture_cube_map
) {
1019 _mesa_error(ctx
, GL_INVALID_ENUM
,
1020 "glGetColorTableParameterfv(target)");
1023 table
= &texUnit
->CurrentCubeMap
->Palette
;
1025 case GL_PROXY_TEXTURE_1D
:
1026 table
= &ctx
->Texture
.Proxy1D
->Palette
;
1028 case GL_PROXY_TEXTURE_2D
:
1029 table
= &ctx
->Texture
.Proxy2D
->Palette
;
1031 case GL_PROXY_TEXTURE_3D
:
1032 table
= &ctx
->Texture
.Proxy3D
->Palette
;
1034 case GL_PROXY_TEXTURE_CUBE_MAP_ARB
:
1035 if (!ctx
->Extensions
.ARB_texture_cube_map
) {
1036 _mesa_error(ctx
, GL_INVALID_ENUM
,
1037 "glGetColorTableParameterfv(target)");
1040 table
= &ctx
->Texture
.ProxyCubeMap
->Palette
;
1042 case GL_SHARED_TEXTURE_PALETTE_EXT
:
1043 table
= &ctx
->Texture
.Palette
;
1045 case GL_COLOR_TABLE
:
1046 table
= &ctx
->ColorTable
;
1047 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
1048 params
[0] = ctx
->Pixel
.ColorTableScale
[0];
1049 params
[1] = ctx
->Pixel
.ColorTableScale
[1];
1050 params
[2] = ctx
->Pixel
.ColorTableScale
[2];
1051 params
[3] = ctx
->Pixel
.ColorTableScale
[3];
1054 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
1055 params
[0] = ctx
->Pixel
.ColorTableBias
[0];
1056 params
[1] = ctx
->Pixel
.ColorTableBias
[1];
1057 params
[2] = ctx
->Pixel
.ColorTableBias
[2];
1058 params
[3] = ctx
->Pixel
.ColorTableBias
[3];
1062 case GL_PROXY_COLOR_TABLE
:
1063 table
= &ctx
->ProxyColorTable
;
1065 case GL_TEXTURE_COLOR_TABLE_SGI
:
1066 if (!ctx
->Extensions
.SGI_texture_color_table
) {
1067 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameter(target)");
1070 table
= &(texUnit
->ColorTable
);
1071 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
1072 params
[0] = ctx
->Pixel
.TextureColorTableScale
[0];
1073 params
[1] = ctx
->Pixel
.TextureColorTableScale
[1];
1074 params
[2] = ctx
->Pixel
.TextureColorTableScale
[2];
1075 params
[3] = ctx
->Pixel
.TextureColorTableScale
[3];
1078 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
1079 params
[0] = ctx
->Pixel
.TextureColorTableBias
[0];
1080 params
[1] = ctx
->Pixel
.TextureColorTableBias
[1];
1081 params
[2] = ctx
->Pixel
.TextureColorTableBias
[2];
1082 params
[3] = ctx
->Pixel
.TextureColorTableBias
[3];
1086 case GL_PROXY_TEXTURE_COLOR_TABLE_SGI
:
1087 if (!ctx
->Extensions
.SGI_texture_color_table
) {
1088 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameter(target)");
1091 table
= &(texUnit
->ProxyColorTable
);
1093 case GL_POST_CONVOLUTION_COLOR_TABLE
:
1094 table
= &ctx
->PostConvolutionColorTable
;
1095 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
1096 params
[0] = ctx
->Pixel
.PCCTscale
[0];
1097 params
[1] = ctx
->Pixel
.PCCTscale
[1];
1098 params
[2] = ctx
->Pixel
.PCCTscale
[2];
1099 params
[3] = ctx
->Pixel
.PCCTscale
[3];
1102 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
1103 params
[0] = ctx
->Pixel
.PCCTbias
[0];
1104 params
[1] = ctx
->Pixel
.PCCTbias
[1];
1105 params
[2] = ctx
->Pixel
.PCCTbias
[2];
1106 params
[3] = ctx
->Pixel
.PCCTbias
[3];
1110 case GL_PROXY_POST_CONVOLUTION_COLOR_TABLE
:
1111 table
= &ctx
->ProxyPostConvolutionColorTable
;
1113 case GL_POST_COLOR_MATRIX_COLOR_TABLE
:
1114 table
= &ctx
->PostColorMatrixColorTable
;
1115 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
1116 params
[0] = ctx
->Pixel
.PCMCTscale
[0];
1117 params
[1] = ctx
->Pixel
.PCMCTscale
[1];
1118 params
[2] = ctx
->Pixel
.PCMCTscale
[2];
1119 params
[3] = ctx
->Pixel
.PCMCTscale
[3];
1122 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
1123 params
[0] = ctx
->Pixel
.PCMCTbias
[0];
1124 params
[1] = ctx
->Pixel
.PCMCTbias
[1];
1125 params
[2] = ctx
->Pixel
.PCMCTbias
[2];
1126 params
[3] = ctx
->Pixel
.PCMCTbias
[3];
1130 case GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE
:
1131 table
= &ctx
->ProxyPostColorMatrixColorTable
;
1134 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameterfv(target)");
1141 case GL_COLOR_TABLE_FORMAT
:
1142 *params
= (GLfloat
) table
->IntFormat
;
1144 case GL_COLOR_TABLE_WIDTH
:
1145 *params
= (GLfloat
) table
->Size
;
1147 case GL_COLOR_TABLE_RED_SIZE
:
1148 *params
= (GLfloat
) table
->RedSize
;
1150 case GL_COLOR_TABLE_GREEN_SIZE
:
1151 *params
= (GLfloat
) table
->GreenSize
;
1153 case GL_COLOR_TABLE_BLUE_SIZE
:
1154 *params
= (GLfloat
) table
->BlueSize
;
1156 case GL_COLOR_TABLE_ALPHA_SIZE
:
1157 *params
= (GLfloat
) table
->AlphaSize
;
1159 case GL_COLOR_TABLE_LUMINANCE_SIZE
:
1160 *params
= (GLfloat
) table
->LuminanceSize
;
1162 case GL_COLOR_TABLE_INTENSITY_SIZE
:
1163 *params
= (GLfloat
) table
->IntensitySize
;
1166 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameterfv(pname)" );
1174 _mesa_GetColorTableParameteriv( GLenum target
, GLenum pname
, GLint
*params
)
1176 GET_CURRENT_CONTEXT(ctx
);
1177 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1178 struct gl_color_table
*table
= NULL
;
1179 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1183 table
= &texUnit
->Current1D
->Palette
;
1186 table
= &texUnit
->Current2D
->Palette
;
1189 table
= &texUnit
->Current3D
->Palette
;
1191 case GL_TEXTURE_CUBE_MAP_ARB
:
1192 if (!ctx
->Extensions
.ARB_texture_cube_map
) {
1193 _mesa_error(ctx
, GL_INVALID_ENUM
,
1194 "glGetColorTableParameteriv(target)");
1197 table
= &texUnit
->CurrentCubeMap
->Palette
;
1199 case GL_PROXY_TEXTURE_1D
:
1200 table
= &ctx
->Texture
.Proxy1D
->Palette
;
1202 case GL_PROXY_TEXTURE_2D
:
1203 table
= &ctx
->Texture
.Proxy2D
->Palette
;
1205 case GL_PROXY_TEXTURE_3D
:
1206 table
= &ctx
->Texture
.Proxy3D
->Palette
;
1208 case GL_PROXY_TEXTURE_CUBE_MAP_ARB
:
1209 if (!ctx
->Extensions
.ARB_texture_cube_map
) {
1210 _mesa_error(ctx
, GL_INVALID_ENUM
,
1211 "glGetColorTableParameteriv(target)");
1214 table
= &ctx
->Texture
.ProxyCubeMap
->Palette
;
1216 case GL_SHARED_TEXTURE_PALETTE_EXT
:
1217 table
= &ctx
->Texture
.Palette
;
1219 case GL_COLOR_TABLE
:
1220 table
= &ctx
->ColorTable
;
1221 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
1222 params
[0] = (GLint
) ctx
->Pixel
.ColorTableScale
[0];
1223 params
[1] = (GLint
) ctx
->Pixel
.ColorTableScale
[1];
1224 params
[2] = (GLint
) ctx
->Pixel
.ColorTableScale
[2];
1225 params
[3] = (GLint
) ctx
->Pixel
.ColorTableScale
[3];
1228 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
1229 params
[0] = (GLint
) ctx
->Pixel
.ColorTableBias
[0];
1230 params
[1] = (GLint
) ctx
->Pixel
.ColorTableBias
[1];
1231 params
[2] = (GLint
) ctx
->Pixel
.ColorTableBias
[2];
1232 params
[3] = (GLint
) ctx
->Pixel
.ColorTableBias
[3];
1236 case GL_PROXY_COLOR_TABLE
:
1237 table
= &ctx
->ProxyColorTable
;
1239 case GL_TEXTURE_COLOR_TABLE_SGI
:
1240 if (!ctx
->Extensions
.SGI_texture_color_table
) {
1241 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameter(target)");
1244 table
= &(texUnit
->ColorTable
);
1245 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
1246 params
[0] = (GLint
) ctx
->Pixel
.TextureColorTableScale
[0];
1247 params
[1] = (GLint
) ctx
->Pixel
.TextureColorTableScale
[1];
1248 params
[2] = (GLint
) ctx
->Pixel
.TextureColorTableScale
[2];
1249 params
[3] = (GLint
) ctx
->Pixel
.TextureColorTableScale
[3];
1252 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
1253 params
[0] = (GLint
) ctx
->Pixel
.TextureColorTableBias
[0];
1254 params
[1] = (GLint
) ctx
->Pixel
.TextureColorTableBias
[1];
1255 params
[2] = (GLint
) ctx
->Pixel
.TextureColorTableBias
[2];
1256 params
[3] = (GLint
) ctx
->Pixel
.TextureColorTableBias
[3];
1260 case GL_PROXY_TEXTURE_COLOR_TABLE_SGI
:
1261 if (!ctx
->Extensions
.SGI_texture_color_table
) {
1262 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameter(target)");
1265 table
= &(texUnit
->ProxyColorTable
);
1267 case GL_POST_CONVOLUTION_COLOR_TABLE
:
1268 table
= &ctx
->PostConvolutionColorTable
;
1269 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
1270 params
[0] = (GLint
) ctx
->Pixel
.PCCTscale
[0];
1271 params
[1] = (GLint
) ctx
->Pixel
.PCCTscale
[1];
1272 params
[2] = (GLint
) ctx
->Pixel
.PCCTscale
[2];
1273 params
[3] = (GLint
) ctx
->Pixel
.PCCTscale
[3];
1276 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
1277 params
[0] = (GLint
) ctx
->Pixel
.PCCTbias
[0];
1278 params
[1] = (GLint
) ctx
->Pixel
.PCCTbias
[1];
1279 params
[2] = (GLint
) ctx
->Pixel
.PCCTbias
[2];
1280 params
[3] = (GLint
) ctx
->Pixel
.PCCTbias
[3];
1284 case GL_PROXY_POST_CONVOLUTION_COLOR_TABLE
:
1285 table
= &ctx
->ProxyPostConvolutionColorTable
;
1287 case GL_POST_COLOR_MATRIX_COLOR_TABLE
:
1288 table
= &ctx
->PostColorMatrixColorTable
;
1289 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
1290 params
[0] = (GLint
) ctx
->Pixel
.PCMCTscale
[0];
1291 params
[1] = (GLint
) ctx
->Pixel
.PCMCTscale
[1];
1292 params
[2] = (GLint
) ctx
->Pixel
.PCMCTscale
[2];
1293 params
[3] = (GLint
) ctx
->Pixel
.PCMCTscale
[3];
1296 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
1297 params
[0] = (GLint
) ctx
->Pixel
.PCMCTbias
[0];
1298 params
[1] = (GLint
) ctx
->Pixel
.PCMCTbias
[1];
1299 params
[2] = (GLint
) ctx
->Pixel
.PCMCTbias
[2];
1300 params
[3] = (GLint
) ctx
->Pixel
.PCMCTbias
[3];
1304 case GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE
:
1305 table
= &ctx
->ProxyPostColorMatrixColorTable
;
1308 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameteriv(target)");
1315 case GL_COLOR_TABLE_FORMAT
:
1316 *params
= table
->IntFormat
;
1318 case GL_COLOR_TABLE_WIDTH
:
1319 *params
= table
->Size
;
1321 case GL_COLOR_TABLE_RED_SIZE
:
1322 *params
= table
->RedSize
;
1324 case GL_COLOR_TABLE_GREEN_SIZE
:
1325 *params
= table
->GreenSize
;
1327 case GL_COLOR_TABLE_BLUE_SIZE
:
1328 *params
= table
->BlueSize
;
1330 case GL_COLOR_TABLE_ALPHA_SIZE
:
1331 *params
= table
->AlphaSize
;
1333 case GL_COLOR_TABLE_LUMINANCE_SIZE
:
1334 *params
= table
->LuminanceSize
;
1336 case GL_COLOR_TABLE_INTENSITY_SIZE
:
1337 *params
= table
->IntensitySize
;
1340 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameteriv(pname)" );
1345 /**********************************************************************/
1346 /***** Initialization *****/
1347 /**********************************************************************/
1351 _mesa_init_colortable( struct gl_color_table
*p
)
1353 p
->Type
= CHAN_TYPE
;
1356 p
->IntFormat
= GL_RGBA
;
1362 _mesa_free_colortable_data( struct gl_color_table
*p
)
1372 * Initialize all colortables for a context.
1374 void _mesa_init_colortables( GLcontext
* ctx
)
1377 _mesa_init_colortable(&ctx
->ColorTable
);
1378 _mesa_init_colortable(&ctx
->ProxyColorTable
);
1379 _mesa_init_colortable(&ctx
->PostConvolutionColorTable
);
1380 _mesa_init_colortable(&ctx
->ProxyPostConvolutionColorTable
);
1381 _mesa_init_colortable(&ctx
->PostColorMatrixColorTable
);
1382 _mesa_init_colortable(&ctx
->ProxyPostColorMatrixColorTable
);
1387 * Free all colortable data for a context
1389 void _mesa_free_colortables_data( GLcontext
*ctx
)
1391 _mesa_free_colortable_data(&ctx
->ColorTable
);
1392 _mesa_free_colortable_data(&ctx
->ProxyColorTable
);
1393 _mesa_free_colortable_data(&ctx
->PostConvolutionColorTable
);
1394 _mesa_free_colortable_data(&ctx
->ProxyPostConvolutionColorTable
);
1395 _mesa_free_colortable_data(&ctx
->PostColorMatrixColorTable
);
1396 _mesa_free_colortable_data(&ctx
->ProxyPostColorMatrixColorTable
);