fixed image transfer errors
[mesa.git] / src / mesa / main / colortab.c
1 /* $Id: colortab.c,v 1.21 2000/08/21 14:23:09 brianp Exp $ */
2
3 /*
4 * Mesa 3-D graphics library
5 * Version: 3.5
6 *
7 * Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
8 *
9 * Permission is hereby granted, free of charge, to any person obtaining a
10 * copy of this software and associated documentation files (the "Software"),
11 * to deal in the Software without restriction, including without limitation
12 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 * and/or sell copies of the Software, and to permit persons to whom the
14 * Software is furnished to do so, subject to the following conditions:
15 *
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
23 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 */
26
27
28 #ifdef PC_HEADER
29 #include "all.h"
30 #else
31 #include "glheader.h"
32 #include "colortab.h"
33 #include "context.h"
34 #include "image.h"
35 #include "macros.h"
36 #include "mem.h"
37 #include "mmath.h"
38 #include "span.h"
39 #endif
40
41
42
43 /*
44 * Given an internalFormat token passed to glColorTable,
45 * return the corresponding base format.
46 * Return -1 if invalid token.
47 */
48 static GLint
49 base_colortab_format( GLenum format )
50 {
51 switch (format) {
52 case GL_ALPHA:
53 case GL_ALPHA4:
54 case GL_ALPHA8:
55 case GL_ALPHA12:
56 case GL_ALPHA16:
57 return GL_ALPHA;
58 case GL_LUMINANCE:
59 case GL_LUMINANCE4:
60 case GL_LUMINANCE8:
61 case GL_LUMINANCE12:
62 case GL_LUMINANCE16:
63 return GL_LUMINANCE;
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;
72 case GL_INTENSITY:
73 case GL_INTENSITY4:
74 case GL_INTENSITY8:
75 case GL_INTENSITY12:
76 case GL_INTENSITY16:
77 return GL_INTENSITY;
78 case GL_RGB:
79 case GL_R3_G3_B2:
80 case GL_RGB4:
81 case GL_RGB5:
82 case GL_RGB8:
83 case GL_RGB10:
84 case GL_RGB12:
85 case GL_RGB16:
86 return GL_RGB;
87 case GL_RGBA:
88 case GL_RGBA2:
89 case GL_RGBA4:
90 case GL_RGB5_A1:
91 case GL_RGBA8:
92 case GL_RGB10_A2:
93 case GL_RGBA12:
94 case GL_RGBA16:
95 return GL_RGBA;
96 default:
97 return -1; /* error */
98 }
99 }
100
101
102 void
103 _mesa_init_colortable( struct gl_color_table *p )
104 {
105 p->TableType = GL_UNSIGNED_BYTE;
106 /* allocate a width=1 table by default */
107 p->Table = CALLOC(4 * sizeof(GLubyte));
108 if (p->Table) {
109 GLubyte *t = (GLubyte *) p->Table;
110 t[0] = 255;
111 t[1] = 255;
112 t[2] = 255;
113 t[3] = 255;
114 }
115 p->Size = 1;
116 p->IntFormat = GL_RGBA;
117 p->Format = GL_RGBA;
118 p->RedSize = 8;
119 p->GreenSize = 8;
120 p->BlueSize = 8;
121 p->AlphaSize = 8;
122 p->IntensitySize = 0;
123 p->LuminanceSize = 0;
124 }
125
126
127
128 void
129 _mesa_free_colortable_data( struct gl_color_table *p )
130 {
131 if (p->Table) {
132 FREE(p->Table);
133 p->Table = NULL;
134 }
135 }
136
137
138 /*
139 * Examine table's format and set the component sizes accordingly.
140 */
141 static void
142 set_component_sizes( struct gl_color_table *table )
143 {
144 switch (table->Format) {
145 case GL_ALPHA:
146 table->RedSize = 0;
147 table->GreenSize = 0;
148 table->BlueSize = 0;
149 table->AlphaSize = 8;
150 table->IntensitySize = 0;
151 table->LuminanceSize = 0;
152 break;
153 case GL_LUMINANCE:
154 table->RedSize = 0;
155 table->GreenSize = 0;
156 table->BlueSize = 0;
157 table->AlphaSize = 0;
158 table->IntensitySize = 0;
159 table->LuminanceSize = 8;
160 break;
161 case GL_LUMINANCE_ALPHA:
162 table->RedSize = 0;
163 table->GreenSize = 0;
164 table->BlueSize = 0;
165 table->AlphaSize = 8;
166 table->IntensitySize = 0;
167 table->LuminanceSize = 8;
168 break;
169 case GL_INTENSITY:
170 table->RedSize = 0;
171 table->GreenSize = 0;
172 table->BlueSize = 0;
173 table->AlphaSize = 0;
174 table->IntensitySize = 8;
175 table->LuminanceSize = 0;
176 break;
177 case GL_RGB:
178 table->RedSize = 8;
179 table->GreenSize = 8;
180 table->BlueSize = 8;
181 table->AlphaSize = 0;
182 table->IntensitySize = 0;
183 table->LuminanceSize = 0;
184 break;
185 case GL_RGBA:
186 table->RedSize = 8;
187 table->GreenSize = 8;
188 table->BlueSize = 8;
189 table->AlphaSize = 8;
190 table->IntensitySize = 0;
191 table->LuminanceSize = 0;
192 break;
193 default:
194 gl_problem(NULL, "unexpected format in set_component_sizes");
195 }
196 }
197
198
199
200 void
201 _mesa_ColorTable( GLenum target, GLenum internalFormat,
202 GLsizei width, GLenum format, GLenum type,
203 const GLvoid *data )
204 {
205 GET_CURRENT_CONTEXT(ctx);
206 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
207 struct gl_texture_object *texObj = NULL;
208 struct gl_color_table *table = NULL;
209 GLboolean proxy = GL_FALSE;
210 GLint baseFormat;
211 GLfloat rScale = 1.0, gScale = 1.0, bScale = 1.0, aScale = 1.0;
212 GLfloat rBias = 0.0, gBias = 0.0, bBias = 0.0, aBias = 0.0;
213 GLboolean floatTable = GL_FALSE;
214 GLint comps;
215
216 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glColorTable");
217
218 switch (target) {
219 case GL_TEXTURE_1D:
220 texObj = texUnit->CurrentD[1];
221 table = &texObj->Palette;
222 break;
223 case GL_TEXTURE_2D:
224 texObj = texUnit->CurrentD[2];
225 table = &texObj->Palette;
226 break;
227 case GL_TEXTURE_3D:
228 texObj = texUnit->CurrentD[3];
229 table = &texObj->Palette;
230 break;
231 case GL_PROXY_TEXTURE_1D:
232 texObj = ctx->Texture.Proxy1D;
233 table = &texObj->Palette;
234 proxy = GL_TRUE;
235 break;
236 case GL_PROXY_TEXTURE_2D:
237 texObj = ctx->Texture.Proxy2D;
238 table = &texObj->Palette;
239 proxy = GL_TRUE;
240 break;
241 case GL_PROXY_TEXTURE_3D:
242 texObj = ctx->Texture.Proxy3D;
243 table = &texObj->Palette;
244 proxy = GL_TRUE;
245 break;
246 case GL_SHARED_TEXTURE_PALETTE_EXT:
247 table = &ctx->Texture.Palette;
248 break;
249 case GL_COLOR_TABLE:
250 table = &ctx->ColorTable;
251 floatTable = GL_TRUE;
252 rScale = ctx->Pixel.ColorTableScale[0];
253 gScale = ctx->Pixel.ColorTableScale[1];
254 bScale = ctx->Pixel.ColorTableScale[2];
255 aScale = ctx->Pixel.ColorTableScale[3];
256 rBias = ctx->Pixel.ColorTableBias[0];
257 gBias = ctx->Pixel.ColorTableBias[1];
258 bBias = ctx->Pixel.ColorTableBias[2];
259 aBias = ctx->Pixel.ColorTableBias[3];
260 break;
261 case GL_PROXY_COLOR_TABLE:
262 table = &ctx->ProxyColorTable;
263 proxy = GL_TRUE;
264 break;
265 case GL_POST_CONVOLUTION_COLOR_TABLE:
266 table = &ctx->PostConvolutionColorTable;
267 floatTable = GL_TRUE;
268 rScale = ctx->Pixel.PCCTscale[0];
269 gScale = ctx->Pixel.PCCTscale[1];
270 bScale = ctx->Pixel.PCCTscale[2];
271 aScale = ctx->Pixel.PCCTscale[3];
272 rBias = ctx->Pixel.PCCTbias[0];
273 gBias = ctx->Pixel.PCCTbias[1];
274 bBias = ctx->Pixel.PCCTbias[2];
275 aBias = ctx->Pixel.PCCTbias[3];
276 break;
277 case GL_PROXY_POST_CONVOLUTION_COLOR_TABLE:
278 table = &ctx->ProxyPostConvolutionColorTable;
279 proxy = GL_TRUE;
280 break;
281 case GL_POST_COLOR_MATRIX_COLOR_TABLE:
282 table = &ctx->PostColorMatrixColorTable;
283 floatTable = GL_TRUE;
284 rScale = ctx->Pixel.PCMCTscale[0];
285 gScale = ctx->Pixel.PCMCTscale[1];
286 bScale = ctx->Pixel.PCMCTscale[2];
287 aScale = ctx->Pixel.PCMCTscale[3];
288 rBias = ctx->Pixel.PCMCTbias[0];
289 gBias = ctx->Pixel.PCMCTbias[1];
290 bBias = ctx->Pixel.PCMCTbias[2];
291 aBias = ctx->Pixel.PCMCTbias[3];
292 break;
293 case GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE:
294 table = &ctx->ProxyPostColorMatrixColorTable;
295 proxy = GL_TRUE;
296 break;
297 default:
298 gl_error(ctx, GL_INVALID_ENUM, "glColorTable(target)");
299 return;
300 }
301
302 assert(table);
303
304 if (!_mesa_is_legal_format_and_type(format, type) ||
305 format == GL_INTENSITY) {
306 gl_error(ctx, GL_INVALID_ENUM, "glColorTable(format or type)");
307 return;
308 }
309
310 baseFormat = base_colortab_format(internalFormat);
311 if (baseFormat < 0 || baseFormat == GL_COLOR_INDEX) {
312 gl_error(ctx, GL_INVALID_ENUM, "glColorTable(internalFormat)");
313 return;
314 }
315
316 if (width < 0 || _mesa_bitcount(width) != 1) {
317 if (proxy) {
318 table->Size = 0;
319 table->IntFormat = (GLenum) 0;
320 table->Format = (GLenum) 0;
321 }
322 else {
323 gl_error(ctx, GL_INVALID_VALUE, "glColorTable(width)");
324 }
325 return;
326 }
327
328 if (width > ctx->Const.MaxColorTableSize) {
329 if (proxy) {
330 table->Size = 0;
331 table->IntFormat = (GLenum) 0;
332 table->Format = (GLenum) 0;
333 }
334 else {
335 if (width > ctx->Const.MaxColorTableSize)
336 gl_error(ctx, GL_TABLE_TOO_LARGE, "glColorTable(width)");
337 else
338 gl_error(ctx, GL_INVALID_VALUE, "glColorTable(width)");
339 }
340 return;
341 }
342
343 table->Size = width;
344 table->IntFormat = internalFormat;
345 table->Format = (GLenum) baseFormat;
346 set_component_sizes(table);
347
348 comps = _mesa_components_in_format(table->Format);
349 assert(comps > 0); /* error should have been caught sooner */
350
351 if (!proxy) {
352 /* free old table, if any */
353 if (table->Table) {
354 FREE(table->Table);
355 }
356 if (floatTable) {
357 GLfloat tempTab[MAX_COLOR_TABLE_SIZE * 4];
358 GLfloat *tableF;
359 GLuint i;
360
361 _mesa_unpack_float_color_span(ctx, width, table->Format,
362 tempTab, /* dest */
363 format, type, data, &ctx->Unpack,
364 0, GL_FALSE);
365
366 table->TableType = GL_FLOAT;
367 table->Table = MALLOC(comps * width * sizeof(GLfloat));
368 if (!table->Table) {
369 gl_error(ctx, GL_OUT_OF_MEMORY, "glColorTable");
370 return;
371 }
372
373 tableF = (GLfloat *) table->Table;
374
375 switch (table->Format) {
376 case GL_INTENSITY:
377 for (i = 0; i < width; i++) {
378 tableF[i] = CLAMP(tempTab[i] * rScale + rBias, 0.0F, 1.0F);
379 }
380 break;
381 case GL_LUMINANCE:
382 for (i = 0; i < width; i++) {
383 tableF[i] = CLAMP(tempTab[i] * rScale + rBias, 0.0F, 1.0F);
384 }
385 break;
386 case GL_ALPHA:
387 for (i = 0; i < width; i++) {
388 tableF[i] = CLAMP(tempTab[i] * aScale + aBias, 0.0F, 1.0F);
389 }
390 break;
391 case GL_LUMINANCE_ALPHA:
392 for (i = 0; i < width; i++) {
393 tableF[i*2+0] = CLAMP(tempTab[i*2+0] * rScale + rBias, 0.0F, 1.0F);
394 tableF[i*2+1] = CLAMP(tempTab[i*2+1] * aScale + aBias, 0.0F, 1.0F);
395 }
396 break;
397 case GL_RGB:
398 for (i = 0; i < width; i++) {
399 tableF[i*3+0] = CLAMP(tempTab[i*3+0] * rScale + rBias, 0.0F, 1.0F);
400 tableF[i*3+1] = CLAMP(tempTab[i*3+1] * gScale + gBias, 0.0F, 1.0F);
401 tableF[i*3+2] = CLAMP(tempTab[i*3+2] * bScale + bBias, 0.0F, 1.0F);
402 }
403 break;
404 case GL_RGBA:
405 for (i = 0; i < width; i++) {
406 tableF[i*4+0] = CLAMP(tempTab[i*4+0] * rScale + rBias, 0.0F, 1.0F);
407 tableF[i*4+1] = CLAMP(tempTab[i*4+1] * gScale + gBias, 0.0F, 1.0F);
408 tableF[i*4+2] = CLAMP(tempTab[i*4+2] * bScale + bBias, 0.0F, 1.0F);
409 tableF[i*4+3] = CLAMP(tempTab[i*4+3] * aScale + aBias, 0.0F, 1.0F);
410 }
411 break;
412 default:
413 gl_problem(ctx, "Bad format in _mesa_ColorTable");
414 return;
415 }
416 }
417 else {
418 /* store GLubyte table */
419 table->TableType = GL_UNSIGNED_BYTE;
420 table->Table = MALLOC(comps * width * sizeof(GLubyte));
421 if (!table->Table) {
422 gl_error(ctx, GL_OUT_OF_MEMORY, "glColorTable");
423 return;
424 }
425 _mesa_unpack_ubyte_color_span(ctx, width, table->Format,
426 table->Table, /* dest */
427 format, type, data,
428 &ctx->Unpack, 0);
429 } /* floatTable */
430 } /* proxy */
431
432 if (texObj || target == GL_SHARED_TEXTURE_PALETTE_EXT) {
433 /* texture object palette, texObj==NULL means the shared palette */
434 if (ctx->Driver.UpdateTexturePalette) {
435 (*ctx->Driver.UpdateTexturePalette)( ctx, texObj );
436 }
437 }
438 }
439
440
441
442 void
443 _mesa_ColorSubTable( GLenum target, GLsizei start,
444 GLsizei count, GLenum format, GLenum type,
445 const GLvoid *data )
446 {
447 GET_CURRENT_CONTEXT(ctx);
448 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
449 struct gl_texture_object *texObj = NULL;
450 struct gl_color_table *table = NULL;
451 GLfloat rScale = 1.0, gScale = 1.0, bScale = 1.0, aScale = 1.0;
452 GLfloat rBias = 0.0, gBias = 0.0, bBias = 0.0, aBias = 0.0;
453 GLint comps;
454
455 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glColorSubTable");
456
457 switch (target) {
458 case GL_TEXTURE_1D:
459 texObj = texUnit->CurrentD[1];
460 table = &texObj->Palette;
461 break;
462 case GL_TEXTURE_2D:
463 texObj = texUnit->CurrentD[2];
464 table = &texObj->Palette;
465 break;
466 case GL_TEXTURE_3D:
467 texObj = texUnit->CurrentD[3];
468 table = &texObj->Palette;
469 break;
470 case GL_SHARED_TEXTURE_PALETTE_EXT:
471 table = &ctx->Texture.Palette;
472 break;
473 case GL_COLOR_TABLE:
474 table = &ctx->ColorTable;
475 rScale = ctx->Pixel.ColorTableScale[0];
476 gScale = ctx->Pixel.ColorTableScale[1];
477 bScale = ctx->Pixel.ColorTableScale[2];
478 aScale = ctx->Pixel.ColorTableScale[3];
479 rBias = ctx->Pixel.ColorTableBias[0];
480 gBias = ctx->Pixel.ColorTableBias[1];
481 bBias = ctx->Pixel.ColorTableBias[2];
482 aBias = ctx->Pixel.ColorTableBias[3];
483 break;
484 case GL_POST_CONVOLUTION_COLOR_TABLE:
485 table = &ctx->PostConvolutionColorTable;
486 rScale = ctx->Pixel.PCCTscale[0];
487 gScale = ctx->Pixel.PCCTscale[1];
488 bScale = ctx->Pixel.PCCTscale[2];
489 aScale = ctx->Pixel.PCCTscale[3];
490 rBias = ctx->Pixel.PCCTbias[0];
491 gBias = ctx->Pixel.PCCTbias[1];
492 bBias = ctx->Pixel.PCCTbias[2];
493 aBias = ctx->Pixel.PCCTbias[3];
494 break;
495 case GL_POST_COLOR_MATRIX_COLOR_TABLE:
496 table = &ctx->PostColorMatrixColorTable;
497 rScale = ctx->Pixel.PCMCTscale[0];
498 gScale = ctx->Pixel.PCMCTscale[1];
499 bScale = ctx->Pixel.PCMCTscale[2];
500 aScale = ctx->Pixel.PCMCTscale[3];
501 rBias = ctx->Pixel.PCMCTbias[0];
502 gBias = ctx->Pixel.PCMCTbias[1];
503 bBias = ctx->Pixel.PCMCTbias[2];
504 aBias = ctx->Pixel.PCMCTbias[3];
505 break;
506 default:
507 gl_error(ctx, GL_INVALID_ENUM, "glColorSubTable(target)");
508 return;
509 }
510
511 assert(table);
512
513 if (!_mesa_is_legal_format_and_type(format, type) ||
514 format == GL_INTENSITY) {
515 gl_error(ctx, GL_INVALID_ENUM, "glColorSubTable(format or type)");
516 return;
517 }
518
519 if (count < 1) {
520 gl_error(ctx, GL_INVALID_VALUE, "glColorSubTable(count)");
521 return;
522 }
523
524 comps = _mesa_components_in_format(table->Format);
525 assert(comps > 0); /* error should have been caught sooner */
526
527 if (start + count > table->Size) {
528 gl_error(ctx, GL_INVALID_VALUE, "glColorSubTable(count)");
529 return;
530 }
531
532 if (!table->Table) {
533 gl_error(ctx, GL_OUT_OF_MEMORY, "glColorSubTable");
534 return;
535 }
536
537 if (table->TableType == GL_UNSIGNED_BYTE) {
538 GLubyte *dest = (GLubyte *) table->Table + start * comps * sizeof(GLubyte);
539 _mesa_unpack_ubyte_color_span(ctx, count, table->Format, dest,
540 format, type, data, &ctx->Unpack, 0);
541 }
542 else {
543 GLfloat tempTab[MAX_COLOR_TABLE_SIZE * 4];
544 GLfloat *tableF;
545 GLuint i;
546
547 ASSERT(table->TableType == GL_FLOAT);
548
549 _mesa_unpack_float_color_span(ctx, count, table->Format,
550 tempTab, /* dest */
551 format, type, data, &ctx->Unpack,
552 0, GL_FALSE);
553
554 tableF = (GLfloat *) table->Table;
555
556 switch (table->Format) {
557 case GL_INTENSITY:
558 for (i = 0; i < count; i++) {
559 GLuint j = start + i;
560 tableF[j] = CLAMP(tempTab[i] * rScale + rBias, 0.0F, 1.0F);
561 }
562 break;
563 case GL_LUMINANCE:
564 for (i = 0; i < count; i++) {
565 GLuint j = start + i;
566 tableF[j] = CLAMP(tempTab[i] * rScale + rBias, 0.0F, 1.0F);
567 }
568 break;
569 case GL_ALPHA:
570 for (i = 0; i < count; i++) {
571 GLuint j = start + i;
572 tableF[j] = CLAMP(tempTab[i] * aScale + aBias, 0.0F, 1.0F);
573 }
574 break;
575 case GL_LUMINANCE_ALPHA:
576 for (i = 0; i < count; i++) {
577 GLuint j = start + i;
578 tableF[j*2+0] = CLAMP(tempTab[i*2+0] * rScale + rBias, 0.0F, 1.0F);
579 tableF[j*2+1] = CLAMP(tempTab[i*2+1] * aScale + aBias, 0.0F, 1.0F);
580 }
581 break;
582 case GL_RGB:
583 for (i = 0; i < count; i++) {
584 GLuint j = start + i;
585 tableF[j*3+0] = CLAMP(tempTab[i*3+0] * rScale + rBias, 0.0F, 1.0F);
586 tableF[j*3+1] = CLAMP(tempTab[i*3+1] * gScale + gBias, 0.0F, 1.0F);
587 tableF[j*3+2] = CLAMP(tempTab[i*3+2] * bScale + bBias, 0.0F, 1.0F);
588 }
589 break;
590 case GL_RGBA:
591 for (i = 0; i < count; i++) {
592 GLuint j = start + i;
593 tableF[j*4+0] = CLAMP(tempTab[i*4+0] * rScale + rBias, 0.0F, 1.0F);
594 tableF[j*4+1] = CLAMP(tempTab[i*4+1] * gScale + gBias, 0.0F, 1.0F);
595 tableF[j*4+2] = CLAMP(tempTab[i*4+2] * bScale + bBias, 0.0F, 1.0F);
596 tableF[j*4+3] = CLAMP(tempTab[i*4+3] * aScale + aBias, 0.0F, 1.0F);
597 }
598 break;
599 default:
600 gl_problem(ctx, "Bad format in _mesa_ColorSubTable");
601 return;
602 }
603 }
604
605 if (texObj || target == GL_SHARED_TEXTURE_PALETTE_EXT) {
606 /* per-texture object palette */
607 if (ctx->Driver.UpdateTexturePalette) {
608 (*ctx->Driver.UpdateTexturePalette)( ctx, texObj );
609 }
610 }
611 }
612
613
614
615 /* XXX not tested */
616 void
617 _mesa_CopyColorTable(GLenum target, GLenum internalformat,
618 GLint x, GLint y, GLsizei width)
619 {
620 GLubyte data[MAX_WIDTH][4];
621 GET_CURRENT_CONTEXT(ctx);
622 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glCopyColorTable");
623
624 /* Select buffer to read from */
625 (*ctx->Driver.SetReadBuffer)( ctx, ctx->ReadBuffer,
626 ctx->Pixel.DriverReadBuffer );
627
628 if (width > MAX_WIDTH)
629 width = MAX_WIDTH;
630
631 /* read the data from framebuffer */
632 gl_read_rgba_span( ctx, ctx->ReadBuffer, width, x, y, data );
633
634 /* Restore reading from draw buffer (the default) */
635 (*ctx->Driver.SetReadBuffer)( ctx, ctx->DrawBuffer,
636 ctx->Color.DriverDrawBuffer );
637
638 _mesa_ColorTable(target, internalformat, width,
639 GL_RGBA, GL_UNSIGNED_BYTE, data);
640 }
641
642
643
644 /* XXX not tested */
645 void
646 _mesa_CopyColorSubTable(GLenum target, GLsizei start,
647 GLint x, GLint y, GLsizei width)
648 {
649 GLubyte data[MAX_WIDTH][4];
650 GET_CURRENT_CONTEXT(ctx);
651 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glCopyColorSubTable");
652
653 /* Select buffer to read from */
654 (*ctx->Driver.SetReadBuffer)( ctx, ctx->ReadBuffer,
655 ctx->Pixel.DriverReadBuffer );
656
657 if (width > MAX_WIDTH)
658 width = MAX_WIDTH;
659
660 /* read the data from framebuffer */
661 gl_read_rgba_span( ctx, ctx->ReadBuffer, width, x, y, data );
662
663 /* Restore reading from draw buffer (the default) */
664 (*ctx->Driver.SetReadBuffer)( ctx, ctx->DrawBuffer,
665 ctx->Color.DriverDrawBuffer );
666
667 _mesa_ColorSubTable(target, start, width, GL_RGBA, GL_UNSIGNED_BYTE, data);
668 }
669
670
671
672 void
673 _mesa_GetColorTable( GLenum target, GLenum format,
674 GLenum type, GLvoid *data )
675 {
676 GET_CURRENT_CONTEXT(ctx);
677 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
678 struct gl_color_table *table = NULL;
679 GLubyte rgba[MAX_COLOR_TABLE_SIZE][4];
680 GLint i;
681
682 ASSERT_OUTSIDE_BEGIN_END(ctx, "glGetColorTable");
683
684 switch (target) {
685 case GL_TEXTURE_1D:
686 table = &texUnit->CurrentD[1]->Palette;
687 break;
688 case GL_TEXTURE_2D:
689 table = &texUnit->CurrentD[2]->Palette;
690 break;
691 case GL_TEXTURE_3D:
692 table = &texUnit->CurrentD[3]->Palette;
693 break;
694 case GL_SHARED_TEXTURE_PALETTE_EXT:
695 table = &ctx->Texture.Palette;
696 break;
697 case GL_COLOR_TABLE:
698 table = &ctx->ColorTable;
699 break;
700 case GL_POST_CONVOLUTION_COLOR_TABLE:
701 table = &ctx->PostConvolutionColorTable;
702 break;
703 case GL_POST_COLOR_MATRIX_COLOR_TABLE:
704 table = &ctx->PostColorMatrixColorTable;
705 break;
706 default:
707 gl_error(ctx, GL_INVALID_ENUM, "glGetColorTable(target)");
708 return;
709 }
710
711 assert(table);
712
713 switch (table->Format) {
714 case GL_ALPHA:
715 if (table->TableType == GL_FLOAT) {
716 const GLfloat *tableF = (const GLfloat *) table->Table;
717 for (i = 0; i < table->Size; i++) {
718 rgba[i][RCOMP] = 0;
719 rgba[i][GCOMP] = 0;
720 rgba[i][BCOMP] = 0;
721 rgba[i][ACOMP] = (GLint) (tableF[i] * 255.0F);
722 }
723 }
724 else {
725 const GLubyte *tableUB = (const GLubyte *) table->Table;
726 for (i = 0; i < table->Size; i++) {
727 rgba[i][RCOMP] = 0;
728 rgba[i][GCOMP] = 0;
729 rgba[i][BCOMP] = 0;
730 rgba[i][ACOMP] = tableUB[i];
731 }
732 }
733 break;
734 case GL_LUMINANCE:
735 if (table->TableType == GL_FLOAT) {
736 const GLfloat *tableF = (const GLfloat *) table->Table;
737 for (i = 0; i < table->Size; i++) {
738 rgba[i][RCOMP] = (GLint) (tableF[i] * 255.0F);
739 rgba[i][GCOMP] = (GLint) (tableF[i] * 255.0F);
740 rgba[i][BCOMP] = (GLint) (tableF[i] * 255.0F);
741 rgba[i][ACOMP] = 255;
742 }
743 }
744 else {
745 const GLubyte *tableUB = (const GLubyte *) table->Table;
746 for (i = 0; i < table->Size; i++) {
747 rgba[i][RCOMP] = tableUB[i];
748 rgba[i][GCOMP] = tableUB[i];
749 rgba[i][BCOMP] = tableUB[i];
750 rgba[i][ACOMP] = 255;
751 }
752 }
753 break;
754 case GL_LUMINANCE_ALPHA:
755 if (table->TableType == GL_FLOAT) {
756 const GLfloat *tableF = (const GLfloat *) table->Table;
757 for (i = 0; i < table->Size; i++) {
758 rgba[i][RCOMP] = (GLint) (tableF[i*2+0] * 255.0F);
759 rgba[i][GCOMP] = (GLint) (tableF[i*2+0] * 255.0F);
760 rgba[i][BCOMP] = (GLint) (tableF[i*2+0] * 255.0F);
761 rgba[i][ACOMP] = (GLint) (tableF[i*2+1] * 255.0F);
762 }
763 }
764 else {
765 const GLubyte *tableUB = (const GLubyte *) table->Table;
766 for (i = 0; i < table->Size; i++) {
767 rgba[i][RCOMP] = tableUB[i*2+0];
768 rgba[i][GCOMP] = tableUB[i*2+0];
769 rgba[i][BCOMP] = tableUB[i*2+0];
770 rgba[i][ACOMP] = tableUB[i*2+1];
771 }
772 }
773 break;
774 case GL_INTENSITY:
775 if (table->TableType == GL_FLOAT) {
776 const GLfloat *tableF = (const GLfloat *) table->Table;
777 for (i = 0; i < table->Size; i++) {
778 rgba[i][RCOMP] = (GLint) (tableF[i] * 255.0F);
779 rgba[i][GCOMP] = (GLint) (tableF[i] * 255.0F);
780 rgba[i][BCOMP] = (GLint) (tableF[i] * 255.0F);
781 rgba[i][ACOMP] = (GLint) (tableF[i] * 255.0F);
782 }
783 }
784 else {
785 const GLubyte *tableUB = (const GLubyte *) table->Table;
786 for (i = 0; i < table->Size; i++) {
787 rgba[i][RCOMP] = tableUB[i];
788 rgba[i][GCOMP] = tableUB[i];
789 rgba[i][BCOMP] = tableUB[i];
790 rgba[i][ACOMP] = tableUB[i];
791 }
792 }
793 break;
794 case GL_RGB:
795 if (table->TableType == GL_FLOAT) {
796 const GLfloat *tableF = (const GLfloat *) table->Table;
797 for (i = 0; i < table->Size; i++) {
798 rgba[i][RCOMP] = (GLint) (tableF[i*3+0] * 255.0F);
799 rgba[i][GCOMP] = (GLint) (tableF[i*3+1] * 255.0F);
800 rgba[i][BCOMP] = (GLint) (tableF[i*3+2] * 255.0F);
801 rgba[i][ACOMP] = 255;
802 }
803 }
804 else {
805 const GLubyte *tableUB = (const GLubyte *) table->Table;
806 for (i = 0; i < table->Size; i++) {
807 rgba[i][RCOMP] = tableUB[i*3+0];
808 rgba[i][GCOMP] = tableUB[i*3+1];
809 rgba[i][BCOMP] = tableUB[i*3+2];
810 rgba[i][ACOMP] = 255;
811 }
812 }
813 break;
814 case GL_RGBA:
815 if (table->TableType == GL_FLOAT) {
816 const GLfloat *tableF = (const GLfloat *) table->Table;
817 for (i = 0; i < table->Size; i++) {
818 rgba[i][RCOMP] = (GLint) (tableF[i*4+0] * 255.0F + 0.5F);
819 rgba[i][GCOMP] = (GLint) (tableF[i*4+1] * 255.0F + 0.5F);
820 rgba[i][BCOMP] = (GLint) (tableF[i*4+2] * 255.0F + 0.5F);
821 rgba[i][ACOMP] = (GLint) (tableF[i*4+3] * 255.0F + 0.5F);
822 }
823 }
824 else {
825 const GLubyte *tableUB = (const GLubyte *) table->Table;
826 for (i = 0; i < table->Size; i++) {
827 rgba[i][RCOMP] = tableUB[i*4+0];
828 rgba[i][GCOMP] = tableUB[i*4+1];
829 rgba[i][BCOMP] = tableUB[i*4+2];
830 rgba[i][ACOMP] = tableUB[i*4+3];
831 }
832 }
833 break;
834 default:
835 gl_problem(ctx, "bad table format in glGetColorTable");
836 return;
837 }
838
839 _mesa_pack_rgba_span(ctx, table->Size, (const GLubyte (*)[]) rgba,
840 format, type, data, &ctx->Pack, GL_FALSE);
841 }
842
843
844
845 void
846 _mesa_ColorTableParameterfv(GLenum target, GLenum pname, const GLfloat *params)
847 {
848 GET_CURRENT_CONTEXT(ctx);
849 ASSERT_OUTSIDE_BEGIN_END(ctx, "glColorTableParameterfv");
850
851 switch (target) {
852 case GL_COLOR_TABLE_SGI:
853 if (pname == GL_COLOR_TABLE_SCALE_SGI) {
854 ctx->Pixel.ColorTableScale[0] = params[0];
855 ctx->Pixel.ColorTableScale[1] = params[1];
856 ctx->Pixel.ColorTableScale[2] = params[2];
857 ctx->Pixel.ColorTableScale[3] = params[3];
858 }
859 else if (pname == GL_COLOR_TABLE_BIAS_SGI) {
860 ctx->Pixel.ColorTableBias[0] = params[0];
861 ctx->Pixel.ColorTableBias[1] = params[1];
862 ctx->Pixel.ColorTableBias[2] = params[2];
863 ctx->Pixel.ColorTableBias[3] = params[3];
864 }
865 else {
866 gl_error(ctx, GL_INVALID_ENUM, "glColorTableParameterfv(pname)");
867 return;
868 }
869 break;
870 case GL_POST_CONVOLUTION_COLOR_TABLE_SGI:
871 if (pname == GL_COLOR_TABLE_SCALE_SGI) {
872 ctx->Pixel.PCCTscale[0] = params[0];
873 ctx->Pixel.PCCTscale[1] = params[1];
874 ctx->Pixel.PCCTscale[2] = params[2];
875 ctx->Pixel.PCCTscale[3] = params[3];
876 }
877 else if (pname == GL_COLOR_TABLE_BIAS_SGI) {
878 ctx->Pixel.PCCTbias[0] = params[0];
879 ctx->Pixel.PCCTbias[1] = params[1];
880 ctx->Pixel.PCCTbias[2] = params[2];
881 ctx->Pixel.PCCTbias[3] = params[3];
882 }
883 else {
884 gl_error(ctx, GL_INVALID_ENUM, "glColorTableParameterfv(pname)");
885 return;
886 }
887 break;
888 case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI:
889 if (pname == GL_COLOR_TABLE_SCALE_SGI) {
890 ctx->Pixel.PCMCTscale[0] = params[0];
891 ctx->Pixel.PCMCTscale[1] = params[1];
892 ctx->Pixel.PCMCTscale[2] = params[2];
893 ctx->Pixel.PCMCTscale[3] = params[3];
894 }
895 else if (pname == GL_COLOR_TABLE_BIAS_SGI) {
896 ctx->Pixel.PCMCTbias[0] = params[0];
897 ctx->Pixel.PCMCTbias[1] = params[1];
898 ctx->Pixel.PCMCTbias[2] = params[2];
899 ctx->Pixel.PCMCTbias[3] = params[3];
900 }
901 else {
902 gl_error(ctx, GL_INVALID_ENUM, "glColorTableParameterfv(pname)");
903 return;
904 }
905 break;
906 default:
907 gl_error(ctx, GL_INVALID_ENUM, "glColorTableParameter(target)");
908 return;
909 }
910 }
911
912
913
914 void
915 _mesa_ColorTableParameteriv(GLenum target, GLenum pname, const GLint *params)
916 {
917 GLfloat fparams[4];
918 if (pname == GL_COLOR_TABLE_SGI ||
919 pname == GL_POST_CONVOLUTION_COLOR_TABLE_SGI ||
920 pname == GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI) {
921 /* four values */
922 fparams[0] = (GLfloat) params[0];
923 fparams[1] = (GLfloat) params[1];
924 fparams[2] = (GLfloat) params[2];
925 fparams[3] = (GLfloat) params[3];
926 }
927 else {
928 /* one values */
929 fparams[0] = (GLfloat) params[0];
930 }
931 _mesa_ColorTableParameterfv(target, pname, fparams);
932 }
933
934
935
936 void
937 _mesa_GetColorTableParameterfv( GLenum target, GLenum pname, GLfloat *params )
938 {
939 GET_CURRENT_CONTEXT(ctx);
940 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
941 struct gl_color_table *table = NULL;
942
943 ASSERT_OUTSIDE_BEGIN_END(ctx, "glGetColorTableParameterfv");
944
945 switch (target) {
946 case GL_TEXTURE_1D:
947 table = &texUnit->CurrentD[1]->Palette;
948 break;
949 case GL_TEXTURE_2D:
950 table = &texUnit->CurrentD[2]->Palette;
951 break;
952 case GL_TEXTURE_3D:
953 table = &texUnit->CurrentD[3]->Palette;
954 break;
955 case GL_PROXY_TEXTURE_1D:
956 table = &ctx->Texture.Proxy1D->Palette;
957 break;
958 case GL_PROXY_TEXTURE_2D:
959 table = &ctx->Texture.Proxy2D->Palette;
960 break;
961 case GL_PROXY_TEXTURE_3D:
962 table = &ctx->Texture.Proxy3D->Palette;
963 break;
964 case GL_SHARED_TEXTURE_PALETTE_EXT:
965 table = &ctx->Texture.Palette;
966 break;
967 case GL_COLOR_TABLE:
968 table = &ctx->ColorTable;
969 if (pname == GL_COLOR_TABLE_SCALE_SGI) {
970 params[0] = ctx->Pixel.ColorTableScale[0];
971 params[1] = ctx->Pixel.ColorTableScale[1];
972 params[2] = ctx->Pixel.ColorTableScale[2];
973 params[3] = ctx->Pixel.ColorTableScale[3];
974 return;
975 }
976 else if (pname == GL_COLOR_TABLE_BIAS_SGI) {
977 params[0] = ctx->Pixel.ColorTableBias[0];
978 params[1] = ctx->Pixel.ColorTableBias[1];
979 params[2] = ctx->Pixel.ColorTableBias[2];
980 params[3] = ctx->Pixel.ColorTableBias[3];
981 return;
982 }
983 break;
984 case GL_PROXY_COLOR_TABLE:
985 table = &ctx->ProxyColorTable;
986 break;
987 case GL_POST_CONVOLUTION_COLOR_TABLE:
988 table = &ctx->PostConvolutionColorTable;
989 if (pname == GL_COLOR_TABLE_SCALE_SGI) {
990 params[0] = ctx->Pixel.PCCTscale[0];
991 params[1] = ctx->Pixel.PCCTscale[1];
992 params[2] = ctx->Pixel.PCCTscale[2];
993 params[3] = ctx->Pixel.PCCTscale[3];
994 return;
995 }
996 else if (pname == GL_COLOR_TABLE_BIAS_SGI) {
997 params[0] = ctx->Pixel.PCCTbias[0];
998 params[1] = ctx->Pixel.PCCTbias[1];
999 params[2] = ctx->Pixel.PCCTbias[2];
1000 params[3] = ctx->Pixel.PCCTbias[3];
1001 return;
1002 }
1003 break;
1004 case GL_PROXY_POST_CONVOLUTION_COLOR_TABLE:
1005 table = &ctx->ProxyPostConvolutionColorTable;
1006 break;
1007 case GL_POST_COLOR_MATRIX_COLOR_TABLE:
1008 table = &ctx->PostColorMatrixColorTable;
1009 if (pname == GL_COLOR_TABLE_SCALE_SGI) {
1010 params[0] = ctx->Pixel.PCMCTscale[0];
1011 params[1] = ctx->Pixel.PCMCTscale[1];
1012 params[2] = ctx->Pixel.PCMCTscale[2];
1013 params[3] = ctx->Pixel.PCMCTscale[3];
1014 return;
1015 }
1016 else if (pname == GL_COLOR_TABLE_BIAS_SGI) {
1017 params[0] = ctx->Pixel.PCMCTbias[0];
1018 params[1] = ctx->Pixel.PCMCTbias[1];
1019 params[2] = ctx->Pixel.PCMCTbias[2];
1020 params[3] = ctx->Pixel.PCMCTbias[3];
1021 return;
1022 }
1023 break;
1024 case GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE:
1025 table = &ctx->ProxyPostColorMatrixColorTable;
1026 break;
1027 default:
1028 gl_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameterfv(target)");
1029 return;
1030 }
1031
1032 assert(table);
1033
1034 switch (pname) {
1035 case GL_COLOR_TABLE_FORMAT:
1036 *params = table->IntFormat;
1037 break;
1038 case GL_COLOR_TABLE_WIDTH:
1039 *params = table->Size;
1040 break;
1041 case GL_COLOR_TABLE_RED_SIZE:
1042 *params = table->RedSize;
1043 break;
1044 case GL_COLOR_TABLE_GREEN_SIZE:
1045 *params = table->GreenSize;
1046 break;
1047 case GL_COLOR_TABLE_BLUE_SIZE:
1048 *params = table->BlueSize;
1049 break;
1050 case GL_COLOR_TABLE_ALPHA_SIZE:
1051 *params = table->AlphaSize;
1052 break;
1053 case GL_COLOR_TABLE_LUMINANCE_SIZE:
1054 *params = table->LuminanceSize;
1055 break;
1056 case GL_COLOR_TABLE_INTENSITY_SIZE:
1057 *params = table->IntensitySize;
1058 break;
1059 default:
1060 gl_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameterfv(pname)" );
1061 return;
1062 }
1063 }
1064
1065
1066
1067 void
1068 _mesa_GetColorTableParameteriv( GLenum target, GLenum pname, GLint *params )
1069 {
1070 GET_CURRENT_CONTEXT(ctx);
1071 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
1072 struct gl_color_table *table = NULL;
1073
1074 ASSERT_OUTSIDE_BEGIN_END(ctx, "glGetColorTableParameteriv");
1075
1076 switch (target) {
1077 case GL_TEXTURE_1D:
1078 table = &texUnit->CurrentD[1]->Palette;
1079 break;
1080 case GL_TEXTURE_2D:
1081 table = &texUnit->CurrentD[2]->Palette;
1082 break;
1083 case GL_TEXTURE_3D:
1084 table = &texUnit->CurrentD[3]->Palette;
1085 break;
1086 case GL_PROXY_TEXTURE_1D:
1087 table = &ctx->Texture.Proxy1D->Palette;
1088 break;
1089 case GL_PROXY_TEXTURE_2D:
1090 table = &ctx->Texture.Proxy2D->Palette;
1091 break;
1092 case GL_PROXY_TEXTURE_3D:
1093 table = &ctx->Texture.Proxy3D->Palette;
1094 break;
1095 case GL_SHARED_TEXTURE_PALETTE_EXT:
1096 table = &ctx->Texture.Palette;
1097 break;
1098 case GL_COLOR_TABLE:
1099 table = &ctx->ColorTable;
1100 if (pname == GL_COLOR_TABLE_SCALE_SGI) {
1101 params[0] = (GLint) ctx->Pixel.ColorTableScale[0];
1102 params[1] = (GLint) ctx->Pixel.ColorTableScale[1];
1103 params[2] = (GLint) ctx->Pixel.ColorTableScale[2];
1104 params[3] = (GLint) ctx->Pixel.ColorTableScale[3];
1105 return;
1106 }
1107 else if (pname == GL_COLOR_TABLE_BIAS_SGI) {
1108 params[0] = (GLint) ctx->Pixel.ColorTableBias[0];
1109 params[1] = (GLint) ctx->Pixel.ColorTableBias[1];
1110 params[2] = (GLint) ctx->Pixel.ColorTableBias[2];
1111 params[3] = (GLint) ctx->Pixel.ColorTableBias[3];
1112 return;
1113 }
1114 break;
1115 case GL_PROXY_COLOR_TABLE:
1116 table = &ctx->ProxyColorTable;
1117 break;
1118 case GL_POST_CONVOLUTION_COLOR_TABLE:
1119 table = &ctx->PostConvolutionColorTable;
1120 if (pname == GL_COLOR_TABLE_SCALE_SGI) {
1121 params[0] = (GLint) ctx->Pixel.PCCTscale[0];
1122 params[1] = (GLint) ctx->Pixel.PCCTscale[1];
1123 params[2] = (GLint) ctx->Pixel.PCCTscale[2];
1124 params[3] = (GLint) ctx->Pixel.PCCTscale[3];
1125 return;
1126 }
1127 else if (pname == GL_COLOR_TABLE_BIAS_SGI) {
1128 params[0] = (GLint) ctx->Pixel.PCCTbias[0];
1129 params[1] = (GLint) ctx->Pixel.PCCTbias[1];
1130 params[2] = (GLint) ctx->Pixel.PCCTbias[2];
1131 params[3] = (GLint) ctx->Pixel.PCCTbias[3];
1132 return;
1133 }
1134 break;
1135 case GL_PROXY_POST_CONVOLUTION_COLOR_TABLE:
1136 table = &ctx->ProxyPostConvolutionColorTable;
1137 break;
1138 case GL_POST_COLOR_MATRIX_COLOR_TABLE:
1139 table = &ctx->PostColorMatrixColorTable;
1140 if (pname == GL_COLOR_TABLE_SCALE_SGI) {
1141 params[0] = (GLint) ctx->Pixel.PCMCTscale[0];
1142 params[1] = (GLint) ctx->Pixel.PCMCTscale[1];
1143 params[2] = (GLint) ctx->Pixel.PCMCTscale[2];
1144 params[3] = (GLint) ctx->Pixel.PCMCTscale[3];
1145 return;
1146 }
1147 else if (pname == GL_COLOR_TABLE_BIAS_SGI) {
1148 params[0] = (GLint) ctx->Pixel.PCMCTbias[0];
1149 params[1] = (GLint) ctx->Pixel.PCMCTbias[1];
1150 params[2] = (GLint) ctx->Pixel.PCMCTbias[2];
1151 params[3] = (GLint) ctx->Pixel.PCMCTbias[3];
1152 return;
1153 }
1154 break;
1155 case GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE:
1156 table = &ctx->ProxyPostColorMatrixColorTable;
1157 break;
1158 default:
1159 gl_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameteriv(target)");
1160 return;
1161 }
1162
1163 assert(table);
1164
1165 switch (pname) {
1166 case GL_COLOR_TABLE_FORMAT:
1167 *params = table->IntFormat;
1168 break;
1169 case GL_COLOR_TABLE_WIDTH:
1170 *params = table->Size;
1171 break;
1172 case GL_COLOR_TABLE_RED_SIZE:
1173 *params = table->RedSize;
1174 break;
1175 case GL_COLOR_TABLE_GREEN_SIZE:
1176 *params = table->GreenSize;
1177 break;
1178 case GL_COLOR_TABLE_BLUE_SIZE:
1179 *params = table->BlueSize;
1180 break;
1181 case GL_COLOR_TABLE_ALPHA_SIZE:
1182 *params = table->AlphaSize;
1183 break;
1184 case GL_COLOR_TABLE_LUMINANCE_SIZE:
1185 *params = table->LuminanceSize;
1186 break;
1187 case GL_COLOR_TABLE_INTENSITY_SIZE:
1188 *params = table->IntensitySize;
1189 break;
1190 default:
1191 gl_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameteriv(pname)" );
1192 return;
1193 }
1194 }