Android中的OpenGL ES如何摆脱锯齿边缘? [英] How to get rid of Jagged edges in Android OpenGL ES?
问题描述
我有以下的code:
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
gl.glClearColor(0.0f, 0.0f, 0.0f, 0.5f);
gl.glShadeModel(GL10.GL_SMOOTH);
gl.glClearDepthf(1.0f);
gl.glEnable(GL10.GL_DEPTH_TEST);
gl.glDepthFunc(GL10.GL_LEQUAL);
//gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT, GL10.GL_NICEST);
gl.glHint(GL10.GL_POLYGON_SMOOTH_HINT, GL10.GL_NICEST);
}
public void onDrawFrame(GL10 gl) {
gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
gl.glLoadIdentity();
但仍是边缘锯齿严重的Android模拟器。有什么解决办法?
But still the edges are severely jagged in Android Emulator. What is the solution?
推荐答案
那么最好的方法是使用多重采样(反锯齿)。由于您使用的模拟器,这不是一个选择。 (Multismapling支持OpenGL ES 2.0的,但模拟器不支持2.0) 根据OpenGL规范,设备可以忽略您设置的glHint,所以不要指望太多它。 该GL_DITHER是一种从16位颜色深度'假'24bit的色彩深度基本上它无关的边缘。
Well the best way is to use Multisampling ( Antialiasing ). Since you use the emulator this is not an option for you. ( Multismapling supported in OpenGL ES 2.0 but the emulator does not support 2.0 ) According to the OpenGL specification, the device can ignore the glHint you set, so don't expect to much from it. The GL_DITHER is a way to 'fake' 24bit color depth from 16bit color depth basically it has nothing to do with the edges.
Altho有一个古老的方法,以假抗锯齿,它的一个相同的,我从来没有使用过,所以我不能告诉你怎么样,但你可以在网上找到一些线索。
Altho there is an old method to 'fake' antialiasing, its a same that I never used so I cant tell you how, but you can find some hints on the web.
混合功能(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA)也是以任意顺序渲染抗锯齿点和线是有用的。
Blend function (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) is also useful for rendering antialiased points and lines in arbitrary order.
多边形抗锯齿是使用混合功能(GL_SRC_ALPHA_SATURATE,GL_ONE)多边形进行排序,从最近到最远的优化。
Polygon antialiasing is optimized using blend function (GL_SRC_ALPHA_SATURATE, GL_ONE) with polygons sorted from nearest to farthest.
这篇关于Android中的OpenGL ES如何摆脱锯齿边缘?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!