From 1b6bc9a449c967ba8f0991ac6c61bd4e69b6e628 Mon Sep 17 00:00:00 2001 From: lisyarus Date: Wed, 21 Jul 2021 23:46:30 +0300 Subject: [PATCH] Add name parameter to framebuffer::assert_complete for better error reporting --- libs/gfx/include/psemek/gfx/framebuffer.hpp | 4 +++- libs/gfx/source/framebuffer.cpp | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/libs/gfx/include/psemek/gfx/framebuffer.hpp b/libs/gfx/include/psemek/gfx/framebuffer.hpp index 74e7595d..16fe1d2c 100644 --- a/libs/gfx/include/psemek/gfx/framebuffer.hpp +++ b/libs/gfx/include/psemek/gfx/framebuffer.hpp @@ -6,6 +6,8 @@ #include #include +#include + namespace psemek::gfx { @@ -50,7 +52,7 @@ namespace psemek::gfx GLenum status() const; bool complete() const; - void assert_complete() const; + void assert_complete(std::string_view name = {}) const; template void read_pixels(basic_pixmap & p) const diff --git a/libs/gfx/source/framebuffer.cpp b/libs/gfx/source/framebuffer.cpp index bf597532..12dcfbc1 100644 --- a/libs/gfx/source/framebuffer.cpp +++ b/libs/gfx/source/framebuffer.cpp @@ -1,5 +1,7 @@ #include +#include + namespace psemek::gfx { @@ -178,10 +180,10 @@ namespace psemek::gfx return status() == gl::FRAMEBUFFER_COMPLETE; } - void framebuffer::assert_complete() const + void framebuffer::assert_complete(std::string_view name) const { if (auto s = status(); s != gl::FRAMEBUFFER_COMPLETE) - throw std::runtime_error("Framebuffer incomplete: " + framebuffer_status_string(s)); + throw std::runtime_error(util::to_string("Framebuffer ", name, name.empty() ? "" : " ", "incomplete: ", framebuffer_status_string(s))); } framebuffer::framebuffer(std::nullptr_t)