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:
parent
9946c17a23
commit
a643d0fc3a
|
|
@ -95,6 +95,7 @@ namespace Nz::GL
|
|||
{
|
||||
ContextType type = ContextType::OpenGL_ES;
|
||||
bool doubleBuffering = true;
|
||||
bool wrapErrorHandling = false;
|
||||
unsigned int bitsPerPixel = 32;
|
||||
unsigned int depthBits = 24;
|
||||
unsigned int glMajorVersion = 0;
|
||||
|
|
|
|||
|
|
@ -26,6 +26,9 @@ namespace Nz
|
|||
GL::ContextParams params;
|
||||
params.type = loader.GetPreferredContextType();
|
||||
|
||||
#ifdef NAZARA_OPENGLRENDERER_DEBUG
|
||||
params.wrapErrorHandling = true;
|
||||
#endif
|
||||
|
||||
m_referenceContext = loader.CreateContext(this, params);
|
||||
if (!m_referenceContext)
|
||||
|
|
|
|||
|
|
@ -44,6 +44,9 @@ namespace Nz
|
|||
OpenGLDevice& device = static_cast<OpenGLDevice&>(*m_owner.GetRenderDevice());
|
||||
|
||||
GL::ContextParams contextParams;
|
||||
#ifdef NAZARA_OPENGLRENDERER_DEBUG
|
||||
contextParams.wrapErrorHandling = true;
|
||||
#endif
|
||||
//TODO: Pass render window parameters to context
|
||||
|
||||
m_context = device.CreateContext(contextParams, dummySurface->GetWindowHandle());
|
||||
|
|
|
|||
|
|
@ -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
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue