- texturesArray[i] = HandleRef.ToIntPtr(Texture.getCPtr(textures[i]));
- }
- System.Runtime.InteropServices.Marshal.Copy(texturesArray, 0, unmanagedPointer, textures.Count);
+ IntPtr unmanagedPointer = Marshal.AllocHGlobal(intptrBytes);
+ IntPtr[] texturesArray = new IntPtr[textures.Count];
+ for (int i = 0; i < textures.Count; i++)
+ {
+ texturesArray[i] = HandleRef.ToIntPtr(Texture.getCPtr(textures[i]));
+ }
+ System.Runtime.InteropServices.Marshal.Copy(texturesArray, 0, unmanagedPointer, textures.Count);