如何使用opengl4绘制圆



我想画一个圆。但什么都没画出来。

for (int i = 0; i < 1080; i += 3) {
    angle = (float)M_PI / 180.0f * i;
    vertices[i] = sinf((float)angle) * 0.5f;
    vertices[i + 1] = cosf((float)angle) * 0.5f;
    vertices[i + 2] = 0.0f;
}
bool isFirst = true;
int temp;
for (int i = 0, j = 1; i < 360; i++) {
    if (i % 3 == 0) {
    indices[i] = 0;
}
else {
    if (!isFirst) {
    temp = ++j;
    isFirst = true;
    }
    else {
    temp = j;
    isFirst = false;
    }
    indices[i] = (GLushort)temp;
}
}
.
.
.
glDrawElements(GL_TRIANGLE_STRIP, 360, GL_UNSIGNED_SHORT, 0);

请帮帮我……

第一段代码在androidjavagles2.0上运行良好。

for (int i = 0; i < 1080; i += 3) {
    angle = (float)M_PI / 180.0f * i;
    vertices[i] = sinf((float)angle) * 0.5f;
    vertices[i + 1] = cosf((float)angle) * 0.5f;
    vertices[i + 2] = 0.25f;
}
bool isFirst = true;
int temp;
for (int i = 0, j = 1; i < 360; i++) {
    if (i % 3 == 0) {
        indices[i] = 0;
    }
    else {
        if (!isFirst) {
            temp = ++j;
            isFirst = true;
        }
        else {
            temp = j;
            isFirst = false;
        }
    indices[i] = (GLushort)temp;
    }
}

相关内容

  • 没有找到相关文章