Fix sf::Context::getActiveContext to stop returning inactive contexts
sf::Context::getActiveContext could return an inactive context if RenderTargets activation occured since the last sf::Context activation. This is not what its documentation suggest, and was clearly an unexpected behaviour. This fix make the function return NULL if the current active context is not managed by sf::Context (e.g. because it is a RenderTarget).
This commit is contained in:
parent
ce992ee01f
commit
f3a180bc09
@ -32,7 +32,7 @@
|
|||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
// This per-thread variable holds the current context for each thread
|
// This per-thread variable holds the last activated sf::Context for each thread
|
||||||
sf::ThreadLocalPtr<sf::Context> currentContext(NULL);
|
sf::ThreadLocalPtr<sf::Context> currentContext(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,7 +76,11 @@ const ContextSettings& Context::getSettings() const
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
const Context* Context::getActiveContext()
|
const Context* Context::getActiveContext()
|
||||||
{
|
{
|
||||||
return currentContext;
|
// We have to check that the last activated sf::Context is still active (a RenderTarget activation may have deactivated it)
|
||||||
|
if (currentContext && currentContext->m_context == priv::GlContext::getActiveContext())
|
||||||
|
return currentContext;
|
||||||
|
else
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -549,6 +549,13 @@ GlFunctionPointer GlContext::getFunction(const char* name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
const GlContext* GlContext::getActiveContext()
|
||||||
|
{
|
||||||
|
return currentContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
Uint64 GlContext::getActiveContextId()
|
Uint64 GlContext::getActiveContextId()
|
||||||
{
|
{
|
||||||
|
@ -157,6 +157,14 @@ public:
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
static GlFunctionPointer getFunction(const char* name);
|
static GlFunctionPointer getFunction(const char* name);
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
/// \brief Get the currently active context
|
||||||
|
///
|
||||||
|
/// \return The currently active context or NULL if none is active
|
||||||
|
///
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
static const GlContext* getActiveContext();
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Get the currently active context's ID
|
/// \brief Get the currently active context's ID
|
||||||
///
|
///
|
||||||
|
Loading…
Reference in New Issue
Block a user