]> git.tdb.fi Git - libs/gl.git/commitdiff
Use a persistent Renderer in View
authorMikko Rasa <tdb@tdb.fi>
Sun, 3 Nov 2019 17:41:37 +0000 (19:41 +0200)
committerMikko Rasa <tdb@tdb.fi>
Sun, 3 Nov 2019 17:41:37 +0000 (19:41 +0200)
source/view.cpp
source/view.h

index ad6e266c4468ba477e9f8f72ad55423fce8ee8b1..8c77054f976b5f77cca21c42bcf0fa3126a8112c 100644 (file)
@@ -9,9 +9,15 @@ namespace GL {
 View::View(Framebuffer &t):
        target(t),
        camera(0),
-       content(0)
+       content(0),
+       internal_renderer(0)
 { }
 
+View::~View()
+{
+       delete internal_renderer;
+}
+
 void View::set_camera(Camera *c)
 {
        camera = c;
@@ -26,8 +32,9 @@ void View::set_content(Renderable *r)
 
 void View::render()
 {
-       Renderer renderer;
-       render(renderer);
+       if(!internal_renderer)
+               internal_renderer = new Renderer;
+       render(*internal_renderer);
 }
 
 void View::render(Renderer &renderer)
index b34ae5c75abf070ecd1f9100548744d773b9b7d2..df623c3a7d88b632e89a397609da0fba3d42d6c7 100644 (file)
@@ -20,10 +20,12 @@ protected:
        Framebuffer &target;
        Camera *camera;
        Renderable *content;
+       Renderer *internal_renderer;
 
        View(Framebuffer &);
-
 public:
+       virtual ~View();
+
        virtual unsigned get_width() const { return target.get_width(); }
        virtual unsigned get_height() const { return target.get_height(); }
        float get_aspect_ratio() const { return static_cast<float>(get_width())/get_height(); }