From c23d4a838596a2286ec04635f17ae87f64e4a108 Mon Sep 17 00:00:00 2001 From: Laurent Gomila Date: Sat, 6 Jul 2013 18:24:30 +0200 Subject: [PATCH] Checking errors in RenderTarget::pushGLStates() to avoid generating false error messages when user leaves unchecked OpenGL errors (#340) --- src/SFML/Graphics/RenderTarget.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/SFML/Graphics/RenderTarget.cpp b/src/SFML/Graphics/RenderTarget.cpp index 9394214ba..a2316cf0c 100644 --- a/src/SFML/Graphics/RenderTarget.cpp +++ b/src/SFML/Graphics/RenderTarget.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include @@ -242,6 +243,17 @@ void RenderTarget::pushGLStates() { if (activate(true)) { +#ifdef SFML_DEBUG + // make sure that the user didn't leave an unchecked OpenGL error + GLenum error = glGetError(); + if (error != GL_NO_ERROR) + { + err() << "OpenGL error (" << error << ") detected in user code, " + << "you should check for errors with glGetError()" + << std::endl; + } +#endif + glCheck(glPushClientAttrib(GL_CLIENT_ALL_ATTRIB_BITS)); glCheck(glPushAttrib(GL_ALL_ATTRIB_BITS)); glCheck(glMatrixMode(GL_MODELVIEW));