Change resolution of RenderWindow on resize

Problems building or running the engine, queries about how to use features etc.
Post Reply
Pacha
Halfling
Posts: 63
Joined: Tue Dec 04, 2012 12:59 am

Change resolution of RenderWindow on resize

Post by Pacha »

I am using the OpenGL rendering system, and when I increase the size of the window, the resolution is really low as it keeps the resolution before resizing.

Is it possible to change the resolution of the rectangle I am rendering? I already looked at the forums, and all the threads are really, really old.

Thanks.
User avatar
areay
Bugbear
Posts: 819
Joined: Wed May 05, 2010 4:59 am
Location: Auckland, NZ
x 69

Re: Change resolution of RenderWindow on resize

Post by areay »

I haven't done this either, but here's how I'd try it.

I assume that your class that starts Ogre inherits from Ogre::WindowEventListener and that you can therefore redeclare a public function like this

Code: Select all

	void windowResized(Ogre::RenderWindow *rw);
Then your in your implementation, you get the size of the new renderwindow. Now you have to figure out what the biggest supported resolution is that fits into the newly resized window.

Code: Select all

void GameEngine::windowResized(Ogre::RenderWindow *rw) {
	unsigned int width, height, depth;
	int left, top;
	rw->getMetrics( width, height, depth, left, top );

       //width & height are now set to the renderwindow size

   // ripped off from http://www.ogre3d.org/forums/viewtopic.php?f=2&t=28437
   // get available rendering devices and available resolutions
   Ogre::ConfigOptionMap& CurrentRendererOptions = mRenderSystem->getConfigOptions();
   Ogre::ConfigOptionMap::iterator configItr = CurrentRendererOptions.begin();
   while( configItr != CurrentRendererOptions.end() ) 
    {
      if( (configItr)->first == "Rendering Device" ) 
        {
         // Store Available Rendering Devices
         mFoundRenderDevices = ((configItr)->second.possibleValues);
      }
      if( (configItr)->first == "Video Mode" )
      {
         // Store Available Resolutions
         mFoundResolutions = ((configItr)->second.possibleValues);
      }
      configItr++;
   }

  //then iterate through the mFoundResolutions and find the biggest one that fits inside the 'width' & 'height' variables

//Then start reading from this post, Jacmoe shows us that the 'SampleBrowser' application includes code to perform the destruction and recreation of the renderer with new resolution settings.
//http://www.ogre3d.org/forums/viewtopic.php?f=2&t=10811#p398662

Post Reply