Implemented LOOP/ENDLOOP in GLSL profile. trunk
authorRyan C. Gordon <icculus@icculus.org>
Mon, 07 Apr 2008 20:04:24 -0400
branchtrunk
changeset 124 63fb1b69fda5
parent 123 45c694d8d318
child 125 9d7952ff149d
Implemented LOOP/ENDLOOP in GLSL profile. I _think_ this should work, we'll see.
mojoshader.c
--- a/mojoshader.c	Mon Apr 07 13:18:31 2008 -0400
+++ b/mojoshader.c	Mon Apr 07 20:04:24 2008 -0400
@@ -2349,8 +2349,10 @@
 
 static void emit_GLSL_LOOP(Context *ctx)
 {
-    //fail(ctx, "unimplemented.");  // !!! FIXME
-    output_line(ctx, "for (int aL = BLAH, BLAH, BLAH) {");
+    const char *varname = get_GLSL_sourcearg_varname(ctx, 1);
+    assert(ctx->source_args[0].regnum == 0);  // in case they add aL1 someday.
+    output_line(ctx, "for (int aL = %s.y, const int aLend = %s.x+%s.y; aL < aLend; aL += %s.z) {",
+                varname, varname, varname, varname);
     ctx->indent++;
 } // emit_GLSL_LOOP
 
@@ -2367,7 +2369,6 @@
 
 static void emit_GLSL_ENDLOOP(Context *ctx)
 {
-    //fail(ctx, "unimplemented.");  // !!! FIXME
     ctx->indent--;
     output_line(ctx, "}");
 } // emit_GLSL_ENDLOOP