问题与Android的OpenGL多重采样/抗锯齿 [英] Issue with Android OpenGL Multisampling/Antialiasing

查看:1339
本文介绍了问题与Android的OpenGL多重采样/抗锯齿的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为Android应用程序,用户可以点击屏幕绘制的颜色。我已经得到了所有的绘图code在Android 4.0.4,Galaxy Nexus的下的OpenGL(测试工作很好,虽然我试图使这个向后兼容尽可能;我的SDK API的目标,但是14有8 minSDK)。

I'm working on an app for Android allows the user to tap the screen to draw colors. I've got all of the drawing code working nicely under OpenGL (testing on Android 4.0.4, Galaxy Nexus, though I'm trying to make this backward compatible as far as possible; my SDK targets API 14 but has a minSDK of 8).

我碰到的问题是与抗锯齿;我希望我的所有多边形和线条进行抗锯齿,但他们出来锯齿状。我是正面的Galaxy Nexus支持反锯齿(我已经看到了它在其他应用程序),所以我敢肯定,我做错了什么。

The issue I've run into is with antialiasing; I want all my polygons and lines to be antialiased, but they're coming out jagged. I'm positive the Galaxy Nexus supports antialiasing (I've seen it in other apps), so I'm sure I'm doing something wrong.

我一直在向上和向下谷歌现在一个多小时,并通过几个StackOverflow的Q /为,我发现了一些答案:

I've been up and down Google for over an hour now, and through several StackOverflow Q/As, and I've found a few answers:

gl.glEnable(GL10.GL_BLEND);
gl.glEnable(GL10.GL_ALPHA_BITS);
gl.glEnable(GL10.GL_MULTISAMPLE);
gl.glEnable(GL10.GL_SMOOTH);
gl.glShadeModel(GL10.GL_SMOOTH);
gl.glHint(GL10.GL_POLYGON_SMOOTH_HINT, GL10.GL_NICEST);
gl.glHint(GL10.GL_POINT_SMOOTH_HINT, GL10.GL_NICEST);

我添加了一些或全部的各种次序这些行,并没有影响。 (这些在onSurfaceCreated加。)

I've added some or all of these lines in various orders, and to no effect. (These were added in onSurfaceCreated.)

gl.glEnable(GL10.GL_DITHER);

我觉得这个稍微帮助...但是,这可能是我的脑海里捉弄我。即使使用时,虽然仍有锯齿线被发现。 (在onSurfaceCreated还增加了。)

I think this one helped slightly... but that might be my mind playing tricks on me. Even when using it, though, there are still jagged lines to be found. (Also added in onSurfaceCreated.)

gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);

这一次似乎是最常见的答案。但是,这样做的时候,一切都绘制无形;也就是说,与黑色背景启动时,一切都只是黑,永远。 (我知道它仍然正在绘制由于内存冲厕LogCat中的消息。)我也与上述所有其他方法试过这个组合。 (这是在onSurfaceCreated增加,也是如此。)

This one seems to be the most common answer. But when doing this, everything is drawn invisible; that is, when starting with a black background, everything is just black, always. (I know it's still being drawn due to the memory flushing messages in LogCat.) I've also tried this in combination with all the other methods above. (And this was added in onSurfaceCreated, as well.)

要回顾一下:我使用OpenGL在Android 4+,没有多重采样方法似乎工作;而大多数只是有没有效果,使用glBlendFunc似乎打破完全渲染。

To recap: I'm using OpenGL on Android 4+ and no multisampling methods appear to be working; while most just have no effect, using glBlendFunc seems to break the rendering entirely.

所以,我很为难。我接受任何建议在所有...他们一定会帮助比defenestrating我的电脑更多!

So, I'm quite stumped. I'm open to any suggestions at all... they will surely help more than defenestrating my computer!

提前给大家足够的耐心感谢阅读。

Thanks in advance to everyone patient enough to read this.

推荐答案

如果你还没有要求对多重采样EGL的背景下,你不能只用GL功能打开。看到这里如何做到这一点:

If you have not requested multisampling on EGL context, you can not turn it on with just the GL functions. See here how to do that:

  • http://code.google.com/p/gdc2011-android-opengl/source/browse/trunk/src/com/example/gdc11/MultisampleConfigChooser.java
  • http://stackoverflow.com/a/7388176/675078

这篇关于问题与Android的OpenGL多重采样/抗锯齿的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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