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