How to get multipointer to matrix?

Hi! I’m learning opengl with odin. “vendon:OpenGL” package has a function OpenGL.UniformMatrix4fv: proc(location: i32, count: i32, transpose: bool, value: [^]f32) that expects a matrix. I have a matrix of type matrix[4, 4]f32. How can i pass it to this function?

Or in other words, how can i convert matrix[4, 4]f32 into [^]f32?

I solved the issue this way:

gl.UniformMatrix4fv(loc, 1, false, cast([^]f32)(&val))

Also it is possible to use ([^]f32)(&val) and transmute([^]f32)(&val), the result will be the same

1 Like

You can also do &m[0,0] (which is a ^f32 but will implicitly convert to [^]f32) or raw_data(&m) (which will actually give a [^]f32).

2 Likes

@Barinzaya Oh, that looks nice. Thank you!