28 July 2008

Framerate and rendering time

I've noticed when testing the new code, that the display would pause every now and then for a noticeable delay. After a bit of experimentation, it looked like the pause was related to crossing texture boundaries.

I have the framerate set at 60Hz, but was not sure how that hardware was actually taking to render a frame; a task that must complete in less that 1/60 second (0.0167s). Added a text overlay that shows time to render the current frame, and the maximum time in the last 3 seconds. From the screenshot here we can see a render time of less than 1ms (very good), but a max of over half a second (very bad).

I'm now quite certain the pause is related to loading textures and maybe I need to reduce their size. At least now I have a means of objectively measuring the benefits of any changes.

The other change I've made is to the code that locates the ship vertically on the screen. Previously the ship was always centred, except when approaching the limits when the background would remain stationary and the ship would move. I found the sudden transition of movement disconcerting and have now made the vertical position of the ship on the screen proportional to its position in the world. This seems much better and still allows the ship to reach both the top and bottom of the screen.

[UPDATE 28 July - Further testing has narrowed the cause of the delay down to the two lines of code that draw the background textures. I've reduced their size by a quarter to 512x512 which has eliminated the delay. Max render time is now about 5ms.]

1 comment:

  1. Lets see the ship fire a missile or laser beam when you tap the right hand bottom corner of the screen.

    Also email me the mini pong version and what it runs on for the iPOD.

    Keep up the good work man.

    ReplyDelete

Please note, comments are moderated which means they won't show up until I OK them. This seems to be the most effective way of stopping comment spam.