void GuiDemo::initRocket() { GK_ASSERT(m_scene && !m_rkContext); gkWindow* window = m_scene->getDisplayWindow(); // Rocket initialisation. m_rkOgreRenderer = new RenderInterfaceOgre3D(window->getWidth(), window->getHeight()); Rocket::Core::SetRenderInterface(m_rkOgreRenderer); m_rkOgreSystem = new SystemInterfaceOgre3D(); Rocket::Core::SetSystemInterface(m_rkOgreSystem); Rocket::Core::Initialise(); Rocket::Controls::Initialise(); installRocketFonts(); m_rkContext = Rocket::Core::CreateContext("main", Rocket::Core::Vector2i(window->getWidth(), window->getHeight())); Rocket::Debugger::Initialise(m_rkContext); m_rkFileInterface = new FileInterfaceOgre3D(); Rocket::Core::SetFileInterface(m_rkFileInterface); // Load the mouse cursor and release the caller's reference. Rocket::Core::ElementDocument* cursor = m_rkContext->LoadMouseCursor(ROCKET_CURSOR_PAGE); if (cursor) cursor->RemoveReference(); m_document = m_rkContext->LoadDocument(ROCKET_DEMO_PAGE); if (m_document) { Rocket::Core::Element* button = m_document->GetElementById(DEMO_PAGE_BUTTON_ID); if (button) button->AddEventListener("click", this); m_document->Show(); } m_rkEventListener = new RocketEventListener(window, m_rkContext); m_rkRenderListener = new RocketRenderListener(window->getRenderWindow(), m_scene->getManager(), m_rkContext); }
void GuiDemo::loadGUI() { GK_ASSERT(m_scene); // Install fonts gkGUIManager *gm = gkGUIManager::getSingletonPtr(); gm->loadFont("Delicious-Roman"); gm->loadFont("Delicious-Bold"); gm->loadFont("Delicious-Italic"); gm->loadFont("Delicious-BoldItalic"); // Initialise the Lua interface Rocket::Core::Lua::Interpreter::Initialise(); Rocket::Controls::Lua::RegisterTypes(Rocket::Core::Lua::Interpreter::GetLuaState()); //Rocket::Core::Vector2f v; v.Normalise(); // Create context gkGUI *gui = m_scene->getDisplayWindow()->getGUI(); // Enable debugger (shift+~) gm->setDebug(gui); // Load the mouse cursor and release the caller's reference. Rocket::Core::ElementDocument* cursor = gui->getContext()->LoadMouseCursor(ROCKET_CURSOR_PAGE); if (cursor) cursor->RemoveReference(); m_document = gui->getContext()->LoadDocument(ROCKET_DEMO_PAGE); if (m_document) { Rocket::Core::Element* button = m_document->GetElementById(DEMO_PAGE_BUTTON_ID); if (button) button->AddEventListener("click", this); m_document->Show(); } }