diff --git a/src/SFML/Audio/ALCheck.cpp b/src/SFML/Audio/ALCheck.cpp index e1522c5c..3bb8e288 100644 --- a/src/SFML/Audio/ALCheck.cpp +++ b/src/SFML/Audio/ALCheck.cpp @@ -26,8 +26,8 @@ // Headers //////////////////////////////////////////////////////////// #include -#include #include +#include namespace sf @@ -35,14 +35,16 @@ namespace sf namespace priv { //////////////////////////////////////////////////////////// -void alCheckError(const std::string& file, unsigned int line) +void alCheckError(const char* file, unsigned int line, const char* expression) { // Get the last error ALenum errorCode = alGetError(); if (errorCode != AL_NO_ERROR) { - std::string error, description; + std::string fileString = file; + std::string error = "Unknown error"; + std::string description = "No description"; // Decode the error code switch (errorCode) @@ -50,43 +52,44 @@ void alCheckError(const std::string& file, unsigned int line) case AL_INVALID_NAME: { error = "AL_INVALID_NAME"; - description = "an unacceptable name has been specified"; + description = "A bad name (ID) has been specified."; break; } case AL_INVALID_ENUM: { error = "AL_INVALID_ENUM"; - description = "an unacceptable value has been specified for an enumerated argument"; + description = "An unacceptable value has been specified for an enumerated argument."; break; } case AL_INVALID_VALUE: { error = "AL_INVALID_VALUE"; - description = "a numeric argument is out of range"; + description = "A numeric argument is out of range."; break; } case AL_INVALID_OPERATION: { error = "AL_INVALID_OPERATION"; - description = "the specified operation is not allowed in the current state"; + description = "The specified operation is not allowed in the current state."; break; } case AL_OUT_OF_MEMORY: { error = "AL_OUT_OF_MEMORY"; - description = "there is not enough memory left to execute the command"; + description = "There is not enough memory left to execute the command."; break; } } // Log the error err() << "An internal OpenAL call failed in " - << file.substr(file.find_last_of("\\/") + 1) << " (" << line << ") : " - << error << ", " << description + << fileString.substr(fileString.find_last_of("\\/") + 1) << "(" << line << ")." + << "\nExpression:\n " << expression + << "\nError description:\n " << error << "\n " << description << "\n" << std::endl; } } diff --git a/src/SFML/Audio/ALCheck.hpp b/src/SFML/Audio/ALCheck.hpp index 34b76264..750af9ec 100644 --- a/src/SFML/Audio/ALCheck.hpp +++ b/src/SFML/Audio/ALCheck.hpp @@ -29,8 +29,6 @@ // Headers //////////////////////////////////////////////////////////// #include -#include -#include #ifdef SFML_SYSTEM_IOS #include #include @@ -45,7 +43,7 @@ namespace sf namespace priv { //////////////////////////////////////////////////////////// -/// Let's define a macro to quickly check every OpenAL API calls +/// Let's define a macro to quickly check every OpenAL API call //////////////////////////////////////////////////////////// #ifdef SFML_DEBUG @@ -56,7 +54,7 @@ namespace priv #else // Else, we don't add any overhead - #define alCheck(Func) (Func) + #define alCheck(expr) (expr) #endif @@ -66,9 +64,10 @@ namespace priv /// /// \param file Source file where the call is located /// \param line Line number of the source file where the call is located +/// \param expression The evaluated expression as a string /// //////////////////////////////////////////////////////////// -void alCheckError(const std::string& file, unsigned int line); +void alCheckError(const char* file, unsigned int line, const char* expression); } // namespace priv diff --git a/src/SFML/Graphics/GLCheck.cpp b/src/SFML/Graphics/GLCheck.cpp index ce777b2c..2a706cd8 100644 --- a/src/SFML/Graphics/GLCheck.cpp +++ b/src/SFML/Graphics/GLCheck.cpp @@ -27,6 +27,7 @@ //////////////////////////////////////////////////////////// #include #include +#include namespace sf @@ -34,16 +35,16 @@ namespace sf namespace priv { //////////////////////////////////////////////////////////// -void glCheckError(const char* file, unsigned int line) +void glCheckError(const char* file, unsigned int line, const char* expression) { // Get the last error GLenum errorCode = glGetError(); if (errorCode != GL_NO_ERROR) { - std::string fileString(file); - std::string error = "unknown error"; - std::string description = "no description"; + std::string fileString = file; + std::string error = "Unknown error"; + std::string description = "No description"; // Decode the error code switch (errorCode) @@ -51,57 +52,58 @@ void glCheckError(const char* file, unsigned int line) case GL_INVALID_ENUM: { error = "GL_INVALID_ENUM"; - description = "an unacceptable value has been specified for an enumerated argument"; + description = "An unacceptable value has been specified for an enumerated argument."; break; } case GL_INVALID_VALUE: { error = "GL_INVALID_VALUE"; - description = "a numeric argument is out of range"; + description = "A numeric argument is out of range."; break; } case GL_INVALID_OPERATION: { error = "GL_INVALID_OPERATION"; - description = "the specified operation is not allowed in the current state"; + description = "The specified operation is not allowed in the current state."; break; } case GL_STACK_OVERFLOW: { error = "GL_STACK_OVERFLOW"; - description = "this command would cause a stack overflow"; + description = "This command would cause a stack overflow."; break; } case GL_STACK_UNDERFLOW: { error = "GL_STACK_UNDERFLOW"; - description = "this command would cause a stack underflow"; + description = "This command would cause a stack underflow."; break; } case GL_OUT_OF_MEMORY: { error = "GL_OUT_OF_MEMORY"; - description = "there is not enough memory left to execute the command"; + description = "There is not enough memory left to execute the command."; break; } case GLEXT_GL_INVALID_FRAMEBUFFER_OPERATION: { error = "GL_INVALID_FRAMEBUFFER_OPERATION"; - description = "the object bound to FRAMEBUFFER_BINDING is not \"framebuffer complete\""; + description = "The object bound to FRAMEBUFFER_BINDING is not \"framebuffer complete\"."; break; } } // Log the error err() << "An internal OpenGL call failed in " - << fileString.substr(fileString.find_last_of("\\/") + 1) << " (" << line << ") : " - << error << ", " << description + << fileString.substr(fileString.find_last_of("\\/") + 1) << "(" << line << ")." + << "\nExpression:\n " << expression + << "\nError description:\n " << error << "\n " << description << "\n" << std::endl; } } diff --git a/src/SFML/Graphics/GLCheck.hpp b/src/SFML/Graphics/GLCheck.hpp index 94e386b3..9b7db8b7 100644 --- a/src/SFML/Graphics/GLCheck.hpp +++ b/src/SFML/Graphics/GLCheck.hpp @@ -30,7 +30,6 @@ //////////////////////////////////////////////////////////// #include #include -#include namespace sf @@ -38,7 +37,7 @@ namespace sf namespace priv { //////////////////////////////////////////////////////////// -/// Let's define a macro to quickly check every OpenGL API calls +/// Let's define a macro to quickly check every OpenGL API call //////////////////////////////////////////////////////////// #ifdef SFML_DEBUG @@ -49,7 +48,7 @@ namespace priv #else // Else, we don't add any overhead - #define glCheck(call) (call) + #define glCheck(expr) (expr) #endif @@ -58,9 +57,10 @@ namespace priv /// /// \param file Source file where the call is located /// \param line Line number of the source file where the call is located +/// \param expression The evaluated expression as a string /// //////////////////////////////////////////////////////////// -void glCheckError(const char* file, unsigned int line); +void glCheckError(const char* file, unsigned int line, const char* expression); } // namespace priv