void Renderer::clear(const ClearValue *values)
{
- const State &state = get_state();
-
- pipeline_state.set_framebuffer(state.framebuffer);
- pipeline_state.set_viewport(state.viewport);
- pipeline_state.set_scissor(state.scissor);
+ apply_framebuffer();
commands.use_pipeline(&pipeline_state);
commands.clear(values);
}
commands.end_query(pool, index);
}
+void Renderer::apply_framebuffer()
+{
+ const State &state = get_state();
+
+ pipeline_state.set_framebuffer(state.framebuffer);
+ static const Rect default_rect = Rect::max();
+ pipeline_state.set_viewport(state.viewport ? *state.viewport : default_rect);
+ pipeline_state.set_scissor(state.scissor ? *state.scissor : default_rect);
+}
+
void Renderer::apply_state()
{
const State &state = get_state();
if(!state.shprog)
throw invalid_operation("Renderer::apply_state");
- pipeline_state.set_framebuffer(state.framebuffer);
- pipeline_state.set_viewport(state.viewport);
- pipeline_state.set_scissor(state.scissor);
+ apply_framebuffer();
bool shprog_changed = (state.shprog!=pipeline_state.get_shader_program());
pipeline_state.set_shader_program(state.shprog);