2 * Mesa 3-D graphics library
5 * Copyright (C) 1999-2004 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
= sizeof(GLubyte
);
107 case GL_UNSIGNED_SHORT
:
108 sz
= sizeof(GLushort
);
111 sz
= sizeof(GLfloat
);
114 _mesa_problem(NULL
, "bad color table type in set_component_sizes 0x%x", table
->Type
);
118 switch (table
->Format
) {
121 table
->GreenSize
= 0;
123 table
->AlphaSize
= sz
;
124 table
->IntensitySize
= 0;
125 table
->LuminanceSize
= 0;
129 table
->GreenSize
= 0;
131 table
->AlphaSize
= 0;
132 table
->IntensitySize
= 0;
133 table
->LuminanceSize
= sz
;
135 case GL_LUMINANCE_ALPHA
:
137 table
->GreenSize
= 0;
139 table
->AlphaSize
= sz
;
140 table
->IntensitySize
= 0;
141 table
->LuminanceSize
= sz
;
145 table
->GreenSize
= 0;
147 table
->AlphaSize
= 0;
148 table
->IntensitySize
= sz
;
149 table
->LuminanceSize
= 0;
153 table
->GreenSize
= sz
;
154 table
->BlueSize
= sz
;
155 table
->AlphaSize
= 0;
156 table
->IntensitySize
= 0;
157 table
->LuminanceSize
= 0;
161 table
->GreenSize
= sz
;
162 table
->BlueSize
= sz
;
163 table
->AlphaSize
= sz
;
164 table
->IntensitySize
= 0;
165 table
->LuminanceSize
= 0;
168 _mesa_problem(NULL
, "unexpected format in set_component_sizes");
175 * Update/replace all or part of a color table. Helper function
176 * used by _mesa_ColorTable() and _mesa_ColorSubTable().
177 * The table->Table buffer should already be allocated.
178 * \param start first entry to update
179 * \param count number of entries to update
180 * \param format format of user-provided table data
181 * \param type datatype of user-provided table data
182 * \param data user-provided table data
183 * \param [rgba]Scale - RGBA scale factors
184 * \param [rgba]Bias - RGBA bias factors
187 store_colortable_entries(GLcontext
*ctx
, struct gl_color_table
*table
,
188 GLsizei start
, GLsizei count
,
189 GLenum format
, GLenum type
, const GLvoid
*data
,
190 GLfloat rScale
, GLfloat rBias
,
191 GLfloat gScale
, GLfloat gBias
,
192 GLfloat bScale
, GLfloat bBias
,
193 GLfloat aScale
, GLfloat aBias
)
195 if (ctx
->Unpack
.BufferObj
->Name
) {
196 /* Get/unpack the color table data from a PBO */
198 if (!_mesa_validate_pbo_access(1, &ctx
->Unpack
, count
, 1, 1,
199 format
, type
, data
)) {
200 _mesa_error(ctx
, GL_INVALID_OPERATION
,
201 "glColor[Sub]Table(bad PBO access)");
204 buf
= (GLubyte
*) ctx
->Driver
.MapBuffer(ctx
, GL_PIXEL_UNPACK_BUFFER_EXT
,
206 ctx
->Unpack
.BufferObj
);
208 _mesa_error(ctx
, GL_INVALID_OPERATION
,
209 "glColor[Sub]Table(PBO mapped)");
212 data
= ADD_POINTERS(buf
, data
);
216 if (table
->Type
== GL_FLOAT
) {
217 /* convert user-provided data to GLfloat values */
218 GLfloat tempTab
[MAX_COLOR_TABLE_SIZE
* 4];
222 _mesa_unpack_color_span_float(ctx
,
223 count
, /* number of pixels */
224 table
->Format
, /* dest format */
225 tempTab
, /* dest address */
226 format
, type
, /* src format/type */
229 IMAGE_CLAMP_BIT
); /* transfer ops */
231 /* the destination */
232 tableF
= (GLfloat
*) table
->Table
;
234 /* Apply scale & bias & clamp now */
235 switch (table
->Format
) {
237 for (i
= 0; i
< count
; i
++) {
238 GLuint j
= start
+ i
;
239 tableF
[j
] = CLAMP(tempTab
[i
] * rScale
+ rBias
, 0.0F
, 1.0F
);
243 for (i
= 0; i
< count
; i
++) {
244 GLuint j
= start
+ i
;
245 tableF
[j
] = CLAMP(tempTab
[i
] * rScale
+ rBias
, 0.0F
, 1.0F
);
249 for (i
= 0; i
< count
; i
++) {
250 GLuint j
= start
+ i
;
251 tableF
[j
] = CLAMP(tempTab
[i
] * aScale
+ aBias
, 0.0F
, 1.0F
);
254 case GL_LUMINANCE_ALPHA
:
255 for (i
= 0; i
< count
; i
++) {
256 GLuint j
= start
+ i
;
257 tableF
[j
*2+0] = CLAMP(tempTab
[i
*2+0] * rScale
+ rBias
, 0.0F
, 1.0F
);
258 tableF
[j
*2+1] = CLAMP(tempTab
[i
*2+1] * aScale
+ aBias
, 0.0F
, 1.0F
);
262 for (i
= 0; i
< count
; i
++) {
263 GLuint j
= start
+ i
;
264 tableF
[j
*3+0] = CLAMP(tempTab
[i
*3+0] * rScale
+ rBias
, 0.0F
, 1.0F
);
265 tableF
[j
*3+1] = CLAMP(tempTab
[i
*3+1] * gScale
+ gBias
, 0.0F
, 1.0F
);
266 tableF
[j
*3+2] = CLAMP(tempTab
[i
*3+2] * bScale
+ bBias
, 0.0F
, 1.0F
);
270 for (i
= 0; i
< count
; i
++) {
271 GLuint j
= start
+ i
;
272 tableF
[j
*4+0] = CLAMP(tempTab
[i
*4+0] * rScale
+ rBias
, 0.0F
, 1.0F
);
273 tableF
[j
*4+1] = CLAMP(tempTab
[i
*4+1] * gScale
+ gBias
, 0.0F
, 1.0F
);
274 tableF
[j
*4+2] = CLAMP(tempTab
[i
*4+2] * bScale
+ bBias
, 0.0F
, 1.0F
);
275 tableF
[j
*4+3] = CLAMP(tempTab
[i
*4+3] * aScale
+ aBias
, 0.0F
, 1.0F
);
279 _mesa_problem(ctx
, "Bad format in store_colortable_entries");
284 /* non-float (GLchan) */
285 const GLint comps
= _mesa_components_in_format(table
->Format
);
286 GLchan
*dest
= (GLchan
*) table
->Table
+ start
* comps
;
287 _mesa_unpack_color_span_chan(ctx
, count
, /* number of entries */
288 table
->Format
, /* dest format */
289 dest
, /* dest address */
290 format
, type
, data
, /* src data */
292 0); /* transfer ops */
295 if (ctx
->Unpack
.BufferObj
->Name
) {
296 ctx
->Driver
.UnmapBuffer(ctx
, GL_PIXEL_UNPACK_BUFFER_EXT
,
297 ctx
->Unpack
.BufferObj
);
304 _mesa_ColorTable( GLenum target
, GLenum internalFormat
,
305 GLsizei width
, GLenum format
, GLenum type
,
308 GET_CURRENT_CONTEXT(ctx
);
309 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
310 struct gl_texture_object
*texObj
= NULL
;
311 struct gl_color_table
*table
= NULL
;
312 GLboolean proxy
= GL_FALSE
;
314 GLfloat rScale
= 1.0, gScale
= 1.0, bScale
= 1.0, aScale
= 1.0;
315 GLfloat rBias
= 0.0, gBias
= 0.0, bBias
= 0.0, aBias
= 0.0;
316 GLenum tableType
= CHAN_TYPE
;
318 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
); /* too complex */
322 texObj
= texUnit
->Current1D
;
323 table
= &texObj
->Palette
;
326 texObj
= texUnit
->Current2D
;
327 table
= &texObj
->Palette
;
330 texObj
= texUnit
->Current3D
;
331 table
= &texObj
->Palette
;
333 case GL_TEXTURE_CUBE_MAP_ARB
:
334 if (!ctx
->Extensions
.ARB_texture_cube_map
) {
335 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTable(target)");
338 texObj
= texUnit
->CurrentCubeMap
;
339 table
= &texObj
->Palette
;
341 case GL_PROXY_TEXTURE_1D
:
342 texObj
= ctx
->Texture
.Proxy1D
;
343 table
= &texObj
->Palette
;
346 case GL_PROXY_TEXTURE_2D
:
347 texObj
= ctx
->Texture
.Proxy2D
;
348 table
= &texObj
->Palette
;
351 case GL_PROXY_TEXTURE_3D
:
352 texObj
= ctx
->Texture
.Proxy3D
;
353 table
= &texObj
->Palette
;
356 case GL_PROXY_TEXTURE_CUBE_MAP_ARB
:
357 if (!ctx
->Extensions
.ARB_texture_cube_map
) {
358 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTable(target)");
361 texObj
= ctx
->Texture
.ProxyCubeMap
;
362 table
= &texObj
->Palette
;
364 case GL_SHARED_TEXTURE_PALETTE_EXT
:
365 table
= &ctx
->Texture
.Palette
;
368 table
= &ctx
->ColorTable
;
369 tableType
= GL_FLOAT
;
370 rScale
= ctx
->Pixel
.ColorTableScale
[0];
371 gScale
= ctx
->Pixel
.ColorTableScale
[1];
372 bScale
= ctx
->Pixel
.ColorTableScale
[2];
373 aScale
= ctx
->Pixel
.ColorTableScale
[3];
374 rBias
= ctx
->Pixel
.ColorTableBias
[0];
375 gBias
= ctx
->Pixel
.ColorTableBias
[1];
376 bBias
= ctx
->Pixel
.ColorTableBias
[2];
377 aBias
= ctx
->Pixel
.ColorTableBias
[3];
379 case GL_PROXY_COLOR_TABLE
:
380 table
= &ctx
->ProxyColorTable
;
383 case GL_TEXTURE_COLOR_TABLE_SGI
:
384 if (!ctx
->Extensions
.SGI_texture_color_table
) {
385 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTable(target)");
388 table
= &(texUnit
->ColorTable
);
389 tableType
= GL_FLOAT
;
390 rScale
= ctx
->Pixel
.TextureColorTableScale
[0];
391 gScale
= ctx
->Pixel
.TextureColorTableScale
[1];
392 bScale
= ctx
->Pixel
.TextureColorTableScale
[2];
393 aScale
= ctx
->Pixel
.TextureColorTableScale
[3];
394 rBias
= ctx
->Pixel
.TextureColorTableBias
[0];
395 gBias
= ctx
->Pixel
.TextureColorTableBias
[1];
396 bBias
= ctx
->Pixel
.TextureColorTableBias
[2];
397 aBias
= ctx
->Pixel
.TextureColorTableBias
[3];
399 case GL_PROXY_TEXTURE_COLOR_TABLE_SGI
:
400 if (!ctx
->Extensions
.SGI_texture_color_table
) {
401 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTable(target)");
404 table
= &(texUnit
->ProxyColorTable
);
407 case GL_POST_CONVOLUTION_COLOR_TABLE
:
408 table
= &ctx
->PostConvolutionColorTable
;
409 tableType
= GL_FLOAT
;
410 rScale
= ctx
->Pixel
.PCCTscale
[0];
411 gScale
= ctx
->Pixel
.PCCTscale
[1];
412 bScale
= ctx
->Pixel
.PCCTscale
[2];
413 aScale
= ctx
->Pixel
.PCCTscale
[3];
414 rBias
= ctx
->Pixel
.PCCTbias
[0];
415 gBias
= ctx
->Pixel
.PCCTbias
[1];
416 bBias
= ctx
->Pixel
.PCCTbias
[2];
417 aBias
= ctx
->Pixel
.PCCTbias
[3];
419 case GL_PROXY_POST_CONVOLUTION_COLOR_TABLE
:
420 table
= &ctx
->ProxyPostConvolutionColorTable
;
423 case GL_POST_COLOR_MATRIX_COLOR_TABLE
:
424 table
= &ctx
->PostColorMatrixColorTable
;
425 tableType
= GL_FLOAT
;
426 rScale
= ctx
->Pixel
.PCMCTscale
[0];
427 gScale
= ctx
->Pixel
.PCMCTscale
[1];
428 bScale
= ctx
->Pixel
.PCMCTscale
[2];
429 aScale
= ctx
->Pixel
.PCMCTscale
[3];
430 rBias
= ctx
->Pixel
.PCMCTbias
[0];
431 gBias
= ctx
->Pixel
.PCMCTbias
[1];
432 bBias
= ctx
->Pixel
.PCMCTbias
[2];
433 aBias
= ctx
->Pixel
.PCMCTbias
[3];
435 case GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE
:
436 table
= &ctx
->ProxyPostColorMatrixColorTable
;
440 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTable(target)");
446 if (!_mesa_is_legal_format_and_type(ctx
, format
, type
) ||
447 format
== GL_INTENSITY
) {
448 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glColorTable(format or type)");
452 baseFormat
= base_colortab_format(internalFormat
);
453 if (baseFormat
< 0 || baseFormat
== GL_COLOR_INDEX
) {
454 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTable(internalFormat)");
458 if (width
< 0 || (width
!= 0 && _mesa_bitcount(width
) != 1)) {
462 table
->IntFormat
= (GLenum
) 0;
463 table
->Format
= (GLenum
) 0;
466 _mesa_error(ctx
, GL_INVALID_VALUE
, "glColorTable(width=%d)", width
);
471 if (width
> (GLsizei
) ctx
->Const
.MaxColorTableSize
) {
474 table
->IntFormat
= (GLenum
) 0;
475 table
->Format
= (GLenum
) 0;
478 _mesa_error(ctx
, GL_TABLE_TOO_LARGE
, "glColorTable(width)");
484 table
->IntFormat
= internalFormat
;
485 table
->Format
= (GLenum
) baseFormat
;
486 set_component_sizes(table
);
488 comps
= _mesa_components_in_format(table
->Format
);
489 assert(comps
> 0); /* error should have been caught sooner */
492 /* free old table, if any */
499 if (tableType
== GL_FLOAT
) {
500 table
->Type
= GL_FLOAT
;
501 table
->Table
= MALLOC(comps
* width
* sizeof(GLfloat
));
504 table
->Type
= CHAN_TYPE
;
505 table
->Table
= MALLOC(comps
* width
* sizeof(GLchan
));
509 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glColorTable");
513 store_colortable_entries(ctx
, table
,
514 0, width
, /* start, count */
523 if (texObj
|| target
== GL_SHARED_TEXTURE_PALETTE_EXT
) {
524 /* texture object palette, texObj==NULL means the shared palette */
525 if (ctx
->Driver
.UpdateTexturePalette
) {
526 (*ctx
->Driver
.UpdateTexturePalette
)( ctx
, texObj
);
530 ctx
->NewState
|= _NEW_PIXEL
;
536 _mesa_ColorSubTable( GLenum target
, GLsizei start
,
537 GLsizei count
, GLenum format
, GLenum type
,
540 GET_CURRENT_CONTEXT(ctx
);
541 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
542 struct gl_texture_object
*texObj
= NULL
;
543 struct gl_color_table
*table
= NULL
;
544 GLfloat rScale
= 1.0, gScale
= 1.0, bScale
= 1.0, aScale
= 1.0;
545 GLfloat rBias
= 0.0, gBias
= 0.0, bBias
= 0.0, aBias
= 0.0;
547 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
551 texObj
= texUnit
->Current1D
;
552 table
= &texObj
->Palette
;
555 texObj
= texUnit
->Current2D
;
556 table
= &texObj
->Palette
;
559 texObj
= texUnit
->Current3D
;
560 table
= &texObj
->Palette
;
562 case GL_TEXTURE_CUBE_MAP_ARB
:
563 if (!ctx
->Extensions
.ARB_texture_cube_map
) {
564 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorSubTable(target)");
567 texObj
= texUnit
->CurrentCubeMap
;
568 table
= &texObj
->Palette
;
570 case GL_SHARED_TEXTURE_PALETTE_EXT
:
571 table
= &ctx
->Texture
.Palette
;
574 table
= &ctx
->ColorTable
;
575 rScale
= ctx
->Pixel
.ColorTableScale
[0];
576 gScale
= ctx
->Pixel
.ColorTableScale
[1];
577 bScale
= ctx
->Pixel
.ColorTableScale
[2];
578 aScale
= ctx
->Pixel
.ColorTableScale
[3];
579 rBias
= ctx
->Pixel
.ColorTableBias
[0];
580 gBias
= ctx
->Pixel
.ColorTableBias
[1];
581 bBias
= ctx
->Pixel
.ColorTableBias
[2];
582 aBias
= ctx
->Pixel
.ColorTableBias
[3];
584 case GL_TEXTURE_COLOR_TABLE_SGI
:
585 if (!ctx
->Extensions
.SGI_texture_color_table
) {
586 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorSubTable(target)");
589 table
= &(texUnit
->ColorTable
);
590 rScale
= ctx
->Pixel
.TextureColorTableScale
[0];
591 gScale
= ctx
->Pixel
.TextureColorTableScale
[1];
592 bScale
= ctx
->Pixel
.TextureColorTableScale
[2];
593 aScale
= ctx
->Pixel
.TextureColorTableScale
[3];
594 rBias
= ctx
->Pixel
.TextureColorTableBias
[0];
595 gBias
= ctx
->Pixel
.TextureColorTableBias
[1];
596 bBias
= ctx
->Pixel
.TextureColorTableBias
[2];
597 aBias
= ctx
->Pixel
.TextureColorTableBias
[3];
599 case GL_POST_CONVOLUTION_COLOR_TABLE
:
600 table
= &ctx
->PostConvolutionColorTable
;
601 rScale
= ctx
->Pixel
.PCCTscale
[0];
602 gScale
= ctx
->Pixel
.PCCTscale
[1];
603 bScale
= ctx
->Pixel
.PCCTscale
[2];
604 aScale
= ctx
->Pixel
.PCCTscale
[3];
605 rBias
= ctx
->Pixel
.PCCTbias
[0];
606 gBias
= ctx
->Pixel
.PCCTbias
[1];
607 bBias
= ctx
->Pixel
.PCCTbias
[2];
608 aBias
= ctx
->Pixel
.PCCTbias
[3];
610 case GL_POST_COLOR_MATRIX_COLOR_TABLE
:
611 table
= &ctx
->PostColorMatrixColorTable
;
612 rScale
= ctx
->Pixel
.PCMCTscale
[0];
613 gScale
= ctx
->Pixel
.PCMCTscale
[1];
614 bScale
= ctx
->Pixel
.PCMCTscale
[2];
615 aScale
= ctx
->Pixel
.PCMCTscale
[3];
616 rBias
= ctx
->Pixel
.PCMCTbias
[0];
617 gBias
= ctx
->Pixel
.PCMCTbias
[1];
618 bBias
= ctx
->Pixel
.PCMCTbias
[2];
619 aBias
= ctx
->Pixel
.PCMCTbias
[3];
622 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorSubTable(target)");
628 if (!_mesa_is_legal_format_and_type(ctx
, format
, type
) ||
629 format
== GL_INTENSITY
) {
630 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glColorSubTable(format or type)");
635 _mesa_error(ctx
, GL_INVALID_VALUE
, "glColorSubTable(count)");
639 comps
= _mesa_components_in_format(table
->Format
);
640 assert(comps
> 0); /* error should have been caught sooner */
642 if (start
+ count
> (GLint
) table
->Size
) {
643 _mesa_error(ctx
, GL_INVALID_VALUE
, "glColorSubTable(count)");
648 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glColorSubTable");
652 store_colortable_entries(ctx
, table
, start
, count
,
659 if (texObj
|| target
== GL_SHARED_TEXTURE_PALETTE_EXT
) {
660 /* per-texture object palette */
661 if (ctx
->Driver
.UpdateTexturePalette
) {
662 (*ctx
->Driver
.UpdateTexturePalette
)( ctx
, texObj
);
666 ctx
->NewState
|= _NEW_PIXEL
;
672 _mesa_CopyColorTable(GLenum target
, GLenum internalformat
,
673 GLint x
, GLint y
, GLsizei width
)
675 GET_CURRENT_CONTEXT(ctx
);
676 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
678 /* Select buffer to read from */
679 ctx
->Driver
.CopyColorTable( ctx
, target
, internalformat
, x
, y
, width
);
685 _mesa_CopyColorSubTable(GLenum target
, GLsizei start
,
686 GLint x
, GLint y
, GLsizei width
)
688 GET_CURRENT_CONTEXT(ctx
);
689 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
691 ctx
->Driver
.CopyColorSubTable( ctx
, target
, start
, x
, y
, width
);
697 _mesa_GetColorTable( GLenum target
, GLenum format
,
698 GLenum type
, GLvoid
*data
)
700 GET_CURRENT_CONTEXT(ctx
);
701 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
702 struct gl_color_table
*table
= NULL
;
703 GLchan rgba
[MAX_COLOR_TABLE_SIZE
][4];
704 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
707 _mesa_update_state(ctx
);
712 table
= &texUnit
->Current1D
->Palette
;
715 table
= &texUnit
->Current2D
->Palette
;
718 table
= &texUnit
->Current3D
->Palette
;
720 case GL_TEXTURE_CUBE_MAP_ARB
:
721 if (!ctx
->Extensions
.ARB_texture_cube_map
) {
722 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTable(target)");
725 table
= &texUnit
->CurrentCubeMap
->Palette
;
727 case GL_SHARED_TEXTURE_PALETTE_EXT
:
728 table
= &ctx
->Texture
.Palette
;
731 table
= &ctx
->ColorTable
;
733 case GL_TEXTURE_COLOR_TABLE_SGI
:
734 if (!ctx
->Extensions
.SGI_texture_color_table
) {
735 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTable(target)");
738 table
= &(texUnit
->ColorTable
);
740 case GL_POST_CONVOLUTION_COLOR_TABLE
:
741 table
= &ctx
->PostConvolutionColorTable
;
743 case GL_POST_COLOR_MATRIX_COLOR_TABLE
:
744 table
= &ctx
->PostColorMatrixColorTable
;
747 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTable(target)");
753 switch (table
->Format
) {
755 if (table
->Type
== GL_FLOAT
) {
756 const GLfloat
*tableF
= (const GLfloat
*) table
->Table
;
758 for (i
= 0; i
< table
->Size
; i
++) {
762 rgba
[i
][ACOMP
] = IROUND_POS(tableF
[i
] * CHAN_MAXF
);
766 const GLchan
*tableUB
= (const GLchan
*) table
->Table
;
768 for (i
= 0; i
< table
->Size
; i
++) {
772 rgba
[i
][ACOMP
] = tableUB
[i
];
777 if (table
->Type
== GL_FLOAT
) {
778 const GLfloat
*tableF
= (const GLfloat
*) table
->Table
;
780 for (i
= 0; i
< table
->Size
; i
++) {
781 rgba
[i
][RCOMP
] = IROUND_POS(tableF
[i
] * CHAN_MAXF
);
782 rgba
[i
][GCOMP
] = IROUND_POS(tableF
[i
] * CHAN_MAXF
);
783 rgba
[i
][BCOMP
] = IROUND_POS(tableF
[i
] * CHAN_MAXF
);
784 rgba
[i
][ACOMP
] = CHAN_MAX
;
788 const GLchan
*tableUB
= (const GLchan
*) table
->Table
;
790 for (i
= 0; i
< table
->Size
; i
++) {
791 rgba
[i
][RCOMP
] = tableUB
[i
];
792 rgba
[i
][GCOMP
] = tableUB
[i
];
793 rgba
[i
][BCOMP
] = tableUB
[i
];
794 rgba
[i
][ACOMP
] = CHAN_MAX
;
798 case GL_LUMINANCE_ALPHA
:
799 if (table
->Type
== GL_FLOAT
) {
800 const GLfloat
*tableF
= (const GLfloat
*) table
->Table
;
802 for (i
= 0; i
< table
->Size
; i
++) {
803 rgba
[i
][RCOMP
] = IROUND_POS(tableF
[i
*2+0] * CHAN_MAXF
);
804 rgba
[i
][GCOMP
] = IROUND_POS(tableF
[i
*2+0] * CHAN_MAXF
);
805 rgba
[i
][BCOMP
] = IROUND_POS(tableF
[i
*2+0] * CHAN_MAXF
);
806 rgba
[i
][ACOMP
] = IROUND_POS(tableF
[i
*2+1] * CHAN_MAXF
);
810 const GLchan
*tableUB
= (const GLchan
*) table
->Table
;
812 for (i
= 0; i
< table
->Size
; i
++) {
813 rgba
[i
][RCOMP
] = tableUB
[i
*2+0];
814 rgba
[i
][GCOMP
] = tableUB
[i
*2+0];
815 rgba
[i
][BCOMP
] = tableUB
[i
*2+0];
816 rgba
[i
][ACOMP
] = tableUB
[i
*2+1];
821 if (table
->Type
== GL_FLOAT
) {
822 const GLfloat
*tableF
= (const GLfloat
*) table
->Table
;
824 for (i
= 0; i
< table
->Size
; i
++) {
825 rgba
[i
][RCOMP
] = IROUND_POS(tableF
[i
] * CHAN_MAXF
);
826 rgba
[i
][GCOMP
] = IROUND_POS(tableF
[i
] * CHAN_MAXF
);
827 rgba
[i
][BCOMP
] = IROUND_POS(tableF
[i
] * CHAN_MAXF
);
828 rgba
[i
][ACOMP
] = IROUND_POS(tableF
[i
] * CHAN_MAXF
);
832 const GLchan
*tableUB
= (const GLchan
*) table
->Table
;
834 for (i
= 0; i
< table
->Size
; i
++) {
835 rgba
[i
][RCOMP
] = tableUB
[i
];
836 rgba
[i
][GCOMP
] = tableUB
[i
];
837 rgba
[i
][BCOMP
] = tableUB
[i
];
838 rgba
[i
][ACOMP
] = tableUB
[i
];
843 if (table
->Type
== GL_FLOAT
) {
844 const GLfloat
*tableF
= (const GLfloat
*) table
->Table
;
846 for (i
= 0; i
< table
->Size
; i
++) {
847 rgba
[i
][RCOMP
] = IROUND_POS(tableF
[i
*3+0] * CHAN_MAXF
);
848 rgba
[i
][GCOMP
] = IROUND_POS(tableF
[i
*3+1] * CHAN_MAXF
);
849 rgba
[i
][BCOMP
] = IROUND_POS(tableF
[i
*3+2] * CHAN_MAXF
);
850 rgba
[i
][ACOMP
] = CHAN_MAX
;
854 const GLchan
*tableUB
= (const GLchan
*) table
->Table
;
856 for (i
= 0; i
< table
->Size
; i
++) {
857 rgba
[i
][RCOMP
] = tableUB
[i
*3+0];
858 rgba
[i
][GCOMP
] = tableUB
[i
*3+1];
859 rgba
[i
][BCOMP
] = tableUB
[i
*3+2];
860 rgba
[i
][ACOMP
] = CHAN_MAX
;
865 if (table
->Type
== GL_FLOAT
) {
866 const GLfloat
*tableF
= (const GLfloat
*) table
->Table
;
868 for (i
= 0; i
< table
->Size
; i
++) {
869 rgba
[i
][RCOMP
] = IROUND_POS(tableF
[i
*4+0] * CHAN_MAXF
);
870 rgba
[i
][GCOMP
] = IROUND_POS(tableF
[i
*4+1] * CHAN_MAXF
);
871 rgba
[i
][BCOMP
] = IROUND_POS(tableF
[i
*4+2] * CHAN_MAXF
);
872 rgba
[i
][ACOMP
] = IROUND_POS(tableF
[i
*4+3] * CHAN_MAXF
);
876 const GLchan
*tableUB
= (const GLchan
*) table
->Table
;
878 for (i
= 0; i
< table
->Size
; i
++) {
879 rgba
[i
][RCOMP
] = tableUB
[i
*4+0];
880 rgba
[i
][GCOMP
] = tableUB
[i
*4+1];
881 rgba
[i
][BCOMP
] = tableUB
[i
*4+2];
882 rgba
[i
][ACOMP
] = tableUB
[i
*4+3];
887 _mesa_problem(ctx
, "bad table format in glGetColorTable");
891 if (ctx
->Pack
.BufferObj
->Name
) {
892 /* pack color table into PBO */
894 if (!_mesa_validate_pbo_access(1, &ctx
->Pack
, table
->Size
, 1, 1,
895 format
, type
, data
)) {
896 _mesa_error(ctx
, GL_INVALID_OPERATION
,
897 "glGetColorTable(invalid PBO access)");
900 buf
= (GLubyte
*) ctx
->Driver
.MapBuffer(ctx
, GL_PIXEL_PACK_BUFFER_EXT
,
902 ctx
->Pack
.BufferObj
);
904 /* buffer is already mapped - that's an error */
905 _mesa_error(ctx
, GL_INVALID_OPERATION
,
906 "glGetColorTable(PBO is mapped)");
909 data
= ADD_POINTERS(buf
, data
);
912 _mesa_pack_rgba_span_chan(ctx
, table
->Size
, (const GLchan (*)[4]) rgba
,
913 format
, type
, data
, &ctx
->Pack
, GL_FALSE
);
915 if (ctx
->Pack
.BufferObj
->Name
) {
916 ctx
->Driver
.UnmapBuffer(ctx
, GL_PIXEL_PACK_BUFFER_EXT
,
917 ctx
->Pack
.BufferObj
);
924 _mesa_ColorTableParameterfv(GLenum target
, GLenum pname
, const GLfloat
*params
)
926 GET_CURRENT_CONTEXT(ctx
);
927 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
930 case GL_COLOR_TABLE_SGI
:
931 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
932 ctx
->Pixel
.ColorTableScale
[0] = params
[0];
933 ctx
->Pixel
.ColorTableScale
[1] = params
[1];
934 ctx
->Pixel
.ColorTableScale
[2] = params
[2];
935 ctx
->Pixel
.ColorTableScale
[3] = params
[3];
937 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
938 ctx
->Pixel
.ColorTableBias
[0] = params
[0];
939 ctx
->Pixel
.ColorTableBias
[1] = params
[1];
940 ctx
->Pixel
.ColorTableBias
[2] = params
[2];
941 ctx
->Pixel
.ColorTableBias
[3] = params
[3];
944 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTableParameterfv(pname)");
948 case GL_TEXTURE_COLOR_TABLE_SGI
:
949 if (!ctx
->Extensions
.SGI_texture_color_table
) {
950 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTableParameter(target)");
953 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
954 ctx
->Pixel
.TextureColorTableScale
[0] = params
[0];
955 ctx
->Pixel
.TextureColorTableScale
[1] = params
[1];
956 ctx
->Pixel
.TextureColorTableScale
[2] = params
[2];
957 ctx
->Pixel
.TextureColorTableScale
[3] = params
[3];
959 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
960 ctx
->Pixel
.TextureColorTableBias
[0] = params
[0];
961 ctx
->Pixel
.TextureColorTableBias
[1] = params
[1];
962 ctx
->Pixel
.TextureColorTableBias
[2] = params
[2];
963 ctx
->Pixel
.TextureColorTableBias
[3] = params
[3];
966 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTableParameterfv(pname)");
970 case GL_POST_CONVOLUTION_COLOR_TABLE_SGI
:
971 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
972 ctx
->Pixel
.PCCTscale
[0] = params
[0];
973 ctx
->Pixel
.PCCTscale
[1] = params
[1];
974 ctx
->Pixel
.PCCTscale
[2] = params
[2];
975 ctx
->Pixel
.PCCTscale
[3] = params
[3];
977 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
978 ctx
->Pixel
.PCCTbias
[0] = params
[0];
979 ctx
->Pixel
.PCCTbias
[1] = params
[1];
980 ctx
->Pixel
.PCCTbias
[2] = params
[2];
981 ctx
->Pixel
.PCCTbias
[3] = params
[3];
984 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTableParameterfv(pname)");
988 case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI
:
989 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
990 ctx
->Pixel
.PCMCTscale
[0] = params
[0];
991 ctx
->Pixel
.PCMCTscale
[1] = params
[1];
992 ctx
->Pixel
.PCMCTscale
[2] = params
[2];
993 ctx
->Pixel
.PCMCTscale
[3] = params
[3];
995 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
996 ctx
->Pixel
.PCMCTbias
[0] = params
[0];
997 ctx
->Pixel
.PCMCTbias
[1] = params
[1];
998 ctx
->Pixel
.PCMCTbias
[2] = params
[2];
999 ctx
->Pixel
.PCMCTbias
[3] = params
[3];
1002 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTableParameterfv(pname)");
1007 _mesa_error(ctx
, GL_INVALID_ENUM
, "glColorTableParameter(target)");
1011 ctx
->NewState
|= _NEW_PIXEL
;
1017 _mesa_ColorTableParameteriv(GLenum target
, GLenum pname
, const GLint
*params
)
1020 if (pname
== GL_COLOR_TABLE_SGI
||
1021 pname
== GL_TEXTURE_COLOR_TABLE_SGI
||
1022 pname
== GL_POST_CONVOLUTION_COLOR_TABLE_SGI
||
1023 pname
== GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI
) {
1025 fparams
[0] = (GLfloat
) params
[0];
1026 fparams
[1] = (GLfloat
) params
[1];
1027 fparams
[2] = (GLfloat
) params
[2];
1028 fparams
[3] = (GLfloat
) params
[3];
1032 fparams
[0] = (GLfloat
) params
[0];
1034 _mesa_ColorTableParameterfv(target
, pname
, fparams
);
1040 _mesa_GetColorTableParameterfv( GLenum target
, GLenum pname
, GLfloat
*params
)
1042 GET_CURRENT_CONTEXT(ctx
);
1043 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1044 struct gl_color_table
*table
= NULL
;
1045 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1049 table
= &texUnit
->Current1D
->Palette
;
1052 table
= &texUnit
->Current2D
->Palette
;
1055 table
= &texUnit
->Current3D
->Palette
;
1057 case GL_TEXTURE_CUBE_MAP_ARB
:
1058 if (!ctx
->Extensions
.ARB_texture_cube_map
) {
1059 _mesa_error(ctx
, GL_INVALID_ENUM
,
1060 "glGetColorTableParameterfv(target)");
1063 table
= &texUnit
->CurrentCubeMap
->Palette
;
1065 case GL_PROXY_TEXTURE_1D
:
1066 table
= &ctx
->Texture
.Proxy1D
->Palette
;
1068 case GL_PROXY_TEXTURE_2D
:
1069 table
= &ctx
->Texture
.Proxy2D
->Palette
;
1071 case GL_PROXY_TEXTURE_3D
:
1072 table
= &ctx
->Texture
.Proxy3D
->Palette
;
1074 case GL_PROXY_TEXTURE_CUBE_MAP_ARB
:
1075 if (!ctx
->Extensions
.ARB_texture_cube_map
) {
1076 _mesa_error(ctx
, GL_INVALID_ENUM
,
1077 "glGetColorTableParameterfv(target)");
1080 table
= &ctx
->Texture
.ProxyCubeMap
->Palette
;
1082 case GL_SHARED_TEXTURE_PALETTE_EXT
:
1083 table
= &ctx
->Texture
.Palette
;
1085 case GL_COLOR_TABLE
:
1086 table
= &ctx
->ColorTable
;
1087 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
1088 params
[0] = ctx
->Pixel
.ColorTableScale
[0];
1089 params
[1] = ctx
->Pixel
.ColorTableScale
[1];
1090 params
[2] = ctx
->Pixel
.ColorTableScale
[2];
1091 params
[3] = ctx
->Pixel
.ColorTableScale
[3];
1094 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
1095 params
[0] = ctx
->Pixel
.ColorTableBias
[0];
1096 params
[1] = ctx
->Pixel
.ColorTableBias
[1];
1097 params
[2] = ctx
->Pixel
.ColorTableBias
[2];
1098 params
[3] = ctx
->Pixel
.ColorTableBias
[3];
1102 case GL_PROXY_COLOR_TABLE
:
1103 table
= &ctx
->ProxyColorTable
;
1105 case GL_TEXTURE_COLOR_TABLE_SGI
:
1106 if (!ctx
->Extensions
.SGI_texture_color_table
) {
1107 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameter(target)");
1110 table
= &(texUnit
->ColorTable
);
1111 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
1112 params
[0] = ctx
->Pixel
.TextureColorTableScale
[0];
1113 params
[1] = ctx
->Pixel
.TextureColorTableScale
[1];
1114 params
[2] = ctx
->Pixel
.TextureColorTableScale
[2];
1115 params
[3] = ctx
->Pixel
.TextureColorTableScale
[3];
1118 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
1119 params
[0] = ctx
->Pixel
.TextureColorTableBias
[0];
1120 params
[1] = ctx
->Pixel
.TextureColorTableBias
[1];
1121 params
[2] = ctx
->Pixel
.TextureColorTableBias
[2];
1122 params
[3] = ctx
->Pixel
.TextureColorTableBias
[3];
1126 case GL_PROXY_TEXTURE_COLOR_TABLE_SGI
:
1127 if (!ctx
->Extensions
.SGI_texture_color_table
) {
1128 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameter(target)");
1131 table
= &(texUnit
->ProxyColorTable
);
1133 case GL_POST_CONVOLUTION_COLOR_TABLE
:
1134 table
= &ctx
->PostConvolutionColorTable
;
1135 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
1136 params
[0] = ctx
->Pixel
.PCCTscale
[0];
1137 params
[1] = ctx
->Pixel
.PCCTscale
[1];
1138 params
[2] = ctx
->Pixel
.PCCTscale
[2];
1139 params
[3] = ctx
->Pixel
.PCCTscale
[3];
1142 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
1143 params
[0] = ctx
->Pixel
.PCCTbias
[0];
1144 params
[1] = ctx
->Pixel
.PCCTbias
[1];
1145 params
[2] = ctx
->Pixel
.PCCTbias
[2];
1146 params
[3] = ctx
->Pixel
.PCCTbias
[3];
1150 case GL_PROXY_POST_CONVOLUTION_COLOR_TABLE
:
1151 table
= &ctx
->ProxyPostConvolutionColorTable
;
1153 case GL_POST_COLOR_MATRIX_COLOR_TABLE
:
1154 table
= &ctx
->PostColorMatrixColorTable
;
1155 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
1156 params
[0] = ctx
->Pixel
.PCMCTscale
[0];
1157 params
[1] = ctx
->Pixel
.PCMCTscale
[1];
1158 params
[2] = ctx
->Pixel
.PCMCTscale
[2];
1159 params
[3] = ctx
->Pixel
.PCMCTscale
[3];
1162 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
1163 params
[0] = ctx
->Pixel
.PCMCTbias
[0];
1164 params
[1] = ctx
->Pixel
.PCMCTbias
[1];
1165 params
[2] = ctx
->Pixel
.PCMCTbias
[2];
1166 params
[3] = ctx
->Pixel
.PCMCTbias
[3];
1170 case GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE
:
1171 table
= &ctx
->ProxyPostColorMatrixColorTable
;
1174 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameterfv(target)");
1181 case GL_COLOR_TABLE_FORMAT
:
1182 *params
= (GLfloat
) table
->IntFormat
;
1184 case GL_COLOR_TABLE_WIDTH
:
1185 *params
= (GLfloat
) table
->Size
;
1187 case GL_COLOR_TABLE_RED_SIZE
:
1188 *params
= (GLfloat
) table
->RedSize
;
1190 case GL_COLOR_TABLE_GREEN_SIZE
:
1191 *params
= (GLfloat
) table
->GreenSize
;
1193 case GL_COLOR_TABLE_BLUE_SIZE
:
1194 *params
= (GLfloat
) table
->BlueSize
;
1196 case GL_COLOR_TABLE_ALPHA_SIZE
:
1197 *params
= (GLfloat
) table
->AlphaSize
;
1199 case GL_COLOR_TABLE_LUMINANCE_SIZE
:
1200 *params
= (GLfloat
) table
->LuminanceSize
;
1202 case GL_COLOR_TABLE_INTENSITY_SIZE
:
1203 *params
= (GLfloat
) table
->IntensitySize
;
1206 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameterfv(pname)" );
1214 _mesa_GetColorTableParameteriv( GLenum target
, GLenum pname
, GLint
*params
)
1216 GET_CURRENT_CONTEXT(ctx
);
1217 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1218 struct gl_color_table
*table
= NULL
;
1219 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1223 table
= &texUnit
->Current1D
->Palette
;
1226 table
= &texUnit
->Current2D
->Palette
;
1229 table
= &texUnit
->Current3D
->Palette
;
1231 case GL_TEXTURE_CUBE_MAP_ARB
:
1232 if (!ctx
->Extensions
.ARB_texture_cube_map
) {
1233 _mesa_error(ctx
, GL_INVALID_ENUM
,
1234 "glGetColorTableParameteriv(target)");
1237 table
= &texUnit
->CurrentCubeMap
->Palette
;
1239 case GL_PROXY_TEXTURE_1D
:
1240 table
= &ctx
->Texture
.Proxy1D
->Palette
;
1242 case GL_PROXY_TEXTURE_2D
:
1243 table
= &ctx
->Texture
.Proxy2D
->Palette
;
1245 case GL_PROXY_TEXTURE_3D
:
1246 table
= &ctx
->Texture
.Proxy3D
->Palette
;
1248 case GL_PROXY_TEXTURE_CUBE_MAP_ARB
:
1249 if (!ctx
->Extensions
.ARB_texture_cube_map
) {
1250 _mesa_error(ctx
, GL_INVALID_ENUM
,
1251 "glGetColorTableParameteriv(target)");
1254 table
= &ctx
->Texture
.ProxyCubeMap
->Palette
;
1256 case GL_SHARED_TEXTURE_PALETTE_EXT
:
1257 table
= &ctx
->Texture
.Palette
;
1259 case GL_COLOR_TABLE
:
1260 table
= &ctx
->ColorTable
;
1261 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
1262 params
[0] = (GLint
) ctx
->Pixel
.ColorTableScale
[0];
1263 params
[1] = (GLint
) ctx
->Pixel
.ColorTableScale
[1];
1264 params
[2] = (GLint
) ctx
->Pixel
.ColorTableScale
[2];
1265 params
[3] = (GLint
) ctx
->Pixel
.ColorTableScale
[3];
1268 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
1269 params
[0] = (GLint
) ctx
->Pixel
.ColorTableBias
[0];
1270 params
[1] = (GLint
) ctx
->Pixel
.ColorTableBias
[1];
1271 params
[2] = (GLint
) ctx
->Pixel
.ColorTableBias
[2];
1272 params
[3] = (GLint
) ctx
->Pixel
.ColorTableBias
[3];
1276 case GL_PROXY_COLOR_TABLE
:
1277 table
= &ctx
->ProxyColorTable
;
1279 case GL_TEXTURE_COLOR_TABLE_SGI
:
1280 if (!ctx
->Extensions
.SGI_texture_color_table
) {
1281 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameter(target)");
1284 table
= &(texUnit
->ColorTable
);
1285 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
1286 params
[0] = (GLint
) ctx
->Pixel
.TextureColorTableScale
[0];
1287 params
[1] = (GLint
) ctx
->Pixel
.TextureColorTableScale
[1];
1288 params
[2] = (GLint
) ctx
->Pixel
.TextureColorTableScale
[2];
1289 params
[3] = (GLint
) ctx
->Pixel
.TextureColorTableScale
[3];
1292 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
1293 params
[0] = (GLint
) ctx
->Pixel
.TextureColorTableBias
[0];
1294 params
[1] = (GLint
) ctx
->Pixel
.TextureColorTableBias
[1];
1295 params
[2] = (GLint
) ctx
->Pixel
.TextureColorTableBias
[2];
1296 params
[3] = (GLint
) ctx
->Pixel
.TextureColorTableBias
[3];
1300 case GL_PROXY_TEXTURE_COLOR_TABLE_SGI
:
1301 if (!ctx
->Extensions
.SGI_texture_color_table
) {
1302 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameter(target)");
1305 table
= &(texUnit
->ProxyColorTable
);
1307 case GL_POST_CONVOLUTION_COLOR_TABLE
:
1308 table
= &ctx
->PostConvolutionColorTable
;
1309 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
1310 params
[0] = (GLint
) ctx
->Pixel
.PCCTscale
[0];
1311 params
[1] = (GLint
) ctx
->Pixel
.PCCTscale
[1];
1312 params
[2] = (GLint
) ctx
->Pixel
.PCCTscale
[2];
1313 params
[3] = (GLint
) ctx
->Pixel
.PCCTscale
[3];
1316 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
1317 params
[0] = (GLint
) ctx
->Pixel
.PCCTbias
[0];
1318 params
[1] = (GLint
) ctx
->Pixel
.PCCTbias
[1];
1319 params
[2] = (GLint
) ctx
->Pixel
.PCCTbias
[2];
1320 params
[3] = (GLint
) ctx
->Pixel
.PCCTbias
[3];
1324 case GL_PROXY_POST_CONVOLUTION_COLOR_TABLE
:
1325 table
= &ctx
->ProxyPostConvolutionColorTable
;
1327 case GL_POST_COLOR_MATRIX_COLOR_TABLE
:
1328 table
= &ctx
->PostColorMatrixColorTable
;
1329 if (pname
== GL_COLOR_TABLE_SCALE_SGI
) {
1330 params
[0] = (GLint
) ctx
->Pixel
.PCMCTscale
[0];
1331 params
[1] = (GLint
) ctx
->Pixel
.PCMCTscale
[1];
1332 params
[2] = (GLint
) ctx
->Pixel
.PCMCTscale
[2];
1333 params
[3] = (GLint
) ctx
->Pixel
.PCMCTscale
[3];
1336 else if (pname
== GL_COLOR_TABLE_BIAS_SGI
) {
1337 params
[0] = (GLint
) ctx
->Pixel
.PCMCTbias
[0];
1338 params
[1] = (GLint
) ctx
->Pixel
.PCMCTbias
[1];
1339 params
[2] = (GLint
) ctx
->Pixel
.PCMCTbias
[2];
1340 params
[3] = (GLint
) ctx
->Pixel
.PCMCTbias
[3];
1344 case GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE
:
1345 table
= &ctx
->ProxyPostColorMatrixColorTable
;
1348 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameteriv(target)");
1355 case GL_COLOR_TABLE_FORMAT
:
1356 *params
= table
->IntFormat
;
1358 case GL_COLOR_TABLE_WIDTH
:
1359 *params
= table
->Size
;
1361 case GL_COLOR_TABLE_RED_SIZE
:
1362 *params
= table
->RedSize
;
1364 case GL_COLOR_TABLE_GREEN_SIZE
:
1365 *params
= table
->GreenSize
;
1367 case GL_COLOR_TABLE_BLUE_SIZE
:
1368 *params
= table
->BlueSize
;
1370 case GL_COLOR_TABLE_ALPHA_SIZE
:
1371 *params
= table
->AlphaSize
;
1373 case GL_COLOR_TABLE_LUMINANCE_SIZE
:
1374 *params
= table
->LuminanceSize
;
1376 case GL_COLOR_TABLE_INTENSITY_SIZE
:
1377 *params
= table
->IntensitySize
;
1380 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetColorTableParameteriv(pname)" );
1385 /**********************************************************************/
1386 /***** Initialization *****/
1387 /**********************************************************************/
1391 _mesa_init_colortable( struct gl_color_table
*p
)
1393 p
->Type
= CHAN_TYPE
;
1396 p
->IntFormat
= GL_RGBA
;
1402 _mesa_free_colortable_data( struct gl_color_table
*p
)
1412 * Initialize all colortables for a context.
1414 void _mesa_init_colortables( GLcontext
* ctx
)
1417 _mesa_init_colortable(&ctx
->ColorTable
);
1418 _mesa_init_colortable(&ctx
->ProxyColorTable
);
1419 _mesa_init_colortable(&ctx
->PostConvolutionColorTable
);
1420 _mesa_init_colortable(&ctx
->ProxyPostConvolutionColorTable
);
1421 _mesa_init_colortable(&ctx
->PostColorMatrixColorTable
);
1422 _mesa_init_colortable(&ctx
->ProxyPostColorMatrixColorTable
);
1427 * Free all colortable data for a context
1429 void _mesa_free_colortables_data( GLcontext
*ctx
)
1431 _mesa_free_colortable_data(&ctx
->ColorTable
);
1432 _mesa_free_colortable_data(&ctx
->ProxyColorTable
);
1433 _mesa_free_colortable_data(&ctx
->PostConvolutionColorTable
);
1434 _mesa_free_colortable_data(&ctx
->ProxyPostConvolutionColorTable
);
1435 _mesa_free_colortable_data(&ctx
->PostColorMatrixColorTable
);
1436 _mesa_free_colortable_data(&ctx
->ProxyPostColorMatrixColorTable
);