コード例 #1
0
GUI::TGuiContextPtr
CGUIDriverGL::CreateGUIContext( GUI::TWindowContextPtr windowContext )
{GUCEF_TRACE;

    // Lazy initialize if needed
    if ( !Init( windowContext ) )
    {
        return GUI::TGuiContextPtr();
    }

    // Create an input context using the default driver and set it for this GUI context so that we can interact
    // with the GUI based on input events. Note that in order to correctly tie in the input system we have to pass the
    // correct parameters for the O/S
    CORE::CValueList inputContextParams;
    inputContextParams.Set( "WINDOW", windowContext->GetProperty( "WINDOW" ) );
    INPUT::CInputContext* inputContext = INPUT::CInputGlobal::Instance()->GetInputController().CreateContext( inputContextParams );

    CEGUI::RenderTarget* renderTarget = m_guiRenderer->getActiveRenderTarget();
    if ( nullptr == renderTarget )
    {
        renderTarget = &m_guiRenderer->getDefaultRenderTarget();
    }
    
    CEGUI::GUIContext* ceGuiContext = &m_guiSystem->createGUIContext( *renderTarget );
    ceGuiContext->setRootWindow( CEGUI::System::getSingleton().getDefaultGUIContext().getRootWindow() );
    GUI::TGuiContextPtr guiContextPtr = new CGUIContextGL( *this         ,
                                                           windowContext ,
                                                           inputContext  ,
                                                           ceGuiContext  );
    // Add a reference to the context in our set
    m_contextSet.insert( guiContextPtr );

    return guiContextPtr;
}
コード例 #2
0
ファイル: application.cpp プロジェクト: rokuz/DemoOpenGL
void Application::initGui()
{
	m_guiRenderer = &CEGUI::OpenGL3Renderer::create();
	static_cast<CEGUI::OpenGL3Renderer*>(m_guiRenderer)->enableExtraStateSettings(true);
	CEGUI::System::create(*m_guiRenderer);
	initialiseResources();

	CEGUI::System& gui_system(CEGUI::System::getSingleton());
	CEGUI::GUIContext* guiContext = &gui_system.getDefaultGUIContext();
	CEGUI::SchemeManager::getSingleton().createFromFile(getGuiFullName(".scheme").c_str());
	guiContext->getMouseCursor().setDefaultImage(getGuiFullName("/MouseArrow").c_str());
	guiContext->getMouseCursor().hide();

	CEGUI::WindowManager& winMgr = CEGUI::WindowManager::getSingleton();
	m_rootWindow = (CEGUI::DefaultWindow*)winMgr.createWindow("DefaultWindow", "Root");
	CEGUI::Font& defaultFont = CEGUI::FontManager::getSingleton().createFromFile("DejaVuSans-12.font");
	guiContext->setDefaultFont(&defaultFont);
	guiContext->setRootWindow(m_rootWindow);

	m_fpsLabel = (CEGUI::Window*)winMgr.createWindow(getGuiFullName("/Label").c_str());
	m_rootWindow->addChild(m_fpsLabel);

	m_fpsLabel->setPosition(CEGUI::UVector2(CEGUI::UDim(1.0f, -150.0f), cegui_reldim(0.0)));
	m_fpsLabel->setSize(CEGUI::USize(cegui_absdim(150.0f), cegui_absdim(25.0f)));
	m_fpsLabel->setProperty("HorzFormatting", "RightAligned");
	m_fpsLabel->setText("0 fps");
}