| /* $Id: osmesa.c,v 1.61 2001/07/12 22:09:21 keithw Exp $ */ | |||||
| /* $Id: osmesa.c,v 1.62 2001/07/13 20:07:37 brianp Exp $ */ | |||||
| /* | /* | ||||
| * Mesa 3-D graphics library | * Mesa 3-D graphics library | ||||
| #define PACK_RGB_565(DST, R, G, B) \ | #define PACK_RGB_565(DST, R, G, B) \ | ||||
| do { \ | do { \ | ||||
| (DST) = (((R) << 8) & 0xf800) | (((G) << 3) & 0x7e0) | ((B) >> 3);\ | |||||
| (DST) = (((int) (R) << 8) & 0xf800) | (((int) (G) << 3) & 0x7e0) | ((int) (B) >> 3);\ | |||||
| } while (0) | } while (0) | ||||
| static void | static void | ||||
| write_rgba_span2( const GLcontext *ctx, | write_rgba_span2( const GLcontext *ctx, | ||||
| GLuint n, GLint x, GLint y, | GLuint n, GLint x, GLint y, | ||||
| CONST GLubyte rgba[][4], const GLubyte mask[] ) | |||||
| CONST GLchan rgba[][4], const GLubyte mask[] ) | |||||
| { | { | ||||
| OSMesaContext osmesa = OSMESA_CONTEXT(ctx); | OSMesaContext osmesa = OSMESA_CONTEXT(ctx); | ||||
| GLushort *ptr2 = (GLushort *) PIXELADDR2(x, y); | GLushort *ptr2 = (GLushort *) PIXELADDR2(x, y); | ||||
| static void | static void | ||||
| write_rgb_span2( const GLcontext *ctx, | write_rgb_span2( const GLcontext *ctx, | ||||
| GLuint n, GLint x, GLint y, | GLuint n, GLint x, GLint y, | ||||
| CONST GLubyte rgb[][3], const GLubyte mask[] ) | |||||
| CONST GLchan rgb[][3], const GLubyte mask[] ) | |||||
| { | { | ||||
| OSMesaContext osmesa = OSMESA_CONTEXT(ctx); | OSMesaContext osmesa = OSMESA_CONTEXT(ctx); | ||||
| GLushort *ptr2 = (GLushort *) PIXELADDR2(x, y); | GLushort *ptr2 = (GLushort *) PIXELADDR2(x, y); | ||||
| static void | static void | ||||
| write_rgba_pixels2( const GLcontext *ctx, | write_rgba_pixels2( const GLcontext *ctx, | ||||
| GLuint n, const GLint x[], const GLint y[], | GLuint n, const GLint x[], const GLint y[], | ||||
| CONST GLubyte rgba[][4], const GLubyte mask[] ) | |||||
| CONST GLchan rgba[][4], const GLubyte mask[] ) | |||||
| { | { | ||||
| OSMesaContext osmesa = OSMESA_CONTEXT(ctx); | OSMesaContext osmesa = OSMESA_CONTEXT(ctx); | ||||
| GLuint i; | GLuint i; | ||||
| static void | static void | ||||
| read_rgba_span2( const GLcontext *ctx, | read_rgba_span2( const GLcontext *ctx, | ||||
| GLuint n, GLint x, GLint y, | GLuint n, GLint x, GLint y, | ||||
| GLubyte rgba[][4] ) | |||||
| GLchan rgba[][4] ) | |||||
| { | { | ||||
| OSMesaContext osmesa = OSMESA_CONTEXT(ctx); | OSMesaContext osmesa = OSMESA_CONTEXT(ctx); | ||||
| GLuint i; | GLuint i; | ||||
| static void | static void | ||||
| read_rgba_pixels2( const GLcontext *ctx, | read_rgba_pixels2( const GLcontext *ctx, | ||||
| GLuint n, const GLint x[], const GLint y[], | GLuint n, const GLint x[], const GLint y[], | ||||
| GLubyte rgba[][4], const GLubyte mask[] ) | |||||
| GLchan rgba[][4], const GLubyte mask[] ) | |||||
| { | { | ||||
| OSMesaContext osmesa = OSMESA_CONTEXT(ctx); | OSMesaContext osmesa = OSMESA_CONTEXT(ctx); | ||||
| GLuint i; | GLuint i; |
| # $Id: Makefile.OSMesa16,v 1.3 2001/06/18 17:26:08 brianp Exp $ | |||||
| # $Id: Makefile.OSMesa16,v 1.4 2001/07/13 20:07:37 brianp Exp $ | |||||
| # Mesa 3-D graphics library | # Mesa 3-D graphics library | ||||
| # Version: 3.5 | # Version: 3.5 | ||||
| # Copyright (C) 1995-2001 Brian Paul | # Copyright (C) 1995-2001 Brian Paul | ||||
| # Makefile for building Mesa for 16-bit/channel rendering with the OSMesa | |||||
| # Makefile for building Mesa for 16/32-bit/channel rendering with the OSMesa | |||||
| # driver. | # driver. | ||||
| /* $Id: config.h,v 1.32 2001/06/13 14:56:14 brianp Exp $ */ | |||||
| /* $Id: config.h,v 1.33 2001/07/13 20:07:37 brianp Exp $ */ | |||||
| /* | /* | ||||
| * Mesa 3-D graphics library | * Mesa 3-D graphics library | ||||
| /* | /* | ||||
| * Bits per accumulation buffer color component: 8 or 16 | |||||
| * Bits per accumulation buffer color component: 8, 16 or 32 | |||||
| */ | */ | ||||
| #define ACCUM_BITS 16 | #define ACCUM_BITS 16 | ||||
| /* $Id: mtypes.h,v 1.48 2001/06/26 21:15:35 brianp Exp $ */ | |||||
| /* $Id: mtypes.h,v 1.49 2001/07/13 20:07:37 brianp Exp $ */ | |||||
| /* | /* | ||||
| * Mesa 3-D graphics library | * Mesa 3-D graphics library | ||||
| typedef GLbyte GLaccum; | typedef GLbyte GLaccum; | ||||
| #elif ACCUM_BITS==16 | #elif ACCUM_BITS==16 | ||||
| typedef GLshort GLaccum; | typedef GLshort GLaccum; | ||||
| #elif ACCUM_BITS==32 | |||||
| typedef GLfloat GLaccum; | |||||
| #else | #else | ||||
| # error "illegal number of accumulation bits" | # error "illegal number of accumulation bits" | ||||
| #endif | #endif |
| /* $Id: pixel.c,v 1.29 2001/05/23 23:55:01 brianp Exp $ */ | |||||
| /* $Id: pixel.c,v 1.30 2001/07/13 20:07:37 brianp Exp $ */ | |||||
| /* | /* | ||||
| * Mesa 3-D graphics library | * Mesa 3-D graphics library | ||||
| switch (pname) { | switch (pname) { | ||||
| case GL_MAP_COLOR: | case GL_MAP_COLOR: | ||||
| if (ctx->Pixel.MapColorFlag == param ? GL_TRUE : GL_FALSE) | |||||
| if (ctx->Pixel.MapColorFlag == (param ? GL_TRUE : GL_FALSE)) | |||||
| return; | return; | ||||
| FLUSH_VERTICES(ctx, _NEW_PIXEL); | FLUSH_VERTICES(ctx, _NEW_PIXEL); | ||||
| ctx->Pixel.MapColorFlag = param ? GL_TRUE : GL_FALSE; | ctx->Pixel.MapColorFlag = param ? GL_TRUE : GL_FALSE; | ||||
| break; | break; | ||||
| case GL_MAP_STENCIL: | case GL_MAP_STENCIL: | ||||
| if (ctx->Pixel.MapStencilFlag == param ? GL_TRUE : GL_FALSE) | |||||
| if (ctx->Pixel.MapStencilFlag == (param ? GL_TRUE : GL_FALSE)) | |||||
| return; | return; | ||||
| FLUSH_VERTICES(ctx, _NEW_PIXEL); | FLUSH_VERTICES(ctx, _NEW_PIXEL); | ||||
| ctx->Pixel.MapStencilFlag = param ? GL_TRUE : GL_FALSE; | ctx->Pixel.MapStencilFlag = param ? GL_TRUE : GL_FALSE; | ||||
| _mesa_chan_to_float_span(const GLcontext *ctx, GLuint n, | _mesa_chan_to_float_span(const GLcontext *ctx, GLuint n, | ||||
| CONST GLchan rgba[][4], GLfloat rgbaf[][4]) | CONST GLchan rgba[][4], GLfloat rgbaf[][4]) | ||||
| { | { | ||||
| #if CHAN_TYPE == GL_FLOAT | |||||
| MEMCPY(rgbaf, rgba, n * 4 * sizeof(GLfloat)); | |||||
| #else | |||||
| const GLuint rShift = CHAN_BITS - ctx->Visual.redBits; | const GLuint rShift = CHAN_BITS - ctx->Visual.redBits; | ||||
| const GLuint gShift = CHAN_BITS - ctx->Visual.greenBits; | const GLuint gShift = CHAN_BITS - ctx->Visual.greenBits; | ||||
| const GLuint bShift = CHAN_BITS - ctx->Visual.blueBits; | const GLuint bShift = CHAN_BITS - ctx->Visual.blueBits; | ||||
| rgbaf[i][BCOMP] = (GLfloat) b * bScale; | rgbaf[i][BCOMP] = (GLfloat) b * bScale; | ||||
| rgbaf[i][ACOMP] = (GLfloat) a * aScale; | rgbaf[i][ACOMP] = (GLfloat) a * aScale; | ||||
| } | } | ||||
| #endif | |||||
| } | } |
| /* $Id: teximage.c,v 1.99 2001/07/13 15:44:21 brianp Exp $ */ | |||||
| /* $Id: teximage.c,v 1.100 2001/07/13 20:07:37 brianp Exp $ */ | |||||
| /* | /* | ||||
| * Mesa 3-D graphics library | * Mesa 3-D graphics library | ||||
| #ifdef DEBUG | #ifdef DEBUG | ||||
| static void PrintTexture(const struct gl_texture_image *img) | static void PrintTexture(const struct gl_texture_image *img) | ||||
| { | { | ||||
| #if CHAN_TYPE == GL_FLOAT | |||||
| _mesa_problem(NULL, "PrintTexture doesn't support float channels"); | |||||
| #else | |||||
| GLuint i, j, c; | GLuint i, j, c; | ||||
| const GLchan *data = (const GLchan *) img->Data; | const GLchan *data = (const GLchan *) img->Data; | ||||
| } | } | ||||
| printf("\n"); | printf("\n"); | ||||
| } | } | ||||
| #endif | |||||
| } | } | ||||
| #endif | #endif | ||||
| /* $Id: texstore.c,v 1.30 2001/07/13 16:38:44 brianp Exp $ */ | |||||
| /* $Id: texstore.c,v 1.31 2001/07/13 20:07:37 brianp Exp $ */ | |||||
| /* | /* | ||||
| * Mesa 3-D graphics library | * Mesa 3-D graphics library | ||||
| for (i = j = 0, k = k0; i < dstWidth; | for (i = j = 0, k = k0; i < dstWidth; | ||||
| i++, j += colStride, k += colStride) { | i++, j += colStride, k += colStride) { | ||||
| dst[i][0] = (rowA[j][0] + rowA[k][0] + | dst[i][0] = (rowA[j][0] + rowA[k][0] + | ||||
| rowB[j][0] + rowB[k][0]) >> 2; | |||||
| rowB[j][0] + rowB[k][0]) / 4; | |||||
| dst[i][1] = (rowA[j][1] + rowA[k][1] + | dst[i][1] = (rowA[j][1] + rowA[k][1] + | ||||
| rowB[j][1] + rowB[k][1]) >> 2; | |||||
| rowB[j][1] + rowB[k][1]) / 4; | |||||
| dst[i][2] = (rowA[j][2] + rowA[k][2] + | dst[i][2] = (rowA[j][2] + rowA[k][2] + | ||||
| rowB[j][2] + rowB[k][2]) >> 2; | |||||
| rowB[j][2] + rowB[k][2]) / 4; | |||||
| dst[i][3] = (rowA[j][3] + rowA[k][3] + | dst[i][3] = (rowA[j][3] + rowA[k][3] + | ||||
| rowB[j][3] + rowB[k][3]) >> 2; | |||||
| rowB[j][3] + rowB[k][3]) / 4; | |||||
| } | } | ||||
| } | } | ||||
| return; | return; | ||||
| for (i = j = 0, k = k0; i < dstWidth; | for (i = j = 0, k = k0; i < dstWidth; | ||||
| i++, j += colStride, k += colStride) { | i++, j += colStride, k += colStride) { | ||||
| dst[i][0] = (rowA[j][0] + rowA[k][0] + | dst[i][0] = (rowA[j][0] + rowA[k][0] + | ||||
| rowB[j][0] + rowB[k][0]) >> 2; | |||||
| rowB[j][0] + rowB[k][0]) / 4; | |||||
| dst[i][1] = (rowA[j][1] + rowA[k][1] + | dst[i][1] = (rowA[j][1] + rowA[k][1] + | ||||
| rowB[j][1] + rowB[k][1]) >> 2; | |||||
| rowB[j][1] + rowB[k][1]) / 4; | |||||
| dst[i][2] = (rowA[j][2] + rowA[k][2] + | dst[i][2] = (rowA[j][2] + rowA[k][2] + | ||||
| rowB[j][2] + rowB[k][2]) >> 2; | |||||
| rowB[j][2] + rowB[k][2]) / 4; | |||||
| } | } | ||||
| } | } | ||||
| return; | return; | ||||
| GLchan *dst = (GLchan *) dstRow; | GLchan *dst = (GLchan *) dstRow; | ||||
| for (i = j = 0, k = k0; i < dstWidth; | for (i = j = 0, k = k0; i < dstWidth; | ||||
| i++, j += colStride, k += colStride) { | i++, j += colStride, k += colStride) { | ||||
| dst[i] = (rowA[j] + rowA[k] + rowB[j] + rowB[k]) >> 2; | |||||
| dst[i] = (rowA[j] + rowA[k] + rowB[j] + rowB[k]) / 4; | |||||
| } | } | ||||
| } | } | ||||
| return; | return; | ||||
| for (i = j = 0, k = k0; i < dstWidth; | for (i = j = 0, k = k0; i < dstWidth; | ||||
| i++, j += colStride, k += colStride) { | i++, j += colStride, k += colStride) { | ||||
| dst[i][0] = (rowA[j][0] + rowA[k][0] + | dst[i][0] = (rowA[j][0] + rowA[k][0] + | ||||
| rowB[j][0] + rowB[k][0]) >> 2; | |||||
| rowB[j][0] + rowB[k][0]) / 4; | |||||
| dst[i][1] = (rowA[j][1] + rowA[k][1] + | dst[i][1] = (rowA[j][1] + rowA[k][1] + | ||||
| rowB[j][1] + rowB[k][1]) >> 2; | |||||
| rowB[j][1] + rowB[k][1]) / 4; | |||||
| } | } | ||||
| } | } | ||||
| return; | return; | ||||
| for (i = j = 0, k = k0; i < dstWidth; | for (i = j = 0, k = k0; i < dstWidth; | ||||
| i++, j += colStride, k += colStride) { | i++, j += colStride, k += colStride) { | ||||
| dst[i][0] = (rowA[j][0] + rowA[k][0] + | dst[i][0] = (rowA[j][0] + rowA[k][0] + | ||||
| rowB[j][0] + rowB[k][0]) >> 2; | |||||
| rowB[j][0] + rowB[k][0]) / 4; | |||||
| dst[i][1] = (rowA[j][1] + rowA[k][1] + | dst[i][1] = (rowA[j][1] + rowA[k][1] + | ||||
| rowB[j][1] + rowB[k][1]) >> 2; | |||||
| rowB[j][1] + rowB[k][1]) / 4; | |||||
| dst[i][2] = (rowA[j][2] + rowA[k][2] + | dst[i][2] = (rowA[j][2] + rowA[k][2] + | ||||
| rowB[j][2] + rowB[k][2]) >> 2; | |||||
| rowB[j][2] + rowB[k][2]) / 4; | |||||
| dst[i][3] = (rowA[j][3] + rowA[k][3] + | dst[i][3] = (rowA[j][3] + rowA[k][3] + | ||||
| rowB[j][3] + rowB[k][3]) >> 2; | |||||
| rowB[j][3] + rowB[k][3]) / 4; | |||||
| } | } | ||||
| } | } | ||||
| return; | return; | ||||
| for (i = j = 0, k = k0; i < dstWidth; | for (i = j = 0, k = k0; i < dstWidth; | ||||
| i++, j += colStride, k += colStride) { | i++, j += colStride, k += colStride) { | ||||
| dst[i][0] = (rowA[j][0] + rowA[k][0] + | dst[i][0] = (rowA[j][0] + rowA[k][0] + | ||||
| rowB[j][0] + rowB[k][0]) >> 2; | |||||
| rowB[j][0] + rowB[k][0]) / 4; | |||||
| dst[i][1] = (rowA[j][1] + rowA[k][1] + | dst[i][1] = (rowA[j][1] + rowA[k][1] + | ||||
| rowB[j][1] + rowB[k][1]) >> 2; | |||||
| rowB[j][1] + rowB[k][1]) / 4; | |||||
| dst[i][2] = (rowA[j][2] + rowA[k][2] + | dst[i][2] = (rowA[j][2] + rowA[k][2] + | ||||
| rowB[j][2] + rowB[k][2]) >> 2; | |||||
| rowB[j][2] + rowB[k][2]) / 4; | |||||
| } | } | ||||
| } | } | ||||
| return; | return; |
| /* $Id: s_aatritemp.h,v 1.18 2001/06/05 21:41:05 brianp Exp $ */ | |||||
| /* $Id: s_aatritemp.h,v 1.19 2001/07/13 20:07:37 brianp Exp $ */ | |||||
| /* | /* | ||||
| * Mesa 3-D graphics library | * Mesa 3-D graphics library | ||||
| const GLfloat *p1 = v1->win; | const GLfloat *p1 = v1->win; | ||||
| const GLfloat *p2 = v2->win; | const GLfloat *p2 = v2->win; | ||||
| const SWvertex *vMin, *vMid, *vMax; | const SWvertex *vMin, *vMid, *vMax; | ||||
| GLint iyMin, iyMax; | |||||
| GLfloat yMin, yMax; | |||||
| GLboolean ltor; | |||||
| GLfloat majDx, majDy; /* major (i.e. long) edge dx and dy */ | |||||
| GLfloat xMin, yMin, xMid, yMid, xMax, yMax; | |||||
| GLfloat majDx, majDy, botDx, botDy, topDx, topDy; | |||||
| GLfloat area; | |||||
| GLboolean majorOnLeft; | |||||
| GLfloat bf = SWRAST_CONTEXT(ctx)->_backface_sign; | |||||
| #ifdef DO_Z | #ifdef DO_Z | ||||
| GLfloat zPlane[4]; | GLfloat zPlane[4]; | ||||
| GLfloat iPlane[4]; | GLfloat iPlane[4]; | ||||
| GLuint index[MAX_WIDTH]; | GLuint index[MAX_WIDTH]; | ||||
| GLint icoverageSpan[MAX_WIDTH]; | GLint icoverageSpan[MAX_WIDTH]; | ||||
| GLfloat coverageSpan[MAX_WIDTH]; | |||||
| #else | #else | ||||
| GLfloat coverageSpan[MAX_WIDTH]; | GLfloat coverageSpan[MAX_WIDTH]; | ||||
| #endif | #endif | ||||
| DEFMARRAY(GLfloat, u, MAX_TEXTURE_UNITS, MAX_WIDTH); | DEFMARRAY(GLfloat, u, MAX_TEXTURE_UNITS, MAX_WIDTH); | ||||
| DEFMARRAY(GLfloat, lambda, MAX_TEXTURE_UNITS, MAX_WIDTH); | DEFMARRAY(GLfloat, lambda, MAX_TEXTURE_UNITS, MAX_WIDTH); | ||||
| #endif | #endif | ||||
| GLfloat bf = SWRAST_CONTEXT(ctx)->_backface_sign; | |||||
| #ifdef DO_RGBA | #ifdef DO_RGBA | ||||
| CHECKARRAY(rgba, return); /* mac 32k limitation */ | CHECKARRAY(rgba, return); /* mac 32k limitation */ | ||||
| } | } | ||||
| } | } | ||||
| majDx = vMax->win[0] - vMin->win[0]; | |||||
| majDy = vMax->win[1] - vMin->win[1]; | |||||
| { | |||||
| const GLfloat botDx = vMid->win[0] - vMin->win[0]; | |||||
| const GLfloat botDy = vMid->win[1] - vMin->win[1]; | |||||
| const GLfloat area = majDx * botDy - botDx * majDy; | |||||
| ltor = (GLboolean) (area < 0.0F); | |||||
| /* Do backface culling */ | |||||
| if (area * bf < 0 || area * area < .0025) | |||||
| return; | |||||
| } | |||||
| xMin = vMin->win[0]; yMin = vMin->win[1]; | |||||
| xMid = vMid->win[0]; yMid = vMid->win[1]; | |||||
| xMax = vMax->win[0]; yMax = vMax->win[1]; | |||||
| /* the major edge is between the top and bottom vertices */ | |||||
| majDx = xMax - xMin; | |||||
| majDy = yMax - yMin; | |||||
| /* the bottom edge is between the bottom and mid vertices */ | |||||
| botDx = xMid - xMin; | |||||
| botDy = yMid - yMin; | |||||
| /* the top edge is between the top and mid vertices */ | |||||
| topDx = xMax - xMid; | |||||
| topDy = yMax - yMid; | |||||
| /* compute clockwise / counter-clockwise orientation and do BF culling */ | |||||
| area = majDx * botDy - botDx * majDy; | |||||
| /* Do backface culling */ | |||||
| if (area * bf < 0 || area * area < .0025) | |||||
| return; | |||||
| majorOnLeft = (GLboolean) (area < 0.0F); | |||||
| #ifndef DO_OCCLUSION_TEST | #ifndef DO_OCCLUSION_TEST | ||||
| ctx->OcclusionResult = GL_TRUE; | ctx->OcclusionResult = GL_TRUE; | ||||
| #endif | #endif | ||||
| assert(majDy > 0.0F); | |||||
| /* Plane equation setup: | /* Plane equation setup: | ||||
| * We evaluate plane equations at window (x,y) coordinates in order | * We evaluate plane equations at window (x,y) coordinates in order | ||||
| * to compute color, Z, fog, texcoords, etc. This isn't terribly | * to compute color, Z, fog, texcoords, etc. This isn't terribly | ||||
| * efficient but it's easy and reliable. | |||||
| * efficient but it's easy and reliable. It also copes with computing | |||||
| * interpolated data just outside the triangle's edges. | |||||
| */ | */ | ||||
| #ifdef DO_Z | #ifdef DO_Z | ||||
| compute_plane(p0, p1, p2, p0[2], p1[2], p2[2], zPlane); | compute_plane(p0, p1, p2, p0[2], p1[2], p2[2], zPlane); | ||||
| * edges, stopping when we find that coverage = 0. If the long edge | * edges, stopping when we find that coverage = 0. If the long edge | ||||
| * is on the left we scan left-to-right. Else, we scan right-to-left. | * is on the left we scan left-to-right. Else, we scan right-to-left. | ||||
| */ | */ | ||||
| yMin = vMin->win[1]; | |||||
| yMax = vMax->win[1]; | |||||
| iyMin = (GLint) yMin; | |||||
| iyMax = (GLint) yMax + 1; | |||||
| if (ltor) { | |||||
| /* scan left to right */ | |||||
| const GLfloat *pMin = vMin->win; | |||||
| const GLfloat *pMid = vMid->win; | |||||
| const GLfloat *pMax = vMax->win; | |||||
| const GLfloat dxdy = majDx / majDy; | |||||
| const GLfloat xAdj = dxdy < 0.0F ? -dxdy : 0.0F; | |||||
| GLfloat x = pMin[0] - (yMin - iyMin) * dxdy; | |||||
| { | |||||
| const GLint iyMin = (GLint) yMin; | |||||
| const GLint iyMax = (GLint) yMax + 1; | |||||
| /* upper edge and lower edge derivatives */ | |||||
| const GLfloat topDxDy = (topDy != 0.0F) ? topDx / topDy : 0.0F; | |||||
| const GLfloat botDxDy = (botDy != 0.0F) ? botDx / botDy : 0.0F; | |||||
| const GLfloat *pA, *pB, *pC; | |||||
| const GLfloat majDxDy = majDx / majDy; | |||||
| const GLfloat absMajDxDy = FABSF(majDxDy); | |||||
| const GLfloat absTopDxDy = FABSF(topDxDy); | |||||
| const GLfloat absBotDxDy = FABSF(botDxDy); | |||||
| #if 0 | |||||
| GLfloat xMaj = xMin - (yMin - (GLfloat) iyMin) * majDxDy; | |||||
| GLfloat xBot = xMaj; | |||||
| GLfloat xTop = xMid - (yMid - (GLint) yMid) * topDxDy; | |||||
| #else | |||||
| GLfloat xMaj; | |||||
| GLfloat xBot; | |||||
| GLfloat xTop; | |||||
| #endif | |||||
| GLint iy; | GLint iy; | ||||
| for (iy = iyMin; iy < iyMax; iy++, x += dxdy) { | |||||
| GLint ix, startX = (GLint) (x - xAdj); | |||||
| GLuint count, n; | |||||
| GLint k; | |||||
| /* pA, pB, pC are the vertices in counter-clockwise order */ | |||||
| if (majorOnLeft) { | |||||
| pA = vMin->win; | |||||
| pB = vMid->win; | |||||
| pC = vMax->win; | |||||
| xMaj = xMin - absMajDxDy - 1.0; | |||||
| xBot = xMin + absBotDxDy + 1.0; | |||||
| xTop = xMid + absTopDxDy + 1.0; | |||||
| } | |||||
| else { | |||||
| pA = vMin->win; | |||||
| pB = vMax->win; | |||||
| pC = vMid->win; | |||||
| xMaj = xMin + absMajDxDy + 1.0; | |||||
| xBot = xMin - absBotDxDy - 1.0; | |||||
| xTop = xMid - absTopDxDy - 1.0; | |||||
| } | |||||
| /* Scan from bottom to top */ | |||||
| for (iy = iyMin; iy < iyMax; iy++, xMaj += majDxDy) { | |||||
| GLint ix, i, j, len; | |||||
| GLint iRight, iLeft; | |||||
| GLfloat coverage = 0.0F; | GLfloat coverage = 0.0F; | ||||
| /* skip over fragments with zero coverage */ | |||||
| while (startX < MAX_WIDTH) { | |||||
| coverage = compute_coveragef(pMin, pMid, pMax, startX, iy); | |||||
| if (coverage > 0.0F) | |||||
| break; | |||||
| startX++; | |||||
| if (majorOnLeft) { | |||||
| iLeft = (GLint) (xMaj + 0.0); | |||||
| /* compute right */ | |||||
| if (iy <= yMid) { | |||||
| /* we're in the lower part */ | |||||
| iRight = (GLint) (xBot + 0.0); | |||||
| xBot += botDxDy; | |||||
| } | |||||
| else { | |||||
| /* we're in the upper part */ | |||||
| iRight = (GLint) (xTop + 0.0); | |||||
| xTop += topDxDy; | |||||
| } | |||||
| } | |||||
| else { | |||||
| iRight = (GLint) (xMaj + 0.0); | |||||
| /* compute left */ | |||||
| if (iy <= yMid) { | |||||
| /* we're in the lower part */ | |||||
| iLeft = (GLint) (xBot - 0.0); | |||||
| xBot += botDxDy; | |||||
| } | |||||
| else { | |||||
| /* we're in the upper part */ | |||||
| iLeft = (GLint) (xTop - 0.0); | |||||
| xTop += topDxDy; | |||||
| } | |||||
| } | } | ||||
| /* enter interior of triangle */ | |||||
| ix = startX; | |||||
| count = 0; | |||||
| while (coverage > 0.0F) { | |||||
| /* (cx,cy) = center of fragment */ | |||||
| const GLfloat cx = ix + 0.5F, cy = iy + 0.5F; | |||||
| #ifdef DO_INDEX | |||||
| icoverageSpan[count] = compute_coveragei(pMin, pMid, pMax, ix, iy); | |||||
| #else | |||||
| coverageSpan[count] = coverage; | |||||
| #ifdef DEBUG | |||||
| for (i = 0; i < MAX_WIDTH; i++) { | |||||
| coverageSpan[i] = -1.0; | |||||
| } | |||||
| #endif | #endif | ||||
| if (iLeft < 0) | |||||
| iLeft = 0; | |||||
| if (iRight >= ctx->DrawBuffer->_Xmax) | |||||
| iRight = ctx->DrawBuffer->_Xmax - 1; | |||||
| /*printf("%d: iLeft = %d iRight = %d\n", iy, iLeft, iRight);*/ | |||||
| /* The pixels at y in [iLeft, iRight] (inclusive) are candidates */ | |||||
| /* scan left to right until we hit 100% coverage or the right edge */ | |||||
| i = iLeft; | |||||
| while (i < iRight) { | |||||
| coverage = compute_coveragef(pA, pB, pC, i, iy); | |||||
| if (coverage == 0.0F) { | |||||
| if (i == iLeft) | |||||
| iLeft++; /* skip zero coverage pixels */ | |||||
| else { | |||||
| iRight = i; | |||||
| i--; | |||||
| break; /* went past right edge */ | |||||
| } | |||||
| } | |||||
| else { | |||||
| coverageSpan[i - iLeft] = coverage; | |||||
| if (coverage == 1.0F) | |||||
| break; | |||||
| } | |||||
| i++; | |||||
| } | |||||
| assert(coverageSpan[i-iLeft] > 0.0 || iLeft == iRight); | |||||
| assert(i == iRight || coverage == 1.0 || coverage == 0.0); | |||||
| /* scan right to left until we hit 100% coverage or the left edge */ | |||||
| j = iRight; | |||||
| assert(j - iLeft >= 0); | |||||
| while (1) { | |||||
| coverage = compute_coveragef(pA, pB, pC, j, iy); | |||||
| if (coverage == 0.0F) { | |||||
| if (j == iRight && j > i) | |||||
| iRight--; /* skip zero coverage pixels */ | |||||
| else | |||||
| break; | |||||
| } | |||||
| else { | |||||
| if (j <= i) | |||||
| break; | |||||
| assert(j - iLeft >= 0); | |||||
| coverageSpan[j - iLeft] = coverage; | |||||
| if (coverage == 1.0F) | |||||
| break; | |||||
| } | |||||
| /*printf("%d: coverage[%d]' = %g\n", iy, j-iLeft, coverage);*/ | |||||
| j--; | |||||
| } | |||||
| assert(coverageSpan[j-iLeft] > 0.0 || iRight <= iLeft); | |||||
| printf("iLeft=%d i=%d j=%d iRight=%d\n", iLeft, i, j, iRight); | |||||
| assert(iLeft >= 0); | |||||
| assert(iLeft < ctx->DrawBuffer->_Xmax); | |||||
| assert(iRight >= 0); | |||||
| assert(iRight < ctx->DrawBuffer->_Xmax); | |||||
| assert(iRight >= iLeft); | |||||
| /* any pixels left in between must have 100% coverage */ | |||||
| k = i + 1; | |||||
| while (k < j) { | |||||
| coverageSpan[k - iLeft] = 1.0F; | |||||
| k++; | |||||
| } | |||||
| len = iRight - iLeft; | |||||
| /*printf("len = %d\n", len);*/ | |||||
| assert(len >= 0); | |||||
| assert(len < MAX_WIDTH); | |||||
| if (len == 0) | |||||
| continue; | |||||
| #ifdef DEBUG | |||||
| for (k = 0; k < len; k++) { | |||||
| assert(coverageSpan[k] > 0.0); | |||||
| } | |||||
| #endif | |||||
| /* | |||||
| * Compute color, texcoords, etc for the span | |||||
| */ | |||||
| { | |||||
| const GLfloat cx = iLeft + 0.5F, cy = iy + 0.5F; | |||||
| #ifdef DO_Z | #ifdef DO_Z | ||||
| z[count] = (GLdepth) solve_plane(cx, cy, zPlane); | |||||
| GLfloat zFrag = solve_plane(cx, cy, zPlane); | |||||
| const GLfloat zStep = -zPlane[0] / zPlane[2]; | |||||
| #endif | #endif | ||||
| #ifdef DO_FOG | #ifdef DO_FOG | ||||
| fog[count] = solve_plane(cx, cy, fogPlane); | |||||
| GLfloat fogFrag = solve_plane(cx, cy, fogPlane); | |||||
| const GLfloat fogStep = -fogPlane[0] / fogPlane[2]; | |||||
| #endif | #endif | ||||
| #ifdef DO_RGBA | #ifdef DO_RGBA | ||||
| rgba[count][RCOMP] = solve_plane_chan(cx, cy, rPlane); | |||||
| rgba[count][GCOMP] = solve_plane_chan(cx, cy, gPlane); | |||||
| rgba[count][BCOMP] = solve_plane_chan(cx, cy, bPlane); | |||||
| rgba[count][ACOMP] = solve_plane_chan(cx, cy, aPlane); | |||||
| /* to do */ | |||||
| #endif | #endif | ||||
| #ifdef DO_INDEX | #ifdef DO_INDEX | ||||
| index[count] = (GLint) solve_plane(cx, cy, iPlane); | |||||
| /* to do */ | |||||
| #endif | #endif | ||||
| #ifdef DO_SPEC | #ifdef DO_SPEC | ||||
| spec[count][RCOMP] = solve_plane_chan(cx, cy, srPlane); | |||||
| spec[count][GCOMP] = solve_plane_chan(cx, cy, sgPlane); | |||||
| spec[count][BCOMP] = solve_plane_chan(cx, cy, sbPlane); | |||||
| /* to do */ | |||||
| #endif | #endif | ||||
| #ifdef DO_TEX | #ifdef DO_TEX | ||||
| { | |||||
| const GLfloat invQ = solve_plane_recip(cx, cy, vPlane); | |||||
| s[count] = solve_plane(cx, cy, sPlane) * invQ; | |||||
| t[count] = solve_plane(cx, cy, tPlane) * invQ; | |||||
| u[count] = solve_plane(cx, cy, uPlane) * invQ; | |||||
| lambda[count] = compute_lambda(sPlane, tPlane, invQ, | |||||
| texWidth, texHeight); | |||||
| } | |||||
| GLfloat sFrag = solve_plane(cx, cy, sPlane); | |||||
| GLfloat tFrag = solve_plane(cx, cy, tPlane); | |||||
| GLfloat uFrag = solve_plane(cx, cy, uPlane); | |||||
| GLfloat vFrag = solve_plane(cx, cy, vPlane); | |||||
| const GLfloat sStep = -sPlane[0] / sPlane[2]; | |||||
| const GLfloat tStep = -tPlane[0] / tPlane[2]; | |||||
| const GLfloat uStep = -uPlane[0] / uPlane[2]; | |||||
| const GLfloat vStep = -vPlane[0] / vPlane[2]; | |||||
| #elif defined(DO_MULTITEX) | #elif defined(DO_MULTITEX) | ||||
| { | |||||
| GLuint unit; | |||||
| for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) { | |||||
| if (ctx->Texture.Unit[unit]._ReallyEnabled) { | |||||
| GLfloat invQ = solve_plane_recip(cx, cy, vPlane[unit]); | |||||
| s[unit][count] = solve_plane(cx, cy, sPlane[unit]) * invQ; | |||||
| t[unit][count] = solve_plane(cx, cy, tPlane[unit]) * invQ; | |||||
| u[unit][count] = solve_plane(cx, cy, uPlane[unit]) * invQ; | |||||
| lambda[unit][count] = compute_lambda(sPlane[unit], | |||||
| tPlane[unit], invQ, texWidth[unit], texHeight[unit]); | |||||
| } | |||||
| } | |||||
| } | |||||
| #endif | |||||
| ix++; | |||||
| count++; | |||||
| coverage = compute_coveragef(pMin, pMid, pMax, ix, iy); | |||||
| } | |||||
| if (ix <= startX) | |||||
| continue; | |||||
| n = (GLuint) ix - (GLuint) startX; | |||||
| #ifdef DO_MULTITEX | |||||
| # ifdef DO_SPEC | |||||
| _mesa_write_multitexture_span(ctx, n, startX, iy, z, fog, | |||||
| (const GLfloat (*)[MAX_WIDTH]) s, | |||||
| (const GLfloat (*)[MAX_WIDTH]) t, | |||||
| (const GLfloat (*)[MAX_WIDTH]) u, | |||||
| (GLfloat (*)[MAX_WIDTH]) lambda, | |||||
| rgba, (const GLchan (*)[4]) spec, | |||||
| coverageSpan, GL_POLYGON); | |||||
| # else | |||||
| _mesa_write_multitexture_span(ctx, n, startX, iy, z, fog, | |||||
| (const GLfloat (*)[MAX_WIDTH]) s, | |||||
| (const GLfloat (*)[MAX_WIDTH]) t, | |||||
| (const GLfloat (*)[MAX_WIDTH]) u, | |||||
| lambda, rgba, NULL, coverageSpan, | |||||
| GL_POLYGON); | |||||
| # endif | |||||
| #elif defined(DO_TEX) | |||||
| # ifdef DO_SPEC | |||||
| _mesa_write_texture_span(ctx, n, startX, iy, z, fog, | |||||
| s, t, u, lambda, rgba, | |||||
| (const GLchan (*)[4]) spec, | |||||
| coverageSpan, GL_POLYGON); | |||||
| # else | |||||
| _mesa_write_texture_span(ctx, n, startX, iy, z, fog, | |||||
| s, t, u, lambda, | |||||
| rgba, NULL, coverageSpan, GL_POLYGON); | |||||
| # endif | |||||
| #elif defined(DO_RGBA) | |||||
| _mesa_write_rgba_span(ctx, n, startX, iy, z, fog, rgba, | |||||
| coverageSpan, GL_POLYGON); | |||||
| #elif defined(DO_INDEX) | |||||
| _mesa_write_index_span(ctx, n, startX, iy, z, fog, index, | |||||
| icoverageSpan, GL_POLYGON); | |||||
| /* to do */ | |||||
| #endif | #endif | ||||
| } | |||||
| } | |||||
| else { | |||||
| /* scan right to left */ | |||||
| const GLfloat *pMin = vMin->win; | |||||
| const GLfloat *pMid = vMid->win; | |||||
| const GLfloat *pMax = vMax->win; | |||||
| const GLfloat dxdy = majDx / majDy; | |||||
| const GLfloat xAdj = dxdy > 0 ? dxdy : 0.0F; | |||||
| GLfloat x = pMin[0] - (yMin - iyMin) * dxdy; | |||||
| GLint iy; | |||||
| for (iy = iyMin; iy < iyMax; iy++, x += dxdy) { | |||||
| GLint ix, left, startX = (GLint) (x + xAdj); | |||||
| GLuint count, n; | |||||
| GLfloat coverage = 0.0F; | |||||
| /* make sure we're not past the window edge */ | |||||
| if (startX >= ctx->DrawBuffer->_Xmax) { | |||||
| startX = ctx->DrawBuffer->_Xmax - 1; | |||||
| } | |||||
| for (ix = iLeft; ix < iRight; ix++) { | |||||
| const GLint k = ix - iLeft; | |||||
| const GLfloat cx = ix + 0.5F, cy = iy + 0.5F; | |||||
| /* skip fragments with zero coverage */ | |||||
| while (startX >= 0) { | |||||
| coverage = compute_coveragef(pMin, pMax, pMid, startX, iy); | |||||
| if (coverage > 0.0F) | |||||
| break; | |||||
| startX--; | |||||
| } | |||||
| /* enter interior of triangle */ | |||||
| ix = startX; | |||||
| count = 0; | |||||
| while (coverage > 0.0F) { | |||||
| /* (cx,cy) = center of fragment */ | |||||
| const GLfloat cx = ix + 0.5F, cy = iy + 0.5F; | |||||
| #ifdef DO_INDEX | |||||
| icoverageSpan[ix] = compute_coveragei(pMin, pMid, pMax, ix, iy); | |||||
| #else | |||||
| coverageSpan[ix] = coverage; | |||||
| #endif | |||||
| #ifdef DO_Z | #ifdef DO_Z | ||||
| z[ix] = (GLdepth) solve_plane(cx, cy, zPlane); | |||||
| z[k] = zFrag; zFrag += zStep; | |||||
| #endif | #endif | ||||
| #ifdef DO_FOG | #ifdef DO_FOG | ||||
| fog[ix] = solve_plane(cx, cy, fogPlane); | |||||
| fog[k] = fogFrag; fogFrag += fogStep; | |||||
| #endif | #endif | ||||
| #ifdef DO_RGBA | #ifdef DO_RGBA | ||||
| rgba[ix][RCOMP] = solve_plane_chan(cx, cy, rPlane); | |||||
| rgba[ix][GCOMP] = solve_plane_chan(cx, cy, gPlane); | |||||
| rgba[ix][BCOMP] = solve_plane_chan(cx, cy, bPlane); | |||||
| rgba[ix][ACOMP] = solve_plane_chan(cx, cy, aPlane); | |||||
| rgba[k][RCOMP] = solve_plane_chan(cx, cy, rPlane); | |||||
| rgba[k][GCOMP] = solve_plane_chan(cx, cy, gPlane); | |||||
| rgba[k][BCOMP] = solve_plane_chan(cx, cy, bPlane); | |||||
| rgba[k][ACOMP] = solve_plane_chan(cx, cy, aPlane); | |||||
| #endif | #endif | ||||
| #ifdef DO_INDEX | #ifdef DO_INDEX | ||||
| index[ix] = (GLint) solve_plane(cx, cy, iPlane); | |||||
| index[k] = (GLint) solve_plane(cx, cy, iPlane); | |||||
| #endif | #endif | ||||
| #ifdef DO_SPEC | #ifdef DO_SPEC | ||||
| spec[ix][RCOMP] = solve_plane_chan(cx, cy, srPlane); | |||||
| spec[ix][GCOMP] = solve_plane_chan(cx, cy, sgPlane); | |||||
| spec[ix][BCOMP] = solve_plane_chan(cx, cy, sbPlane); | |||||
| spec[k][RCOMP] = solve_plane_chan(cx, cy, srPlane); | |||||
| spec[k][GCOMP] = solve_plane_chan(cx, cy, sgPlane); | |||||
| spec[k][BCOMP] = solve_plane_chan(cx, cy, sbPlane); | |||||
| #endif | #endif | ||||
| #ifdef DO_TEX | #ifdef DO_TEX | ||||
| { | |||||
| const GLfloat invQ = solve_plane_recip(cx, cy, vPlane); | |||||
| s[ix] = solve_plane(cx, cy, sPlane) * invQ; | |||||
| t[ix] = solve_plane(cx, cy, tPlane) * invQ; | |||||
| u[ix] = solve_plane(cx, cy, uPlane) * invQ; | |||||
| lambda[ix] = compute_lambda(sPlane, tPlane, invQ, | |||||
| texWidth, texHeight); | |||||
| } | |||||
| s[k] = sFrag / vFrag; | |||||
| t[k] = tFrag / vFrag; | |||||
| u[k] = uFrag / vFrag; | |||||
| lambda[k] = compute_lambda(sPlane, tPlane, 1.0F / vFrag, | |||||
| texWidth, texHeight); | |||||
| sFrag += sStep; | |||||
| tFrag += tStep; | |||||
| uFrag += uStep; | |||||
| vFrag += vStep; | |||||
| #elif defined(DO_MULTITEX) | #elif defined(DO_MULTITEX) | ||||
| { | |||||
| GLuint unit; | |||||
| for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) { | |||||
| if (ctx->Texture.Unit[unit]._ReallyEnabled) { | |||||
| GLfloat invQ = solve_plane_recip(cx, cy, vPlane[unit]); | |||||
| s[unit][ix] = solve_plane(cx, cy, sPlane[unit]) * invQ; | |||||
| t[unit][ix] = solve_plane(cx, cy, tPlane[unit]) * invQ; | |||||
| u[unit][ix] = solve_plane(cx, cy, uPlane[unit]) * invQ; | |||||
| lambda[unit][ix] = compute_lambda(sPlane[unit], | |||||
| tPlane[unit], invQ, texWidth[unit], texHeight[unit]); | |||||
| { | |||||
| GLuint unit; | |||||
| for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) { | |||||
| if (ctx->Texture.Unit[unit]._ReallyEnabled) { | |||||
| GLfloat invQ = solve_plane_recip(cx, cy, vPlane[unit]); | |||||
| s[unit][k] = solve_plane(cx, cy, sPlane[unit]) * invQ; | |||||
| t[unit][k] = solve_plane(cx, cy, tPlane[unit]) * invQ; | |||||
| u[unit][k] = solve_plane(cx, cy, uPlane[unit]) * invQ; | |||||
| lambda[unit][k] = compute_lambda(sPlane[unit], | |||||
| tPlane[unit], invQ, texWidth[unit], texHeight[unit]); | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| } | |||||
| #endif | #endif | ||||
| ix--; | |||||
| count++; | |||||
| coverage = compute_coveragef(pMin, pMax, pMid, ix, iy); | |||||
| } /* for ix */ | |||||
| } | } | ||||
| if (startX <= ix) | |||||
| continue; | |||||
| n = (GLuint) startX - (GLuint) ix; | |||||
| left = ix + 1; | |||||
| /* | |||||
| * Write/process the span of fragments. | |||||
| */ | |||||
| #ifdef DO_MULTITEX | #ifdef DO_MULTITEX | ||||
| { | |||||
| GLuint unit; | |||||
| for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) { | |||||
| if (ctx->Texture.Unit[unit]._ReallyEnabled) { | |||||
| GLint j; | |||||
| for (j = 0; j < (GLint) n; j++) { | |||||
| s[unit][j] = s[unit][j + left]; | |||||
| t[unit][j] = t[unit][j + left]; | |||||
| u[unit][j] = u[unit][j + left]; | |||||
| lambda[unit][j] = lambda[unit][j + left]; | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| # ifdef DO_SPEC | |||||
| _mesa_write_multitexture_span(ctx, n, left, iy, z + left, fog + left, | |||||
| _mesa_write_multitexture_span(ctx, len, iLeft, iy, z, fog, | |||||
| (const GLfloat (*)[MAX_WIDTH]) s, | (const GLfloat (*)[MAX_WIDTH]) s, | ||||
| (const GLfloat (*)[MAX_WIDTH]) t, | (const GLfloat (*)[MAX_WIDTH]) t, | ||||
| (const GLfloat (*)[MAX_WIDTH]) u, | (const GLfloat (*)[MAX_WIDTH]) u, | ||||
| lambda, rgba + left, | |||||
| (const GLchan (*)[4]) (spec + left), | |||||
| coverageSpan + left, | |||||
| GL_POLYGON); | |||||
| (GLfloat (*)[MAX_WIDTH]) lambda, | |||||
| rgba, | |||||
| # ifdef DO_SPEC | |||||
| (const GLchan (*)[4]) spec, | |||||
| # else | # else | ||||
| _mesa_write_multitexture_span(ctx, n, left, iy, z + left, fog + left, | |||||
| (const GLfloat (*)[MAX_WIDTH]) s, | |||||
| (const GLfloat (*)[MAX_WIDTH]) t, | |||||
| (const GLfloat (*)[MAX_WIDTH]) u, | |||||
| lambda, | |||||
| rgba + left, NULL, coverageSpan + left, | |||||
| GL_POLYGON); | |||||
| NULL, | |||||
| # endif | # endif | ||||
| coverageSpan, GL_POLYGON); | |||||
| #elif defined(DO_TEX) | #elif defined(DO_TEX) | ||||
| _mesa_write_texture_span(ctx, len, iLeft, iy, z, fog, | |||||
| s, t, u, lambda, rgba, | |||||
| # ifdef DO_SPEC | # ifdef DO_SPEC | ||||
| _mesa_write_texture_span(ctx, n, left, iy, z + left, fog + left, | |||||
| s + left, t + left, u + left, | |||||
| lambda + left, rgba + left, | |||||
| (const GLchan (*)[4]) (spec + left), | |||||
| coverageSpan + left, | |||||
| GL_POLYGON); | |||||
| (const GLchan (*)[4]) spec, | |||||
| # else | # else | ||||
| _mesa_write_texture_span(ctx, n, left, iy, z + left, fog + left, | |||||
| s + left, t + left, | |||||
| u + left, lambda + left, | |||||
| rgba + left, NULL, | |||||
| coverageSpan + left, GL_POLYGON); | |||||
| NULL, | |||||
| # endif | # endif | ||||
| coverageSpan, GL_POLYGON); | |||||
| #elif defined(DO_RGBA) | #elif defined(DO_RGBA) | ||||
| _mesa_write_rgba_span(ctx, n, left, iy, z + left, fog + left, | |||||
| rgba + left, coverageSpan + left, GL_POLYGON); | |||||
| _mesa_write_rgba_span(ctx, len, iLeft, iy, z, fog, rgba, | |||||
| coverageSpan, GL_POLYGON); | |||||
| #elif defined(DO_INDEX) | #elif defined(DO_INDEX) | ||||
| _mesa_write_index_span(ctx, n, left, iy, z + left, fog + left, | |||||
| index + left, icoverageSpan + left, GL_POLYGON); | |||||
| _mesa_write_index_span(ctx, len, iLeft, iy, z, fog, index, | |||||
| icoverageSpan, GL_POLYGON); | |||||
| #endif | #endif | ||||
| } | |||||
| } /* for iy */ | |||||
| } | } | ||||
| #ifdef DO_RGBA | #ifdef DO_RGBA | ||||
| UNDEFARRAY(rgba); /* mac 32k limitation */ | UNDEFARRAY(rgba); /* mac 32k limitation */ | ||||
| #endif | #endif |
| /* $Id: s_accum.c,v 1.11 2001/04/20 19:21:41 brianp Exp $ */ | |||||
| /* $Id: s_accum.c,v 1.12 2001/07/13 20:07:37 brianp Exp $ */ | |||||
| /* | /* | ||||
| * Mesa 3-D graphics library | * Mesa 3-D graphics library | ||||
| { | { | ||||
| SWcontext *swrast = SWRAST_CONTEXT(ctx); | SWcontext *swrast = SWRAST_CONTEXT(ctx); | ||||
| const GLuint n = ctx->DrawBuffer->Width * ctx->DrawBuffer->Height * 4; | const GLuint n = ctx->DrawBuffer->Width * ctx->DrawBuffer->Height * 4; | ||||
| const GLfloat fChanMax = (1 << (sizeof(GLchan) * 8)) - 1; | |||||
| const GLfloat s = swrast->_IntegerAccumScaler * (32767.0 / fChanMax); | |||||
| const GLfloat s = swrast->_IntegerAccumScaler * (32767.0 / CHAN_MAXF); | |||||
| GLaccum *accum = ctx->DrawBuffer->Accum; | GLaccum *accum = ctx->DrawBuffer->Accum; | ||||
| GLuint i; | GLuint i; | ||||
| acc_scale = 32767.0; | acc_scale = 32767.0; | ||||
| } | } | ||||
| else { | else { | ||||
| /* sizeof(GLaccum) > 2 (Cray) */ | |||||
| acc_scale = (float) SHRT_MAX; | |||||
| acc_scale = 1.0F; | |||||
| } | } | ||||
| /* number of pixels */ | /* number of pixels */ | ||||
| if (ctx->DrawBuffer->Accum) { | if (ctx->DrawBuffer->Accum) { | ||||
| if (ctx->Scissor.Enabled) { | if (ctx->Scissor.Enabled) { | ||||
| /* Limit clear to scissor box */ | /* Limit clear to scissor box */ | ||||
| GLaccum r, g, b, a; | |||||
| const GLaccum r = (GLaccum) (ctx->Accum.ClearColor[0] * acc_scale); | |||||
| const GLaccum g = (GLaccum) (ctx->Accum.ClearColor[1] * acc_scale); | |||||
| const GLaccum b = (GLaccum) (ctx->Accum.ClearColor[2] * acc_scale); | |||||
| const GLaccum a = (GLaccum) (ctx->Accum.ClearColor[3] * acc_scale); | |||||
| GLint i, j; | GLint i, j; | ||||
| GLint width, height; | GLint width, height; | ||||
| GLaccum *row; | GLaccum *row; | ||||
| r = (GLaccum) (ctx->Accum.ClearColor[0] * acc_scale); | |||||
| g = (GLaccum) (ctx->Accum.ClearColor[1] * acc_scale); | |||||
| b = (GLaccum) (ctx->Accum.ClearColor[2] * acc_scale); | |||||
| a = (GLaccum) (ctx->Accum.ClearColor[3] * acc_scale); | |||||
| /* size of region to clear */ | /* size of region to clear */ | ||||
| width = 4 * (ctx->DrawBuffer->_Xmax - ctx->DrawBuffer->_Xmin); | width = 4 * (ctx->DrawBuffer->_Xmax - ctx->DrawBuffer->_Xmin); | ||||
| height = ctx->DrawBuffer->_Ymax - ctx->DrawBuffer->_Ymin; | height = ctx->DrawBuffer->_Ymax - ctx->DrawBuffer->_Ymin; | ||||
| } | } | ||||
| else { | else { | ||||
| /* Not black */ | /* Not black */ | ||||
| GLaccum *acc, r, g, b, a; | |||||
| const GLaccum r = (GLaccum) (ctx->Accum.ClearColor[0] * acc_scale); | |||||
| const GLaccum g = (GLaccum) (ctx->Accum.ClearColor[1] * acc_scale); | |||||
| const GLaccum b = (GLaccum) (ctx->Accum.ClearColor[2] * acc_scale); | |||||
| const GLaccum a = (GLaccum) (ctx->Accum.ClearColor[3] * acc_scale); | |||||
| GLaccum *acc = ctx->DrawBuffer->Accum; | |||||
| GLuint i; | GLuint i; | ||||
| acc = ctx->DrawBuffer->Accum; | |||||
| r = (GLaccum) (ctx->Accum.ClearColor[0] * acc_scale); | |||||
| g = (GLaccum) (ctx->Accum.ClearColor[1] * acc_scale); | |||||
| b = (GLaccum) (ctx->Accum.ClearColor[2] * acc_scale); | |||||
| a = (GLaccum) (ctx->Accum.ClearColor[3] * acc_scale); | |||||
| for (i=0;i<buffersize;i++) { | for (i=0;i<buffersize;i++) { | ||||
| *acc++ = r; | *acc++ = r; | ||||
| *acc++ = g; | *acc++ = g; | ||||
| GLfloat acc_scale; | GLfloat acc_scale; | ||||
| GLchan rgba[MAX_WIDTH][4]; | GLchan rgba[MAX_WIDTH][4]; | ||||
| const GLuint colorMask = *((GLuint *) &ctx->Color.ColorMask); | const GLuint colorMask = *((GLuint *) &ctx->Color.ColorMask); | ||||
| const GLint iChanMax = (1 << (sizeof(GLchan) * 8)) - 1; | |||||
| const GLfloat fChanMax = (1 << (sizeof(GLchan) * 8)) - 1; | |||||
| if (SWRAST_CONTEXT(ctx)->NewState) | if (SWRAST_CONTEXT(ctx)->NewState) | ||||
| acc_scale = 32767.0; | acc_scale = 32767.0; | ||||
| } | } | ||||
| else { | else { | ||||
| /* sizeof(GLaccum) > 2 (Cray) */ | |||||
| acc_scale = (float) SHRT_MAX; | |||||
| acc_scale = 1.0F; | |||||
| } | } | ||||
| width4 = 4 * width; | width4 = 4 * width; | ||||
| switch (op) { | switch (op) { | ||||
| case GL_ADD: | case GL_ADD: | ||||
| if (value != 0.0F) { | if (value != 0.0F) { | ||||
| const GLaccum intVal = (GLaccum) (value * acc_scale); | |||||
| const GLaccum val = (GLaccum) (value * acc_scale); | |||||
| GLint j; | GLint j; | ||||
| /* Leave optimized accum buffer mode */ | /* Leave optimized accum buffer mode */ | ||||
| if (swrast->_IntegerAccumMode) | if (swrast->_IntegerAccumMode) | ||||
| rescale_accum(ctx); | rescale_accum(ctx); | ||||
| for (j = 0; j < height; j++) { | for (j = 0; j < height; j++) { | ||||
| GLaccum * acc = ctx->DrawBuffer->Accum + ypos * width4 + 4 * xpos; | |||||
| GLaccum *acc = ctx->DrawBuffer->Accum + ypos * width4 + 4*xpos; | |||||
| GLuint i; | GLuint i; | ||||
| for (i = 0; i < width4; i++) { | for (i = 0; i < width4; i++) { | ||||
| acc[i] += intVal; | |||||
| acc[i] += val; | |||||
| } | } | ||||
| ypos++; | ypos++; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| /* scaled integer accum buffer */ | |||||
| const GLfloat rscale = value * acc_scale / fChanMax; | |||||
| const GLfloat gscale = value * acc_scale / fChanMax; | |||||
| const GLfloat bscale = value * acc_scale / fChanMax; | |||||
| const GLfloat ascale = value * acc_scale / fChanMax; | |||||
| /* scaled integer (or float) accum buffer */ | |||||
| const GLfloat rscale = value * acc_scale / CHAN_MAXF; | |||||
| const GLfloat gscale = value * acc_scale / CHAN_MAXF; | |||||
| const GLfloat bscale = value * acc_scale / CHAN_MAXF; | |||||
| const GLfloat ascale = value * acc_scale / CHAN_MAXF; | |||||
| GLint j; | GLint j; | ||||
| for (j=0;j<height;j++) { | for (j=0;j<height;j++) { | ||||
| GLaccum *acc = ctx->DrawBuffer->Accum + ypos * width4 + xpos * 4; | GLaccum *acc = ctx->DrawBuffer->Accum + ypos * width4 + xpos * 4; | ||||
| GLint i; | GLint i; | ||||
| _mesa_read_rgba_span(ctx, ctx->DrawBuffer, width, xpos, ypos, rgba); | _mesa_read_rgba_span(ctx, ctx->DrawBuffer, width, xpos, ypos, rgba); | ||||
| for (i=0;i<width;i++) { | for (i=0;i<width;i++) { | ||||
| *acc += (GLaccum) ( (GLfloat) rgba[i][RCOMP] * rscale ); acc++; | |||||
| *acc += (GLaccum) ( (GLfloat) rgba[i][GCOMP] * gscale ); acc++; | |||||
| *acc += (GLaccum) ( (GLfloat) rgba[i][BCOMP] * bscale ); acc++; | |||||
| *acc += (GLaccum) ( (GLfloat) rgba[i][ACOMP] * ascale ); acc++; | |||||
| acc[0] += (GLaccum) ( (GLfloat) rgba[i][RCOMP] * rscale ); | |||||
| acc[1] += (GLaccum) ( (GLfloat) rgba[i][GCOMP] * gscale ); | |||||
| acc[2] += (GLaccum) ( (GLfloat) rgba[i][BCOMP] * bscale ); | |||||
| acc[3] += (GLaccum) ( (GLfloat) rgba[i][ACOMP] * ascale ); | |||||
| acc += 4; | |||||
| } | } | ||||
| ypos++; | ypos++; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| /* scaled integer accum buffer */ | |||||
| const GLfloat rscale = value * acc_scale / fChanMax; | |||||
| const GLfloat gscale = value * acc_scale / fChanMax; | |||||
| const GLfloat bscale = value * acc_scale / fChanMax; | |||||
| const GLfloat ascale = value * acc_scale / fChanMax; | |||||
| const GLfloat d = 3.0 / acc_scale; | |||||
| /* scaled integer (or float) accum buffer */ | |||||
| const GLfloat rscale = value * acc_scale / CHAN_MAXF; | |||||
| const GLfloat gscale = value * acc_scale / CHAN_MAXF; | |||||
| const GLfloat bscale = value * acc_scale / CHAN_MAXF; | |||||
| const GLfloat ascale = value * acc_scale / CHAN_MAXF; | |||||
| #if 0 | |||||
| const GLfloat d = 3.0 / acc_scale; /* XXX what's this? */ | |||||
| #endif | |||||
| GLint i, j; | GLint i, j; | ||||
| for (j = 0; j < height; j++) { | for (j = 0; j < height; j++) { | ||||
| GLaccum *acc = ctx->DrawBuffer->Accum + ypos * width4 + xpos * 4; | GLaccum *acc = ctx->DrawBuffer->Accum + ypos * width4 + xpos * 4; | ||||
| _mesa_read_rgba_span(ctx, ctx->DrawBuffer, width, xpos, ypos, rgba); | _mesa_read_rgba_span(ctx, ctx->DrawBuffer, width, xpos, ypos, rgba); | ||||
| for (i=0;i<width;i++) { | for (i=0;i<width;i++) { | ||||
| #if 0 | |||||
| *acc++ = (GLaccum) ((GLfloat) rgba[i][RCOMP] * rscale + d); | *acc++ = (GLaccum) ((GLfloat) rgba[i][RCOMP] * rscale + d); | ||||
| *acc++ = (GLaccum) ((GLfloat) rgba[i][GCOMP] * gscale + d); | *acc++ = (GLaccum) ((GLfloat) rgba[i][GCOMP] * gscale + d); | ||||
| *acc++ = (GLaccum) ((GLfloat) rgba[i][BCOMP] * bscale + d); | *acc++ = (GLaccum) ((GLfloat) rgba[i][BCOMP] * bscale + d); | ||||
| *acc++ = (GLaccum) ((GLfloat) rgba[i][ACOMP] * ascale + d); | *acc++ = (GLaccum) ((GLfloat) rgba[i][ACOMP] * ascale + d); | ||||
| #else | |||||
| *acc++ = (GLaccum) ((GLfloat) rgba[i][RCOMP] * rscale); | |||||
| *acc++ = (GLaccum) ((GLfloat) rgba[i][GCOMP] * gscale); | |||||
| *acc++ = (GLaccum) ((GLfloat) rgba[i][BCOMP] * bscale); | |||||
| *acc++ = (GLaccum) ((GLfloat) rgba[i][ACOMP] * ascale); | |||||
| #endif | |||||
| } | } | ||||
| ypos++; | ypos++; | ||||
| } | } | ||||
| rescale_accum(ctx); | rescale_accum(ctx); | ||||
| RENDER_START(swrast,ctx); | RENDER_START(swrast,ctx); | ||||
| #ifdef USE_OPTIMIZED_ACCUM | |||||
| if (swrast->_IntegerAccumMode && swrast->_IntegerAccumScaler > 0) { | if (swrast->_IntegerAccumMode && swrast->_IntegerAccumScaler > 0) { | ||||
| /* build lookup table to avoid many floating point multiplies */ | /* build lookup table to avoid many floating point multiplies */ | ||||
| static GLchan multTable[32768]; | static GLchan multTable[32768]; | ||||
| ypos++; | ypos++; | ||||
| } | } | ||||
| } | } | ||||
| else { | |||||
| const GLfloat rscale = value / acc_scale * fChanMax; | |||||
| const GLfloat gscale = value / acc_scale * fChanMax; | |||||
| const GLfloat bscale = value / acc_scale * fChanMax; | |||||
| const GLfloat ascale = value / acc_scale * fChanMax; | |||||
| else | |||||
| #endif /* USE_OPTIMIZED_ACCUM */ | |||||
| { | |||||
| /* scaled integer (or float) accum buffer */ | |||||
| const GLfloat rscale = value / acc_scale * CHAN_MAXF; | |||||
| const GLfloat gscale = value / acc_scale * CHAN_MAXF; | |||||
| const GLfloat bscale = value / acc_scale * CHAN_MAXF; | |||||
| const GLfloat ascale = value / acc_scale * CHAN_MAXF; | |||||
| GLint i, j; | GLint i, j; | ||||
| for (j=0;j<height;j++) { | for (j=0;j<height;j++) { | ||||
| const GLaccum *acc = ctx->DrawBuffer->Accum + ypos * width4 + xpos*4; | const GLaccum *acc = ctx->DrawBuffer->Accum + ypos * width4 + xpos*4; | ||||
| GLint b = IROUND( (GLfloat) (acc[2]) * bscale ); | GLint b = IROUND( (GLfloat) (acc[2]) * bscale ); | ||||
| GLint a = IROUND( (GLfloat) (acc[3]) * ascale ); | GLint a = IROUND( (GLfloat) (acc[3]) * ascale ); | ||||
| acc += 4; | acc += 4; | ||||
| rgba[i][RCOMP] = CLAMP( r, 0, iChanMax ); | |||||
| rgba[i][GCOMP] = CLAMP( g, 0, iChanMax ); | |||||
| rgba[i][BCOMP] = CLAMP( b, 0, iChanMax ); | |||||
| rgba[i][ACOMP] = CLAMP( a, 0, iChanMax ); | |||||
| rgba[i][RCOMP] = CLAMP( r, 0, CHAN_MAX ); | |||||
| rgba[i][GCOMP] = CLAMP( g, 0, CHAN_MAX ); | |||||
| rgba[i][BCOMP] = CLAMP( b, 0, CHAN_MAX ); | |||||
| rgba[i][ACOMP] = CLAMP( a, 0, CHAN_MAX ); | |||||
| } | } | ||||
| if (colorMask != 0xffffffff) { | if (colorMask != 0xffffffff) { | ||||
| _mesa_mask_rgba_span( ctx, width, xpos, ypos, rgba ); | _mesa_mask_rgba_span( ctx, width, xpos, ypos, rgba ); |
| /* $Id: s_alphabuf.c,v 1.7 2001/05/11 18:58:32 brianp Exp $ */ | |||||
| /* $Id: s_alphabuf.c,v 1.8 2001/07/13 20:07:37 brianp Exp $ */ | |||||
| /* | /* | ||||
| * Mesa 3-D graphics library | * Mesa 3-D graphics library | ||||
| if (ctx->Scissor.Enabled) { | if (ctx->Scissor.Enabled) { | ||||
| /* clear scissor region */ | /* clear scissor region */ | ||||
| GLint j; | GLint j; | ||||
| GLint rowLen = ctx->DrawBuffer->_Xmax - ctx->DrawBuffer->_Xmin + 1; | |||||
| GLint rows = ctx->DrawBuffer->_Ymax - ctx->DrawBuffer->_Ymin + 1; | |||||
| GLint rowLen = ctx->DrawBuffer->_Xmax - ctx->DrawBuffer->_Xmin; | |||||
| GLint rows = ctx->DrawBuffer->_Ymax - ctx->DrawBuffer->_Ymin; | |||||
| GLint width = ctx->DrawBuffer->Width; | GLint width = ctx->DrawBuffer->Width; | ||||
| GLchan *aptr = buffer | GLchan *aptr = buffer | ||||
| + ctx->DrawBuffer->_Ymin * ctx->DrawBuffer->Width | + ctx->DrawBuffer->_Ymin * ctx->DrawBuffer->Width | ||||
| #elif CHAN_BITS == 16 | #elif CHAN_BITS == 16 | ||||
| MEMSET16( aptr, aclear, rowLen ); | MEMSET16( aptr, aclear, rowLen ); | ||||
| #else | #else | ||||
| #error unexpected CHAN_BITS value | |||||
| GLint i; | |||||
| for (i = 0; i < rowLen; i++) { | |||||
| aptr[i] = aclear; | |||||
| } | |||||
| #endif | #endif | ||||
| aptr += width; | aptr += width; | ||||
| } | } | ||||
| #elif CHAN_BITS == 16 | #elif CHAN_BITS == 16 | ||||
| MEMSET16(buffer, aclear, pixels); | MEMSET16(buffer, aclear, pixels); | ||||
| #else | #else | ||||
| #error unexpected CHAN_BITS value | |||||
| GLuint i; | |||||
| for (i = 0; i < pixels; i++) { | |||||
| buffer[i] = aclear; | |||||
| } | |||||
| #endif | #endif | ||||
| } | } | ||||
| } | } |
| /* $Id: s_blend.c,v 1.7 2001/03/19 02:25:36 keithw Exp $ */ | |||||
| /* $Id: s_blend.c,v 1.8 2001/07/13 20:07:37 brianp Exp $ */ | |||||
| /* | /* | ||||
| * Mesa 3-D graphics library | * Mesa 3-D graphics library | ||||
| for (i=0;i<n;i++) { | for (i=0;i<n;i++) { | ||||
| if (mask[i]) { | if (mask[i]) { | ||||
| #if CHAN_TYPE == GL_FLOAT | |||||
| rgba[i][RCOMP] = rgba[i][RCOMP] * dest[i][RCOMP]; | |||||
| rgba[i][GCOMP] = rgba[i][GCOMP] * dest[i][GCOMP]; | |||||
| rgba[i][BCOMP] = rgba[i][BCOMP] * dest[i][BCOMP]; | |||||
| rgba[i][ACOMP] = rgba[i][ACOMP] * dest[i][ACOMP]; | |||||
| #else | |||||
| GLint r = (rgba[i][RCOMP] * dest[i][RCOMP]) >> 8; | GLint r = (rgba[i][RCOMP] * dest[i][RCOMP]) >> 8; | ||||
| GLint g = (rgba[i][GCOMP] * dest[i][GCOMP]) >> 8; | GLint g = (rgba[i][GCOMP] * dest[i][GCOMP]) >> 8; | ||||
| GLint b = (rgba[i][BCOMP] * dest[i][BCOMP]) >> 8; | GLint b = (rgba[i][BCOMP] * dest[i][BCOMP]) >> 8; | ||||
| rgba[i][GCOMP] = (GLchan) g; | rgba[i][GCOMP] = (GLchan) g; | ||||
| rgba[i][BCOMP] = (GLchan) b; | rgba[i][BCOMP] = (GLchan) b; | ||||
| rgba[i][ACOMP] = (GLchan) a; | rgba[i][ACOMP] = (GLchan) a; | ||||
| #endif | |||||
| } | } | ||||
| } | } | ||||
| } | } |
| /* $Id: s_context.c,v 1.22 2001/07/12 22:09:21 keithw Exp $ */ | |||||
| /* $Id: s_context.c,v 1.23 2001/07/13 20:07:37 brianp Exp $ */ | |||||
| /* | /* | ||||
| * Mesa 3-D graphics library | * Mesa 3-D graphics library | ||||
| v->texcoord[i][0], v->texcoord[i][1], | v->texcoord[i][0], v->texcoord[i][1], | ||||
| v->texcoord[i][2], v->texcoord[i][3]); | v->texcoord[i][2], v->texcoord[i][3]); | ||||
| #if CHAN_TYPE == GL_FLOAT | |||||
| fprintf(stderr, "color %f %f %f %f\n", | |||||
| v->color[0], v->color[1], v->color[2], v->color[3]); | |||||
| fprintf(stderr, "spec %f %f %f %f\n", | |||||
| v->specular[0], v->specular[1], v->specular[2], v->specular[3]); | |||||
| #else | |||||
| fprintf(stderr, "color %d %d %d %d\n", | fprintf(stderr, "color %d %d %d %d\n", | ||||
| v->color[0], v->color[1], v->color[2], v->color[3]); | v->color[0], v->color[1], v->color[2], v->color[3]); | ||||
| fprintf(stderr, "spec %d %d %d %d\n", | fprintf(stderr, "spec %d %d %d %d\n", | ||||
| v->specular[0], v->specular[1], v->specular[2], v->specular[3]); | v->specular[0], v->specular[1], v->specular[2], v->specular[3]); | ||||
| #endif | |||||
| fprintf(stderr, "fog %f\n", v->fog); | fprintf(stderr, "fog %f\n", v->fog); | ||||
| fprintf(stderr, "index %d\n", v->index); | fprintf(stderr, "index %d\n", v->index); | ||||
| fprintf(stderr, "pointsize %f\n", v->pointSize); | fprintf(stderr, "pointsize %f\n", v->pointSize); |
| /* $Id: s_context.h,v 1.10 2001/05/17 09:32:17 keithw Exp $ */ | |||||
| /* $Id: s_context.h,v 1.11 2001/07/13 20:07:37 brianp Exp $ */ | |||||
| /* | /* | ||||
| * Mesa 3-D graphics library | * Mesa 3-D graphics library | ||||
| } SWcontext; | } SWcontext; | ||||
| void | |||||
| extern void | |||||
| _swrast_validate_derived( GLcontext *ctx ); | _swrast_validate_derived( GLcontext *ctx ); | ||||
| #define SWRAST_CONTEXT(ctx) ((SWcontext *)ctx->swrast_context) | #define SWRAST_CONTEXT(ctx) ((SWcontext *)ctx->swrast_context) | ||||
| #define RENDER_START(SWctx, GLctx) \ | #define RENDER_START(SWctx, GLctx) \ | ||||
| do { \ | |||||
| do { \ | |||||
| if ((SWctx)->Driver.SpanRenderStart) { \ | if ((SWctx)->Driver.SpanRenderStart) { \ | ||||
| (*(SWctx)->Driver.SpanRenderStart)(GLctx); \ | (*(SWctx)->Driver.SpanRenderStart)(GLctx); \ | ||||
| } \ | |||||
| } \ | |||||
| } while (0) | } while (0) | ||||
| #define RENDER_FINISH(SWctx, GLctx) \ | #define RENDER_FINISH(SWctx, GLctx) \ | ||||
| do { \ | |||||
| do { \ | |||||
| if ((SWctx)->Driver.SpanRenderFinish) { \ | if ((SWctx)->Driver.SpanRenderFinish) { \ | ||||
| (*(SWctx)->Driver.SpanRenderFinish)(GLctx); \ | (*(SWctx)->Driver.SpanRenderFinish)(GLctx); \ | ||||
| } \ | |||||
| } \ | |||||
| } while (0) | } while (0) | ||||
| /* | |||||
| * XXX these macros are just bandages for now in order to make | |||||
| * CHAN_BITS==32 compile cleanly. | |||||
| * These should probably go elsewhere at some point. | |||||
| */ | |||||
| #if CHAN_TYPE == GL_FLOAT | |||||
| #define ChanToFixed(X) FloatToFixed(X) | |||||
| #define FixedToChan(X) FixedToFloat(X) | |||||
| #else | |||||
| #define ChanToFixed(X) IntToFixed(X) | |||||
| #define FixedToChan(X) FixedToInt(X) | |||||
| #endif | |||||
| #endif | #endif |
| /* $Id: s_copypix.c,v 1.22 2001/07/13 15:24:34 brianp Exp $ */ | |||||
| /* $Id: s_copypix.c,v 1.23 2001/07/13 20:07:37 brianp Exp $ */ | |||||
| /* | /* | ||||
| * Mesa 3-D graphics library | * Mesa 3-D graphics library | ||||
| } | } | ||||
| else { | else { | ||||
| _mesa_write_rgba_span( ctx, width, destx, dy, zspan, fogSpan, | _mesa_write_rgba_span( ctx, width, destx, dy, zspan, fogSpan, | ||||
| rgba, NULL, GL_BITMAP); | |||||
| (GLchan (*)[4])rgba, NULL, GL_BITMAP); | |||||
| } | } | ||||
| } | } | ||||
| else { | else { |
| /* $Id: s_linetemp.h,v 1.8 2001/05/03 22:13:32 brianp Exp $ */ | |||||
| /* $Id: s_linetemp.h,v 1.9 2001/07/13 20:07:37 brianp Exp $ */ | |||||
| /* | /* | ||||
| * Mesa 3-D graphics library | * Mesa 3-D graphics library | ||||
| GLfloat dfog = vert1->fog - fog0; | GLfloat dfog = vert1->fog - fog0; | ||||
| #endif | #endif | ||||
| #ifdef INTERP_RGB | #ifdef INTERP_RGB | ||||
| GLfixed r0 = IntToFixed(vert0->color[0]); | |||||
| GLfixed dr = IntToFixed(vert1->color[0]) - r0; | |||||
| GLfixed g0 = IntToFixed(vert0->color[1]); | |||||
| GLfixed dg = IntToFixed(vert1->color[1]) - g0; | |||||
| GLfixed b0 = IntToFixed(vert0->color[2]); | |||||
| GLfixed db = IntToFixed(vert1->color[2]) - b0; | |||||
| GLfixed r0 = ChanToFixed(vert0->color[0]); | |||||
| GLfixed dr = ChanToFixed(vert1->color[0]) - r0; | |||||
| GLfixed g0 = ChanToFixed(vert0->color[1]); | |||||
| GLfixed dg = ChanToFixed(vert1->color[1]) - g0; | |||||
| GLfixed b0 = ChanToFixed(vert0->color[2]); | |||||
| GLfixed db = ChanToFixed(vert1->color[2]) - b0; | |||||
| #endif | #endif | ||||
| #ifdef INTERP_SPEC | #ifdef INTERP_SPEC | ||||
| GLfixed sr0 = IntToFixed(vert0->specular[0]); | |||||
| GLfixed dsr = IntToFixed(vert1->specular[0]) - sr0; | |||||
| GLfixed sg0 = IntToFixed(vert0->specular[1]); | |||||
| GLfixed dsg = IntToFixed(vert1->specular[1]) - sg0; | |||||
| GLfixed sb0 = IntToFixed(vert0->specular[2]); | |||||
| GLfixed dsb = IntToFixed(vert1->specular[2]) - sb0; | |||||
| GLfixed sr0 = ChanToFixed(vert0->specular[0]); | |||||
| GLfixed dsr = ChanToFixed(vert1->specular[0]) - sr0; | |||||
| GLfixed sg0 = ChanToFixed(vert0->specular[1]); | |||||
| GLfixed dsg = ChanToFixed(vert1->specular[1]) - sg0; | |||||
| GLfixed sb0 = ChanToFixed(vert0->specular[2]); | |||||
| GLfixed dsb = ChanToFixed(vert1->specular[2]) - sb0; | |||||
| #endif | #endif | ||||
| #ifdef INTERP_ALPHA | #ifdef INTERP_ALPHA | ||||
| GLfixed a0 = IntToFixed(vert0->color[3]); | |||||
| GLfixed da = IntToFixed(vert1->color[3]) - a0; | |||||
| GLfixed a0 = ChanToFixed(vert0->color[3]); | |||||
| GLfixed da = ChanToFixed(vert1->color[3]) - a0; | |||||
| #endif | #endif | ||||
| #ifdef INTERP_INDEX | #ifdef INTERP_INDEX | ||||
| GLint i0 = vert0->index << 8; | GLint i0 = vert0->index << 8; |
| /* $Id: s_logic.c,v 1.7 2001/05/10 16:54:12 brianp Exp $ */ | |||||
| /* $Id: s_logic.c,v 1.8 2001/07/13 20:07:37 brianp Exp $ */ | |||||
| /* | /* | ||||
| * Mesa 3-D graphics library | * Mesa 3-D graphics library | ||||
| */ | */ | ||||
| static void rgba_logicop_chan( const GLcontext *ctx, GLuint n, | static void rgba_logicop_chan( const GLcontext *ctx, GLuint n, | ||||
| const GLubyte mask[], | const GLubyte mask[], | ||||
| GLchan src[], const GLchan dest[] ) | |||||
| GLchan srcPtr[], const GLchan destPtr[] ) | |||||
| { | { | ||||
| #if CHAN_TYPE == GL_FLOAT | |||||
| GLuint *src = (GLuint *) srcPtr; | |||||
| const GLuint *dest = (const GLuint *) destPtr; | |||||
| GLuint i; | GLuint i; | ||||
| ASSERT(sizeof(GLfloat) == sizeof(GLuint)); | |||||
| #else | |||||
| GLchan *src = srcPtr; | |||||
| const GLchan *dest = destPtr; | |||||
| GLuint i; | |||||
| #endif | |||||
| switch (ctx->Color.LogicOp) { | switch (ctx->Color.LogicOp) { | ||||
| case GL_CLEAR: | case GL_CLEAR: | ||||
| for (i=0;i<n;i++) { | for (i=0;i<n;i++) { |
| /* $Id: s_texture.c,v 1.32 2001/06/01 13:23:27 brianp Exp $ */ | |||||
| /* $Id: s_texture.c,v 1.33 2001/07/13 20:07:37 brianp Exp $ */ | |||||
| /* | /* | ||||
| * Mesa 3-D graphics library | * Mesa 3-D graphics library | ||||
| GLuint i, j; | GLuint i, j; | ||||
| const GLuint RGBshift = textureUnit->CombineScaleShiftRGB; | const GLuint RGBshift = textureUnit->CombineScaleShiftRGB; | ||||
| const GLuint Ashift = textureUnit->CombineScaleShiftA; | const GLuint Ashift = textureUnit->CombineScaleShiftA; | ||||
| #if CHAN_TYPE == GL_FLOAT | |||||
| const GLchan RGBmult = (GLfloat) (1 << RGBshift); | |||||
| const GLchan Amult = (GLfloat) (1 << Ashift); | |||||
| #else | |||||
| const GLint half = (CHAN_MAX + 1) / 2; | |||||
| #endif | |||||
| DEFMNARRAY(GLchan, ccolor, 3, 3 * MAX_WIDTH, 4); /* mac 32k limitation */ | DEFMNARRAY(GLchan, ccolor, 3, 3 * MAX_WIDTH, 4); /* mac 32k limitation */ | ||||
| CHECKARRAY(ccolor, return); /* mac 32k limitation */ | CHECKARRAY(ccolor, return); /* mac 32k limitation */ | ||||
| const GLchan (*arg0)[4] = (const GLchan (*)[4]) argRGB[0]; | const GLchan (*arg0)[4] = (const GLchan (*)[4]) argRGB[0]; | ||||
| if (RGBshift) { | if (RGBshift) { | ||||
| for (i = 0; i < n; i++) { | for (i = 0; i < n; i++) { | ||||
| #if CHAN_TYPE == GL_FLOAT | |||||
| GLchan r = arg0[i][RCOMP] * RGBmult; | |||||
| GLchan g = arg0[i][GCOMP] * RGBmult; | |||||
| GLchan b = arg0[i][BCOMP] * RGBmult; | |||||
| #else | |||||
| GLuint r = (GLuint) arg0[i][RCOMP] << RGBshift; | GLuint r = (GLuint) arg0[i][RCOMP] << RGBshift; | ||||
| GLuint g = (GLuint) arg0[i][GCOMP] << RGBshift; | GLuint g = (GLuint) arg0[i][GCOMP] << RGBshift; | ||||
| GLuint b = (GLuint) arg0[i][BCOMP] << RGBshift; | GLuint b = (GLuint) arg0[i][BCOMP] << RGBshift; | ||||
| #endif | |||||
| rgba[i][RCOMP] = MIN2(r, CHAN_MAX); | rgba[i][RCOMP] = MIN2(r, CHAN_MAX); | ||||
| rgba[i][GCOMP] = MIN2(g, CHAN_MAX); | rgba[i][GCOMP] = MIN2(g, CHAN_MAX); | ||||
| rgba[i][BCOMP] = MIN2(b, CHAN_MAX); | rgba[i][BCOMP] = MIN2(b, CHAN_MAX); | ||||
| { | { | ||||
| const GLchan (*arg0)[4] = (const GLchan (*)[4]) argRGB[0]; | const GLchan (*arg0)[4] = (const GLchan (*)[4]) argRGB[0]; | ||||
| const GLchan (*arg1)[4] = (const GLchan (*)[4]) argRGB[1]; | const GLchan (*arg1)[4] = (const GLchan (*)[4]) argRGB[1]; | ||||
| #if CHAN_TYPE != GL_FLOAT | |||||
| const GLint shift = 8 - RGBshift; | const GLint shift = 8 - RGBshift; | ||||
| #endif | |||||
| for (i = 0; i < n; i++) { | for (i = 0; i < n; i++) { | ||||
| GLuint r = PROD(arg0[i][0], arg1[i][RCOMP]) >> shift; | |||||
| GLuint g = PROD(arg0[i][1], arg1[i][GCOMP]) >> shift; | |||||
| GLuint b = PROD(arg0[i][2], arg1[i][BCOMP]) >> shift; | |||||
| #if CHAN_TYPE == GL_FLOAT | |||||
| GLchan r = arg0[i][RCOMP] * arg1[i][RCOMP] * RGBmult; | |||||
| GLuint g = arg0[i][GCOMP] * arg1[i][GCOMP] * RGBmult; | |||||
| GLuint b = arg0[i][BCOMP] * arg1[i][BCOMP] * RGBmult; | |||||
| #else | |||||
| GLuint r = PROD(arg0[i][RCOMP], arg1[i][RCOMP]) >> shift; | |||||
| GLuint g = PROD(arg0[i][GCOMP], arg1[i][GCOMP]) >> shift; | |||||
| GLuint b = PROD(arg0[i][BCOMP], arg1[i][BCOMP]) >> shift; | |||||
| #endif | |||||
| rgba[i][RCOMP] = (GLchan) MIN2(r, CHAN_MAX); | rgba[i][RCOMP] = (GLchan) MIN2(r, CHAN_MAX); | ||||
| rgba[i][GCOMP] = (GLchan) MIN2(g, CHAN_MAX); | rgba[i][GCOMP] = (GLchan) MIN2(g, CHAN_MAX); | ||||
| rgba[i][BCOMP] = (GLchan) MIN2(b, CHAN_MAX); | rgba[i][BCOMP] = (GLchan) MIN2(b, CHAN_MAX); | ||||
| const GLchan (*arg0)[4] = (const GLchan (*)[4]) argRGB[0]; | const GLchan (*arg0)[4] = (const GLchan (*)[4]) argRGB[0]; | ||||
| const GLchan (*arg1)[4] = (const GLchan (*)[4]) argRGB[1]; | const GLchan (*arg1)[4] = (const GLchan (*)[4]) argRGB[1]; | ||||
| for (i = 0; i < n; i++) { | for (i = 0; i < n; i++) { | ||||
| #if CHAN_TYPE == GL_FLOAT | |||||
| GLchan r = (arg0[i][RCOMP] + arg1[i][RCOMP]) * RGBmult; | |||||
| GLchan g = (arg0[i][GCOMP] + arg1[i][GCOMP]) * RGBmult; | |||||
| GLchan b = (arg0[i][BCOMP] + arg1[i][BCOMP]) * RGBmult; | |||||
| #else | |||||
| GLint r = ((GLint) arg0[i][RCOMP] + (GLint) arg1[i][RCOMP]) << RGBshift; | GLint r = ((GLint) arg0[i][RCOMP] + (GLint) arg1[i][RCOMP]) << RGBshift; | ||||
| GLint g = ((GLint) arg0[i][GCOMP] + (GLint) arg1[i][GCOMP]) << RGBshift; | GLint g = ((GLint) arg0[i][GCOMP] + (GLint) arg1[i][GCOMP]) << RGBshift; | ||||
| GLint b = ((GLint) arg0[i][BCOMP] + (GLint) arg1[i][BCOMP]) << RGBshift; | GLint b = ((GLint) arg0[i][BCOMP] + (GLint) arg1[i][BCOMP]) << RGBshift; | ||||
| #endif | |||||
| rgba[i][RCOMP] = (GLchan) MIN2(r, CHAN_MAX); | rgba[i][RCOMP] = (GLchan) MIN2(r, CHAN_MAX); | ||||
| rgba[i][GCOMP] = (GLchan) MIN2(g, CHAN_MAX); | rgba[i][GCOMP] = (GLchan) MIN2(g, CHAN_MAX); | ||||
| rgba[i][BCOMP] = (GLchan) MIN2(b, CHAN_MAX); | rgba[i][BCOMP] = (GLchan) MIN2(b, CHAN_MAX); | ||||
| const GLchan (*arg0)[4] = (const GLchan (*)[4]) argRGB[0]; | const GLchan (*arg0)[4] = (const GLchan (*)[4]) argRGB[0]; | ||||
| const GLchan (*arg1)[4] = (const GLchan (*)[4]) argRGB[1]; | const GLchan (*arg1)[4] = (const GLchan (*)[4]) argRGB[1]; | ||||
| for (i = 0; i < n; i++) { | for (i = 0; i < n; i++) { | ||||
| GLint r = (GLint) arg0[i][RCOMP] + (GLint) arg1[i][RCOMP] - 128; | |||||
| GLint g = (GLint) arg0[i][GCOMP] + (GLint) arg1[i][GCOMP] - 128; | |||||
| GLint b = (GLint) arg0[i][BCOMP] + (GLint) arg1[i][BCOMP] - 128; | |||||
| #if CHAN_TYPE == GL_FLOAT | |||||
| GLchan r = (arg0[i][RCOMP] + arg1[i][RCOMP] - 0.5) * RGBmult; | |||||
| GLchan g = (arg0[i][GCOMP] + arg1[i][GCOMP] - 0.5) * RGBmult; | |||||
| GLchan b = (arg0[i][BCOMP] + arg1[i][BCOMP] - 0.5) * RGBmult; | |||||
| #else | |||||
| GLint r = (GLint) arg0[i][RCOMP] + (GLint) arg1[i][RCOMP] -half; | |||||
| GLint g = (GLint) arg0[i][GCOMP] + (GLint) arg1[i][GCOMP] -half; | |||||
| GLint b = (GLint) arg0[i][BCOMP] + (GLint) arg1[i][BCOMP] -half; | |||||
| r = (r < 0) ? 0 : r << RGBshift; | r = (r < 0) ? 0 : r << RGBshift; | ||||
| g = (g < 0) ? 0 : g << RGBshift; | g = (g < 0) ? 0 : g << RGBshift; | ||||
| b = (b < 0) ? 0 : b << RGBshift; | b = (b < 0) ? 0 : b << RGBshift; | ||||
| #endif | |||||
| rgba[i][RCOMP] = (GLchan) MIN2(r, CHAN_MAX); | rgba[i][RCOMP] = (GLchan) MIN2(r, CHAN_MAX); | ||||
| rgba[i][GCOMP] = (GLchan) MIN2(g, CHAN_MAX); | rgba[i][GCOMP] = (GLchan) MIN2(g, CHAN_MAX); | ||||
| rgba[i][BCOMP] = (GLchan) MIN2(b, CHAN_MAX); | rgba[i][BCOMP] = (GLchan) MIN2(b, CHAN_MAX); | ||||
| const GLchan (*arg0)[4] = (const GLchan (*)[4]) argRGB[0]; | const GLchan (*arg0)[4] = (const GLchan (*)[4]) argRGB[0]; | ||||
| const GLchan (*arg1)[4] = (const GLchan (*)[4]) argRGB[1]; | const GLchan (*arg1)[4] = (const GLchan (*)[4]) argRGB[1]; | ||||
| const GLchan (*arg2)[4] = (const GLchan (*)[4]) argRGB[2]; | const GLchan (*arg2)[4] = (const GLchan (*)[4]) argRGB[2]; | ||||
| #if CHAN_TYPE != GL_FLOAT | |||||
| const GLint shift = 8 - RGBshift; | const GLint shift = 8 - RGBshift; | ||||
| #endif | |||||
| for (i = 0; i < n; i++) { | for (i = 0; i < n; i++) { | ||||
| #if CHAN_TYPE == GL_FLOAT | |||||
| GLchan r = (arg0[i][RCOMP] * arg2[i][RCOMP] + | |||||
| arg1[i][RCOMP] * (CHAN_MAXF - arg2[i][RCOMP])) * RGBmult; | |||||
| GLchan g = (arg0[i][GCOMP] * arg2[i][GCOMP] + | |||||
| arg1[i][GCOMP] * (CHAN_MAXF - arg2[i][GCOMP])) * RGBmult; | |||||
| GLchan b = (arg0[i][BCOMP] * arg2[i][BCOMP] + | |||||
| arg1[i][BCOMP] * (CHAN_MAXF - arg2[i][BCOMP])) * RGBmult; | |||||
| #else | |||||
| GLuint r = (PROD(arg0[i][RCOMP], arg2[i][RCOMP]) | GLuint r = (PROD(arg0[i][RCOMP], arg2[i][RCOMP]) | ||||
| + PROD(arg1[i][RCOMP], CHAN_MAX - arg2[i][RCOMP])) | + PROD(arg1[i][RCOMP], CHAN_MAX - arg2[i][RCOMP])) | ||||
| >> shift; | >> shift; | ||||
| GLuint b = (PROD(arg0[i][BCOMP], arg2[i][BCOMP]) | GLuint b = (PROD(arg0[i][BCOMP], arg2[i][BCOMP]) | ||||
| + PROD(arg1[i][BCOMP], CHAN_MAX - arg2[i][BCOMP])) | + PROD(arg1[i][BCOMP], CHAN_MAX - arg2[i][BCOMP])) | ||||
| >> shift; | >> shift; | ||||
| #endif | |||||
| rgba[i][RCOMP] = (GLchan) MIN2(r, CHAN_MAX); | rgba[i][RCOMP] = (GLchan) MIN2(r, CHAN_MAX); | ||||
| rgba[i][GCOMP] = (GLchan) MIN2(g, CHAN_MAX); | rgba[i][GCOMP] = (GLchan) MIN2(g, CHAN_MAX); | ||||
| rgba[i][BCOMP] = (GLchan) MIN2(b, CHAN_MAX); | rgba[i][BCOMP] = (GLchan) MIN2(b, CHAN_MAX); | ||||
| const GLchan (*arg0)[4] = (const GLchan (*)[4]) argRGB[0]; | const GLchan (*arg0)[4] = (const GLchan (*)[4]) argRGB[0]; | ||||
| const GLchan (*arg1)[4] = (const GLchan (*)[4]) argRGB[1]; | const GLchan (*arg1)[4] = (const GLchan (*)[4]) argRGB[1]; | ||||
| for (i = 0; i < n; i++) { | for (i = 0; i < n; i++) { | ||||
| #if CHAN_TYPE == GL_FLOAT | |||||
| GLchan r = (arg0[i][RCOMP] - arg1[i][RCOMP]) * RGBmult; | |||||
| GLchan g = (arg0[i][GCOMP] - arg1[i][GCOMP]) * RGBmult; | |||||
| GLchan b = (arg0[i][BCOMP] - arg1[i][BCOMP]) * RGBmult; | |||||
| #else | |||||
| GLint r = ((GLint) arg0[i][RCOMP] - (GLint) arg1[i][RCOMP]) << RGBshift; | GLint r = ((GLint) arg0[i][RCOMP] - (GLint) arg1[i][RCOMP]) << RGBshift; | ||||
| GLint g = ((GLint) arg0[i][GCOMP] - (GLint) arg1[i][GCOMP]) << RGBshift; | GLint g = ((GLint) arg0[i][GCOMP] - (GLint) arg1[i][GCOMP]) << RGBshift; | ||||
| GLint b = ((GLint) arg0[i][BCOMP] - (GLint) arg1[i][BCOMP]) << RGBshift; | GLint b = ((GLint) arg0[i][BCOMP] - (GLint) arg1[i][BCOMP]) << RGBshift; | ||||
| #endif | |||||
| rgba[i][RCOMP] = (GLchan) CLAMP(r, 0, CHAN_MAX); | rgba[i][RCOMP] = (GLchan) CLAMP(r, 0, CHAN_MAX); | ||||
| rgba[i][GCOMP] = (GLchan) CLAMP(g, 0, CHAN_MAX); | rgba[i][GCOMP] = (GLchan) CLAMP(g, 0, CHAN_MAX); | ||||
| rgba[i][BCOMP] = (GLchan) CLAMP(b, 0, CHAN_MAX); | rgba[i][BCOMP] = (GLchan) CLAMP(b, 0, CHAN_MAX); | ||||
| * drop the EXT extension in favour of the ARB one. | * drop the EXT extension in favour of the ARB one. | ||||
| */ | */ | ||||
| for (i = 0; i < n; i++) { | for (i = 0; i < n; i++) { | ||||
| GLint dot = (S_PROD((GLint)arg0[i][RCOMP] - 128, | |||||
| (GLint)arg1[i][RCOMP] - 128) + | |||||
| S_PROD((GLint)arg0[i][GCOMP] - 128, | |||||
| (GLint)arg1[i][GCOMP] - 128) + | |||||
| S_PROD((GLint)arg0[i][BCOMP] - 128, | |||||
| (GLint)arg1[i][BCOMP] - 128)) >> 6; | |||||
| dot = CLAMP(dot, 0, 255); | |||||
| #if CHAN_TYPE == GL_FLOAT | |||||
| GLchan dot = ((arg0[i][RCOMP]-0.5F) * (arg1[i][RCOMP]-0.5F) + | |||||
| (arg0[i][GCOMP]-0.5F) * (arg1[i][GCOMP]-0.5F) + | |||||
| (arg0[i][BCOMP]-0.5F) * (arg1[i][BCOMP]-0.5F)) | |||||
| * 4.0F; | |||||
| #else | |||||
| GLint dot = (S_PROD((GLint)arg0[i][RCOMP] - half, | |||||
| (GLint)arg1[i][RCOMP] - half) + | |||||
| S_PROD((GLint)arg0[i][GCOMP] - half, | |||||
| (GLint)arg1[i][GCOMP] - half) + | |||||
| S_PROD((GLint)arg0[i][BCOMP] - half, | |||||
| (GLint)arg1[i][BCOMP] - half)) >> 6; | |||||
| #endif | |||||
| dot = CLAMP(dot, 0, CHAN_MAX); | |||||
| rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = (GLchan) dot; | rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = (GLchan) dot; | ||||
| } | } | ||||
| } | } | ||||
| const GLchan (*arg0)[4] = (const GLchan (*)[4]) argA[0]; | const GLchan (*arg0)[4] = (const GLchan (*)[4]) argA[0]; | ||||
| if (Ashift) { | if (Ashift) { | ||||
| for (i = 0; i < n; i++) { | for (i = 0; i < n; i++) { | ||||
| #if CHAN_TYPE == GL_FLOAT | |||||
| GLchan a = arg0[i][ACOMP] * Amult; | |||||
| #else | |||||
| GLuint a = (GLuint) arg0[i][ACOMP] << Ashift; | GLuint a = (GLuint) arg0[i][ACOMP] << Ashift; | ||||
| #endif | |||||
| rgba[i][ACOMP] = (GLchan) MIN2(a, CHAN_MAX); | rgba[i][ACOMP] = (GLchan) MIN2(a, CHAN_MAX); | ||||
| } | } | ||||
| } | } | ||||
| { | { | ||||
| const GLchan (*arg0)[4] = (const GLchan (*)[4]) argA[0]; | const GLchan (*arg0)[4] = (const GLchan (*)[4]) argA[0]; | ||||
| const GLchan (*arg1)[4] = (const GLchan (*)[4]) argA[1]; | const GLchan (*arg1)[4] = (const GLchan (*)[4]) argA[1]; | ||||
| #if CHAN_TYPE != GL_FLOAT | |||||
| const GLint shift = 8 - Ashift; | const GLint shift = 8 - Ashift; | ||||
| #endif | |||||
| for (i = 0; i < n; i++) { | for (i = 0; i < n; i++) { | ||||
| #if CHAN_TYPE == GL_FLOAT | |||||
| GLchan a = arg0[i][ACOMP] * arg1[i][ACOMP] * Amult; | |||||
| #else | |||||
| GLuint a = (PROD(arg0[i][ACOMP], arg1[i][ACOMP]) >> shift); | GLuint a = (PROD(arg0[i][ACOMP], arg1[i][ACOMP]) >> shift); | ||||
| #endif | |||||
| rgba[i][ACOMP] = (GLchan) MIN2(a, CHAN_MAX); | rgba[i][ACOMP] = (GLchan) MIN2(a, CHAN_MAX); | ||||
| } | } | ||||
| } | } | ||||
| const GLchan (*arg0)[4] = (const GLchan (*)[4]) argA[0]; | const GLchan (*arg0)[4] = (const GLchan (*)[4]) argA[0]; | ||||
| const GLchan (*arg1)[4] = (const GLchan (*)[4]) argA[1]; | const GLchan (*arg1)[4] = (const GLchan (*)[4]) argA[1]; | ||||
| for (i = 0; i < n; i++) { | for (i = 0; i < n; i++) { | ||||
| #if CHAN_TYPE == GL_FLOAT | |||||
| GLchan a = (arg0[i][ACOMP] + arg1[i][ACOMP]) * Amult; | |||||
| rgba[i][ACOMP] = (GLchan) MIN2(a, CHAN_MAXF); | |||||
| #else | |||||
| GLint a = ((GLint) arg0[i][ACOMP] + arg1[i][ACOMP]) << Ashift; | GLint a = ((GLint) arg0[i][ACOMP] + arg1[i][ACOMP]) << Ashift; | ||||
| rgba[i][ACOMP] = (GLchan) MIN2(a, CHAN_MAX); | rgba[i][ACOMP] = (GLchan) MIN2(a, CHAN_MAX); | ||||
| #endif | |||||
| } | } | ||||
| } | } | ||||
| break; | break; | ||||
| const GLchan (*arg0)[4] = (const GLchan (*)[4]) argA[0]; | const GLchan (*arg0)[4] = (const GLchan (*)[4]) argA[0]; | ||||
| const GLchan (*arg1)[4] = (const GLchan (*)[4]) argA[1]; | const GLchan (*arg1)[4] = (const GLchan (*)[4]) argA[1]; | ||||
| for (i = 0; i < n; i++) { | for (i = 0; i < n; i++) { | ||||
| GLint a = (GLint) arg0[i][ACOMP] + (GLint) arg1[i][ACOMP] - 128; | |||||
| #if CHAN_TYPE == GL_FLOAT | |||||
| GLchan a = (arg0[i][ACOMP] + arg1[i][ACOMP] - 0.5F) * Amult; | |||||
| #else | |||||
| GLint a = (GLint) arg0[i][ACOMP] + (GLint) arg1[i][ACOMP] -half; | |||||
| a = (a < 0) ? 0 : a << Ashift; | a = (a < 0) ? 0 : a << Ashift; | ||||
| #endif | |||||
| rgba[i][ACOMP] = (GLchan) MIN2(a, CHAN_MAX); | rgba[i][ACOMP] = (GLchan) MIN2(a, CHAN_MAX); | ||||
| } | } | ||||
| } | } | ||||
| const GLchan (*arg0)[4] = (const GLchan (*)[4]) argA[0]; | const GLchan (*arg0)[4] = (const GLchan (*)[4]) argA[0]; | ||||
| const GLchan (*arg1)[4] = (const GLchan (*)[4]) argA[1]; | const GLchan (*arg1)[4] = (const GLchan (*)[4]) argA[1]; | ||||
| const GLchan (*arg2)[4] = (const GLchan (*)[4]) argA[2]; | const GLchan (*arg2)[4] = (const GLchan (*)[4]) argA[2]; | ||||
| #if CHAN_TYPE != GL_FLOAT | |||||
| const GLint shift = 8 - Ashift; | const GLint shift = 8 - Ashift; | ||||
| #endif | |||||
| for (i=0; i<n; i++) { | for (i=0; i<n; i++) { | ||||
| #if CHAN_TYPE == GL_FLOAT | |||||
| GLchan a = (arg0[i][ACOMP] * arg2[i][ACOMP] + | |||||
| arg1[i][ACOMP] * (CHAN_MAXF - arg2[i][ACOMP])) | |||||
| * Amult; | |||||
| #else | |||||
| GLuint a = (PROD(arg0[i][ACOMP], arg2[i][ACOMP]) | GLuint a = (PROD(arg0[i][ACOMP], arg2[i][ACOMP]) | ||||
| + PROD(arg1[i][ACOMP], CHAN_MAX - arg2[i][ACOMP])) | + PROD(arg1[i][ACOMP], CHAN_MAX - arg2[i][ACOMP])) | ||||
| >> shift; | >> shift; | ||||
| #endif | |||||
| rgba[i][ACOMP] = (GLchan) MIN2(a, CHAN_MAX); | rgba[i][ACOMP] = (GLchan) MIN2(a, CHAN_MAX); | ||||
| } | } | ||||
| } | } | ||||
| const GLchan (*arg0)[4] = (const GLchan (*)[4]) argRGB[0]; | const GLchan (*arg0)[4] = (const GLchan (*)[4]) argRGB[0]; | ||||
| const GLchan (*arg1)[4] = (const GLchan (*)[4]) argRGB[1]; | const GLchan (*arg1)[4] = (const GLchan (*)[4]) argRGB[1]; | ||||
| for (i = 0; i < n; i++) { | for (i = 0; i < n; i++) { | ||||
| #if CHAN_TYPE == GL_FLOAT | |||||
| GLchan a = (arg0[i][ACOMP] - arg1[i][ACOMP]) * Amult; | |||||
| #else | |||||
| GLint a = ((GLint) arg0[i][ACOMP] - (GLint) arg1[i][ACOMP]) << RGBshift; | GLint a = ((GLint) arg0[i][ACOMP] - (GLint) arg1[i][ACOMP]) << RGBshift; | ||||
| #endif | |||||
| rgba[i][ACOMP] = (GLchan) CLAMP(a, 0, CHAN_MAX); | rgba[i][ACOMP] = (GLchan) CLAMP(a, 0, CHAN_MAX); | ||||
| } | } | ||||
| } | } |
| /* $Id: s_triangle.c,v 1.32 2001/07/09 16:24:30 brianp Exp $ */ | |||||
| /* $Id: s_triangle.c,v 1.33 2001/07/13 20:07:37 brianp Exp $ */ | |||||
| /* | /* | ||||
| * Mesa 3-D graphics library | * Mesa 3-D graphics library | ||||
| } | } | ||||
| #if CHAN_TYPE != GL_FLOAT | |||||
| struct affine_info | struct affine_info | ||||
| { | { | ||||
| } | } | ||||
| #endif /* CHAN_BITS != GL_FLOAT */ | |||||
| struct persp_info | struct persp_info | ||||
| { | { | ||||
| GLint fixedToDepthShift; | GLint fixedToDepthShift; | ||||
| }; | }; | ||||
| static void | static void | ||||
| fast_persp_span(GLcontext *ctx, struct triangle_span *span, | fast_persp_span(GLcontext *ctx, struct triangle_span *span, | ||||
| struct persp_info *info) | struct persp_info *info) | ||||
| * and complexity. Observe that an optimizing compiler kills | * and complexity. Observe that an optimizing compiler kills | ||||
| * unused variables (for instance tf,sf,ti,si in case of GL_NEAREST). | * unused variables (for instance tf,sf,ti,si in case of GL_NEAREST). | ||||
| */ | */ | ||||
| #define SPAN_NEAREST(DO_TEX,COMP) \ | #define SPAN_NEAREST(DO_TEX,COMP) \ | ||||
| for (i = 0; i < span->count; i++) { \ | for (i = 0; i < span->count; i++) { \ | ||||
| GLdouble invQ = tex_coord[2] ? \ | GLdouble invQ = tex_coord[2] ? \ | ||||
| CHECKARRAY(tSpan, return); /* mac 32k limitation */ \ | CHECKARRAY(tSpan, return); /* mac 32k limitation */ \ | ||||
| CHECKARRAY(uSpan, return); /* mac 32k limitation */ \ | CHECKARRAY(uSpan, return); /* mac 32k limitation */ \ | ||||
| if (flatShade) { \ | if (flatShade) { \ | ||||
| rFlat = IntToFixed(v2->color[RCOMP]); \ | |||||
| gFlat = IntToFixed(v2->color[GCOMP]); \ | |||||
| bFlat = IntToFixed(v2->color[BCOMP]); \ | |||||
| aFlat = IntToFixed(v2->color[ACOMP]); \ | |||||
| rFlat = ChanToFixed(v2->color[RCOMP]); \ | |||||
| gFlat = ChanToFixed(v2->color[GCOMP]); \ | |||||
| bFlat = ChanToFixed(v2->color[BCOMP]); \ | |||||
| aFlat = ChanToFixed(v2->color[ACOMP]); \ | |||||
| } \ | } \ | ||||
| span.texWidth[0] = (GLfloat) texImage->Width; \ | span.texWidth[0] = (GLfloat) texImage->Width; \ | ||||
| span.texHeight[0] = (GLfloat) texImage->Height; \ | span.texHeight[0] = (GLfloat) texImage->Height; \ | ||||
| GLfixed rFlat, gFlat, bFlat, aFlat; \ | GLfixed rFlat, gFlat, bFlat, aFlat; \ | ||||
| GLfixed srFlat, sgFlat, sbFlat; \ | GLfixed srFlat, sgFlat, sbFlat; \ | ||||
| if (flatShade) { \ | if (flatShade) { \ | ||||
| rFlat = IntToFixed(v2->color[RCOMP]); \ | |||||
| gFlat = IntToFixed(v2->color[GCOMP]); \ | |||||
| bFlat = IntToFixed(v2->color[BCOMP]); \ | |||||
| aFlat = IntToFixed(v2->color[ACOMP]); \ | |||||
| srFlat = IntToFixed(v2->specular[RCOMP]); \ | |||||
| sgFlat = IntToFixed(v2->specular[GCOMP]); \ | |||||
| sbFlat = IntToFixed(v2->specular[BCOMP]); \ | |||||
| rFlat = ChanToFixed(v2->color[RCOMP]); \ | |||||
| gFlat = ChanToFixed(v2->color[GCOMP]); \ | |||||
| bFlat = ChanToFixed(v2->color[BCOMP]); \ | |||||
| aFlat = ChanToFixed(v2->color[ACOMP]); \ | |||||
| srFlat = ChanToFixed(v2->specular[RCOMP]); \ | |||||
| sgFlat = ChanToFixed(v2->specular[GCOMP]); \ | |||||
| sbFlat = ChanToFixed(v2->specular[BCOMP]); \ | |||||
| } \ | } \ | ||||
| span.texWidth[0] = (GLfloat) texImage->Width; \ | span.texWidth[0] = (GLfloat) texImage->Width; \ | ||||
| span.texHeight[0] = (GLfloat) texImage->Height; \ | span.texHeight[0] = (GLfloat) texImage->Height; \ | ||||
| GLfixed rFlat, gFlat, bFlat, aFlat; \ | GLfixed rFlat, gFlat, bFlat, aFlat; \ | ||||
| GLfixed srFlat, sgFlat, sbFlat; \ | GLfixed srFlat, sgFlat, sbFlat; \ | ||||
| if (flatShade) { \ | if (flatShade) { \ | ||||
| rFlat = IntToFixed(v2->color[RCOMP]); \ | |||||
| gFlat = IntToFixed(v2->color[GCOMP]); \ | |||||
| bFlat = IntToFixed(v2->color[BCOMP]); \ | |||||
| aFlat = IntToFixed(v2->color[ACOMP]); \ | |||||
| srFlat = IntToFixed(v2->specular[RCOMP]); \ | |||||
| sgFlat = IntToFixed(v2->specular[GCOMP]); \ | |||||
| sbFlat = IntToFixed(v2->specular[BCOMP]); \ | |||||
| rFlat = ChanToFixed(v2->color[RCOMP]); \ | |||||
| gFlat = ChanToFixed(v2->color[GCOMP]); \ | |||||
| bFlat = ChanToFixed(v2->color[BCOMP]); \ | |||||
| aFlat = ChanToFixed(v2->color[ACOMP]); \ | |||||
| srFlat = ChanToFixed(v2->specular[RCOMP]); \ | |||||
| sgFlat = ChanToFixed(v2->specular[GCOMP]); \ | |||||
| sbFlat = ChanToFixed(v2->specular[BCOMP]); \ | |||||
| } \ | } \ | ||||
| span.texWidth[0] = (GLfloat) texImage->Width; \ | span.texWidth[0] = (GLfloat) texImage->Width; \ | ||||
| span.texHeight[0] = (GLfloat) texImage->Height; \ | span.texHeight[0] = (GLfloat) texImage->Height; \ | ||||
| GLfixed rFlat, gFlat, bFlat, aFlat; \ | GLfixed rFlat, gFlat, bFlat, aFlat; \ | ||||
| GLfixed srFlat, sgFlat, sbFlat; \ | GLfixed srFlat, sgFlat, sbFlat; \ | ||||
| if (flatShade) { \ | if (flatShade) { \ | ||||
| rFlat = IntToFixed(v2->color[RCOMP]); \ | |||||
| gFlat = IntToFixed(v2->color[GCOMP]); \ | |||||
| bFlat = IntToFixed(v2->color[BCOMP]); \ | |||||
| aFlat = IntToFixed(v2->color[ACOMP]); \ | |||||
| srFlat = IntToFixed(v2->specular[RCOMP]); \ | |||||
| sgFlat = IntToFixed(v2->specular[GCOMP]); \ | |||||
| sbFlat = IntToFixed(v2->specular[BCOMP]); \ | |||||
| rFlat = ChanToFixed(v2->color[RCOMP]); \ | |||||
| gFlat = ChanToFixed(v2->color[GCOMP]); \ | |||||
| bFlat = ChanToFixed(v2->color[BCOMP]); \ | |||||
| aFlat = ChanToFixed(v2->color[ACOMP]); \ | |||||
| srFlat = ChanToFixed(v2->specular[RCOMP]); \ | |||||
| sgFlat = ChanToFixed(v2->specular[GCOMP]); \ | |||||
| sbFlat = ChanToFixed(v2->specular[BCOMP]); \ | |||||
| } \ | } \ | ||||
| span.texWidth[0] = (GLfloat) texImage->Width; \ | span.texWidth[0] = (GLfloat) texImage->Width; \ | ||||
| span.texHeight[0] = (GLfloat) texImage->Height; \ | span.texHeight[0] = (GLfloat) texImage->Height; \ | ||||
| GLfixed srFlat, sgFlat, sbFlat; \ | GLfixed srFlat, sgFlat, sbFlat; \ | ||||
| GLuint u; \ | GLuint u; \ | ||||
| if (flatShade) { \ | if (flatShade) { \ | ||||
| rFlat = IntToFixed(v2->color[RCOMP]); \ | |||||
| gFlat = IntToFixed(v2->color[GCOMP]); \ | |||||
| bFlat = IntToFixed(v2->color[BCOMP]); \ | |||||
| aFlat = IntToFixed(v2->color[ACOMP]); \ | |||||
| srFlat = IntToFixed(v2->specular[RCOMP]); \ | |||||
| sgFlat = IntToFixed(v2->specular[GCOMP]); \ | |||||
| sbFlat = IntToFixed(v2->specular[BCOMP]); \ | |||||
| rFlat = ChanToFixed(v2->color[RCOMP]); \ | |||||
| gFlat = ChanToFixed(v2->color[GCOMP]); \ | |||||
| bFlat = ChanToFixed(v2->color[BCOMP]); \ | |||||
| aFlat = ChanToFixed(v2->color[ACOMP]); \ | |||||
| srFlat = ChanToFixed(v2->specular[RCOMP]); \ | |||||
| sgFlat = ChanToFixed(v2->specular[GCOMP]); \ | |||||
| sbFlat = ChanToFixed(v2->specular[BCOMP]); \ | |||||
| } \ | } \ | ||||
| for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { \ | for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { \ | ||||
| if (ctx->Texture.Unit[u]._ReallyEnabled) { \ | if (ctx->Texture.Unit[u]._ReallyEnabled) { \ | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| /* GL_MODULATE seems also not to work !! */ | |||||
| if (ctx->Texture.Unit[0].EnvMode==GL_ADD) { | |||||
| USE(general_textured_triangle); | |||||
| } | |||||
| else { | |||||
| #if CHAN_TYPE != GL_FLOAT | |||||
| if (ctx->Texture.Unit[0].EnvMode != GL_ADD) { | |||||
| USE(affine_textured_triangle); | USE(affine_textured_triangle); | ||||
| } | } | ||||
| else | |||||
| #endif | |||||
| { | |||||
| USE(general_textured_triangle); | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| /* GL_MODULATE seems also not to work !! */ | |||||
| if (ctx->Texture.Unit[0].EnvMode==GL_ADD) { | if (ctx->Texture.Unit[0].EnvMode==GL_ADD) { | ||||
| USE(general_textured_triangle); | USE(general_textured_triangle); | ||||
| } | } |
| /* $Id: s_tritemp.h,v 1.19 2001/06/13 14:53:52 brianp Exp $ */ | |||||
| /* $Id: s_tritemp.h,v 1.20 2001/07/13 20:07:37 brianp Exp $ */ | |||||
| /* | /* | ||||
| * Mesa 3-D graphics library | * Mesa 3-D graphics library | ||||
| dfogOuter = dfogdy + dxOuter * span.fogStep; | dfogOuter = dfogdy + dxOuter * span.fogStep; | ||||
| #endif | #endif | ||||
| #ifdef INTERP_RGB | #ifdef INTERP_RGB | ||||
| fr = (GLfixed)(IntToFixed(vLower->color[0]) | |||||
| fr = (GLfixed)(ChanToFixed(vLower->color[0]) | |||||
| + drdx * adjx + drdy * adjy) + FIXED_HALF; | + drdx * adjx + drdy * adjy) + FIXED_HALF; | ||||
| fdrOuter = SignedFloatToFixed(drdy + dxOuter * drdx); | fdrOuter = SignedFloatToFixed(drdy + dxOuter * drdx); | ||||
| fg = (GLfixed)(IntToFixed(vLower->color[1]) | |||||
| fg = (GLfixed)(ChanToFixed(vLower->color[1]) | |||||
| + dgdx * adjx + dgdy * adjy) + FIXED_HALF; | + dgdx * adjx + dgdy * adjy) + FIXED_HALF; | ||||
| fdgOuter = SignedFloatToFixed(dgdy + dxOuter * dgdx); | fdgOuter = SignedFloatToFixed(dgdy + dxOuter * dgdx); | ||||
| fb = (GLfixed)(IntToFixed(vLower->color[2]) | |||||
| fb = (GLfixed)(ChanToFixed(vLower->color[2]) | |||||
| + dbdx * adjx + dbdy * adjy) + FIXED_HALF; | + dbdx * adjx + dbdy * adjy) + FIXED_HALF; | ||||
| fdbOuter = SignedFloatToFixed(dbdy + dxOuter * dbdx); | fdbOuter = SignedFloatToFixed(dbdy + dxOuter * dbdx); | ||||
| #endif | #endif | ||||
| #ifdef INTERP_ALPHA | #ifdef INTERP_ALPHA | ||||
| fa = (GLfixed)(IntToFixed(vLower->color[3]) | |||||
| fa = (GLfixed)(ChanToFixed(vLower->color[3]) | |||||
| + dadx * adjx + dady * adjy) + FIXED_HALF; | + dadx * adjx + dady * adjy) + FIXED_HALF; | ||||
| fdaOuter = SignedFloatToFixed(dady + dxOuter * dadx); | fdaOuter = SignedFloatToFixed(dady + dxOuter * dadx); | ||||
| #endif | #endif | ||||
| #ifdef INTERP_SPEC | #ifdef INTERP_SPEC | ||||
| fsr = (GLfixed)(IntToFixed(vLower->specular[0]) | |||||
| fsr = (GLfixed)(ChanToFixed(vLower->specular[0]) | |||||
| + dsrdx * adjx + dsrdy * adjy) + FIXED_HALF; | + dsrdx * adjx + dsrdy * adjy) + FIXED_HALF; | ||||
| fdsrOuter = SignedFloatToFixed(dsrdy + dxOuter * dsrdx); | fdsrOuter = SignedFloatToFixed(dsrdy + dxOuter * dsrdx); | ||||
| fsg = (GLfixed)(IntToFixed(vLower->specular[1]) | |||||
| fsg = (GLfixed)(ChanToFixed(vLower->specular[1]) | |||||
| + dsgdx * adjx + dsgdy * adjy) + FIXED_HALF; | + dsgdx * adjx + dsgdy * adjy) + FIXED_HALF; | ||||
| fdsgOuter = SignedFloatToFixed(dsgdy + dxOuter * dsgdx); | fdsgOuter = SignedFloatToFixed(dsgdy + dxOuter * dsgdx); | ||||
| fsb = (GLfixed)(IntToFixed(vLower->specular[2]) | |||||
| fsb = (GLfixed)(ChanToFixed(vLower->specular[2]) | |||||
| + dsbdx * adjx + dsbdy * adjy) + FIXED_HALF; | + dsbdx * adjx + dsbdy * adjy) + FIXED_HALF; | ||||
| fdsbOuter = SignedFloatToFixed(dsbdy + dxOuter * dsbdx); | fdsbOuter = SignedFloatToFixed(dsbdy + dxOuter * dsbdx); | ||||
| #endif | #endif |