forked from AbleOS/ableos
27 lines
649 B
Rust
27 lines
649 B
Rust
#![no_std]
|
|
extern crate alloc;
|
|
|
|
pub mod pixel_format;
|
|
|
|
mod engine_internals;
|
|
|
|
use alloc::boxed::Box;
|
|
use core::result::Result;
|
|
use engine_internals::engine_startup;
|
|
use pixel_format::Rgba64;
|
|
use rhai::{EvalAltResult, Scope};
|
|
|
|
pub const SHADER: &str = include_str!("../shaders/simple.shade");
|
|
|
|
pub fn evaluate_shader(x: usize, y: usize, pixel: Rgba64) -> Result<Rgba64, Box<EvalAltResult>> {
|
|
let engine = engine_startup();
|
|
|
|
let ast = engine.compile(SHADER)?;
|
|
let mut scope = Scope::new();
|
|
scope.push("PIXEL_RGBA", pixel);
|
|
scope.push("PIXEL_X", x);
|
|
scope.push("PIXEL_Y", y);
|
|
|
|
engine.call_fn(&mut scope, &ast, "main", ())
|
|
}
|