Advertisement
RaZgRiZ

inline tex commands

Aug 1st, 2020
2,226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.49 KB | None | 0 0
  1. while(cmds)
  2.     {
  3.         PARSETEXCOMMANDS(cmds);
  4.         if(d.compressed) goto compressed;
  5.         if(matchstring(cmd, len, "mad")) texmad(d, parsevec(arg[0]), parsevec(arg[1]));
  6.         else if(matchstring(cmd, len, "colorify")) texcolorify(d, parsevec(arg[0]), parsevec(arg[1]));
  7.         else if(matchstring(cmd, len, "colormask")) texcolormask(d, parsevec(arg[0]), *arg[1] ? parsevec(arg[1]) : vec(1, 1, 1));
  8.         else if(matchstring(cmd, len, "normal"))
  9.         {
  10.             int emphasis = atoi(arg[0]);
  11.             texnormal(d, emphasis > 0 ? emphasis : 3);
  12.         }
  13.         else if(matchstring(cmd, len, "dup")) texdup(d, atoi(arg[0]), atoi(arg[1]));
  14.         else if(matchstring(cmd, len, "offset")) texoffset(d, atoi(arg[0]), atoi(arg[1]));
  15.         else if(matchstring(cmd, len, "rotate")) texrotate(d, atoi(arg[0]), tex ? tex->type : 0);
  16.         else if(matchstring(cmd, len, "reorient")) texreorient(d, atoi(arg[0])>0, atoi(arg[1])>0, atoi(arg[2])>0, tex ? tex->type : TEX_DIFFUSE);
  17.         else if(matchstring(cmd, len, "mix")) texmix(d, *arg[0] ? atoi(arg[0]) : -1, *arg[1] ? atoi(arg[1]) : -1, *arg[2] ? atoi(arg[2]) : -1, *arg[3] ? atoi(arg[3]) : -1);
  18.         else if(matchstring(cmd, len, "grey")) texgrey(d);
  19.         else if(matchstring(cmd, len, "blur"))
  20.         {
  21.             int emphasis = atoi(arg[0]), repeat = atoi(arg[1]);
  22.             texblur(d, emphasis > 0 ? clamp(emphasis, 1, 2) : 1, repeat > 0 ? repeat : 1);
  23.         }
  24.         else if(matchstring(cmd, len, "premul")) texpremul(d);
  25.         else if(matchstring(cmd, len, "agrad")) texagrad(d, atof(arg[0]), atof(arg[1]), atof(arg[2]), atof(arg[3]));
  26.         else if(matchstring(cmd, len, "compress") || matchstring(cmd, len, "dds"))
  27.         {
  28.             int scale = atoi(arg[0]);
  29.             if(scale <= 0) scale = scaledds;
  30.             if(compress) *compress = scale;
  31.         }
  32.         else if(matchstring(cmd, len, "nocompress"))
  33.         {
  34.             if(compress) *compress = -1;
  35.         }
  36.         else if(matchstring(cmd, len, "thumbnail"))
  37.         {
  38.             int w = atoi(arg[0]), h = atoi(arg[1]);
  39.             if(w <= 0 || w > (1<<12)) w = 64;
  40.             if(h <= 0 || h > (1<<12)) h = w;
  41.             if(d.w > w || d.h > h) scaleimage(d, w, h);
  42.         }
  43.         else
  44.     compressed:
  45.         if(matchstring(cmd, len, "mirror"))
  46.         {
  47.             if(wrap) *wrap |= 0x300;
  48.         }
  49.         else if(matchstring(cmd, len, "noswizzle"))
  50.         {
  51.             if(wrap) *wrap |= 0x10000;
  52.         }
  53.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement