mirror of
https://github.com/SFML/SFML.git
synced 2024-12-01 15:51:04 +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,7 +28,6 @@
|
||||
#include <SFML/Graphics/Text.hpp>
|
||||
#include <SFML/Graphics/Texture.hpp>
|
||||
#include <SFML/Graphics/RenderTarget.hpp>
|
||||
#include <cassert>
|
||||
|
||||
|
||||
namespace sf
|
||||
|
@ -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