mirror of
https://github.com/SFML/SFML.git
synced 2024-11-29 06:41:05 +08:00
Solved graphics resources not updated or corrupted when loaded in a thread (#411)
This commit is contained in:
parent
4d55bbe4ff
commit
6b50691551
@ -26,6 +26,7 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Graphics/Font.hpp>
|
#include <SFML/Graphics/Font.hpp>
|
||||||
|
#include <SFML/Graphics/GLCheck.hpp>
|
||||||
#include <SFML/System/InputStream.hpp>
|
#include <SFML/System/InputStream.hpp>
|
||||||
#include <SFML/System/Err.hpp>
|
#include <SFML/System/Err.hpp>
|
||||||
#include <ft2build.h>
|
#include <ft2build.h>
|
||||||
@ -480,6 +481,10 @@ Glyph Font::loadGlyph(Uint32 codePoint, unsigned int characterSize, bool bold) c
|
|||||||
// Delete the FT glyph
|
// Delete the FT glyph
|
||||||
FT_Done_Glyph(glyphDesc);
|
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 :)
|
// Done :)
|
||||||
return glyph;
|
return glyph;
|
||||||
}
|
}
|
||||||
|
@ -535,6 +535,10 @@ bool Shader::compile(const char* vertexShaderCode, const char* fragmentShaderCod
|
|||||||
return false;
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -192,6 +192,11 @@ bool Texture::loadFromImage(const Image& image, const IntRect& area)
|
|||||||
if (create(image.getSize().x, image.getSize().y))
|
if (create(image.getSize().x, image.getSize().y))
|
||||||
{
|
{
|
||||||
update(image);
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -225,6 +230,10 @@ bool Texture::loadFromImage(const Image& image, const IntRect& area)
|
|||||||
pixels += 4 * width;
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user