OpenGLRenderer: Improve error handling (fixes Windows/x86 compilation)

Template specialization was failing because OpenGL function type have __stdcall convention on Windows/32bits
This commit is contained in:
Jérôme Leclercq
2021-11-02 09:43:30 +01:00
parent 9946c17a23
commit a643d0fc3a
4 changed files with 12 additions and 7 deletions

View File

@@ -26,7 +26,7 @@ namespace Nz::GL
struct GLWrapper;
template<typename FuncType, std::size_t FuncIndex, typename Ret, typename... Args>
struct GLWrapper<FuncType, FuncIndex, Ret(Args...)>
struct GLWrapper<FuncType, FuncIndex, Ret(GL_APIENTRYP)(Args...)>
{
static auto WrapErrorHandling()
{
@@ -37,8 +37,6 @@ namespace Nz::GL
FuncType funcPtr = reinterpret_cast<FuncType>(context->GetFunctionByIndex(FuncIndex));
context->ClearErrorStack();
if constexpr (std::is_same_v<Ret, void>)
{
funcPtr(std::forward<Args>(args)...);
@@ -79,16 +77,14 @@ namespace Nz::GL
func = reinterpret_cast<FuncType>(originalFuncPtr);
#if defined(NAZARA_OPENGLRENDERER_DEBUG) && (!defined(NAZARA_COMPILER_MSVC) || defined(NAZARA_PLATFORM_x64))
if (func)
if (func && wrapErrorHandling)
{
if (std::strcmp(funcName, "glGetError") != 0) //< Prevent infinite recursion
{
using Wrapper = GLWrapper<FuncType, FuncIndex, std::remove_pointer_t<FuncType>>;
using Wrapper = GLWrapper<FuncType, FuncIndex, FuncType>;
func = Wrapper::WrapErrorHandling();
}
}
#endif
if (!func)
{
@@ -105,6 +101,7 @@ namespace Nz::GL
}
Context& context;
bool wrapErrorHandling = false;
};
@@ -326,6 +323,7 @@ namespace Nz::GL
}
SymbolLoader loader(*this);
loader.wrapErrorHandling = params.wrapErrorHandling;
try
{