I cannot move the mouse out of the OGRE Render Window
-
- Gnoblar
- Posts: 3
- Joined: Mon Jan 17, 2005 6:21 am
I cannot move the mouse out of the OGRE Render Window
When I run the OGRE GUI Sample,I cannot move my mouse out of the OGRE Render Window.Can anybody tell me why?Another question,I found my mouse move quite slowly in the OGRE GUI Sample's Render Window.Please help,thanks!
-
- Gremlin
- Posts: 150
- Joined: Wed Oct 20, 2004 2:35 pm
- Location: Paris, France
It is because the samples captures the mouse. I don't think there is a way to avoid that unless you write your own input system. That's because the input system provided by Ogre only exists because it was needed to quickly produce demos. It was never intended to be a perfect input system. But it works for most case.When I run the OGRE GUI Sample,I cannot move my mouse out of the OGRE Render Window.Can anybody tell me why?
Banania
-
- OGRE Retired Team Member
- Posts: 3067
- Joined: Tue Feb 10, 2004 12:53 pm
- Location: The Netherlands
- x 1
-
- Greenskin
- Posts: 133
- Joined: Tue Oct 15, 2002 10:14 am
- Location: Helsinki, Finland
- x 1
However, if you are creating something that you occasionally need to run in windowed standard cursor support is cool. I use the standard win32 cursor by replacing the main OGRE rendering loop with a custom one. The events from Windows are then fed into CEGUI (that has a disabled mouse as well).
Here is basically what I'm doing (the real code is slightly more complex):
This lets the application drop the FPS to 10-15 and still keep the user feeling everything is running smoothly. 
Here is basically what I'm doing (the real code is slightly more complex):
Code: Select all
main()
{
while(isRunning) {
pumpMessages();
if(Ogre::Root::getSingleton().renderOneFrame() == false)
isRunning = false;
}
}
pumpMessages()
{
// Pump messages on Win32
MSG msg;
while(PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE)) {
TranslateMessage(&msg );
if(main != NULL)
main->injectMessageWin32(msg);
DispatchMessage(&msg );
}
}
// Message handler
void
Main::injectMessageWin32(MSG msg)
{
CEGUI::System& cegui = CEGUI::System::getSingleton();
char keyCode;
switch(msg.message) {
case WM_LBUTTONDOWN:
cegui.injectMouseButtonDown(CEGUI::LeftButton);
break;
case WM_LBUTTONUP:
cegui.injectMouseButtonUp(CEGUI::LeftButton);
break;
case WM_RBUTTONDOWN:
cegui.injectMouseButtonDown(CEGUI::RightButton);
break;
case WM_RBUTTONUP:
cegui.injectMouseButtonUp(CEGUI::RightButton);
break;
case WM_MBUTTONDOWN:
cegui.injectMouseButtonDown(CEGUI::MiddleButton);
break;
case WM_MBUTTONUP:
cegui.injectMouseButtonUp(CEGUI::MiddleButton);
break;
case WM_MOUSEMOVE: {
POINTS currentPos = MAKEPOINTS(msg.lParam);
int mouseX = currentPos.x;
int mouseY = currentPos.y;
if(!(mouseX < 0 || mouseY < 0 ||
mouseX >= static_cast<int>(renderWindow->getWidth()) ||
mouseY >= static_cast<int>(renderWindow->getHeight()))) {
CEGUI::MouseCursor::getSingleton().setPosition(CEGUI::Point(static_cast<float>(mouseX), static_cast<float>(mouseY)));
cegui.injectMouseMove(0.0f, 0.0f);
}
break;
}
case WM_KEYDOWN:
keyCode = static_cast<char>(msg.wParam);
CEGUI::System::getSingleton().injectKeyDown(InputEventConvert::convertKeyWin32ToCEGUI(keyCode));
break;
case WM_KEYUP:
keyCode = static_cast<char>(msg.wParam);
CEGUI::System::getSingleton().injectKeyUp(InputEventConvert::convertKeyWin32ToCEGUI(keyCode));
break;
}
}

-
- Gnoblar
- Posts: 3
- Joined: Mon Jan 17, 2005 6:21 am
thanks a lot
Thanks a lot!But I am still puzzling why the mouse cursor moves so slowly?
-
- Greenskin
- Posts: 133
- Joined: Tue Oct 15, 2002 10:14 am
- Location: Helsinki, Finland
- x 1
Re: thanks a lot
It moves slowly because it is only rendered every time the ogre screen is rendered. If you set up the mouse using the above the mouse will move as quickly as your screen can update.cubic wrote:Thanks a lot!But I am still puzzling why the mouse cursor moves so slowly?

-
- Greenskin
- Posts: 145
- Joined: Wed Jan 19, 2005 4:36 am
- Location: Arica, Chile
We too want to use the standard hardware cursor on our windowed Ogre application. I'm trying to understand the specifics here...Kai-Peter wrote: I use the standard win32 cursor by replacing the main OGRE rendering loop with a custom one. The events from Windows are then fed into CEGUI (that has a disabled mouse as well).
Are you saying that you have to modify and recompile Ogre to make this work, or just that you change your own code?
I'd prefer a way we could do this against 'stock ogre' - if that isn't possible, maybe we need to suggest this as a feature?
Thanks.
-
- OGRE Community Helper
- Posts: 198
- Joined: Sat Oct 02, 2004 9:11 am
- Location: San Francisco, California, USA
The changes are all in your own code. You will need to create your own main window using the Win32 API, or some other app toolkit like WTL or GTK.RoundSparrow wrote: We too want to use the standard hardware cursor on our windowed Ogre application. I'm trying to understand the specifics here...
Are you saying that you have to modify and recompile Ogre to make this work, or just that you change your own code?
Then you'll need to pass the external window handle to Ogre (see http://www.ogre3d.org/docs/api/html/cla ... rSystema14 w.r.t. externalWindowHandle in the NameValuePairList param) and handle all your own input according to the window toolkit you are using. You can then call the single-frame render function (renderOneFrame insead of startRendering) whenever you want to redraw the screen.
See the source code for the MeshViewer add-on (in CVS under ogreaddons) for inspiration.