Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: sf::View zoom help  (Read 2339 times)

0 Members and 1 Guest are viewing this topic.

slotdev

  • Sr. Member
  • ****
  • Posts: 385
    • View Profile
sf::View zoom help
« 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.
SFML 2.1

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: sf::View zoom help
« Reply #1 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.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

slotdev

  • Sr. Member
  • ****
  • Posts: 385
    • View Profile
[FIXED] Re: sf::View zoom help
« Reply #2 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
SFML 2.1

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: sf::View zoom help
« Reply #3 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 ;)
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development: