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

Author Topic: vertical sync does not seems to work (maybe ubuntu problem)  (Read 4672 times)

0 Members and 2 Guests are viewing this topic.

sfora14

  • Newbie
  • *
  • Posts: 10
    • View Profile
    • Email
vertical sync does not seems to work (maybe ubuntu problem)
« on: December 28, 2012, 09:46:15 am »
hello all, i have problems with vertical syncing and screen tearing when running my app on PC with Ubuntu 12.10 installed, GPU is nvidia gtx 275 card, drivers are 304.41. I cant get rid  of excessive screen tearing, using window.setVerticalSyncEnabled(true); changes nothing at all. i red that ubuntu have some problems with nvidia drivers so it may be ubuntu issue not sfml but the only place where it happens is my sfml app. Here is minimal code sample, niebo.png resolution is 2048x2048:
#include <SFML/Audio.hpp>
#include <SFML/Graphics.hpp>
#include <sstream>

 int main()
 {
     float czas1;
     float klatki;
     sf::Vector2f vfklatki;
     sf::Vector2i viklatki(0,0);
     sf::RenderWindow window(sf::VideoMode(800, 600), "SFML window",sf::Style::Fullscreen);
     window.setVerticalSyncEnabled(true);
     sf::Clock clock1;
     sf::Texture texture;
     texture.loadFromFile("niebo.png");
     sf::Sprite sprite;
     sprite.setTexture(texture);
     sf::View view;
     view.reset(sf::FloatRect(800,600,800,600));
     window.setView(view);
     sf::Font font;
     font.loadFromFile("FreeMono.ttf");
    while (window.isOpen())
     {
         sf::Event event;
         while (window.pollEvent(event))
         {
             if ((event.type == sf::Event::KeyPressed)&&(event.key.code==sf::Keyboard::Escape))
                 window.close();
         }
         clock1.restart();
         window.clear();
         window.draw(sprite);
         if (sf::Keyboard::isKeyPressed(sf::Keyboard::Left))
            view.move(-1000.0f*czas1,0.0f);
            if (sf::Keyboard::isKeyPressed(sf::Keyboard::Right))
            view.move(1000.0f*czas1,0.0f);
            if (sf::Keyboard::isKeyPressed(sf::Keyboard::Up))
            view.move(0.0f,-1000.0f*czas1);
            if (sf::Keyboard::isKeyPressed(sf::Keyboard::Down))
            view.move(0.0f,1000.0f*czas1);
        window.setView(view);
        vfklatki = window.mapPixelToCoords(viklatki);

        klatki = 1/czas1;

        std::stringstream ss;
        ss << klatki;
        std::string myString = ss.str();
        sf::Text text(myString,font,50);
        text.setPosition(vfklatki);
        window.draw(text);
        window.display();
        sf::Time time1 = clock1.getElapsedTime();
        czas1 = time1.asSeconds();
     }

     return EXIT_SUCCESS;
 }

 

btw, there is no change in documentation about changing convertCoords function to mapPixelToCoords.
 I would be very grateful for confirming or denying if on your Ubuntu installations there is the same issue.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11033
    • View Profile
    • development blog
    • Email
AW: vertical sync does not seems to work (maybe ubuntu problem)
« Reply #1 on: December 28, 2012, 04:30:45 pm »
Have you checked that the driver doesn't force VSync to be off?

Yes the documentation matches the RC version.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

sfora14

  • Newbie
  • *
  • Posts: 10
    • View Profile
    • Email
Re: vertical sync does not seems to work (maybe ubuntu problem)
« Reply #2 on: December 28, 2012, 05:58:50 pm »
i checked settings in nvidia system panel and in compizconfig as well. in both places there seems to be vsync turned on, also when i run glxgears it seems that number of frames match my refresh rate. I returned to linux after few years so im not sure if i checked everything what i could.
Even more weird thing is that after changing driver to another one and running my app i have constant 80 fps even that i commented out syncing or frame limit in my program. Tearing is still there. On previous drivers i reached fps numbers betwen 450-800 when without vsync or frame limiting. Ill have to further investigate it and try to run my app on other systems, right now im trying to build sfml2 for windows7.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11033
    • View Profile
    • development blog
    • Email
Re: vertical sync does not seems to work (maybe ubuntu problem)
« Reply #3 on: December 28, 2012, 07:25:42 pm »
When you're talking about tearing, do you also refer to the posted code above? I've tested it with my own image (since you didn't provide yours) and I didn't get any tearing. Neither with VSync, frame-rate limit or no limit at all and I can successfully go up to 1500-2000 fps, but I'm using Windows 8, MinGW GCC 4.7.2 and have a ATI graphics card.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything