Ogre3D、多显示器和鼠标光标

4

我正在开发一个需要在OpenGL中进行多头渲染的应用程序。目前,我可以在多个屏幕上进行渲染,但是鼠标光标只能在单个屏幕上移动。然而,我希望能够在所有渲染的屏幕上使用鼠标光标。

是否有人遇到过同样的问题?如果有,你是如何解决的?

1个回答

6
我找到了一个可行的解决方案。首先,我需要在窗口模式下实例化我的Ogre::RenderWindow对象,而不是全屏模式——可以通过这样实例化没有边框的Ogre::RenderWindow对象来轻松地模拟全屏模式:
Ogre::NameValuePairList options;
options["left"] = "0";
options["top"] = "0";
options["border"] = "none";
options["monitorIndex"] = "0";
m_pVisWindow[0] = mRoot->createRenderWindow("Window1", 1920, 1200, false, &options);

options["monitorIndex"] = "1";
m_pVizWindow[1] = mRoot->createRenderWindow("Window2", 1920, 1200, false, &options);

options["monitorIndex"] = "2";
m_pVizWindow[2] = mRoot->createRenderWindow("Window3", 1920, 1200, false, &options);

options["monitorIndex"] = "3";
m_pVizWindow[3] = mRoot->createRenderWindow("Window4", 1920, 1200, false, &options);

options["monitorIndex"] = "4";
m_pVizWindow[4] = mRoot->createRenderWindow("Window5", 1920, 1200, false, &options);

options["monitorIndex"] = "5";
m_pVizWindow[5] = mRoot->createRenderWindow("Window6", 1920, 1200, false, &options);

在每个Ogre::RenderWindow上附加的Ogre::FrameListener的构造函数中(在本例中,它继承自ExampleFrameListener),我基本上需要销毁现有的mInputManager并使用参数实例化一个新的mInputManager,以配置非独占输入的OIS。如何以及为什么要这样做的更详细描述可以在此处找到。
mInputManager->destroyInputObject(mMouse);
mInputManager->destroyInputObject(mKeyboard);
mInputManager->destroyInputObject(mJoy);
OIS::InputManager::destroyInputSystem(mInputManager);

// override OIS construction to avoid grabbing mouse
OIS::ParamList pl;
size_t windowHnd = 0;
std::ostringstream windowHndStr;

window->getCustomAttribute("WINDOW", &windowHnd);
windowHndStr << windowHnd;
pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
#if defined OIS_WIN32_PLATFORM
pl.insert(std::make_pair(std::string("w32_mouse"), std::string("DISCL_FOREGROUND" )));
pl.insert(std::make_pair(std::string("w32_mouse"), std::string("DISCL_NONEXCLUSIVE")));
pl.insert(std::make_pair(std::string("w32_keyboard"), std::string("DISCL_FOREGROUND")));
pl.insert(std::make_pair(std::string("w32_keyboard"), std::string("DISCL_NONEXCLUSIVE")));
#elif defined OIS_LINUX_PLATFORM
pl.insert(std::make_pair(std::string("x11_mouse_grab"), std::string("false")));
pl.insert(std::make_pair(std::string("x11_mouse_hide"), std::string("false")));
pl.insert(std::make_pair(std::string("x11_keyboard_grab"), std::string("false")));
pl.insert(std::make_pair(std::string("XAutoRepeatOn"), std::string("true")));
#endif

mInputManager = OIS::InputManager::createInputSystem( pl );

//Create all devices (We only catch joystick exceptions here, as, most people have Key/Mouse)
mKeyboard = static_cast<OIS::Keyboard*>(mInputManager->createInputObject( OIS::OISKeyboard, false ));
mMouse = static_cast<OIS::Mouse*>(mInputManager->createInputObject( OIS::OISMouse, false ));
try {
    mJoy = static_cast<OIS::JoyStick*>(mInputManager->createInputObject( OIS::OISJoyStick, false ));
}
catch(...) {
    mJoy = 0;
}

我仍然需要在特定的渲染窗口上进行物理点击,以便使其获得焦点,因此如果有一种方法可以在mouseover事件上授予渲染窗口焦点,那就太好了--但是,目前这已经满足我的需求...


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接