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"
37 #include "main/dispatch.h"
40 #if FEATURE_colortable
44 * Given an internalFormat token passed to glColorTable,
45 * return the corresponding base format.
46 * Return -1 if invalid token.
49 base_colortab_format( GLenum format
)
64 case GL_LUMINANCE_ALPHA
:
65 case GL_LUMINANCE4_ALPHA4
:
66 case GL_LUMINANCE6_ALPHA2
:
67 case GL_LUMINANCE8_ALPHA8
:
68 case GL_LUMINANCE12_ALPHA4
:
69 case GL_LUMINANCE12_ALPHA12
:
70 case GL_LUMINANCE16_ALPHA16
:
71 return GL_LUMINANCE_ALPHA
;
97 return -1; /* error */
104 * Examine table's format and set the component sizes accordingly.
107 set_component_sizes( struct gl_color_table
*table
)
109 /* assuming the ubyte table */
110 const GLubyte sz
= 8;
112 switch (table
->_BaseFormat
) {
115 table
->GreenSize
= 0;
117 table
->AlphaSize
= sz
;
118 table
->IntensitySize
= 0;
119 table
->LuminanceSize
= 0;
123 table
->GreenSize
= 0;
125 table
->AlphaSize
= 0;
126 table
->IntensitySize
= 0;
127 table
->LuminanceSize
= sz
;
129 case GL_LUMINANCE_ALPHA
:
131 table
->GreenSize
= 0;
133 table
->AlphaSize
= sz
;
134 table
->IntensitySize
= 0;
135 table
->LuminanceSize
= sz
;
139 table
->GreenSize
= 0;
141 table
->AlphaSize
= 0;
142 table
->IntensitySize
= sz
;
143 table
->LuminanceSize
= 0;
147 table
->GreenSize
= sz
;
148 table
->BlueSize
= sz
;
149 table
->AlphaSize
= 0;
150 table
->IntensitySize
= 0;
151 table
->LuminanceSize
= 0;
155 table
->GreenSize
= sz
;
156 table
->BlueSize
= sz
;
157 table
->AlphaSize
= sz
;
158 table
->IntensitySize
= 0;
159 table
->LuminanceSize
= 0;
162 _mesa_problem(NULL
, "unexpected format in set_component_sizes");
169 * Update/replace all or part of a color table. Helper function
170 * used by _mesa_ColorTable() and _mesa_ColorSubTable().
171 * The table->Table buffer should already be allocated.
172 * \param start first entry to update
173 * \param count number of entries to update
174 * \param format format of user-provided table data
175 * \param type datatype of user-provided table data
176 * \param data user-provided table data
177 * \param [rgba]Scale - RGBA scale factors
178 * \param [rgba]Bias - RGBA bias factors
181 store_colortable_entries(struct gl_context
*ctx
, struct gl_color_table
*table
,
182 GLsizei start
, GLsizei count
,
183 GLenum format
, GLenum type
, const GLvoid
*data
,
184 GLfloat rScale
, GLfloat rBias
,
185 GLfloat gScale
, GLfloat gBias
,
186 GLfloat bScale
, GLfloat bBias
,
187 GLfloat aScale
, GLfloat aBias
)
189 data
= _mesa_map_validate_pbo_source(ctx
,
190 1, &ctx
->Unpack
, count
, 1, 1,
192 "glColor[Sub]Table");
197 /* convert user-provided data to GLfloat values */
198 GLfloat tempTab
[MAX_COLOR_TABLE_SIZE
* 4];
202 _mesa_unpack_color_span_float(ctx
,
203 count
, /* number of pixels */
204 table
->_BaseFormat
, /* dest format */
205 tempTab
, /* dest address */
206 format
, type
, /* src format/type */
209 IMAGE_CLAMP_BIT
); /* transfer ops */
211 /* the destination */
212 tableF
= table
->TableF
;
214 /* Apply scale & bias & clamp now */
215 switch (table
->_BaseFormat
) {
217 for (i
= 0; i
< count
; i
++) {
218 GLuint j
= start
+ i
;
219 tableF
[j
] = CLAMP(tempTab
[i
] * rScale
+ rBias
, 0.0F
, 1.0F
);
223 for (i
= 0; i
< count
; i
++) {
224 GLuint j
= start
+ i
;
225 tableF
[j
] = CLAMP(tempTab
[i
] * rScale
+ rBias
, 0.0F
, 1.0F
);
229 for (i
= 0; i
< count
; i
++) {
230 GLuint j
= start
+ i
;
231 tableF
[j
] = CLAMP(tempTab
[i
] * aScale
+ aBias
, 0.0F
, 1.0F
);
234 case GL_LUMINANCE_ALPHA
:
235 for (i
= 0; i
< count
; i
++) {
236 GLuint j
= start
+ i
;
237 tableF
[j
*2+0] = CLAMP(tempTab
[i
*2+0] * rScale
+ rBias
, 0.0F
, 1.0F
);
238 tableF
[j
*2+1] = CLAMP(tempTab
[i
*2+1] * aScale
+ aBias
, 0.0F
, 1.0F
);
242 for (i
= 0; i
< count
; i
++) {
243 GLuint j
= start
+ i
;
244 tableF
[j
*3+0] = CLAMP(tempTab
[i
*3+0] * rScale
+ rBias
, 0.0F
, 1.0F
);
245 tableF
[j
*3+1] = CLAMP(tempTab
[i
*3+1] * gScale
+ gBias
, 0.0F
, 1.0F
);
246 tableF
[j
*3+2] = CLAMP(tempTab
[i
*3+2] * bScale
+ bBias
, 0.0F
, 1.0F
);
250 for (i
= 0; i
< count
; i
++) {
251 GLuint j
= start
+ i
;
252 tableF
[j
*4+0] = CLAMP(tempTab
[i
*4+0] * rScale
+ rBias
, 0.0F
, 1.0F
);
253 tableF
[j
*4+1] = CLAMP(tempTab
[i
*4+1] * gScale
+ gBias
, 0.0F
, 1.0F
);
254 tableF
[j
*4+2] = CLAMP(tempTab
[i
*4+2] * bScale
+ bBias
, 0.0F
, 1.0F
);
255 tableF
[j
*4+3] = CLAMP(tempTab
[i
*4+3] * aScale
+ aBias
, 0.0F
, 1.0F
);
259 _mesa_problem(ctx
, "Bad format in store_colortable_entries");
264 /* update the ubyte table */
266 const GLint comps
= _mesa_components_in_format(table
->_BaseFormat
);
267 const GLfloat
*tableF
= table
->TableF
+ start
* comps
;
268 GLubyte
*tableUB
= table
->TableUB
+ start
* comps
;
270 for (i
= 0; i
< count
* comps
; i
++) {
271 CLAMPED_FLOAT_TO_UBYTE(tableUB
[i
], tableF
[i
]);
275 _mesa_unmap_pbo_source(ctx
, &ctx
->Unpack
);
281 _mesa_ColorTable( GLenum target
, GLenum internalFormat
,
282 GLsizei width
, GLenum format
, GLenum type
,
285 static const GLfloat one
[4] = { 1.0, 1.0, 1.0, 1.0 };
286 static const GLfloat zero
[4] = { 0.0, 0.0, 0.0, 0.0 };
287 GET_CURRENT_CONTEXT(ctx
);
288 struct gl_texture_unit
*texUnit
= _mesa_get_current_tex_unit(ctx
);
289 struct gl_texture_object
*texObj
= NULL
;
290 struct gl_color_table
*table
= NULL
;
291 GLboolean proxy
= GL_FALSE
;
293 const GLfloat
*scale
= one
, *bias
= zero
;
296 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
); /* too complex */
299 case GL_SHARED_TEXTURE_PALETTE_EXT
:
300 table
= &ctx
->Texture
.Palette
;
302 case GL_TEXTURE_COLOR_TABLE_SGI
:
303 if (!ctx
->Extensions
.SGI_texture_color_table
) {
304 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTable(target)");
307 table
= &(texUnit
->ColorTable
);
308 scale
= ctx
->Pixel
.TextureColorTableScale
;
309 bias
= ctx
->Pixel
.TextureColorTableBias
;
311 case GL_PROXY_TEXTURE_COLOR_TABLE_SGI
:
312 if (!ctx
->Extensions
.SGI_texture_color_table
) {
313 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTable(target)");
316 table
= &(texUnit
->ProxyColorTable
);
320 /* try texture targets */
322 struct gl_texture_object
*texobj
323 = _mesa_select_tex_object(ctx
, texUnit
, target
);
325 table
= &texobj
->Palette
;
326 proxy
= _mesa_is_proxy_texture(target
);
329 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTable(target)");
337 if (!_mesa_is_legal_format_and_type(ctx
, format
, type
) ||
338 format
== GL_INTENSITY
) {
339 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glColorTable(format or type)");
343 baseFormat
= base_colortab_format(internalFormat
);
344 if (baseFormat
< 0) {
345 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTable(internalFormat)");
349 if (width
< 0 || (width
!= 0 && !_mesa_is_pow_two(width
))) {
353 table
->InternalFormat
= (GLenum
) 0;
354 table
->_BaseFormat
= (GLenum
) 0;
357 _mesa_error(ctx
, GL_INVALID_VALUE
, "glColorTable(width=%d)", width
);
362 if (width
> (GLsizei
) ctx
->Const
.MaxColorTableSize
) {
365 table
->InternalFormat
= (GLenum
) 0;
366 table
->_BaseFormat
= (GLenum
) 0;
369 _mesa_error(ctx
, GL_TABLE_TOO_LARGE
, "glColorTable(width)");
375 table
->InternalFormat
= internalFormat
;
376 table
->_BaseFormat
= (GLenum
) baseFormat
;
378 comps
= _mesa_components_in_format(table
->_BaseFormat
);
379 assert(comps
> 0); /* error should have been caught sooner */
382 _mesa_free_colortable_data(table
);
385 table
->TableF
= (GLfloat
*) malloc(comps
* width
* sizeof(GLfloat
));
386 table
->TableUB
= (GLubyte
*) malloc(comps
* width
* sizeof(GLubyte
));
388 if (!table
->TableF
|| !table
->TableUB
) {
389 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glColorTable");
393 store_colortable_entries(ctx
, table
,
394 0, width
, /* start, count */
403 /* do this after the table's Type and Format are set */
404 set_component_sizes(table
);
406 if (texObj
|| target
== GL_SHARED_TEXTURE_PALETTE_EXT
) {
407 /* texture object palette, texObj==NULL means the shared palette */
408 if (ctx
->Driver
.UpdateTexturePalette
) {
409 (*ctx
->Driver
.UpdateTexturePalette
)( ctx
, texObj
);
413 ctx
->NewState
|= _NEW_PIXEL
;
419 _mesa_ColorSubTable( GLenum target
, GLsizei start
,
420 GLsizei count
, GLenum format
, GLenum type
,
423 static const GLfloat one
[4] = { 1.0, 1.0, 1.0, 1.0 };
424 static const GLfloat zero
[4] = { 0.0, 0.0, 0.0, 0.0 };
425 GET_CURRENT_CONTEXT(ctx
);
426 struct gl_texture_unit
*texUnit
= _mesa_get_current_tex_unit(ctx
);
427 struct gl_texture_object
*texObj
= NULL
;
428 struct gl_color_table
*table
= NULL
;
429 const GLfloat
*scale
= one
, *bias
= zero
;
431 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
434 case GL_SHARED_TEXTURE_PALETTE_EXT
:
435 table
= &ctx
->Texture
.Palette
;
437 case GL_TEXTURE_COLOR_TABLE_SGI
:
438 if (!ctx
->Extensions
.SGI_texture_color_table
) {
439 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorSubTable(target)");
442 table
= &(texUnit
->ColorTable
);
443 scale
= ctx
->Pixel
.TextureColorTableScale
;
444 bias
= ctx
->Pixel
.TextureColorTableBias
;
447 /* try texture targets */
448 texObj
= _mesa_select_tex_object(ctx
, texUnit
, target
);
449 if (texObj
&& !_mesa_is_proxy_texture(target
)) {
450 table
= &texObj
->Palette
;
453 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorSubTable(target)");
460 if (!_mesa_is_legal_format_and_type(ctx
, format
, type
) ||
461 format
== GL_INTENSITY
) {
462 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glColorSubTable(format or type)");
467 _mesa_error(ctx
, GL_INVALID_VALUE
, "glColorSubTable(count)");
471 /* error should have been caught sooner */
472 assert(_mesa_components_in_format(table
->_BaseFormat
) > 0);
474 if (start
+ count
> (GLint
) table
->Size
) {
475 _mesa_error(ctx
, GL_INVALID_VALUE
, "glColorSubTable(count)");
479 if (!table
->TableF
|| !table
->TableUB
) {
480 /* a GL_OUT_OF_MEMORY error would have been recorded previously */
484 store_colortable_entries(ctx
, table
, start
, count
,
491 if (texObj
|| target
== GL_SHARED_TEXTURE_PALETTE_EXT
) {
492 /* per-texture object palette */
493 if (ctx
->Driver
.UpdateTexturePalette
) {
494 (*ctx
->Driver
.UpdateTexturePalette
)( ctx
, texObj
);
498 ctx
->NewState
|= _NEW_PIXEL
;
503 static void GLAPIENTRY
504 _mesa_CopyColorTable(GLenum target
, GLenum internalformat
,
505 GLint x
, GLint y
, GLsizei width
)
507 GET_CURRENT_CONTEXT(ctx
);
508 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
510 if (!ctx
->ReadBuffer
->_ColorReadBuffer
) {
511 return; /* no readbuffer - OK */
514 ctx
->Driver
.CopyColorTable( ctx
, target
, internalformat
, x
, y
, width
);
519 static void GLAPIENTRY
520 _mesa_CopyColorSubTable(GLenum target
, GLsizei start
,
521 GLint x
, GLint y
, GLsizei width
)
523 GET_CURRENT_CONTEXT(ctx
);
524 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
526 if (!ctx
->ReadBuffer
->_ColorReadBuffer
) {
527 return; /* no readbuffer - OK */
530 ctx
->Driver
.CopyColorSubTable( ctx
, target
, start
, x
, y
, width
);
535 static void GLAPIENTRY
536 _mesa_GetColorTable( GLenum target
, GLenum format
,
537 GLenum type
, GLvoid
*data
)
539 GET_CURRENT_CONTEXT(ctx
);
540 struct gl_texture_unit
*texUnit
= _mesa_get_current_tex_unit(ctx
);
541 struct gl_color_table
*table
= NULL
;
542 GLfloat rgba
[MAX_COLOR_TABLE_SIZE
][4];
543 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
546 _mesa_update_state(ctx
);
550 case GL_SHARED_TEXTURE_PALETTE_EXT
:
551 table
= &ctx
->Texture
.Palette
;
553 case GL_TEXTURE_COLOR_TABLE_SGI
:
554 if (!ctx
->Extensions
.SGI_texture_color_table
) {
555 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTable(target)");
558 table
= &(texUnit
->ColorTable
);
561 /* try texture targets */
563 struct gl_texture_object
*texobj
564 = _mesa_select_tex_object(ctx
, texUnit
, target
);
565 if (texobj
&& !_mesa_is_proxy_texture(target
)) {
566 table
= &texobj
->Palette
;
569 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTable(target)");
577 if (table
->Size
<= 0) {
581 switch (table
->_BaseFormat
) {
585 for (i
= 0; i
< table
->Size
; i
++) {
589 rgba
[i
][ACOMP
] = table
->TableF
[i
];
596 for (i
= 0; i
< table
->Size
; i
++) {
599 rgba
[i
][BCOMP
] = table
->TableF
[i
];
600 rgba
[i
][ACOMP
] = 1.0F
;
604 case GL_LUMINANCE_ALPHA
:
607 for (i
= 0; i
< table
->Size
; i
++) {
610 rgba
[i
][BCOMP
] = table
->TableF
[i
*2+0];
611 rgba
[i
][ACOMP
] = table
->TableF
[i
*2+1];
618 for (i
= 0; i
< table
->Size
; i
++) {
622 rgba
[i
][ACOMP
] = table
->TableF
[i
];
629 for (i
= 0; i
< table
->Size
; i
++) {
630 rgba
[i
][RCOMP
] = table
->TableF
[i
*3+0];
631 rgba
[i
][GCOMP
] = table
->TableF
[i
*3+1];
632 rgba
[i
][BCOMP
] = table
->TableF
[i
*3+2];
633 rgba
[i
][ACOMP
] = 1.0F
;
638 memcpy(rgba
, table
->TableF
, 4 * table
->Size
* sizeof(GLfloat
));
641 _mesa_problem(ctx
, "bad table format in glGetColorTable");
645 data
= _mesa_map_validate_pbo_dest(ctx
,
646 1, &ctx
->Pack
, table
->Size
, 1, 1,
652 _mesa_pack_rgba_span_float(ctx
, table
->Size
, rgba
,
653 format
, type
, data
, &ctx
->Pack
, 0x0);
655 _mesa_unmap_pbo_dest(ctx
, &ctx
->Pack
);
660 static void GLAPIENTRY
661 _mesa_ColorTableParameterfv(GLenum target
, GLenum pname
, const GLfloat
*params
)
663 GLfloat
*scale
, *bias
;
664 GET_CURRENT_CONTEXT(ctx
);
665 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
668 case GL_TEXTURE_COLOR_TABLE_SGI
:
669 scale
= ctx
->Pixel
.TextureColorTableScale
;
670 bias
= ctx
->Pixel
.TextureColorTableBias
;
673 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTableParameter(target)");
677 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
678 COPY_4V(scale
, params
);
680 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
681 COPY_4V(bias
, params
);
684 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTableParameterfv(pname)");
688 ctx
->NewState
|= _NEW_PIXEL
;
693 static void GLAPIENTRY
694 _mesa_ColorTableParameteriv(GLenum target
, GLenum pname
, const GLint
*params
)
697 if (pname
== GL_TEXTURE_COLOR_TABLE_SGI
) {
699 fparams
[0] = (GLfloat
) params
[0];
700 fparams
[1] = (GLfloat
) params
[1];
701 fparams
[2] = (GLfloat
) params
[2];
702 fparams
[3] = (GLfloat
) params
[3];
706 fparams
[0] = (GLfloat
) params
[0];
708 _mesa_ColorTableParameterfv(target
, pname
, fparams
);
713 static void GLAPIENTRY
714 _mesa_GetColorTableParameterfv( GLenum target
, GLenum pname
, GLfloat
*params
)
716 GET_CURRENT_CONTEXT(ctx
);
717 struct gl_texture_unit
*texUnit
= _mesa_get_current_tex_unit(ctx
);
718 struct gl_color_table
*table
= NULL
;
719 ASSERT_OUTSIDE_BEGIN_END(ctx
);
722 case GL_SHARED_TEXTURE_PALETTE_EXT
:
723 table
= &ctx
->Texture
.Palette
;
725 case GL_TEXTURE_COLOR_TABLE_SGI
:
726 if (!ctx
->Extensions
.SGI_texture_color_table
) {
727 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameter(target)");
730 table
= &(texUnit
->ColorTable
);
731 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
732 COPY_4V(params
, ctx
->Pixel
.TextureColorTableScale
);
735 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
736 COPY_4V(params
, ctx
->Pixel
.TextureColorTableBias
);
740 case GL_PROXY_TEXTURE_COLOR_TABLE_SGI
:
741 if (!ctx
->Extensions
.SGI_texture_color_table
) {
742 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameter(target)");
745 table
= &(texUnit
->ProxyColorTable
);
748 /* try texture targets */
750 struct gl_texture_object
*texobj
751 = _mesa_select_tex_object(ctx
, texUnit
, target
);
753 table
= &texobj
->Palette
;
756 _mesa_error(ctx
, GL_INVALID_ENUM
,
757 "glGetColorTableParameterfv(target)");
766 case GL_COLOR_TABLE_FORMAT
:
767 *params
= (GLfloat
) table
->InternalFormat
;
769 case GL_COLOR_TABLE_WIDTH
:
770 *params
= (GLfloat
) table
->Size
;
772 case GL_COLOR_TABLE_RED_SIZE
:
773 *params
= (GLfloat
) table
->RedSize
;
775 case GL_COLOR_TABLE_GREEN_SIZE
:
776 *params
= (GLfloat
) table
->GreenSize
;
778 case GL_COLOR_TABLE_BLUE_SIZE
:
779 *params
= (GLfloat
) table
->BlueSize
;
781 case GL_COLOR_TABLE_ALPHA_SIZE
:
782 *params
= (GLfloat
) table
->AlphaSize
;
784 case GL_COLOR_TABLE_LUMINANCE_SIZE
:
785 *params
= (GLfloat
) table
->LuminanceSize
;
787 case GL_COLOR_TABLE_INTENSITY_SIZE
:
788 *params
= (GLfloat
) table
->IntensitySize
;
791 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameterfv(pname)" );
798 static void GLAPIENTRY
799 _mesa_GetColorTableParameteriv( GLenum target
, GLenum pname
, GLint
*params
)
801 GET_CURRENT_CONTEXT(ctx
);
802 struct gl_texture_unit
*texUnit
= _mesa_get_current_tex_unit(ctx
);
803 struct gl_color_table
*table
= NULL
;
804 ASSERT_OUTSIDE_BEGIN_END(ctx
);
807 case GL_SHARED_TEXTURE_PALETTE_EXT
:
808 table
= &ctx
->Texture
.Palette
;
810 case GL_TEXTURE_COLOR_TABLE_SGI
:
811 if (!ctx
->Extensions
.SGI_texture_color_table
) {
812 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameter(target)");
815 table
= &(texUnit
->ColorTable
);
816 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
817 params
[0] = (GLint
) ctx
->Pixel
.TextureColorTableScale
[0];
818 params
[1] = (GLint
) ctx
->Pixel
.TextureColorTableScale
[1];
819 params
[2] = (GLint
) ctx
->Pixel
.TextureColorTableScale
[2];
820 params
[3] = (GLint
) ctx
->Pixel
.TextureColorTableScale
[3];
823 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
824 params
[0] = (GLint
) ctx
->Pixel
.TextureColorTableBias
[0];
825 params
[1] = (GLint
) ctx
->Pixel
.TextureColorTableBias
[1];
826 params
[2] = (GLint
) ctx
->Pixel
.TextureColorTableBias
[2];
827 params
[3] = (GLint
) ctx
->Pixel
.TextureColorTableBias
[3];
831 case GL_PROXY_TEXTURE_COLOR_TABLE_SGI
:
832 if (!ctx
->Extensions
.SGI_texture_color_table
) {
833 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameter(target)");
836 table
= &(texUnit
->ProxyColorTable
);
839 /* Try texture targets */
841 struct gl_texture_object
*texobj
842 = _mesa_select_tex_object(ctx
, texUnit
, target
);
844 table
= &texobj
->Palette
;
847 _mesa_error(ctx
, GL_INVALID_ENUM
,
848 "glGetColorTableParameteriv(target)");
857 case GL_COLOR_TABLE_FORMAT
:
858 *params
= table
->InternalFormat
;
860 case GL_COLOR_TABLE_WIDTH
:
861 *params
= table
->Size
;
863 case GL_COLOR_TABLE_RED_SIZE
:
864 *params
= table
->RedSize
;
866 case GL_COLOR_TABLE_GREEN_SIZE
:
867 *params
= table
->GreenSize
;
869 case GL_COLOR_TABLE_BLUE_SIZE
:
870 *params
= table
->BlueSize
;
872 case GL_COLOR_TABLE_ALPHA_SIZE
:
873 *params
= table
->AlphaSize
;
875 case GL_COLOR_TABLE_LUMINANCE_SIZE
:
876 *params
= table
->LuminanceSize
;
878 case GL_COLOR_TABLE_INTENSITY_SIZE
:
879 *params
= table
->IntensitySize
;
882 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameteriv(pname)" );
889 _mesa_init_colortable_dispatch(struct _glapi_table
*disp
)
891 SET_ColorSubTable(disp
, _mesa_ColorSubTable
);
892 SET_ColorTable(disp
, _mesa_ColorTable
);
893 SET_ColorTableParameterfv(disp
, _mesa_ColorTableParameterfv
);
894 SET_ColorTableParameteriv(disp
, _mesa_ColorTableParameteriv
);
895 SET_CopyColorSubTable(disp
, _mesa_CopyColorSubTable
);
896 SET_CopyColorTable(disp
, _mesa_CopyColorTable
);
897 SET_GetColorTable(disp
, _mesa_GetColorTable
);
898 SET_GetColorTableParameterfv(disp
, _mesa_GetColorTableParameterfv
);
899 SET_GetColorTableParameteriv(disp
, _mesa_GetColorTableParameteriv
);
903 #endif /* FEATURE_colortable */
906 /**********************************************************************/
907 /***** Initialization *****/
908 /**********************************************************************/
912 _mesa_init_colortable( struct gl_color_table
*p
)
917 p
->InternalFormat
= GL_RGBA
;
923 _mesa_free_colortable_data( struct gl_color_table
*p
)