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

查看:28
本文介绍了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 上线条变得非常细而且没有任何抗锯齿功能.

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天全站免登陆