void application::perform_idle() { on_update(); if (m_ready) { begin_render(); on_render(); end_render(); } }
bool RenderChain::render(const void *data, unsigned width, unsigned height, unsigned pitch, unsigned rotation) { start_render(); unsigned current_width = width, current_height = height; unsigned out_width = 0, out_height = 0; convert_geometry(passes[0].info, out_width, out_height, current_width, current_height, final_viewport); blit_to_texture(data, width, height, pitch); // Grab back buffer. LPDIRECT3DSURFACE back_buffer; dev->GetRenderTarget(0, &back_buffer); // In-between render target passes. for (unsigned i = 0; i < passes.size() - 1; i++) { Pass &from_pass = passes[i]; Pass &to_pass = passes[i + 1]; LPDIRECT3DSURFACE target; to_pass.tex->GetSurfaceLevel(0, &target); dev->SetRenderTarget(0, target); convert_geometry(from_pass.info, out_width, out_height, current_width, current_height, final_viewport); // Clear out whole FBO. D3DVIEWPORT viewport = {0}; viewport.Width = to_pass.info.tex_w; viewport.Height = to_pass.info.tex_h; viewport.MinZ = 0.0f; viewport.MaxZ = 1.0f; dev->SetViewport(&viewport); dev->Clear(0, 0, D3DCLEAR_TARGET, 0, 1, 0); viewport.Width = out_width; viewport.Height = out_height; set_viewport(viewport); set_vertices(from_pass, current_width, current_height, out_width, out_height, out_width, out_height, 0); render_pass(from_pass, i + 1); current_width = out_width; current_height = out_height; target->Release(); } // Final pass dev->SetRenderTarget(0, back_buffer); Pass &last_pass = passes.back(); convert_geometry(last_pass.info, out_width, out_height, current_width, current_height, final_viewport); set_viewport(final_viewport); set_vertices(last_pass, current_width, current_height, out_width, out_height, final_viewport.Width, final_viewport.Height, rotation); render_pass(last_pass, passes.size()); frame_count++; back_buffer->Release(); end_render(); set_shaders(fStock, vStock); set_cg_mvp(vStock, final_viewport.Width, final_viewport.Height, 0); return true; }