diff --git a/libs/gfx/include/psemek/gfx/error.hpp b/libs/gfx/include/psemek/gfx/error.hpp index 85e753f4..ee577d79 100644 --- a/libs/gfx/include/psemek/gfx/error.hpp +++ b/libs/gfx/include/psemek/gfx/error.hpp @@ -7,6 +7,6 @@ namespace psemek::gfx std::string_view gl_error_str(unsigned int e); - void check_error(); + void check_error(std::string_view context = ""); } diff --git a/libs/gfx/source/error.cpp b/libs/gfx/source/error.cpp index 31bd834b..fa9a7c34 100644 --- a/libs/gfx/source/error.cpp +++ b/libs/gfx/source/error.cpp @@ -24,12 +24,15 @@ namespace psemek::gfx return "(unknown)"; } - void check_error() + void check_error(std::string_view context) { + if (context.empty()) + context = "OpenGL error: "; + auto e = gl::GetError(); if (e != gl::GetError()) - throw std::runtime_error(util::to_string("OpenGL error: ", gl_error_str(e))); + throw std::runtime_error(util::to_string(context, gl_error_str(e))); } }