77#include < auxBitplaneAttrib.h>
88#include < transparencyAttrib.h>
99
10+ #include < spdlog/fmt/fmt.h>
11+
1012#include " render_pipeline/rpcore/globals.h"
1113#include " render_pipeline/rppanda/showbase/showbase.h"
1214
@@ -26,7 +28,7 @@ struct RenderTarget::Impl
2628{
2729 Impl (RenderTarget& self);
2830
29- int percent_to_number (const std::string& v);
31+ int percent_to_number (const std::string& v) const NOEXCEPT ;
3032
3133 void create_buffer (void );
3234 void compute_size_from_constraint (void );
@@ -81,9 +83,17 @@ RenderTarget::Impl::Impl(RenderTarget& self): self(self)
8183 });
8284}
8385
84- int RenderTarget::Impl::percent_to_number (const std::string& v)
86+ int RenderTarget::Impl::percent_to_number (const std::string& v) const NOEXCEPT
8587{
86- return percent_to_number_map.at (v);
88+ try
89+ {
90+ return percent_to_number_map.at (v);
91+ }
92+ catch (...)
93+ {
94+ self.error (fmt::format (" Invalid percent: {}" , v));
95+ return -1 ;
96+ }
8797}
8898
8999void RenderTarget::Impl::create_buffer (void )
@@ -325,17 +335,17 @@ void RenderTarget::set_layers(int layers)
325335 impl_->layers_ = layers;
326336}
327337
328- void RenderTarget::set_size (int width, int height)
338+ void RenderTarget::set_size (int width, int height) NOEXCEPT
329339{
330340 impl_->size_constraint_ = LVecBase2i (width, height);
331341}
332342
333- void RenderTarget::set_size (int size)
343+ void RenderTarget::set_size (int size) NOEXCEPT
334344{
335345 impl_->size_constraint_ = LVecBase2i (size);
336346}
337347
338- void RenderTarget::set_size (const LVecBase2i& size)
348+ void RenderTarget::set_size (const LVecBase2i& size) NOEXCEPT
339349{
340350 impl_->size_constraint_ = size;
341351}
@@ -360,22 +370,22 @@ Texture* RenderTarget::get_aux_tex(size_t index) const
360370 return impl_->targets_ .at (std::string (" aux_" ) + std::to_string (index));
361371}
362372
363- const boost::optional<int >& RenderTarget::get_sort (void ) const
373+ const boost::optional<int >& RenderTarget::get_sort (void ) const NOEXCEPT
364374{
365375 return impl_->sort_ ;
366376}
367377
368- void RenderTarget::set_sort (int sort)
378+ void RenderTarget::set_sort (int sort) NOEXCEPT
369379{
370380 impl_->sort_ = sort;
371381}
372382
373- void RenderTarget::set_size (const std::string& width, const std::string& height)
383+ void RenderTarget::set_size (const std::string& width, const std::string& height) NOEXCEPT
374384{
375385 impl_->size_constraint_ = LVecBase2i (impl_->percent_to_number (width), impl_->percent_to_number (height));
376386}
377387
378- void RenderTarget::set_size (const std::string& size)
388+ void RenderTarget::set_size (const std::string& size) NOEXCEPT
379389{
380390 set_size (size, size);
381391}
0 commit comments