#include <SFML/Graphics.hpp>
#ifdef _DEBUG
#pragma comment(lib, "sfml-system-d.lib")
#pragma comment(lib, "sfml-window-d.lib")
#pragma comment(lib, "sfml-graphics-d.lib")
#else
#pragma comment(lib, "sfml-system.lib")
#pragma comment(lib, "sfml-window.lib")
#pragma comment(lib, "sfml-graphics.lib")
#endif
int main(int argc, char** argv)
{
sf::VideoMode video_mode(1280, 720);
sf::RenderWindow rw(video_mode, "Title", sf::Style::Close |sf::Style::Titlebar);
rw.setVerticalSyncEnabled(true);
sf::RectangleShape rs;
rs.setSize(sf::Vector2f(100, 100));
rs.setPosition(50.0f, 50.0f);
rs.setFillColor(sf::Color::Red);
rs.setOutlineColor(sf::Color::Blue);
rs.setOutlineThickness(2.0f);
sf::Event e;
bool running = true;
while (running)
{
while (rw.pollEvent(e))
{
if (e.type == sf::Event::Closed)
{
running = false;
}
}
// update
rs.move(2.0f, 0.0f);
// render
rw.clear();
rw.draw(rs);
rw.display();
}
}
This is the minimal code to reproduce the problem. As I said, it smoothly moves for 1-2 seconds then seems to jump backwards for one frame then forwards again. I have is vsync so it will stay with the 60fps but even if there is a slightly longer frame time, then it wouldnt move backwards though. And I can take the same exact program here and convert it to use SDL for rendering and have no issues. Now I understand SDL uses DirectX as its backend on Windows which is why I think it may just be an OpenGL issue on my laptop.
Unless I am really doing something wrong, but I don't believe I am, then this makes SFML unusable for me as I cannot get smooth movements which is unfortunate because I love SFML. And I dont believe it is an issue with SFML itself really since I dont see alot of people mentioning this problem on the boards or on google.
I should mention that i have used the .NET binding of SFML with C# with the same issue.