【问题标题】:How send eigen a matrix to GLSL?如何将特征矩阵发送到 GLSL?
【发布时间】:2013-12-02 09:07:25
【问题描述】:

如何将“特征矩阵”发送到 GLSL? 例如:

// 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]);

我在way(matrix.date()[0]) 中查找了 uBLAS,但 Eigen 不是 uBLAS。我该怎么做?

【问题讨论】:

  • 您可能想看看eigen/demos/opengl 目录。

标签: c++ opengl matrix glsl eigen


【解决方案1】:

只需调用 .data() 函数:

glUniformMatrix4fv(render_projection_matrix_loc, 1, GL_FALSE, projection_matrix.data());

您可能还对&lt;unsupported/Eigen/OpenGLSupport&gt; 模块感兴趣,它允许您编写:

glUniform(render_projection_matrix_loc, projection_matrix);

同时处理维度、标量类型、存储布局等。例如,它也适用于表达式:

glUniform(render_projection_matrix_loc, 2*projection_matrix.tranpose());

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-05-11
    • 1970-01-01
    • 1970-01-01
    • 2016-10-09
    • 2021-12-03
    • 2012-11-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多