Azhukar wrote:Currently I think the default love.run has these following issues:
1. love.timer.step is called after processing events, so event calls get different love.timer.getDelta return values than update / draw.
2. First update call is passed dt equal to loading time + event processing time instead of some arbitrarily small positive value.
3. love.graphics.clear is called between update and draw.
- If trying to draw in update had some (optional) feedback, this would not necessarily be an issue.
4. love.timer.sleep is called even with vsync turned on.
- It makes no sense to cap frame rate with vsync and a love.timer.sleep call at the same time.
5. love.graphics.present is called after the sleep call.
I have 'fixed' these issues in my version of love.run
1. I'm not sure of any case where it would be appropriate to use the delta time in a callback such as keypressed, that's what the isDown etc. functions are for. calling it directly before updating ensures the most accurate value for love.update.
3. update is for logic, draw is for drawing. It might be confusing if newbies mix them up, but then they probably have bigger code problems than that.
4. I don't believe the game loop would be affected (other than adding additional complexity) if this were checked, so I don't really see the point of checking.
5. This is changed for LÖVE 0.8.1 so sleep is called after present, however there are advantages in some cases with the current method. OpenGL calls are not processed the instant you call them, they're submitted to the graphics card and it works its way down the list of things to do while the CPU is doing other things (one of the benefits of having a separate processor for graphics operations). This means that, with the current ordering, the CPU may sleep while the GPU does work. If instead it sleeps after presenting, both the CPU and GPU will be idle during the sleep, possibly wasting frame time.