mirror of
https://github.com/SFML/SFML.git
synced 2024-11-24 20:31:05 +08:00
Drain errors in [E]GLCheck via loop
This commit is contained in:
parent
7cec342b2b
commit
eb4a2dbe0f
@ -29,10 +29,15 @@
|
||||
////////////////////////////////////////////////////////////
|
||||
#include <SFML/Config.hpp>
|
||||
|
||||
#include <SFML/Graphics/GLExtensions.hpp>
|
||||
|
||||
#include <SFML/System/Err.hpp>
|
||||
|
||||
#include <filesystem>
|
||||
#include <string_view>
|
||||
#include <type_traits>
|
||||
|
||||
|
||||
namespace sf::priv
|
||||
{
|
||||
////////////////////////////////////////////////////////////
|
||||
@ -53,20 +58,28 @@ bool glCheckError(const std::filesystem::path& file, unsigned int line, std::str
|
||||
#ifdef SFML_DEBUG
|
||||
// In debug mode, perform a test on every OpenGL call
|
||||
// The lamdba allows us to call glCheck as an expression and acts as a single statement perfect for if/else statements
|
||||
#define glCheck(...) \
|
||||
[](auto&& glCheckInternalFunction) \
|
||||
{ \
|
||||
if constexpr (!std::is_void_v<decltype(glCheckInternalFunction())>) \
|
||||
{ \
|
||||
const auto glCheckInternalReturnValue = glCheckInternalFunction(); \
|
||||
sf::priv::glCheckError(__FILE__, static_cast<unsigned int>(__LINE__), #__VA_ARGS__); \
|
||||
return glCheckInternalReturnValue; \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
glCheckInternalFunction(); \
|
||||
sf::priv::glCheckError(__FILE__, static_cast<unsigned int>(__LINE__), #__VA_ARGS__); \
|
||||
} \
|
||||
#define glCheck(...) \
|
||||
[](auto&& glCheckInternalFunction) \
|
||||
{ \
|
||||
if (const GLenum glCheckInternalError = glGetError(); glCheckInternalError != GL_NO_ERROR) \
|
||||
sf::err() << "OpenGL error (" << glCheckInternalError << ") detected during glCheck call" << std::endl; \
|
||||
\
|
||||
if constexpr (!std::is_void_v<decltype(glCheckInternalFunction())>) \
|
||||
{ \
|
||||
const auto glCheckInternalReturnValue = glCheckInternalFunction(); \
|
||||
\
|
||||
while (!sf::priv::glCheckError(__FILE__, static_cast<unsigned int>(__LINE__), #__VA_ARGS__)) \
|
||||
/* no-op */; \
|
||||
\
|
||||
return glCheckInternalReturnValue; \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
glCheckInternalFunction(); \
|
||||
\
|
||||
while (!sf::priv::glCheckError(__FILE__, static_cast<unsigned int>(__LINE__), #__VA_ARGS__)) \
|
||||
/* no-op */; \
|
||||
} \
|
||||
}([&]() { return __VA_ARGS__; })
|
||||
#else
|
||||
|
||||
|
@ -29,8 +29,13 @@
|
||||
////////////////////////////////////////////////////////////
|
||||
#include <SFML/Config.hpp>
|
||||
|
||||
#include <SFML/System/Err.hpp>
|
||||
|
||||
#include <glad/egl.h>
|
||||
|
||||
#include <filesystem>
|
||||
#include <string_view>
|
||||
#include <type_traits>
|
||||
|
||||
|
||||
namespace sf::priv
|
||||
@ -54,20 +59,28 @@ bool eglCheckError(const std::filesystem::path& file, unsigned int line, std::st
|
||||
|
||||
// In debug mode, perform a test on every EGL call
|
||||
// The lamdba allows us to call eglCheck as an expression and acts as a single statement perfect for if/else statements
|
||||
#define eglCheck(...) \
|
||||
[](auto&& eglCheckInternalFunction) \
|
||||
{ \
|
||||
if constexpr (!std::is_void_v<decltype(eglCheckInternalFunction())>) \
|
||||
{ \
|
||||
const auto eglCheckInternalReturnValue = eglCheckInternalFunction(); \
|
||||
sf::priv::eglCheckError(__FILE__, static_cast<unsigned int>(__LINE__), #__VA_ARGS__); \
|
||||
return eglCheckInternalReturnValue; \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
eglCheckInternalFunction(); \
|
||||
sf::priv::eglCheckError(__FILE__, static_cast<unsigned int>(__LINE__), #__VA_ARGS__); \
|
||||
} \
|
||||
#define eglCheck(...) \
|
||||
[](auto&& eglCheckInternalFunction) \
|
||||
{ \
|
||||
if (const EGLint eglCheckInternalError = eglGetError(); eglCheckInternalError != EGL_SUCCESS) \
|
||||
sf::err() << "EGL error (" << eglCheckInternalError << ") detected during eglCheck call" << std::endl; \
|
||||
\
|
||||
if constexpr (!std::is_void_v<decltype(eglCheckInternalFunction())>) \
|
||||
{ \
|
||||
const auto eglCheckInternalReturnValue = eglCheckInternalFunction(); \
|
||||
\
|
||||
while (!sf::priv::eglCheckError(__FILE__, static_cast<unsigned int>(__LINE__), #__VA_ARGS__)) \
|
||||
/* no-op */; \
|
||||
\
|
||||
return eglCheckInternalReturnValue; \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
eglCheckInternalFunction(); \
|
||||
\
|
||||
while (!sf::priv::eglCheckError(__FILE__, static_cast<unsigned int>(__LINE__), #__VA_ARGS__)) \
|
||||
/* no-op */; \
|
||||
} \
|
||||
}([&]() { return __VA_ARGS__; })
|
||||
|
||||
#else
|
||||
|
Loading…
Reference in New Issue
Block a user