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

Author Topic: View -> Fullscreen Window. How to apply empty margin?  (Read 1500 times)

0 Members and 1 Guest are viewing this topic.

mcassimus

  • Newbie
  • *
  • Posts: 3
    • View Profile
View -> Fullscreen Window. How to apply empty margin?
« on: October 26, 2017, 08:40:42 pm »
I have a view defined as
sf::View view(sf::Rect<float>(0, 0, 310, 248));

I am then applying it to a window defined as
 sf::RenderWindow window(sf::Videomode::getFullscreenModes().at(0), "Space Invaders", sf::Style::Fullscreen);

I am trying to apply the view to any monitor of any aspect ratio and would like to keep the dimensions of the view and add void space around the view as needed. it works for any monitor with the aspect ratio of 5:4, which isnt even too common anymore. I am unable to figure out how to use view.setViewport(...); correctly to apply this empty space to fill the screen to keep the appropriate aspect ratio of the view. What would be the best way to center the view onto the window while blowing up the view as large as possible using whatever void space necessary?

fallahn

  • Sr. Member
  • ****
  • Posts: 492
  • Buns.
    • View Profile
    • Trederia
Re: View -> Fullscreen Window. How to apply empty margin?
« Reply #1 on: October 27, 2017, 12:16:20 am »
This wiki entry should point you in the right direction:
https://github.com/SFML/SFML/wiki/Source%3A-Letterbox-effect-using-a-view

mcassimus

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: View -> Fullscreen Window. How to apply empty margin?
« Reply #2 on: October 27, 2017, 09:54:51 pm »
Thank you very much, this resource helped a ton.

Now, is there a way to get the rotation of the display resolution through sfml or would that have to be something that needs to be retrieved through another resource?