This is a tentative fix for #28. I cannot test nvidia, however I confirm it works for Intel (Mesa) cards.