Open Hilarius86 opened 1 year ago
Hi!
The block is protected by a static global variable:
if( !mClassRegistered )
{
mClassRegistered = true;
}
How are you able to enter that block twice?
I have to look for it a little more. Working theory is about unloading the Ogre Dlls. RenderSystems are Plugins and loaded/unloaded with the Ogre Root, which I shut down in between.
It works as described. When shutting down the 3D rendering part of the application OgreRoot is deleted. That unloads all plugins and therefore the dll. When restarting 3D, the Dll is loaded again and a new set of statics is generated / initalised. But the registration of the windowclass is still active.
@darksylinc Do you care for me to provide a PR for this? Finishing up on updateing to 2.2 and remembered this issue.
Sure!!!
PRs are more than welcome!
When creating a window for the DirectX 11 Rendersystem a WindowClass is registered. That window class is not unregistered. In 2.1 that was silently ignored and a window was created anyway, but now (2.2 for me) it fails and throws an exception.
ogre-next\RenderSystems\Direct3D11\src\Windowing\WIN32\OgreD3D11WindowHwnd.cpp
if (!mClassRegistered
{
if (!RegisterClassEx(&wcex))
{
OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR,
"RegisterClassEx failed! Cannot create window",
"D3D11WindowHwnd::create");
}
mClassRegistered = true;
}
Shouldn't this class unregister it`s window class in the destroy function ala?
if( mClassRegistered )
{
UnregisterClass( OGRE_D3D11_WIN_CLASS_NAME, 0 );
mClassRegistered = false;
}