void DrawSVG::init() { // hardware renderer hardware_renderer = new HardwareRenderer(); // software renderer implementations software_renderer_imp = new SoftwareRendererImp(); software_renderer_ref = new SoftwareRendererRef(); software_renderer = software_renderer_imp; // use imp at launch // texture sampler implementations sampler_imp = new Sampler2DImp(); sampler_ref = new Sampler2DRef(); sampler = sampler_imp; // use imp at launch software_renderer_imp->set_tex_sampler(sampler_imp); software_renderer_ref->set_tex_sampler(sampler_ref); // generate mipmaps & set initial viewports for (size_t i = 0; i < tabs.size(); ++i) { viewport_imp.push_back(new ViewportImp()); viewport_ref.push_back(new ViewportRef()); // auto adjust auto_adjust(i); // set initial canvas_to_norm for imp using ref viewport_imp[i]->set_canvas_to_norm(viewport_ref[i]->get_canvas_to_norm()); // generate mipmaps regenerate_mipmap(i); } // set tab and transformation if tabs loaded current_tab = 0; // initial osd osd = "Software Renderer"; }
void DrawSVG::key_event(char key) { switch (key) { // reset view transformation case ' ': auto_adjust(current_tab); redraw(); break; // SSAA controls case '=': inc_sample_rate(); break; case '-': dec_sample_rate(); break; // switch between iml and ref renderer case 'R': if (software_renderer == software_renderer_imp) { software_renderer = software_renderer_ref; } else { software_renderer = software_renderer_imp; } setRenderMethod(Software); break; // switch between iml and ref sampler case ';': sampler = sampler_imp; regenerate_mipmap(current_tab); redraw(); break; case '\'': sampler = sampler_ref; regenerate_mipmap(current_tab); redraw(); break; // change render method // case 'S': // setRenderMethod( Software ); // break; // case 'H': // setRenderMethod( Hardware ); // break; // toggle diff case 'D': if (method == Software) { show_diff = !show_diff; redraw(); } break; // toggle zoom case 'Z': show_zoom = !show_zoom; break; // tab selection case '0': setTab(9); break; case '1': setTab(0); break; case '2': setTab(1); break; case '3': setTab(2); break; case '4': setTab(3); break; case '5': setTab(4); break; case '6': setTab(5); break; case '7': setTab(6); break; case '8': setTab(7); break; case '9': setTab(8); break; default: return; } }