Odd stuttering when translating matrix

private void update() {
    if (curent_speed < max_speed) curent_speed = curent_speed + .005; glTranslated(-curent_speed, 0, 0);

It’s odd, it skips some frames now and then and sometimes you can actually see the quad margins (blueish) when side-scrolling. How can I achieve a smooth translation? I’m just testing it inside update() but would actually like to use WASD to move it smoothly and accelerated until max speed is reached. Full code available in my repository.


Your current code doesn’t appear to take into account the frame time. I would both accelerate and translate using a timer, or ensure you run at a fixed frametime.

A quick look shows that your code also uses a second thread and runs all the code in that thread. Many GLFW functions need to be called from the main thread. Since it doesn’t look like you need the thread, I would just run without it.

By the way, I would put braces around the body of your if statement as it is very confusing as to what you intend.


I solved this by using individual sprites instead of sprite sheets. Apparently applying large sprite sheets as texture is wasteful in terms of processing power required. Each quad had an entire sprite sheet set as texture which was translated until the right sprite was on top of the said quad.


Using a ‘sprite sheet’, otherwise known as a texture atlas, is a common technique used to improve the performance of sprites. I doubt a texture per quad would be faster, though you might not see any difference if you’re only drawing a few sprites.


Well i am drawing a 500x300 matrix of quads. The blue-ish lines dissapeared aswell. It might have something to do with the way I was processing those sprite sheets to get the individual sprites. Maybe that algorithm was broken and now not having those processing mechanisms in place fixed the issue.