diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Context.hpp b/include/Nazara/OpenGLRenderer/Wrapper/Context.hpp index d2cc4248f..fca467789 100644 --- a/include/Nazara/OpenGLRenderer/Wrapper/Context.hpp +++ b/include/Nazara/OpenGLRenderer/Wrapper/Context.hpp @@ -163,6 +163,7 @@ namespace Nz::GL inline void NotifyTextureDestruction(GLuint texture) const; inline void NotifyVertexArrayDestruction(GLuint vao) const; + template void PrintFunctionCall(std::size_t funcIndex, Args... args) const; bool ProcessErrorStack() const; inline void ResetColorWriteMasks() const; diff --git a/src/Nazara/OpenGLRenderer/Wrapper/Context.cpp b/src/Nazara/OpenGLRenderer/Wrapper/Context.cpp index 118bedcc5..dad354979 100644 --- a/src/Nazara/OpenGLRenderer/Wrapper/Context.cpp +++ b/src/Nazara/OpenGLRenderer/Wrapper/Context.cpp @@ -22,6 +22,12 @@ namespace Nz::GL namespace { + constexpr std::array s_functionNames = { +#define NAZARA_OPENGLRENDERER_FUNC(name, sig) #name, + NAZARA_OPENGLRENDERER_FOREACH_GLES_FUNC(NAZARA_OPENGLRENDERER_FUNC, NAZARA_OPENGLRENDERER_FUNC) +#undef NAZARA_OPENGLRENDERER_FUNC + }; + template struct GLWrapper; @@ -41,13 +47,15 @@ namespace Nz::GL { funcPtr(std::forward(args)...); - context->ProcessErrorStack(); + if (!context->ProcessErrorStack()) + context->PrintFunctionCall(FuncIndex, std::forward(args)...); } else { Ret r = funcPtr(std::forward(args)...); - context->ProcessErrorStack(); + if (!context->ProcessErrorStack()) + context->PrintFunctionCall(FuncIndex, std::forward(args)...); return r; } @@ -565,6 +573,29 @@ namespace Nz::GL return true; } + template + void Context::PrintFunctionCall(std::size_t funcIndex, Args... args) const + { + std::stringstream ss; + ss << s_functionNames[funcIndex] << "("; + if constexpr (sizeof...(args) > 0) + { + bool first = true; + auto PrintParam = [&](auto value) + { + if (!first) + ss << ", "; + + ss << +value; + first = false; + }; + + (PrintParam(args), ...); + } + ss << ")"; + NazaraDebug(ss.str()); + } + bool Context::ProcessErrorStack() const { assert(GetCurrentContext() == this);