]> git.tdb.fi Git - r2c2.git/commitdiff
Only use postprocessors that can be supported
authorMikko Rasa <tdb@tdb.fi>
Tue, 7 Apr 2015 12:19:27 +0000 (15:19 +0300)
committerMikko Rasa <tdb@tdb.fi>
Tue, 7 Apr 2015 12:19:27 +0000 (15:19 +0300)
source/3d/view.cpp
source/3d/view.h

index 9fd5684f6ab50851f82c42c8ba10a25da16b3abc..40a168f86fc7e5986dd14db78de668b0680c3900 100644 (file)
@@ -15,8 +15,7 @@ View3D::View3D(Layout3D &l, unsigned w, unsigned h):
        height(h),
        pipeline(w, h),
        sky(layout.get_catalogue()),
-       shadow(4096, layout.get_scene(), layout.get_sun()),
-       ambient_occlusion(w, h, 100)
+       shadow(4096, layout.get_scene(), layout.get_sun())
 {
        pipeline.set_hdr(true);
        pipeline.set_camera(&camera);
@@ -36,9 +35,28 @@ View3D::View3D(Layout3D &l, unsigned w, unsigned h):
        pass->set_depth_test(&GL::DepthTest::lequal());
        pass->set_blend(&GL::Blend::alpha());
 
-       pipeline.add_postprocessor(ambient_occlusion);
-       colorcurve.set_srgb();
-       pipeline.add_postprocessor(colorcurve);
+       try
+       {
+               ambient_occlusion = new GL::AmbientOcclusion(w, h, 100);
+               pipeline.add_postprocessor(*ambient_occlusion);
+       }
+       catch(...)
+       {
+               delete ambient_occlusion;
+               ambient_occlusion = 0;
+       }
+
+       try
+       {
+               colorcurve = new GL::ColorCurve;
+               colorcurve->set_srgb();
+               pipeline.add_postprocessor(*colorcurve);
+       }
+       catch(...)
+       {
+               delete colorcurve;
+               colorcurve = 0;
+       }
 
        update_shadow_area();
        layout.get_layout().signal_object_added.connect(sigc::hide(sigc::mem_fun(this, &View3D::update_shadow_area)));
@@ -51,6 +69,12 @@ View3D::View3D(Layout3D &l, unsigned w, unsigned h):
        view_all();
 }
 
+View3D::~View3D()
+{
+       delete colorcurve;
+       delete ambient_occlusion;
+}
+
 Ray View3D::create_ray(int x, int y) const
 {
        return create_ray(x*2.0f/width-1.0f, y*2.0f/height-1.0f);
index 5be2d8c0adf383bf56714e113845b96006270de9..a191a150ec60e1cd9819ed2ce8e7bd9a1f9db884 100644 (file)
@@ -22,11 +22,12 @@ protected:
        Msp::GL::Pipeline pipeline;
        Sky3D sky;
        Msp::GL::ShadowMap shadow;
-       Msp::GL::ColorCurve colorcurve;
-       Msp::GL::AmbientOcclusion ambient_occlusion;
+       Msp::GL::ColorCurve *colorcurve;
+       Msp::GL::AmbientOcclusion *ambient_occlusion;
 
 public:
        View3D(Layout3D &, unsigned, unsigned);
+       ~View3D();
 
        Layout3D &get_layout() const { return layout; }
        Msp::GL::Camera &get_camera() { return camera; }