#![allow(unused_variables, unused_must_use)] extern crate sciter; use sciter::dom::event::*; use sciter::{Element, HELEMENT}; use sciter::video::{fragmented_video_destination, AssetPtr}; struct VideoGen { thread: Option>, } impl Drop for VideoGen { fn drop(&mut self) { println!("[video] behavior is destroyed"); } } impl VideoGen { fn new() -> Self { Self { thread: None } } fn generation_thread(site: AssetPtr) { println!("[video] thread is started"); // our video frame size and its part to update const FRAME: (i32, i32) = (1200, 800); const UPDATE: (i32, i32) = (256, 32); // our frame data (RGBA) let figure = [0xFF_FFA500u32; (UPDATE.0 * UPDATE.1) as usize]; // configure video output let mut site = site; let ok = site.start_streaming(FRAME, sciter::video::COLOR_SPACE::Rgb32, None); println!("[video] initialized: {:?}", ok); let mut x = 0; let mut xd = 1; let mut y = 0; let mut yd = 1; while site.is_alive() { // send an update portion let buf: &[u8] = unsafe { std::mem::transmute(figure.as_ref()) }; site.render_frame_part(buf, (x, y), UPDATE); // set the next position x += xd; y += yd; if x == 0 { xd = 1; } else if x + UPDATE.0 == FRAME.0 { xd = -1; } if y == 0 { yd = 1; } else if y + UPDATE.1 == FRAME.1 { yd = -1; } // simulate 25 FPS std::thread::sleep(std::time::Duration::from_millis(1000 / 25)); } site.stop_streaming(); println!("[video] thread is finished"); } } impl sciter::EventHandler for VideoGen { fn get_subscription(&mut self) -> Option { Some(EVENT_GROUPS::HANDLE_BEHAVIOR_EVENT) } fn detached(&mut self, _root: HELEMENT) { println!("[video]