Esempio n. 1
0
void Application::_onCursor(GLFWwindow* window, double xpos, double ypos)
{
	CEGUI::System& gui_system(CEGUI::System::getSingleton());
	gui_system.getDefaultGUIContext().injectMousePosition((float)xpos, (float)ypos);

	m_self->onMouseMove(xpos, ypos);
}
Esempio n. 2
0
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");
}
Esempio n. 3
0
void Application::_onKey(GLFWwindow* window, int key, int scancode, int action, int mods)
{
	CEGUI::System& gui_system(CEGUI::System::getSingleton());
	CEGUI::Key::Scan ceguiKey = glfwToCeguiKey(key);

	if(action == GLFW_PRESS)
	{
		gui_system.getDefaultGUIContext().injectKeyDown(ceguiKey);
	}
	else if (action == GLFW_RELEASE)
	{
		gui_system.getDefaultGUIContext().injectKeyUp(ceguiKey);
	}

	m_self->onKeyButton(key, scancode, action, mods);
}
Esempio n. 4
0
void Application::_onMouse(GLFWwindow* window, int button, int action, int mods)
{
	CEGUI::System& gui_system(CEGUI::System::getSingleton());
	CEGUI::MouseButton ceguiMouseButton = glfwToCeguiMouseButton(button);

	if(action == GLFW_PRESS)
	{
		gui_system.getDefaultGUIContext().injectMouseButtonDown(ceguiMouseButton);
	}
	else if (action == GLFW_RELEASE)
	{
		gui_system.getDefaultGUIContext().injectMouseButtonUp(ceguiMouseButton);
	}

	double xpos = 0, ypos = 0;
	glfwGetCursorPos(window, &xpos, &ypos);
	m_self->onMouseButton(xpos, ypos, button, action, mods);
}
Esempio n. 5
0
void Application::renderGui(double elapsedTime)
{
	GLboolean scissorTestEnable = glIsEnabled(GL_SCISSOR_TEST);
	GLboolean depthTestEnable = glIsEnabled(GL_DEPTH_TEST);
	GLboolean blendingEnable = glIsEnabled(GL_BLEND);
	GLboolean cullfaceEnable = glIsEnabled(GL_CULL_FACE);

	CEGUI::System& gui_system(CEGUI::System::getSingleton());
	gui_system.injectTimePulse((float)elapsedTime);
	m_guiRenderer->beginRendering();
	gui_system.getDefaultGUIContext().draw();
	m_guiRenderer->endRendering();
	CEGUI::WindowManager::getSingleton().cleanDeadPool();

	if (scissorTestEnable) glEnable(GL_SCISSOR_TEST); else glDisable(GL_SCISSOR_TEST);
	if (depthTestEnable) glEnable(GL_DEPTH_TEST); else glDisable(GL_DEPTH_TEST);
	if (blendingEnable) glEnable(GL_BLEND); else glDisable(GL_BLEND);
	if (cullfaceEnable) glEnable(GL_CULL_FACE); else glDisable(GL_CULL_FACE);
}
Esempio n. 6
0
//----------------------------------------------------------------------------//
void CEGuiBaseApplication::renderSingleFrame(const float elapsed)
{
    CEGUI::System& gui_system(CEGUI::System::getSingleton());

    gui_system.injectTimePulse(elapsed);
    d_sampleApp->update(static_cast<float>(elapsed));

    updateFPS(elapsed);
    updateLogo(elapsed);

    beginRendering(elapsed);

    CEGUI::Renderer* gui_renderer(gui_system.getRenderer());
    gui_renderer->beginRendering();

    d_sampleApp->renderGUIContexts();

    gui_renderer->endRendering();
    CEGUI::WindowManager::getSingleton().cleanDeadPool();

    endRendering();
}
Esempio n. 7
0
void Application::_onScroll(GLFWwindow* window, double xoffset, double yoffset)
{
	CEGUI::System& gui_system(CEGUI::System::getSingleton());
	gui_system.getDefaultGUIContext().injectMouseWheelChange((float)yoffset);
}
Esempio n. 8
0
void Application::_onChar(GLFWwindow* window, unsigned int codepoint)
{
	CEGUI::System& gui_system(CEGUI::System::getSingleton());
	gui_system.getDefaultGUIContext().injectChar(codepoint);
}