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