diff --git a/src/SFML/Graphics/Font.cpp b/src/SFML/Graphics/Font.cpp index 1ad882da..8afe57e7 100644 --- a/src/SFML/Graphics/Font.cpp +++ b/src/SFML/Graphics/Font.cpp @@ -26,6 +26,7 @@ // Headers //////////////////////////////////////////////////////////// #include +#include #include #include #include @@ -480,6 +481,10 @@ Glyph Font::loadGlyph(Uint32 codePoint, unsigned int characterSize, bool bold) c // Delete the FT glyph FT_Done_Glyph(glyphDesc); + // Force an OpenGL flush, so that the font's texture will appear updated + // in all contexts immediately (solves problems in multi-threaded apps) + glCheck(glFlush()); + // Done :) return glyph; } diff --git a/src/SFML/Graphics/Shader.cpp b/src/SFML/Graphics/Shader.cpp index 072bc6e3..eb292b72 100644 --- a/src/SFML/Graphics/Shader.cpp +++ b/src/SFML/Graphics/Shader.cpp @@ -535,6 +535,10 @@ bool Shader::compile(const char* vertexShaderCode, const char* fragmentShaderCod return false; } + // Force an OpenGL flush, so that the shader will appear updated + // in all contexts immediately (solves problems in multi-threaded apps) + glCheck(glFlush()); + return true; } diff --git a/src/SFML/Graphics/Texture.cpp b/src/SFML/Graphics/Texture.cpp index a0e57e19..7b5fdb27 100644 --- a/src/SFML/Graphics/Texture.cpp +++ b/src/SFML/Graphics/Texture.cpp @@ -192,6 +192,11 @@ bool Texture::loadFromImage(const Image& image, const IntRect& area) if (create(image.getSize().x, image.getSize().y)) { update(image); + + // Force an OpenGL flush, so that the texture will appear updated + // in all contexts immediately (solves problems in multi-threaded apps) + glCheck(glFlush()); + return true; } else @@ -225,6 +230,10 @@ bool Texture::loadFromImage(const Image& image, const IntRect& area) pixels += 4 * width; } + // Force an OpenGL flush, so that the texture will appear updated + // in all contexts immediately (solves problems in multi-threaded apps) + glCheck(glFlush()); + return true; } else