为了平滑任何线条或形状,使用多重采样抗锯齿。
将:Gdx.gl.glclear()
替换成:Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT | (Gdx.graphics.getBufferFormat().coverageSampling?GL20.GL_COVERAGE_BUFFER_BIT_NV:0))
对于Android,在打开AndroidLauncher.java文件并添加:config.numSamples = 2
, 2 是一个不错的数值。
对于桌面设备,config.samples=3
这样就能完成工作...
bg = new TextureRegion(new Texture(
Gdx.files.internal("data/bg.png")));
//bg.getTexture().setFilter(GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR);
bg.getTexture().setFilter(TextureFilter.Linear, TextureFilter.Linear);
在你的Lwjgl3ApplicationConfiguration中设置样本数。默认值为0,尝试使用更高的值:
final Lwjgl3ApplicationConfiguration config = new Lwjgl3ApplicationConfiguration();
int samples = 2; // you can also play around with hiher values like 4
config.setBackBufferConfig(8, 8, 8, 8, 16, 0, samples); // 8, 8, 8, 8, 16, 0 are default values