-static void
-antialiased_rgba_point( GLcontext *ctx, SWvertex *vert )
-{
- struct pixel_buffer *PB = SWRAST_CONTEXT(ctx)->PB;
- const GLfloat radius = ctx->Point.Size * 0.5F;
- const GLfloat rmin = radius - 0.7071F; /* 0.7071 = sqrt(2)/2 */
- const GLfloat rmax = radius + 0.7071F;
- const GLfloat rmin2 = MAX2(0.0, rmin * rmin);
- const GLfloat rmax2 = rmax * rmax;
- const GLfloat cscale = 256.0F / (rmax2 - rmin2);
-
- if (ctx->Texture._ReallyEnabled) {
- GLint x, y;
- GLfloat vx = vert->win[0];
- GLfloat vy = vert->win[1];
- const GLint xmin = (GLint) (vx - radius);
- const GLint xmax = (GLint) (vx + radius);
- const GLint ymin = (GLint) (vy - radius);
- const GLint ymax = (GLint) (vy + radius);
- const GLint z = (GLint) (vert->win[2]);
- const GLint red = vert->color[0];
- const GLint green = vert->color[1];
- const GLint blue = vert->color[2];
- GLfloat texcoord[MAX_TEXTURE_UNITS][4];
- GLint u, alpha;
-
- GLfixed fog = FloatToFixed( vert->fog );
-
- for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
- if (ctx->Texture.Unit[u]._ReallyEnabled) {
- if (texcoord[u][3] != 1.0) {
- texcoord[u][0] = (vert->texcoord[u][0] /
- vert->texcoord[u][3]);
- texcoord[u][1] = (vert->texcoord[u][1] /
- vert->texcoord[u][3]);
- texcoord[u][2] = (vert->texcoord[u][2] /
- vert->texcoord[u][3]);
- }
- else {
- texcoord[u][0] = vert->texcoord[u][0];
- texcoord[u][1] = vert->texcoord[u][1];
- texcoord[u][2] = vert->texcoord[u][2];
- }
- }
- }
-
- /* translate by a half pixel to simplify math below */
- vx -= 0.5F;
- vx -= 0.5F;
-
- for (y = ymin; y <= ymax; y++) {
- for (x = xmin; x <= xmax; x++) {
- const GLfloat dx = x - vx;
- const GLfloat dy = y - vy;
- const GLfloat dist2 = dx*dx + dy*dy;
- if (dist2 < rmax2) {
- alpha = vert->color[3];
- if (dist2 >= rmin2) {
- GLint coverage = (GLint) (256.0F - (dist2 - rmin2) * cscale);
- /* coverage is in [0,256] */
- alpha = (alpha * coverage) >> 8;
- }
- if (ctx->Texture._MultiTextureEnabled) {
- PB_WRITE_MULTITEX_PIXEL( PB, x,y,z, fog,
- red, green, blue,
- alpha, texcoord );
- }
- else {
- PB_WRITE_TEX_PIXEL( PB, x,y,z, fog,
- red, green, blue, alpha,
- texcoord[0][0],
- texcoord[0][1],
- texcoord[0][2] );
- }
- }
- }
- }
-
- PB_CHECK_FLUSH(ctx,PB);
- }
- else {
- /* Not texture mapped */
- const GLint xmin = (GLint) (vert->win[0] - 0.0 - radius);
- const GLint xmax = (GLint) (vert->win[0] - 0.0 + radius);
- const GLint ymin = (GLint) (vert->win[1] - 0.0 - radius);
- const GLint ymax = (GLint) (vert->win[1] - 0.0 + radius);
- const GLint red = vert->color[0];
- const GLint green = vert->color[1];
- const GLint blue = vert->color[2];
- const GLint z = (GLint) (vert->win[2]);
- GLint x, y;
-
- GLfixed fog = FloatToFixed( vert->fog );
-
- /*
- printf("point %g, %g\n", vert->win[0], vert->win[1]);
- printf("%d..%d X %d..%d\n", xmin, xmax, ymin, ymax);
- */
- for (y = ymin; y <= ymax; y++) {
- for (x = xmin; x <= xmax; x++) {
- const GLfloat dx = x + 0.5F - vert->win[0];
- const GLfloat dy = y + 0.5F - vert->win[1];
- const GLfloat dist2 = dx*dx + dy*dy;
- if (dist2 < rmax2) {
- GLint alpha = vert->color[3];
- if (dist2 >= rmin2) {
- GLint coverage = (GLint) (256.0F - (dist2 - rmin2) * cscale);
- /* coverage is in [0,256] */
- alpha = (alpha * coverage) >> 8;
- }
- PB_WRITE_RGBA_PIXEL(PB, x, y, z, fog,
- red, green, blue, alpha);
- }
- }
- }
- PB_CHECK_FLUSH(ctx,PB);
- }
-}
-
-