SFML community forums

Help => Graphics => Topic started by: slotdev on March 13, 2013, 10:17:41 pm

Title: sf::View zoom help
Post by: slotdev on March 13, 2013, 10:17:41 pm
Hi

First off, I have read the tutorial on sf::View, and I can't figure out how to make it do what I want, though I know it can, and it's probably very simple.

My graphics are 1024x768. My window is 1280x1024.

I need to zoom the graphics to the size of the window. I cannot use a stretch (forbidden..) so I have to use a view somehow. Can anyone help? I won't even post the code I've tried to do....its quite bad.
Title: Re: sf::View zoom help
Post by: Nexus on March 13, 2013, 10:24:51 pm
You cannot zoom the graphics without stretching them visually -- either you have distorted graphics or black borders. Have you tried to set the view's size to 1024x768?

You could also have a look at exploiter's view tutorial (https://github.com/SFML/SFML/wiki/Tutorial:-Using-View).
Title: [FIXED] Re: sf::View zoom help
Post by: slotdev on March 14, 2013, 02:22:42 pm
It's OK, I figured it out in the end. This is what I do, after opening a window of whatever size is necessary (1920x1080, 800x600, etc etc). My graphics were produced for a default resolution of 1024x768.

                int scrW = graphicsBaseSizeW; //1024 for this game
                int scrH = graphicsBaseSizeH; //768 for this game
                window1View = window1.GetView();
                window1View.Reset(sf::FloatRect(0,0,scrW,scrH));
                window1View.SetViewport(sf::FloatRect(0,0,1,1));
                window1View.SetSize(scrW,scrH);
                window1View.SetCenter((scrW/2),(scrH/2));
                window1.SetView(window1View);
 

Hope this helps someone in future...

Ed
Title: Re: sf::View zoom help
Post by: Nexus on March 14, 2013, 03:50:44 pm
Many of the statements in your code are not necessary. SetSize() and SetCenter() override the attributes set by Reset(). The viewport is (0,0,1,1) by default.

Also, why do you get a view from the window if you reset it? You could as well create a new one.


Quote from: slotdev's signature
I DO use SFML 2.0 - honestly!!
But then it's a terribly outdated revision ;)