Fix pow <small> and a very stypid bug with dummy srcs(0 equals to tmp0.x)</small...
[mesa.git] / src / mesa / main / fog.c
index dbb8269bd51f348b8c2ff429db1fb33474ad09b3..d3b8a923aae6e15ede9d4f9143c205836e0565c8 100644 (file)
@@ -1,10 +1,8 @@
-/* $Id: fog.c,v 1.35 2001/05/30 14:43:17 brianp Exp $ */
-
 /*
  * Mesa 3-D graphics library
- * Version:  3.5
+ * Version:  5.1
  *
- * Copyright (C) 1999-2001  Brian Paul   All Rights Reserved.
+ * Copyright (C) 1999-2003  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 "colormac.h"
 #include "context.h"
 #include "fog.h"
 #include "mtypes.h"
-#endif
 
 
 
-void
+void GLAPIENTRY
 _mesa_Fogf(GLenum pname, GLfloat param)
 {
    _mesa_Fogfv(pname, &param);
 }
 
 
-void
+void GLAPIENTRY
 _mesa_Fogi(GLenum pname, GLint param )
 {
    GLfloat fparam = (GLfloat) param;
@@ -52,7 +46,7 @@ _mesa_Fogi(GLenum pname, GLint param )
 }
 
 
-void
+void GLAPIENTRY
 _mesa_Fogiv(GLenum pname, const GLint *params )
 {
    GLfloat p[4];
@@ -79,7 +73,7 @@ _mesa_Fogiv(GLenum pname, const GLint *params )
 }
 
 
-void
+void GLAPIENTRY
 _mesa_Fogfv( GLenum pname, const GLfloat *params )
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -135,10 +129,10 @@ _mesa_Fogfv( GLenum pname, const GLfloat *params )
         if (TEST_EQ_4V(ctx->Fog.Color, params))
            return;
         FLUSH_VERTICES(ctx, _NEW_FOG);
-        ctx->Fog.Color[0] = params[0];
-        ctx->Fog.Color[1] = params[1];
-        ctx->Fog.Color[2] = params[2];
-        ctx->Fog.Color[3] = params[3];
+        ctx->Fog.Color[0] = CLAMP(params[0], 0.0F, 1.0F);
+        ctx->Fog.Color[1] = CLAMP(params[1], 0.0F, 1.0F);
+        ctx->Fog.Color[2] = CLAMP(params[2], 0.0F, 1.0F);
+        ctx->Fog.Color[3] = CLAMP(params[3], 0.0F, 1.0F);
          break;
       case GL_FOG_COORDINATE_SOURCE_EXT: {
         GLenum p = (GLenum) (GLint) *params;
@@ -162,3 +156,22 @@ _mesa_Fogfv( GLenum pname, const GLfloat *params )
       (*ctx->Driver.Fogfv)( ctx, pname, params );
    }
 }
+
+
+/**********************************************************************/
+/*****                      Initialization                        *****/
+/**********************************************************************/
+
+void _mesa_init_fog( GLcontext * ctx )
+{
+   /* Fog group */
+   ctx->Fog.Enabled = GL_FALSE;
+   ctx->Fog.Mode = GL_EXP;
+   ASSIGN_4V( ctx->Fog.Color, 0.0, 0.0, 0.0, 0.0 );
+   ctx->Fog.Index = 0.0;
+   ctx->Fog.Density = 1.0;
+   ctx->Fog.Start = 0.0;
+   ctx->Fog.End = 1.0;
+   ctx->Fog.ColorSumEnabled = GL_FALSE;
+   ctx->Fog.FogCoordinateSource = GL_FRAGMENT_DEPTH_EXT;
+}