在透视投影矩阵上应用一些其他矩阵(偏差或未知矩阵)

时间:2014-01-12 12:46:38

标签: opengl graphics

我被问到为什么今天在透视投影矩阵上应用以下未知矩阵的原因。但我不知道它是什么。所以我把这些代码片段放在这里帮忙。提前谢谢你。

{
    QRectF rect = boundingRect().translated(pos());
    float width = float(painter->device()->width());
    float height = float(painter->device()->height());

    float left = 2.0f * float(rect.left()) / width - 1.0f;
    float right = 2.0f * float(rect.right()) / width - 1.0f;
    float top = 1.0f - 2.0f * float(rect.top()) / height;
    float bottom = 1.0f - 2.0f * float(rect.bottom()) / height;
    float moveToRectMatrix[] = {
        0.5f * (right - left), 0.0f, 0.0f, 0.0f,
        0.0f, 0.5f * (bottom - top), 0.0f, 0.0f,
        0.0f, 0.0f, 1.0f, 0.0f,
        0.5f * (right + left), 0.5f * (bottom + top), 0.0f, 1.0f
    };          //here,what's the matrix meaning for, can i ignore it.

    glMatrixMode(GL_PROJECTION);
    glPushMatrix();
    glLoadMatrixf(moveToRectMatrix);
    gluPerspective(60.0, 1.0, 0.01, 10.0);

    glMatrixMode(GL_MODELVIEW);

   .............................................

在应用透视投影矩阵之前,moveToRectMatrix被加载到投影矩阵堆栈中,矩阵代表什么?谢谢。

1 个答案:

答案 0 :(得分:0)

我认为moveToRectMatrix是“视口”矩阵,它将NDC点(在标准化设备坐标系中,应用透视投影矩阵后)转换为画家设备中的点。我想你是在绘制某个设备而不是窗口屏幕。

相关问题