added GL_SGIX/SGIS_pixel_texture
[mesa.git] / src / mesa / main / points.c
index 6690b2a10252da731f039c868a0062a17f4723c5..66b38df3f2e0aa372e1f8f56f1bc0562698a34b4 100644 (file)
@@ -1,10 +1,10 @@
-/* $Id: points.c,v 1.2 1999/09/18 20:41:23 keithw Exp $ */
+/* $Id: points.c,v 1.7 2000/03/02 18:34:34 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
- * Version:  3.1
+ * Version:  3.3
  * 
- * Copyright (C) 1999  Brian Paul   All Rights Reserved.
+ * Copyright (C) 1999-2000  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"),
  */
 
 
-
-
-
 #ifdef PC_HEADER
 #include "all.h"
 #else
+#include "glheader.h"
 #include "context.h"
 #include "feedback.h"
 #include "macros.h"
+#include "mmath.h"
 #include "pb.h"
+#include "points.h"
 #include "span.h"
 #include "texstate.h"
 #include "types.h"
 #include "vb.h"
-#include "mmath.h"
-#ifdef XFree86Server
-#include "GL/xf86glx.h"
-#endif
 #endif
 
 
 
-void gl_PointSize( GLcontext *ctx, GLfloat size )
+void
+_mesa_PointSize( GLfloat size )
 {
-   if (size<=0.0) {
+   GET_CURRENT_CONTEXT(ctx);
+   ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glPointSize");
+
+   if (size <= 0.0) {
       gl_error( ctx, GL_INVALID_VALUE, "glPointSize" );
       return;
    }
-   ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glPointSize");
 
    if (ctx->Point.Size != size) {
       ctx->Point.Size = size;
@@ -65,42 +64,61 @@ void gl_PointSize( GLcontext *ctx, GLfloat size )
 
 
 
-void gl_PointParameterfvEXT( GLcontext *ctx, GLenum pname,
-                                    const GLfloat *params)
+void
+_mesa_PointParameterfEXT( GLenum pname, GLfloat param)
 {
+   _mesa_PointParameterfvEXT(pname, &param);
+}
+
+
+void
+_mesa_PointParameterfvEXT( GLenum pname, const GLfloat *params)
+{
+   GET_CURRENT_CONTEXT(ctx);
    ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glPointParameterfvEXT");
-   if(pname==GL_DISTANCE_ATTENUATION_EXT) {
-      GLboolean tmp = ctx->Point.Attenuated;
-      COPY_3V(ctx->Point.Params,params);
-      ctx->Point.Attenuated = (params[0] != 1.0 ||
-                              params[1] != 0.0 ||
-                              params[2] != 0.0);
-
-      if (tmp != ctx->Point.Attenuated) {
-        ctx->Enabled ^= ENABLE_POINT_ATTEN;
-        ctx->TriangleCaps ^= DD_POINT_ATTEN;
-        ctx->NewState |= NEW_RASTER_OPS;
-      }
-   } else {
-        if (*params<0.0 ) {
+
+   switch (pname) {
+      case GL_DISTANCE_ATTENUATION_EXT:
+         {
+            const GLboolean tmp = ctx->Point.Attenuated;
+            COPY_3V(ctx->Point.Params, params);
+            ctx->Point.Attenuated = (params[0] != 1.0 ||
+                                     params[1] != 0.0 ||
+                                     params[2] != 0.0);
+
+            if (tmp != ctx->Point.Attenuated) {
+               ctx->Enabled ^= ENABLE_POINT_ATTEN;
+               ctx->TriangleCaps ^= DD_POINT_ATTEN;
+               ctx->NewState |= NEW_RASTER_OPS;
+            }
+         }
+         break;
+      case GL_POINT_SIZE_MIN_EXT:
+         if (*params < 0.0F) {
             gl_error( ctx, GL_INVALID_VALUE, "glPointParameterfvEXT" );
             return;
-        }
-        switch (pname) {
-            case GL_POINT_SIZE_MIN_EXT:
-                ctx->Point.MinSize=*params;
-                break;
-            case GL_POINT_SIZE_MAX_EXT:
-                ctx->Point.MaxSize=*params;
-                break;
-            case GL_POINT_FADE_THRESHOLD_SIZE_EXT:
-                ctx->Point.Threshold=*params;
-                break;
-            default:
-                gl_error( ctx, GL_INVALID_ENUM, "glPointParameterfvEXT" );
-                return;
-        }
+         }
+         ctx->Point.MinSize = *params;
+         break;
+      case GL_POINT_SIZE_MAX_EXT:
+         if (*params < 0.0F) {
+            gl_error( ctx, GL_INVALID_VALUE, "glPointParameterfvEXT" );
+            return;
+         }
+         ctx->Point.MaxSize = *params;
+         break;
+      case GL_POINT_FADE_THRESHOLD_SIZE_EXT:
+         if (*params < 0.0F) {
+            gl_error( ctx, GL_INVALID_VALUE, "glPointParameterfvEXT" );
+            return;
+         }
+         ctx->Point.Threshold = *params;
+         break;
+      default:
+         gl_error( ctx, GL_INVALID_ENUM, "glPointParameterfvEXT" );
+         return;
    }
+
    ctx->NewState |= NEW_RASTER_OPS;
 }
 
@@ -128,7 +146,7 @@ void gl_PointParameterfvEXT( GLcontext *ctx, GLenum pname,
 /*
  * CI points with size == 1.0
  */
-void size1_ci_points( GLcontext *ctx, GLuint first, GLuint last )
+static void size1_ci_points( GLcontext *ctx, GLuint first, GLuint last )
 {
    struct vertex_buffer *VB = ctx->VB;
    struct pixel_buffer *PB = ctx->PB;
@@ -361,11 +379,12 @@ static void textured_rgba_points( GLcontext *ctx, GLuint first, GLuint last )
            t = 0.0;
            u = 0.0;
            break;
+         default:
+            /* should never get here */
+            s = t = u = 0.0;
+            gl_problem(ctx, "unexpected texcoord size in textured_rgba_points()");
         }
 
-
-
-
 /*    don't think this is needed
          PB_SET_COLOR( red, green, blue, alpha );
 */
@@ -452,6 +471,10 @@ static void multitextured_rgba_points( GLcontext *ctx, GLuint first, GLuint last
            t = 0.0;
            u = 0.0;
            break;
+         default:
+            /* should never get here */
+            s = t = u = 0.0;
+            gl_problem(ctx, "unexpected texcoord size in multitextured_rgba_points()");
         }
 
         switch (VB->TexCoordPtr[1]->size) {
@@ -475,6 +498,10 @@ static void multitextured_rgba_points( GLcontext *ctx, GLuint first, GLuint last
            t1 = 0.0;
            u1 = 0.0;
            break;
+         default:
+            /* should never get here */
+            s1 = t1 = u1 = 0.0;
+            gl_problem(ctx, "unexpected texcoord size in multitextured_rgba_points()");
         }
 
          for (iy=y0;iy<=y1;iy++) {
@@ -551,6 +578,10 @@ static void antialiased_rgba_points( GLcontext *ctx,
               t = 0.0;
               u = 0.0;
               break;
+            default:
+               /* should never get here */
+               s = t = u = 0.0;
+               gl_problem(ctx, "unexpected texcoord size in antialiased_rgba_points()");
            }
 
            if (ctx->Texture.ReallyEnabled >= TEXTURE1_1D) {
@@ -580,6 +611,10 @@ static void antialiased_rgba_points( GLcontext *ctx,
                  t1 = 0.0;
                  u1 = 0.0;
                  break;
+               default:
+                  /* should never get here */
+                  s1 = t1 = u1 = 0.0;
+                  gl_problem(ctx, "unexpected texcoord size in antialiased_rgba_points()");
               }
            }
 
@@ -674,15 +709,14 @@ static void dist3(GLfloat *out, GLuint first, GLuint last,
                  const GLcontext *ctx, const GLvector4f *v)
 {
    GLuint stride = v->stride;
-   GLfloat *p = VEC_ELT(v, GLfloat, first);
+   const GLfloat *p = VEC_ELT(v, GLfloat, first);
    GLuint i;
 
-   for (i = first ; i <= last ; i++, STRIDE_F(p, stride) )
-   {
+   for (i = first ; i <= last ; i++, STRIDE_F(p, stride) ) {
       GLfloat dist = GL_SQRT(p[0]*p[0]+p[1]*p[1]+p[2]*p[2]);
-      out[i] = 1/(ctx->Point.Params[0]+ 
-                 dist * (ctx->Point.Params[1] +
-                         dist * ctx->Point.Params[2]));
+      out[i] = 1.0F / (ctx->Point.Params[0] +
+                       dist * (ctx->Point.Params[1] +
+                               dist * ctx->Point.Params[2]));
    }
 }
 
@@ -690,15 +724,14 @@ static void dist2(GLfloat *out, GLuint first, GLuint last,
                  const GLcontext *ctx, const GLvector4f *v)
 {
    GLuint stride = v->stride;
-   GLfloat *p = VEC_ELT(v, GLfloat, first);
+   const GLfloat *p = VEC_ELT(v, GLfloat, first);
    GLuint i;
 
-   for (i = first ; i <= last ; i++, STRIDE_F(p, stride) )
-   {
+   for (i = first ; i <= last ; i++, STRIDE_F(p, stride) ) {
       GLfloat dist = GL_SQRT(p[0]*p[0]+p[1]*p[1]);
-      out[i] = 1/(ctx->Point.Params[0]+ 
-                 dist * (ctx->Point.Params[1] +
-                         dist * ctx->Point.Params[2]));
+      out[i] = 1.0F / (ctx->Point.Params[0] +
+                       dist * (ctx->Point.Params[1] +
+                               dist * ctx->Point.Params[2]));
    }
 }
 
@@ -971,6 +1004,10 @@ static void dist_atten_textured_rgba_points( GLcontext *ctx, GLuint first,
            t = 0.0;
            u = 0.0;
            break;
+         default:
+            /* should never get here */
+            s = t = u = 0.0;
+            gl_problem(ctx, "unexpected texcoord size in dist_atten_textured_rgba_points()");
         }
 
         if (ctx->Texture.ReallyEnabled >= TEXTURE1_1D) {
@@ -1000,6 +1037,10 @@ static void dist_atten_textured_rgba_points( GLcontext *ctx, GLuint first,
               t1 = 0.0;
               u1 = 0.0;
               break;
+            default:
+               /* should never get here */
+               s1 = t1 = u1 = 0.0;
+               gl_problem(ctx, "unexpected texcoord size in dist_atten_textured_rgba_points()");
            }
         }
 
@@ -1098,6 +1139,10 @@ static void dist_atten_antialiased_rgba_points( GLcontext *ctx,
               t = 0.0;
               u = 0.0;
               break;
+            default:
+               /* should never get here */
+               s = t = u = 0.0;
+               gl_problem(ctx, "unexpected texcoord size in dist_atten_antialiased_rgba_points()");
            }
 
            if (ctx->Texture.ReallyEnabled >= TEXTURE1_1D) {
@@ -1127,6 +1172,10 @@ static void dist_atten_antialiased_rgba_points( GLcontext *ctx,
                  t1 = 0.0;
                  u1 = 0.0;
                  break;
+               default:
+                  /* should never get here */
+                  s = t = u = 0.0;
+                  gl_problem(ctx, "unexpected texcoord size in dist_atten_antialiased_rgba_points()");
               }
            }