我想分别绘制一个圆的所有 1/4,但它是我的窗口设置,原点位于左上角(0, 0)。无论如何,我可以避免再次反转屏幕吗?
我目前的实现是这样的:
//nX: x
//nY: y
//nR: radius
//verts: std::vector<int>
//indices: std::vector<uint32_t>
verts.push_back(nX + nR); verts.push_back(nY + nR);
for (int i = 270; i >= 360; i -= slice_count)
{
verts.push_back(nX + cos(DEG_TO_RAD * i) * nR);
verts.push_back(nY + sin(DEG_TO_RAD * i) * nR);
}
//...
//rest of the code are index manipulation
glDrawElements(GL_TRIANGLE_STRIP, indices.size(), GL_UNSIGNED_INT, &indices[0]);
这个只会画
| -
| -
| -
| -
| -
| -
| -
| -
| -
| -
|____________________
如果我开始从 270 到 360 的旋转只是为了制作上面的图,这会让我感到困惑。你有什么办法可以缓解我的困惑?这在逻辑上也不正确,对吧?
这是我制作的新测试代码。
glBegin(GL_TRIANGLE_FAN);
glVertex2i(500, 400);
for (int i = 360; i >= 270; --i)
{
int ax = (500 + cos(DEG_TO_RAD * i) * 100);
int ay = (400 + sin(DEG_TO_RAD * i) * 100);
glVertex2i(ax, -ay);
}
glEnd();