Update Sprite Texture from native Plugin?. Not updated

Hi all.

I’m implementing a native plugin to create a dynamic texture which it is updated in a native plugin (I have to use native plugin because i’m using third party IOS framework).

After read some doc It seems that it will be quite easy in theory… In practice not errors are reported but Sprite texture not changes.

Inside Sprite script I do:

void Start () {
_texture = newTexture2D(255, 255 ,TextureFormat.ARGB32,false);
_texture.filterMode = FilterMode.Point;
}

void Update () {
UpdateDummyTexture(_texture.GetNativeTextureID(), _texture.width, _texture.height);

SpriteRendererrenderer = GetComponent ();
MaterialPropertyBlockblock = newMaterialPropertyBlock();
block.AddTexture(“_MainTex”,_texture);
renderer.SetPropertyBlock(block);

GL.InvalidateState();
}
[DllImport(“__Internal”)]
private static extern void UpdateDummyTexture (int textureID, int width, int height);

Inside Plugin Code I do:

void UpdateDummyTexture(int textureID, int width, int height)
{
printf(“[%s]{%d} Entering method with param %d.\n”, “UpdateDummyTexture”, LINE, textureID);

glBindTexture(GL_TEXTURE_2D, textureID);
int size = width * height * 3;
unsigned char pixels = (unsigned char)malloc(size);

fractal_generateArrayValue(pixels);

for(int y=0;y<height;y++)
{

for(int x=0;x<byteWidth;x+=3)
{
if(x < 10)
{
pixels[x + y * byteWidth] = 255;
pixels[x + y * byteWidth+1] += 10;
pixels[x + y * byteWidth+2] += 20;
}
else
{
pixels[x + y * byteWidth] = 0;
pixels[x + y * byteWidth+1] += 20;
pixels[x + y * byteWidth+2] += 20;
}
}
}

glPixelStorei(GL_UNPACK_ALIGNMENT,1);

glTexImage2D(GL_TEXTURE_2D,0,GL_RGB,width,height,0,GL_RGB, GL_UNSIGNED_BYTE,pixels);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);

free(pixels );
}

The result is a blank texture .

Any help will be highly appreciated.

Thank you very much.

i assume you force gles, right? (just to make sure)
i would expect glTexImage2D to throw gl error (add glGetError calls or set breakpoint on gles errors in xcode).
the reason is we switched to use GL_EXT_texture_storage, so you want to use glTexSubImage2D

Thank you Alexey.

Same result with glTexSubImage2D :frowning:

I’m testing it in a IPAD 3 so by default gles is force, right?

Regards