How to draw circle on OpenGL ES 2.0 cross platform?

≯℡__Kan透↙ 提交于 2019-12-13 03:05:44

问题


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:

  1. 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).
  2. Use a texture which contains an image of a circle and map that to a pair of triangles (a quad).
  3. Use a point sprite.


来源:https://stackoverflow.com/questions/17729352/how-to-draw-circle-on-opengl-es-2-0-cross-platform

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!