首页 > 解决方案 > 什么是不同的lowp float vT

问题描述

我试图理解 QT 中的图形示例并坚持一些东西。GLSL 顶点和片段着色器用于绘制图形。

这是顶点着色器代码:

attribute highp vec4 pos;
attribute highp float t;

uniform lowp float size;
uniform highp mat4 qt_Matrix;

varying lowp float vT;

void main(void)
{
    vec4 adjustedPos = pos;
    adjustedPos.y += (t * size );
    gl_Position = qt_Matrix * adjustedPos;

    vT = t;
}

vT是什么???

还,

struct LineVertex {
    float x, y, t;
    inline void set(float xx, float yy, float tt) {x = xx; y = yy; t = tt;}
};


void LineNode::updateGeometry(const QRectF &bounds, const QList<qreal> &samples) {

    m_geometry.allocate(samples.size() * 2);

    qreal x = bounds.x();
    qreal y = bounds.y();
    qreal w = bounds.width();
    qreal h = bounds.height();

    qreal dx = w / (samples.size() - 1);


    LineVertex *v = (LineVertex *) m_geometry.vertexData();

    for(int i = 0; i < samples.size(); ++i) {
        v[i*2 + 0].set(x + dx * i, y + samples.at(i) * h, 0);
        v[i*2 + 1].set(x + dx * i, y + samples.at(i) * h, 1);
    }
    markDirty(QSGNode::DirtyGeometry);
}

我不明白为什么在 for 循环中

for(int i = 0; i < samples.size(); ++i) {
        v[i*2 + 0].set(x + dx * i, y + samples.at(i) * h, 0);
        v[i*2 + 1].set(x + dx * i, y + samples.at(i) * h, 1);
    }

他们正在创建一对具有相同位置的顶点并添加t*size(这对中的第一个为 0,第二个为 1)这还不足以正确调整 x,y 位置吗

我试图评论adjustedPos.y += (t * size );和图表只是消失了。

标签: glsl

解决方案


推荐阅读