From 99e72c552b4510615dcaf71336ef6bb560f4d918 Mon Sep 17 00:00:00 2001 From: lisyarus Date: Sat, 29 May 2021 18:38:28 +0300 Subject: [PATCH] Support printing context to gfx::check_error --- libs/gfx/include/psemek/gfx/error.hpp | 2 +- libs/gfx/source/error.cpp | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) 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))); } }