Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

No binding for glUniformMatrix* #33

Open
thiago-negri opened this Issue · 6 comments

6 participants

@thiago-negri

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

@thiago-negri thiago-negri referenced this issue in acowley/GLUtil
Closed

Create a GLUtilRaw #4

@Laar

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

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

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

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

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

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

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.