]> git.tdb.fi Git - libs/gl.git/commitdiff
Create a function for applying framebuffer state in Renderer
authorMikko Rasa <tdb@tdb.fi>
Wed, 12 Jan 2022 20:18:09 +0000 (22:18 +0200)
committerMikko Rasa <tdb@tdb.fi>
Wed, 12 Jan 2022 20:18:09 +0000 (22:18 +0200)
source/render/renderer.cpp
source/render/renderer.h

index 4beb2da7eca300d13450806b65d2eb503cd71f8e..a235a42b416e3b6a20429062e44b0aadf7135226 100644 (file)
@@ -241,11 +241,7 @@ void Renderer::set_object_lod_bias(unsigned b)
 
 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);
 }
@@ -295,6 +291,16 @@ void Renderer::end_query(const QueryPool &pool, unsigned index)
        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();
@@ -302,9 +308,7 @@ void Renderer::apply_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);
index f08ea0b2d5bfa305c0ab1af8aeacf980e5ef79b1..c176f87aa231664f5eccfb442317421737004f47 100644 (file)
@@ -199,6 +199,7 @@ public:
        void end_query(const QueryPool &, unsigned);
 
 private:
+       void apply_framebuffer();
        void apply_state();
 };