]> git.tdb.fi Git - libs/gl.git/commitdiff
Set a sensible projection matrix when there's no camera
authorMikko Rasa <tdb@tdb.fi>
Tue, 6 Dec 2016 21:31:40 +0000 (23:31 +0200)
committerMikko Rasa <tdb@tdb.fi>
Wed, 7 Dec 2016 00:28:31 +0000 (02:28 +0200)
source/renderer.cpp

index c8972934cb304d34b22ed3a2f68147c7b7d74c48..c744ac5a825009f588c305657f7938daf97b7178 100644 (file)
@@ -33,6 +33,8 @@ Renderer::Renderer(const Camera *c):
 
        if(c)
                set_camera(*c);
+       else
+               standard_shdata.uniform("projection_matrix", Matrix());
 }
 
 Renderer::~Renderer()
@@ -169,7 +171,10 @@ void Renderer::pop_state()
        bool camera_changed = (state->camera!=old_camera);
        if(camera_changed)
        {
-               standard_shdata.uniform("projection_matrix", state->camera->get_projection_matrix());
+               if(state->camera)
+                       standard_shdata.uniform("projection_matrix", state->camera->get_projection_matrix());
+               else
+                       standard_shdata.uniform("projection_matrix", Matrix());
                changed |= STANDARD_SHDATA|LEGACY_PROJECTION;
        }
        /* This actually should compare the relevant matrices rather than check for