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

missing Uniform instances for matrices #68

Closed ekmett closed 8 years ago

ekmett commented 10 years ago

There doesn't appear to be a way to set up mat4 matrices for e.g. perspective matrices in shaders.

schell commented 10 years ago

I ran into this issue as well in #33. I wouldn't consider the solution (was there one?) awesome. Now I'm just using GLUtil which adds support. Seems like haskell-opengl should provide this though. :+1:

bananu7 commented 8 years ago

Just for reference for people who don't want to use GLUtil - the way it did that was rather simple:

unUL :: GL.UniformLocation -> GLint
unUL = unsafeCoerce

uniformGLMat4 :: GL.UniformLocation -> GL.SettableStateVar (GL.GLmatrix GL.GLfloat)
uniformGLMat4 loc = GL.makeSettableStateVar aux
  where aux m = GL.withMatrix m $ \_ -> GLRaw.glUniformMatrix4fv loc' 1 1
        loc' = unUL loc

Apart from the ugly unsafeCoerce to pass the uniform location to the native code, it's no rocket science. What are the plans to solve that? Are you perhaps waiting for a PR?

svenpanne commented 8 years ago

This has been fixed in b1b50031f7880b918fc6ec056342c5c89f118213, I'm about to make a new release on Hackage.