Support printing context to gfx::check_error

This commit is contained in:
Nikita Lisitsa 2021-05-29 18:38:28 +03:00
parent 38f704c3ed
commit 99e72c552b
2 changed files with 6 additions and 3 deletions

View file

@ -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 = "");
}

View file

@ -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)));
}
}