Thanks for your help! You are right, the resolution does get set and when I change the size while keeping the aspect ratio the same it looks correct.
The problem was that I didn`t update the camera`s aspect ratio in the render loop. I never knew or realized that was necessary.
Adding: myCamera->setAspectRatio(Ogre::Real(myWindow->getWidth()) / Ogre::Real(myWindow->getHeight())); fixed it.
Here is the minimal reproduction code for the initial window being wrong:
Code: Select all
#include "OgreWindowEventUtilities.h"
#include "Vao/OgreVaoManager.h"
#include "OgreRoot.h"
#include "OgreRenderSystem.h"
#include "OgreWindow.h"
#include "OgreCamera.h"
#include "Compositor/OgreCompositorManager2.h"
int main()
{
Ogre::Root* myRoot = OGRE_NEW Ogre::Root();
#if defined(_DEBUG)
myRoot->loadPlugin("RenderSystem_Direct3D11_d.dll");
myRoot->loadPlugin("RenderSystem_GL3Plus_d.dll");
#else
myRoot->loadPlugin("RenderSystem_GL3Plus.dll");
myRoot->loadPlugin("RenderSystem_Direct3D11.dll");
//Linux
//root->loadPlugin("/usr/local/lib/OGRE/RenderSystem_GL");
#endif
Ogre::RenderSystemList::const_iterator renderers = myRoot->getAvailableRenderers().begin();
while (renderers != myRoot->getAvailableRenderers().end())
{
Ogre::String rName = (*renderers)->getName();
if (rName == "OpenGL 3+ Rendering Subsystem")//Direct3D11 Rendering Subsystem, OpenGL 3+ Rendering Subsystem
break;
renderers++;
}
Ogre::RenderSystem* renderSystem = *renderers;
renderSystem->setConfigOption("Full Screen", "No");
renderSystem->setConfigOption("Video Mode", "1000 x 1080 @ 32-bit colour"); //1920
//renderSystem->setConfigOption("Display Frequency", "60 Hz");
renderSystem->setConfigOption("FSAA", "8"); //stutters at 16
//renderSystem->setConfigOption("Fixed Pipeline Enabled", "Yes");
//renderSystem->setConfigOption("RTT Preferred Mode", "FBO");
//renderSystem->setConfigOption("VSync", "Yes");
renderSystem->setConfigOption("sRGB Gamma Conversion", "Yes");
myRoot->setRenderSystem(renderSystem);
Ogre::Window* myWindow = myRoot->initialise(true, "Ogre Window");
// myWindow = myRoot->createRenderWindow("Ogre Window", 1920, 1080, false, params);
//myWindow->reposition(0, -8);
//myWindow->requestFullscreenSwitch(false, false, 0, 500, 1080, 0, 0);
//myWindow->reposition(0, 0);
//myWindow->requestResolution(1920, 1080);
Ogre::SceneManager* mySceneManager = myRoot->createSceneManager(Ogre::ST_GENERIC, 1, "InstanceName");
//Ogre::SceneNode* myRootSceneNode = mySceneManager->getRootSceneNode();
Ogre::ResourceGroupManager::getSingleton().addResourceLocation("../media/models", "FileSystem", "General");
Ogre::ResourceGroupManager::getSingleton().addResourceLocation("../media/materials/textures", "FileSystem", "General");
Ogre::ResourceGroupManager::getSingleton().addResourceLocation("../media/materials/textures/Cubemaps", "FileSystem", "General");
Ogre::ResourceGroupManager::getSingleton().addResourceLocation("../media/packs/OgreCore.zip", "Zip");
Ogre::ResourceGroupManager::getSingleton().addResourceLocation("../media/2.0/scripts/materials/TutorialSky_Postprocess", "FileSystem");
Ogre::ResourceGroupManager::getSingleton().addResourceLocation("../media/2.0/scripts/materials", "FileSystem");
// Load all resources except compositor
Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups(false);
Ogre::ResourceGroupManager::getSingleton().addResourceLocation("../media/2.0/scripts/Compositors", "FileSystem", "Compositors");
Ogre::ResourceGroupManager::getSingleton().initialiseResourceGroup("Compositors", false);
myRoot->clearEventTimes();
Ogre::Camera* myCamera = mySceneManager->createCamera("cameraName");
myCamera->setPosition(0, 0, 0);
myCamera->lookAt(50, 0, 0);
myCamera->setNearClipDistance(0.12f); //1.0f
myCamera->setFarClipDistance(3000.0f);
myCamera->setAspectRatio(Ogre::Real(myWindow->getWidth()) / Ogre::Real(myWindow->getHeight()));
Ogre::CompositorManager2* compositorManager = myRoot->getCompositorManager2();
compositorManager->addWorkspace(mySceneManager, myWindow->getTexture(), myCamera, "TutorialSky_PostprocessWorkspace", true);//
while (!myWindow->isClosed())
{
//std::cout << "myWindow->isClosed(): " << myWindow->isClosed() << std::endl;
myCamera->setAspectRatio(Ogre::Real(myWindow->getWidth()) / Ogre::Real(myWindow->getHeight()));
myRoot->renderOneFrame();
Ogre::WindowEventUtilities::messagePump();
}
}
After moving the window for the first time you should see its content moving. The invisible borders are there too.
There is also a difference between: renderSystem->setConfigOption("Video Mode", "1920 x 1080 @ 32-bit colour"); and myWindow->requestResolution(1920, 1080); in windowed mode.
The latter seems to ignore the taskbar and the invisible border on the right(and maybe bottom).
If I open any of the samples and set "Full Screen" to "No" and "Video Mode" to 1920x1080 the entire top bar of the window is missing.
On a positive note: All the invisible borders are missing too. Maybe you fixed it there already?
Ouch! I gave up on Windows 10. They keep changing/breaking basic stuff regarding windows, keyboard and mouse cursor.
Yeah, sounds bad. I know why I waited till 2 months ago before I started to use it. Looks like it still hasn`t settled.
For me, fixing that isn`t a high priority, I can work around it.
Edit: Looks like Hearthstone(made with unity) hasn`t fixed that either.
If I set the resolution to 1920x1080 in windowed mode it has the invisible border on the left and part of the window is too far right. The bottom part of the window is behind the taskbar.