Hey guys,
I can't find anything on google about this. Has anyone been able to draw a disk shape in opengl? usually you'd use gluDisk but opengl es doesn't support glu. Any ideas? Thanks!
A fast, easy to use, free, and community supported 2D game engine
Hey guys,
I can't find anything on google about this. Has anyone been able to draw a disk shape in opengl? usually you'd use gluDisk but opengl es doesn't support glu. Any ideas? Thanks!
I ran into the same problem some time ago when I was working on a game. This is wat should do the job. NR_OF_SEGMENTS determines the quality of the render, the higher, the smoother, the slower. INNER_RADIUS is the distance from the center to the inner disc border and OUTER_RADIUS is the outer border (thus: OUTER_RADIUS-INNER_RADIUS is the width of the disc)
- (GLfloat *) calculateSegmentPoints {
float step = (2*M_PI) / NR_OF_SEGMENTS;
float *vertices = malloc( sizeof(float)*4*(NR_OF_SEGMENTS+1));
if( ! vertices )
return 0;
memset( vertices,0, sizeof(float)*4*(NR_OF_SEGMENTS+1));
int count = 0;
for( int i = 0; i <= NR_OF_SEGMENTS; i++ ) {
// calculating the current vertice on the outer side of the segment
float outerRads = i*step;
float outerX = OUTER_RADIUS * cos( outerRads );
float outerY = OUTER_RADIUS * sin( outerRads );
vertices[count++] = outerX;
vertices[count++] = outerY;
// calculating the current vertice on the inner side of the segment
float innerRads = i*step;
float innerX = INNER_RADIUS * cos( innerRads );
float innerY = INNER_RADIUS * sin( innerRads );
vertices[count++] = innerX;
vertices[count++] = innerY;
}
return vertices;
}
I hope it is of any use.
You must log in to post.