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

Author Topic: Difference between creating a window with VideoMode(...) and getDesktopMode()?  (Read 503 times)

0 Members and 1 Guest are viewing this topic.

Sub

  • Full Member
  • ***
  • Posts: 143
    • View Profile
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.
« Last Edit: November 07, 2018, 08:46:35 pm by Sub »

Sub

  • Full Member
  • ***
  • Posts: 143
    • View Profile
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;
}


eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 9221
    • View Profile
    • development blog
    • Email
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". :-\
Official FAQ: https://www.sfml-dev.org/faq.php
Nightly Builds: https://www.nightlybuilds.ch/
——————————————————————
Dev Blog: https://dev.my-gate.net/
Thor: http://www.bromeon.ch/libraries/thor/

Sub

  • Full Member
  • ***
  • Posts: 143
    • View Profile
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.