- Home /
How to use Texture2D.LoadRawTextureData(IntPtr, int)?
Hi, I have a light C# .dll wrapper around a C++ library, and I am trying to update a texture without needing to copy the bytes across the unmanaged/managed boundary (using Marshall.Copy or something similar).
The LoadRawTextureData(IntPtr, int) function looks like exactly what I want, so I am passing it a byte* cast to an IntPtr, and a size of width*height*4 (ARGB32). When it renders, I get an error: "No texture data provided to LoadRawTextureData".
Using GetRawTextureData returns a byte[] of size width*height*4 filled with the colour I have specified, so I'm not quite sure what I'm doing wrong here.. I have looked at the example native plugin here, but this requires me to write API wrappers for several versions of DirectX, as well as OpenGL and Metal which I'd rather not have to do.
Answer by gameplay4all · Mar 21, 2017 at 03:27 PM
Did you call Apply()
?
You must call Texture2D.Apply()
to actually upload the data to the GPU.
Hope this helps,
-Gameplay4all
Your answer
