问题
Ive been teaching myself to program on openGL ES 2.0 for the past 2 weeks however I am struggling to draw certain objects. I am using Mosync to do my coding in as I can programme for all platforms. So far I have written a programme to draw a triangle and another to draw a square. Im looking for a way to draw a circle, I know I have do define the centre, radius, angle and resolution but I dont know how to go about making it work.
Can I draw the circle straight from draw() or do I have to define the vertices of a square and use the fragment shader to only colour the pixels in a circle shape?
回答1:
There are 3 common ways to draw a circle in OpenGL ES:
- Use a single Triangle Fan, where the first vertex is at the center of your circle. The more points you supply, the higher quality the circle will be (tessellation level).
- Use a texture which contains an image of a circle and map that to a pair of triangles (a quad).
- Use a point sprite.
来源:https://stackoverflow.com/questions/17729352/how-to-draw-circle-on-opengl-es-2-0-cross-platform