diff --git a/src/SFML/Graphics/GLCheck.hpp b/src/SFML/Graphics/GLCheck.hpp index a78872d7..f96289e8 100644 --- a/src/SFML/Graphics/GLCheck.hpp +++ b/src/SFML/Graphics/GLCheck.hpp @@ -43,7 +43,7 @@ namespace priv #ifdef SFML_DEBUG // In debug mode, perform a test on every OpenGL call - #define glCheck(call) ((call), sf::priv::glCheckError(__FILE__, __LINE__)) + #define glCheck(x) x; sf::priv::glCheckError(__FILE__, __LINE__); #else diff --git a/src/SFML/Graphics/RenderTarget.cpp b/src/SFML/Graphics/RenderTarget.cpp index 42ef83c1..3c0b15a5 100644 --- a/src/SFML/Graphics/RenderTarget.cpp +++ b/src/SFML/Graphics/RenderTarget.cpp @@ -379,19 +379,29 @@ void RenderTarget::applyBlendMode(BlendMode mode) // Alpha blending default : - case BlendAlpha : + case BlendAlpha : if (GL_blend_func_separate) + { glCheck(glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA)); + } else + { glCheck(glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)); + } + break; // Additive blending - case BlendAdd : + case BlendAdd : if (GL_blend_func_separate) + { glCheck(glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE, GL_ONE, GL_ONE)); + } else + { glCheck(glBlendFunc(GL_SRC_ALPHA, GL_ONE)); + } + break; // Multiplicative blending diff --git a/src/SFML/Graphics/RenderTextureImplFBO.cpp b/src/SFML/Graphics/RenderTextureImplFBO.cpp index 05157491..c49ac351 100644 --- a/src/SFML/Graphics/RenderTextureImplFBO.cpp +++ b/src/SFML/Graphics/RenderTextureImplFBO.cpp @@ -116,8 +116,9 @@ bool RenderTextureImplFBO::create(unsigned int width, unsigned int height, unsig // Link the texture to the frame buffer glCheck(glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textureId, 0)); - // A final check, just to be sure... - if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) + // A final check, just to be sure... + GLenum status = glCheck(glCheckFramebufferStatus(GL_FRAMEBUFFER)); + if (status != GL_FRAMEBUFFER_COMPLETE) { glCheck(glBindFramebuffer(GL_FRAMEBUFFER, 0)); err() << "Impossible to create render texture (failed to link the target texture to the frame buffer)" << std::endl; @@ -138,7 +139,7 @@ bool RenderTextureImplFBO::activate(bool active) //////////////////////////////////////////////////////////// void RenderTextureImplFBO::updateTexture(unsigned int) { - glFlush(); + glCheck(glFlush()); } } // namespace priv diff --git a/src/SFML/Graphics/Shader.cpp b/src/SFML/Graphics/Shader.cpp index 4b91b12e..805b6b6f 100644 --- a/src/SFML/Graphics/Shader.cpp +++ b/src/SFML/Graphics/Shader.cpp @@ -228,13 +228,15 @@ void Shader::setParameter(const std::string& name, float x) ensureGlContext(); // Enable program - GLhandleARB program = glGetHandleARB(GL_PROGRAM_OBJECT_ARB); + GLhandleARB program = glCheck(glGetHandleARB(GL_PROGRAM_OBJECT_ARB)); glCheck(glUseProgramObjectARB(m_shaderProgram)); // Get parameter location and assign it new values GLint location = getParamLocation(name); if (location != -1) + { glCheck(glUniform1fARB(location, x)); + } // Disable program glCheck(glUseProgramObjectARB(program)); @@ -250,13 +252,15 @@ void Shader::setParameter(const std::string& name, float x, float y) ensureGlContext(); // Enable program - GLhandleARB program = glGetHandleARB(GL_PROGRAM_OBJECT_ARB); + GLhandleARB program = glCheck(glGetHandleARB(GL_PROGRAM_OBJECT_ARB)); glCheck(glUseProgramObjectARB(m_shaderProgram)); // Get parameter location and assign it new values GLint location = getParamLocation(name); if (location != -1) + { glCheck(glUniform2fARB(location, x, y)); + } // Disable program glCheck(glUseProgramObjectARB(program)); @@ -272,13 +276,15 @@ void Shader::setParameter(const std::string& name, float x, float y, float z) ensureGlContext(); // Enable program - GLhandleARB program = glGetHandleARB(GL_PROGRAM_OBJECT_ARB); + GLhandleARB program = glCheck(glGetHandleARB(GL_PROGRAM_OBJECT_ARB)); glCheck(glUseProgramObjectARB(m_shaderProgram)); // Get parameter location and assign it new values GLint location = getParamLocation(name); if (location != -1) + { glCheck(glUniform3fARB(location, x, y, z)); + } // Disable program glCheck(glUseProgramObjectARB(program)); @@ -294,13 +300,15 @@ void Shader::setParameter(const std::string& name, float x, float y, float z, fl ensureGlContext(); // Enable program - GLhandleARB program = glGetHandleARB(GL_PROGRAM_OBJECT_ARB); + GLhandleARB program = glCheck(glGetHandleARB(GL_PROGRAM_OBJECT_ARB)); glCheck(glUseProgramObjectARB(m_shaderProgram)); // Get parameter location and assign it new values GLint location = getParamLocation(name); if (location != -1) + { glCheck(glUniform4fARB(location, x, y, z, w)); + } // Disable program glCheck(glUseProgramObjectARB(program)); @@ -337,13 +345,15 @@ void Shader::setParameter(const std::string& name, const sf::Transform& transfor ensureGlContext(); // Enable program - GLhandleARB program = glGetHandleARB(GL_PROGRAM_OBJECT_ARB); + GLhandleARB program = glCheck(glGetHandleARB(GL_PROGRAM_OBJECT_ARB)); glCheck(glUseProgramObjectARB(m_shaderProgram)); // Get parameter location and assign it new values GLint location = getParamLocation(name); if (location != -1) + { glCheck(glUniformMatrix4fvARB(location, 1, GL_FALSE, transform.getMatrix())); + } // Disable program glCheck(glUseProgramObjectARB(program)); @@ -462,13 +472,13 @@ bool Shader::compile(const char* vertexShaderCode, const char* fragmentShaderCod m_params.clear(); // Create the program - m_shaderProgram = glCreateProgramObjectARB(); + m_shaderProgram = glCheck(glCreateProgramObjectARB()); // Create the vertex shader if needed if (vertexShaderCode) { // Create and compile the shader - GLhandleARB vertexShader = glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB); + GLhandleARB vertexShader = glCheck(glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB)); glCheck(glShaderSourceARB(vertexShader, 1, &vertexShaderCode, NULL)); glCheck(glCompileShaderARB(vertexShader)); @@ -496,7 +506,7 @@ bool Shader::compile(const char* vertexShaderCode, const char* fragmentShaderCod if (fragmentShaderCode) { // Create and compile the shader - GLhandleARB fragmentShader = glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB); + GLhandleARB fragmentShader = glCheck(glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB)); glCheck(glShaderSourceARB(fragmentShader, 1, &fragmentShaderCode, NULL)); glCheck(glCompileShaderARB(fragmentShader)); @@ -576,7 +586,7 @@ int Shader::getParamLocation(const std::string& name) else { // Not in cache, request the location from OpenGL - int location = glGetUniformLocationARB(m_shaderProgram, name.c_str()); + int location = glCheck(glGetUniformLocationARB(m_shaderProgram, name.c_str())); if (location != -1) { // Location found: add it to the cache