Geoffrey Mainland did significant work generating C with his GHC quasi quote extension. I'm not sure the status or availability of the code but there was a good Haskell Workshop paper describing it. For the specific problem of OpenGL - as the package already exists I'm not sure a generative approach would actually pay its way