我想画一个圆圈。但是没有画出任何东西。
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);
请帮帮我......
第一个代码在android java gl es2.0上工作正常。
答案 0 :(得分: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;
}
}