且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在Android中使用OpenGL绘制圆?

更新时间:2021-09-10 05:12:33

基本上有三个选项画一个圆圈。你不指定是否要固/薄/厚等等看,所以不是所有的这些可能是appriopriate为您的情况:

Basically, there are three options for drawing a circle. You don't specify whether you want a solid/thin/thick etc look, so not all of these might be appriopriate for your case:


  1. 产生在一个圆圈顶点和使用glDrawArray(GL_LINES,...)。根据你有多少个顶点生成,这将产生一个很好的和清晰的结果。

  1. Generate vertices in a circle and use glDrawArray( GL_LINES, ... ). Depending on how many vertices you generate this will yield a nice and crisp result.

使用pgenerated圆(阿尔法透明度)的质地$ P $并将其映射在四。这将导致非常流畅的图形,并允许一个'thick'圈,但它不会像灵活:即使有纹理映射,你会希望你的纹理是关于你正在呈现四相同尺寸

Use a pregenerated texture of a circle (with alpha transparency) and map it on a quad. This will result in very smooth graphics and allow for a ´thick´ circle, but it will not be as flexible: even with mipmapping, you'll want your texture to be about the same size you are rendering the quad.

使用一个片段着色器。如这个例子应该的正常工作。

Use a fragment shader. Examples like this should work fine.