{"id":3165,"date":"2014-04-08T19:52:31","date_gmt":"2014-04-08T09:52:31","guid":{"rendered":"http:\/\/www.vectorstorm.org\/?p=3165"},"modified":"2014-04-08T19:52:31","modified_gmt":"2014-04-08T09:52:31","slug":"resolution-change","status":"publish","type":"post","link":"https:\/\/www.vectorstorm.com.au\/2014\/04\/08\/resolution-change\/","title":{"rendered":"Resolution change will take effect after restarting"},"content":{"rendered":"

\"Screen<\/a>Image unrelated.<\/p>\n

One of my pet peeves is games which need to quit and restart when some apparently trivial setting is changed.\u00a0 So when the original MMORPG Tycoon was released, I made an extra effort to make sure that you could change the game’s resolution while the game was running.\u00a0 It worked, but it was problematic, and it imposed a lot of restrictions on the way the game was structured and the what I could draw in that interface.<\/p>\n

I’ve recently added support for freely changing game resolution to Vectorstorm, in the v2 branch.\u00a0 Including simple window resizing and pixel density changes (due to dragging the game window from a low-density display to a high-density display, for example).\u00a0 And this has brought me the opportunity to make the “no-restart” resolution change work in MMORPG Tycoon 2 as well.<\/p>\n

Changing resolution is a surprisingly tricky problem.\u00a0 In the original VectorStorm engine, doing it involved closing the current window, creating a new window, and a new OpenGL rendering context.\u00a0 This meant that every current OpenGL object needed to be re-created in the new context.\u00a0 Back in the era of the original MMORPG Tycoon, that basically just meant display lists.\u00a0 In the original MMORPG Tycoon, I solved the issue by not using any display lists in the main menu, where you changed resolutions.<\/p>\n

These days, we don’t use OpenGL display lists any more, but there are a lot more objects that need to survive the resize event;\u00a0 VBOs, textures, shaders, render targets, etc;\u00a0 far more than I really want to recreate on the fly.\u00a0 So we don’t do that any more — now we resize the data in the existing context, so that I can keep the currently loaded data still resident in the OpenGL context.\u00a0 This leads to some complications, of course — I need to recreate render targets at the new window size, and similar updates.\u00a0 But this isn’t the only reason that many games don’t support changing resolution at runtime.<\/p>\n

For many games, the real problem is needing to rearrange and rebuild the onscreen user interface to fit the newly resized window in which the game is being played.\u00a0 This can be surprisingly tricky, especially if text is involved.<\/p>\n

I’ve made two fixes to address these issues:\u00a0 First, MMORPG Tycoon 2 now watches for resize events, and will re-layout all of its UI if and when one happens.\u00a0 This allows resizing to happen at any time (simply adjusting the size of the window in the usual way, entering\/exiting full-screen mode, etc), and the game’s UI automatically updates to fit the new screen size.\u00a0 Second, VectorStorm itself now remembers every bit of text that it’s rendering (via the Fragment system only), and can now be asked to re-build all renderable text fragments, to look as good as possible at the new display size.<\/p>\n

I’m pretty excited about this.\u00a0 And it’s neat to be able to take the game window from a retina screen to an external screen, and then switch to fullscreen, all seamlessly while the game is running.\u00a0 Looking forward to the next milestone build, which hopefully won’t be too too far in the future.\u00a0 More details very soon.<\/p>\n

(the linked image is of a terrain rendering bug, in which large, 128×128 meter blocks of terrain appear to be ‘grid squares’, due to misalignment with their neighbors))<\/p>\n","protected":false},"excerpt":{"rendered":"

Image unrelated. One of my pet peeves is games which need to quit and restart when some apparently trivial setting is changed.\u00a0 So when the original MMORPG Tycoon was released, I made an extra effort to make sure that you could change the game’s resolution while the game was running.\u00a0 It worked, but it was…<\/p>\n","protected":false},"author":1,"featured_media":3167,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":""},"categories":[4,24,25,3],"tags":[],"jetpack_featured_media_url":"https:\/\/www.vectorstorm.com.au\/wp-content\/uploads\/2014\/04\/Grid.png","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/po9WK-P3","_links":{"self":[{"href":"https:\/\/www.vectorstorm.com.au\/wp-json\/wp\/v2\/posts\/3165"}],"collection":[{"href":"https:\/\/www.vectorstorm.com.au\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.vectorstorm.com.au\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.vectorstorm.com.au\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.vectorstorm.com.au\/wp-json\/wp\/v2\/comments?post=3165"}],"version-history":[{"count":2,"href":"https:\/\/www.vectorstorm.com.au\/wp-json\/wp\/v2\/posts\/3165\/revisions"}],"predecessor-version":[{"id":3169,"href":"https:\/\/www.vectorstorm.com.au\/wp-json\/wp\/v2\/posts\/3165\/revisions\/3169"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.vectorstorm.com.au\/wp-json\/wp\/v2\/media\/3167"}],"wp:attachment":[{"href":"https:\/\/www.vectorstorm.com.au\/wp-json\/wp\/v2\/media?parent=3165"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.vectorstorm.com.au\/wp-json\/wp\/v2\/categories?post=3165"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.vectorstorm.com.au\/wp-json\/wp\/v2\/tags?post=3165"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}