Fixed bug with threads and OpenGL contexts

Former-commit-id: 044923d57873f4e1a1eb4001395a83dbe97aabed
This commit is contained in:
Lynix 2013-06-25 00:26:18 +02:00
parent 0e3a4fa90b
commit 3b88cd936c
2 changed files with 4 additions and 8 deletions

View File

@ -167,7 +167,7 @@ bool NzContext::Create(const NzContextParameters& parameters)
if (m_parameters.antialiasingLevel > 0) if (m_parameters.antialiasingLevel > 0)
glEnable(GL_MULTISAMPLE); glEnable(GL_MULTISAMPLE);
if (NzOpenGL::IsSupported(nzOpenGLExtension_DebugOutput) && m_parameters.debugMode) if (m_parameters.debugMode && NzOpenGL::IsSupported(nzOpenGLExtension_DebugOutput))
{ {
glDebugMessageCallback(&DebugCallback, this); glDebugMessageCallback(&DebugCallback, this);
@ -186,13 +186,9 @@ void NzContext::Destroy()
if (m_impl) if (m_impl)
{ {
NotifyDestroy(); NotifyDestroy();
NzOpenGL::OnContextDestruction(this);
if (currentContext == this) NzOpenGL::OnContextDestruction(this);
{ SetActive(false);
NzContextImpl::Desactivate();
currentContext = nullptr;
}
m_impl->Destroy(); m_impl->Destroy();
delete m_impl; delete m_impl;

View File

@ -71,7 +71,7 @@ namespace
std::set<NzString> s_openGLextensionSet; std::set<NzString> s_openGLextensionSet;
std::unordered_map<NzContext*, ContextStates> s_contexts; std::unordered_map<NzContext*, ContextStates> s_contexts;
ContextStates* s_contextStates = nullptr; thread_local ContextStates* s_contextStates = nullptr;
const char* s_rendererName = nullptr; const char* s_rendererName = nullptr;
const char* s_vendorName = nullptr; const char* s_vendorName = nullptr;
bool s_initialized = false; bool s_initialized = false;