如何重置librocket库?

时间:2012-08-20 20:32:24

标签: c++ librocket

我正在尝试重置库,但我似乎不能。

我找到this post,但即使有解释,我也无法做到。

在您看到我的代码之前,我要做的是在选项菜单中更改窗口的分辨率。也许有一种方法我不知道,这是一种矫枉过正的行为。

这就是我正在做的事情(引用“渲染器”将它们作为OpenGL处理​​程序):

此代码位于函数ProcessEvent

中的EventHandlerOptions.cpp中
     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:.... location 0x2ab60ee1”

看起来它与事件管理器有关,但是我把它关闭了......?

感谢。

0 个答案:

没有答案