Adam's Lair Forum
https://forum.adamslair.net:80/

Resolution/Window
https://forum.adamslair.net:80/viewtopic.php?f=4&t=749
Page 1 of 1

Author:  FreshAfro [ 2016/04/03, 00:36 ]
Post subject:  Resolution/Window

Heyho! I am fresh new to this forum and I am just learning duality! So, a couple of friends and I wanted to start making a game using the duality framework, but we are not sure how to handle resolution and responsiveness in window mode, so it would look the the way it should be on all screens and devices. Can someone help us out how to scale it the best way and what to do exactly?

I thank everyone that will be answering very much :)

Author:  Adam [ 2016/04/03, 11:00 ]
Post subject:  Re: Resolution/Window

Hello and welcome ^^

As always, there are lots of ways to approach the topic and I'd say it depends on the kind of game you want to make.

If you have a strategy game for example, it may be a good thing for players to use a higher resolution for simply displaying more stuff and providing a better overview on the map. In this case, you wouldn't have to do anything - this is the default behavior.

If you instead choose to provide a constant "view", you'll have to scale the rendering to match the resolution. There's a "soft" way that just does scaling, as it is done in the Dual Stick Space Shooter sample package, or more specifically here. You'll get a similar physical size / appearance at the cost of completely disregarding aspect ratio and thus providing a slightly different viewport on different screens.

Another option was implemented by loeller in the MoonRogue game with fixed scaling options and a black border around the main viewport, should the window be larger than that. A nice option for pixel art I think.

Author:  loeller [ 2016/04/03, 21:20 ]
Post subject:  Re: Resolution/Window

Hello, and welcome to the forums!

The latter two options Adam mentioned differ in a small, but important detail: camera mode. If you use the parallax camera, it's Z coordinate will determine the size of the area fitting on the screen, because of the perspective projection. If you disable the parallax setting, it's simpler: the ratio of the pixel and the world units is 1, since it is paralell projection.

In my game, I used flat (not parallax) projection, and scaling it up was dead simple because of Duality's flexible camera rendering pipeline. It didn't even involve coding. (Of course changing between multiple scaling levels needs some code.)

The main thing is, that you need two cameras, one of them rendering your game at a fixed resolution to a RenderTarget, which is a built-in Duality resource. In the RenderTarget's inspector, you need to assign a texture to render to.
It's important to set the destination texture's resolution before.

Set the texture's filtering mode to Nearest. After that, you can assign that texture to any sprite, which you can scale up. There are some limitations though: it only looks good with pixel graphics, and only at certain scale levels. Set the second camera to render only this sprite to screen using the render group controls, and the first mentioned camera to not.

There's more information of the process in this topic.

I hope it helps :]

Page 1 of 1 All times are UTC + 1 hour [ DST ]
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/