tksuoran's picture

glUniformMatrix4 with count > 1

What is a correct and best way to upload Matrix4[] with a single GL call?

GL class has three versions of UniformMatrix4:

  1. Single[] value
  2. ref Single value
  3. Single* value

I understand that the first version safely fixes the whole array passed to it, but it is not convenient to convert Matrix[] to Single[].

For the second version, I have no idea what really gets fixed and what not. If I pass in ref matrix4array[0].Row0.X, does the whole array really get fixed or not?

Currently I am using the last version, with my own version of UniformMatrix4 that takes in ref Matrix4[] matrix, and which uses fixed (float* matrix_ptr = &matrix[0].Row0.X). I hope this does the right thing, but I wonder if the ref Single value version would work too?



Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
the Fiddler's picture

The ref Single version should work too.

However, the best solution would be to file a feature request for a proper Matrix4[] overload.