我正在尝试重置库,但我似乎不能。
我找到了这篇文章,但即使有那里的解释,我也无法做到。
在您看到我的代码之前,我要做的是在选项菜单中更改窗口的分辨率。也许有一种我不知道的方法,这是一种矫枉过正。
这就是我正在做的事情(对“渲染器”的引用将它们作为 OpenGL 处理程序):
此代码在 EventHandlerOptions.cpp 中,在函数 ProcessEvent 中
if(ResolutionChanged)
{
// Change the resolution
Renderer *renderer = GameSettings::GetRenderer();
GUIScene *gui = GameSettings::GetGUI();
if(renderer != NULL && gui != NULL)
{
bool ok;
// Shutdown old ones
gui->Shutdown();
renderer->Shutdown();
// Initialize the new ones
ok = renderer->Init(GameSettings::GetResolutionWidth(), GameSettings::GetResolutionHeight(), 16, (bool)GameSettings::GetRepresentation());
assert(ok);
ok = gui->Init(GameSettings::GetResolutionWidth(), GameSettings::GetResolutionHeight());
assert(ok);
}
}
GUI 的相关代码(我正在使用库附带的示例代码,因此您将看到对 Shell 的引用):
bool GUIScene::Init(int width, int height)
{
// Generic OS initialisation, creates a window and attaches OpenGL.
if (!Shell::Initialise("."))
{
Shell::Shutdown();
return false;
}
//Rocket initialisation.
Rocket::Core::SetRenderInterface(new ShellRenderInterfaceOpenGL());
Rocket::Core::SetSystemInterface(new ShellSystemInterface());
Rocket::Core::Initialise();
// Initialise the Rocket Controls library.
Rocket::Controls::Initialise();
// Create the main Rocket context and set it on the shell's input layer.
context = Rocket::Core::CreateContext("main", Rocket::Core::Vector2i(width, height));
if (context == NULL)
{
Rocket::Core::Shutdown();
Shell::Shutdown();
return false;
}
Rocket::Debugger::Initialise(context);
Input::SetContext(context);
Shell::LoadFonts("Data/");
// Initialise the event instancer and handlers.
EventInstancer* event_instancer = new EventInstancer();
Rocket::Core::Factory::RegisterEventListenerInstancer(event_instancer);
event_instancer->RemoveReference();
EventManager::SetContext(context);
EventManager::RegisterEventHandler("options", new EventHandlerOptions());
EventManager::LoadWindow("demo");
return true;
}
void GUIScene::Shutdown()
{
// Shutdown Rocket.
EventManager::Shutdown();
context->RemoveReference();
Rocket::Core::Shutdown();
Rocket::Core::SetSystemInterface(NULL);
Rocket::Core::SetRenderInterface(NULL);
Shell::Shutdown();
}
这在 EventManager.cpp 上崩溃(我认为在 ProcessEvent 函数中)
消息是:“Game.exe 中 0x773515de 中的未处理异常:0xC0000005:....位置 0x2ab60ee1”
看起来它与事件管理器有关,但我正在关闭它所以......?
谢谢。