Quantcast
Channel: Community | MonoGame - Latest topics
Viewing all articles
Browse latest Browse all 6822

Texture GetData strange results on desktop and android.

$
0
0

@Gronk wrote:

Hello,

I was trying modify a texture data on runtime to make some funny outlines, color changes and just generally messing about. The texture draws empty on android but works fine on desktop.

Found this:

And i also found tihs:
That hints that getting setting data would work fine on android and ios.

This code dont work on Android:

    public Texture2D CreateModifiedTexture(Texture2D texture)
    {
        Color[] data;
        data = new Color[texture.Width * texture.Height];
        texture.GetData(data);

        for (int i = 0; i < data.Length; i++)
            data[i] *= 2;

        texture.SetData(data);
        return texture;
    }

This code works on Android:

    public Texture2D CreateModifiedTexture(Texture2D texture)
    {
        Color[] data;
        data = new Color[texture.Width * texture.Height];
        texture.GetData(data);

        for (int i = 0; i < data.Length; i++)
            data[i] *= 2;

        Texture2D result = new Texture2D(GraphicsDevice, texture.Width, texture.Height);
        result.SetData(data);
        return result;
    }

Questions
Well whats going on =)
Do i have to use some other approach on Android/IOS?
What is the best way to modify pixelinformation in runtime overall?

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 6822

Latest Images

Trending Articles



Latest Images