summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2000-07-15 03:13:43 +0000
committerBrian Paul <[email protected]>2000-07-15 03:13:43 +0000
commit6fae9eb4b46ec0569b0ccad7c529fbcfd8b5f1cb (patch)
treeeb4981285eb9e7f0f2fa0143d5f550cfe247fcf4 /src/mesa
parent3284b5ddbae2792dd008c27bda55d2c7a18f3f24 (diff)
fixed AA sampling problem, misc clean-up
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/main/points.c93
1 files changed, 57 insertions, 36 deletions
diff --git a/src/mesa/main/points.c b/src/mesa/main/points.c
index 2aebb72472d..fe4810eaebe 100644
--- a/src/mesa/main/points.c
+++ b/src/mesa/main/points.c
@@ -1,4 +1,4 @@
-/* $Id: points.c,v 1.10 2000/06/28 23:11:10 brianp Exp $ */
+/* $Id: points.c,v 1.11 2000/07/15 03:13:43 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -521,6 +521,17 @@ multitextured_rgba_points( GLcontext *ctx, GLuint first, GLuint last )
}
+/*
+ * NOTES on aa point rasterization:
+ *
+ * Let d = distance of fragment center from vertex.
+ * if d < rmin2 then
+ * fragment has 100% coverage
+ * else if d > rmax2 then
+ * fragment has 0% coverage
+ * else
+ * fragement has % coverage = (d - rmin2) / (rmax2 - rmin2)
+ */
/*
@@ -534,7 +545,7 @@ antialiased_rgba_points( GLcontext *ctx, GLuint first, GLuint last )
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 = rmin * rmin;
+ const GLfloat rmin2 = MAX2(0.0, rmin * rmin);
const GLfloat rmax2 = rmax * rmax;
const GLfloat cscale = 256.0F / (rmax2 - rmin2);
GLuint i;
@@ -546,11 +557,13 @@ antialiased_rgba_points( GLcontext *ctx, GLuint first, GLuint last )
GLint red, green, blue, alpha;
GLfloat s, t, u;
GLfloat s1, t1, u1;
+ GLfloat vx = VB->Win.data[i][0];
+ GLfloat vy = VB->Win.data[i][1];
- GLint xmin = (GLint) (VB->Win.data[i][0] - radius);
- GLint xmax = (GLint) (VB->Win.data[i][0] + radius);
- GLint ymin = (GLint) (VB->Win.data[i][1] - radius);
- GLint ymax = (GLint) (VB->Win.data[i][1] + radius);
+ GLint xmin = (GLint) (vx - radius);
+ GLint xmax = (GLint) (vx + radius);
+ GLint ymin = (GLint) (vy - radius);
+ GLint ymax = (GLint) (vy + radius);
GLint z = (GLint) (VB->Win.data[i][2] + ctx->PointZoffset);
red = VB->ColorPtr->data[i][0];
@@ -621,15 +634,19 @@ antialiased_rgba_points( GLcontext *ctx, GLuint first, GLuint last )
}
}
- for (y=ymin;y<=ymax;y++) {
- for (x=xmin;x<=xmax;x++) {
- GLfloat dx = x/*+0.5F*/ - VB->Win.data[i][0];
- GLfloat dy = y/*+0.5F*/ - VB->Win.data[i][1];
- GLfloat dist2 = dx*dx + dy*dy;
- if (dist2<rmax2) {
+ /* 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 = VB->ColorPtr->data[i][3];
- if (dist2>=rmin2) {
- GLint coverage = (GLint) (256.0F-(dist2-rmin2)*cscale);
+ if (dist2 >= rmin2) {
+ GLint coverage = (GLint) (256.0F - (dist2 - rmin2) * cscale);
/* coverage is in [0,256] */
alpha = (alpha * coverage) >> 8;
}
@@ -656,25 +673,29 @@ antialiased_rgba_points( GLcontext *ctx, GLuint first, GLuint last )
GLint x, y, z;
GLint red, green, blue, alpha;
- 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);
+ xmin = (GLint) (VB->Win.data[i][0] - 0.0 - radius);
+ xmax = (GLint) (VB->Win.data[i][0] - 0.0 + radius);
+ ymin = (GLint) (VB->Win.data[i][1] - 0.0 - radius);
+ ymax = (GLint) (VB->Win.data[i][1] - 0.0 + 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];
- for (y=ymin;y<=ymax;y++) {
- for (x=xmin;x<=xmax;x++) {
- GLfloat dx = x/*+0.5F*/ - VB->Win.data[i][0];
- GLfloat dy = y/*+0.5F*/ - VB->Win.data[i][1];
- GLfloat dist2 = dx*dx + dy*dy;
- if (dist2<rmax2) {
+ /*
+ printf("point %g, %g\n", VB->Win.data[i][0], VB->Win.data[i][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 - 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);
+ if (dist2 >= rmin2) {
+ GLint coverage = (GLint) (256.0F - (dist2 - rmin2) * cscale);
/* coverage is in [0,256] */
alpha = (alpha * coverage) >> 8;
}
@@ -1104,9 +1125,9 @@ dist_atten_antialiased_rgba_points( GLcontext *ctx, GLuint first, GLuint last )
}
rmin = radius - 0.7071F; /* 0.7071 = sqrt(2)/2 */
rmax = radius + 0.7071F;
- rmin2 = rmin*rmin;
- rmax2 = rmax*rmax;
- cscale = 256.0F / (rmax2-rmin2);
+ 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);
@@ -1184,9 +1205,9 @@ dist_atten_antialiased_rgba_points( GLcontext *ctx, GLuint first, GLuint last )
for (y = ymin; y <= ymax; y++) {
for (x = xmin; x <= xmax; x++) {
- GLfloat dx = x/*+0.5F*/ - VB->Win.data[i][0];
- GLfloat dy = y/*+0.5F*/ - VB->Win.data[i][1];
- GLfloat dist2 = dx*dx + dy*dy;
+ 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) {
@@ -1230,7 +1251,7 @@ dist_atten_antialiased_rgba_points( GLcontext *ctx, GLuint first, GLuint last )
}
rmin = radius - 0.7071F; /* 0.7071 = sqrt(2)/2 */
rmax = radius + 0.7071F;
- rmin2 = rmin * rmin;
+ rmin2 = MAX2(0.0, rmin * rmin);
rmax2 = rmax * rmax;
cscale = 256.0F / (rmax2 - rmin2);
@@ -1246,9 +1267,9 @@ dist_atten_antialiased_rgba_points( GLcontext *ctx, GLuint first, GLuint last )
for (y = ymin; y <= ymax; y++) {
for (x = xmin; x <= xmax; x++) {
- GLfloat dx = x/*+0.5F*/ - VB->Win.data[i][0];
- GLfloat dy = y/*+0.5F*/ - VB->Win.data[i][1];
- GLfloat dist2 = dx * dx + dy * dy;
+ 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) {