【发布时间】:2013-12-31 21:55:51
【问题描述】:
我有一个高度和宽度,我正在尝试用它们生成一个四边形。 当我这样做时:
vector<Point2D> vertices;
vector<unsigned int> indices;
Point2D topLeft = Point2(0, height);
Point2D topRight = Point2(width, height);
Point2D bottomLeft = Point2(0, 0);
Point2D bottomRight= Point2(width, 0);
indices.push_back(0);
indices.push_back(1);
indices.push_back(2);
indices.push_back(0);
indices.push_back(2);
indices.push_back(3);
vertices.push_back(topLeft);
vertices.push_back(topRight);
vertices.push_back(bottomLeft);
vertices.push_back(bottomRight);
我得到的是三角形而不是四边形。 但是当我这样做时:
vector<Point2D> vertices;
vector<unsigned int> indices;
Point2D topLeft = Point2(-width, height);
Point2D topRight = Point2(width, height);
Point2D bottomLeft = Point2(width, -height);
Point2D bottomRight= Point2(-width, -height);
indices.push_back(0);
indices.push_back(1);
indices.push_back(2);
indices.push_back(0);
indices.push_back(2);
indices.push_back(3);
vertices.push_back(topLeft);
vertices.push_back(topRight);
vertices.push_back(bottomLeft);
vertices.push_back(bottomRight);
完美运行。出了什么问题?我认为右下角?
【问题讨论】:
-
三角形有一个方向。如果你渲染一个背对你的三角形,它就会变成什么都没有。缠绕顺序很重要。
-
@IInspectable 但是当我没有将左下角设置为 0,0 时它起作用了,我只是将它们全部偏移了相同的值,现在完全不同了