OpenGL ES iPhone - 绘制抗锯齿线条 [英] OpenGL ES iPhone - drawing anti aliased lines

查看:364
本文介绍了OpenGL ES iPhone - 绘制抗锯齿线条的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通常情况下,您会使用以下内容:

Normally, you'd use something like:

glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
glEnable(GL_LINE_SMOOTH);

glLineWidth(2.0f);

glVertexPointer(2, GL_FLOAT, 0, points);
glEnableClientState(GL_VERTEX_ARRAY);

glDrawArrays(GL_LINE_STRIP, 0, num_points);

glDisableClientState(GL_VERTEX_ARRAY);

它在iPhone模拟器中看起来不错,但在iPhone上线条非常薄而且没有o / o任何抗锯齿。

It looks good in the iPhone simulator, but on the iPhone the lines get extremely thin and w/o any anti aliasing.

你如何在iPhone上获得AA?

How do you get AA on iPhone?

推荐答案

使用不透明度为0的顶点可以非常便宜地实现抗锯齿效果。
这是一个图像示例来解释:

One can achieve the effect of anti aliasing very cheaply using vertices with opacity 0. Here's an image example to explain:

与AA的比较:

你可以看一篇论文关于这个:

You can read a paper about this here:

http://research.microsoft.com/en-us/um/people/hoppe/overdraw.pdf

你可以做点什么这样:

// Colors is a pointer to unsigned bytes (4 per color).
// Should alternate in opacity.
glColorPointer(4, GL_UNSIGNED_BYTE, 0, colors);
glEnableClientState(GL_COLOR_ARRAY);

// points is a pointer to floats (2 per vertex)
glVertexPointer(2, GL_FLOAT, 0, points);
glEnableClientState(GL_VERTEX_ARRAY);

glDrawArrays(GL_TRIANGLE_STRIP, 0, points_count);

glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);

这篇关于OpenGL ES iPhone - 绘制抗锯齿线条的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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