1
0
Fork 0
forked from AbleOS/ableos
ableos_time/shadeable/src/lib.rs

27 lines
649 B
Rust
Raw Normal View History

2022-01-16 19:42:11 -06:00
#![no_std]
extern crate alloc;
2022-04-11 17:27:34 -05:00
pub mod pixel_format;
mod engine_internals;
2022-01-22 00:01:16 -06:00
use alloc::boxed::Box;
2022-01-16 19:42:11 -06:00
use engine_internals::engine_startup;
2022-01-22 00:01:16 -06:00
use pixel_format::Rgba64;
2022-01-16 19:42:11 -06:00
use core::result::Result;
use rhai::{EvalAltResult, Scope};
pub const SHADER: &str = include_str!("../shaders/simple.shade");
2022-01-22 00:01:16 -06:00
pub fn evaluate_shader(x: usize, y: usize, pixel: Rgba64) -> Result<Rgba64, Box<EvalAltResult>> {
2022-01-18 06:15:51 -06:00
let engine = engine_startup();
let ast = engine.compile(SHADER)?;
let mut scope = Scope::new();
scope.push("PIXEL_RGBA", pixel);
2022-01-22 00:01:16 -06:00
scope.push("PIXEL_X", x);
scope.push("PIXEL_Y", y);
2022-01-18 06:15:51 -06:00
2022-04-11 17:23:11 -05:00
engine.call_fn(&mut scope, &ast, "main", ())
2022-01-18 06:15:51 -06:00
}