OpenGLRenderer: Print GL call and parameters on failure
This commit is contained in:
parent
6af0904849
commit
f2c83df8ff
|
|
@ -163,6 +163,7 @@ namespace Nz::GL
|
|||
inline void NotifyTextureDestruction(GLuint texture) const;
|
||||
inline void NotifyVertexArrayDestruction(GLuint vao) const;
|
||||
|
||||
template<typename... Args> void PrintFunctionCall(std::size_t funcIndex, Args... args) const;
|
||||
bool ProcessErrorStack() const;
|
||||
|
||||
inline void ResetColorWriteMasks() const;
|
||||
|
|
|
|||
|
|
@ -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<typename FuncType, std::size_t FuncIndex, typename>
|
||||
struct GLWrapper;
|
||||
|
||||
|
|
@ -41,13 +47,15 @@ namespace Nz::GL
|
|||
{
|
||||
funcPtr(std::forward<Args>(args)...);
|
||||
|
||||
context->ProcessErrorStack();
|
||||
if (!context->ProcessErrorStack())
|
||||
context->PrintFunctionCall(FuncIndex, std::forward<Args>(args)...);
|
||||
}
|
||||
else
|
||||
{
|
||||
Ret r = funcPtr(std::forward<Args>(args)...);
|
||||
|
||||
context->ProcessErrorStack();
|
||||
if (!context->ProcessErrorStack())
|
||||
context->PrintFunctionCall(FuncIndex, std::forward<Args>(args)...);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
|
@ -565,6 +573,29 @@ namespace Nz::GL
|
|||
return true;
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue