Likewise, if I rotate the screen from landscape to portrait, the view starts at about the middle of the screen, such as elements starting at pos (0, screenHeight/2) instead of (0, 0).
Here is what I've tried:
Code: Select all
void checkWindowSizeUpdate()
{
Game::window.resized.resized = false;
bool screenChanged = false;
int newX = 0, newY = 0, newWidth = 0, newHeight = 0;
#ifdef _IRR_ANDROID_PLATFORM_
newWidth = ANativeWindow_getWidth(Game::state->window);
newHeight = ANativeWindow_getHeight(Game::state->window);
#elif _WIN32 || _WIN64
newWidth = Game::driver->getScreenSize().Width;
newHeight = Game::driver->getScreenSize().Height;
HWND hWnd = GetActiveWindow();
RECT rect;
if(GetWindowRect(hWnd, &rect))
{
newX = rect.left;
newY = rect.top;
}
#endif
screenChanged = Game::window.x != newX || Game::window.y != newY || newWidth != Game::window.width || newHeight != Game::window.height;
if (screenChanged)
{
Game::window.width = newWidth;
Game::window.height = newHeight;
Game::window.x = newX;
Game::window.y = newY;
core::rect<s32> rct = core::rect<s32>(Game::window.x,Game::window.y,Game::window.x+Game::window.width,Game::window.y+Game::window.height);
#ifdef _WIN32 || _WIN64
Game::device->getCursorControl()->setReferenceRect(&rct);
#endif // _WIN32
Game::smgr->getActiveCamera()->setAspectRatio((float)Game::window.width/(float)Game::window.height);
Game::log("NEW SCREEN SIZE: " + Operations::intToString(Game::window.x) + ", " + Operations::intToString(Game::window.y) + ", " +
Operations::intToString(Game::window.width) + ", " + Operations::intToString(Game::window.height));
Game::driver->setViewPort(recti(0, 0, Game::window.width, Game::window.height));
}
}
The "NEW SCREEN SIZE: " output is correctly outputting the Android rotated screen resolution.
Any help would be appreciated.