Share text atlas between renderers

This commit is contained in:
grovesNL 2022-05-15 00:02:00 -02:30 committed by Josh Groves
parent a2c65f86d7
commit 4b4594492a
2 changed files with 106 additions and 75 deletions

View file

@ -3,7 +3,7 @@ use glyphon::{
layout::{CoordinateSystem, Layout, LayoutSettings, TextStyle},
Font, FontSettings,
},
Color, HasColor, Resolution, TextRenderer,
Color, HasColor, Resolution, TextAtlas, TextRenderer,
};
use wgpu::{
Backends, CommandEncoderDescriptor, DeviceDescriptor, Features, Instance, Limits, LoadOp,
@ -66,7 +66,8 @@ async fn run() {
};
surface.configure(&device, &config);
let mut text_renderer = TextRenderer::new(&device, &queue, swapchain_format);
let atlas = TextAtlas::new(&device, &queue, swapchain_format);
let mut text_renderer = TextRenderer::new(&device, &queue, &atlas);
let font = include_bytes!("./Inter-Bold.ttf") as &[u8];
let font = Font::from_bytes(font, FontSettings::default()).unwrap();