0
votes

Has anyone run into an issue where running the basic window setup in SFML renders a window with smaller size than what was actually passed as argument. I am not sure what the issue is:

#include <SFML/Graphics.hpp>

int main()
{
    sf::RenderWindow window(sf::VideoMode(500, 500), "SFML works!");
    sf::Event event;
    while(window.isOpen()) {
        while(window.pollEvent(event)) {
            if(event.type == sf::Event::Closed)
                window.close();
        }
    }
    return 0;
}

I am running my code on mac os. Here is the result that I get - that looks a lot smaller than 500 x 500.

enter image description here

1
Check the resolution of your display in "about this mac". 500x500 is pretty small on a retina display. - Botje
Yes, I have a 2880 x 1800 Retina display. Is there a standard way to get around this ? - mrk

1 Answers

1
votes

If your mac is a high resolution retina display, you'll have to find a way of scaling your window to match that. A 500x500 window in a 1280 x 720 display will be very large compared to a window that's on a 3840 x 2160 display for example. You could probably do it with something like this:

void scaleWindow(int& screenWidth, int& screenHeight, float portion){
    screenWidth *portion;
    screenHeight *portion;
}

main(){
    int windowWidth     = 1920;
    int windowHeight    = 1080;
    float scale         = 0.5
    scaleWindow(windowWidth, windowHeight, scale) // Half your current screen size

    //make window here
}