Rendering takes the current buffer into account, so change its value before using it, not afterwards. The order happened to not matter on at least Windows, because we just queue a message.