glColor4f(0.0f, 0.0f, 0.0f, 0.35f);
// 设置为Array
glDisable(GL_TEXTURE_2D);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);
GLfloat *vertices = malloc(2 * sizeof(GLfloat) * (angle + 1));
vertices[0] = 0;
vertices[1] = 0;
for(int i = 0;i < angle; i++)
{
GLfloat x = r * cosf(CC_DEGREES_TO_RADIANS(i));
GLfloat y = r * sinf(CC_DEGREES_TO_RADIANS(i));
vertices[i * 2 + 2] = x;
vertices[i * 2 + 2 + 1] = y;
}
glDisable(GL_TEXTURE_2D);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);
glVertexPointer(2, GL_FLOAT, 0, vertices);
glDrawArrays(GL_TRIANGLE_FAN, 0, (GLsizei)(angle + 2));
// restore default state
glEnableClientState(GL_COLOR_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glEnable(GL_TEXTURE_2D);
free( vertices );
opengl 画扇形
最新推荐文章于 2024-08-28 11:34:21 发布