tedsta, maybe you should show a complete example that seems to jitter. Because in my experience I have never seen any issues when omitting the interpolation part of that game loop.
It's very subtle, and becomes more noticeable as the actual framerate gets lower. You can play around with the framerate cap and with and without smoothing. Maybe I've just gone crazy and my eyes deceive me, but I think the smoothing helps :P
#include <SFML/System/Vector2.hpp>
#include <SFML/Window/Keyboard.hpp>
#include <SFML/Window/Event.hpp>
#include <SFML/Graphics/RenderWindow.hpp>
#include <SFML/Graphics/RectangleShape.hpp>
const float lockStep = 1.f/60.f;
void step(sf::Vector2f& state, const float dt);
int main()
{
// Setup the window
sf::RenderWindow window;
window.create(sf::VideoMode(800, 600), "SFML Lockstep Example");
// Player states
sf::Vector2f oldState;
sf::Vector2f curState;
// Player object
sf::RectangleShape player(sf::Vector2f(32, 32));
player.setFillColor(sf::Color::Red);
// Delta time stuff
sf::Clock dtClock;
float dtAccum = 0.f;
// Main loop
while (window.isOpen())
{
// Framerate cap
while (dtClock.getElapsedTime().asSeconds() < 1.f/50.f);
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
// Calculate dt
float dt = dtClock.restart().asSeconds();
// Add to the dt accumulator
dtAccum += dt;
// While there's unsimulated time
while (dtAccum >= lockStep)
{
dtAccum -= lockStep;
oldState = curState;
step(curState, lockStep);
}
float accumStepRatio = dtAccum / lockStep;
sf::Vector2f state = curState*accumStepRatio + oldState*(1.f - accumStepRatio);
// Smoothed state
player.setPosition(state);
// Non smoothed
//player.setPosition(curState);
window.clear(sf::Color::Black);
window.draw(player);
window.display();
}
return 0;
}
void step(sf::Vector2f& state, const float dt)
{
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::W))
state.y -= 100.f*dt;
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::S))
state.y += 100.f*dt;
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::A))
state.x -= 100.f*dt;
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::D))
state.x += 100.f*dt;
}
EDIT:
Also becomes more noticeable as speed increases. Try upping the speed to 200 pixels per second.