s/BlendEquatioRGB/BlendEquationRGB/
[mesa.git] / src / mesa / swrast / s_pointtemp.h
index cf45dcde8254bc6cd80165f2c005a7669aa31ea4..0ca137cd02964395d1c8e160499b0dc82dc0c4a4 100644 (file)
@@ -1,10 +1,8 @@
-/* $Id: s_pointtemp.h,v 1.19 2002/10/04 17:37:47 brianp Exp $ */
-
 /*
  * Mesa 3-D graphics library
- * Version:  4.1
+ * Version:  6.0
  *
- * Copyright (C) 1999-2002  Brian Paul   All Rights Reserved.
+ * Copyright (C) 1999-2004  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"),
  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
 
+/*
+ * Regarding GL_NV_point_sprite:
+ *
+ * Portions of this software may use or implement intellectual
+ * property owned and licensed by NVIDIA Corporation. NVIDIA disclaims
+ * any and all warranties with respect to such intellectual property,
+ * including any use thereof or modifications thereto.
+ */
+
 
 /*
  * Point rendering template code.
@@ -36,7 +43,7 @@
  *   SPECULAR = do separate specular color
  *   LARGE = do points with diameter > 1 pixel
  *   ATTENUATE = compute point size attenuation
- *   SPRITE = GL_NV_point_sprite
+ *   SPRITE = GL_ARB_point_sprite / GL_NV_point_sprite
  *
  * Notes: LARGE and ATTENUATE are exclusive of each other.
  *        TEXTURE requires RGBA
@@ -64,10 +71,10 @@ NAME ( GLcontext *ctx, const SWvertex *vert )
 #if FLAGS & (ATTENUATE | LARGE | SMOOTH | SPRITE)
    GLfloat size;
 #endif
-#if FLAGS & ATTENUATE
+#if FLAGS & RGBA
+#if (FLAGS & ATTENUATE) && (FLAGS & SMOOTH)
    GLfloat alphaAtten;
 #endif
-#if FLAGS & RGBA
    const GLchan red   = vert->color[0];
    const GLchan green = vert->color[1];
    const GLchan blue  = vert->color[2];
@@ -82,7 +89,7 @@ NAME ( GLcontext *ctx, const SWvertex *vert )
    const GLuint colorIndex = vert->index;
 #endif
 #if FLAGS & TEXTURE
-   GLfloat texcoord[MAX_TEXTURE_UNITS][4];
+   GLfloat texcoord[MAX_TEXTURE_COORD_UNITS][4];
    GLuint u;
 #endif
    SWcontext *swrast = SWRAST_CONTEXT(ctx);
@@ -117,7 +124,7 @@ NAME ( GLcontext *ctx, const SWvertex *vert )
    for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
       if (ctx->Texture.Unit[u]._ReallyEnabled) {
          const GLfloat q = vert->texcoord[u][3];
-         const GLfloat invQ = (q == 0.0 || q == 1.0) ? 1.0 : (1.0 / q);
+         const GLfloat invQ = (q == 0.0F || q == 1.0F) ? 1.0F : (1.0F / q);
          texcoord[u][0] = vert->texcoord[u][0] * invQ;
          texcoord[u][1] = vert->texcoord[u][1] * invQ;
          texcoord[u][2] = vert->texcoord[u][2] * invQ;
@@ -135,12 +142,16 @@ NAME ( GLcontext *ctx, const SWvertex *vert )
 #if FLAGS & ATTENUATE
    if (vert->pointSize >= ctx->Point.Threshold) {
       size = MIN2(vert->pointSize, ctx->Point.MaxSize);
+#if (FLAGS & RGBA) && (FLAGS & SMOOTH)
       alphaAtten = 1.0F;
+#endif
    }
    else {
+#if (FLAGS & RGBA) && (FLAGS & SMOOTH)
       GLfloat dsize = vert->pointSize / ctx->Point.Threshold;
-      size = MAX2(ctx->Point.Threshold, ctx->Point.MinSize);
       alphaAtten = dsize * dsize;
+#endif
+      size = MAX2(ctx->Point.Threshold, ctx->Point.MinSize);
    }
 #elif FLAGS & (LARGE | SMOOTH | SPRITE)
    size = ctx->Point._Size;
@@ -153,7 +164,7 @@ NAME ( GLcontext *ctx, const SWvertex *vert )
    {{
       GLint x, y;
       const GLfloat radius = 0.5F * size;
-      const GLint z = (GLint) (vert->win[2]);
+      const GLint z = (GLint) (vert->win[2] + 0.5F);
       GLuint count;
 #if FLAGS & SMOOTH
       const GLfloat rmin = radius - 0.7071F;  /* 0.7071 = sqrt(2)/2 */
@@ -193,13 +204,13 @@ NAME ( GLcontext *ctx, const SWvertex *vert )
           (swrast->_RasterMask & (BLEND_BIT | LOGIC_OP_BIT | MASKING_BIT))) {
 #if FLAGS & (TEXTURE | SPRITE)
          if (ctx->Texture._EnabledUnits)
-            _mesa_write_texture_span(ctx, span);
+            _swrast_write_texture_span(ctx, span);
          else
-            _mesa_write_rgba_span(ctx, span);
+            _swrast_write_rgba_span(ctx, span);
 #elif FLAGS & RGBA
-         _mesa_write_rgba_span(ctx, span);
+         _swrast_write_rgba_span(ctx, span);
 #else
-         _mesa_write_index_span(ctx, span);
+         _swrast_write_index_span(ctx, span);
 #endif
          span->end = 0;
       }
@@ -322,13 +333,13 @@ NAME ( GLcontext *ctx, const SWvertex *vert )
           (swrast->_RasterMask & (BLEND_BIT | LOGIC_OP_BIT | MASKING_BIT))) {
 #if FLAGS & (TEXTURE | SPRITE)
          if (ctx->Texture._EnabledUnits)
-            _mesa_write_texture_span(ctx, span);
+            _swrast_write_texture_span(ctx, span);
          else
-            _mesa_write_rgba_span(ctx, span);
+            _swrast_write_rgba_span(ctx, span);
 #elif FLAGS & RGBA
-         _mesa_write_rgba_span(ctx, span);
+         _swrast_write_rgba_span(ctx, span);
 #else
-         _mesa_write_index_span(ctx, span);
+         _swrast_write_index_span(ctx, span);
 #endif
          span->end = 0;
       }
@@ -359,7 +370,7 @@ NAME ( GLcontext *ctx, const SWvertex *vert )
 
       span->array->x[count] = (GLint) vert->win[0];
       span->array->y[count] = (GLint) vert->win[1];
-      span->array->z[count] = (GLint) vert->win[2];
+      span->array->z[count] = (GLint) (vert->win[2] + 0.5F);
       span->end = count + 1;
    }}