如何在Android中使用OpenGL绘制圆? [英] How to draw Circle using OpenGl in android?

查看:657
本文介绍了如何在Android中使用OpenGL绘制圆?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直工作在一个小应用程序为我的电话,我想补充一个
功能需求
一个圆圈被吸引到屏幕上。我不知道我怎么能做到这一点
使用OpenGL ES。谁能帮助?

I've been working on a small app for my phone, and I wanted to add a feature that needs a circle to be drawn to screen. I was wondering how I could do this using OpenGL ES. can anyone help?

推荐答案

基本上有三个选项画一个圆圈。你不指定是否要固/薄/厚等等看,所以不是所有的这些可能是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.

这篇关于如何在Android中使用OpenGL绘制圆?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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