-/* $Id: image.c,v 1.25 2000/04/08 18:57:45 brianp Exp $ */
+/* $Id: image.c,v 1.26 2000/04/12 18:54:48 brianp Exp $ */
/*
* Mesa 3-D graphics library
*/
void
_mesa_pack_rgba_span( const GLcontext *ctx,
- GLuint n, CONST GLubyte rgba[][4],
+ GLuint n, CONST GLubyte srcRgba[][4],
GLenum format, GLenum type, GLvoid *destination,
const struct gl_pixelstore_attrib *packing,
GLboolean applyTransferOps )
{
- applyTransferOps &= (ctx->Pixel.ScaleOrBiasRGBA || ctx->Pixel.MapColorFlag);
+ applyTransferOps &= (ctx->Pixel.ScaleOrBiasRGBA ||
+ ctx->Pixel.MapColorFlag ||
+ ctx->ColorMatrix.type != MATRIX_IDENTITY ||
+ ctx->Pixel.ScaleOrBiasRGBApcm ||
+ ctx->Pixel.ColorTableEnabled);
/* Test for optimized case first */
if (!applyTransferOps && format == GL_RGBA && type == GL_UNSIGNED_BYTE) {
/* common simple case */
- MEMCPY( destination, rgba, n * 4 * sizeof(GLubyte) );
+ MEMCPY( destination, srcRgba, n * 4 * sizeof(GLubyte) );
}
else if (!applyTransferOps && format == GL_RGB && type == GL_UNSIGNED_BYTE) {
/* common simple case */
GLint i;
GLubyte *dest = (GLubyte *) destination;
for (i = 0; i < n; i++) {
- dest[0] = rgba[i][RCOMP];
- dest[1] = rgba[i][GCOMP];
- dest[2] = rgba[i][BCOMP];
+ dest[0] = srcRgba[i][RCOMP];
+ dest[1] = srcRgba[i][GCOMP];
+ dest[2] = srcRgba[i][BCOMP];
dest += 3;
}
}
else {
/* general solution */
- GLfloat red[MAX_WIDTH], green[MAX_WIDTH], blue[MAX_WIDTH];
- GLfloat alpha[MAX_WIDTH], luminance[MAX_WIDTH];
+ GLfloat rgba[MAX_WIDTH][4], luminance[MAX_WIDTH];
const GLfloat rscale = 1.0F / 255.0F;
const GLfloat gscale = 1.0F / 255.0F;
const GLfloat bscale = 1.0F / 255.0F;
/* convert color components to floating point */
for (i=0;i<n;i++) {
- red[i] = rgba[i][RCOMP] * rscale;
- green[i] = rgba[i][GCOMP] * gscale;
- blue[i] = rgba[i][BCOMP] * bscale;
- alpha[i] = rgba[i][ACOMP] * ascale;
+ rgba[i][RCOMP] = srcRgba[i][RCOMP] * rscale;
+ rgba[i][GCOMP] = srcRgba[i][GCOMP] * gscale;
+ rgba[i][BCOMP] = srcRgba[i][BCOMP] * bscale;
+ rgba[i][ACOMP] = srcRgba[i][ACOMP] * ascale;
}
/*
* Apply scale, bias and lookup-tables if enabled.
*/
if (applyTransferOps) {
+ /* scale & bias */
if (ctx->Pixel.ScaleOrBiasRGBA) {
- gl_scale_and_bias_color( ctx, n, red, green, blue, alpha );
+ _mesa_scale_and_bias_rgba( ctx, n, rgba );
}
+ /* color table lookup */
if (ctx->Pixel.MapColorFlag) {
- gl_map_color( ctx, n, red, green, blue, alpha );
+ _mesa_map_rgba( ctx, n, rgba );
+ }
+ /* color matrix */
+ if (ctx->ColorMatrix.type != MATRIX_IDENTITY ||
+ ctx->Pixel.ScaleOrBiasRGBApcm) {
+ _mesa_transform_rgba(ctx, n, rgba);
+ }
+ /* GL_SGI_color_table lookup */
+ if (ctx->Pixel.ColorTableEnabled) {
+ _mesa_lookup_rgba(&ctx->ColorTable, n, rgba);
}
}
if (format==GL_LUMINANCE || format==GL_LUMINANCE_ALPHA) {
for (i=0;i<n;i++) {
- GLfloat sum = red[i] + green[i] + blue[i];
+ GLfloat sum = rgba[i][RCOMP] + rgba[i][GCOMP] + rgba[i][BCOMP];
luminance[i] = CLAMP( sum, 0.0F, 1.0F );
}
}
switch (format) {
case GL_RED:
for (i=0;i<n;i++)
- dst[i] = FLOAT_TO_UBYTE(red[i]);
+ dst[i] = FLOAT_TO_UBYTE(rgba[i][RCOMP]);
break;
case GL_GREEN:
for (i=0;i<n;i++)
- dst[i] = FLOAT_TO_UBYTE(green[i]);
+ dst[i] = FLOAT_TO_UBYTE(rgba[i][GCOMP]);
break;
case GL_BLUE:
for (i=0;i<n;i++)
- dst[i] = FLOAT_TO_UBYTE(blue[i]);
+ dst[i] = FLOAT_TO_UBYTE(rgba[i][BCOMP]);
break;
case GL_ALPHA:
for (i=0;i<n;i++)
- dst[i] = FLOAT_TO_UBYTE(alpha[i]);
+ dst[i] = FLOAT_TO_UBYTE(rgba[i][ACOMP]);
break;
case GL_LUMINANCE:
for (i=0;i<n;i++)
case GL_LUMINANCE_ALPHA:
for (i=0;i<n;i++) {
dst[i*2+0] = FLOAT_TO_UBYTE(luminance[i]);
- dst[i*2+1] = FLOAT_TO_UBYTE(alpha[i]);
+ dst[i*2+1] = FLOAT_TO_UBYTE(rgba[i][ACOMP]);
}
break;
case GL_RGB:
for (i=0;i<n;i++) {
- dst[i*3+0] = FLOAT_TO_UBYTE(red[i]);
- dst[i*3+1] = FLOAT_TO_UBYTE(green[i]);
- dst[i*3+2] = FLOAT_TO_UBYTE(blue[i]);
+ dst[i*3+0] = FLOAT_TO_UBYTE(rgba[i][RCOMP]);
+ dst[i*3+1] = FLOAT_TO_UBYTE(rgba[i][GCOMP]);
+ dst[i*3+2] = FLOAT_TO_UBYTE(rgba[i][BCOMP]);
}
break;
case GL_RGBA:
for (i=0;i<n;i++) {
- dst[i*4+0] = FLOAT_TO_UBYTE(red[i]);
- dst[i*4+1] = FLOAT_TO_UBYTE(green[i]);
- dst[i*4+2] = FLOAT_TO_UBYTE(blue[i]);
- dst[i*4+3] = FLOAT_TO_UBYTE(alpha[i]);
+ dst[i*4+0] = FLOAT_TO_UBYTE(rgba[i][RCOMP]);
+ dst[i*4+1] = FLOAT_TO_UBYTE(rgba[i][GCOMP]);
+ dst[i*4+2] = FLOAT_TO_UBYTE(rgba[i][BCOMP]);
+ dst[i*4+3] = FLOAT_TO_UBYTE(rgba[i][ACOMP]);
}
break;
case GL_BGR:
for (i=0;i<n;i++) {
- dst[i*3+0] = FLOAT_TO_UBYTE(blue[i]);
- dst[i*3+1] = FLOAT_TO_UBYTE(green[i]);
- dst[i*3+2] = FLOAT_TO_UBYTE(red[i]);
+ dst[i*3+0] = FLOAT_TO_UBYTE(rgba[i][BCOMP]);
+ dst[i*3+1] = FLOAT_TO_UBYTE(rgba[i][GCOMP]);
+ dst[i*3+2] = FLOAT_TO_UBYTE(rgba[i][RCOMP]);
}
break;
case GL_BGRA:
for (i=0;i<n;i++) {
- dst[i*4+0] = FLOAT_TO_UBYTE(blue[i]);
- dst[i*4+1] = FLOAT_TO_UBYTE(green[i]);
- dst[i*4+2] = FLOAT_TO_UBYTE(red[i]);
- dst[i*4+3] = FLOAT_TO_UBYTE(alpha[i]);
+ dst[i*4+0] = FLOAT_TO_UBYTE(rgba[i][BCOMP]);
+ dst[i*4+1] = FLOAT_TO_UBYTE(rgba[i][GCOMP]);
+ dst[i*4+2] = FLOAT_TO_UBYTE(rgba[i][RCOMP]);
+ dst[i*4+3] = FLOAT_TO_UBYTE(rgba[i][ACOMP]);
}
break;
case GL_ABGR_EXT:
for (i=0;i<n;i++) {
- dst[i*4+0] = FLOAT_TO_UBYTE(alpha[i]);
- dst[i*4+1] = FLOAT_TO_UBYTE(blue[i]);
- dst[i*4+2] = FLOAT_TO_UBYTE(green[i]);
- dst[i*4+3] = FLOAT_TO_UBYTE(red[i]);
+ dst[i*4+0] = FLOAT_TO_UBYTE(rgba[i][ACOMP]);
+ dst[i*4+1] = FLOAT_TO_UBYTE(rgba[i][BCOMP]);
+ dst[i*4+2] = FLOAT_TO_UBYTE(rgba[i][GCOMP]);
+ dst[i*4+3] = FLOAT_TO_UBYTE(rgba[i][RCOMP]);
}
break;
default:
switch (format) {
case GL_RED:
for (i=0;i<n;i++)
- dst[i] = FLOAT_TO_BYTE(red[i]);
+ dst[i] = FLOAT_TO_BYTE(rgba[i][RCOMP]);
break;
case GL_GREEN:
for (i=0;i<n;i++)
- dst[i] = FLOAT_TO_BYTE(green[i]);
+ dst[i] = FLOAT_TO_BYTE(rgba[i][GCOMP]);
break;
case GL_BLUE:
for (i=0;i<n;i++)
- dst[i] = FLOAT_TO_BYTE(blue[i]);
+ dst[i] = FLOAT_TO_BYTE(rgba[i][BCOMP]);
break;
case GL_ALPHA:
for (i=0;i<n;i++)
- dst[i] = FLOAT_TO_BYTE(alpha[i]);
+ dst[i] = FLOAT_TO_BYTE(rgba[i][ACOMP]);
break;
case GL_LUMINANCE:
for (i=0;i<n;i++)
case GL_LUMINANCE_ALPHA:
for (i=0;i<n;i++) {
dst[i*2+0] = FLOAT_TO_BYTE(luminance[i]);
- dst[i*2+1] = FLOAT_TO_BYTE(alpha[i]);
+ dst[i*2+1] = FLOAT_TO_BYTE(rgba[i][ACOMP]);
}
break;
case GL_RGB:
for (i=0;i<n;i++) {
- dst[i*3+0] = FLOAT_TO_BYTE(red[i]);
- dst[i*3+1] = FLOAT_TO_BYTE(green[i]);
- dst[i*3+2] = FLOAT_TO_BYTE(blue[i]);
+ dst[i*3+0] = FLOAT_TO_BYTE(rgba[i][RCOMP]);
+ dst[i*3+1] = FLOAT_TO_BYTE(rgba[i][GCOMP]);
+ dst[i*3+2] = FLOAT_TO_BYTE(rgba[i][BCOMP]);
}
break;
case GL_RGBA:
for (i=0;i<n;i++) {
- dst[i*4+0] = FLOAT_TO_BYTE(red[i]);
- dst[i*4+1] = FLOAT_TO_BYTE(green[i]);
- dst[i*4+2] = FLOAT_TO_BYTE(blue[i]);
- dst[i*4+3] = FLOAT_TO_BYTE(alpha[i]);
+ dst[i*4+0] = FLOAT_TO_BYTE(rgba[i][RCOMP]);
+ dst[i*4+1] = FLOAT_TO_BYTE(rgba[i][GCOMP]);
+ dst[i*4+2] = FLOAT_TO_BYTE(rgba[i][BCOMP]);
+ dst[i*4+3] = FLOAT_TO_BYTE(rgba[i][ACOMP]);
}
break;
case GL_BGR:
for (i=0;i<n;i++) {
- dst[i*3+0] = FLOAT_TO_BYTE(blue[i]);
- dst[i*3+1] = FLOAT_TO_BYTE(green[i]);
- dst[i*3+2] = FLOAT_TO_BYTE(red[i]);
+ dst[i*3+0] = FLOAT_TO_BYTE(rgba[i][BCOMP]);
+ dst[i*3+1] = FLOAT_TO_BYTE(rgba[i][GCOMP]);
+ dst[i*3+2] = FLOAT_TO_BYTE(rgba[i][RCOMP]);
}
break;
case GL_BGRA:
for (i=0;i<n;i++) {
- dst[i*4+0] = FLOAT_TO_BYTE(blue[i]);
- dst[i*4+1] = FLOAT_TO_BYTE(green[i]);
- dst[i*4+2] = FLOAT_TO_BYTE(red[i]);
- dst[i*4+3] = FLOAT_TO_BYTE(alpha[i]);
+ dst[i*4+0] = FLOAT_TO_BYTE(rgba[i][BCOMP]);
+ dst[i*4+1] = FLOAT_TO_BYTE(rgba[i][GCOMP]);
+ dst[i*4+2] = FLOAT_TO_BYTE(rgba[i][RCOMP]);
+ dst[i*4+3] = FLOAT_TO_BYTE(rgba[i][ACOMP]);
}
case GL_ABGR_EXT:
for (i=0;i<n;i++) {
- dst[i*4+0] = FLOAT_TO_BYTE(alpha[i]);
- dst[i*4+1] = FLOAT_TO_BYTE(blue[i]);
- dst[i*4+2] = FLOAT_TO_BYTE(green[i]);
- dst[i*4+3] = FLOAT_TO_BYTE(red[i]);
+ dst[i*4+0] = FLOAT_TO_BYTE(rgba[i][ACOMP]);
+ dst[i*4+1] = FLOAT_TO_BYTE(rgba[i][BCOMP]);
+ dst[i*4+2] = FLOAT_TO_BYTE(rgba[i][GCOMP]);
+ dst[i*4+3] = FLOAT_TO_BYTE(rgba[i][RCOMP]);
}
break;
default:
switch (format) {
case GL_RED:
for (i=0;i<n;i++)
- dst[i] = FLOAT_TO_USHORT(red[i]);
+ dst[i] = FLOAT_TO_USHORT(rgba[i][RCOMP]);
break;
case GL_GREEN:
for (i=0;i<n;i++)
- dst[i] = FLOAT_TO_USHORT(green[i]);
+ dst[i] = FLOAT_TO_USHORT(rgba[i][GCOMP]);
break;
case GL_BLUE:
for (i=0;i<n;i++)
- dst[i] = FLOAT_TO_USHORT(blue[i]);
+ dst[i] = FLOAT_TO_USHORT(rgba[i][BCOMP]);
break;
case GL_ALPHA:
for (i=0;i<n;i++)
- dst[i] = FLOAT_TO_USHORT(alpha[i]);
+ dst[i] = FLOAT_TO_USHORT(rgba[i][ACOMP]);
break;
case GL_LUMINANCE:
for (i=0;i<n;i++)
case GL_LUMINANCE_ALPHA:
for (i=0;i<n;i++) {
dst[i*2+0] = FLOAT_TO_USHORT(luminance[i]);
- dst[i*2+1] = FLOAT_TO_USHORT(alpha[i]);
+ dst[i*2+1] = FLOAT_TO_USHORT(rgba[i][ACOMP]);
}
break;
case GL_RGB:
for (i=0;i<n;i++) {
- dst[i*3+0] = FLOAT_TO_USHORT(red[i]);
- dst[i*3+1] = FLOAT_TO_USHORT(green[i]);
- dst[i*3+2] = FLOAT_TO_USHORT(blue[i]);
+ dst[i*3+0] = FLOAT_TO_USHORT(rgba[i][RCOMP]);
+ dst[i*3+1] = FLOAT_TO_USHORT(rgba[i][GCOMP]);
+ dst[i*3+2] = FLOAT_TO_USHORT(rgba[i][BCOMP]);
}
break;
case GL_RGBA:
for (i=0;i<n;i++) {
- dst[i*4+0] = FLOAT_TO_USHORT(red[i]);
- dst[i*4+1] = FLOAT_TO_USHORT(green[i]);
- dst[i*4+2] = FLOAT_TO_USHORT(blue[i]);
- dst[i*4+3] = FLOAT_TO_USHORT(alpha[i]);
+ dst[i*4+0] = FLOAT_TO_USHORT(rgba[i][RCOMP]);
+ dst[i*4+1] = FLOAT_TO_USHORT(rgba[i][GCOMP]);
+ dst[i*4+2] = FLOAT_TO_USHORT(rgba[i][BCOMP]);
+ dst[i*4+3] = FLOAT_TO_USHORT(rgba[i][ACOMP]);
}
break;
case GL_BGR:
for (i=0;i<n;i++) {
- dst[i*3+0] = FLOAT_TO_USHORT(blue[i]);
- dst[i*3+1] = FLOAT_TO_USHORT(green[i]);
- dst[i*3+2] = FLOAT_TO_USHORT(red[i]);
+ dst[i*3+0] = FLOAT_TO_USHORT(rgba[i][BCOMP]);
+ dst[i*3+1] = FLOAT_TO_USHORT(rgba[i][GCOMP]);
+ dst[i*3+2] = FLOAT_TO_USHORT(rgba[i][RCOMP]);
}
break;
case GL_BGRA:
for (i=0;i<n;i++) {
- dst[i*4+0] = FLOAT_TO_USHORT(blue[i]);
- dst[i*4+1] = FLOAT_TO_USHORT(green[i]);
- dst[i*4+2] = FLOAT_TO_USHORT(red[i]);
- dst[i*4+3] = FLOAT_TO_USHORT(alpha[i]);
+ dst[i*4+0] = FLOAT_TO_USHORT(rgba[i][BCOMP]);
+ dst[i*4+1] = FLOAT_TO_USHORT(rgba[i][GCOMP]);
+ dst[i*4+2] = FLOAT_TO_USHORT(rgba[i][RCOMP]);
+ dst[i*4+3] = FLOAT_TO_USHORT(rgba[i][ACOMP]);
}
break;
case GL_ABGR_EXT:
for (i=0;i<n;i++) {
- dst[i*4+0] = FLOAT_TO_USHORT(alpha[i]);
- dst[i*4+1] = FLOAT_TO_USHORT(blue[i]);
- dst[i*4+2] = FLOAT_TO_USHORT(green[i]);
- dst[i*4+3] = FLOAT_TO_USHORT(red[i]);
+ dst[i*4+0] = FLOAT_TO_USHORT(rgba[i][ACOMP]);
+ dst[i*4+1] = FLOAT_TO_USHORT(rgba[i][BCOMP]);
+ dst[i*4+2] = FLOAT_TO_USHORT(rgba[i][GCOMP]);
+ dst[i*4+3] = FLOAT_TO_USHORT(rgba[i][RCOMP]);
}
break;
default:
switch (format) {
case GL_RED:
for (i=0;i<n;i++)
- dst[i] = FLOAT_TO_SHORT(red[i]);
+ dst[i] = FLOAT_TO_SHORT(rgba[i][RCOMP]);
break;
case GL_GREEN:
for (i=0;i<n;i++)
- dst[i] = FLOAT_TO_SHORT(green[i]);
+ dst[i] = FLOAT_TO_SHORT(rgba[i][GCOMP]);
break;
case GL_BLUE:
for (i=0;i<n;i++)
- dst[i] = FLOAT_TO_SHORT(blue[i]);
+ dst[i] = FLOAT_TO_SHORT(rgba[i][BCOMP]);
break;
case GL_ALPHA:
for (i=0;i<n;i++)
- dst[i] = FLOAT_TO_SHORT(alpha[i]);
+ dst[i] = FLOAT_TO_SHORT(rgba[i][ACOMP]);
break;
case GL_LUMINANCE:
for (i=0;i<n;i++)
case GL_LUMINANCE_ALPHA:
for (i=0;i<n;i++) {
dst[i*2+0] = FLOAT_TO_SHORT(luminance[i]);
- dst[i*2+1] = FLOAT_TO_SHORT(alpha[i]);
+ dst[i*2+1] = FLOAT_TO_SHORT(rgba[i][ACOMP]);
}
break;
case GL_RGB:
for (i=0;i<n;i++) {
- dst[i*3+0] = FLOAT_TO_SHORT(red[i]);
- dst[i*3+1] = FLOAT_TO_SHORT(green[i]);
- dst[i*3+2] = FLOAT_TO_SHORT(blue[i]);
+ dst[i*3+0] = FLOAT_TO_SHORT(rgba[i][RCOMP]);
+ dst[i*3+1] = FLOAT_TO_SHORT(rgba[i][GCOMP]);
+ dst[i*3+2] = FLOAT_TO_SHORT(rgba[i][BCOMP]);
}
break;
case GL_RGBA:
for (i=0;i<n;i++) {
- dst[i*4+0] = FLOAT_TO_SHORT(red[i]);
- dst[i*4+1] = FLOAT_TO_SHORT(green[i]);
- dst[i*4+2] = FLOAT_TO_SHORT(blue[i]);
- dst[i*4+3] = FLOAT_TO_SHORT(alpha[i]);
+ dst[i*4+0] = FLOAT_TO_SHORT(rgba[i][RCOMP]);
+ dst[i*4+1] = FLOAT_TO_SHORT(rgba[i][GCOMP]);
+ dst[i*4+2] = FLOAT_TO_SHORT(rgba[i][BCOMP]);
+ dst[i*4+3] = FLOAT_TO_SHORT(rgba[i][ACOMP]);
}
break;
case GL_BGR:
for (i=0;i<n;i++) {
- dst[i*3+0] = FLOAT_TO_SHORT(blue[i]);
- dst[i*3+1] = FLOAT_TO_SHORT(green[i]);
- dst[i*3+2] = FLOAT_TO_SHORT(red[i]);
+ dst[i*3+0] = FLOAT_TO_SHORT(rgba[i][BCOMP]);
+ dst[i*3+1] = FLOAT_TO_SHORT(rgba[i][GCOMP]);
+ dst[i*3+2] = FLOAT_TO_SHORT(rgba[i][RCOMP]);
}
break;
case GL_BGRA:
for (i=0;i<n;i++) {
- dst[i*4+0] = FLOAT_TO_SHORT(blue[i]);
- dst[i*4+1] = FLOAT_TO_SHORT(green[i]);
- dst[i*4+2] = FLOAT_TO_SHORT(red[i]);
- dst[i*4+3] = FLOAT_TO_SHORT(alpha[i]);
+ dst[i*4+0] = FLOAT_TO_SHORT(rgba[i][BCOMP]);
+ dst[i*4+1] = FLOAT_TO_SHORT(rgba[i][GCOMP]);
+ dst[i*4+2] = FLOAT_TO_SHORT(rgba[i][RCOMP]);
+ dst[i*4+3] = FLOAT_TO_SHORT(rgba[i][ACOMP]);
}
case GL_ABGR_EXT:
for (i=0;i<n;i++) {
- dst[i*4+0] = FLOAT_TO_SHORT(alpha[i]);
- dst[i*4+1] = FLOAT_TO_SHORT(blue[i]);
- dst[i*4+2] = FLOAT_TO_SHORT(green[i]);
- dst[i*4+3] = FLOAT_TO_SHORT(red[i]);
+ dst[i*4+0] = FLOAT_TO_SHORT(rgba[i][ACOMP]);
+ dst[i*4+1] = FLOAT_TO_SHORT(rgba[i][BCOMP]);
+ dst[i*4+2] = FLOAT_TO_SHORT(rgba[i][GCOMP]);
+ dst[i*4+3] = FLOAT_TO_SHORT(rgba[i][RCOMP]);
}
break;
default:
switch (format) {
case GL_RED:
for (i=0;i<n;i++)
- dst[i] = FLOAT_TO_UINT(red[i]);
+ dst[i] = FLOAT_TO_UINT(rgba[i][RCOMP]);
break;
case GL_GREEN:
for (i=0;i<n;i++)
- dst[i] = FLOAT_TO_UINT(green[i]);
+ dst[i] = FLOAT_TO_UINT(rgba[i][GCOMP]);
break;
case GL_BLUE:
for (i=0;i<n;i++)
- dst[i] = FLOAT_TO_UINT(blue[i]);
+ dst[i] = FLOAT_TO_UINT(rgba[i][BCOMP]);
break;
case GL_ALPHA:
for (i=0;i<n;i++)
- dst[i] = FLOAT_TO_UINT(alpha[i]);
+ dst[i] = FLOAT_TO_UINT(rgba[i][ACOMP]);
break;
case GL_LUMINANCE:
for (i=0;i<n;i++)
case GL_LUMINANCE_ALPHA:
for (i=0;i<n;i++) {
dst[i*2+0] = FLOAT_TO_UINT(luminance[i]);
- dst[i*2+1] = FLOAT_TO_UINT(alpha[i]);
+ dst[i*2+1] = FLOAT_TO_UINT(rgba[i][ACOMP]);
}
break;
case GL_RGB:
for (i=0;i<n;i++) {
- dst[i*3+0] = FLOAT_TO_UINT(red[i]);
- dst[i*3+1] = FLOAT_TO_UINT(green[i]);
- dst[i*3+2] = FLOAT_TO_UINT(blue[i]);
+ dst[i*3+0] = FLOAT_TO_UINT(rgba[i][RCOMP]);
+ dst[i*3+1] = FLOAT_TO_UINT(rgba[i][GCOMP]);
+ dst[i*3+2] = FLOAT_TO_UINT(rgba[i][BCOMP]);
}
break;
case GL_RGBA:
for (i=0;i<n;i++) {
- dst[i*4+0] = FLOAT_TO_UINT(red[i]);
- dst[i*4+1] = FLOAT_TO_UINT(green[i]);
- dst[i*4+2] = FLOAT_TO_UINT(blue[i]);
- dst[i*4+3] = FLOAT_TO_UINT(alpha[i]);
+ dst[i*4+0] = FLOAT_TO_UINT(rgba[i][RCOMP]);
+ dst[i*4+1] = FLOAT_TO_UINT(rgba[i][GCOMP]);
+ dst[i*4+2] = FLOAT_TO_UINT(rgba[i][BCOMP]);
+ dst[i*4+3] = FLOAT_TO_UINT(rgba[i][ACOMP]);
}
break;
case GL_BGR:
for (i=0;i<n;i++) {
- dst[i*3+0] = FLOAT_TO_UINT(blue[i]);
- dst[i*3+1] = FLOAT_TO_UINT(green[i]);
- dst[i*3+2] = FLOAT_TO_UINT(red[i]);
+ dst[i*3+0] = FLOAT_TO_UINT(rgba[i][BCOMP]);
+ dst[i*3+1] = FLOAT_TO_UINT(rgba[i][GCOMP]);
+ dst[i*3+2] = FLOAT_TO_UINT(rgba[i][RCOMP]);
}
break;
case GL_BGRA:
for (i=0;i<n;i++) {
- dst[i*4+0] = FLOAT_TO_UINT(blue[i]);
- dst[i*4+1] = FLOAT_TO_UINT(green[i]);
- dst[i*4+2] = FLOAT_TO_UINT(red[i]);
- dst[i*4+3] = FLOAT_TO_UINT(alpha[i]);
+ dst[i*4+0] = FLOAT_TO_UINT(rgba[i][BCOMP]);
+ dst[i*4+1] = FLOAT_TO_UINT(rgba[i][GCOMP]);
+ dst[i*4+2] = FLOAT_TO_UINT(rgba[i][RCOMP]);
+ dst[i*4+3] = FLOAT_TO_UINT(rgba[i][ACOMP]);
}
break;
case GL_ABGR_EXT:
for (i=0;i<n;i++) {
- dst[i*4+0] = FLOAT_TO_UINT(alpha[i]);
- dst[i*4+1] = FLOAT_TO_UINT(blue[i]);
- dst[i*4+2] = FLOAT_TO_UINT(green[i]);
- dst[i*4+3] = FLOAT_TO_UINT(red[i]);
+ dst[i*4+0] = FLOAT_TO_UINT(rgba[i][ACOMP]);
+ dst[i*4+1] = FLOAT_TO_UINT(rgba[i][BCOMP]);
+ dst[i*4+2] = FLOAT_TO_UINT(rgba[i][GCOMP]);
+ dst[i*4+3] = FLOAT_TO_UINT(rgba[i][RCOMP]);
}
break;
default:
switch (format) {
case GL_RED:
for (i=0;i<n;i++)
- dst[i] = FLOAT_TO_INT(red[i]);
+ dst[i] = FLOAT_TO_INT(rgba[i][RCOMP]);
break;
case GL_GREEN:
for (i=0;i<n;i++)
- dst[i] = FLOAT_TO_INT(green[i]);
+ dst[i] = FLOAT_TO_INT(rgba[i][GCOMP]);
break;
case GL_BLUE:
for (i=0;i<n;i++)
- dst[i] = FLOAT_TO_INT(blue[i]);
+ dst[i] = FLOAT_TO_INT(rgba[i][BCOMP]);
break;
case GL_ALPHA:
for (i=0;i<n;i++)
- dst[i] = FLOAT_TO_INT(alpha[i]);
+ dst[i] = FLOAT_TO_INT(rgba[i][ACOMP]);
break;
case GL_LUMINANCE:
for (i=0;i<n;i++)
case GL_LUMINANCE_ALPHA:
for (i=0;i<n;i++) {
dst[i*2+0] = FLOAT_TO_INT(luminance[i]);
- dst[i*2+1] = FLOAT_TO_INT(alpha[i]);
+ dst[i*2+1] = FLOAT_TO_INT(rgba[i][ACOMP]);
}
break;
case GL_RGB:
for (i=0;i<n;i++) {
- dst[i*3+0] = FLOAT_TO_INT(red[i]);
- dst[i*3+1] = FLOAT_TO_INT(green[i]);
- dst[i*3+2] = FLOAT_TO_INT(blue[i]);
+ dst[i*3+0] = FLOAT_TO_INT(rgba[i][RCOMP]);
+ dst[i*3+1] = FLOAT_TO_INT(rgba[i][GCOMP]);
+ dst[i*3+2] = FLOAT_TO_INT(rgba[i][BCOMP]);
}
break;
case GL_RGBA:
for (i=0;i<n;i++) {
- dst[i*4+0] = FLOAT_TO_INT(red[i]);
- dst[i*4+1] = FLOAT_TO_INT(green[i]);
- dst[i*4+2] = FLOAT_TO_INT(blue[i]);
- dst[i*4+3] = FLOAT_TO_INT(alpha[i]);
+ dst[i*4+0] = FLOAT_TO_INT(rgba[i][RCOMP]);
+ dst[i*4+1] = FLOAT_TO_INT(rgba[i][GCOMP]);
+ dst[i*4+2] = FLOAT_TO_INT(rgba[i][BCOMP]);
+ dst[i*4+3] = FLOAT_TO_INT(rgba[i][ACOMP]);
}
break;
case GL_BGR:
for (i=0;i<n;i++) {
- dst[i*3+0] = FLOAT_TO_INT(blue[i]);
- dst[i*3+1] = FLOAT_TO_INT(green[i]);
- dst[i*3+2] = FLOAT_TO_INT(red[i]);
+ dst[i*3+0] = FLOAT_TO_INT(rgba[i][BCOMP]);
+ dst[i*3+1] = FLOAT_TO_INT(rgba[i][GCOMP]);
+ dst[i*3+2] = FLOAT_TO_INT(rgba[i][RCOMP]);
}
break;
case GL_BGRA:
for (i=0;i<n;i++) {
- dst[i*4+0] = FLOAT_TO_INT(blue[i]);
- dst[i*4+1] = FLOAT_TO_INT(green[i]);
- dst[i*4+2] = FLOAT_TO_INT(red[i]);
- dst[i*4+3] = FLOAT_TO_INT(alpha[i]);
+ dst[i*4+0] = FLOAT_TO_INT(rgba[i][BCOMP]);
+ dst[i*4+1] = FLOAT_TO_INT(rgba[i][GCOMP]);
+ dst[i*4+2] = FLOAT_TO_INT(rgba[i][RCOMP]);
+ dst[i*4+3] = FLOAT_TO_INT(rgba[i][ACOMP]);
}
break;
case GL_ABGR_EXT:
for (i=0;i<n;i++) {
- dst[i*4+0] = FLOAT_TO_INT(alpha[i]);
- dst[i*4+1] = FLOAT_TO_INT(blue[i]);
- dst[i*4+2] = FLOAT_TO_INT(green[i]);
- dst[i*4+3] = FLOAT_TO_INT(red[i]);
+ dst[i*4+0] = FLOAT_TO_INT(rgba[i][ACOMP]);
+ dst[i*4+1] = FLOAT_TO_INT(rgba[i][BCOMP]);
+ dst[i*4+2] = FLOAT_TO_INT(rgba[i][GCOMP]);
+ dst[i*4+3] = FLOAT_TO_INT(rgba[i][RCOMP]);
}
break;
default:
switch (format) {
case GL_RED:
for (i=0;i<n;i++)
- dst[i] = red[i];
+ dst[i] = rgba[i][RCOMP];
break;
case GL_GREEN:
for (i=0;i<n;i++)
- dst[i] = green[i];
+ dst[i] = rgba[i][GCOMP];
break;
case GL_BLUE:
for (i=0;i<n;i++)
- dst[i] = blue[i];
+ dst[i] = rgba[i][BCOMP];
break;
case GL_ALPHA:
for (i=0;i<n;i++)
- dst[i] = alpha[i];
+ dst[i] = rgba[i][ACOMP];
break;
case GL_LUMINANCE:
for (i=0;i<n;i++)
case GL_LUMINANCE_ALPHA:
for (i=0;i<n;i++) {
dst[i*2+0] = luminance[i];
- dst[i*2+1] = alpha[i];
+ dst[i*2+1] = rgba[i][ACOMP];
}
break;
case GL_RGB:
for (i=0;i<n;i++) {
- dst[i*3+0] = red[i];
- dst[i*3+1] = green[i];
- dst[i*3+2] = blue[i];
+ dst[i*3+0] = rgba[i][RCOMP];
+ dst[i*3+1] = rgba[i][GCOMP];
+ dst[i*3+2] = rgba[i][BCOMP];
}
break;
case GL_RGBA:
for (i=0;i<n;i++) {
- dst[i*4+0] = red[i];
- dst[i*4+1] = green[i];
- dst[i*4+2] = blue[i];
- dst[i*4+3] = alpha[i];
+ dst[i*4+0] = rgba[i][RCOMP];
+ dst[i*4+1] = rgba[i][GCOMP];
+ dst[i*4+2] = rgba[i][BCOMP];
+ dst[i*4+3] = rgba[i][ACOMP];
}
break;
case GL_BGR:
for (i=0;i<n;i++) {
- dst[i*3+0] = blue[i];
- dst[i*3+1] = green[i];
- dst[i*3+2] = red[i];
+ dst[i*3+0] = rgba[i][BCOMP];
+ dst[i*3+1] = rgba[i][GCOMP];
+ dst[i*3+2] = rgba[i][RCOMP];
}
break;
case GL_BGRA:
for (i=0;i<n;i++) {
- dst[i*4+0] = blue[i];
- dst[i*4+1] = green[i];
- dst[i*4+2] = red[i];
- dst[i*4+3] = alpha[i];
+ dst[i*4+0] = rgba[i][BCOMP];
+ dst[i*4+1] = rgba[i][GCOMP];
+ dst[i*4+2] = rgba[i][RCOMP];
+ dst[i*4+3] = rgba[i][ACOMP];
}
break;
case GL_ABGR_EXT:
for (i=0;i<n;i++) {
- dst[i*4+0] = alpha[i];
- dst[i*4+1] = blue[i];
- dst[i*4+2] = green[i];
- dst[i*4+3] = red[i];
+ dst[i*4+0] = rgba[i][ACOMP];
+ dst[i*4+1] = rgba[i][BCOMP];
+ dst[i*4+2] = rgba[i][GCOMP];
+ dst[i*4+3] = rgba[i][RCOMP];
}
break;
default:
if (format == GL_RGB) {
GLubyte *dst = (GLubyte *) destination;
for (i=0;i<n;i++) {
- dst[i] = (((GLint) (red[i] * 7.0F)) << 5)
- | (((GLint) (green[i] * 7.0F)) << 2)
- | (((GLint) (blue[i] * 3.0F)) );
+ dst[i] = (((GLint) (rgba[i][RCOMP] * 7.0F)) << 5)
+ | (((GLint) (rgba[i][GCOMP] * 7.0F)) << 2)
+ | (((GLint) (rgba[i][BCOMP] * 3.0F)) );
}
}
break;
if (format == GL_RGB) {
GLubyte *dst = (GLubyte *) destination;
for (i=0;i<n;i++) {
- dst[i] = (((GLint) (red[i] * 7.0F)) )
- | (((GLint) (green[i] * 7.0F)) << 3)
- | (((GLint) (blue[i] * 3.0F)) << 5);
+ dst[i] = (((GLint) (rgba[i][RCOMP] * 7.0F)) )
+ | (((GLint) (rgba[i][GCOMP] * 7.0F)) << 3)
+ | (((GLint) (rgba[i][BCOMP] * 3.0F)) << 5);
}
}
break;
if (format == GL_RGB) {
GLushort *dst = (GLushort *) destination;
for (i=0;i<n;i++) {
- dst[i] = (((GLint) (red[i] * 31.0F)) << 11)
- | (((GLint) (green[i] * 63.0F)) << 5)
- | (((GLint) (blue[i] * 31.0F)) );
+ dst[i] = (((GLint) (rgba[i][RCOMP] * 31.0F)) << 11)
+ | (((GLint) (rgba[i][GCOMP] * 63.0F)) << 5)
+ | (((GLint) (rgba[i][BCOMP] * 31.0F)) );
}
}
break;
if (format == GL_RGB) {
GLushort *dst = (GLushort *) destination;
for (i=0;i<n;i++) {
- dst[i] = (((GLint) (red[i] * 31.0F)) )
- | (((GLint) (green[i] * 63.0F)) << 5)
- | (((GLint) (blue[i] * 31.0F)) << 11);
+ dst[i] = (((GLint) (rgba[i][RCOMP] * 31.0F)) )
+ | (((GLint) (rgba[i][GCOMP] * 63.0F)) << 5)
+ | (((GLint) (rgba[i][BCOMP] * 31.0F)) << 11);
}
}
break;
if (format == GL_RGB) {
GLushort *dst = (GLushort *) destination;
for (i=0;i<n;i++) {
- dst[i] = (((GLint) (red[i] * 15.0F)) << 12)
- | (((GLint) (green[i] * 15.0F)) << 8)
- | (((GLint) (blue[i] * 15.0F)) << 4)
- | (((GLint) (alpha[i] * 15.0F)) );
+ dst[i] = (((GLint) (rgba[i][RCOMP] * 15.0F)) << 12)
+ | (((GLint) (rgba[i][GCOMP] * 15.0F)) << 8)
+ | (((GLint) (rgba[i][BCOMP] * 15.0F)) << 4)
+ | (((GLint) (rgba[i][ACOMP] * 15.0F)) );
}
}
break;
if (format == GL_RGB) {
GLushort *dst = (GLushort *) destination;
for (i=0;i<n;i++) {
- dst[i] = (((GLint) (red[i] * 15.0F)) )
- | (((GLint) (green[i] * 15.0F)) << 4)
- | (((GLint) (blue[i] * 15.0F)) << 8)
- | (((GLint) (alpha[i] * 15.0F)) << 12);
+ dst[i] = (((GLint) (rgba[i][RCOMP] * 15.0F)) )
+ | (((GLint) (rgba[i][GCOMP] * 15.0F)) << 4)
+ | (((GLint) (rgba[i][BCOMP] * 15.0F)) << 8)
+ | (((GLint) (rgba[i][ACOMP] * 15.0F)) << 12);
}
}
break;
if (format == GL_RGB) {
GLushort *dst = (GLushort *) destination;
for (i=0;i<n;i++) {
- dst[i] = (((GLint) (red[i] * 31.0F)) << 11)
- | (((GLint) (green[i] * 31.0F)) << 6)
- | (((GLint) (blue[i] * 31.0F)) << 1)
- | (((GLint) (alpha[i] * 1.0F)) );
+ dst[i] = (((GLint) (rgba[i][RCOMP] * 31.0F)) << 11)
+ | (((GLint) (rgba[i][GCOMP] * 31.0F)) << 6)
+ | (((GLint) (rgba[i][BCOMP] * 31.0F)) << 1)
+ | (((GLint) (rgba[i][ACOMP] * 1.0F)) );
}
}
break;
if (format == GL_RGB) {
GLushort *dst = (GLushort *) destination;
for (i=0;i<n;i++) {
- dst[i] = (((GLint) (red[i] * 31.0F)) )
- | (((GLint) (green[i] * 31.0F)) << 5)
- | (((GLint) (blue[i] * 31.0F)) << 10)
- | (((GLint) (alpha[i] * 1.0F)) << 15);
+ dst[i] = (((GLint) (rgba[i][RCOMP] * 31.0F)) )
+ | (((GLint) (rgba[i][GCOMP] * 31.0F)) << 5)
+ | (((GLint) (rgba[i][BCOMP] * 31.0F)) << 10)
+ | (((GLint) (rgba[i][ACOMP] * 1.0F)) << 15);
}
}
break;
if (format == GL_RGBA) {
GLuint *dst = (GLuint *) destination;
for (i=0;i<n;i++) {
- dst[i] = (((GLuint) (red[i] * 255.0F)) << 24)
- | (((GLuint) (green[i] * 255.0F)) << 16)
- | (((GLuint) (blue[i] * 255.0F)) << 8)
- | (((GLuint) (alpha[i] * 255.0F)) );
+ dst[i] = (((GLuint) (rgba[i][RCOMP] * 255.0F)) << 24)
+ | (((GLuint) (rgba[i][GCOMP] * 255.0F)) << 16)
+ | (((GLuint) (rgba[i][BCOMP] * 255.0F)) << 8)
+ | (((GLuint) (rgba[i][ACOMP] * 255.0F)) );
}
}
else if (format == GL_BGRA) {
GLuint *dst = (GLuint *) destination;
for (i=0;i<n;i++) {
- dst[i] = (((GLuint) (blue[i] * 255.0F)) << 24)
- | (((GLuint) (green[i] * 255.0F)) << 16)
- | (((GLuint) (red[i] * 255.0F)) << 8)
- | (((GLuint) (alpha[i] * 255.0F)) );
+ dst[i] = (((GLuint) (rgba[i][BCOMP] * 255.0F)) << 24)
+ | (((GLuint) (rgba[i][GCOMP] * 255.0F)) << 16)
+ | (((GLuint) (rgba[i][RCOMP] * 255.0F)) << 8)
+ | (((GLuint) (rgba[i][ACOMP] * 255.0F)) );
}
}
else if (format == GL_ABGR_EXT) {
GLuint *dst = (GLuint *) destination;
for (i=0;i<n;i++) {
- dst[i] = (((GLuint) (alpha[i] * 255.0F)) << 24)
- | (((GLuint) (blue[i] * 255.0F)) << 16)
- | (((GLuint) (green[i] * 255.0F)) << 8)
- | (((GLuint) (red[i] * 255.0F)) );
+ dst[i] = (((GLuint) (rgba[i][ACOMP] * 255.0F)) << 24)
+ | (((GLuint) (rgba[i][BCOMP] * 255.0F)) << 16)
+ | (((GLuint) (rgba[i][GCOMP] * 255.0F)) << 8)
+ | (((GLuint) (rgba[i][RCOMP] * 255.0F)) );
}
}
break;
if (format == GL_RGBA) {
GLuint *dst = (GLuint *) destination;
for (i=0;i<n;i++) {
- dst[i] = (((GLuint) (red[i] * 255.0F)) )
- | (((GLuint) (green[i] * 255.0F)) << 8)
- | (((GLuint) (blue[i] * 255.0F)) << 16)
- | (((GLuint) (alpha[i] * 255.0F)) << 24);
+ dst[i] = (((GLuint) (rgba[i][RCOMP] * 255.0F)) )
+ | (((GLuint) (rgba[i][GCOMP] * 255.0F)) << 8)
+ | (((GLuint) (rgba[i][BCOMP] * 255.0F)) << 16)
+ | (((GLuint) (rgba[i][ACOMP] * 255.0F)) << 24);
}
}
else if (format == GL_BGRA) {
GLuint *dst = (GLuint *) destination;
for (i=0;i<n;i++) {
- dst[i] = (((GLuint) (blue[i] * 255.0F)) )
- | (((GLuint) (green[i] * 255.0F)) << 8)
- | (((GLuint) (red[i] * 255.0F)) << 16)
- | (((GLuint) (alpha[i] * 255.0F)) << 24);
+ dst[i] = (((GLuint) (rgba[i][BCOMP] * 255.0F)) )
+ | (((GLuint) (rgba[i][GCOMP] * 255.0F)) << 8)
+ | (((GLuint) (rgba[i][RCOMP] * 255.0F)) << 16)
+ | (((GLuint) (rgba[i][ACOMP] * 255.0F)) << 24);
}
}
else if (format == GL_ABGR_EXT) {
GLuint *dst = (GLuint *) destination;
for (i=0;i<n;i++) {
- dst[i] = (((GLuint) (alpha[i] * 255.0F)) )
- | (((GLuint) (blue[i] * 255.0F)) << 8)
- | (((GLuint) (green[i] * 255.0F)) << 16)
- | (((GLuint) (red[i] * 255.0F)) << 24);
+ dst[i] = (((GLuint) (rgba[i][ACOMP] * 255.0F)) )
+ | (((GLuint) (rgba[i][BCOMP] * 255.0F)) << 8)
+ | (((GLuint) (rgba[i][GCOMP] * 255.0F)) << 16)
+ | (((GLuint) (rgba[i][RCOMP] * 255.0F)) << 24);
}
}
break;
if (format == GL_RGBA) {
GLuint *dst = (GLuint *) destination;
for (i=0;i<n;i++) {
- dst[i] = (((GLuint) (red[i] * 1023.0F)) << 22)
- | (((GLuint) (green[i] * 1023.0F)) << 12)
- | (((GLuint) (blue[i] * 1023.0F)) << 2)
- | (((GLuint) (alpha[i] * 3.0F)) );
+ dst[i] = (((GLuint) (rgba[i][RCOMP] * 1023.0F)) << 22)
+ | (((GLuint) (rgba[i][GCOMP] * 1023.0F)) << 12)
+ | (((GLuint) (rgba[i][BCOMP] * 1023.0F)) << 2)
+ | (((GLuint) (rgba[i][ACOMP] * 3.0F)) );
}
}
else if (format == GL_BGRA) {
GLuint *dst = (GLuint *) destination;
for (i=0;i<n;i++) {
- dst[i] = (((GLuint) (blue[i] * 1023.0F)) << 22)
- | (((GLuint) (green[i] * 1023.0F)) << 12)
- | (((GLuint) (red[i] * 1023.0F)) << 2)
- | (((GLuint) (alpha[i] * 3.0F)) );
+ dst[i] = (((GLuint) (rgba[i][BCOMP] * 1023.0F)) << 22)
+ | (((GLuint) (rgba[i][GCOMP] * 1023.0F)) << 12)
+ | (((GLuint) (rgba[i][RCOMP] * 1023.0F)) << 2)
+ | (((GLuint) (rgba[i][ACOMP] * 3.0F)) );
}
}
else if (format == GL_ABGR_EXT) {
GLuint *dst = (GLuint *) destination;
for (i=0;i<n;i++) {
- dst[i] = (((GLuint) (alpha[i] * 1023.0F)) << 22)
- | (((GLuint) (blue[i] * 1023.0F)) << 12)
- | (((GLuint) (green[i] * 1023.0F)) << 2)
- | (((GLuint) (red[i] * 3.0F)) );
+ dst[i] = (((GLuint) (rgba[i][ACOMP] * 1023.0F)) << 22)
+ | (((GLuint) (rgba[i][BCOMP] * 1023.0F)) << 12)
+ | (((GLuint) (rgba[i][GCOMP] * 1023.0F)) << 2)
+ | (((GLuint) (rgba[i][RCOMP] * 3.0F)) );
}
}
break;
if (format == GL_RGBA) {
GLuint *dst = (GLuint *) destination;
for (i=0;i<n;i++) {
- dst[i] = (((GLuint) (red[i] * 1023.0F)) )
- | (((GLuint) (green[i] * 1023.0F)) << 10)
- | (((GLuint) (blue[i] * 1023.0F)) << 20)
- | (((GLuint) (alpha[i] * 3.0F)) << 30);
+ dst[i] = (((GLuint) (rgba[i][RCOMP] * 1023.0F)) )
+ | (((GLuint) (rgba[i][GCOMP] * 1023.0F)) << 10)
+ | (((GLuint) (rgba[i][BCOMP] * 1023.0F)) << 20)
+ | (((GLuint) (rgba[i][ACOMP] * 3.0F)) << 30);
}
}
else if (format == GL_BGRA) {
GLuint *dst = (GLuint *) destination;
for (i=0;i<n;i++) {
- dst[i] = (((GLuint) (blue[i] * 1023.0F)) )
- | (((GLuint) (green[i] * 1023.0F)) << 10)
- | (((GLuint) (red[i] * 1023.0F)) << 20)
- | (((GLuint) (alpha[i] * 3.0F)) << 30);
+ dst[i] = (((GLuint) (rgba[i][BCOMP] * 1023.0F)) )
+ | (((GLuint) (rgba[i][GCOMP] * 1023.0F)) << 10)
+ | (((GLuint) (rgba[i][RCOMP] * 1023.0F)) << 20)
+ | (((GLuint) (rgba[i][ACOMP] * 3.0F)) << 30);
}
}
else if (format == GL_ABGR_EXT) {
GLuint *dst = (GLuint *) destination;
for (i=0;i<n;i++) {
- dst[i] = (((GLuint) (alpha[i] * 1023.0F)) )
- | (((GLuint) (blue[i] * 1023.0F)) << 10)
- | (((GLuint) (green[i] * 1023.0F)) << 20)
- | (((GLuint) (red[i] * 3.0F)) << 30);
+ dst[i] = (((GLuint) (rgba[i][ACOMP] * 1023.0F)) )
+ | (((GLuint) (rgba[i][BCOMP] * 1023.0F)) << 10)
+ | (((GLuint) (rgba[i][GCOMP] * 1023.0F)) << 20)
+ | (((GLuint) (rgba[i][RCOMP] * 3.0F)) << 30);
}
}
break;
}
+
#define SWAP2BYTE(VALUE) \
{ \
GLubyte *bytes = (GLubyte *) &(VALUE); \
applyTransferOps &= (ctx->Pixel.ScaleOrBiasRGBA ||
ctx->Pixel.MapColorFlag ||
ctx->ColorMatrix.type != MATRIX_IDENTITY ||
- ctx->Pixel.ScaleOrBiasRGBApcm);
+ ctx->Pixel.ScaleOrBiasRGBApcm ||
+ ctx->Pixel.ColorTableEnabled);
/* Try simple cases first */
if (!applyTransferOps && srcType == GL_UNSIGNED_BYTE) {
}
+ /* general solution begins here */
{
- /* general solution */
GLfloat rgba[MAX_WIDTH][4];
GLint dstComponents;
GLint dstRedIndex, dstGreenIndex, dstBlueIndex, dstAlphaIndex;
unpacking);
/* shift and offset indexes */
- gl_shift_and_offset_ci(ctx, n, indexes);
+ _mesa_shift_and_offset_ci(ctx, n, indexes);
if (dstFormat == GL_COLOR_INDEX) {
if (applyTransferOps) {
if (ctx->Pixel.MapColorFlag) {
/* Apply lookup table */
- gl_map_ci(ctx, n, indexes);
+ _mesa_map_ci(ctx, n, indexes);
}
-
if (ctx->Pixel.IndexShift || ctx->Pixel.IndexOffset) {
-
+ _mesa_shift_and_offset_ci(ctx, n, indexes);
}
}
-
/* convert to GLubyte and return */
{
GLuint i;
}
else {
/* Convert indexes to RGBA */
- gl_map_ci_to_rgba_float(ctx, n, indexes, rgba);
+ _mesa_map_ci_to_rgba(ctx, n, indexes, rgba);
}
}
else {
if (applyTransferOps) {
/* scale and bias colors */
- _mesa_scale_and_bias_rgba_float(ctx, n, rgba);
-
+ _mesa_scale_and_bias_rgba(ctx, n, rgba);
/* color table lookup */
if (ctx->Pixel.MapColorFlag) {
- _mesa_map_rgba_float(ctx, n, rgba);
+ _mesa_map_rgba(ctx, n, rgba);
}
-
+ /* color matrix transform */
if (ctx->ColorMatrix.type != MATRIX_IDENTITY ||
ctx->Pixel.ScaleOrBiasRGBApcm) {
_mesa_transform_rgba(ctx, n, rgba);
}
+ /* GL_SGI_color_table lookup */
+ if (ctx->Pixel.ColorTableEnabled) {
+ _mesa_lookup_rgba(&ctx->ColorTable, n, rgba);
+ }
}
}
-
- /*
- * XXX This is where more color table lookups, convolution,
- * histograms, minmax, color matrix, etc would take place if
- * implemented.
- * See figure 3.7 in the OpenGL 1.2 specification for more info.
- */
-
-
/* clamp to [0,1] */
{
GLuint i;
if (applyTransferOps) {
if (ctx->Pixel.IndexShift || ctx->Pixel.IndexOffset) {
/* shift and offset indexes */
- gl_shift_and_offset_ci(ctx, n, indexes);
+ _mesa_shift_and_offset_ci(ctx, n, indexes);
}
-
if (ctx->Pixel.MapColorFlag) {
/* Apply lookup table */
- gl_map_ci(ctx, n, indexes);
+ _mesa_map_ci(ctx, n, indexes);
}
}
if (applyTransferOps) {
if (ctx->Pixel.IndexShift || ctx->Pixel.IndexOffset) {
/* shift and offset indexes */
- gl_shift_and_offset_ci(ctx, n, indexes);
+ _mesa_shift_and_offset_ci(ctx, n, indexes);
}
if (ctx->Pixel.MapStencilFlag) {
-/* $Id: pixel.c,v 1.6 2000/04/08 18:57:45 brianp Exp $ */
+/* $Id: pixel.c,v 1.7 2000/04/12 18:54:48 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 3.3
*
- * Copyright (C) 1999 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
*/
-/*
- * glPixelStore, glPixelTransfer, glPixelMap, glPixelZoom, etc.
- */
-
-
#ifdef PC_HEADER
#include "all.h"
#else
-
-/*
- * Pixel processing functions
- */
-
-
-/*
- * Apply scale and bias factors to an array of RGBA pixels.
- */
-void gl_scale_and_bias_color( const GLcontext *ctx, GLuint n,
- GLfloat red[], GLfloat green[],
- GLfloat blue[], GLfloat alpha[] )
-{
- GLuint i;
- for (i=0;i<n;i++) {
- GLfloat r = red[i] * ctx->Pixel.RedScale + ctx->Pixel.RedBias;
- GLfloat g = green[i] * ctx->Pixel.GreenScale + ctx->Pixel.GreenBias;
- GLfloat b = blue[i] * ctx->Pixel.BlueScale + ctx->Pixel.BlueBias;
- GLfloat a = alpha[i] * ctx->Pixel.AlphaScale + ctx->Pixel.AlphaBias;
- red[i] = CLAMP( r, 0.0F, 1.0F );
- green[i] = CLAMP( g, 0.0F, 1.0F );
- blue[i] = CLAMP( b, 0.0F, 1.0F );
- alpha[i] = CLAMP( a, 0.0F, 1.0F );
- }
-}
-
-
-/*
- * Apply scale and bias factors to an array of RGBA pixels.
- */
-void gl_scale_and_bias_rgba( const GLcontext *ctx, GLuint n, GLubyte rgba[][4] )
-{
- GLfloat rbias = ctx->Pixel.RedBias * 255.0F;
- GLfloat gbias = ctx->Pixel.GreenBias * 255.0F;
- GLfloat bbias = ctx->Pixel.BlueBias * 255.0F;
- GLfloat abias = ctx->Pixel.AlphaBias * 255.0F;
- GLuint i;
- for (i=0;i<n;i++) {
- GLint r = (GLint) (rgba[i][RCOMP] * ctx->Pixel.RedScale + rbias);
- GLint g = (GLint) (rgba[i][GCOMP] * ctx->Pixel.GreenScale + gbias);
- GLint b = (GLint) (rgba[i][BCOMP] * ctx->Pixel.BlueScale + bbias);
- GLint a = (GLint) (rgba[i][ACOMP] * ctx->Pixel.AlphaScale + abias);
- rgba[i][RCOMP] = CLAMP( r, 0, 255 );
- rgba[i][GCOMP] = CLAMP( g, 0, 255 );
- rgba[i][BCOMP] = CLAMP( b, 0, 255 );
- rgba[i][ACOMP] = CLAMP( a, 0, 255 );
- }
-}
+/**********************************************************************/
+/***** Pixel processing functions ******/
+/**********************************************************************/
/*
* Apply scale and bias factors to an array of RGBA pixels.
*/
void
-_mesa_scale_and_bias_rgba_float(const GLcontext *ctx, GLuint n,
- GLfloat rgba[][4])
+_mesa_scale_and_bias_rgba(const GLcontext *ctx, GLuint n, GLfloat rgba[][4])
{
if (ctx->Pixel.RedScale != 1.0 || ctx->Pixel.RedBias != 0.0) {
const GLfloat scale = ctx->Pixel.RedScale;
}
-/*
- * Apply pixel mapping to an array of RGBA pixels.
- */
-void gl_map_rgba( const GLcontext *ctx, GLuint n, GLubyte rgba[][4] )
-{
- GLfloat rscale = (ctx->Pixel.MapRtoRsize - 1) / 255.0F;
- GLfloat gscale = (ctx->Pixel.MapGtoGsize - 1) / 255.0F;
- GLfloat bscale = (ctx->Pixel.MapBtoBsize - 1) / 255.0F;
- GLfloat ascale = (ctx->Pixel.MapAtoAsize - 1) / 255.0F;
- GLuint i;
- for (i=0;i<n;i++) {
- GLint ir = (GLint) (rgba[i][RCOMP] * rscale);
- GLint ig = (GLint) (rgba[i][GCOMP] * gscale);
- GLint ib = (GLint) (rgba[i][BCOMP] * bscale);
- GLint ia = (GLint) (rgba[i][ACOMP] * ascale);
- rgba[i][RCOMP] = (GLint) (ctx->Pixel.MapRtoR[ir] * 255.0F);
- rgba[i][GCOMP] = (GLint) (ctx->Pixel.MapGtoG[ig] * 255.0F);
- rgba[i][BCOMP] = (GLint) (ctx->Pixel.MapBtoB[ib] * 255.0F);
- rgba[i][ACOMP] = (GLint) (ctx->Pixel.MapAtoA[ia] * 255.0F);
- }
-}
-
-
/*
* Apply pixel mapping to an array of floating point RGBA pixels.
*/
void
-_mesa_map_rgba_float( const GLcontext *ctx, GLuint n, GLfloat rgba[][4] )
+_mesa_map_rgba( const GLcontext *ctx, GLuint n, GLfloat rgba[][4] )
{
const GLfloat rscale = ctx->Pixel.MapRtoRsize - 1;
const GLfloat gscale = ctx->Pixel.MapGtoGsize - 1;
}
-
/*
- * Apply pixel mapping to an array of RGBA pixels.
+ * Apply a color table lookup to an array of colors.
*/
-void gl_map_color( const GLcontext *ctx, GLuint n,
- GLfloat red[], GLfloat green[],
- GLfloat blue[], GLfloat alpha[] )
+void
+_mesa_lookup_rgba(const struct gl_color_table *table,
+ GLuint n, GLfloat rgba[][4])
{
- GLfloat rscale = ctx->Pixel.MapRtoRsize - 1;
- GLfloat gscale = ctx->Pixel.MapGtoGsize - 1;
- GLfloat bscale = ctx->Pixel.MapBtoBsize - 1;
- GLfloat ascale = ctx->Pixel.MapAtoAsize - 1;
- GLuint i;
- for (i=0;i<n;i++) {
- red[i] = ctx->Pixel.MapRtoR[ (GLint) (red[i] * rscale + 0.5F) ];
- green[i] = ctx->Pixel.MapGtoG[ (GLint) (green[i] * gscale + 0.5F) ];
- blue[i] = ctx->Pixel.MapBtoB[ (GLint) (blue[i] * bscale + 0.5F) ];
- alpha[i] = ctx->Pixel.MapAtoA[ (GLint) (alpha[i] * ascale + 0.5F) ];
+ switch (table->Format) {
+ case GL_INTENSITY:
+ {
+ const GLfloat scale = (GLfloat) (table->Size - 1);
+ const GLubyte *lut = table->Table;
+ GLuint i;
+ /* replace RGBA with I */
+ for (i = 0; i < n; i++) {
+ GLint j = (GLint) (rgba[i][RCOMP] * scale + 0.5F);
+ GLubyte c = lut[j];
+ rgba[i][RCOMP] = rgba[i][GCOMP] =
+ rgba[i][BCOMP] = rgba[i][ACOMP] = c;
+ }
+ }
+ break;
+ case GL_LUMINANCE:
+ {
+ const GLfloat scale = (GLfloat) (table->Size - 1);
+ const GLubyte *lut = table->Table;
+ GLuint i;
+ /* replace RGB with L */
+ for (i = 0; i < n; i++) {
+ GLint j = (GLint) (rgba[i][RCOMP] * scale + 0.5F);
+ GLubyte c = lut[j];
+ rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = c;
+ }
+ }
+ break;
+ case GL_ALPHA:
+ {
+ const GLfloat scale = (GLfloat) (table->Size - 1);
+ const GLubyte *lut = table->Table;
+ GLuint i;
+ /* replace A with A */
+ for (i = 0; i < n; i++) {
+ GLint j = (GLint) (rgba[i][ACOMP] * scale + 0.5F);
+ rgba[i][ACOMP] = lut[j];
+ }
+ }
+ break;
+ case GL_LUMINANCE_ALPHA:
+ {
+ const GLfloat scale = (GLfloat) (table->Size - 1);
+ const GLubyte *lut = table->Table;
+ GLuint i;
+ /* replace RGBA with LLLA */
+ for (i = 0; i < n; i++) {
+ GLint jL = (GLint) (rgba[i][RCOMP] * scale + 0.5F);
+ GLint jA = (GLint) (rgba[i][ACOMP] * scale + 0.5F);
+ GLubyte luminance = lut[jL * 2 + 0];
+ GLubyte alpha = lut[jA * 2 + 1];
+ rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = luminance;
+ rgba[i][ACOMP] = alpha;;
+ }
+ }
+ break;
+ case GL_RGB:
+ {
+ const GLfloat scale = (GLfloat) (table->Size - 1);
+ const GLubyte *lut = table->Table;
+ GLuint i;
+ /* replace RGB with RGB */
+ for (i = 0; i < n; i++) {
+ GLint jR = (GLint) (rgba[i][RCOMP] * scale + 0.5F);
+ GLint jG = (GLint) (rgba[i][GCOMP] * scale + 0.5F);
+ GLint jB = (GLint) (rgba[i][BCOMP] * scale + 0.5F);
+ rgba[i][RCOMP] = lut[jR * 3 + 0];
+ rgba[i][GCOMP] = lut[jG * 3 + 1];
+ rgba[i][BCOMP] = lut[jB * 3 + 2];
+ }
+ }
+ break;
+ case GL_RGBA:
+ {
+ const GLfloat scale = (GLfloat) (table->Size - 1);
+ const GLubyte *lut = table->Table;
+ GLuint i;
+ /* replace RGBA with RGBA */
+ for (i = 0; i < n; i++) {
+ GLint jR = (GLint) (rgba[i][RCOMP] * scale + 0.5F);
+ GLint jG = (GLint) (rgba[i][GCOMP] * scale + 0.5F);
+ GLint jB = (GLint) (rgba[i][BCOMP] * scale + 0.5F);
+ GLint jA = (GLint) (rgba[i][ACOMP] * scale + 0.5F);
+ rgba[i][RCOMP] = lut[jR * 4 + 0];
+ rgba[i][GCOMP] = lut[jG * 4 + 1];
+ rgba[i][BCOMP] = lut[jB * 4 + 2];
+ rgba[i][ACOMP] = lut[jA * 4 + 3];
+ }
+ }
+ break;
+ default:
+ gl_problem(NULL, "Bad format in _mesa_lookup_rgba");
+ return;
}
}
/*
* Apply color index shift and offset to an array of pixels.
*/
-void gl_shift_and_offset_ci( const GLcontext *ctx, GLuint n, GLuint indexes[] )
+void
+_mesa_shift_and_offset_ci( const GLcontext *ctx, GLuint n, GLuint indexes[] )
{
GLint shift = ctx->Pixel.IndexShift;
GLint offset = ctx->Pixel.IndexOffset;
/*
* Apply color index mapping to color indexes.
*/
-void gl_map_ci( const GLcontext *ctx, GLuint n, GLuint index[] )
+void
+_mesa_map_ci( const GLcontext *ctx, GLuint n, GLuint index[] )
{
GLuint mask = ctx->Pixel.MapItoIsize - 1;
GLuint i;
/*
* Map color indexes to rgba values.
*/
-void gl_map_ci_to_rgba( const GLcontext *ctx, GLuint n, const GLuint index[],
- GLubyte rgba[][4] )
+void
+_mesa_map_ci_to_rgba_ubyte( const GLcontext *ctx, GLuint n,
+ const GLuint index[], GLubyte rgba[][4] )
{
GLuint rmask = ctx->Pixel.MapItoRsize - 1;
GLuint gmask = ctx->Pixel.MapItoGsize - 1;
/*
* Map color indexes to float rgba values.
*/
-void gl_map_ci_to_rgba_float( const GLcontext *ctx, GLuint n, const GLuint index[],
- GLfloat rgba[][4] )
+void
+_mesa_map_ci_to_rgba( const GLcontext *ctx, GLuint n,
+ const GLuint index[], GLfloat rgba[][4] )
{
GLuint rmask = ctx->Pixel.MapItoRsize - 1;
GLuint gmask = ctx->Pixel.MapItoGsize - 1;
/*
* Map 8-bit color indexes to rgb values.
*/
-void gl_map_ci8_to_rgba( const GLcontext *ctx, GLuint n, const GLubyte index[],
- GLubyte rgba[][4] )
+void
+_mesa_map_ci8_to_rgba( const GLcontext *ctx, GLuint n, const GLubyte index[],
+ GLubyte rgba[][4] )
{
GLuint rmask = ctx->Pixel.MapItoRsize - 1;
GLuint gmask = ctx->Pixel.MapItoGsize - 1;
}
-void gl_map_ci_to_color( const GLcontext *ctx, GLuint n, const GLuint index[],
- GLfloat r[], GLfloat g[],
- GLfloat b[], GLfloat a[] )
-{
- GLuint rmask = ctx->Pixel.MapItoRsize - 1;
- GLuint gmask = ctx->Pixel.MapItoGsize - 1;
- GLuint bmask = ctx->Pixel.MapItoBsize - 1;
- GLuint amask = ctx->Pixel.MapItoAsize - 1;
- GLuint i;
- for (i=0;i<n;i++) {
- r[i] = ctx->Pixel.MapItoR[index[i] & rmask];
- g[i] = ctx->Pixel.MapItoG[index[i] & gmask];
- b[i] = ctx->Pixel.MapItoB[index[i] & bmask];
- a[i] = ctx->Pixel.MapItoA[index[i] & amask];
- }
-}
-
-
-
-void gl_shift_and_offset_stencil( const GLcontext *ctx, GLuint n,
- GLstencil stencil[] )
+void
+_mesa_shift_and_offset_stencil( const GLcontext *ctx, GLuint n,
+ GLstencil stencil[] )
{
GLuint i;
GLint shift = ctx->Pixel.IndexShift;
}
-
-void gl_map_stencil( const GLcontext *ctx, GLuint n, GLstencil stencil[] )
+void
+_mesa_map_stencil( const GLcontext *ctx, GLuint n, GLstencil stencil[] )
{
GLuint mask = ctx->Pixel.MapStoSsize - 1;
GLuint i;
stencil[i] = ctx->Pixel.MapStoS[ stencil[i] & mask ];
}
}
-