streamline Font loading
parent
3c832550d0
commit
33ed8b2364
|
@ -49,25 +49,12 @@ namespace MoonWorks.Graphics.Font
|
|||
|
||||
var imagePath = Path.ChangeExtension(fontPath, ".png");
|
||||
ImageUtils.ImageInfoFromFile(imagePath, out var width, out var height, out var sizeInBytes);
|
||||
var texture = Texture.CreateTexture2D(graphicsDevice, width, height, TextureFormat.R8G8B8A8, TextureUsageFlags.Sampler);
|
||||
|
||||
var transferBuffer = new TransferBuffer(graphicsDevice, sizeInBytes);
|
||||
ImageUtils.DecodeIntoTransferBuffer(
|
||||
imagePath,
|
||||
transferBuffer,
|
||||
0,
|
||||
TransferOptions.Overwrite
|
||||
);
|
||||
var uploader = new ResourceUploader(graphicsDevice);
|
||||
var texture = uploader.CreateTexture2DFromCompressed(imagePath);
|
||||
uploader.Upload();
|
||||
uploader.Dispose();
|
||||
|
||||
commandBuffer.BeginCopyPass();
|
||||
commandBuffer.UploadToTexture(
|
||||
transferBuffer,
|
||||
texture,
|
||||
WriteOptions.SafeOverwrite
|
||||
);
|
||||
commandBuffer.EndCopyPass();
|
||||
|
||||
transferBuffer.Dispose();
|
||||
NativeMemory.Free(fontFileByteBuffer);
|
||||
NativeMemory.Free(atlasFileByteBuffer);
|
||||
|
||||
|
|
Loading…
Reference in New Issue