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

Author Topic: Image Stretch with window resize  (Read 2274 times)

0 Members and 1 Guest are viewing this topic.

Robonics

  • Newbie
  • *
  • Posts: 7
    • View Profile
    • Email
Image Stretch with window resize
« on: January 28, 2020, 11:58:18 pm »
I was a bit unsure of whether to post this in Graphics or Window, but I think this will be the most relevant. I'm using SFML in C++and ran into an issue. How and I prevent my Images from resizing themselves? What I mean is that when I load a sprite, in this case a rectangle with a logo on it, how can I prevent it from being stretch with the window.
It should look like:
What it does look like:

Does anyone have any suggestions? I've already tried setting a sf::View, which did not work.

fallahn

  • Hero Member
  • *****
  • Posts: 507
  • Buns.
    • View Profile
    • Trederia
Re: Image Stretch with window resize
« Reply #1 on: January 29, 2020, 12:33:57 am »
A custom sf::View is the way to go. This wiki article might explain it better: https://github.com/SFML/SFML/wiki/Source%3A-Letterbox-effect-using-a-view

Robonics

  • Newbie
  • *
  • Posts: 7
    • View Profile
    • Email
Re: Image Stretch with window resize
« Reply #2 on: January 29, 2020, 01:56:08 am »
Thanks, it helped. I was thinking something similar, but I couldn't find the right variable to draw to make it work. Like I didn't know
window.getSize().x
was a thing.

 

anything