haskell-opengl / OpenGL

Haskell bindings to OpenGL
http://www.haskell.org/haskellwiki/OpenGL
BSD 3-Clause "New" or "Revised" License
147 stars 26 forks source link

withMappedBuffer - Restore buffer object before unbinding #48

Open blitzcode opened 10 years ago

blitzcode commented 10 years ago

The withMappedBuffer helper function can be unsafe if the inner changes the VAO/VBO bindings and either forgets to change it back or gets interrupted by an exception.

withMappedBuffer could query the current buffer object at the beginning and restore it inside its finally block before calling unmapBuffer.

I'm not sure if there is a good reason for not doing this, but I thought I at least suggest this change here.