summaryrefslogtreecommitdiffstats
path: root/src/mesa/swrast/s_points.c
diff options
context:
space:
mode:
authorBrian <[email protected]>2007-11-22 09:31:16 -0700
committerBrian <[email protected]>2007-11-22 09:34:38 -0700
commit0fd679a1903d997b53fe20b86821a58c1a66262f (patch)
tree14a0df785508b36b04fff1df077adfac8eded616 /src/mesa/swrast/s_points.c
parentccb1c9df002b1bf7ef69ccfa57593f5cd6b63099 (diff)
Consolidate point size computation, clamping in get_size().
Also, apply user-defined clamp limits to point size even when not using attentuation or program-computed size.
Diffstat (limited to 'src/mesa/swrast/s_points.c')
-rw-r--r--src/mesa/swrast/s_points.c71
1 files changed, 35 insertions, 36 deletions
diff --git a/src/mesa/swrast/s_points.c b/src/mesa/swrast/s_points.c
index ce73365a4ea..dd664b980ed 100644
--- a/src/mesa/swrast/s_points.c
+++ b/src/mesa/swrast/s_points.c
@@ -46,6 +46,38 @@
} while(0)
+
+/**
+ * Get/compute the point size.
+ * The size may come from a vertex shader, or computed with attentuation
+ * or just the glPointSize value.
+ * Must also clamp to user-defined range and implmentation limits.
+ */
+static INLINE GLfloat
+get_size(const GLcontext *ctx, const SWvertex *vert, GLboolean smoothed)
+{
+ GLfloat size;
+
+ if (ctx->Point._Attenuated || ctx->VertexProgram.PointSizeEnabled) {
+ /* use vertex's point size */
+ size = vert->pointSize;
+ }
+ else {
+ /* use constant point size */
+ size = ctx->Point.Size;
+ }
+ /* always clamp to user-specified limits */
+ size = CLAMP(size, ctx->Point.MinSize, ctx->Point.MaxSize);
+ /* clamp to implementation limits */
+ if (smoothed)
+ size = CLAMP(size, ctx->Const.MinPointSizeAA, ctx->Const.MaxPointSizeAA);
+ else
+ size = CLAMP(size, ctx->Const.MinPointSize, ctx->Const.MaxPointSize);
+
+ return size;
+}
+
+
/**
* Draw a point sprite
*/
@@ -68,18 +100,7 @@ sprite_point(GLcontext *ctx, const SWvertex *vert)
span.z = (GLuint) (vert->attrib[FRAG_ATTRIB_WPOS][2] + 0.5F);
span.zStep = 0;
- /* compute size */
- if (ctx->Point._Attenuated || ctx->VertexProgram.PointSizeEnabled) {
- /* use vertex's point size */
- /* first, clamp attenuated size to the user-specifed range */
- size = CLAMP(vert->pointSize, ctx->Point.MinSize, ctx->Point.MaxSize);
- }
- else {
- /* use constant point size */
- size = ctx->Point.Size;
- }
- /* clamp to non-AA implementation limits */
- size = CLAMP(size, ctx->Const.MinPointSize, ctx->Const.MaxPointSize);
+ size = get_size(ctx, vert, GL_FALSE);
/* span init */
INIT_SPAN(span, GL_POINT);
@@ -237,18 +258,7 @@ smooth_point(GLcontext *ctx, const SWvertex *vert)
span.z = (GLuint) (vert->attrib[FRAG_ATTRIB_WPOS][2] + 0.5F);
span.zStep = 0;
- /* compute size */
- if (ctx->Point._Attenuated || ctx->VertexProgram.PointSizeEnabled) {
- /* use vertex's point size */
- /* first, clamp attenuated size to the user-specifed range */
- size = CLAMP(vert->pointSize, ctx->Point.MinSize, ctx->Point.MaxSize);
- }
- else {
- /* use constant point size */
- size = ctx->Point.Size;
- }
- /* clamp to AA implementation limits */
- size = CLAMP(size, ctx->Const.MinPointSizeAA, ctx->Const.MaxPointSizeAA);
+ size = get_size(ctx, vert, GL_TRUE);
/* alpha attenuation / fade factor */
if (ctx->Multisample.Enabled) {
@@ -371,18 +381,7 @@ large_point(GLcontext *ctx, const SWvertex *vert)
span.z = (GLuint) (vert->attrib[FRAG_ATTRIB_WPOS][2] + 0.5F);
span.zStep = 0;
- /* compute size */
- if (ctx->Point._Attenuated || ctx->VertexProgram.PointSizeEnabled) {
- /* use vertex's point size */
- /* first, clamp attenuated size to the user-specifed range */
- size = CLAMP(vert->pointSize, ctx->Point.MinSize, ctx->Point.MaxSize);
- }
- else {
- /* use constant point size */
- size = ctx->Point.Size;
- }
- /* clamp to non-AA implementation limits */
- size = CLAMP(size, ctx->Const.MinPointSize, ctx->Const.MaxPointSize);
+ size = get_size(ctx, vert, GL_FALSE);
/* span init */
INIT_SPAN(span, GL_POINT);