Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
glsl: Implemented most of the missing srcmods.
Reread the GLSL spec, and it turns out that "vec3(x,y,z) - 3.0" is legal
 syntactic sugar: the compiler knows to subtract 3.0 from each of the three
 components in that vec3. This made this simpler than having to tapdance to
 generate correct constant vectors ourselves, and it's easier to read.
  • Loading branch information
icculus committed Apr 18, 2012
1 parent 10d3078 commit 1952322
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions mojoshader.c
Expand Up @@ -1933,7 +1933,6 @@ static const char *make_GLSL_srcarg_string(Context *ctx, const size_t idx,
return buf;
} // if

// !!! FIXME: not right.
const SourceArgInfo *arg = &ctx->source_args[idx];

const char *premod_str = "";
Expand All @@ -1955,27 +1954,26 @@ static const char *make_GLSL_srcarg_string(Context *ctx, const size_t idx,
break;

case SRCMOD_SIGNNEGATE:
premod_str = "-";
// fall through.
premod_str = "-((";
postmod_str = " - 0.5) * 2.0)";
break;

case SRCMOD_SIGN:
fail(ctx, "SRCMOD_SIGN unsupported"); return buf; // !!! FIXME
postmod_str = "_bx2";
premod_str = "((";
postmod_str = " - 0.5) * 2.0)";
break;

case SRCMOD_COMPLEMENT:
fail(ctx, "SRCMOD_COMPLEMENT unsupported"); return buf; // !!! FIXME (need to handle vecsize)
premod_str = "(1.0 - (";
postmod_str = "))";
premod_str = "(1.0 - ";
postmod_str = ")";
break;

case SRCMOD_X2NEGATE:
fail(ctx, "SRCMOD_X2NEGATE unsupported"); return buf; // !!! FIXME (need to handle vecsize)
premod_str = "-(";
postmod_str = " * 2.0)";
break;

case SRCMOD_X2:
fail(ctx, "SRCMOD_X2 unsupported"); return buf; // !!! FIXME (need to handle vecsize)
premod_str = "(";
postmod_str = " * 2.0)";
break;
Expand Down

0 comments on commit 1952322

Please sign in to comment.