fix some float/ubyte mistakes (Daniel Borca)
[mesa.git] / src / mesa / drivers / glide / fxdd.c
index d4ef05be146c2133703252a316674af1c961e21c..fd099e7e1153c25896cb9067a38808b42353b13c 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: fxdd.c,v 1.91 2002/09/27 02:45:38 brianp Exp $ */
+/* $Id: fxdd.c,v 1.95 2003/01/08 21:32:36 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -45,6 +45,7 @@
 #include "fxdrv.h"
 #include "enums.h"
 #include "extensions.h"
+#include "mmath.h"
 #include "texstore.h"
 #include "swrast/swrast.h"
 #include "swrast_setup/swrast_setup.h"
@@ -125,19 +126,23 @@ fxDDBufferSize(GLframebuffer *buffer, GLuint * width, GLuint * height)
 
 /* Implements glClearColor() */
 static void
-fxDDClearColor(GLcontext * ctx, const GLchan color[4])
+fxDDClearColor(GLcontext * ctx, const GLfloat color[4])
 {
    fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
    GLubyte col[4];
 
    if (MESA_VERBOSE & VERBOSE_DRIVER) {
-      fprintf(stderr, "fxmesa: fxDDClearColor(%d,%d,%d,%d)\n",
+      fprintf(stderr, "fxmesa: fxDDClearColor(%f,%f,%f,%f)\n",
              color[0], color[1], color[2], color[3]);
    }
 
-   ASSIGN_4V(col, color[0], color[1], color[2], 255);
+   CLAMPED_FLOAT_TO_UBYTE(col[0], color[0]);
+   CLAMPED_FLOAT_TO_UBYTE(col[1], color[1]);
+   CLAMPED_FLOAT_TO_UBYTE(col[2], color[2]);
+   CLAMPED_FLOAT_TO_UBYTE(col[3], color[3]);
+
    fxMesa->clearC = FXCOLOR4(col);
-   fxMesa->clearA = color[3];
+   fxMesa->clearA = col[3];
 }
 
 
@@ -694,7 +699,7 @@ fxDDInitFxMesaContext(fxMesaContext fxMesa)
 
    fxMesa->unitsState.alphaTestEnabled = GL_FALSE;
    fxMesa->unitsState.alphaTestFunc = GR_CMP_ALWAYS;
-   fxMesa->unitsState.alphaTestRefValue = 0;
+   fxMesa->unitsState.alphaTestRefValue = 0.0;
 
    fxMesa->unitsState.blendEnabled = GL_FALSE;
    fxMesa->unitsState.blendSrcFuncRGB = GR_BLEND_ONE;
@@ -717,7 +722,7 @@ fxDDInitFxMesaContext(fxMesaContext fxMesa)
    }
 
    fxMesa->state = malloc(FX_grGetInteger(FX_GLIDE_STATE_SIZE));
-   fxMesa->fogTable = malloc(FX_grGetInteger(FX_FOG_TABLE_ENTRIES) *
+   fxMesa->fogTable = (GrFog_t *) malloc(FX_grGetInteger(FX_FOG_TABLE_ENTRIES) *
                             sizeof(GrFog_t));
 
    if (!fxMesa->state || !fxMesa->fogTable) {