erebus
diff liberebus/src/scene.cc @ 28:4a0a288ffb27
phong/lafortune BRDF
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Fri, 06 Jun 2014 14:39:40 +0300 |
parents | 56d504cc555a |
children | 9d6368850fe1 |
line diff
1.1 --- a/liberebus/src/scene.cc Mon Jun 02 00:53:01 2014 +0300 1.2 +++ b/liberebus/src/scene.cc Fri Jun 06 14:39:40 2014 +0300 1.3 @@ -140,9 +140,22 @@ 1.4 1.5 bool Scene::load(FILE *fp) 1.6 { 1.7 - static char buf[256]; 1.8 + static char buf[4096]; 1.9 + int offset = 0; 1.10 1.11 - while(fgets(buf, sizeof buf, fp)) { 1.12 + while(fgets(buf + offset, sizeof buf - offset, fp)) { 1.13 + // handle line continuations 1.14 + int len = strlen(buf); 1.15 + if(strcmp(buf + len - 2, "\\\n") == 0 || strcmp(buf + len - 2, "\\\r") == 0) { 1.16 + offset = len - 2; 1.17 + continue; 1.18 + } 1.19 + if(strcmp(buf + len - 3, "\\\r\n") == 0) { 1.20 + offset = len - 3; 1.21 + continue; 1.22 + } 1.23 + offset = 0; 1.24 + 1.25 char *line = strip_wspace(buf); 1.26 if(!line || !*line || *line == '#') { 1.27 continue; 1.28 @@ -198,6 +211,13 @@ 1.29 brdf = new LambertRefl; 1.30 if(!composite) break; 1.31 1.32 + } else if(strcmp(argv[i], "phong") == 0) { 1.33 + if(composite && brdf) { 1.34 + composite->add_brdf(brdf, weight); 1.35 + } 1.36 + brdf = new PhongRefl; 1.37 + if(!composite) break; 1.38 + 1.39 } else if(strcmp(argv[i], "mirror") == 0) { 1.40 if(composite && brdf) { 1.41 composite->add_brdf(brdf, weight);