Quote Originally Posted by ricardo View Post
Thanks, so in your opinion the only solution is to implement an adaptative timer. I will try it right now.
No, it's not a solution. But it will give better results than a static timeout timer.

By the way: What happens if render takes more than 20 ms? 20-now.elapsed() would be a negative value. Should I control that case and pass a 0 to 20-now.elapsed()?
Either use 0 or immediately calculate the next frame (and skip rendering it).

But first see how many frames per second can your application obtain as faldżip suggested.