I'm developing a game, and I want to support different resolutions, so I need to make a scaling algorithm. This is what i came up with:
void Player::setViewSize(sf::Vector2f ViewSize)
{
const sf::Vector2f defaultSize{960, 540}; // A size constant. I came up with it because it is a quarter of 1080p
float scaleFactor = 1;
while(ViewSize.x / scaleFactor > defaultSize.x || ViewSize.y / scaleFactor > defaultSize.y)
scaleFactor++;
PlayerView.setSize(ViewSize.x / scaleFactor, ViewSize.y / scaleFactor);
}
Are there better scaling algorithms? If so? Can you recommend one?
*edit: Please Remove the other 2 posts