Merge pull request #317 from cforfang/master

Speedup for debugging: don't create std::string on every call to glCheckError
This commit is contained in:
Laurent Gomila 2012-11-17 13:40:43 -08:00
commit 62c6dc3c59
2 changed files with 4 additions and 3 deletions

View File

@ -34,13 +34,14 @@ namespace sf
namespace priv namespace priv
{ {
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void glCheckError(const std::string& file, unsigned int line) void glCheckError(const char* file, unsigned int line)
{ {
// Get the last error // Get the last error
GLenum errorCode = glGetError(); GLenum errorCode = glGetError();
if (errorCode != GL_NO_ERROR) if (errorCode != GL_NO_ERROR)
{ {
std::string fileString(file);
std::string error = "unknown error"; std::string error = "unknown error";
std::string description = "no description"; std::string description = "no description";
@ -99,7 +100,7 @@ void glCheckError(const std::string& file, unsigned int line)
// Log the error // Log the error
err() << "An internal OpenGL call failed in " err() << "An internal OpenGL call failed in "
<< file.substr(file.find_last_of("\\/") + 1) << " (" << line << ") : " << fileString.substr(fileString.find_last_of("\\/") + 1) << " (" << line << ") : "
<< error << ", " << description << error << ", " << description
<< std::endl; << std::endl;
} }

View File

@ -59,7 +59,7 @@ namespace priv
/// \param line Line number of the source file where the call is located /// \param line Line number of the source file where the call is located
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void glCheckError(const std::string& file, unsigned int line); void glCheckError(const char* file, unsigned int line);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Make sure that GLEW is initialized /// \brief Make sure that GLEW is initialized