Android Andengine 纹理质量差
问题:用 Andengine(wraps opengl) 编写的 Android 应用程序中的纹理质量很差,尤其是在以几种颜色显示为步骤的渐变上。真实和虚拟设备上都会出现问题
设置:默认纹理、全屏、本机分辨率、android 2.2。 我尝试强制使用 PixelFromat:
public void onAttachedToWindow() {
super.onAttachedToWindow();
Window window = getWindow();
window.setFormat(PixelFormat.RGBA_8888);
}
没有任何区别。
评论线: GLHelper.disableDither(pGL);
对纹理有一点帮助,但使粒子看起来很糟糕,所以猜测这不是问题的根源。
加载代码示例:
public static void loadResources(StreamgameActivity game) {
magnetTexture = new BitmapTextureAtlas(512, 512, TextureOptions.BILINEAR);
magnetTextureRegion = BitmapTextureAtlasTextureRegionFactory
.createFromAsset(magnetTexture, game,"bateria128CMatte_none.png", 0, 0);
game.getEngine().getTextureManager().loadTexture(magnetTexture);
}
The problem: poor texture quality in android app written with Andengine(wraps opengl), especially on gradients which appear as steps in few colours. Problem occurs on real and virtual device
Settings: default texture, fullscreen, native resolution, android 2.2.
I have tried to enforce PixelFromat with:
public void onAttachedToWindow() {
super.onAttachedToWindow();
Window window = getWindow();
window.setFormat(PixelFormat.RGBA_8888);
}
Haven't made any difference.
Commenting line:GLHelper.disableDither(pGL);
helped a little with textures, but made particles look bad, so a guess it is not the source of problem.
Example loading code:
public static void loadResources(StreamgameActivity game) {
magnetTexture = new BitmapTextureAtlas(512, 512, TextureOptions.BILINEAR);
magnetTextureRegion = BitmapTextureAtlasTextureRegionFactory
.createFromAsset(magnetTexture, game,"bateria128CMatte_none.png", 0, 0);
game.getEngine().getTextureManager().loadTexture(magnetTexture);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果有人遇到 GLES2 的纹理质量和条带较差的情况,这里是解决方案:
只需重写 Sprite 的
preDraw()
并启用抖动,如下所示:关键元素是
pGLState.enableDither();
。您不需要需要任何其他内容,但如果您想确保表面和活动的 32 位渲染,您可以添加:
If someone is experiencing poor texture quality and banding for GLES2 here is the solution:
just override
preDraw()
of your Sprite and enable dithering like this:Key element is
pGLState.enableDither();
.You will not need anything else but in case you want to ensure 32bit rendering for the surface and activity you can add:
Andengine 似乎使用默认的 16 位渲染模式。要更改我所做的:
在
onSetContentView
方法中。Andengine seems to use be default 16bit rendering mode. To change that I have done:
in
onSetContentView
method.我遇到了同样的问题,通过启用抖动解决了
I had the same issue, fixed by enabling Dithering