How send eigen a matrix to GLSL?
c++, eigen, glsl, matrix, opengl
Solution
Simply call the .data() function:
glUniformMatrix4fv(render_projection_matrix_loc, 1, GL_FALSE, projection_matrix.data());
You might also be interested by the `<unsupported/Eigen/OpenGLSupport>` module which allows you to write:
glUniform(render_projection_matrix_loc, projection_matrix);
while taking care of the dimensions, scalar type, storage layout, etc. For instance, it also works with expressions:
glUniform(render_projection_matrix_loc, 2*projection_matrix.tranpose());
Problem
How send "Eigen matrix" to GLSL? For example this: ``` // Set up the model and projection matrix Eigen::Matrix<GLfloat,4,4> projection_matrix; projection_matrix = frustum(-1.0f, 1.0f, -aspect, aspect, 1.0f, 500.0f); glUniformMatrix4fv(render_projection_matrix_loc, 1, GL_FALSE, &projection_matrix.data()[0]); ``` I looked this `way(matrix.date()[0])` for uBLAS, but Eigen isn't uBLAS. How I can do this?