summaryrefslogtreecommitdiff
path: root/racer-tracer/src/scene_controller.rs
diff options
context:
space:
mode:
Diffstat (limited to 'racer-tracer/src/scene_controller.rs')
-rw-r--r--racer-tracer/src/scene_controller.rs37
1 files changed, 37 insertions, 0 deletions
diff --git a/racer-tracer/src/scene_controller.rs b/racer-tracer/src/scene_controller.rs
new file mode 100644
index 0000000..4a867f5
--- /dev/null
+++ b/racer-tracer/src/scene_controller.rs
@@ -0,0 +1,37 @@
+pub mod interactive;
+
+use slog::Logger;
+
+use crate::{
+ camera::Camera, config::Config, error::TracerError, image::Image, key_inputs::KeyCallback,
+ scene::Scene, terminal::Terminal,
+};
+
+pub fn create_screen_buffer(image: &Image) -> Vec<u32> {
+ vec![0; image.width * image.height]
+}
+
+pub struct SceneData {
+ pub log: Logger,
+ pub term: Terminal,
+ pub config: Config,
+ pub scene: Scene,
+ pub camera: Camera,
+ pub image: Image,
+}
+
+pub trait SceneController: Send + Sync {
+ // Return a vector of key callbacks. The provided closure will be
+ // called when the corresponding key is release/pressed.
+ fn get_inputs(&self) -> Vec<KeyCallback>;
+
+ // Render function
+ fn render(&self) -> Result<(), TracerError>;
+
+ // Returns the screen buffer produced by the scene controller.
+ // Returns None if no new buffer is available
+ fn get_buffer(&self) -> Result<Option<Vec<u32>>, TracerError>;
+
+ // Called when the application wants to exit.
+ fn stop(&self);
+}