added compatibility with SDL. No optimisation, but work