- struct vertex_buffer *VB = ctx->VB;
- struct pixel_buffer *PB = ctx->PB;
- GLfloat dist[VB_SIZE];
- const GLfloat psize = ctx->Point.Size;
- GLuint i;
-
- ASSERT(ctx->NeedEyeCoords);
- (eye_dist_tab[VB->EyePtr->size])( dist, first, last, ctx, VB->EyePtr );
-
- if (ctx->Texture.ReallyEnabled) {
- for (i=first;i<=last;i++) {
- if (VB->ClipMask[i]==0) {
- GLfloat radius, rmin, rmax, rmin2, rmax2, cscale, alphaf;
- GLint xmin, ymin, xmax, ymax;
- GLint x, y, z;
- GLint red, green, blue, alpha;
- GLfloat texcoord[MAX_TEXTURE_UNITS][4];
- GLfloat dsize = psize * dist[i];
- GLint u;
-
- GLfixed fog = FloatToFixed( VB->FogCoordPtr->data[i] );
-
- if (dsize >= ctx->Point.Threshold) {
- radius = MIN2(dsize, ctx->Point.MaxSize) * 0.5F;
- alphaf = 1.0F;
- }
- else {
- radius = (MAX2(ctx->Point.Threshold, ctx->Point.MinSize) * 0.5F);
- dsize /= ctx->Point.Threshold;
- alphaf = (dsize*dsize);
- }
- rmin = radius - 0.7071F; /* 0.7071 = sqrt(2)/2 */
- rmax = radius + 0.7071F;
- rmin2 = MAX2(0.0, rmin * rmin);
- rmax2 = rmax * rmax;
- cscale = 256.0F / (rmax2 - rmin2);
-
- xmin = (GLint) (VB->Win.data[i][0] - radius);
- xmax = (GLint) (VB->Win.data[i][0] + radius);
- ymin = (GLint) (VB->Win.data[i][1] - radius);
- ymax = (GLint) (VB->Win.data[i][1] + radius);
- z = (GLint) (VB->Win.data[i][2] + ctx->PointZoffset);
-
- red = VB->ColorPtr->data[i][0];
- green = VB->ColorPtr->data[i][1];
- blue = VB->ColorPtr->data[i][2];
-
- /* get texture coordinates */
- for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
- if (ctx->Texture.Unit[u].ReallyEnabled) {
- switch (VB->TexCoordPtr[0]->size) {
- case 4:
- texcoord[u][0] = VB->TexCoordPtr[u]->data[i][0] /
- VB->TexCoordPtr[u]->data[i][3];
- texcoord[u][1] = VB->TexCoordPtr[u]->data[i][1] /
- VB->TexCoordPtr[u]->data[i][3];
- texcoord[u][2] = VB->TexCoordPtr[u]->data[i][2] /
- VB->TexCoordPtr[u]->data[i][3];
- break;
- case 3:
- texcoord[u][0] = VB->TexCoordPtr[u]->data[i][0];
- texcoord[u][1] = VB->TexCoordPtr[u]->data[i][1];
- texcoord[u][2] = VB->TexCoordPtr[u]->data[i][2];
- break;
- case 2:
- texcoord[u][0] = VB->TexCoordPtr[u]->data[i][0];
- texcoord[u][1] = VB->TexCoordPtr[u]->data[i][1];
- texcoord[u][2] = 0.0;
- break;
- case 1:
- texcoord[u][0] = VB->TexCoordPtr[u]->data[i][0];
- texcoord[u][1] = 0.0;
- texcoord[u][2] = 0.0;
- break;
- default:
- /* should never get here */
- gl_problem(ctx, "unexpected texcoord size");
- }
- }
- }
-
- for (y = ymin; y <= ymax; y++) {
- for (x = xmin; x <= xmax; x++) {
- const GLfloat dx = x + 0.5F - VB->Win.data[i][0];
- const GLfloat dy = y + 0.5F - VB->Win.data[i][1];
- const GLfloat dist2 = dx*dx + dy*dy;
- if (dist2 < rmax2) {
- alpha = VB->ColorPtr->data[i][3];
- if (dist2 >= rmin2) {
- GLint coverage = (GLint) (256.0F - (dist2 - rmin2) * cscale);
- /* coverage is in [0,256] */
- alpha = (alpha * coverage) >> 8;
- }
- alpha = (GLint) (alpha * alphaf);
- 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 */
- for (i = first; i <= last; i++) {
- if (VB->ClipMask[i] == 0) {
- GLfloat radius, rmin, rmax, rmin2, rmax2, cscale, alphaf;
- GLint xmin, ymin, xmax, ymax;
- GLint x, y, z;
- GLfixed fog;
- GLint red, green, blue, alpha;
- GLfloat dsize = psize * dist[i];
-
- if (dsize >= ctx->Point.Threshold) {
- radius = MIN2(dsize, ctx->Point.MaxSize) * 0.5F;
- alphaf = 1.0F;
- }
- else {
- radius = (MAX2(ctx->Point.Threshold, ctx->Point.MinSize) * 0.5F);
- dsize /= ctx->Point.Threshold;
- alphaf = dsize * dsize;
- }
- rmin = radius - 0.7071F; /* 0.7071 = sqrt(2)/2 */
- rmax = radius + 0.7071F;
- rmin2 = MAX2(0.0, rmin * rmin);
- rmax2 = rmax * rmax;
- cscale = 256.0F / (rmax2 - rmin2);
-
- xmin = (GLint) (VB->Win.data[i][0] - radius);
- xmax = (GLint) (VB->Win.data[i][0] + radius);
- ymin = (GLint) (VB->Win.data[i][1] - radius);
- ymax = (GLint) (VB->Win.data[i][1] + radius);
- z = (GLint) (VB->Win.data[i][2] + ctx->PointZoffset);
-
- fog = FloatToFixed( VB->FogCoordPtr->data[i] );
-
- red = VB->ColorPtr->data[i][0];
- green = VB->ColorPtr->data[i][1];
- blue = VB->ColorPtr->data[i][2];
-
- for (y = ymin; y <= ymax; y++) {
- for (x = xmin; x <= xmax; x++) {
- const GLfloat dx = x + 0.5F - VB->Win.data[i][0];
- const GLfloat dy = y + 0.5F - VB->Win.data[i][1];
- const GLfloat dist2 = dx * dx + dy * dy;
- if (dist2 < rmax2) {
- alpha = VB->ColorPtr->data[i][3];
- if (dist2 >= rmin2) {
- GLint coverage = (GLint) (256.0F - (dist2 - rmin2) * cscale);
- /* coverage is in [0,256] */
- alpha = (alpha * coverage) >> 8;
- }
- alpha = (GLint) (alpha * alphaf);
- PB_WRITE_RGBA_PIXEL(PB, x, y, z, fog,
- red, green, blue, alpha);
- }
- }
- }
- PB_CHECK_FLUSH(ctx,PB);
- }
- }
- }
-}