SFML community forums

Help => General => Topic started by: aanthonyz on April 24, 2014, 11:44:54 pm

Title: Resolution problem
Post by: aanthonyz on April 24, 2014, 11:44:54 pm
Hello, im making a game in 1920x1080, all images are to that size etc. How can I make it so people can use different resolutions with the game? If you want a specific example I have a friend who was testing it and has 1366x768.Would I have to make separate images for each resolution I want to support or can I do a scale for everything or a view scale?
Title: Re: Resolution problem
Post by: Ixrec on April 25, 2014, 12:12:10 am
You can scale everything with views, so you won't need separate images for each resolution.  The view tutorial (http://www.sfml-dev.org/tutorials/2.1/graphics-view.php) doesn't cover this specific use, but it's very easy to figure out.
Title: Re: Resolution problem
Post by: aanthonyz on April 25, 2014, 12:27:54 am
What I was thinking was depending on their resolution change this:

sf::View view(sf::FloatRect(0, 0, 1920, 1080));

to whatever size they have it set at.
Title: Re: Resolution problem
Post by: Ixrec on April 25, 2014, 12:40:39 am
You're getting view and viewport confused.  Read the tutorial carefully.

What you want is a constant view of {0,0,1920,1080} and a constant viewport of {0,0,1,1}.  Neither should change, though you will have to explicitly reset the view every time you recreate the window.
Title: Re: Resolution problem
Post by: aanthonyz on April 25, 2014, 12:45:43 am
Wait both view and viewport have to change? Now I understand that view has to stay the same 1920x1080 but wouldnt viewport have to change that way it fits the screen?
Title: Re: Resolution problem
Post by: zsbzsb on April 25, 2014, 01:16:47 am
Wait both view and viewport have to change?

What isn't clear?

....constant viewport of {0,0,1,1}.  Neither should change...
Title: Re: Resolution problem
Post by: aanthonyz on April 25, 2014, 02:42:04 am
Well now im trying to figure it out. Sorry for my slowness since this is my first graphic programming language.
So both would stay constant and if the screen gets resized just reset the view?
Title: Re: Resolution problem
Post by: zsbzsb on April 25, 2014, 04:19:03 am
If all you want is for the screen contents to stretched to whatever resolution the user is using then all you need to do is set the view once at window creation. The only other time you would need to set the view is if you recreate the window.

By default when the window resized nothing will happen to the view, so the view stays the same size and everything gets scaled to fit the window.