summaryrefslogtreecommitdiff
path: root/src/renderer/dummy.rs
diff options
context:
space:
mode:
authorJSDurand <mmemmew@gmail.com>2025-06-21 13:32:55 +0800
committerJSDurand <mmemmew@gmail.com>2025-06-21 13:32:55 +0800
commit9b36d712e25fb1d209df848281b9913b61a6ec45 (patch)
treee7a126af70f71a02b2e63292b07b8458effb7da5 /src/renderer/dummy.rs
init commit
A basic window is available. Now we shall try to render texts and some auxiliary functionalities.
Diffstat (limited to 'src/renderer/dummy.rs')
-rw-r--r--src/renderer/dummy.rs55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/renderer/dummy.rs b/src/renderer/dummy.rs
new file mode 100644
index 0000000..6a5b378
--- /dev/null
+++ b/src/renderer/dummy.rs
@@ -0,0 +1,55 @@
+use winit::application::ApplicationHandler;
+
+use super::backend::RendererBackend;
+use super::text::TextSpan;
+
+#[derive(Debug, Clone)]
+pub struct DummyRenderer;
+
+impl DummyRenderer {
+ pub fn new() -> Self {
+ Self
+ }
+}
+
+impl RendererBackend for DummyRenderer {
+ fn init(&mut self, _width: i32, _height: i32) -> bool {
+ println!("DummyRenderer initialized.");
+ true
+ }
+
+ fn draw_text(&mut self, span: &TextSpan) {
+ println!("[style: {:?}] {}", span.style, span.text);
+ }
+
+ fn shutdown(&mut self) {
+ println!("DummyRenderer shutting down.");
+ }
+
+ fn name(&self) -> &str {
+ "Dummy"
+ }
+
+ fn clear(&mut self) {
+ println!("DummyRenderer clearing.");
+ }
+
+ fn present(&mut self) {
+ println!("DummyRenderer is presenting.");
+ }
+}
+
+impl ApplicationHandler for DummyRenderer {
+ fn resumed(&mut self, event_loop: &winit::event_loop::ActiveEventLoop) {
+ println!("resumed");
+ }
+
+ fn window_event(
+ &mut self,
+ event_loop: &winit::event_loop::ActiveEventLoop,
+ window_id: winit::window::WindowId,
+ event: winit::event::WindowEvent,
+ ) {
+ println!("received an event: {event:?}");
+ }
+}