mirror of
https://github.com/SFML/SFML.git
synced 2024-11-28 22:31:09 +08:00
Fixed a bug where calling Texture::getMaximumSize() before any GlResource is created would break context management.
This commit is contained in:
parent
6ad7b21203
commit
713407e159
@ -28,13 +28,12 @@
|
||||
#include <SFML/Graphics/Text.hpp>
|
||||
#include <SFML/Graphics/Texture.hpp>
|
||||
#include <SFML/Graphics/RenderTarget.hpp>
|
||||
#include <cassert>
|
||||
|
||||
|
||||
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)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include <SFML/Graphics/Image.hpp>
|
||||
#include <SFML/Graphics/GLCheck.hpp>
|
||||
#include <SFML/Graphics/TextureSaver.hpp>
|
||||
#include <SFML/Window/Context.hpp>
|
||||
#include <SFML/Window/Window.hpp>
|
||||
#include <SFML/System/Mutex.hpp>
|
||||
#include <SFML/System/Lock.hpp>
|
||||
@ -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<unsigned int>(size);
|
||||
GLint glSize;
|
||||
glCheck(glGetIntegerv(GL_MAX_TEXTURE_SIZE, &glSize));
|
||||
|
||||
size = static_cast<unsigned int>(glSize);
|
||||
|
||||
checked = true;
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
|
||||
|
@ -32,7 +32,6 @@
|
||||
#include <SFML/OpenGL.hpp>
|
||||
#include <set>
|
||||
#include <cstdlib>
|
||||
#include <cassert>
|
||||
#ifdef SFML_SYSTEM_IOS
|
||||
#include <OpenGLES/ES1/gl.h>
|
||||
#else
|
||||
|
Loading…
Reference in New Issue
Block a user