mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-22 11:20:11 +01:00
fixed AA sampling problem, misc clean-up
This commit is contained in:
parent
3284b5ddba
commit
6fae9eb4b4
1 changed files with 57 additions and 36 deletions
|
|
@ -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,11 +634,15 @@ antialiased_rgba_points( GLcontext *ctx, GLuint first, GLuint last )
|
|||
}
|
||||
}
|
||||
|
||||
/* 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++) {
|
||||
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 - 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) {
|
||||
|
|
@ -656,21 +673,25 @@ 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];
|
||||
|
||||
/*
|
||||
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++) {
|
||||
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) {
|
||||
|
|
@ -1104,7 +1125,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);
|
||||
|
||||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue