diff options
author | Brian Paul <[email protected]> | 2006-04-27 02:50:31 +0000 |
---|---|---|
committer | Brian Paul <[email protected]> | 2006-04-27 02:50:31 +0000 |
commit | c4fe46f0b8b45407ea40500b869ae1beca71063c (patch) | |
tree | 49278ff60f8e6af5f127cff10c266565245f2f4c /src/mesa/main | |
parent | 444cd293fd69d1848b2c55f75674d563e0582fba (diff) |
fixes for CHAN_BITS!=8
Diffstat (limited to 'src/mesa/main')
-rw-r--r-- | src/mesa/main/colortab.c | 64 |
1 files changed, 50 insertions, 14 deletions
diff --git a/src/mesa/main/colortab.c b/src/mesa/main/colortab.c index e2f95cf7f9b..8b6fc127fe9 100644 --- a/src/mesa/main/colortab.c +++ b/src/mesa/main/colortab.c @@ -767,7 +767,11 @@ _mesa_GetColorTable( GLenum target, GLenum format, rgba[i][RCOMP] = 0; rgba[i][GCOMP] = 0; rgba[i][BCOMP] = 0; +#if CHAN_BITS==32 + rgba[i][ACOMP] = tableF[i]; +#else rgba[i][ACOMP] = IROUND_POS(tableF[i] * CHAN_MAXF); +#endif } } else { @@ -786,18 +790,25 @@ _mesa_GetColorTable( GLenum target, GLenum format, const GLfloat *tableF = (const GLfloat *) table->Table; GLuint i; for (i = 0; i < table->Size; i++) { - rgba[i][RCOMP] = IROUND_POS(tableF[i] * CHAN_MAXF); - rgba[i][GCOMP] = IROUND_POS(tableF[i] * CHAN_MAXF); +#if CHAN_BITS==32 + rgba[i][RCOMP] = + rgba[i][GCOMP] = + rgba[i][BCOMP] = tableF[i]; + rgba[i][ACOMP] = CHAN_MAX; +#else + rgba[i][RCOMP] = + rgba[i][GCOMP] = rgba[i][BCOMP] = IROUND_POS(tableF[i] * CHAN_MAXF); rgba[i][ACOMP] = CHAN_MAX; +#endif } } else { const GLchan *tableUB = (const GLchan *) table->Table; GLuint i; for (i = 0; i < table->Size; i++) { - rgba[i][RCOMP] = tableUB[i]; - rgba[i][GCOMP] = tableUB[i]; + rgba[i][RCOMP] = + rgba[i][GCOMP] = rgba[i][BCOMP] = tableUB[i]; rgba[i][ACOMP] = CHAN_MAX; } @@ -808,18 +819,25 @@ _mesa_GetColorTable( GLenum target, GLenum format, const GLfloat *tableF = (const GLfloat *) table->Table; GLuint i; for (i = 0; i < table->Size; i++) { - rgba[i][RCOMP] = IROUND_POS(tableF[i*2+0] * CHAN_MAXF); - rgba[i][GCOMP] = IROUND_POS(tableF[i*2+0] * CHAN_MAXF); +#if CHAN_BITS==32 + rgba[i][RCOMP] = + rgba[i][GCOMP] = + rgba[i][BCOMP] = tableF[i*2+0]; + rgba[i][ACOMP] = tableF[i*2+1]; +#else + rgba[i][RCOMP] = + rgba[i][GCOMP] = rgba[i][BCOMP] = IROUND_POS(tableF[i*2+0] * CHAN_MAXF); rgba[i][ACOMP] = IROUND_POS(tableF[i*2+1] * CHAN_MAXF); +#endif } } else { const GLchan *tableUB = (const GLchan *) table->Table; GLuint i; for (i = 0; i < table->Size; i++) { - rgba[i][RCOMP] = tableUB[i*2+0]; - rgba[i][GCOMP] = tableUB[i*2+0]; + rgba[i][RCOMP] = + rgba[i][GCOMP] = rgba[i][BCOMP] = tableUB[i*2+0]; rgba[i][ACOMP] = tableUB[i*2+1]; } @@ -830,19 +848,26 @@ _mesa_GetColorTable( GLenum target, GLenum format, const GLfloat *tableF = (const GLfloat *) table->Table; GLuint i; for (i = 0; i < table->Size; i++) { - rgba[i][RCOMP] = IROUND_POS(tableF[i] * CHAN_MAXF); - rgba[i][GCOMP] = IROUND_POS(tableF[i] * CHAN_MAXF); - rgba[i][BCOMP] = IROUND_POS(tableF[i] * CHAN_MAXF); +#if CHAN_BITS==32 + rgba[i][RCOMP] = + rgba[i][GCOMP] = + rgba[i][BCOMP] = + rgba[i][ACOMP] = tableF[i]; +#else + rgba[i][RCOMP] = + rgba[i][GCOMP] = + rgba[i][BCOMP] = rgba[i][ACOMP] = IROUND_POS(tableF[i] * CHAN_MAXF); +#endif } } else { const GLchan *tableUB = (const GLchan *) table->Table; GLuint i; for (i = 0; i < table->Size; i++) { - rgba[i][RCOMP] = tableUB[i]; - rgba[i][GCOMP] = tableUB[i]; - rgba[i][BCOMP] = tableUB[i]; + rgba[i][RCOMP] = + rgba[i][GCOMP] = + rgba[i][BCOMP] = rgba[i][ACOMP] = tableUB[i]; } } @@ -852,10 +877,17 @@ _mesa_GetColorTable( GLenum target, GLenum format, const GLfloat *tableF = (const GLfloat *) table->Table; GLuint i; for (i = 0; i < table->Size; i++) { +#if CHAN_BITS==32 + rgba[i][RCOMP] = tableF[i*3+0]; + rgba[i][GCOMP] = tableF[i*3+1]; + rgba[i][BCOMP] = tableF[i*3+2]; + rgba[i][ACOMP] = CHAN_MAX; +#else rgba[i][RCOMP] = IROUND_POS(tableF[i*3+0] * CHAN_MAXF); rgba[i][GCOMP] = IROUND_POS(tableF[i*3+1] * CHAN_MAXF); rgba[i][BCOMP] = IROUND_POS(tableF[i*3+2] * CHAN_MAXF); rgba[i][ACOMP] = CHAN_MAX; +#endif } } else { @@ -872,6 +904,9 @@ _mesa_GetColorTable( GLenum target, GLenum format, case GL_RGBA: if (table->Type == GL_FLOAT) { const GLfloat *tableF = (const GLfloat *) table->Table; +#if CHAN_BITS==32 + _mesa_memcpy(rgba, tableF, 4 * table->Size * sizeof(GLfloat)); +#else GLuint i; for (i = 0; i < table->Size; i++) { rgba[i][RCOMP] = IROUND_POS(tableF[i*4+0] * CHAN_MAXF); @@ -879,6 +914,7 @@ _mesa_GetColorTable( GLenum target, GLenum format, rgba[i][BCOMP] = IROUND_POS(tableF[i*4+2] * CHAN_MAXF); rgba[i][ACOMP] = IROUND_POS(tableF[i*4+3] * CHAN_MAXF); } +#endif } else { const GLchan *tableUB = (const GLchan *) table->Table; |