Skip to content

No binding for glUniformMatrix* #33

Closed
thiago-negri opened this Issue Jan 15, 2013 · 7 comments

7 participants

@thiago-negri

I can't find any function for performing a glUniformMatrix*.

@thiago-negri thiago-negri referenced this issue in acowley/GLUtil Jan 16, 2013
Closed

Create a GLUtilRaw #4

@Laar
Laar commented Jan 16, 2013

If I remember correctly I looked into it (partially) as the same problem was brought forward by #14 . The problem with extending the current implementation for vectors is that there is no specific datatype for matrices. So far I've thought of two possible solutions.

  1. Define a datatype ourselves (maybe as extension of the rather small tensor package), say Mat4x4 a = Vec4 (Vec4 a). But should we tie the users to a specific implementation for matrices and could we maintain it?
  2. Define a typeclass for matrices. This is the current implementation for matrices in .../CoordTrans.hs. It doesn't restrict the user to a specific matrix implementation but might result in performance issues. Furthermore I don't know if this doable without language extensions and how it would scale to the whole set of matrix sizes.
@jan3er
jan3er commented Jul 22, 2013

How about supporting Data.Vect.Float? I'm not quite familiar with both libraries, but they appear to complement each other well. There is a Data.Vect.Float Module for using the libraries vectors and matrices in OpenGL context, but it's only tailored towards the old pipeline and not glUniformMatrix*.

@pakanek
pakanek commented Oct 16, 2013

In OpenGL-2.9 binding, where UniformLocation type constructor is exported

(UniformLocation mvp) <- get (uniformLocation prog "mvp")

can be used with OpenGLRaw. If you store matrix in Data.Vector.Storable then

-- mvpVec :: Vector GLfloat
unsafeWith mvpVec (\ptr -> glUniformMatrix4fv mvp 1 0 ptr)

can be used to upload matrix to the shader uniform.

@schell
schell commented Nov 14, 2013

I'm not sure of the difference, but you can also use

withArray mvpVec (\ptr -> glUniformMatrix4fv mvp 1 0 ptr)

Maybe it's 'less unsafe' ?

@pakanek
pakanek commented Nov 15, 2013

It is probably unsafe function because pointer should be used only to read - not to write - into that memory. It should be okay when you are just sending data to OpenGL. But I am not so sure about differences between Array/Vector/Repa... in FP/Haskell either. I use Vector in my math package.

@bgamari
bgamari commented Jul 12, 2014

I have some Uniform instances in my linear-opengl package that may be of interest here.

@svenpanne
Haskell OpenGL member

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

@svenpanne svenpanne closed this May 11, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.