comparison python/src/lib.rs @ 772:7492d384d122 default tip

Rust: Add a Glide renderer (2D only for now) This is an experiment for a Rust renderer, iterating over the Python data using pyo3. It requires --feature=glide to be passed to cargo build, doesn’t support NPOT textures, text rendering, the background, or even msg faces, some of that may come in a future changeset.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Mon, 05 Sep 2022 17:53:36 +0200
parents f6c287745a67
children
comparison
equal deleted inserted replaced
771:79c3f782dd41 772:7492d384d122
1 use pyo3::prelude::*; 1 use pyo3::prelude::*;
2 use pyo3::types::PyBytes; 2 use pyo3::types::PyBytes;
3 use touhou_formats::th06::pbg3; 3 use touhou_formats::th06::pbg3;
4 use std::fs::File; 4 use std::fs::File;
5 use std::io::BufReader; 5 use std::io::BufReader;
6
7 #[cfg(feature = "glide")]
8 mod glide;
6 9
7 #[pyclass] 10 #[pyclass]
8 struct PBG3 { 11 struct PBG3 {
9 inner: pbg3::PBG3<BufReader<File>>, 12 inner: pbg3::PBG3<BufReader<File>>,
10 } 13 }
33 PyBytes::new(py, &data).into_py(py) 36 PyBytes::new(py, &data).into_py(py)
34 } 37 }
35 } 38 }
36 39
37 #[pymodule] 40 #[pymodule]
38 fn libtouhou(_py: Python, m: &PyModule) -> PyResult<()> { 41 fn libtouhou(py: Python, m: &PyModule) -> PyResult<()> {
39 m.add_class::<PBG3>()?; 42 m.add_class::<PBG3>()?;
43 #[cfg(feature = "glide")]
44 m.add_submodule(glide::module(py)?)?;
40 Ok(()) 45 Ok(())
41 } 46 }