From 9b36d712e25fb1d209df848281b9913b61a6ec45 Mon Sep 17 00:00:00 2001 From: JSDurand Date: Sat, 21 Jun 2025 13:32:55 +0800 Subject: init commit A basic window is available. Now we shall try to render texts and some auxiliary functionalities. --- src/renderer/mod.rs | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 src/renderer/mod.rs (limited to 'src/renderer/mod.rs') diff --git a/src/renderer/mod.rs b/src/renderer/mod.rs new file mode 100644 index 0000000..05f7e25 --- /dev/null +++ b/src/renderer/mod.rs @@ -0,0 +1,46 @@ +#![allow(unused)] + +pub mod backend; +pub mod dummy; +pub mod error; +pub mod text; +pub mod vulkan; + +use backend::RendererBackend; +use text::TextSpan; + +pub struct Renderer<'a> { + pub backend: Box, + pub width: i32, + pub height: i32, +} + +impl<'a> Renderer<'a> { + pub fn new(mut backend: B, width: i32, height: i32) -> Self + where + B: RendererBackend + 'a, + { + backend.init(width, height); + Self { + backend: Box::new(backend), + width, + height, + } + } + + pub fn clear(&mut self) { + self.backend.clear(); + } + + pub fn draw_text(&mut self, span: &TextSpan) { + self.backend.draw_text(span); + } + + pub fn present(&mut self) { + self.backend.present(); + } + + pub fn shutdown(&mut self) { + self.backend.shutdown(); + } +} -- cgit v1.2.3-18-g5258