2 * Mesa 3-D graphics library
5 * Copyright (C) 1999-2007 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"
35 #include "main/dispatch.h"
38 #if FEATURE_colortable
42 * Given an internalFormat token passed to glColorTable,
43 * return the corresponding base format.
44 * Return -1 if invalid token.
47 base_colortab_format( GLenum format
)
62 case GL_LUMINANCE_ALPHA
:
63 case GL_LUMINANCE4_ALPHA4
:
64 case GL_LUMINANCE6_ALPHA2
:
65 case GL_LUMINANCE8_ALPHA8
:
66 case GL_LUMINANCE12_ALPHA4
:
67 case GL_LUMINANCE12_ALPHA12
:
68 case GL_LUMINANCE16_ALPHA16
:
69 return GL_LUMINANCE_ALPHA
;
95 return -1; /* error */
102 * Examine table's format and set the component sizes accordingly.
105 set_component_sizes( struct gl_color_table
*table
)
107 /* assuming the ubyte table */
108 const GLubyte sz
= 8;
110 switch (table
->_BaseFormat
) {
113 table
->GreenSize
= 0;
115 table
->AlphaSize
= sz
;
116 table
->IntensitySize
= 0;
117 table
->LuminanceSize
= 0;
121 table
->GreenSize
= 0;
123 table
->AlphaSize
= 0;
124 table
->IntensitySize
= 0;
125 table
->LuminanceSize
= sz
;
127 case GL_LUMINANCE_ALPHA
:
129 table
->GreenSize
= 0;
131 table
->AlphaSize
= sz
;
132 table
->IntensitySize
= 0;
133 table
->LuminanceSize
= sz
;
137 table
->GreenSize
= 0;
139 table
->AlphaSize
= 0;
140 table
->IntensitySize
= sz
;
141 table
->LuminanceSize
= 0;
145 table
->GreenSize
= sz
;
146 table
->BlueSize
= sz
;
147 table
->AlphaSize
= 0;
148 table
->IntensitySize
= 0;
149 table
->LuminanceSize
= 0;
153 table
->GreenSize
= sz
;
154 table
->BlueSize
= sz
;
155 table
->AlphaSize
= sz
;
156 table
->IntensitySize
= 0;
157 table
->LuminanceSize
= 0;
160 _mesa_problem(NULL
, "unexpected format in set_component_sizes");
167 * Update/replace all or part of a color table. Helper function
168 * used by _mesa_ColorTable() and _mesa_ColorSubTable().
169 * The table->Table buffer should already be allocated.
170 * \param start first entry to update
171 * \param count number of entries to update
172 * \param format format of user-provided table data
173 * \param type datatype of user-provided table data
174 * \param data user-provided table data
175 * \param [rgba]Scale - RGBA scale factors
176 * \param [rgba]Bias - RGBA bias factors
179 store_colortable_entries(struct gl_context
*ctx
, struct gl_color_table
*table
,
180 GLsizei start
, GLsizei count
,
181 GLenum format
, GLenum type
, const GLvoid
*data
,
182 GLfloat rScale
, GLfloat rBias
,
183 GLfloat gScale
, GLfloat gBias
,
184 GLfloat bScale
, GLfloat bBias
,
185 GLfloat aScale
, GLfloat aBias
)
187 data
= _mesa_map_validate_pbo_source(ctx
,
188 1, &ctx
->Unpack
, count
, 1, 1,
190 "glColor[Sub]Table");
195 /* convert user-provided data to GLfloat values */
196 GLfloat tempTab
[MAX_COLOR_TABLE_SIZE
* 4];
200 _mesa_unpack_color_span_float(ctx
,
201 count
, /* number of pixels */
202 table
->_BaseFormat
, /* dest format */
203 tempTab
, /* dest address */
204 format
, type
, /* src format/type */
207 IMAGE_CLAMP_BIT
); /* transfer ops */
209 /* the destination */
210 tableF
= table
->TableF
;
212 /* Apply scale & bias & clamp now */
213 switch (table
->_BaseFormat
) {
215 for (i
= 0; i
< count
; i
++) {
216 GLuint j
= start
+ i
;
217 tableF
[j
] = CLAMP(tempTab
[i
] * rScale
+ rBias
, 0.0F
, 1.0F
);
221 for (i
= 0; i
< count
; i
++) {
222 GLuint j
= start
+ i
;
223 tableF
[j
] = CLAMP(tempTab
[i
] * rScale
+ rBias
, 0.0F
, 1.0F
);
227 for (i
= 0; i
< count
; i
++) {
228 GLuint j
= start
+ i
;
229 tableF
[j
] = CLAMP(tempTab
[i
] * aScale
+ aBias
, 0.0F
, 1.0F
);
232 case GL_LUMINANCE_ALPHA
:
233 for (i
= 0; i
< count
; i
++) {
234 GLuint j
= start
+ i
;
235 tableF
[j
*2+0] = CLAMP(tempTab
[i
*2+0] * rScale
+ rBias
, 0.0F
, 1.0F
);
236 tableF
[j
*2+1] = CLAMP(tempTab
[i
*2+1] * aScale
+ aBias
, 0.0F
, 1.0F
);
240 for (i
= 0; i
< count
; i
++) {
241 GLuint j
= start
+ i
;
242 tableF
[j
*3+0] = CLAMP(tempTab
[i
*3+0] * rScale
+ rBias
, 0.0F
, 1.0F
);
243 tableF
[j
*3+1] = CLAMP(tempTab
[i
*3+1] * gScale
+ gBias
, 0.0F
, 1.0F
);
244 tableF
[j
*3+2] = CLAMP(tempTab
[i
*3+2] * bScale
+ bBias
, 0.0F
, 1.0F
);
248 for (i
= 0; i
< count
; i
++) {
249 GLuint j
= start
+ i
;
250 tableF
[j
*4+0] = CLAMP(tempTab
[i
*4+0] * rScale
+ rBias
, 0.0F
, 1.0F
);
251 tableF
[j
*4+1] = CLAMP(tempTab
[i
*4+1] * gScale
+ gBias
, 0.0F
, 1.0F
);
252 tableF
[j
*4+2] = CLAMP(tempTab
[i
*4+2] * bScale
+ bBias
, 0.0F
, 1.0F
);
253 tableF
[j
*4+3] = CLAMP(tempTab
[i
*4+3] * aScale
+ aBias
, 0.0F
, 1.0F
);
257 _mesa_problem(ctx
, "Bad format in store_colortable_entries");
262 /* update the ubyte table */
264 const GLint comps
= _mesa_components_in_format(table
->_BaseFormat
);
265 const GLfloat
*tableF
= table
->TableF
+ start
* comps
;
266 GLubyte
*tableUB
= table
->TableUB
+ start
* comps
;
268 for (i
= 0; i
< count
* comps
; i
++) {
269 CLAMPED_FLOAT_TO_UBYTE(tableUB
[i
], tableF
[i
]);
273 _mesa_unmap_pbo_source(ctx
, &ctx
->Unpack
);
279 _mesa_ColorTable( GLenum target
, GLenum internalFormat
,
280 GLsizei width
, GLenum format
, GLenum type
,
283 static const GLfloat one
[4] = { 1.0, 1.0, 1.0, 1.0 };
284 static const GLfloat zero
[4] = { 0.0, 0.0, 0.0, 0.0 };
285 GET_CURRENT_CONTEXT(ctx
);
286 struct gl_texture_unit
*texUnit
= _mesa_get_current_tex_unit(ctx
);
287 struct gl_texture_object
*texObj
= NULL
;
288 struct gl_color_table
*table
= NULL
;
289 GLboolean proxy
= GL_FALSE
;
291 const GLfloat
*scale
= one
, *bias
= zero
;
294 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
); /* too complex */
297 case GL_SHARED_TEXTURE_PALETTE_EXT
:
298 table
= &ctx
->Texture
.Palette
;
300 case GL_TEXTURE_COLOR_TABLE_SGI
:
301 if (!ctx
->Extensions
.SGI_texture_color_table
) {
302 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTable(target)");
305 table
= &(texUnit
->ColorTable
);
306 scale
= ctx
->Pixel
.TextureColorTableScale
;
307 bias
= ctx
->Pixel
.TextureColorTableBias
;
309 case GL_PROXY_TEXTURE_COLOR_TABLE_SGI
:
310 if (!ctx
->Extensions
.SGI_texture_color_table
) {
311 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTable(target)");
314 table
= &(texUnit
->ProxyColorTable
);
318 /* try texture targets */
320 struct gl_texture_object
*texobj
321 = _mesa_select_tex_object(ctx
, texUnit
, target
);
323 table
= &texobj
->Palette
;
324 proxy
= _mesa_is_proxy_texture(target
);
327 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTable(target)");
335 if (!_mesa_is_legal_format_and_type(ctx
, format
, type
) ||
336 format
== GL_INTENSITY
) {
337 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glColorTable(format or type)");
341 baseFormat
= base_colortab_format(internalFormat
);
342 if (baseFormat
< 0) {
343 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTable(internalFormat)");
347 if (width
< 0 || (width
!= 0 && !_mesa_is_pow_two(width
))) {
351 table
->InternalFormat
= (GLenum
) 0;
352 table
->_BaseFormat
= (GLenum
) 0;
355 _mesa_error(ctx
, GL_INVALID_VALUE
, "glColorTable(width=%d)", width
);
360 if (width
> (GLsizei
) ctx
->Const
.MaxColorTableSize
) {
363 table
->InternalFormat
= (GLenum
) 0;
364 table
->_BaseFormat
= (GLenum
) 0;
367 _mesa_error(ctx
, GL_TABLE_TOO_LARGE
, "glColorTable(width)");
373 table
->InternalFormat
= internalFormat
;
374 table
->_BaseFormat
= (GLenum
) baseFormat
;
376 comps
= _mesa_components_in_format(table
->_BaseFormat
);
377 assert(comps
> 0); /* error should have been caught sooner */
380 _mesa_free_colortable_data(table
);
383 table
->TableF
= (GLfloat
*) malloc(comps
* width
* sizeof(GLfloat
));
384 table
->TableUB
= (GLubyte
*) malloc(comps
* width
* sizeof(GLubyte
));
386 if (!table
->TableF
|| !table
->TableUB
) {
387 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glColorTable");
391 store_colortable_entries(ctx
, table
,
392 0, width
, /* start, count */
401 /* do this after the table's Type and Format are set */
402 set_component_sizes(table
);
404 if (texObj
|| target
== GL_SHARED_TEXTURE_PALETTE_EXT
) {
405 /* texture object palette, texObj==NULL means the shared palette */
406 if (ctx
->Driver
.UpdateTexturePalette
) {
407 (*ctx
->Driver
.UpdateTexturePalette
)( ctx
, texObj
);
411 ctx
->NewState
|= _NEW_PIXEL
;
417 _mesa_ColorSubTable( GLenum target
, GLsizei start
,
418 GLsizei count
, GLenum format
, GLenum type
,
421 static const GLfloat one
[4] = { 1.0, 1.0, 1.0, 1.0 };
422 static const GLfloat zero
[4] = { 0.0, 0.0, 0.0, 0.0 };
423 GET_CURRENT_CONTEXT(ctx
);
424 struct gl_texture_unit
*texUnit
= _mesa_get_current_tex_unit(ctx
);
425 struct gl_texture_object
*texObj
= NULL
;
426 struct gl_color_table
*table
= NULL
;
427 const GLfloat
*scale
= one
, *bias
= zero
;
429 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
432 case GL_SHARED_TEXTURE_PALETTE_EXT
:
433 table
= &ctx
->Texture
.Palette
;
435 case GL_TEXTURE_COLOR_TABLE_SGI
:
436 if (!ctx
->Extensions
.SGI_texture_color_table
) {
437 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorSubTable(target)");
440 table
= &(texUnit
->ColorTable
);
441 scale
= ctx
->Pixel
.TextureColorTableScale
;
442 bias
= ctx
->Pixel
.TextureColorTableBias
;
445 /* try texture targets */
446 texObj
= _mesa_select_tex_object(ctx
, texUnit
, target
);
447 if (texObj
&& !_mesa_is_proxy_texture(target
)) {
448 table
= &texObj
->Palette
;
451 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorSubTable(target)");
458 if (!_mesa_is_legal_format_and_type(ctx
, format
, type
) ||
459 format
== GL_INTENSITY
) {
460 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glColorSubTable(format or type)");
465 _mesa_error(ctx
, GL_INVALID_VALUE
, "glColorSubTable(count)");
469 /* error should have been caught sooner */
470 assert(_mesa_components_in_format(table
->_BaseFormat
) > 0);
472 if (start
+ count
> (GLint
) table
->Size
) {
473 _mesa_error(ctx
, GL_INVALID_VALUE
, "glColorSubTable(count)");
477 if (!table
->TableF
|| !table
->TableUB
) {
478 /* a GL_OUT_OF_MEMORY error would have been recorded previously */
482 store_colortable_entries(ctx
, table
, start
, count
,
489 if (texObj
|| target
== GL_SHARED_TEXTURE_PALETTE_EXT
) {
490 /* per-texture object palette */
491 if (ctx
->Driver
.UpdateTexturePalette
) {
492 (*ctx
->Driver
.UpdateTexturePalette
)( ctx
, texObj
);
496 ctx
->NewState
|= _NEW_PIXEL
;
501 static void GLAPIENTRY
502 _mesa_CopyColorTable(GLenum target
, GLenum internalformat
,
503 GLint x
, GLint y
, GLsizei width
)
505 GET_CURRENT_CONTEXT(ctx
);
506 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
508 if (!ctx
->ReadBuffer
->_ColorReadBuffer
) {
509 return; /* no readbuffer - OK */
512 ctx
->Driver
.CopyColorTable( ctx
, target
, internalformat
, x
, y
, width
);
517 static void GLAPIENTRY
518 _mesa_CopyColorSubTable(GLenum target
, GLsizei start
,
519 GLint x
, GLint y
, GLsizei width
)
521 GET_CURRENT_CONTEXT(ctx
);
522 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
524 if (!ctx
->ReadBuffer
->_ColorReadBuffer
) {
525 return; /* no readbuffer - OK */
528 ctx
->Driver
.CopyColorSubTable( ctx
, target
, start
, x
, y
, width
);
533 static void GLAPIENTRY
534 _mesa_GetColorTable( GLenum target
, GLenum format
,
535 GLenum type
, GLvoid
*data
)
537 GET_CURRENT_CONTEXT(ctx
);
538 struct gl_texture_unit
*texUnit
= _mesa_get_current_tex_unit(ctx
);
539 struct gl_color_table
*table
= NULL
;
540 GLfloat rgba
[MAX_COLOR_TABLE_SIZE
][4];
541 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
544 _mesa_update_state(ctx
);
548 case GL_SHARED_TEXTURE_PALETTE_EXT
:
549 table
= &ctx
->Texture
.Palette
;
551 case GL_TEXTURE_COLOR_TABLE_SGI
:
552 if (!ctx
->Extensions
.SGI_texture_color_table
) {
553 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTable(target)");
556 table
= &(texUnit
->ColorTable
);
559 /* try texture targets */
561 struct gl_texture_object
*texobj
562 = _mesa_select_tex_object(ctx
, texUnit
, target
);
563 if (texobj
&& !_mesa_is_proxy_texture(target
)) {
564 table
= &texobj
->Palette
;
567 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTable(target)");
575 if (table
->Size
<= 0) {
579 switch (table
->_BaseFormat
) {
583 for (i
= 0; i
< table
->Size
; i
++) {
587 rgba
[i
][ACOMP
] = table
->TableF
[i
];
594 for (i
= 0; i
< table
->Size
; i
++) {
597 rgba
[i
][BCOMP
] = table
->TableF
[i
];
598 rgba
[i
][ACOMP
] = 1.0F
;
602 case GL_LUMINANCE_ALPHA
:
605 for (i
= 0; i
< table
->Size
; i
++) {
608 rgba
[i
][BCOMP
] = table
->TableF
[i
*2+0];
609 rgba
[i
][ACOMP
] = table
->TableF
[i
*2+1];
616 for (i
= 0; i
< table
->Size
; i
++) {
620 rgba
[i
][ACOMP
] = table
->TableF
[i
];
627 for (i
= 0; i
< table
->Size
; i
++) {
628 rgba
[i
][RCOMP
] = table
->TableF
[i
*3+0];
629 rgba
[i
][GCOMP
] = table
->TableF
[i
*3+1];
630 rgba
[i
][BCOMP
] = table
->TableF
[i
*3+2];
631 rgba
[i
][ACOMP
] = 1.0F
;
636 memcpy(rgba
, table
->TableF
, 4 * table
->Size
* sizeof(GLfloat
));
639 _mesa_problem(ctx
, "bad table format in glGetColorTable");
643 data
= _mesa_map_validate_pbo_dest(ctx
,
644 1, &ctx
->Pack
, table
->Size
, 1, 1,
650 _mesa_pack_rgba_span_float(ctx
, table
->Size
, rgba
,
651 format
, type
, data
, &ctx
->Pack
, 0x0);
653 _mesa_unmap_pbo_dest(ctx
, &ctx
->Pack
);
658 static void GLAPIENTRY
659 _mesa_ColorTableParameterfv(GLenum target
, GLenum pname
, const GLfloat
*params
)
661 GLfloat
*scale
, *bias
;
662 GET_CURRENT_CONTEXT(ctx
);
663 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
666 case GL_TEXTURE_COLOR_TABLE_SGI
:
667 scale
= ctx
->Pixel
.TextureColorTableScale
;
668 bias
= ctx
->Pixel
.TextureColorTableBias
;
671 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTableParameter(target)");
675 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
676 COPY_4V(scale
, params
);
678 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
679 COPY_4V(bias
, params
);
682 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTableParameterfv(pname)");
686 ctx
->NewState
|= _NEW_PIXEL
;
691 static void GLAPIENTRY
692 _mesa_ColorTableParameteriv(GLenum target
, GLenum pname
, const GLint
*params
)
695 if (pname
== GL_TEXTURE_COLOR_TABLE_SGI
) {
697 fparams
[0] = (GLfloat
) params
[0];
698 fparams
[1] = (GLfloat
) params
[1];
699 fparams
[2] = (GLfloat
) params
[2];
700 fparams
[3] = (GLfloat
) params
[3];
704 fparams
[0] = (GLfloat
) params
[0];
706 _mesa_ColorTableParameterfv(target
, pname
, fparams
);
711 static void GLAPIENTRY
712 _mesa_GetColorTableParameterfv( GLenum target
, GLenum pname
, GLfloat
*params
)
714 GET_CURRENT_CONTEXT(ctx
);
715 struct gl_texture_unit
*texUnit
= _mesa_get_current_tex_unit(ctx
);
716 struct gl_color_table
*table
= NULL
;
717 ASSERT_OUTSIDE_BEGIN_END(ctx
);
720 case GL_SHARED_TEXTURE_PALETTE_EXT
:
721 table
= &ctx
->Texture
.Palette
;
723 case GL_TEXTURE_COLOR_TABLE_SGI
:
724 if (!ctx
->Extensions
.SGI_texture_color_table
) {
725 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameter(target)");
728 table
= &(texUnit
->ColorTable
);
729 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
730 COPY_4V(params
, ctx
->Pixel
.TextureColorTableScale
);
733 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
734 COPY_4V(params
, ctx
->Pixel
.TextureColorTableBias
);
738 case GL_PROXY_TEXTURE_COLOR_TABLE_SGI
:
739 if (!ctx
->Extensions
.SGI_texture_color_table
) {
740 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameter(target)");
743 table
= &(texUnit
->ProxyColorTable
);
746 /* try texture targets */
748 struct gl_texture_object
*texobj
749 = _mesa_select_tex_object(ctx
, texUnit
, target
);
751 table
= &texobj
->Palette
;
754 _mesa_error(ctx
, GL_INVALID_ENUM
,
755 "glGetColorTableParameterfv(target)");
764 case GL_COLOR_TABLE_FORMAT
:
765 *params
= (GLfloat
) table
->InternalFormat
;
767 case GL_COLOR_TABLE_WIDTH
:
768 *params
= (GLfloat
) table
->Size
;
770 case GL_COLOR_TABLE_RED_SIZE
:
771 *params
= (GLfloat
) table
->RedSize
;
773 case GL_COLOR_TABLE_GREEN_SIZE
:
774 *params
= (GLfloat
) table
->GreenSize
;
776 case GL_COLOR_TABLE_BLUE_SIZE
:
777 *params
= (GLfloat
) table
->BlueSize
;
779 case GL_COLOR_TABLE_ALPHA_SIZE
:
780 *params
= (GLfloat
) table
->AlphaSize
;
782 case GL_COLOR_TABLE_LUMINANCE_SIZE
:
783 *params
= (GLfloat
) table
->LuminanceSize
;
785 case GL_COLOR_TABLE_INTENSITY_SIZE
:
786 *params
= (GLfloat
) table
->IntensitySize
;
789 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameterfv(pname)" );
796 static void GLAPIENTRY
797 _mesa_GetColorTableParameteriv( GLenum target
, GLenum pname
, GLint
*params
)
799 GET_CURRENT_CONTEXT(ctx
);
800 struct gl_texture_unit
*texUnit
= _mesa_get_current_tex_unit(ctx
);
801 struct gl_color_table
*table
= NULL
;
802 ASSERT_OUTSIDE_BEGIN_END(ctx
);
805 case GL_SHARED_TEXTURE_PALETTE_EXT
:
806 table
= &ctx
->Texture
.Palette
;
808 case GL_TEXTURE_COLOR_TABLE_SGI
:
809 if (!ctx
->Extensions
.SGI_texture_color_table
) {
810 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameter(target)");
813 table
= &(texUnit
->ColorTable
);
814 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
815 params
[0] = (GLint
) ctx
->Pixel
.TextureColorTableScale
[0];
816 params
[1] = (GLint
) ctx
->Pixel
.TextureColorTableScale
[1];
817 params
[2] = (GLint
) ctx
->Pixel
.TextureColorTableScale
[2];
818 params
[3] = (GLint
) ctx
->Pixel
.TextureColorTableScale
[3];
821 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
822 params
[0] = (GLint
) ctx
->Pixel
.TextureColorTableBias
[0];
823 params
[1] = (GLint
) ctx
->Pixel
.TextureColorTableBias
[1];
824 params
[2] = (GLint
) ctx
->Pixel
.TextureColorTableBias
[2];
825 params
[3] = (GLint
) ctx
->Pixel
.TextureColorTableBias
[3];
829 case GL_PROXY_TEXTURE_COLOR_TABLE_SGI
:
830 if (!ctx
->Extensions
.SGI_texture_color_table
) {
831 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameter(target)");
834 table
= &(texUnit
->ProxyColorTable
);
837 /* Try texture targets */
839 struct gl_texture_object
*texobj
840 = _mesa_select_tex_object(ctx
, texUnit
, target
);
842 table
= &texobj
->Palette
;
845 _mesa_error(ctx
, GL_INVALID_ENUM
,
846 "glGetColorTableParameteriv(target)");
855 case GL_COLOR_TABLE_FORMAT
:
856 *params
= table
->InternalFormat
;
858 case GL_COLOR_TABLE_WIDTH
:
859 *params
= table
->Size
;
861 case GL_COLOR_TABLE_RED_SIZE
:
862 *params
= table
->RedSize
;
864 case GL_COLOR_TABLE_GREEN_SIZE
:
865 *params
= table
->GreenSize
;
867 case GL_COLOR_TABLE_BLUE_SIZE
:
868 *params
= table
->BlueSize
;
870 case GL_COLOR_TABLE_ALPHA_SIZE
:
871 *params
= table
->AlphaSize
;
873 case GL_COLOR_TABLE_LUMINANCE_SIZE
:
874 *params
= table
->LuminanceSize
;
876 case GL_COLOR_TABLE_INTENSITY_SIZE
:
877 *params
= table
->IntensitySize
;
880 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameteriv(pname)" );
887 _mesa_init_colortable_dispatch(struct _glapi_table
*disp
)
889 SET_ColorSubTable(disp
, _mesa_ColorSubTable
);
890 SET_ColorTable(disp
, _mesa_ColorTable
);
891 SET_ColorTableParameterfv(disp
, _mesa_ColorTableParameterfv
);
892 SET_ColorTableParameteriv(disp
, _mesa_ColorTableParameteriv
);
893 SET_CopyColorSubTable(disp
, _mesa_CopyColorSubTable
);
894 SET_CopyColorTable(disp
, _mesa_CopyColorTable
);
895 SET_GetColorTable(disp
, _mesa_GetColorTable
);
896 SET_GetColorTableParameterfv(disp
, _mesa_GetColorTableParameterfv
);
897 SET_GetColorTableParameteriv(disp
, _mesa_GetColorTableParameteriv
);
901 #endif /* FEATURE_colortable */
904 /**********************************************************************/
905 /***** Initialization *****/
906 /**********************************************************************/
910 _mesa_init_colortable( struct gl_color_table
*p
)
915 p
->InternalFormat
= GL_RGBA
;
921 _mesa_free_colortable_data( struct gl_color_table
*p
)