X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Frenderer.cpp;h=e59949a3683f938797251a4a5d3f34a7ebbddc46;hp=19811146235ec6622c0917a1536190490597bff8;hb=463746f62d9b48f9fbbba3b2fcf7354067873e94;hpb=71240e5c5ef7165313664ee9fe81df95c0eff10b diff --git a/source/renderer.cpp b/source/renderer.cpp index 19811146..e59949a3 100644 --- a/source/renderer.cpp +++ b/source/renderer.cpp @@ -14,6 +14,7 @@ #include "texturing.h" #include "texunit.h" #include "vertexarray.h" +#include "vertexsetup.h" #include "windingtest.h" using namespace std; @@ -34,7 +35,10 @@ Renderer::Renderer(const Camera *c): if(c) set_camera(*c); else + { standard_shdata.uniform("projection_matrix", Matrix()); + standard_shdata.uniform("eye_world_matrix", Matrix()); + } } Renderer::~Renderer() @@ -53,6 +57,7 @@ void Renderer::set_camera(const Camera &c) { state->camera = &c; standard_shdata.uniform("projection_matrix", state->camera->get_projection_matrix()); + standard_shdata.uniform("eye_world_matrix", state->camera->get_view_matrix()); changed |= STANDARD_SHDATA|LEGACY_PROJECTION; set_matrix(state->camera->get_view_matrix()); } @@ -142,6 +147,11 @@ void Renderer::set_mesh(const Mesh *m) state->mesh = m; } +void Renderer::set_vertex_setup(const VertexSetup *vs) +{ + state->vertex_setup = vs; +} + void Renderer::set_winding_test(const WindingTest *w) { state->winding_test = w; @@ -173,9 +183,15 @@ void Renderer::pop_state() if(camera_changed) { if(state->camera) + { standard_shdata.uniform("projection_matrix", state->camera->get_projection_matrix()); + standard_shdata.uniform("eye_world_matrix", state->camera->get_view_matrix()); + } else + { standard_shdata.uniform("projection_matrix", Matrix()); + standard_shdata.uniform("eye_world_matrix", Matrix()); + } changed |= STANDARD_SHDATA|LEGACY_PROJECTION; } /* This actually should compare the relevant matrices rather than check for @@ -221,6 +237,7 @@ void Renderer::end() Lighting::unbind(); Clipping::unbind(); Program::unbind(); + VertexSetup::unbind(); Buffer::unbind_from(ELEMENT_ARRAY_BUFFER); WindingTest::unbind(); @@ -374,8 +391,15 @@ void Renderer::apply_state() state->mesh->bind(); } else + { Mesh::unbind(); + if(state->vertex_setup) + state->vertex_setup->bind(); + else + VertexSetup::unbind(); + } + if(state->winding_test) { if(state->reverse_winding) @@ -421,6 +445,7 @@ Renderer::State::State(): shprog(0), shdata_count(0), mesh(0), + vertex_setup(0), winding_test(0), reverse_winding(false) { }