diff options
author | Brian Paul <[email protected]> | 2005-10-07 03:56:29 +0000 |
---|---|---|
committer | Brian Paul <[email protected]> | 2005-10-07 03:56:29 +0000 |
commit | dfe7aedf845ce9117065c6cee2146df7eee1c0fa (patch) | |
tree | 5a2f0638c52c406babdaf5975f83798c1e265010 /src/mesa/tnl/t_vb_points.c | |
parent | 9dd973ec3b2b53f4b95d2ba0a746a0e52533becf (diff) |
Fix a number of point size attenuation problems.
Move size clamping into the rasterization function.
Diffstat (limited to 'src/mesa/tnl/t_vb_points.c')
-rw-r--r-- | src/mesa/tnl/t_vb_points.c | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/src/mesa/tnl/t_vb_points.c b/src/mesa/tnl/t_vb_points.c index ccceba3262d..47c37930d57 100644 --- a/src/mesa/tnl/t_vb_points.c +++ b/src/mesa/tnl/t_vb_points.c @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 6.1 + * Version: 6.5 * - * Copyright (C) 1999-2004 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2005 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -38,11 +38,14 @@ struct point_stage_data { #define POINT_STAGE_DATA(stage) ((struct point_stage_data *)stage->privatePtr) -/* - * Compute attenuated point sizes +/** + * Compute point size for each vertex from the vertex eye-space Z + * coordinate and the point size attenuation factors. + * Only done when point size attenuation is enabled and vertex program is + * disabled. */ -static GLboolean run_point_stage( GLcontext *ctx, - struct tnl_pipeline_stage *stage ) +static GLboolean +run_point_stage(GLcontext *ctx, struct tnl_pipeline_stage *stage) { if (ctx->Point._Attenuated && !ctx->VertexProgram._Enabled) { struct point_stage_data *store = POINT_STAGE_DATA(stage); @@ -51,14 +54,15 @@ static GLboolean run_point_stage( GLcontext *ctx, const GLfloat p0 = ctx->Point.Params[0]; const GLfloat p1 = ctx->Point.Params[1]; const GLfloat p2 = ctx->Point.Params[2]; - const GLfloat pointSize = ctx->Point._Size; + const GLfloat pointSize = ctx->Point.Size; GLfloat (*size)[4] = store->PointSize.data; GLuint i; for (i = 0; i < VB->Count; i++) { - const GLfloat dist = -eye[i][2]; - /* GLfloat dist = SQRTF(pos[0]*pos[0]+pos[1]*pos[1]+pos[2]*pos[2]);*/ - size[i][0] = pointSize / (p0 + dist * (p1 + dist * p2)); + const GLfloat dist = FABSF(eye[i][2]); + const GLfloat q = p0 + dist * (p1 + dist * p2); + const GLfloat atten = (q != 0.0) ? SQRTF(1.0 / q) : 1.0; + size[i][0] = pointSize * atten; /* clamping done in rasterization */ } VB->PointSizePtr = &store->PointSize; @@ -69,13 +73,12 @@ static GLboolean run_point_stage( GLcontext *ctx, } - -static GLboolean alloc_point_data( GLcontext *ctx, - struct tnl_pipeline_stage *stage ) +static GLboolean +alloc_point_data(GLcontext *ctx, struct tnl_pipeline_stage *stage) { struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; struct point_stage_data *store; - stage->privatePtr = MALLOC(sizeof(*store)); + stage->privatePtr = _mesa_malloc(sizeof(*store)); store = POINT_STAGE_DATA(stage); if (!store) return GL_FALSE; @@ -85,16 +88,18 @@ static GLboolean alloc_point_data( GLcontext *ctx, } -static void free_point_data( struct tnl_pipeline_stage *stage ) +static void +free_point_data(struct tnl_pipeline_stage *stage) { struct point_stage_data *store = POINT_STAGE_DATA(stage); if (store) { _mesa_vector4f_free( &store->PointSize ); - FREE( store ); + _mesa_free( store ); stage->privatePtr = NULL; } } + const struct tnl_pipeline_stage _tnl_point_attenuation_stage = { "point size attenuation", /* name */ |