Support printing context to gfx::check_error
This commit is contained in:
parent
38f704c3ed
commit
99e72c552b
2 changed files with 6 additions and 3 deletions
|
|
@ -7,6 +7,6 @@ namespace psemek::gfx
|
||||||
|
|
||||||
std::string_view gl_error_str(unsigned int e);
|
std::string_view gl_error_str(unsigned int e);
|
||||||
|
|
||||||
void check_error();
|
void check_error(std::string_view context = "");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,12 +24,15 @@ namespace psemek::gfx
|
||||||
return "(unknown)";
|
return "(unknown)";
|
||||||
}
|
}
|
||||||
|
|
||||||
void check_error()
|
void check_error(std::string_view context)
|
||||||
{
|
{
|
||||||
|
if (context.empty())
|
||||||
|
context = "OpenGL error: ";
|
||||||
|
|
||||||
auto e = gl::GetError();
|
auto e = gl::GetError();
|
||||||
|
|
||||||
if (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)));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue