Skip to content
Permalink
Browse files
More work on emit_GLSL_DCL().
Still needs more work.

--HG--
branch : trunk
  • Loading branch information
icculus committed Apr 5, 2008
1 parent 30b5186 commit 473e42c1d71a393f0f4d8650ac65803203986492
Showing with 24 additions and 4 deletions.
  1. +24 −4 mojoshader.c
@@ -2104,28 +2104,48 @@ static void emit_GLSL_DCL(Context *ctx)
{
const uint32 index = ctx->dwords[1];
const char *usage_str = NULL;
const char *arrayleft = "";
const char *arrayright = "";
char index_str[16] = { '\0' };
if (index != 0) // !!! FIXME: a lot of these MUST be zero.
snprintf(index_str, sizeof (index_str), "%u", (uint) index);

switch (usage)
{
case MOJOSHADER_USAGE_POSITION:
// !!! FIXME: make sure this is index == 0 in state machine.
usage_str = "gl_Position";
break;
case MOJOSHADER_USAGE_POINTSIZE:
usage_str = "gl_PointSize";
break;
// !!! FIXME: we need to deal with some built-in varyings here.
case MOJOSHADER_USAGE_COLOR:
index_str[0] = '\0'; // no explicit number.
if (index == 0)
usage_str = "gl_FrontColor";
else if (index == 1)
usage_str = "gl_FrontSecondaryColor";
break;
case MOJOSHADER_USAGE_TEXCOORD:
usage_str = "gl_TexCoord";
arrayleft = "[";
arrayright = "]";
break;
default:
fail(ctx, "Don't know how to handle this output register.");
// !!! FIXME: we need to deal with some more built-in varyings here.
break;
} // switch

// !!! FIXME: the #define is a little hacky, but it means we don't
// !!! FIXME: have to track these separately if this works.
push_output(ctx, &ctx->globals);
output_line(ctx, "#define %s %s;", varname, usage_str);
// no mapping to built-in var? Just make it a regular global, pray.
if (usage_str == NULL)
output_line(ctx, "vec %s;", varname);
else
{
output_line(ctx, "#define %s %s%s%s%s", varname, usage_str,
arrayleft, index_str, arrayright);
} // else
pop_output(ctx);
} // else
} // if

0 comments on commit 473e42c

Please sign in to comment.