Android studio 是否因发动机/GL+;安卓牛轧糖,还是AVD中的一个bug?

Android studio 是否因发动机/GL+;安卓牛轧糖,还是AVD中的一个bug?,android-studio,opengl-es,andengine,avd,Android Studio,Opengl Es,Andengine,Avd,当我在安卓Studio 2.2.2中使用安卓7.0(Nougat)图像在AVDs上运行基于安卓引擎的应用程序时,我遇到了一些错误的图形行为。结果是正常的,但它被平移、放大并包裹在x维中,颜色扭曲 有人有过这种图形失真的经验吗?这可能是因为安卓7.0与安卓/OpenGL中的某些东西不向后兼容,或者安卓工作室AVD中的牛轧糖图像有问题 我用来重现这种行为的最小应用程序使用AndEngine(GLES2 AnchorCenter)在主场景中显示一个精灵。我已经用几个AVD对它进行了测试,无论使用哪种设

当我在安卓Studio 2.2.2中使用安卓7.0(Nougat)图像在AVDs上运行基于安卓引擎的应用程序时,我遇到了一些错误的图形行为。结果是正常的,但它被平移、放大并包裹在x维中,颜色扭曲

有人有过这种图形失真的经验吗?这可能是因为安卓7.0与安卓/OpenGL中的某些东西不向后兼容,或者安卓工作室AVD中的牛轧糖图像有问题

我用来重现这种行为的最小应用程序使用AndEngine(GLES2 AnchorCenter)在主场景中显示一个精灵。我已经用几个AVD对它进行了测试,无论使用哪种设备,牛轧糖都会让它一直有问题

public class MainActivity extends SimpleLayoutGameActivity {
    private static int CAMERA_WIDTH = 480;
    private static int CAMERA_HEIGHT = 800;
    private Scene mScene;
    private ITextureRegion myTexture;

    @Override
    protected int getLayoutID() {
        return R.layout.activity_main;
    }

    @Override
    protected int getRenderSurfaceViewID() {
        return R.id.gameview;
    }

    @Override
    public void onCreate(Bundle pSavedInstanceState) {
        super.onCreate(pSavedInstanceState);
    }

    @Override
    public Engine onCreateEngine(EngineOptions pEngineOptions) {
        return new Engine(pEngineOptions);
    }

    @Override
    public EngineOptions onCreateEngineOptions() {
        ScreenOrientation orientation = ScreenOrientation.PORTRAIT_FIXED;
        EngineOptions en = new EngineOptions(true, orientation,
                new FillResolutionPolicy(), new Camera(0, 0, CAMERA_WIDTH, CAMERA_HEIGHT));
        return en;
    }

    @Override
    public synchronized void onPauseGame() {
        super.onPauseGame();
    }

    @Override
    public synchronized void onResumeGame() {
        super.onResumeGame();
    }
    @Override
    protected void onCreateResources() {

        BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/");

        final BuildableBitmapTextureAtlas gameTextureAtlasBIPMA2  = new BuildableBitmapTextureAtlas(this.getTextureManager(),
                136, 136, BitmapTextureFormat.RGBA_4444, TextureOptions.BILINEAR_PREMULTIPLYALPHA);
        myTexture = BitmapTextureAtlasTextureRegionFactory.createFromAsset(
                gameTextureAtlasBIPMA2, this.getAssets(), "redbomb.png");
        try {
            gameTextureAtlasBIPMA2.build(new BlackPawnTextureAtlasBuilder<IBitmapTextureAtlasSource, BitmapTextureAtlas>(2, 0, 2));
            gameTextureAtlasBIPMA2.load();
        } catch (Exception e) {
            throw new RuntimeException("Error loading BIPMA2", e);
        }
    }

    @Override
    protected Scene onCreateScene() {
        this.mScene = new Scene();

        // Add a sprite
        float diameter = CAMERA_WIDTH/1.5f;
        this.mScene.attachChild(new Sprite(CAMERA_WIDTH/2f, CAMERA_HEIGHT/2f,
                diameter, myTexture.getHeight() * diameter / myTexture.getWidth(),
                myTexture, getVertexBufferObjectManager()));

        return this.mScene;
    }
}
public类MainActivity扩展了SimpleLayoutGameActivity{
专用静态int摄像机_宽度=480;
专用静态int摄像机_高度=800;
私密场景;
私有ITextureRegion myTexture;
@凌驾
受保护的int getLayoutID(){
返回R.layout.activity\u main;
}
@凌驾
受保护的int getRenderSurfaceViewID(){
返回R.id.gameview;
}
@凌驾
创建时的公共void(Bundle pSavedInstanceState){
super.onCreate(pSavedInstanceState);
}
@凌驾
公共引擎onCreateEngine(引擎选项){
返回新发动机(选装件);
}
@凌驾
public EngineOptions onCreateEngineOptions(){
ScreenOrientation方向=ScreenOrientation.纵向\固定;
EngineOptions en=新的EngineOptions(正确,方向,
新的FillResolutionPolicy(),新的摄影机(0,0,摄影机_宽度,摄影机_高度));
返回en;
}
@凌驾
公共同步的void onPauseGame(){
super.onPauseGame();
}
@凌驾
公共同步的void onResumeGame(){
super.ongame();
}
@凌驾
受保护的void onCreateResources(){
BitmapTextureLastTextureRegionFactory.setAssetBasePath(“gfx/”);
final BuildableBitmapTextureAtlas gameTextureAtlasBIPMA2=新的BuildableBitmapTextureAtlas(this.getTextureManager(),
136,136,BitmapTextureFormat.RGBA_4444,TextureOptions.BILINEAR_PREMULTIPLYALPHA);
myTexture=BitMapTextureAtlastTextureRegionFactory.createFromAsset(
gameTextureAtlasBIPMA2,this.getAssets(),“redbomb.png”);
试一试{
gameTextureAtlasBIPMA2.build(新的BlackPawnTextureAtlasBuilder(2,0,2));
gameTextureAtlasBIPMA2.load();
}捕获(例外e){
抛出新的运行时异常(“加载BIPMA2时出错”,e);
}
}
@凌驾
受保护的场景onCreateSecene(){
this.mScene=新场景();
//加一个雪碧
浮子直径=摄像机宽度/1.5f;
这个.mScene.attachChild(新精灵(摄像头宽度/2f,摄像头高度/2f,
直径,myTexture.getHeight()*直径/myTexture.getWidth(),
myTexture,getVertexBufferObjectManager());
返回此.mScene;
}
}

更新:我已经找出了使用RGBA_4444作为纹理像素格式的原因;更改为RGBA_8888时,图形正常。不过,如果有人知道如何修复它,以便我可以使用RGBA_4444…

我不知道是什么导致了渲染问题。它看起来有点像我使用16位颜色分辨率时遇到的问题,但部分图形驱动程序决定像读取32位缓冲区一样读取它。但两者之间存在巨大差异,所以这并不是问题所在。您可以尝试使用gltracer/debugger调试问题(例如:)。如果比较GL跟踪,您可能会注意到错误所在。检查不同的Android设备是否有相同的GL驱动程序也是一个好主意。许多设备共享相同的GPU设计。(可能会出现驱动程序错误)谢谢Pauli。看起来Studio的GL tracer在虚拟设备上不起作用,只在真实设备上起作用。但是我发现了问题,你非常接近,问题是RGBA的位数。虚拟设备将GL命令转发给桌面驱动程序。您可以尝试对整个虚拟设备使用GL跟踪器。太糟糕了,这将包括来自surfaceflinger的轻微额外噪音。它应该提供足够的跟踪,以查看android在将GL调用转发到桌面时出错的纹理上载设置。这可能是纹理格式或GL_解包设置错误。我不知道是什么导致了渲染问题。它看起来有点像我使用16位颜色分辨率时遇到的问题,但部分图形驱动程序决定像读取32位缓冲区一样读取它。但两者之间存在巨大差异,所以这并不是问题所在。您可以尝试使用gltracer/debugger调试问题(例如:)。如果比较GL跟踪,您可能会注意到错误所在。检查不同的Android设备是否有相同的GL驱动程序也是一个好主意。许多设备共享相同的GPU设计。(可能会出现驱动程序错误)谢谢Pauli。看起来Studio的GL tracer在虚拟设备上不起作用,只在真实设备上起作用。但是我发现了问题,你非常接近,问题是RGBA的位数。虚拟设备将GL命令转发给桌面驱动程序。您可以尝试对整个虚拟设备使用GL跟踪器。太糟糕了,这将包括来自surfaceflinger的轻微额外噪音。它应该提供足够的跟踪,以查看android在将GL调用转发到桌面时出错的纹理上载设置。它可能是纹理格式或GL_解包设置错误。