improve SDL2 render code, remove flickering
- remove unnecessary copy between SDL_Surface and SDL_Texture,
using SDL_LockTexture we can access its pixel memory directly.
- remove unnecessary SDL_RenderClear() - the engine always writes
an entire frame, so there's no need to explicitly clear the
buffer.
- use platform independent pixel format SDL_PIXELFORMAT_BGRA32
instead of SDL_PIXELFORMAT_ARGB8888. the latter is endian
specific and what SDL_PIXELFORMAT_BGRA32 translates to
for little endian.
- use vsync by default, which removes flickering (very noticeable
e.g. in the "MAIN MENU" scroller of Mario Tennis).
unfortunately it comes at a cost; without vsync CPU usage
in powersave governor is around 6-7% for gnuboy and 3-5% for
Xorg, with vsync it's about 8% for gnuboy and 15-20% for Xorg.
the game still runs sufficiently fast though not to introduce
audio stuttering even at high scale settings.
if the additional load is considered unreasonable, it can be
turned off by exporting environment variable SDL_RENDER_VSYNC=0,
which activates SDL_HINT_RENDER_VSYNC, overriding the code.