]> git.tdb.fi Git - libs/gl.git/commitdiff
Restore old samples value if create_targets fails
authorMikko Rasa <tdb@tdb.fi>
Thu, 28 Nov 2013 12:51:23 +0000 (14:51 +0200)
committerMikko Rasa <tdb@tdb.fi>
Thu, 28 Nov 2013 12:51:23 +0000 (14:51 +0200)
An application could use try-catch to check if a certain level of
multisampling is available, and leaving samples to that value would
interfere with later operations.

source/pipeline.cpp

index 0df03ca7df7231931874355f855de9c3284cd148..d7e175de7185fe39fcf890c2c8eeb89c8986346a 100644 (file)
@@ -49,8 +49,17 @@ void Pipeline::set_multisample(unsigned s)
        if(s==samples)
                return;
 
+       unsigned old_samples = samples;
        samples = s;
-       create_targets(1);
+       try
+       {
+               create_targets(1);
+       }
+       catch(...)
+       {
+               samples = old_samples;
+               throw;
+       }
 }
 
 void Pipeline::set_camera(const Camera *c)