public static DX11Texture3D LoadTexture3D(DxDevice device, string path) { IntPtr resource; long retcode = NativeMethods.LoadTextureFromFile(device.Device.NativePointer, path, out resource, 1); if (retcode == 0) { Resource r = Resource.FromPointer <Resource>(resource); if (r.Dimension != ResourceDimension.Texture3D) { r.Dispose(); throw new Exception("Texture is not a 3D Texture"); } Texture3D texture = Texture3D.FromPointer <Texture3D>(resource); ShaderResourceView srv = new ShaderResourceView(device, texture); return(DX11Texture3D.FromReference(device, texture, srv)); } else { throw new Exception("Failed to load texture"); } }