繁体   English   中英

Ogre3D,多个监视器和鼠标光标

[英]Ogre3D, Multiple Monitors, and the Mouse Cursor

我正在开发一个需要在OpenGL中进行多头渲染的应用程序。 现在,我可以渲染到多个屏幕,但我的鼠标光标的行程仅限于一个屏幕。 但是,我希望能够在所有渲染的屏幕上使用鼠标光标。

有没有人遇到同样的问题,如果有的话,你是怎么解决它的?

我找到了一个有效的解决方案。 首先,我必须在窗口模式而不是全屏模式下实例化我的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::RenderWindowOgre::FrameListener的构造函数中(在这种情况下,继承自ExampleFrameListener ,我基本上必须销毁现有的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事件的渲染窗口,那将是很好的 - 但是,这适合我现在的需要...

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM