I want to update a part of texture and find that ‘engine.updateTextureData()’ is a good choise.
However, when the texture is not link to any material, ‘engine.updateTextureData()’ will not work.
Here is the PG. https://playground.babylonjs.com/#EVX1DH#45
When I delete line 71, ‘engine.updateTextureData’ will not work.
You have some errors in the console log in the 2nd PG:
babylon.js:16 WebGL: INVALID_OPERATION: texSubImage2D: ArrayBufferView
not big enough for request
That’s because the subarray you extract is not big enough given the width/height of the texture you want to update (region.width * 0.5 and region.height * 0.5).
Sorry, I don’t understand. the subarray return an array with 37500 length, and the texture I want to update is 250x150. why this array is not big enough?
I don’t know how to handle this one as I don’t know much of openGL…
After having read some docs, I think we could set the UNPACK_ALIGMENT to 1 in the whole engine as I think our buffers are always tightly packed (we only set it to 1 in the raw texture class when width can’t be divided by 4, and we don’t reset it to 4 afterward, meaning it stays to 1). But it’s not what we are doing, so I prefer @sebavan having a look at that.