]> git.tdb.fi Git - libs/gl.git/commitdiff
Refresh lighting and culling uniforms if the camera changes in pop_state
authorMikko Rasa <tdb@tdb.fi>
Mon, 5 Dec 2016 17:50:48 +0000 (19:50 +0200)
committerMikko Rasa <tdb@tdb.fi>
Mon, 5 Dec 2016 17:50:48 +0000 (19:50 +0200)
source/renderer.cpp

index e57967d9c46b227c5a9bad4da50c7af1320b1864..c8972934cb304d34b22ed3a2f68147c7b7d74c48 100644 (file)
@@ -166,12 +166,16 @@ void Renderer::pop_state()
        }
        shdata_applied = min<unsigned>(shdata_applied, shdata_stack.size());
        changed |= MATRIX;
-       if(state->camera!=old_camera)
+       bool camera_changed = (state->camera!=old_camera);
+       if(camera_changed)
        {
                standard_shdata.uniform("projection_matrix", state->camera->get_projection_matrix());
                changed |= STANDARD_SHDATA|LEGACY_PROJECTION;
        }
-       if(state->lighting!=old_lighting)
+       /* This actually should compare the relevant matrices rather than check for
+       camera, but in practice lighting and clipping is set right after the camera
+       and a boolean check is much faster than matrix comparison. */
+       if(state->lighting!=old_lighting || camera_changed)
        {
                if(state->lighting)
                {
@@ -180,7 +184,7 @@ void Renderer::pop_state()
                }
                changed |= LEGACY_LIGHTING;
        }
-       if(state->clipping!=old_clipping)
+       if(state->clipping!=old_clipping || camera_changed)
        {
                if(state->clipping)
                {