pointer in wrong postition after window resize

luis

15-11-2015 22:08:04

Hi,
After window resize event MyGUI pointer is in a wrong position. As you can see in the screenshot the pointer in the upper position is drawn by MyGUI and the one in the lower position is a regular Ogre Overlay I'm also seeing hardware mouse so I can see tree pointers in the window, Ogre Overlay gets updated correctly and of course HW pointer after windows resize but MyGUI pointer gets a permanent offset position (vertical in this case since the rescale was going from 1280x800 to 1280x720) as you can see in the screenshot.

I'm using the code provided in the wiki, everything is working OK in MyGUI except this "bug". I'm also setting the new window resolution with the regular code:

void InputManager::setWindowExtents( int width, int height ) {
// Set mouse region (if window resizes, we should alter this to reflect as well)
const OIS::MouseState &mouseState = mMouse->getMouseState();
mouseState.width = width;
mouseState.height = height;
}


Using MyGUI 3.2.0 and Ogre 1.9, help please !

luis

15-11-2015 22:27:34

More info:
If I resize the window holding the mouse and dragging to the new size (as always with any resizable window) or if click the "maximize" button on the Ogre windows everything works as expected.

It only happens if I resize the ogre window using a combobox in my settings game menu that finally calls:


// width and height has the new window size
Ogre::Root::getSingletonPtr()->getAutoCreatedWindow()->setFullscreen( _configuration.mFullScreen , width, height );


If none here can help I'll probable disable the combobox selection for different resolutions and let the user resize the window by dragging a corner of clicking maximize button.....

Altren

16-11-2015 08:03:53

I think you should manually input mouse move event after windows resize.

luis

23-02-2017 12:12:10

hi again!
I'm still having the same problem after resize window during runtime. It happens only after resize using:
// width and height has the new window size
Ogre::Root::getSingletonPtr()->getAutoCreatedWindow()->setFullscreen( _configuration.mFullScreen , width, height );


The pointer has a wrong position since it has the previous window resolution. But If I drag the window and resize it manually MyGUI pointer position gets right again.

I've taking a look in MyGUI code and found it uses the same approach, override windowresize event:

// для оповещений об изменении окна рендера
void OgreRenderManager::windowResized(Ogre::RenderWindow* _window)
{
if (_window->getNumViewports() > mActiveViewport)
{
Ogre::Viewport* port = _window->getViewport(mActiveViewport);
#if OGRE_VERSION >= MYGUI_DEFINE_VERSION(1, 7, 0) && OGRE_NO_VIEWPORT_ORIENTATIONMODE == 0
Ogre::OrientationMode orient = port->getOrientationMode();
if (orient == Ogre::OR_DEGREE_90 || orient == Ogre::OR_DEGREE_270)
mViewSize.set(port->getActualHeight(), port->getActualWidth());
else
mViewSize.set(port->getActualWidth(), port->getActualHeight());
#else
mViewSize.set(port->getActualWidth(), port->getActualHeight());
#endif

// обновить всех
mUpdate = true;

updateRenderInfo();

onResizeView(mViewSize);
}
}


I think there is a but there... it has to be there, I'm seeing tree mouse pointers (system, MyGUI and my own overlay), the only one in the wrong position is the one controlled by MyGUI. I'm using MyGUI 3.2.0 and the vanilla MyGUI input listener.

I did add to traces in my app:
void GUIManager::update( Ogre::FrameEvent const &evt )
{
// Call update to current controller
if( mActiveMyGUIController )
{
if( mResize )
{
mActiveMyGUIController->onWindowResize( mWindowWidth, mWindowHeight );
_cprintf("GUIManager::update %d %d\n", mWindowWidth, mWindowHeight);
MyGUI::IntSize const &msize = MyGUI::RenderManager::getInstance().getViewSize();
_cprintf("GUIManager::update myguisize %d %d\n", msize.width, msize.height );
MyGUI::IntSize osize = MyGUI::OgreRenderManager::getInstance().getViewSize();
_cprintf("GUIManager::update OgreRenderManager myguisize %d %d\n", osize.width, osize.height );
//MyGUI::OgreRenderManager::getInstance().windowResized( Ogre::Root::getSingletonPtr()->getAutoCreatedWindow() );
}
mActiveMyGUIController->update( evt );
}
// Call update to modal if active
if( mModalPopUp->isActive() )
{
if( mResize )
mModalPopUp->onWindowResize( mWindowWidth, mWindowHeight );
mModalPopUp->update( evt );
}
mResize = false;
}


This is the output going from 1280x800 to 1600 x 1024:

GameManager::windowResized 1600 1024
GUIManager::setWindowDimensions 1600 1024
GUIManager::setWindowDimensions myguisize 1280 800
GUIManager::update 1600 1024
GUIManager::update myguisize 1280 800
GUIManager::update OgreRenderManager myguisize 1280 800


which is obviously wrong in MyGUI side. then if I drag the window size, the output is:

GameManager::windowResized 1600 1023
GUIManager::setWindowDimensions 1600 1023
GUIManager::setWindowDimensions myguisize 1280 800
GameManager::windowResized 1600 1022
GUIManager::setWindowDimensions 1600 1022
GUIManager::setWindowDimensions myguisize 1600 1023
GameManager::windowResized 1600 1021
GUIManager::setWindowDimensions 1600 1021
GUIManager::setWindowDimensions myguisize 1600 1022
GUIManager::update 1600 1021
GUIManager::update myguisize 1600 1021
GUIManager::update OgreRenderManager myguisize 1600 1021


And suddenly mouse pointer in MyGUI gets fixed and gets the right position....
This is a serious bug... I dont see how to fix it without touching MyGUI code... and i cant release the game with this bug or forcing the user to restart the app when changing resolution. It happens in full screen too... :(

luis

23-02-2017 13:33:52

Ok finally fixed it. I've changed computer and I had to setup a MYGUI+Ogre dev environment again... what a PITA !! :)

Here is my change, file MyGUI_3.2.0\Platforms\Ogre\OgrePlatform\src\MyGUI_OgreRenderManager.cpp:

// для оповещений об изменении окна рендера
void OgreRenderManager::windowResized(Ogre::RenderWindow* _window)
{
// if (_window->getNumViewports() > mActiveViewport)
// {
// Ogre::Viewport* port = _window->getViewport(mActiveViewport);
//#if OGRE_VERSION >= MYGUI_DEFINE_VERSION(1, 7, 0) && OGRE_NO_VIEWPORT_ORIENTATIONMODE == 0
// Ogre::OrientationMode orient = port->getOrientationMode();
// if (orient == Ogre::OR_DEGREE_90 || orient == Ogre::OR_DEGREE_270)
// mViewSize.set(port->getActualHeight(), port->getActualWidth());
// else
// mViewSize.set(port->getActualWidth(), port->getActualHeight());
//#else
// mViewSize.set(port->getActualWidth(), port->getActualHeight());
//#endif
//
// // обновить всех
// mUpdate = true;
//
// updateRenderInfo();
//
// onResizeView(mViewSize);
// }
// below by luis:
unsigned int colourDepth, width = 1024, height = 768;
int left = 0, top = 0;
_window->getMetrics( width, height, colourDepth, left, top );

mViewSize.set(width, height);
// обновить всех
mUpdate = true;
updateRenderInfo();
onResizeView(mViewSize);
}

Hope this helps someone here ;)