diff options
author | JSDurand <mmemmew@gmail.com> | 2025-06-21 13:32:55 +0800 |
---|---|---|
committer | JSDurand <mmemmew@gmail.com> | 2025-06-21 13:32:55 +0800 |
commit | 9b36d712e25fb1d209df848281b9913b61a6ec45 (patch) | |
tree | e7a126af70f71a02b2e63292b07b8458effb7da5 /src/renderer/mod.rs |
init commit
A basic window is available. Now we shall try to render texts and
some auxiliary functionalities.
Diffstat (limited to 'src/renderer/mod.rs')
-rw-r--r-- | src/renderer/mod.rs | 46 |
1 files changed, 46 insertions, 0 deletions
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<dyn RendererBackend + 'a>, + pub width: i32, + pub height: i32, +} + +impl<'a> Renderer<'a> { + pub fn new<B>(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(); + } +} |