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?
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());
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.