void GuiManager::Initialize() { if(mGuiSystem == nullptr) { CameraComponent* c = DisplayManager::Get()->GetMainCamera(); if(c == nullptr || c->GetCamera() == nullptr) { // cannot initialize, there is no camera, so there is no viewport Logger::Get().Error("Cannot initialize GUI System - no main camera set."); return; } Ogre::SceneManager* scene_mgr = c->GetCamera()->getSceneManager(); mPlatform = new MyGUI::OgrePlatform(); // Disable MyGUI output completely, Ogre will throw an exception if a // resource cannot be found MyGUI::LogManager::getInstance().setSTDOutputEnabled(false); mPlatform->initialise(DisplayManager::Get()->GetRenderWindow(), scene_mgr, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); mGuiSystem = new MyGUI::Gui(); mGuiSystem->initialise(); EventManager::Get()->AddListener(this); // Show / hide the mouse cursor. SetMouseCursorVisible(mMouseCursorVisible); // Create the root widget. mRootGuiWindow.Create(); } }
//----------------------------------------------------------------------- bool Window::Init(const WindowDesc &desc, bool fullscreen, bool OGL) { m_desc = desc; m_fullscreen = fullscreen; if ( SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) < 0 ) { Log::Error("Can't Initialize SDL for creating window."); return false; } Uint32 flags = 0; if ( m_fullscreen ) flags = SDL_WINDOW_FULLSCREEN; if ( m_desc.Resize ) flags |= SDL_WINDOW_RESIZABLE; if ( OGL ) { SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24); // TODO: сделать автоматический выбор оптимальной версии GL SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 4); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2); SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE); //SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_COMPATIBILITY); //SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1); //SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 4); #if _DEBUG SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_DEBUG_FLAG); #endif flags |= SDL_WINDOW_OPENGL; } // TODO: установка позиции m_sdlWindow = SDL_CreateWindow(m_desc.Caption, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, m_desc.Size.X, m_desc.Size.Y, flags); #if PLATFORM_WINDOWS SDL_SysWMinfo wmInfo; SDL_VERSION(&wmInfo.version); SDL_GetWindowWMInfo(m_sdlWindow, &wmInfo); m_hwnd = (HWND)wmInfo.info.dummy; #endif if ( !m_sdlWindow ) { Log::Error("Call to SDL_SetVideoMode() failed! - SDL_Error: " + std::string(SDL_GetError())); SDL_Quit(); return false; } SetMouseCursorVisible(m_desc.CursorVisible); return true; }
void GuiManager::Initialize() { if(mGuiSystem == nullptr) { CameraComponent* c = DisplayManager::Get()->GetMainCamera(); if(c == nullptr || c->GetCamera() == nullptr) { // cannot initialize, there is no camera, so there is no viewport Logger::Get().Error("Cannot initialize GUI System - no main camera set."); return; } Ogre::SceneManager* scene_mgr = c->GetCamera()->getSceneManager(); mPlatform = new MyGUI::OgrePlatform(); mPlatform->initialise(DisplayManager::Get()->GetRenderWindow(), scene_mgr, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); mGuiSystem = new MyGUI::Gui(); mGuiSystem->initialise(); EventManager::Get()->AddListener(this); // show/hide mouse cursor SetMouseCursorVisible(mMouseCursorVisible); } }
void GuiManager::Initialize() { if(mGuiSystem == nullptr) { CameraComponent* c = DisplayManager::Get()->GetMainCamera(); if(c == nullptr || c->GetCamera() == nullptr) { // cannot initialize, there is no camera, so there is no viewport Logger::Get().Error("Cannot initialize GUI System - no main camera set."); return; } InputManager* inputMgrPtr = InputManager::Get(); QObject::connect(inputMgrPtr, SIGNAL(sKeyPressed(const OIS::KeyEvent&)), this, SLOT(sKeyPressed(const OIS::KeyEvent&))); QObject::connect(inputMgrPtr, SIGNAL(sKeyReleased(const OIS::KeyEvent&)), this, SLOT(sKeyReleased(const OIS::KeyEvent&))); QObject::connect(inputMgrPtr, SIGNAL(sMouseMoved(const OIS::MouseEvent&)), this, SLOT(sMouseMoved(const OIS::MouseEvent&))); QObject::connect(inputMgrPtr, SIGNAL(sMousePressed(const OIS::MouseEvent&, OIS::MouseButtonID)), this, SLOT(sMousePressed(const OIS::MouseEvent&, OIS::MouseButtonID))); QObject::connect(inputMgrPtr, SIGNAL(sMouseReleased(const OIS::MouseEvent&, OIS::MouseButtonID)), this, SLOT(sMouseReleased(const OIS::MouseEvent&, OIS::MouseButtonID))); Ogre::SceneManager* scene_mgr = c->GetCamera()->getSceneManager(); mPlatform = new MyGUI::OgrePlatform(); // Disable MyGUI output completely, Ogre will throw an exception if a // resource cannot be found MyGUI::LogManager::getInstance().setSTDOutputEnabled(false); mPlatform->initialise(DisplayManager::Get()->GetRenderWindow(), scene_mgr, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); mGuiSystem = new MyGUI::Gui(); mGuiSystem->initialise(); // EventManager::Get()->AddListener(this); // Show / hide the mouse cursor. SetMouseCursorVisible(mMouseCursorVisible); // Initialize the root widget. mRootGuiWindow.Initialize(); }