0

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

2
  • 1
    Check the resolution of your display in "about this mac". 500x500 is pretty small on a retina display. Commented Sep 5, 2019 at 9:00
  • Yes, I have a 2880 x 1800 Retina display. Is there a standard way to get around this ? Commented Sep 5, 2019 at 9:35

1 Answer 1

1

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
}


Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.