additional fog/color matrix changes from gallium-0.1
authorBrian Paul <brian.paul@tungstengraphics.com>
Sun, 18 May 2008 21:55:24 +0000 (15:55 -0600)
committerBrian Paul <brian.paul@tungstengraphics.com>
Sun, 18 May 2008 21:55:24 +0000 (15:55 -0600)
src/mesa/shader/prog_statevars.c

index 592a63651c33d8e575d5301245be7a40ca782baa..539057b43821a135b5db1adf4892c4ad959d78b8 100644 (file)
@@ -425,8 +425,9 @@ _mesa_fetch_state(GLcontext *ctx, const gl_state_index state[],
           * exp: 2^-(density/ln(2) * fogcoord)
           * exp2: 2^-((density/(ln(2)^2) * fogcoord)^2)
           */
-         value[0] = -1.0F / (ctx->Fog.End - ctx->Fog.Start);
-         value[1] = ctx->Fog.End / (ctx->Fog.End - ctx->Fog.Start);
+         value[0] = (ctx->Fog.End == ctx->Fog.Start)
+            ? 1.0 : -1.0F / (ctx->Fog.End - ctx->Fog.Start);
+         value[1] = ctx->Fog.End * -value[0];
          value[2] = ctx->Fog.Density * ONE_DIV_LN2;
          value[3] = ctx->Fog.Density * ONE_DIV_SQRT_LN2;
          return;
@@ -515,6 +516,8 @@ _mesa_program_state_flags(const gl_state_index state[STATE_LENGTH])
       return _NEW_TEXTURE_MATRIX;
    case STATE_PROGRAM_MATRIX:
       return _NEW_TRACK_MATRIX;
+   case STATE_COLOR_MATRIX:
+      return _NEW_COLOR_MATRIX;
 
    case STATE_DEPTH_RANGE:
       return _NEW_VIEWPORT;
@@ -608,6 +611,9 @@ append_token(char *dst, gl_state_index k)
    case STATE_PROGRAM_MATRIX:
       append(dst, "matrix.program");
       break;
+   case STATE_COLOR_MATRIX:
+      append(dst, "matrix.color");
+      break;
    case STATE_MATRIX_INVERSE:
       append(dst, ".inverse");
       break;
@@ -783,6 +789,7 @@ _mesa_program_state_string(const gl_state_index state[STATE_LENGTH])
    case STATE_MVP_MATRIX:
    case STATE_TEXTURE_MATRIX:
    case STATE_PROGRAM_MATRIX:
+   case STATE_COLOR_MATRIX:
       {
          /* state[0] = modelview, projection, texture, etc. */
          /* state[1] = which texture matrix or program matrix */
@@ -850,10 +857,12 @@ _mesa_load_state_parameters(GLcontext *ctx,
    if (!paramList)
       return;
 
+   /*assert(ctx->Driver.NeedFlush == 0);*/
+
    for (i = 0; i < paramList->NumParameters; i++) {
       if (paramList->Parameters[i].Type == PROGRAM_STATE_VAR) {
          _mesa_fetch_state(ctx, 
-                          paramList->Parameters[i].StateIndexes,
+                          (gl_state_index *) paramList->Parameters[i].StateIndexes,
                            paramList->ParameterValues[i]);
       }
    }