From ff87e1c92265574f5c9785117b00907b7a61cf7d Mon Sep 17 00:00:00 2001 From: PKEuS Date: Thu, 5 Jul 2018 12:10:39 +0200 Subject: [PATCH] Reduced context locking&unlocking while creating textures --- src/SFML/Graphics/Texture.cpp | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/SFML/Graphics/Texture.cpp b/src/SFML/Graphics/Texture.cpp index faeef7d7..fd94acf1 100644 --- a/src/SFML/Graphics/Texture.cpp +++ b/src/SFML/Graphics/Texture.cpp @@ -129,6 +129,11 @@ bool Texture::create(unsigned int width, unsigned int height) return false; } + TransientContextLock lock; + + // Make sure that extensions are initialized + priv::ensureExtensionsInit(); + // Compute the internal texture dimensions depending on NPOT textures support Vector2u actualSize(getValidSize(width), getValidSize(height)); @@ -150,8 +155,6 @@ bool Texture::create(unsigned int width, unsigned int height) m_pixelsFlipped = false; m_fboAttachment = false; - TransientContextLock lock; - // Create the OpenGL texture if it doesn't exist yet if (!m_texture) { @@ -160,9 +163,6 @@ bool Texture::create(unsigned int width, unsigned int height) m_texture = static_cast(texture); } - // Make sure that extensions are initialized - priv::ensureExtensionsInit(); - // Make sure that the current texture binding will be preserved priv::TextureSaver save; @@ -851,11 +851,6 @@ unsigned int Texture::getNativeHandle() const //////////////////////////////////////////////////////////// unsigned int Texture::getValidSize(unsigned int size) { - TransientContextLock lock; - - // Make sure that extensions are initialized - priv::ensureExtensionsInit(); - if (GLEXT_texture_non_power_of_two) { // If hardware supports NPOT textures, then just return the unmodified size