2 * Mesa 3-D graphics library
5 * Copyright (C) 1999-2005 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.
27 #include "bufferobj.h"
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
= 8 * sizeof(GLubyte
);
107 case GL_UNSIGNED_SHORT
:
108 sz
= 8 * sizeof(GLushort
);
111 /* Don't actually return 32 here since that causes the conformance
112 * tests to blow up. Conform thinks the component is an integer,
115 sz
= 8; /** 8 * sizeof(GLfloat); **/
118 _mesa_problem(NULL
, "bad color table type in set_component_sizes 0x%x", table
->Type
);
122 switch (table
->_BaseFormat
) {
125 table
->GreenSize
= 0;
127 table
->AlphaSize
= sz
;
128 table
->IntensitySize
= 0;
129 table
->LuminanceSize
= 0;
133 table
->GreenSize
= 0;
135 table
->AlphaSize
= 0;
136 table
->IntensitySize
= 0;
137 table
->LuminanceSize
= sz
;
139 case GL_LUMINANCE_ALPHA
:
141 table
->GreenSize
= 0;
143 table
->AlphaSize
= sz
;
144 table
->IntensitySize
= 0;
145 table
->LuminanceSize
= sz
;
149 table
->GreenSize
= 0;
151 table
->AlphaSize
= 0;
152 table
->IntensitySize
= sz
;
153 table
->LuminanceSize
= 0;
157 table
->GreenSize
= sz
;
158 table
->BlueSize
= sz
;
159 table
->AlphaSize
= 0;
160 table
->IntensitySize
= 0;
161 table
->LuminanceSize
= 0;
165 table
->GreenSize
= sz
;
166 table
->BlueSize
= sz
;
167 table
->AlphaSize
= sz
;
168 table
->IntensitySize
= 0;
169 table
->LuminanceSize
= 0;
172 _mesa_problem(NULL
, "unexpected format in set_component_sizes");
179 * Update/replace all or part of a color table. Helper function
180 * used by _mesa_ColorTable() and _mesa_ColorSubTable().
181 * The table->Table buffer should already be allocated.
182 * \param start first entry to update
183 * \param count number of entries to update
184 * \param format format of user-provided table data
185 * \param type datatype of user-provided table data
186 * \param data user-provided table data
187 * \param [rgba]Scale - RGBA scale factors
188 * \param [rgba]Bias - RGBA bias factors
191 store_colortable_entries(GLcontext
*ctx
, struct gl_color_table
*table
,
192 GLsizei start
, GLsizei count
,
193 GLenum format
, GLenum type
, const GLvoid
*data
,
194 GLfloat rScale
, GLfloat rBias
,
195 GLfloat gScale
, GLfloat gBias
,
196 GLfloat bScale
, GLfloat bBias
,
197 GLfloat aScale
, GLfloat aBias
)
199 if (ctx
->Unpack
.BufferObj
->Name
) {
200 /* Get/unpack the color table data from a PBO */
202 if (!_mesa_validate_pbo_access(1, &ctx
->Unpack
, count
, 1, 1,
203 format
, type
, data
)) {
204 _mesa_error(ctx
, GL_INVALID_OPERATION
,
205 "glColor[Sub]Table(bad PBO access)");
208 buf
= (GLubyte
*) ctx
->Driver
.MapBuffer(ctx
, GL_PIXEL_UNPACK_BUFFER_EXT
,
210 ctx
->Unpack
.BufferObj
);
212 _mesa_error(ctx
, GL_INVALID_OPERATION
,
213 "glColor[Sub]Table(PBO mapped)");
216 data
= ADD_POINTERS(buf
, data
);
220 if (table
->Type
== GL_FLOAT
) {
221 /* convert user-provided data to GLfloat values */
222 GLfloat tempTab
[MAX_COLOR_TABLE_SIZE
* 4];
226 _mesa_unpack_color_span_float(ctx
,
227 count
, /* number of pixels */
228 table
->_BaseFormat
, /* dest format */
229 tempTab
, /* dest address */
230 format
, type
, /* src format/type */
233 IMAGE_CLAMP_BIT
); /* transfer ops */
235 /* the destination */
236 tableF
= (GLfloat
*) table
->Table
;
238 /* Apply scale & bias & clamp now */
239 switch (table
->_BaseFormat
) {
241 for (i
= 0; i
< count
; i
++) {
242 GLuint j
= start
+ i
;
243 tableF
[j
] = CLAMP(tempTab
[i
] * rScale
+ rBias
, 0.0F
, 1.0F
);
247 for (i
= 0; i
< count
; i
++) {
248 GLuint j
= start
+ i
;
249 tableF
[j
] = CLAMP(tempTab
[i
] * rScale
+ rBias
, 0.0F
, 1.0F
);
253 for (i
= 0; i
< count
; i
++) {
254 GLuint j
= start
+ i
;
255 tableF
[j
] = CLAMP(tempTab
[i
] * aScale
+ aBias
, 0.0F
, 1.0F
);
258 case GL_LUMINANCE_ALPHA
:
259 for (i
= 0; i
< count
; i
++) {
260 GLuint j
= start
+ i
;
261 tableF
[j
*2+0] = CLAMP(tempTab
[i
*2+0] * rScale
+ rBias
, 0.0F
, 1.0F
);
262 tableF
[j
*2+1] = CLAMP(tempTab
[i
*2+1] * aScale
+ aBias
, 0.0F
, 1.0F
);
266 for (i
= 0; i
< count
; i
++) {
267 GLuint j
= start
+ i
;
268 tableF
[j
*3+0] = CLAMP(tempTab
[i
*3+0] * rScale
+ rBias
, 0.0F
, 1.0F
);
269 tableF
[j
*3+1] = CLAMP(tempTab
[i
*3+1] * gScale
+ gBias
, 0.0F
, 1.0F
);
270 tableF
[j
*3+2] = CLAMP(tempTab
[i
*3+2] * bScale
+ bBias
, 0.0F
, 1.0F
);
274 for (i
= 0; i
< count
; i
++) {
275 GLuint j
= start
+ i
;
276 tableF
[j
*4+0] = CLAMP(tempTab
[i
*4+0] * rScale
+ rBias
, 0.0F
, 1.0F
);
277 tableF
[j
*4+1] = CLAMP(tempTab
[i
*4+1] * gScale
+ gBias
, 0.0F
, 1.0F
);
278 tableF
[j
*4+2] = CLAMP(tempTab
[i
*4+2] * bScale
+ bBias
, 0.0F
, 1.0F
);
279 tableF
[j
*4+3] = CLAMP(tempTab
[i
*4+3] * aScale
+ aBias
, 0.0F
, 1.0F
);
283 _mesa_problem(ctx
, "Bad format in store_colortable_entries");
288 /* non-float (GLchan) */
289 const GLint comps
= _mesa_components_in_format(table
->_BaseFormat
);
290 GLchan
*dest
= (GLchan
*) table
->Table
+ start
* comps
;
291 _mesa_unpack_color_span_chan(ctx
, count
, /* number of entries */
292 table
->_BaseFormat
, /* dest format */
293 dest
, /* dest address */
294 format
, type
, data
, /* src data */
296 0); /* transfer ops */
299 if (ctx
->Unpack
.BufferObj
->Name
) {
300 ctx
->Driver
.UnmapBuffer(ctx
, GL_PIXEL_UNPACK_BUFFER_EXT
,
301 ctx
->Unpack
.BufferObj
);
308 _mesa_ColorTable( GLenum target
, GLenum internalFormat
,
309 GLsizei width
, GLenum format
, GLenum type
,
312 GET_CURRENT_CONTEXT(ctx
);
313 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
314 struct gl_texture_object
*texObj
= NULL
;
315 struct gl_color_table
*table
= NULL
;
316 GLboolean proxy
= GL_FALSE
;
318 GLfloat rScale
= 1.0, gScale
= 1.0, bScale
= 1.0, aScale
= 1.0;
319 GLfloat rBias
= 0.0, gBias
= 0.0, bBias
= 0.0, aBias
= 0.0;
320 GLenum tableType
= CHAN_TYPE
;
322 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
); /* too complex */
326 texObj
= texUnit
->Current1D
;
327 table
= &texObj
->Palette
;
330 texObj
= texUnit
->Current2D
;
331 table
= &texObj
->Palette
;
334 texObj
= texUnit
->Current3D
;
335 table
= &texObj
->Palette
;
337 case GL_TEXTURE_CUBE_MAP_ARB
:
338 if (!ctx
->Extensions
.ARB_texture_cube_map
) {
339 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTable(target)");
342 texObj
= texUnit
->CurrentCubeMap
;
343 table
= &texObj
->Palette
;
345 case GL_PROXY_TEXTURE_1D
:
346 texObj
= ctx
->Texture
.Proxy1D
;
347 table
= &texObj
->Palette
;
350 case GL_PROXY_TEXTURE_2D
:
351 texObj
= ctx
->Texture
.Proxy2D
;
352 table
= &texObj
->Palette
;
355 case GL_PROXY_TEXTURE_3D
:
356 texObj
= ctx
->Texture
.Proxy3D
;
357 table
= &texObj
->Palette
;
360 case GL_PROXY_TEXTURE_CUBE_MAP_ARB
:
361 if (!ctx
->Extensions
.ARB_texture_cube_map
) {
362 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTable(target)");
365 texObj
= ctx
->Texture
.ProxyCubeMap
;
366 table
= &texObj
->Palette
;
368 case GL_SHARED_TEXTURE_PALETTE_EXT
:
369 table
= &ctx
->Texture
.Palette
;
370 tableType
= GL_FLOAT
;
373 table
= &ctx
->ColorTable
;
374 tableType
= GL_FLOAT
;
375 rScale
= ctx
->Pixel
.ColorTableScale
[0];
376 gScale
= ctx
->Pixel
.ColorTableScale
[1];
377 bScale
= ctx
->Pixel
.ColorTableScale
[2];
378 aScale
= ctx
->Pixel
.ColorTableScale
[3];
379 rBias
= ctx
->Pixel
.ColorTableBias
[0];
380 gBias
= ctx
->Pixel
.ColorTableBias
[1];
381 bBias
= ctx
->Pixel
.ColorTableBias
[2];
382 aBias
= ctx
->Pixel
.ColorTableBias
[3];
384 case GL_PROXY_COLOR_TABLE
:
385 table
= &ctx
->ProxyColorTable
;
388 case GL_TEXTURE_COLOR_TABLE_SGI
:
389 if (!ctx
->Extensions
.SGI_texture_color_table
) {
390 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTable(target)");
393 table
= &(texUnit
->ColorTable
);
394 tableType
= GL_FLOAT
;
395 rScale
= ctx
->Pixel
.TextureColorTableScale
[0];
396 gScale
= ctx
->Pixel
.TextureColorTableScale
[1];
397 bScale
= ctx
->Pixel
.TextureColorTableScale
[2];
398 aScale
= ctx
->Pixel
.TextureColorTableScale
[3];
399 rBias
= ctx
->Pixel
.TextureColorTableBias
[0];
400 gBias
= ctx
->Pixel
.TextureColorTableBias
[1];
401 bBias
= ctx
->Pixel
.TextureColorTableBias
[2];
402 aBias
= ctx
->Pixel
.TextureColorTableBias
[3];
404 case GL_PROXY_TEXTURE_COLOR_TABLE_SGI
:
405 if (!ctx
->Extensions
.SGI_texture_color_table
) {
406 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTable(target)");
409 table
= &(texUnit
->ProxyColorTable
);
410 tableType
= GL_FLOAT
;
413 case GL_POST_CONVOLUTION_COLOR_TABLE
:
414 table
= &ctx
->PostConvolutionColorTable
;
415 tableType
= GL_FLOAT
;
416 rScale
= ctx
->Pixel
.PCCTscale
[0];
417 gScale
= ctx
->Pixel
.PCCTscale
[1];
418 bScale
= ctx
->Pixel
.PCCTscale
[2];
419 aScale
= ctx
->Pixel
.PCCTscale
[3];
420 rBias
= ctx
->Pixel
.PCCTbias
[0];
421 gBias
= ctx
->Pixel
.PCCTbias
[1];
422 bBias
= ctx
->Pixel
.PCCTbias
[2];
423 aBias
= ctx
->Pixel
.PCCTbias
[3];
425 case GL_PROXY_POST_CONVOLUTION_COLOR_TABLE
:
426 table
= &ctx
->ProxyPostConvolutionColorTable
;
427 tableType
= GL_FLOAT
;
430 case GL_POST_COLOR_MATRIX_COLOR_TABLE
:
431 table
= &ctx
->PostColorMatrixColorTable
;
432 tableType
= GL_FLOAT
;
433 rScale
= ctx
->Pixel
.PCMCTscale
[0];
434 gScale
= ctx
->Pixel
.PCMCTscale
[1];
435 bScale
= ctx
->Pixel
.PCMCTscale
[2];
436 aScale
= ctx
->Pixel
.PCMCTscale
[3];
437 rBias
= ctx
->Pixel
.PCMCTbias
[0];
438 gBias
= ctx
->Pixel
.PCMCTbias
[1];
439 bBias
= ctx
->Pixel
.PCMCTbias
[2];
440 aBias
= ctx
->Pixel
.PCMCTbias
[3];
442 case GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE
:
443 table
= &ctx
->ProxyPostColorMatrixColorTable
;
444 tableType
= GL_FLOAT
;
448 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTable(target)");
454 if (!_mesa_is_legal_format_and_type(ctx
, format
, type
) ||
455 format
== GL_INTENSITY
) {
456 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glColorTable(format or type)");
460 baseFormat
= base_colortab_format(internalFormat
);
461 if (baseFormat
< 0) {
462 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTable(internalFormat)");
466 if (width
< 0 || (width
!= 0 && _mesa_bitcount(width
) != 1)) {
470 table
->InternalFormat
= (GLenum
) 0;
471 table
->_BaseFormat
= (GLenum
) 0;
474 _mesa_error(ctx
, GL_INVALID_VALUE
, "glColorTable(width=%d)", width
);
479 if (width
> (GLsizei
) ctx
->Const
.MaxColorTableSize
) {
482 table
->InternalFormat
= (GLenum
) 0;
483 table
->_BaseFormat
= (GLenum
) 0;
486 _mesa_error(ctx
, GL_TABLE_TOO_LARGE
, "glColorTable(width)");
492 table
->InternalFormat
= internalFormat
;
493 table
->_BaseFormat
= (GLenum
) baseFormat
;
494 table
->Type
= (tableType
== GL_FLOAT
) ? GL_FLOAT
: CHAN_TYPE
;
496 comps
= _mesa_components_in_format(table
->_BaseFormat
);
497 assert(comps
> 0); /* error should have been caught sooner */
500 /* free old table, if any */
507 if (table
->Type
== GL_FLOAT
) {
508 table
->Table
= MALLOC(comps
* width
* sizeof(GLfloat
));
511 table
->Table
= MALLOC(comps
* width
* sizeof(GLchan
));
515 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glColorTable");
519 store_colortable_entries(ctx
, table
,
520 0, width
, /* start, count */
529 /* do this after the table's Type and Format are set */
530 set_component_sizes(table
);
532 if (texObj
|| target
== GL_SHARED_TEXTURE_PALETTE_EXT
) {
533 /* texture object palette, texObj==NULL means the shared palette */
534 if (ctx
->Driver
.UpdateTexturePalette
) {
535 (*ctx
->Driver
.UpdateTexturePalette
)( ctx
, texObj
);
539 ctx
->NewState
|= _NEW_PIXEL
;
545 _mesa_ColorSubTable( GLenum target
, GLsizei start
,
546 GLsizei count
, GLenum format
, GLenum type
,
549 GET_CURRENT_CONTEXT(ctx
);
550 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
551 struct gl_texture_object
*texObj
= NULL
;
552 struct gl_color_table
*table
= NULL
;
553 GLfloat rScale
= 1.0, gScale
= 1.0, bScale
= 1.0, aScale
= 1.0;
554 GLfloat rBias
= 0.0, gBias
= 0.0, bBias
= 0.0, aBias
= 0.0;
555 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
559 texObj
= texUnit
->Current1D
;
560 table
= &texObj
->Palette
;
563 texObj
= texUnit
->Current2D
;
564 table
= &texObj
->Palette
;
567 texObj
= texUnit
->Current3D
;
568 table
= &texObj
->Palette
;
570 case GL_TEXTURE_CUBE_MAP_ARB
:
571 if (!ctx
->Extensions
.ARB_texture_cube_map
) {
572 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorSubTable(target)");
575 texObj
= texUnit
->CurrentCubeMap
;
576 table
= &texObj
->Palette
;
578 case GL_SHARED_TEXTURE_PALETTE_EXT
:
579 table
= &ctx
->Texture
.Palette
;
582 table
= &ctx
->ColorTable
;
583 rScale
= ctx
->Pixel
.ColorTableScale
[0];
584 gScale
= ctx
->Pixel
.ColorTableScale
[1];
585 bScale
= ctx
->Pixel
.ColorTableScale
[2];
586 aScale
= ctx
->Pixel
.ColorTableScale
[3];
587 rBias
= ctx
->Pixel
.ColorTableBias
[0];
588 gBias
= ctx
->Pixel
.ColorTableBias
[1];
589 bBias
= ctx
->Pixel
.ColorTableBias
[2];
590 aBias
= ctx
->Pixel
.ColorTableBias
[3];
592 case GL_TEXTURE_COLOR_TABLE_SGI
:
593 if (!ctx
->Extensions
.SGI_texture_color_table
) {
594 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorSubTable(target)");
597 table
= &(texUnit
->ColorTable
);
598 rScale
= ctx
->Pixel
.TextureColorTableScale
[0];
599 gScale
= ctx
->Pixel
.TextureColorTableScale
[1];
600 bScale
= ctx
->Pixel
.TextureColorTableScale
[2];
601 aScale
= ctx
->Pixel
.TextureColorTableScale
[3];
602 rBias
= ctx
->Pixel
.TextureColorTableBias
[0];
603 gBias
= ctx
->Pixel
.TextureColorTableBias
[1];
604 bBias
= ctx
->Pixel
.TextureColorTableBias
[2];
605 aBias
= ctx
->Pixel
.TextureColorTableBias
[3];
607 case GL_POST_CONVOLUTION_COLOR_TABLE
:
608 table
= &ctx
->PostConvolutionColorTable
;
609 rScale
= ctx
->Pixel
.PCCTscale
[0];
610 gScale
= ctx
->Pixel
.PCCTscale
[1];
611 bScale
= ctx
->Pixel
.PCCTscale
[2];
612 aScale
= ctx
->Pixel
.PCCTscale
[3];
613 rBias
= ctx
->Pixel
.PCCTbias
[0];
614 gBias
= ctx
->Pixel
.PCCTbias
[1];
615 bBias
= ctx
->Pixel
.PCCTbias
[2];
616 aBias
= ctx
->Pixel
.PCCTbias
[3];
618 case GL_POST_COLOR_MATRIX_COLOR_TABLE
:
619 table
= &ctx
->PostColorMatrixColorTable
;
620 rScale
= ctx
->Pixel
.PCMCTscale
[0];
621 gScale
= ctx
->Pixel
.PCMCTscale
[1];
622 bScale
= ctx
->Pixel
.PCMCTscale
[2];
623 aScale
= ctx
->Pixel
.PCMCTscale
[3];
624 rBias
= ctx
->Pixel
.PCMCTbias
[0];
625 gBias
= ctx
->Pixel
.PCMCTbias
[1];
626 bBias
= ctx
->Pixel
.PCMCTbias
[2];
627 aBias
= ctx
->Pixel
.PCMCTbias
[3];
630 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorSubTable(target)");
636 if (!_mesa_is_legal_format_and_type(ctx
, format
, type
) ||
637 format
== GL_INTENSITY
) {
638 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glColorSubTable(format or type)");
643 _mesa_error(ctx
, GL_INVALID_VALUE
, "glColorSubTable(count)");
647 /* error should have been caught sooner */
648 assert(_mesa_components_in_format(table
->_BaseFormat
) > 0);
650 if (start
+ count
> (GLint
) table
->Size
) {
651 _mesa_error(ctx
, GL_INVALID_VALUE
, "glColorSubTable(count)");
656 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glColorSubTable");
660 store_colortable_entries(ctx
, table
, start
, count
,
667 if (texObj
|| target
== GL_SHARED_TEXTURE_PALETTE_EXT
) {
668 /* per-texture object palette */
669 if (ctx
->Driver
.UpdateTexturePalette
) {
670 (*ctx
->Driver
.UpdateTexturePalette
)( ctx
, texObj
);
674 ctx
->NewState
|= _NEW_PIXEL
;
680 _mesa_CopyColorTable(GLenum target
, GLenum internalformat
,
681 GLint x
, GLint y
, GLsizei width
)
683 GET_CURRENT_CONTEXT(ctx
);
684 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
686 /* Select buffer to read from */
687 ctx
->Driver
.CopyColorTable( ctx
, target
, internalformat
, x
, y
, width
);
693 _mesa_CopyColorSubTable(GLenum target
, GLsizei start
,
694 GLint x
, GLint y
, GLsizei width
)
696 GET_CURRENT_CONTEXT(ctx
);
697 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
699 ctx
->Driver
.CopyColorSubTable( ctx
, target
, start
, x
, y
, width
);
705 _mesa_GetColorTable( GLenum target
, GLenum format
,
706 GLenum type
, GLvoid
*data
)
708 GET_CURRENT_CONTEXT(ctx
);
709 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
710 struct gl_color_table
*table
= NULL
;
711 GLchan rgba
[MAX_COLOR_TABLE_SIZE
][4];
712 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
715 _mesa_update_state(ctx
);
720 table
= &texUnit
->Current1D
->Palette
;
723 table
= &texUnit
->Current2D
->Palette
;
726 table
= &texUnit
->Current3D
->Palette
;
728 case GL_TEXTURE_CUBE_MAP_ARB
:
729 if (!ctx
->Extensions
.ARB_texture_cube_map
) {
730 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTable(target)");
733 table
= &texUnit
->CurrentCubeMap
->Palette
;
735 case GL_SHARED_TEXTURE_PALETTE_EXT
:
736 table
= &ctx
->Texture
.Palette
;
739 table
= &ctx
->ColorTable
;
741 case GL_TEXTURE_COLOR_TABLE_SGI
:
742 if (!ctx
->Extensions
.SGI_texture_color_table
) {
743 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTable(target)");
746 table
= &(texUnit
->ColorTable
);
748 case GL_POST_CONVOLUTION_COLOR_TABLE
:
749 table
= &ctx
->PostConvolutionColorTable
;
751 case GL_POST_COLOR_MATRIX_COLOR_TABLE
:
752 table
= &ctx
->PostColorMatrixColorTable
;
755 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTable(target)");
761 switch (table
->_BaseFormat
) {
763 if (table
->Type
== GL_FLOAT
) {
764 const GLfloat
*tableF
= (const GLfloat
*) table
->Table
;
766 for (i
= 0; i
< table
->Size
; i
++) {
770 rgba
[i
][ACOMP
] = IROUND_POS(tableF
[i
] * CHAN_MAXF
);
774 const GLchan
*tableUB
= (const GLchan
*) table
->Table
;
776 for (i
= 0; i
< table
->Size
; i
++) {
780 rgba
[i
][ACOMP
] = tableUB
[i
];
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
] * CHAN_MAXF
);
790 rgba
[i
][GCOMP
] = IROUND_POS(tableF
[i
] * CHAN_MAXF
);
791 rgba
[i
][BCOMP
] = IROUND_POS(tableF
[i
] * CHAN_MAXF
);
792 rgba
[i
][ACOMP
] = CHAN_MAX
;
796 const GLchan
*tableUB
= (const GLchan
*) table
->Table
;
798 for (i
= 0; i
< table
->Size
; i
++) {
799 rgba
[i
][RCOMP
] = tableUB
[i
];
800 rgba
[i
][GCOMP
] = tableUB
[i
];
801 rgba
[i
][BCOMP
] = tableUB
[i
];
802 rgba
[i
][ACOMP
] = CHAN_MAX
;
806 case GL_LUMINANCE_ALPHA
:
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
*2+0] * CHAN_MAXF
);
812 rgba
[i
][GCOMP
] = IROUND_POS(tableF
[i
*2+0] * CHAN_MAXF
);
813 rgba
[i
][BCOMP
] = IROUND_POS(tableF
[i
*2+0] * CHAN_MAXF
);
814 rgba
[i
][ACOMP
] = IROUND_POS(tableF
[i
*2+1] * CHAN_MAXF
);
818 const GLchan
*tableUB
= (const GLchan
*) table
->Table
;
820 for (i
= 0; i
< table
->Size
; i
++) {
821 rgba
[i
][RCOMP
] = tableUB
[i
*2+0];
822 rgba
[i
][GCOMP
] = tableUB
[i
*2+0];
823 rgba
[i
][BCOMP
] = tableUB
[i
*2+0];
824 rgba
[i
][ACOMP
] = tableUB
[i
*2+1];
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
] * CHAN_MAXF
);
834 rgba
[i
][GCOMP
] = IROUND_POS(tableF
[i
] * CHAN_MAXF
);
835 rgba
[i
][BCOMP
] = IROUND_POS(tableF
[i
] * CHAN_MAXF
);
836 rgba
[i
][ACOMP
] = IROUND_POS(tableF
[i
] * CHAN_MAXF
);
840 const GLchan
*tableUB
= (const GLchan
*) table
->Table
;
842 for (i
= 0; i
< table
->Size
; i
++) {
843 rgba
[i
][RCOMP
] = tableUB
[i
];
844 rgba
[i
][GCOMP
] = tableUB
[i
];
845 rgba
[i
][BCOMP
] = tableUB
[i
];
846 rgba
[i
][ACOMP
] = tableUB
[i
];
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
*3+0] * CHAN_MAXF
);
856 rgba
[i
][GCOMP
] = IROUND_POS(tableF
[i
*3+1] * CHAN_MAXF
);
857 rgba
[i
][BCOMP
] = IROUND_POS(tableF
[i
*3+2] * CHAN_MAXF
);
858 rgba
[i
][ACOMP
] = CHAN_MAX
;
862 const GLchan
*tableUB
= (const GLchan
*) table
->Table
;
864 for (i
= 0; i
< table
->Size
; i
++) {
865 rgba
[i
][RCOMP
] = tableUB
[i
*3+0];
866 rgba
[i
][GCOMP
] = tableUB
[i
*3+1];
867 rgba
[i
][BCOMP
] = tableUB
[i
*3+2];
868 rgba
[i
][ACOMP
] = CHAN_MAX
;
873 if (table
->Type
== GL_FLOAT
) {
874 const GLfloat
*tableF
= (const GLfloat
*) table
->Table
;
876 for (i
= 0; i
< table
->Size
; i
++) {
877 rgba
[i
][RCOMP
] = IROUND_POS(tableF
[i
*4+0] * CHAN_MAXF
);
878 rgba
[i
][GCOMP
] = IROUND_POS(tableF
[i
*4+1] * CHAN_MAXF
);
879 rgba
[i
][BCOMP
] = IROUND_POS(tableF
[i
*4+2] * CHAN_MAXF
);
880 rgba
[i
][ACOMP
] = IROUND_POS(tableF
[i
*4+3] * CHAN_MAXF
);
884 const GLchan
*tableUB
= (const GLchan
*) table
->Table
;
886 for (i
= 0; i
< table
->Size
; i
++) {
887 rgba
[i
][RCOMP
] = tableUB
[i
*4+0];
888 rgba
[i
][GCOMP
] = tableUB
[i
*4+1];
889 rgba
[i
][BCOMP
] = tableUB
[i
*4+2];
890 rgba
[i
][ACOMP
] = tableUB
[i
*4+3];
895 _mesa_problem(ctx
, "bad table format in glGetColorTable");
899 if (ctx
->Pack
.BufferObj
->Name
) {
900 /* pack color table into PBO */
902 if (!_mesa_validate_pbo_access(1, &ctx
->Pack
, table
->Size
, 1, 1,
903 format
, type
, data
)) {
904 _mesa_error(ctx
, GL_INVALID_OPERATION
,
905 "glGetColorTable(invalid PBO access)");
908 buf
= (GLubyte
*) ctx
->Driver
.MapBuffer(ctx
, GL_PIXEL_PACK_BUFFER_EXT
,
910 ctx
->Pack
.BufferObj
);
912 /* buffer is already mapped - that's an error */
913 _mesa_error(ctx
, GL_INVALID_OPERATION
,
914 "glGetColorTable(PBO is mapped)");
917 data
= ADD_POINTERS(buf
, data
);
920 _mesa_pack_rgba_span_chan(ctx
, table
->Size
, (const GLchan (*)[4]) rgba
,
921 format
, type
, data
, &ctx
->Pack
, GL_FALSE
);
923 if (ctx
->Pack
.BufferObj
->Name
) {
924 ctx
->Driver
.UnmapBuffer(ctx
, GL_PIXEL_PACK_BUFFER_EXT
,
925 ctx
->Pack
.BufferObj
);
932 _mesa_ColorTableParameterfv(GLenum target
, GLenum pname
, const GLfloat
*params
)
934 GET_CURRENT_CONTEXT(ctx
);
935 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
938 case GL_COLOR_TABLE_SGI
:
939 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
940 ctx
->Pixel
.ColorTableScale
[0] = params
[0];
941 ctx
->Pixel
.ColorTableScale
[1] = params
[1];
942 ctx
->Pixel
.ColorTableScale
[2] = params
[2];
943 ctx
->Pixel
.ColorTableScale
[3] = params
[3];
945 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
946 ctx
->Pixel
.ColorTableBias
[0] = params
[0];
947 ctx
->Pixel
.ColorTableBias
[1] = params
[1];
948 ctx
->Pixel
.ColorTableBias
[2] = params
[2];
949 ctx
->Pixel
.ColorTableBias
[3] = params
[3];
952 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTableParameterfv(pname)");
956 case GL_TEXTURE_COLOR_TABLE_SGI
:
957 if (!ctx
->Extensions
.SGI_texture_color_table
) {
958 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTableParameter(target)");
961 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
962 ctx
->Pixel
.TextureColorTableScale
[0] = params
[0];
963 ctx
->Pixel
.TextureColorTableScale
[1] = params
[1];
964 ctx
->Pixel
.TextureColorTableScale
[2] = params
[2];
965 ctx
->Pixel
.TextureColorTableScale
[3] = params
[3];
967 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
968 ctx
->Pixel
.TextureColorTableBias
[0] = params
[0];
969 ctx
->Pixel
.TextureColorTableBias
[1] = params
[1];
970 ctx
->Pixel
.TextureColorTableBias
[2] = params
[2];
971 ctx
->Pixel
.TextureColorTableBias
[3] = params
[3];
974 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTableParameterfv(pname)");
978 case GL_POST_CONVOLUTION_COLOR_TABLE_SGI
:
979 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
980 ctx
->Pixel
.PCCTscale
[0] = params
[0];
981 ctx
->Pixel
.PCCTscale
[1] = params
[1];
982 ctx
->Pixel
.PCCTscale
[2] = params
[2];
983 ctx
->Pixel
.PCCTscale
[3] = params
[3];
985 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
986 ctx
->Pixel
.PCCTbias
[0] = params
[0];
987 ctx
->Pixel
.PCCTbias
[1] = params
[1];
988 ctx
->Pixel
.PCCTbias
[2] = params
[2];
989 ctx
->Pixel
.PCCTbias
[3] = params
[3];
992 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTableParameterfv(pname)");
996 case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI
:
997 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
998 ctx
->Pixel
.PCMCTscale
[0] = params
[0];
999 ctx
->Pixel
.PCMCTscale
[1] = params
[1];
1000 ctx
->Pixel
.PCMCTscale
[2] = params
[2];
1001 ctx
->Pixel
.PCMCTscale
[3] = params
[3];
1003 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
1004 ctx
->Pixel
.PCMCTbias
[0] = params
[0];
1005 ctx
->Pixel
.PCMCTbias
[1] = params
[1];
1006 ctx
->Pixel
.PCMCTbias
[2] = params
[2];
1007 ctx
->Pixel
.PCMCTbias
[3] = params
[3];
1010 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTableParameterfv(pname)");
1015 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTableParameter(target)");
1019 ctx
->NewState
|= _NEW_PIXEL
;
1025 _mesa_ColorTableParameteriv(GLenum target
, GLenum pname
, const GLint
*params
)
1028 if (pname
== GL_COLOR_TABLE_SGI
||
1029 pname
== GL_TEXTURE_COLOR_TABLE_SGI
||
1030 pname
== GL_POST_CONVOLUTION_COLOR_TABLE_SGI
||
1031 pname
== GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI
) {
1033 fparams
[0] = (GLfloat
) params
[0];
1034 fparams
[1] = (GLfloat
) params
[1];
1035 fparams
[2] = (GLfloat
) params
[2];
1036 fparams
[3] = (GLfloat
) params
[3];
1040 fparams
[0] = (GLfloat
) params
[0];
1042 _mesa_ColorTableParameterfv(target
, pname
, fparams
);
1048 _mesa_GetColorTableParameterfv( GLenum target
, GLenum pname
, GLfloat
*params
)
1050 GET_CURRENT_CONTEXT(ctx
);
1051 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1052 struct gl_color_table
*table
= NULL
;
1053 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1057 table
= &texUnit
->Current1D
->Palette
;
1060 table
= &texUnit
->Current2D
->Palette
;
1063 table
= &texUnit
->Current3D
->Palette
;
1065 case GL_TEXTURE_CUBE_MAP_ARB
:
1066 if (!ctx
->Extensions
.ARB_texture_cube_map
) {
1067 _mesa_error(ctx
, GL_INVALID_ENUM
,
1068 "glGetColorTableParameterfv(target)");
1071 table
= &texUnit
->CurrentCubeMap
->Palette
;
1073 case GL_PROXY_TEXTURE_1D
:
1074 table
= &ctx
->Texture
.Proxy1D
->Palette
;
1076 case GL_PROXY_TEXTURE_2D
:
1077 table
= &ctx
->Texture
.Proxy2D
->Palette
;
1079 case GL_PROXY_TEXTURE_3D
:
1080 table
= &ctx
->Texture
.Proxy3D
->Palette
;
1082 case GL_PROXY_TEXTURE_CUBE_MAP_ARB
:
1083 if (!ctx
->Extensions
.ARB_texture_cube_map
) {
1084 _mesa_error(ctx
, GL_INVALID_ENUM
,
1085 "glGetColorTableParameterfv(target)");
1088 table
= &ctx
->Texture
.ProxyCubeMap
->Palette
;
1090 case GL_SHARED_TEXTURE_PALETTE_EXT
:
1091 table
= &ctx
->Texture
.Palette
;
1093 case GL_COLOR_TABLE
:
1094 table
= &ctx
->ColorTable
;
1095 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
1096 params
[0] = ctx
->Pixel
.ColorTableScale
[0];
1097 params
[1] = ctx
->Pixel
.ColorTableScale
[1];
1098 params
[2] = ctx
->Pixel
.ColorTableScale
[2];
1099 params
[3] = ctx
->Pixel
.ColorTableScale
[3];
1102 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
1103 params
[0] = ctx
->Pixel
.ColorTableBias
[0];
1104 params
[1] = ctx
->Pixel
.ColorTableBias
[1];
1105 params
[2] = ctx
->Pixel
.ColorTableBias
[2];
1106 params
[3] = ctx
->Pixel
.ColorTableBias
[3];
1110 case GL_PROXY_COLOR_TABLE
:
1111 table
= &ctx
->ProxyColorTable
;
1113 case GL_TEXTURE_COLOR_TABLE_SGI
:
1114 if (!ctx
->Extensions
.SGI_texture_color_table
) {
1115 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameter(target)");
1118 table
= &(texUnit
->ColorTable
);
1119 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
1120 params
[0] = ctx
->Pixel
.TextureColorTableScale
[0];
1121 params
[1] = ctx
->Pixel
.TextureColorTableScale
[1];
1122 params
[2] = ctx
->Pixel
.TextureColorTableScale
[2];
1123 params
[3] = ctx
->Pixel
.TextureColorTableScale
[3];
1126 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
1127 params
[0] = ctx
->Pixel
.TextureColorTableBias
[0];
1128 params
[1] = ctx
->Pixel
.TextureColorTableBias
[1];
1129 params
[2] = ctx
->Pixel
.TextureColorTableBias
[2];
1130 params
[3] = ctx
->Pixel
.TextureColorTableBias
[3];
1134 case GL_PROXY_TEXTURE_COLOR_TABLE_SGI
:
1135 if (!ctx
->Extensions
.SGI_texture_color_table
) {
1136 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameter(target)");
1139 table
= &(texUnit
->ProxyColorTable
);
1141 case GL_POST_CONVOLUTION_COLOR_TABLE
:
1142 table
= &ctx
->PostConvolutionColorTable
;
1143 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
1144 params
[0] = ctx
->Pixel
.PCCTscale
[0];
1145 params
[1] = ctx
->Pixel
.PCCTscale
[1];
1146 params
[2] = ctx
->Pixel
.PCCTscale
[2];
1147 params
[3] = ctx
->Pixel
.PCCTscale
[3];
1150 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
1151 params
[0] = ctx
->Pixel
.PCCTbias
[0];
1152 params
[1] = ctx
->Pixel
.PCCTbias
[1];
1153 params
[2] = ctx
->Pixel
.PCCTbias
[2];
1154 params
[3] = ctx
->Pixel
.PCCTbias
[3];
1158 case GL_PROXY_POST_CONVOLUTION_COLOR_TABLE
:
1159 table
= &ctx
->ProxyPostConvolutionColorTable
;
1161 case GL_POST_COLOR_MATRIX_COLOR_TABLE
:
1162 table
= &ctx
->PostColorMatrixColorTable
;
1163 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
1164 params
[0] = ctx
->Pixel
.PCMCTscale
[0];
1165 params
[1] = ctx
->Pixel
.PCMCTscale
[1];
1166 params
[2] = ctx
->Pixel
.PCMCTscale
[2];
1167 params
[3] = ctx
->Pixel
.PCMCTscale
[3];
1170 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
1171 params
[0] = ctx
->Pixel
.PCMCTbias
[0];
1172 params
[1] = ctx
->Pixel
.PCMCTbias
[1];
1173 params
[2] = ctx
->Pixel
.PCMCTbias
[2];
1174 params
[3] = ctx
->Pixel
.PCMCTbias
[3];
1178 case GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE
:
1179 table
= &ctx
->ProxyPostColorMatrixColorTable
;
1182 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameterfv(target)");
1189 case GL_COLOR_TABLE_FORMAT
:
1190 *params
= (GLfloat
) table
->InternalFormat
;
1192 case GL_COLOR_TABLE_WIDTH
:
1193 *params
= (GLfloat
) table
->Size
;
1195 case GL_COLOR_TABLE_RED_SIZE
:
1196 *params
= (GLfloat
) table
->RedSize
;
1198 case GL_COLOR_TABLE_GREEN_SIZE
:
1199 *params
= (GLfloat
) table
->GreenSize
;
1201 case GL_COLOR_TABLE_BLUE_SIZE
:
1202 *params
= (GLfloat
) table
->BlueSize
;
1204 case GL_COLOR_TABLE_ALPHA_SIZE
:
1205 *params
= (GLfloat
) table
->AlphaSize
;
1207 case GL_COLOR_TABLE_LUMINANCE_SIZE
:
1208 *params
= (GLfloat
) table
->LuminanceSize
;
1210 case GL_COLOR_TABLE_INTENSITY_SIZE
:
1211 *params
= (GLfloat
) table
->IntensitySize
;
1214 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameterfv(pname)" );
1222 _mesa_GetColorTableParameteriv( GLenum target
, GLenum pname
, GLint
*params
)
1224 GET_CURRENT_CONTEXT(ctx
);
1225 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1226 struct gl_color_table
*table
= NULL
;
1227 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1231 table
= &texUnit
->Current1D
->Palette
;
1234 table
= &texUnit
->Current2D
->Palette
;
1237 table
= &texUnit
->Current3D
->Palette
;
1239 case GL_TEXTURE_CUBE_MAP_ARB
:
1240 if (!ctx
->Extensions
.ARB_texture_cube_map
) {
1241 _mesa_error(ctx
, GL_INVALID_ENUM
,
1242 "glGetColorTableParameteriv(target)");
1245 table
= &texUnit
->CurrentCubeMap
->Palette
;
1247 case GL_PROXY_TEXTURE_1D
:
1248 table
= &ctx
->Texture
.Proxy1D
->Palette
;
1250 case GL_PROXY_TEXTURE_2D
:
1251 table
= &ctx
->Texture
.Proxy2D
->Palette
;
1253 case GL_PROXY_TEXTURE_3D
:
1254 table
= &ctx
->Texture
.Proxy3D
->Palette
;
1256 case GL_PROXY_TEXTURE_CUBE_MAP_ARB
:
1257 if (!ctx
->Extensions
.ARB_texture_cube_map
) {
1258 _mesa_error(ctx
, GL_INVALID_ENUM
,
1259 "glGetColorTableParameteriv(target)");
1262 table
= &ctx
->Texture
.ProxyCubeMap
->Palette
;
1264 case GL_SHARED_TEXTURE_PALETTE_EXT
:
1265 table
= &ctx
->Texture
.Palette
;
1267 case GL_COLOR_TABLE
:
1268 table
= &ctx
->ColorTable
;
1269 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
1270 params
[0] = (GLint
) ctx
->Pixel
.ColorTableScale
[0];
1271 params
[1] = (GLint
) ctx
->Pixel
.ColorTableScale
[1];
1272 params
[2] = (GLint
) ctx
->Pixel
.ColorTableScale
[2];
1273 params
[3] = (GLint
) ctx
->Pixel
.ColorTableScale
[3];
1276 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
1277 params
[0] = (GLint
) ctx
->Pixel
.ColorTableBias
[0];
1278 params
[1] = (GLint
) ctx
->Pixel
.ColorTableBias
[1];
1279 params
[2] = (GLint
) ctx
->Pixel
.ColorTableBias
[2];
1280 params
[3] = (GLint
) ctx
->Pixel
.ColorTableBias
[3];
1284 case GL_PROXY_COLOR_TABLE
:
1285 table
= &ctx
->ProxyColorTable
;
1287 case GL_TEXTURE_COLOR_TABLE_SGI
:
1288 if (!ctx
->Extensions
.SGI_texture_color_table
) {
1289 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameter(target)");
1292 table
= &(texUnit
->ColorTable
);
1293 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
1294 params
[0] = (GLint
) ctx
->Pixel
.TextureColorTableScale
[0];
1295 params
[1] = (GLint
) ctx
->Pixel
.TextureColorTableScale
[1];
1296 params
[2] = (GLint
) ctx
->Pixel
.TextureColorTableScale
[2];
1297 params
[3] = (GLint
) ctx
->Pixel
.TextureColorTableScale
[3];
1300 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
1301 params
[0] = (GLint
) ctx
->Pixel
.TextureColorTableBias
[0];
1302 params
[1] = (GLint
) ctx
->Pixel
.TextureColorTableBias
[1];
1303 params
[2] = (GLint
) ctx
->Pixel
.TextureColorTableBias
[2];
1304 params
[3] = (GLint
) ctx
->Pixel
.TextureColorTableBias
[3];
1308 case GL_PROXY_TEXTURE_COLOR_TABLE_SGI
:
1309 if (!ctx
->Extensions
.SGI_texture_color_table
) {
1310 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameter(target)");
1313 table
= &(texUnit
->ProxyColorTable
);
1315 case GL_POST_CONVOLUTION_COLOR_TABLE
:
1316 table
= &ctx
->PostConvolutionColorTable
;
1317 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
1318 params
[0] = (GLint
) ctx
->Pixel
.PCCTscale
[0];
1319 params
[1] = (GLint
) ctx
->Pixel
.PCCTscale
[1];
1320 params
[2] = (GLint
) ctx
->Pixel
.PCCTscale
[2];
1321 params
[3] = (GLint
) ctx
->Pixel
.PCCTscale
[3];
1324 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
1325 params
[0] = (GLint
) ctx
->Pixel
.PCCTbias
[0];
1326 params
[1] = (GLint
) ctx
->Pixel
.PCCTbias
[1];
1327 params
[2] = (GLint
) ctx
->Pixel
.PCCTbias
[2];
1328 params
[3] = (GLint
) ctx
->Pixel
.PCCTbias
[3];
1332 case GL_PROXY_POST_CONVOLUTION_COLOR_TABLE
:
1333 table
= &ctx
->ProxyPostConvolutionColorTable
;
1335 case GL_POST_COLOR_MATRIX_COLOR_TABLE
:
1336 table
= &ctx
->PostColorMatrixColorTable
;
1337 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
1338 params
[0] = (GLint
) ctx
->Pixel
.PCMCTscale
[0];
1339 params
[1] = (GLint
) ctx
->Pixel
.PCMCTscale
[1];
1340 params
[2] = (GLint
) ctx
->Pixel
.PCMCTscale
[2];
1341 params
[3] = (GLint
) ctx
->Pixel
.PCMCTscale
[3];
1344 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
1345 params
[0] = (GLint
) ctx
->Pixel
.PCMCTbias
[0];
1346 params
[1] = (GLint
) ctx
->Pixel
.PCMCTbias
[1];
1347 params
[2] = (GLint
) ctx
->Pixel
.PCMCTbias
[2];
1348 params
[3] = (GLint
) ctx
->Pixel
.PCMCTbias
[3];
1352 case GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE
:
1353 table
= &ctx
->ProxyPostColorMatrixColorTable
;
1356 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameteriv(target)");
1363 case GL_COLOR_TABLE_FORMAT
:
1364 *params
= table
->InternalFormat
;
1366 case GL_COLOR_TABLE_WIDTH
:
1367 *params
= table
->Size
;
1369 case GL_COLOR_TABLE_RED_SIZE
:
1370 *params
= table
->RedSize
;
1372 case GL_COLOR_TABLE_GREEN_SIZE
:
1373 *params
= table
->GreenSize
;
1375 case GL_COLOR_TABLE_BLUE_SIZE
:
1376 *params
= table
->BlueSize
;
1378 case GL_COLOR_TABLE_ALPHA_SIZE
:
1379 *params
= table
->AlphaSize
;
1381 case GL_COLOR_TABLE_LUMINANCE_SIZE
:
1382 *params
= table
->LuminanceSize
;
1384 case GL_COLOR_TABLE_INTENSITY_SIZE
:
1385 *params
= table
->IntensitySize
;
1388 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameteriv(pname)" );
1393 /**********************************************************************/
1394 /***** Initialization *****/
1395 /**********************************************************************/
1399 _mesa_init_colortable( struct gl_color_table
*p
)
1401 p
->Type
= CHAN_TYPE
;
1404 p
->InternalFormat
= GL_RGBA
;
1410 _mesa_free_colortable_data( struct gl_color_table
*p
)
1420 * Initialize all colortables for a context.
1422 void _mesa_init_colortables( GLcontext
* ctx
)
1425 _mesa_init_colortable(&ctx
->ColorTable
);
1426 _mesa_init_colortable(&ctx
->ProxyColorTable
);
1427 _mesa_init_colortable(&ctx
->PostConvolutionColorTable
);
1428 _mesa_init_colortable(&ctx
->ProxyPostConvolutionColorTable
);
1429 _mesa_init_colortable(&ctx
->PostColorMatrixColorTable
);
1430 _mesa_init_colortable(&ctx
->ProxyPostColorMatrixColorTable
);
1435 * Free all colortable data for a context
1437 void _mesa_free_colortables_data( GLcontext
*ctx
)
1439 _mesa_free_colortable_data(&ctx
->ColorTable
);
1440 _mesa_free_colortable_data(&ctx
->ProxyColorTable
);
1441 _mesa_free_colortable_data(&ctx
->PostConvolutionColorTable
);
1442 _mesa_free_colortable_data(&ctx
->ProxyPostConvolutionColorTable
);
1443 _mesa_free_colortable_data(&ctx
->PostColorMatrixColorTable
);
1444 _mesa_free_colortable_data(&ctx
->ProxyPostColorMatrixColorTable
);