wgs_runtime_base/
runtime.rs

1use anyhow::Result;
2use wgs_core::WgsData;
3
4/// A basic trait for wgs runtime.
5pub trait RuntimeExt {
6    /// Adds a texture to wgs.
7    fn add_texture(&mut self, width: u32, height: u32, buffer: Vec<u8>);
8
9    /// Changes the texture of the given index in wgs.
10    fn change_texture(&mut self, index: usize, width: u32, height: u32, buffer: Vec<u8>);
11
12    /// Compiles wgs manually.
13    fn compile(&mut self) -> Result<()>;
14
15    /// Loads a wgs file.
16    fn load(&mut self, wgs: WgsData) -> Result<()>;
17
18    /// Pauses the runtime.
19    fn pause(&mut self);
20
21    /// Removes a texture from wgs.
22    fn remove_texture(&mut self, index: usize);
23
24    /// Do the rendering.
25    fn render(&mut self) -> Result<()>;
26
27    /// Resize the runtime.
28    fn resize(&mut self, width: f32, height: f32);
29
30    /// Restarts the rendering proccess of wgs.
31    fn restart(&mut self);
32
33    /// Resumes the runtime.
34    fn resume(&mut self);
35
36    /// Sets the content of the editable part of the fragment shader in wgs.
37    fn set_wgs_frag(&mut self, shader_frag: &str);
38
39    /// Sets the name for wgs.
40    fn set_wgs_name(&mut self, name: &str);
41
42    /// Calls when the cursor position changes.
43    fn update_cursor(&mut self, cursor: [f32; 2]);
44
45    /// Calls when the mouse is pressed.
46    fn update_mouse_press(&mut self);
47
48    /// Calls when the mouse is released.
49    fn update_mouse_release(&mut self);
50
51    /// Returns the wgs data.
52    fn wgs(&self) -> &WgsData;
53}