dungeon_crawler
diff prototype/src/main.cc @ 60:aa86119e3295
added multipass deferred
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Tue, 25 Sep 2012 06:19:37 +0300 |
parents | f9b8bbebc9b3 |
children | 7f52d6310317 |
line diff
1.1 --- a/prototype/src/main.cc Fri Sep 21 05:28:45 2012 +0300 1.2 +++ b/prototype/src/main.cc Tue Sep 25 06:19:37 2012 +0300 1.3 @@ -11,6 +11,7 @@ 1.4 #include "tileset.h" 1.5 #include "renderer.h" 1.6 #include "renderer_deferred.h" 1.7 +#include "renderer_multipass.h" 1.8 #include "cmdcon.h" 1.9 #include "cfg.h" 1.10 #include "timer.h" 1.11 @@ -117,15 +118,52 @@ 1.12 } 1.13 } 1.14 1.15 - rend = new DeferredRenderer(); 1.16 - if(!cfg.use_deferred || !rend->init(xsz, ysz)) { 1.17 - printf("falling back to crappy renderer...\n"); 1.18 + switch(cfg.rend) { 1.19 + case Config::Renderer::mrt: 1.20 + rend = new DeferredRenderer; 1.21 + if(!rend->init(xsz, ysz)) { 1.22 + fprintf(stderr, "failed to initialize deferred mrt renderer\n"); 1.23 + delete rend; 1.24 + return false; 1.25 + } 1.26 + break; 1.27 1.28 - rend = new FwdRenderer(); 1.29 + case Config::Renderer::multipass: 1.30 + rend = new MultipassRenderer; 1.31 if(!rend->init(xsz, ysz)) { 1.32 - fprintf(stderr, "failed to create renderer\n"); 1.33 + fprintf(stderr, "failed to initialize multipass deferred renderer\n"); 1.34 + delete rend; 1.35 return false; 1.36 } 1.37 + break; 1.38 + 1.39 + case Config::Renderer::fwd: 1.40 + rend = new FwdRenderer; 1.41 + if(!rend->init(xsz, ysz)) { 1.42 + fprintf(stderr, "failed to initialize forward renderer\n"); 1.43 + delete rend; 1.44 + return false; 1.45 + } 1.46 + break; 1.47 + 1.48 + default: 1.49 + // try each in turn falling back to progressively worse renderers 1.50 + rend = new DeferredRenderer; 1.51 + if(!rend->init(xsz, ysz)) { 1.52 + printf("falling back to multipass renderer...\n"); 1.53 + 1.54 + delete rend; 1.55 + rend = new MultipassRenderer(); 1.56 + if(!rend->init(xsz, ysz)) { 1.57 + printf("falling back to crappy renderer...\n"); 1.58 + 1.59 + rend = new FwdRenderer(); 1.60 + if(!rend->init(xsz, ysz)) { 1.61 + fprintf(stderr, "failed to create renderer\n"); 1.62 + return false; 1.63 + } 1.64 + } 1.65 + } 1.66 } 1.67 1.68 if(!init_cmdcon()) {