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"
32 #include "mfeatures.h"
38 #include "main/dispatch.h"
41 #if FEATURE_colortable
45 * Given an internalFormat token passed to glColorTable,
46 * return the corresponding base format.
47 * Return -1 if invalid token.
50 base_colortab_format( GLenum format
)
65 case GL_LUMINANCE_ALPHA
:
66 case GL_LUMINANCE4_ALPHA4
:
67 case GL_LUMINANCE6_ALPHA2
:
68 case GL_LUMINANCE8_ALPHA8
:
69 case GL_LUMINANCE12_ALPHA4
:
70 case GL_LUMINANCE12_ALPHA12
:
71 case GL_LUMINANCE16_ALPHA16
:
72 return GL_LUMINANCE_ALPHA
;
98 return -1; /* error */
105 * Examine table's format and set the component sizes accordingly.
108 set_component_sizes( struct gl_color_table
*table
)
110 /* assuming the ubyte table */
111 const GLubyte sz
= 8;
113 switch (table
->_BaseFormat
) {
116 table
->GreenSize
= 0;
118 table
->AlphaSize
= sz
;
119 table
->IntensitySize
= 0;
120 table
->LuminanceSize
= 0;
124 table
->GreenSize
= 0;
126 table
->AlphaSize
= 0;
127 table
->IntensitySize
= 0;
128 table
->LuminanceSize
= sz
;
130 case GL_LUMINANCE_ALPHA
:
132 table
->GreenSize
= 0;
134 table
->AlphaSize
= sz
;
135 table
->IntensitySize
= 0;
136 table
->LuminanceSize
= sz
;
140 table
->GreenSize
= 0;
142 table
->AlphaSize
= 0;
143 table
->IntensitySize
= sz
;
144 table
->LuminanceSize
= 0;
148 table
->GreenSize
= sz
;
149 table
->BlueSize
= sz
;
150 table
->AlphaSize
= 0;
151 table
->IntensitySize
= 0;
152 table
->LuminanceSize
= 0;
156 table
->GreenSize
= sz
;
157 table
->BlueSize
= sz
;
158 table
->AlphaSize
= sz
;
159 table
->IntensitySize
= 0;
160 table
->LuminanceSize
= 0;
163 _mesa_problem(NULL
, "unexpected format in set_component_sizes");
170 * Update/replace all or part of a color table. Helper function
171 * used by _mesa_ColorTable() and _mesa_ColorSubTable().
172 * The table->Table buffer should already be allocated.
173 * \param start first entry to update
174 * \param count number of entries to update
175 * \param format format of user-provided table data
176 * \param type datatype of user-provided table data
177 * \param data user-provided table data
178 * \param [rgba]Scale - RGBA scale factors
179 * \param [rgba]Bias - RGBA bias factors
182 store_colortable_entries(struct gl_context
*ctx
, struct gl_color_table
*table
,
183 GLsizei start
, GLsizei count
,
184 GLenum format
, GLenum type
, const GLvoid
*data
,
185 GLfloat rScale
, GLfloat rBias
,
186 GLfloat gScale
, GLfloat gBias
,
187 GLfloat bScale
, GLfloat bBias
,
188 GLfloat aScale
, GLfloat aBias
)
190 data
= _mesa_map_validate_pbo_source(ctx
,
191 1, &ctx
->Unpack
, count
, 1, 1,
193 "glColor[Sub]Table");
198 /* convert user-provided data to GLfloat values */
199 GLfloat tempTab
[MAX_COLOR_TABLE_SIZE
* 4];
203 _mesa_unpack_color_span_float(ctx
,
204 count
, /* number of pixels */
205 table
->_BaseFormat
, /* dest format */
206 tempTab
, /* dest address */
207 format
, type
, /* src format/type */
210 IMAGE_CLAMP_BIT
); /* transfer ops */
212 /* the destination */
213 tableF
= table
->TableF
;
215 /* Apply scale & bias & clamp now */
216 switch (table
->_BaseFormat
) {
218 for (i
= 0; i
< count
; i
++) {
219 GLuint j
= start
+ i
;
220 tableF
[j
] = CLAMP(tempTab
[i
] * rScale
+ rBias
, 0.0F
, 1.0F
);
224 for (i
= 0; i
< count
; i
++) {
225 GLuint j
= start
+ i
;
226 tableF
[j
] = CLAMP(tempTab
[i
] * rScale
+ rBias
, 0.0F
, 1.0F
);
230 for (i
= 0; i
< count
; i
++) {
231 GLuint j
= start
+ i
;
232 tableF
[j
] = CLAMP(tempTab
[i
] * aScale
+ aBias
, 0.0F
, 1.0F
);
235 case GL_LUMINANCE_ALPHA
:
236 for (i
= 0; i
< count
; i
++) {
237 GLuint j
= start
+ i
;
238 tableF
[j
*2+0] = CLAMP(tempTab
[i
*2+0] * rScale
+ rBias
, 0.0F
, 1.0F
);
239 tableF
[j
*2+1] = CLAMP(tempTab
[i
*2+1] * aScale
+ aBias
, 0.0F
, 1.0F
);
243 for (i
= 0; i
< count
; i
++) {
244 GLuint j
= start
+ i
;
245 tableF
[j
*3+0] = CLAMP(tempTab
[i
*3+0] * rScale
+ rBias
, 0.0F
, 1.0F
);
246 tableF
[j
*3+1] = CLAMP(tempTab
[i
*3+1] * gScale
+ gBias
, 0.0F
, 1.0F
);
247 tableF
[j
*3+2] = CLAMP(tempTab
[i
*3+2] * bScale
+ bBias
, 0.0F
, 1.0F
);
251 for (i
= 0; i
< count
; i
++) {
252 GLuint j
= start
+ i
;
253 tableF
[j
*4+0] = CLAMP(tempTab
[i
*4+0] * rScale
+ rBias
, 0.0F
, 1.0F
);
254 tableF
[j
*4+1] = CLAMP(tempTab
[i
*4+1] * gScale
+ gBias
, 0.0F
, 1.0F
);
255 tableF
[j
*4+2] = CLAMP(tempTab
[i
*4+2] * bScale
+ bBias
, 0.0F
, 1.0F
);
256 tableF
[j
*4+3] = CLAMP(tempTab
[i
*4+3] * aScale
+ aBias
, 0.0F
, 1.0F
);
260 _mesa_problem(ctx
, "Bad format in store_colortable_entries");
265 /* update the ubyte table */
267 const GLint comps
= _mesa_components_in_format(table
->_BaseFormat
);
268 const GLfloat
*tableF
= table
->TableF
+ start
* comps
;
269 GLubyte
*tableUB
= table
->TableUB
+ start
* comps
;
271 for (i
= 0; i
< count
* comps
; i
++) {
272 CLAMPED_FLOAT_TO_UBYTE(tableUB
[i
], tableF
[i
]);
276 _mesa_unmap_pbo_source(ctx
, &ctx
->Unpack
);
282 _mesa_ColorTable( GLenum target
, GLenum internalFormat
,
283 GLsizei width
, GLenum format
, GLenum type
,
286 static const GLfloat one
[4] = { 1.0, 1.0, 1.0, 1.0 };
287 static const GLfloat zero
[4] = { 0.0, 0.0, 0.0, 0.0 };
288 GET_CURRENT_CONTEXT(ctx
);
289 struct gl_texture_unit
*texUnit
= _mesa_get_current_tex_unit(ctx
);
290 struct gl_texture_object
*texObj
= NULL
;
291 struct gl_color_table
*table
= NULL
;
292 GLboolean proxy
= GL_FALSE
;
294 const GLfloat
*scale
= one
, *bias
= zero
;
297 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
); /* too complex */
300 case GL_SHARED_TEXTURE_PALETTE_EXT
:
301 table
= &ctx
->Texture
.Palette
;
303 case GL_TEXTURE_COLOR_TABLE_SGI
:
304 if (!ctx
->Extensions
.SGI_texture_color_table
) {
305 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTable(target)");
308 table
= &(texUnit
->ColorTable
);
309 scale
= ctx
->Pixel
.TextureColorTableScale
;
310 bias
= ctx
->Pixel
.TextureColorTableBias
;
312 case GL_PROXY_TEXTURE_COLOR_TABLE_SGI
:
313 if (!ctx
->Extensions
.SGI_texture_color_table
) {
314 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTable(target)");
317 table
= &(texUnit
->ProxyColorTable
);
321 /* try texture targets */
323 struct gl_texture_object
*texobj
324 = _mesa_select_tex_object(ctx
, texUnit
, target
);
326 table
= &texobj
->Palette
;
327 proxy
= _mesa_is_proxy_texture(target
);
330 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTable(target)");
338 if (!_mesa_is_legal_format_and_type(ctx
, format
, type
) ||
339 format
== GL_INTENSITY
) {
340 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glColorTable(format or type)");
344 baseFormat
= base_colortab_format(internalFormat
);
345 if (baseFormat
< 0) {
346 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTable(internalFormat)");
350 if (width
< 0 || (width
!= 0 && !_mesa_is_pow_two(width
))) {
354 table
->InternalFormat
= (GLenum
) 0;
355 table
->_BaseFormat
= (GLenum
) 0;
358 _mesa_error(ctx
, GL_INVALID_VALUE
, "glColorTable(width=%d)", width
);
363 if (width
> (GLsizei
) ctx
->Const
.MaxColorTableSize
) {
366 table
->InternalFormat
= (GLenum
) 0;
367 table
->_BaseFormat
= (GLenum
) 0;
370 _mesa_error(ctx
, GL_TABLE_TOO_LARGE
, "glColorTable(width)");
376 table
->InternalFormat
= internalFormat
;
377 table
->_BaseFormat
= (GLenum
) baseFormat
;
379 comps
= _mesa_components_in_format(table
->_BaseFormat
);
380 assert(comps
> 0); /* error should have been caught sooner */
383 _mesa_free_colortable_data(table
);
386 table
->TableF
= (GLfloat
*) malloc(comps
* width
* sizeof(GLfloat
));
387 table
->TableUB
= (GLubyte
*) malloc(comps
* width
* sizeof(GLubyte
));
389 if (!table
->TableF
|| !table
->TableUB
) {
390 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glColorTable");
394 store_colortable_entries(ctx
, table
,
395 0, width
, /* start, count */
404 /* do this after the table's Type and Format are set */
405 set_component_sizes(table
);
407 if (texObj
|| target
== GL_SHARED_TEXTURE_PALETTE_EXT
) {
408 /* texture object palette, texObj==NULL means the shared palette */
409 if (ctx
->Driver
.UpdateTexturePalette
) {
410 (*ctx
->Driver
.UpdateTexturePalette
)( ctx
, texObj
);
414 ctx
->NewState
|= _NEW_PIXEL
;
420 _mesa_ColorSubTable( GLenum target
, GLsizei start
,
421 GLsizei count
, GLenum format
, GLenum type
,
424 static const GLfloat one
[4] = { 1.0, 1.0, 1.0, 1.0 };
425 static const GLfloat zero
[4] = { 0.0, 0.0, 0.0, 0.0 };
426 GET_CURRENT_CONTEXT(ctx
);
427 struct gl_texture_unit
*texUnit
= _mesa_get_current_tex_unit(ctx
);
428 struct gl_texture_object
*texObj
= NULL
;
429 struct gl_color_table
*table
= NULL
;
430 const GLfloat
*scale
= one
, *bias
= zero
;
432 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
435 case GL_SHARED_TEXTURE_PALETTE_EXT
:
436 table
= &ctx
->Texture
.Palette
;
438 case GL_TEXTURE_COLOR_TABLE_SGI
:
439 if (!ctx
->Extensions
.SGI_texture_color_table
) {
440 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorSubTable(target)");
443 table
= &(texUnit
->ColorTable
);
444 scale
= ctx
->Pixel
.TextureColorTableScale
;
445 bias
= ctx
->Pixel
.TextureColorTableBias
;
448 /* try texture targets */
449 texObj
= _mesa_select_tex_object(ctx
, texUnit
, target
);
450 if (texObj
&& !_mesa_is_proxy_texture(target
)) {
451 table
= &texObj
->Palette
;
454 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorSubTable(target)");
461 if (!_mesa_is_legal_format_and_type(ctx
, format
, type
) ||
462 format
== GL_INTENSITY
) {
463 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glColorSubTable(format or type)");
468 _mesa_error(ctx
, GL_INVALID_VALUE
, "glColorSubTable(count)");
472 /* error should have been caught sooner */
473 assert(_mesa_components_in_format(table
->_BaseFormat
) > 0);
475 if (start
+ count
> (GLint
) table
->Size
) {
476 _mesa_error(ctx
, GL_INVALID_VALUE
, "glColorSubTable(count)");
480 if (!table
->TableF
|| !table
->TableUB
) {
481 /* a GL_OUT_OF_MEMORY error would have been recorded previously */
485 store_colortable_entries(ctx
, table
, start
, count
,
492 if (texObj
|| target
== GL_SHARED_TEXTURE_PALETTE_EXT
) {
493 /* per-texture object palette */
494 if (ctx
->Driver
.UpdateTexturePalette
) {
495 (*ctx
->Driver
.UpdateTexturePalette
)( ctx
, texObj
);
499 ctx
->NewState
|= _NEW_PIXEL
;
504 static void GLAPIENTRY
505 _mesa_CopyColorTable(GLenum target
, GLenum internalformat
,
506 GLint x
, GLint y
, GLsizei width
)
508 GET_CURRENT_CONTEXT(ctx
);
509 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
511 if (!ctx
->ReadBuffer
->_ColorReadBuffer
) {
512 return; /* no readbuffer - OK */
515 ctx
->Driver
.CopyColorTable( ctx
, target
, internalformat
, x
, y
, width
);
520 static void GLAPIENTRY
521 _mesa_CopyColorSubTable(GLenum target
, GLsizei start
,
522 GLint x
, GLint y
, GLsizei width
)
524 GET_CURRENT_CONTEXT(ctx
);
525 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
527 if (!ctx
->ReadBuffer
->_ColorReadBuffer
) {
528 return; /* no readbuffer - OK */
531 ctx
->Driver
.CopyColorSubTable( ctx
, target
, start
, x
, y
, width
);
536 static void GLAPIENTRY
537 _mesa_GetColorTable( GLenum target
, GLenum format
,
538 GLenum type
, GLvoid
*data
)
540 GET_CURRENT_CONTEXT(ctx
);
541 struct gl_texture_unit
*texUnit
= _mesa_get_current_tex_unit(ctx
);
542 struct gl_color_table
*table
= NULL
;
543 GLfloat rgba
[MAX_COLOR_TABLE_SIZE
][4];
544 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
547 _mesa_update_state(ctx
);
551 case GL_SHARED_TEXTURE_PALETTE_EXT
:
552 table
= &ctx
->Texture
.Palette
;
554 case GL_TEXTURE_COLOR_TABLE_SGI
:
555 if (!ctx
->Extensions
.SGI_texture_color_table
) {
556 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTable(target)");
559 table
= &(texUnit
->ColorTable
);
562 /* try texture targets */
564 struct gl_texture_object
*texobj
565 = _mesa_select_tex_object(ctx
, texUnit
, target
);
566 if (texobj
&& !_mesa_is_proxy_texture(target
)) {
567 table
= &texobj
->Palette
;
570 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTable(target)");
578 if (table
->Size
<= 0) {
582 switch (table
->_BaseFormat
) {
586 for (i
= 0; i
< table
->Size
; i
++) {
590 rgba
[i
][ACOMP
] = table
->TableF
[i
];
597 for (i
= 0; i
< table
->Size
; i
++) {
600 rgba
[i
][BCOMP
] = table
->TableF
[i
];
601 rgba
[i
][ACOMP
] = 1.0F
;
605 case GL_LUMINANCE_ALPHA
:
608 for (i
= 0; i
< table
->Size
; i
++) {
611 rgba
[i
][BCOMP
] = table
->TableF
[i
*2+0];
612 rgba
[i
][ACOMP
] = table
->TableF
[i
*2+1];
619 for (i
= 0; i
< table
->Size
; i
++) {
623 rgba
[i
][ACOMP
] = table
->TableF
[i
];
630 for (i
= 0; i
< table
->Size
; i
++) {
631 rgba
[i
][RCOMP
] = table
->TableF
[i
*3+0];
632 rgba
[i
][GCOMP
] = table
->TableF
[i
*3+1];
633 rgba
[i
][BCOMP
] = table
->TableF
[i
*3+2];
634 rgba
[i
][ACOMP
] = 1.0F
;
639 memcpy(rgba
, table
->TableF
, 4 * table
->Size
* sizeof(GLfloat
));
642 _mesa_problem(ctx
, "bad table format in glGetColorTable");
646 data
= _mesa_map_validate_pbo_dest(ctx
,
647 1, &ctx
->Pack
, table
->Size
, 1, 1,
653 _mesa_pack_rgba_span_float(ctx
, table
->Size
, rgba
,
654 format
, type
, data
, &ctx
->Pack
, 0x0);
656 _mesa_unmap_pbo_dest(ctx
, &ctx
->Pack
);
661 static void GLAPIENTRY
662 _mesa_ColorTableParameterfv(GLenum target
, GLenum pname
, const GLfloat
*params
)
664 GLfloat
*scale
, *bias
;
665 GET_CURRENT_CONTEXT(ctx
);
666 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
669 case GL_TEXTURE_COLOR_TABLE_SGI
:
670 scale
= ctx
->Pixel
.TextureColorTableScale
;
671 bias
= ctx
->Pixel
.TextureColorTableBias
;
674 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTableParameter(target)");
678 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
679 COPY_4V(scale
, params
);
681 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
682 COPY_4V(bias
, params
);
685 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTableParameterfv(pname)");
689 ctx
->NewState
|= _NEW_PIXEL
;
694 static void GLAPIENTRY
695 _mesa_ColorTableParameteriv(GLenum target
, GLenum pname
, const GLint
*params
)
698 if (pname
== GL_TEXTURE_COLOR_TABLE_SGI
) {
700 fparams
[0] = (GLfloat
) params
[0];
701 fparams
[1] = (GLfloat
) params
[1];
702 fparams
[2] = (GLfloat
) params
[2];
703 fparams
[3] = (GLfloat
) params
[3];
707 fparams
[0] = (GLfloat
) params
[0];
709 _mesa_ColorTableParameterfv(target
, pname
, fparams
);
714 static void GLAPIENTRY
715 _mesa_GetColorTableParameterfv( GLenum target
, GLenum pname
, GLfloat
*params
)
717 GET_CURRENT_CONTEXT(ctx
);
718 struct gl_texture_unit
*texUnit
= _mesa_get_current_tex_unit(ctx
);
719 struct gl_color_table
*table
= NULL
;
720 ASSERT_OUTSIDE_BEGIN_END(ctx
);
723 case GL_SHARED_TEXTURE_PALETTE_EXT
:
724 table
= &ctx
->Texture
.Palette
;
726 case GL_TEXTURE_COLOR_TABLE_SGI
:
727 if (!ctx
->Extensions
.SGI_texture_color_table
) {
728 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameter(target)");
731 table
= &(texUnit
->ColorTable
);
732 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
733 COPY_4V(params
, ctx
->Pixel
.TextureColorTableScale
);
736 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
737 COPY_4V(params
, ctx
->Pixel
.TextureColorTableBias
);
741 case GL_PROXY_TEXTURE_COLOR_TABLE_SGI
:
742 if (!ctx
->Extensions
.SGI_texture_color_table
) {
743 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameter(target)");
746 table
= &(texUnit
->ProxyColorTable
);
749 /* try texture targets */
751 struct gl_texture_object
*texobj
752 = _mesa_select_tex_object(ctx
, texUnit
, target
);
754 table
= &texobj
->Palette
;
757 _mesa_error(ctx
, GL_INVALID_ENUM
,
758 "glGetColorTableParameterfv(target)");
767 case GL_COLOR_TABLE_FORMAT
:
768 *params
= (GLfloat
) table
->InternalFormat
;
770 case GL_COLOR_TABLE_WIDTH
:
771 *params
= (GLfloat
) table
->Size
;
773 case GL_COLOR_TABLE_RED_SIZE
:
774 *params
= (GLfloat
) table
->RedSize
;
776 case GL_COLOR_TABLE_GREEN_SIZE
:
777 *params
= (GLfloat
) table
->GreenSize
;
779 case GL_COLOR_TABLE_BLUE_SIZE
:
780 *params
= (GLfloat
) table
->BlueSize
;
782 case GL_COLOR_TABLE_ALPHA_SIZE
:
783 *params
= (GLfloat
) table
->AlphaSize
;
785 case GL_COLOR_TABLE_LUMINANCE_SIZE
:
786 *params
= (GLfloat
) table
->LuminanceSize
;
788 case GL_COLOR_TABLE_INTENSITY_SIZE
:
789 *params
= (GLfloat
) table
->IntensitySize
;
792 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameterfv(pname)" );
799 static void GLAPIENTRY
800 _mesa_GetColorTableParameteriv( GLenum target
, GLenum pname
, GLint
*params
)
802 GET_CURRENT_CONTEXT(ctx
);
803 struct gl_texture_unit
*texUnit
= _mesa_get_current_tex_unit(ctx
);
804 struct gl_color_table
*table
= NULL
;
805 ASSERT_OUTSIDE_BEGIN_END(ctx
);
808 case GL_SHARED_TEXTURE_PALETTE_EXT
:
809 table
= &ctx
->Texture
.Palette
;
811 case GL_TEXTURE_COLOR_TABLE_SGI
:
812 if (!ctx
->Extensions
.SGI_texture_color_table
) {
813 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameter(target)");
816 table
= &(texUnit
->ColorTable
);
817 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
818 params
[0] = (GLint
) ctx
->Pixel
.TextureColorTableScale
[0];
819 params
[1] = (GLint
) ctx
->Pixel
.TextureColorTableScale
[1];
820 params
[2] = (GLint
) ctx
->Pixel
.TextureColorTableScale
[2];
821 params
[3] = (GLint
) ctx
->Pixel
.TextureColorTableScale
[3];
824 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
825 params
[0] = (GLint
) ctx
->Pixel
.TextureColorTableBias
[0];
826 params
[1] = (GLint
) ctx
->Pixel
.TextureColorTableBias
[1];
827 params
[2] = (GLint
) ctx
->Pixel
.TextureColorTableBias
[2];
828 params
[3] = (GLint
) ctx
->Pixel
.TextureColorTableBias
[3];
832 case GL_PROXY_TEXTURE_COLOR_TABLE_SGI
:
833 if (!ctx
->Extensions
.SGI_texture_color_table
) {
834 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameter(target)");
837 table
= &(texUnit
->ProxyColorTable
);
840 /* Try texture targets */
842 struct gl_texture_object
*texobj
843 = _mesa_select_tex_object(ctx
, texUnit
, target
);
845 table
= &texobj
->Palette
;
848 _mesa_error(ctx
, GL_INVALID_ENUM
,
849 "glGetColorTableParameteriv(target)");
858 case GL_COLOR_TABLE_FORMAT
:
859 *params
= table
->InternalFormat
;
861 case GL_COLOR_TABLE_WIDTH
:
862 *params
= table
->Size
;
864 case GL_COLOR_TABLE_RED_SIZE
:
865 *params
= table
->RedSize
;
867 case GL_COLOR_TABLE_GREEN_SIZE
:
868 *params
= table
->GreenSize
;
870 case GL_COLOR_TABLE_BLUE_SIZE
:
871 *params
= table
->BlueSize
;
873 case GL_COLOR_TABLE_ALPHA_SIZE
:
874 *params
= table
->AlphaSize
;
876 case GL_COLOR_TABLE_LUMINANCE_SIZE
:
877 *params
= table
->LuminanceSize
;
879 case GL_COLOR_TABLE_INTENSITY_SIZE
:
880 *params
= table
->IntensitySize
;
883 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameteriv(pname)" );
890 _mesa_init_colortable_dispatch(struct _glapi_table
*disp
)
892 SET_ColorSubTable(disp
, _mesa_ColorSubTable
);
893 SET_ColorTable(disp
, _mesa_ColorTable
);
894 SET_ColorTableParameterfv(disp
, _mesa_ColorTableParameterfv
);
895 SET_ColorTableParameteriv(disp
, _mesa_ColorTableParameteriv
);
896 SET_CopyColorSubTable(disp
, _mesa_CopyColorSubTable
);
897 SET_CopyColorTable(disp
, _mesa_CopyColorTable
);
898 SET_GetColorTable(disp
, _mesa_GetColorTable
);
899 SET_GetColorTableParameterfv(disp
, _mesa_GetColorTableParameterfv
);
900 SET_GetColorTableParameteriv(disp
, _mesa_GetColorTableParameteriv
);
904 #endif /* FEATURE_colortable */
907 /**********************************************************************/
908 /***** Initialization *****/
909 /**********************************************************************/
913 _mesa_init_colortable( struct gl_color_table
*p
)
918 p
->InternalFormat
= GL_RGBA
;
924 _mesa_free_colortable_data( struct gl_color_table
*p
)