SFML community forums

Help => General => Topic started by: Sub on November 07, 2018, 08:34:05 pm

Title: Difference between creating a window with VideoMode(...) and getDesktopMode()?
Post by: Sub on November 07, 2018, 08:34:05 pm
I had previously thought the two were more or less interchangable if I provided the same width / height that would be retrieved from the getDesktopMode call, but this doesn't appear to be the case.  With VSync enabled, the following two calls result in different FPS caps for me. 

I have a 144hz monitor, and calling the following results in an FPS cap of 60 when fullscreen (144 when windowed).
Code: [Select]
sf::RenderWindow window(sf::VideoMode(1920, 1080, 32), "SFML", sf::Style::Fullscreen);

This next call results in an FPS cap of 144 when fullscreen (same cap windowed). 

Code: [Select]
sf::RenderWindow window(sf::VideoMode::getDesktopMode(), "SFML", sf::Style::Fullscreen);

Is this expected behavior?  I've only tested this on Linux Mint Cinnamon 19.1 for whatever that is worth.
Title: Re: Difference between creating a window with VideoMode(...) and getDesktopMode()?
Post by: Sub on November 07, 2018, 08:41:23 pm
If anyone wants to test it, the following should do the trick

Code: [Select]
#include <SFML/Graphics.hpp>
#include <iostream>

int main()
{
// sf::RenderWindow window(sf::VideoMode(1920, 1080, 32), "SFML", sf::Style::Fullscreen);
sf::RenderWindow window(sf::VideoMode::getDesktopMode(), "SFML", sf::Style::Fullscreen);
window.setVerticalSyncEnabled(true);

sf::CircleShape shape(100.f);
shape.setFillColor(sf::Color::Green);

sf::Clock clock;

while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}

window.clear();
window.draw(shape);
window.display();

float currentTime = clock.getElapsedTime().asSeconds();
float fps = 1.f / (currentTime);
clock.restart();

std::cout << std::to_string(fps) << std::endl;
}

return 0;
}

Title: Re: Difference between creating a window with VideoMode(...) and getDesktopMode()?
Post by: eXpl0it3r on November 07, 2018, 08:51:09 pm
getDesktopMode() simply returns an instance of sf::VideoMode.

What's the video mode pixel depth you get from getDesktopMode()?

If that's the same, then I can only think of, that getDesktopMode triggering some state change when checking the available video modes "somehow". :-\
Title: Re: Difference between creating a window with VideoMode(...) and getDesktopMode()?
Post by: Sub on November 07, 2018, 08:55:31 pm
bitsPerPixel on getDesktopMode is 24.  When I call

Code: [Select]
sf::RenderWindow window(sf::VideoMode(1920, 1080, 24), "SFML", sf::Style::Fullscreen);

The FPS cap is 144, which is good I guess.  I'm not really sure why a bitsPerPixel of 32 would result in a different cap though.