Reputation: 7055
I'm learning the linmath.h
library, but I'm having trouble passing matrices made by it in my main program to my vert shader:
#include "linmath.h"
…
GLint mat_uniform_handle = glGetUniformLocation(shade_program_handle, "matrix");
…
mat4x4 M;
mat4x4_identity(M);
glUniformMatrix4fv(mat_uniform_handle, 1, GL_FALSE, M);
But of course that gives me a type error because linmath
matrices have the type float (*)[4]
and glUniformMatrix4fv
takes the type const GLfloat *
.
I tried writing my own converter that concated the columns of the matrix into a single array, then returned a pointer to the first element, but that didn't work.
Am I missing some function of linmath.h
that does this conversion for me? If not, how do I properly convert a linmath.h
matrix to an opengl matrix?
Upvotes: 3
Views: 967
Reputation: 7055
It's pathetic that I didn't try this before asking here, but here's the solution, just a straight cast.:
glUniformMatrix4fv(mat_uniform_handle, 1, GL_FALSE, (GLfloat *)M);
Hope this helps someone.
Upvotes: 4