diff --git a/examples/hello-world.rs b/examples/hello-world.rs index b31eac3..2db0dde 100644 --- a/examples/hello-world.rs +++ b/examples/hello-world.rs @@ -51,15 +51,7 @@ async fn run() { }; surface.configure(&device, &config); - let mut text_renderer = TextRenderer::new( - &device, - &queue, - swapchain_format, - Resolution { - width: size.width, - height: size.height, - }, - ); + let mut text_renderer = TextRenderer::new(&device, &queue, swapchain_format); let font = include_bytes!("./Inter-Bold.ttf") as &[u8]; let font = Font::from_bytes(font, FontSettings::default()).unwrap(); diff --git a/src/lib.rs b/src/lib.rs index 31ace64..96560d1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -139,12 +139,7 @@ pub struct TextRenderer { } impl TextRenderer { - pub fn new( - device: &Device, - _queue: &Queue, - format: TextureFormat, - screen_resolution: Resolution, - ) -> Self { + pub fn new(device: &Device, _queue: &Queue, format: TextureFormat) -> Self { let glyph_cache = HashMap::new(); let max_texture_dimension_2d = device.limits().max_texture_dimension_2d; let atlas_width = max_texture_dimension_2d; @@ -244,16 +239,18 @@ impl TextRenderer { label: Some("glyphon bind group layout"), }); - let params = Params { screen_resolution }; - - let params_raw = unsafe { - slice::from_raw_parts(¶ms as *const Params as *const u8, size_of::()) + let params = Params { + screen_resolution: Resolution { + width: 0, + height: 0, + }, }; - let params_buffer = device.create_buffer_init(&wgpu::util::BufferInitDescriptor { + let params_buffer = device.create_buffer(&BufferDescriptor { label: Some("glyphon params"), - contents: params_raw, + size: size_of::() as u64, usage: BufferUsages::UNIFORM | BufferUsages::COPY_DST, + mapped_at_creation: false, }); let bind_group = device.create_bind_group(&wgpu::BindGroupDescriptor {