fix a bug (thanks to grapeot's remainder; added opengl support