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,7 +28,6 @@
|
|||||||
#include <SFML/Graphics/Text.hpp>
|
#include <SFML/Graphics/Text.hpp>
|
||||||
#include <SFML/Graphics/Texture.hpp>
|
#include <SFML/Graphics/Texture.hpp>
|
||||||
#include <SFML/Graphics/RenderTarget.hpp>
|
#include <SFML/Graphics/RenderTarget.hpp>
|
||||||
#include <cassert>
|
|
||||||
|
|
||||||
|
|
||||||
namespace sf
|
namespace sf
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
#include <SFML/Graphics/Image.hpp>
|
#include <SFML/Graphics/Image.hpp>
|
||||||
#include <SFML/Graphics/GLCheck.hpp>
|
#include <SFML/Graphics/GLCheck.hpp>
|
||||||
#include <SFML/Graphics/TextureSaver.hpp>
|
#include <SFML/Graphics/TextureSaver.hpp>
|
||||||
|
#include <SFML/Window/Context.hpp>
|
||||||
#include <SFML/Window/Window.hpp>
|
#include <SFML/Window/Window.hpp>
|
||||||
#include <SFML/System/Mutex.hpp>
|
#include <SFML/System/Mutex.hpp>
|
||||||
#include <SFML/System/Lock.hpp>
|
#include <SFML/System/Lock.hpp>
|
||||||
@ -522,12 +523,26 @@ void Texture::bind(const Texture* texture, CoordinateType coordinateType)
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
unsigned int Texture::getMaximumSize()
|
unsigned int Texture::getMaximumSize()
|
||||||
{
|
{
|
||||||
ensureGlContext();
|
static unsigned int size = 0;
|
||||||
|
static bool checked = false;
|
||||||
|
|
||||||
GLint size;
|
// Make sure we only have to check once
|
||||||
glCheck(glGetIntegerv(GL_MAX_TEXTURE_SIZE, &size));
|
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 <SFML/OpenGL.hpp>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cassert>
|
|
||||||
#ifdef SFML_SYSTEM_IOS
|
#ifdef SFML_SYSTEM_IOS
|
||||||
#include <OpenGLES/ES1/gl.h>
|
#include <OpenGLES/ES1/gl.h>
|
||||||
#else
|
#else
|
||||||
|
Loading…
Reference in New Issue
Block a user