如何在OpenGL ES 2.0跨平台上画圆? [英] How to draw circle on OpenGL ES 2.0 cross platform?

查看:379
本文介绍了如何在OpenGL ES 2.0跨平台上画圆?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在过去的两周里,我一直在教自己如何使用openGL ES 2.0编程,但是我一直在努力绘制某些对象.我正在使用Mosync进行编码,因为我可以为所有平台编程.到目前为止,我已经编写了一个程序绘制一个三角形,另一个程序绘制一个正方形.我正在寻找画圆的方法,我知道我已经定义了中心,半径,角度和分辨率,但是我不知道如何使它起作用.

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.

我可以直接从draw()绘制圆形,还是必须定义正方形的顶点并使用片段着色器仅对圆形像素进行着色?

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?

推荐答案

在OpenGL ES中有3种常见的绘制圆的方法:

There are 3 common ways to draw a circle in OpenGL ES:

  1. 使用单个三角形扇形,第一个顶点在圆的中心.您提供的点数越多,圆的质量就越高(细分水平).
  2. 使用包含圆形图像的纹理并将其映射到一对三角形(四边形).
  3. 使用点精灵.

这篇关于如何在OpenGL ES 2.0跨平台上画圆?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆