问题
I've been looking everywhere for a way to anti-alias edges of filled shapes drawn with ShapeRenderer
(ie. ShapeType.Filled
) but can't find anything about this.
Lines works well with Gdx.gl.glEnable(GL10.GL_LINE_SMOOTH)
but nothing I've tried works with filled shapes. So, does anyone have any suggestions?
回答1:
maybe this link will help: MULTI SAMPLING ANTI-ALASING IN LIBGDX ON ANDROID
in general you have to enable multisampling to have edges of filled shapes smooth.
http://www.opengl.org/wiki/Multisampling
回答2:
I've found the anti-aliasing support in OpenGL to be lacking (as actual support depends on optional hardware support), especially for the basic polygon primitives. There are two solutions that I've found to work:
First, you can get reasonable multi-sampling when using textures. So, maybe render your polygon to a FrameBuffer object, and then copy that to the screen. There are still a bunch of caveats, see http://www.saschahlusiak.de/2012/10/opengl-antialiasing-in-android-with-transparent-textures/ for more details.
Second, render your filled shape with a shader that anti-aliases, as in this question: Drawing Antialiased circle using Shaders. If your filled primitive shape is complicated, this can be quite a bit of work. See https://code.google.com/p/libgdx/wiki/OpenGLShader for how to use a shader with Libgdx. This option only works with OpenGL ES 2.0, too.
回答3:
Have you tried following hints?
Gdx.gl.glEnable(GL10.GL_LINE_SMOOTH);
Gdx.gl.glEnable(GL10.GL_POINT_SMOOTH);
Gdx.gl.glHint(GL10.GL_POLYGON_SMOOTH_HINT, GL10.GL_NICEST);
Gdx.gl.glHint(GL10.GL_POINT_SMOOTH_HINT, GL10.GL_NICEST);
来源:https://stackoverflow.com/questions/18186375/anti-aliasing-filled-shapes-in-libgdx