glsl - 什么是不同的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 );
和图表只是消失了。
解决方案
推荐阅读
- magento - Magento 2.3 上的登录模块
- python - Matplotlib 动画未按预期绘制线条
- azure-active-directory - 使用服务主体的 Power BI REST API - 错误 401 未经授权
- multithreading - 如何在@threads 中“锁定”变量?
- pandas - 熊猫检查数据框中的每个值并在条件满足时替换它
- flutter - Flutter ExpansionTile 扩展按钮位置
- airflow - 无法使用 PIP 安装airflow-pentaho-plugin python 包
- ngx-graph - 有没有办法在 ngx-graph 中的节点上方显示边缘?
- java - Java 正则表达式检查
- vue.js - 如何使用 axio 调用的响应来构建另一个请求