/// <summary> /// Constructs a DeviceTexture from this texture. /// </summary> /// <param name="factory">The resource factory responsible for constructing the DeviceTexture.</param> /// <returns>A new <see cref="DeviceTexture2D"/> containing this image's pixel data.</returns> public unsafe DeviceTexture2D CreateDeviceTexture(ResourceFactory factory) { fixed(Rgba32 *pixelPtr = &ISImage.DangerousGetPinnableReferenceToPixelBuffer()) { return(factory.CreateTexture(new IntPtr(pixelPtr), Width, Height, Format)); } }
/// <summary> /// Constructs a mipmapped 2D device texture from this mipmap chain. /// </summary> /// <param name="factory">The ResourceFactory used to create device resources.</param> /// <returns>A mpimapped 2D device texture.</returns> public unsafe DeviceTexture2D CreateDeviceTexture(ResourceFactory factory) { DeviceTexture2D tex = factory.CreateTexture(MipLevels, Width, Height, Format); for (int level = 0; level < MipLevels; level++) { Image <Rgba32> image = Images[level]; fixed(void *pin = &image.DangerousGetPinnableReferenceToPixelBuffer()) { tex.SetTextureData(level, 0, 0, image.Width, image.Height, (IntPtr)pin, PixelSizeInBytes * Width * Height); } } return(tex); }
public override DeviceTexture2D CreateDeviceTexture(ResourceFactory factory) { return(factory.CreateTexture(PixelData, Width, Height, Format)); }