diff --git a/src/SFML/Graphics/Text.cpp b/src/SFML/Graphics/Text.cpp index 90208cf6..e415728f 100644 --- a/src/SFML/Graphics/Text.cpp +++ b/src/SFML/Graphics/Text.cpp @@ -28,13 +28,12 @@ #include #include #include -#include namespace sf { //////////////////////////////////////////////////////////// -Text::Text() : +Text::Text() : m_string (), m_font (NULL), m_characterSize (30), @@ -42,14 +41,14 @@ m_style (Regular), m_color (255, 255, 255), m_vertices (Triangles), m_bounds (), -m_geometryNeedUpdate(false) +m_geometryNeedUpdate(false) { } //////////////////////////////////////////////////////////// -Text::Text(const String& string, const Font& font, unsigned int characterSize) : +Text::Text(const String& string, const Font& font, unsigned int characterSize) : m_string (string), m_font (&font), m_characterSize (characterSize), @@ -57,7 +56,7 @@ m_style (Regular), m_color (255, 255, 255), m_vertices (Triangles), m_bounds (), -m_geometryNeedUpdate(true) +m_geometryNeedUpdate(true) { } diff --git a/src/SFML/Graphics/Texture.cpp b/src/SFML/Graphics/Texture.cpp index 86f1fdbe..2e93a7c3 100644 --- a/src/SFML/Graphics/Texture.cpp +++ b/src/SFML/Graphics/Texture.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -522,12 +523,26 @@ void Texture::bind(const Texture* texture, CoordinateType coordinateType) //////////////////////////////////////////////////////////// unsigned int Texture::getMaximumSize() { - ensureGlContext(); + static unsigned int size = 0; + static bool checked = false; - GLint size; - glCheck(glGetIntegerv(GL_MAX_TEXTURE_SIZE, &size)); + // Make sure we only have to check once + if (!checked) + { + // Create a temporary context in case the user queries + // the size before a GlResource is created, thus + // initializing the shared context + Context context; - return static_cast(size); + GLint glSize; + glCheck(glGetIntegerv(GL_MAX_TEXTURE_SIZE, &glSize)); + + size = static_cast(glSize); + + checked = true; + } + + return size; } diff --git a/src/SFML/Window/GlContext.cpp b/src/SFML/Window/GlContext.cpp index f76f6c52..7ecc524c 100644 --- a/src/SFML/Window/GlContext.cpp +++ b/src/SFML/Window/GlContext.cpp @@ -32,7 +32,6 @@ #include #include #include -#include #ifdef SFML_SYSTEM_IOS #include #else