如何在单游戏Android上复制一块纹理?

如何在单游戏Android上复制一块纹理?,android,opengl-es,monogame,texture2d,Android,Opengl Es,Monogame,Texture2d,我用这段代码将一块纹理复制到另一个纹理,它在Windows上可以工作,但在Android上不行。我怎样才能修好它 这是我的代码: public int DerivationGraph(int SrcX, int SrcY, int Width, int Height, int SrcGraphHandle) { Texture2D originalTexture = _textureCache[SrcGraphHandle]; Rectangle sour

我用这段代码将一块纹理复制到另一个纹理,它在Windows上可以工作,但在Android上不行。我怎样才能修好它

这是我的代码:

public int DerivationGraph(int SrcX, int SrcY, int Width, int Height, int SrcGraphHandle)
    {
        Texture2D originalTexture = _textureCache[SrcGraphHandle];
        Rectangle sourceRectangle = new Rectangle(SrcX, SrcY, Width, Height);

        Texture2D cropTexture = new Texture2D(GraphicsDevice, sourceRectangle.Width, sourceRectangle.Height);
        Color[] data = new Color[sourceRectangle.Width * sourceRectangle.Height];
        originalTexture.GetData(0, sourceRectangle, data, 0, data.Length);
        cropTexture.SetData(data);
        int nextIndex = textureIndex + 1;
        _textureCache[nextIndex] = cropTexture;

        textureIndex++;
        return textureIndex;
    }

我也在研究同样的问题,不幸的是,使用源矩形的特定重载似乎根本不起作用。据我所知,问题来自OpenGL ES-2.0在加载视频内存后不支持读取

从MonoGame Develop分支的这一点:

汤姆斯皮尔曼于2013年2月19日发表评论

一旦纹理数据上传到视频内存,您就无法读回它

这个特别的讨论是关于GetData的iOS实现,但是它提到了Android重载,并且在让它工作时有一个解决方法

就我个人而言,我已经在Android上试用过了,而且它确实有效。但是,不会使用OpenGL ES 1.1或2.0返回任何数据

获取整个纹理数据可能是您唯一的解决方案