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"
36 #include "main/dispatch.h"
39 #if FEATURE_colortable
43 * Given an internalFormat token passed to glColorTable,
44 * return the corresponding base format.
45 * Return -1 if invalid token.
48 base_colortab_format( GLenum format
)
63 case GL_LUMINANCE_ALPHA
:
64 case GL_LUMINANCE4_ALPHA4
:
65 case GL_LUMINANCE6_ALPHA2
:
66 case GL_LUMINANCE8_ALPHA8
:
67 case GL_LUMINANCE12_ALPHA4
:
68 case GL_LUMINANCE12_ALPHA12
:
69 case GL_LUMINANCE16_ALPHA16
:
70 return GL_LUMINANCE_ALPHA
;
96 return -1; /* error */
103 * Examine table's format and set the component sizes accordingly.
106 set_component_sizes( struct gl_color_table
*table
)
108 /* assuming the ubyte table */
109 const GLubyte sz
= 8;
111 switch (table
->_BaseFormat
) {
114 table
->GreenSize
= 0;
116 table
->AlphaSize
= sz
;
117 table
->IntensitySize
= 0;
118 table
->LuminanceSize
= 0;
122 table
->GreenSize
= 0;
124 table
->AlphaSize
= 0;
125 table
->IntensitySize
= 0;
126 table
->LuminanceSize
= sz
;
128 case GL_LUMINANCE_ALPHA
:
130 table
->GreenSize
= 0;
132 table
->AlphaSize
= sz
;
133 table
->IntensitySize
= 0;
134 table
->LuminanceSize
= sz
;
138 table
->GreenSize
= 0;
140 table
->AlphaSize
= 0;
141 table
->IntensitySize
= sz
;
142 table
->LuminanceSize
= 0;
146 table
->GreenSize
= sz
;
147 table
->BlueSize
= sz
;
148 table
->AlphaSize
= 0;
149 table
->IntensitySize
= 0;
150 table
->LuminanceSize
= 0;
154 table
->GreenSize
= sz
;
155 table
->BlueSize
= sz
;
156 table
->AlphaSize
= sz
;
157 table
->IntensitySize
= 0;
158 table
->LuminanceSize
= 0;
161 _mesa_problem(NULL
, "unexpected format in set_component_sizes");
168 * Update/replace all or part of a color table. Helper function
169 * used by _mesa_ColorTable() and _mesa_ColorSubTable().
170 * The table->Table buffer should already be allocated.
171 * \param start first entry to update
172 * \param count number of entries to update
173 * \param format format of user-provided table data
174 * \param type datatype of user-provided table data
175 * \param data user-provided table data
176 * \param [rgba]Scale - RGBA scale factors
177 * \param [rgba]Bias - RGBA bias factors
180 store_colortable_entries(struct gl_context
*ctx
, struct gl_color_table
*table
,
181 GLsizei start
, GLsizei count
,
182 GLenum format
, GLenum type
, const GLvoid
*data
,
183 GLfloat rScale
, GLfloat rBias
,
184 GLfloat gScale
, GLfloat gBias
,
185 GLfloat bScale
, GLfloat bBias
,
186 GLfloat aScale
, GLfloat aBias
)
188 data
= _mesa_map_validate_pbo_source(ctx
,
189 1, &ctx
->Unpack
, count
, 1, 1,
191 "glColor[Sub]Table");
196 /* convert user-provided data to GLfloat values */
197 GLfloat tempTab
[MAX_COLOR_TABLE_SIZE
* 4];
201 _mesa_unpack_color_span_float(ctx
,
202 count
, /* number of pixels */
203 table
->_BaseFormat
, /* dest format */
204 tempTab
, /* dest address */
205 format
, type
, /* src format/type */
208 IMAGE_CLAMP_BIT
); /* transfer ops */
210 /* the destination */
211 tableF
= table
->TableF
;
213 /* Apply scale & bias & clamp now */
214 switch (table
->_BaseFormat
) {
216 for (i
= 0; i
< count
; i
++) {
217 GLuint j
= start
+ i
;
218 tableF
[j
] = CLAMP(tempTab
[i
] * rScale
+ rBias
, 0.0F
, 1.0F
);
222 for (i
= 0; i
< count
; i
++) {
223 GLuint j
= start
+ i
;
224 tableF
[j
] = CLAMP(tempTab
[i
] * rScale
+ rBias
, 0.0F
, 1.0F
);
228 for (i
= 0; i
< count
; i
++) {
229 GLuint j
= start
+ i
;
230 tableF
[j
] = CLAMP(tempTab
[i
] * aScale
+ aBias
, 0.0F
, 1.0F
);
233 case GL_LUMINANCE_ALPHA
:
234 for (i
= 0; i
< count
; i
++) {
235 GLuint j
= start
+ i
;
236 tableF
[j
*2+0] = CLAMP(tempTab
[i
*2+0] * rScale
+ rBias
, 0.0F
, 1.0F
);
237 tableF
[j
*2+1] = CLAMP(tempTab
[i
*2+1] * aScale
+ aBias
, 0.0F
, 1.0F
);
241 for (i
= 0; i
< count
; i
++) {
242 GLuint j
= start
+ i
;
243 tableF
[j
*3+0] = CLAMP(tempTab
[i
*3+0] * rScale
+ rBias
, 0.0F
, 1.0F
);
244 tableF
[j
*3+1] = CLAMP(tempTab
[i
*3+1] * gScale
+ gBias
, 0.0F
, 1.0F
);
245 tableF
[j
*3+2] = CLAMP(tempTab
[i
*3+2] * bScale
+ bBias
, 0.0F
, 1.0F
);
249 for (i
= 0; i
< count
; i
++) {
250 GLuint j
= start
+ i
;
251 tableF
[j
*4+0] = CLAMP(tempTab
[i
*4+0] * rScale
+ rBias
, 0.0F
, 1.0F
);
252 tableF
[j
*4+1] = CLAMP(tempTab
[i
*4+1] * gScale
+ gBias
, 0.0F
, 1.0F
);
253 tableF
[j
*4+2] = CLAMP(tempTab
[i
*4+2] * bScale
+ bBias
, 0.0F
, 1.0F
);
254 tableF
[j
*4+3] = CLAMP(tempTab
[i
*4+3] * aScale
+ aBias
, 0.0F
, 1.0F
);
258 _mesa_problem(ctx
, "Bad format in store_colortable_entries");
263 /* update the ubyte table */
265 const GLint comps
= _mesa_components_in_format(table
->_BaseFormat
);
266 const GLfloat
*tableF
= table
->TableF
+ start
* comps
;
267 GLubyte
*tableUB
= table
->TableUB
+ start
* comps
;
269 for (i
= 0; i
< count
* comps
; i
++) {
270 CLAMPED_FLOAT_TO_UBYTE(tableUB
[i
], tableF
[i
]);
274 _mesa_unmap_pbo_source(ctx
, &ctx
->Unpack
);
280 _mesa_ColorTable( GLenum target
, GLenum internalFormat
,
281 GLsizei width
, GLenum format
, GLenum type
,
284 static const GLfloat one
[4] = { 1.0, 1.0, 1.0, 1.0 };
285 static const GLfloat zero
[4] = { 0.0, 0.0, 0.0, 0.0 };
286 GET_CURRENT_CONTEXT(ctx
);
287 struct gl_texture_unit
*texUnit
= _mesa_get_current_tex_unit(ctx
);
288 struct gl_texture_object
*texObj
= NULL
;
289 struct gl_color_table
*table
= NULL
;
290 GLboolean proxy
= GL_FALSE
;
292 const GLfloat
*scale
= one
, *bias
= zero
;
295 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
); /* too complex */
298 case GL_SHARED_TEXTURE_PALETTE_EXT
:
299 table
= &ctx
->Texture
.Palette
;
301 case GL_TEXTURE_COLOR_TABLE_SGI
:
302 if (!ctx
->Extensions
.SGI_texture_color_table
) {
303 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTable(target)");
306 table
= &(texUnit
->ColorTable
);
307 scale
= ctx
->Pixel
.TextureColorTableScale
;
308 bias
= ctx
->Pixel
.TextureColorTableBias
;
310 case GL_PROXY_TEXTURE_COLOR_TABLE_SGI
:
311 if (!ctx
->Extensions
.SGI_texture_color_table
) {
312 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTable(target)");
315 table
= &(texUnit
->ProxyColorTable
);
319 /* try texture targets */
321 struct gl_texture_object
*texobj
322 = _mesa_select_tex_object(ctx
, texUnit
, target
);
324 table
= &texobj
->Palette
;
325 proxy
= _mesa_is_proxy_texture(target
);
328 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTable(target)");
336 if (!_mesa_is_legal_format_and_type(ctx
, format
, type
) ||
337 format
== GL_INTENSITY
) {
338 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glColorTable(format or type)");
342 baseFormat
= base_colortab_format(internalFormat
);
343 if (baseFormat
< 0) {
344 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTable(internalFormat)");
348 if (width
< 0 || (width
!= 0 && !_mesa_is_pow_two(width
))) {
352 table
->InternalFormat
= (GLenum
) 0;
353 table
->_BaseFormat
= (GLenum
) 0;
356 _mesa_error(ctx
, GL_INVALID_VALUE
, "glColorTable(width=%d)", width
);
361 if (width
> (GLsizei
) ctx
->Const
.MaxColorTableSize
) {
364 table
->InternalFormat
= (GLenum
) 0;
365 table
->_BaseFormat
= (GLenum
) 0;
368 _mesa_error(ctx
, GL_TABLE_TOO_LARGE
, "glColorTable(width)");
374 table
->InternalFormat
= internalFormat
;
375 table
->_BaseFormat
= (GLenum
) baseFormat
;
377 comps
= _mesa_components_in_format(table
->_BaseFormat
);
378 assert(comps
> 0); /* error should have been caught sooner */
381 _mesa_free_colortable_data(table
);
384 table
->TableF
= (GLfloat
*) malloc(comps
* width
* sizeof(GLfloat
));
385 table
->TableUB
= (GLubyte
*) malloc(comps
* width
* sizeof(GLubyte
));
387 if (!table
->TableF
|| !table
->TableUB
) {
388 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glColorTable");
392 store_colortable_entries(ctx
, table
,
393 0, width
, /* start, count */
402 /* do this after the table's Type and Format are set */
403 set_component_sizes(table
);
405 if (texObj
|| target
== GL_SHARED_TEXTURE_PALETTE_EXT
) {
406 /* texture object palette, texObj==NULL means the shared palette */
407 if (ctx
->Driver
.UpdateTexturePalette
) {
408 (*ctx
->Driver
.UpdateTexturePalette
)( ctx
, texObj
);
412 ctx
->NewState
|= _NEW_PIXEL
;
418 _mesa_ColorSubTable( GLenum target
, GLsizei start
,
419 GLsizei count
, GLenum format
, GLenum type
,
422 static const GLfloat one
[4] = { 1.0, 1.0, 1.0, 1.0 };
423 static const GLfloat zero
[4] = { 0.0, 0.0, 0.0, 0.0 };
424 GET_CURRENT_CONTEXT(ctx
);
425 struct gl_texture_unit
*texUnit
= _mesa_get_current_tex_unit(ctx
);
426 struct gl_texture_object
*texObj
= NULL
;
427 struct gl_color_table
*table
= NULL
;
428 const GLfloat
*scale
= one
, *bias
= zero
;
430 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
433 case GL_SHARED_TEXTURE_PALETTE_EXT
:
434 table
= &ctx
->Texture
.Palette
;
436 case GL_TEXTURE_COLOR_TABLE_SGI
:
437 if (!ctx
->Extensions
.SGI_texture_color_table
) {
438 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorSubTable(target)");
441 table
= &(texUnit
->ColorTable
);
442 scale
= ctx
->Pixel
.TextureColorTableScale
;
443 bias
= ctx
->Pixel
.TextureColorTableBias
;
446 /* try texture targets */
447 texObj
= _mesa_select_tex_object(ctx
, texUnit
, target
);
448 if (texObj
&& !_mesa_is_proxy_texture(target
)) {
449 table
= &texObj
->Palette
;
452 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorSubTable(target)");
459 if (!_mesa_is_legal_format_and_type(ctx
, format
, type
) ||
460 format
== GL_INTENSITY
) {
461 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glColorSubTable(format or type)");
466 _mesa_error(ctx
, GL_INVALID_VALUE
, "glColorSubTable(count)");
470 /* error should have been caught sooner */
471 assert(_mesa_components_in_format(table
->_BaseFormat
) > 0);
473 if (start
+ count
> (GLint
) table
->Size
) {
474 _mesa_error(ctx
, GL_INVALID_VALUE
, "glColorSubTable(count)");
478 if (!table
->TableF
|| !table
->TableUB
) {
479 /* a GL_OUT_OF_MEMORY error would have been recorded previously */
483 store_colortable_entries(ctx
, table
, start
, count
,
490 if (texObj
|| target
== GL_SHARED_TEXTURE_PALETTE_EXT
) {
491 /* per-texture object palette */
492 if (ctx
->Driver
.UpdateTexturePalette
) {
493 (*ctx
->Driver
.UpdateTexturePalette
)( ctx
, texObj
);
497 ctx
->NewState
|= _NEW_PIXEL
;
502 static void GLAPIENTRY
503 _mesa_CopyColorTable(GLenum target
, GLenum internalformat
,
504 GLint x
, GLint y
, GLsizei width
)
506 GET_CURRENT_CONTEXT(ctx
);
507 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
509 if (!ctx
->ReadBuffer
->_ColorReadBuffer
) {
510 return; /* no readbuffer - OK */
513 ctx
->Driver
.CopyColorTable( ctx
, target
, internalformat
, x
, y
, width
);
518 static void GLAPIENTRY
519 _mesa_CopyColorSubTable(GLenum target
, GLsizei start
,
520 GLint x
, GLint y
, GLsizei width
)
522 GET_CURRENT_CONTEXT(ctx
);
523 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
525 if (!ctx
->ReadBuffer
->_ColorReadBuffer
) {
526 return; /* no readbuffer - OK */
529 ctx
->Driver
.CopyColorSubTable( ctx
, target
, start
, x
, y
, width
);
534 static void GLAPIENTRY
535 _mesa_GetColorTable( GLenum target
, GLenum format
,
536 GLenum type
, GLvoid
*data
)
538 GET_CURRENT_CONTEXT(ctx
);
539 struct gl_texture_unit
*texUnit
= _mesa_get_current_tex_unit(ctx
);
540 struct gl_color_table
*table
= NULL
;
541 GLfloat rgba
[MAX_COLOR_TABLE_SIZE
][4];
542 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
545 _mesa_update_state(ctx
);
549 case GL_SHARED_TEXTURE_PALETTE_EXT
:
550 table
= &ctx
->Texture
.Palette
;
552 case GL_TEXTURE_COLOR_TABLE_SGI
:
553 if (!ctx
->Extensions
.SGI_texture_color_table
) {
554 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTable(target)");
557 table
= &(texUnit
->ColorTable
);
560 /* try texture targets */
562 struct gl_texture_object
*texobj
563 = _mesa_select_tex_object(ctx
, texUnit
, target
);
564 if (texobj
&& !_mesa_is_proxy_texture(target
)) {
565 table
= &texobj
->Palette
;
568 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTable(target)");
576 if (table
->Size
<= 0) {
580 switch (table
->_BaseFormat
) {
584 for (i
= 0; i
< table
->Size
; i
++) {
588 rgba
[i
][ACOMP
] = table
->TableF
[i
];
595 for (i
= 0; i
< table
->Size
; i
++) {
598 rgba
[i
][BCOMP
] = table
->TableF
[i
];
599 rgba
[i
][ACOMP
] = 1.0F
;
603 case GL_LUMINANCE_ALPHA
:
606 for (i
= 0; i
< table
->Size
; i
++) {
609 rgba
[i
][BCOMP
] = table
->TableF
[i
*2+0];
610 rgba
[i
][ACOMP
] = table
->TableF
[i
*2+1];
617 for (i
= 0; i
< table
->Size
; i
++) {
621 rgba
[i
][ACOMP
] = table
->TableF
[i
];
628 for (i
= 0; i
< table
->Size
; i
++) {
629 rgba
[i
][RCOMP
] = table
->TableF
[i
*3+0];
630 rgba
[i
][GCOMP
] = table
->TableF
[i
*3+1];
631 rgba
[i
][BCOMP
] = table
->TableF
[i
*3+2];
632 rgba
[i
][ACOMP
] = 1.0F
;
637 memcpy(rgba
, table
->TableF
, 4 * table
->Size
* sizeof(GLfloat
));
640 _mesa_problem(ctx
, "bad table format in glGetColorTable");
644 data
= _mesa_map_validate_pbo_dest(ctx
,
645 1, &ctx
->Pack
, table
->Size
, 1, 1,
651 _mesa_pack_rgba_span_float(ctx
, table
->Size
, rgba
,
652 format
, type
, data
, &ctx
->Pack
, 0x0);
654 _mesa_unmap_pbo_dest(ctx
, &ctx
->Pack
);
659 static void GLAPIENTRY
660 _mesa_ColorTableParameterfv(GLenum target
, GLenum pname
, const GLfloat
*params
)
662 GLfloat
*scale
, *bias
;
663 GET_CURRENT_CONTEXT(ctx
);
664 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
667 case GL_TEXTURE_COLOR_TABLE_SGI
:
668 scale
= ctx
->Pixel
.TextureColorTableScale
;
669 bias
= ctx
->Pixel
.TextureColorTableBias
;
672 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTableParameter(target)");
676 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
677 COPY_4V(scale
, params
);
679 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
680 COPY_4V(bias
, params
);
683 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTableParameterfv(pname)");
687 ctx
->NewState
|= _NEW_PIXEL
;
692 static void GLAPIENTRY
693 _mesa_ColorTableParameteriv(GLenum target
, GLenum pname
, const GLint
*params
)
696 if (pname
== GL_TEXTURE_COLOR_TABLE_SGI
) {
698 fparams
[0] = (GLfloat
) params
[0];
699 fparams
[1] = (GLfloat
) params
[1];
700 fparams
[2] = (GLfloat
) params
[2];
701 fparams
[3] = (GLfloat
) params
[3];
705 fparams
[0] = (GLfloat
) params
[0];
707 _mesa_ColorTableParameterfv(target
, pname
, fparams
);
712 static void GLAPIENTRY
713 _mesa_GetColorTableParameterfv( GLenum target
, GLenum pname
, GLfloat
*params
)
715 GET_CURRENT_CONTEXT(ctx
);
716 struct gl_texture_unit
*texUnit
= _mesa_get_current_tex_unit(ctx
);
717 struct gl_color_table
*table
= NULL
;
718 ASSERT_OUTSIDE_BEGIN_END(ctx
);
721 case GL_SHARED_TEXTURE_PALETTE_EXT
:
722 table
= &ctx
->Texture
.Palette
;
724 case GL_TEXTURE_COLOR_TABLE_SGI
:
725 if (!ctx
->Extensions
.SGI_texture_color_table
) {
726 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameter(target)");
729 table
= &(texUnit
->ColorTable
);
730 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
731 COPY_4V(params
, ctx
->Pixel
.TextureColorTableScale
);
734 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
735 COPY_4V(params
, ctx
->Pixel
.TextureColorTableBias
);
739 case GL_PROXY_TEXTURE_COLOR_TABLE_SGI
:
740 if (!ctx
->Extensions
.SGI_texture_color_table
) {
741 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameter(target)");
744 table
= &(texUnit
->ProxyColorTable
);
747 /* try texture targets */
749 struct gl_texture_object
*texobj
750 = _mesa_select_tex_object(ctx
, texUnit
, target
);
752 table
= &texobj
->Palette
;
755 _mesa_error(ctx
, GL_INVALID_ENUM
,
756 "glGetColorTableParameterfv(target)");
765 case GL_COLOR_TABLE_FORMAT
:
766 *params
= (GLfloat
) table
->InternalFormat
;
768 case GL_COLOR_TABLE_WIDTH
:
769 *params
= (GLfloat
) table
->Size
;
771 case GL_COLOR_TABLE_RED_SIZE
:
772 *params
= (GLfloat
) table
->RedSize
;
774 case GL_COLOR_TABLE_GREEN_SIZE
:
775 *params
= (GLfloat
) table
->GreenSize
;
777 case GL_COLOR_TABLE_BLUE_SIZE
:
778 *params
= (GLfloat
) table
->BlueSize
;
780 case GL_COLOR_TABLE_ALPHA_SIZE
:
781 *params
= (GLfloat
) table
->AlphaSize
;
783 case GL_COLOR_TABLE_LUMINANCE_SIZE
:
784 *params
= (GLfloat
) table
->LuminanceSize
;
786 case GL_COLOR_TABLE_INTENSITY_SIZE
:
787 *params
= (GLfloat
) table
->IntensitySize
;
790 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameterfv(pname)" );
797 static void GLAPIENTRY
798 _mesa_GetColorTableParameteriv( GLenum target
, GLenum pname
, GLint
*params
)
800 GET_CURRENT_CONTEXT(ctx
);
801 struct gl_texture_unit
*texUnit
= _mesa_get_current_tex_unit(ctx
);
802 struct gl_color_table
*table
= NULL
;
803 ASSERT_OUTSIDE_BEGIN_END(ctx
);
806 case GL_SHARED_TEXTURE_PALETTE_EXT
:
807 table
= &ctx
->Texture
.Palette
;
809 case GL_TEXTURE_COLOR_TABLE_SGI
:
810 if (!ctx
->Extensions
.SGI_texture_color_table
) {
811 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameter(target)");
814 table
= &(texUnit
->ColorTable
);
815 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
816 params
[0] = (GLint
) ctx
->Pixel
.TextureColorTableScale
[0];
817 params
[1] = (GLint
) ctx
->Pixel
.TextureColorTableScale
[1];
818 params
[2] = (GLint
) ctx
->Pixel
.TextureColorTableScale
[2];
819 params
[3] = (GLint
) ctx
->Pixel
.TextureColorTableScale
[3];
822 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
823 params
[0] = (GLint
) ctx
->Pixel
.TextureColorTableBias
[0];
824 params
[1] = (GLint
) ctx
->Pixel
.TextureColorTableBias
[1];
825 params
[2] = (GLint
) ctx
->Pixel
.TextureColorTableBias
[2];
826 params
[3] = (GLint
) ctx
->Pixel
.TextureColorTableBias
[3];
830 case GL_PROXY_TEXTURE_COLOR_TABLE_SGI
:
831 if (!ctx
->Extensions
.SGI_texture_color_table
) {
832 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameter(target)");
835 table
= &(texUnit
->ProxyColorTable
);
838 /* Try texture targets */
840 struct gl_texture_object
*texobj
841 = _mesa_select_tex_object(ctx
, texUnit
, target
);
843 table
= &texobj
->Palette
;
846 _mesa_error(ctx
, GL_INVALID_ENUM
,
847 "glGetColorTableParameteriv(target)");
856 case GL_COLOR_TABLE_FORMAT
:
857 *params
= table
->InternalFormat
;
859 case GL_COLOR_TABLE_WIDTH
:
860 *params
= table
->Size
;
862 case GL_COLOR_TABLE_RED_SIZE
:
863 *params
= table
->RedSize
;
865 case GL_COLOR_TABLE_GREEN_SIZE
:
866 *params
= table
->GreenSize
;
868 case GL_COLOR_TABLE_BLUE_SIZE
:
869 *params
= table
->BlueSize
;
871 case GL_COLOR_TABLE_ALPHA_SIZE
:
872 *params
= table
->AlphaSize
;
874 case GL_COLOR_TABLE_LUMINANCE_SIZE
:
875 *params
= table
->LuminanceSize
;
877 case GL_COLOR_TABLE_INTENSITY_SIZE
:
878 *params
= table
->IntensitySize
;
881 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameteriv(pname)" );
888 _mesa_init_colortable_dispatch(struct _glapi_table
*disp
)
890 SET_ColorSubTable(disp
, _mesa_ColorSubTable
);
891 SET_ColorTable(disp
, _mesa_ColorTable
);
892 SET_ColorTableParameterfv(disp
, _mesa_ColorTableParameterfv
);
893 SET_ColorTableParameteriv(disp
, _mesa_ColorTableParameteriv
);
894 SET_CopyColorSubTable(disp
, _mesa_CopyColorSubTable
);
895 SET_CopyColorTable(disp
, _mesa_CopyColorTable
);
896 SET_GetColorTable(disp
, _mesa_GetColorTable
);
897 SET_GetColorTableParameterfv(disp
, _mesa_GetColorTableParameterfv
);
898 SET_GetColorTableParameteriv(disp
, _mesa_GetColorTableParameteriv
);
902 #endif /* FEATURE_colortable */
905 /**********************************************************************/
906 /***** Initialization *****/
907 /**********************************************************************/
911 _mesa_init_colortable( struct gl_color_table
*p
)
916 p
->InternalFormat
= GL_RGBA
;
922 _mesa_free_colortable_data( struct gl_color_table
*p
)