@@ -12,7 +12,7 @@ mod glfw;
1212mod graphics;
1313
1414use graphics:: { Graphics , get_graphics, get_graphics_mut} ;
15- use pyo3:: { exceptions:: PyRuntimeError , prelude:: * } ;
15+ use pyo3:: { exceptions:: PyRuntimeError , prelude:: * , types :: PyString } ;
1616
1717#[ pymodule]
1818fn processing ( m : & Bound < ' _ , PyModule > ) -> PyResult < ( ) > {
@@ -27,10 +27,9 @@ fn processing(m: &Bound<'_, PyModule>) -> PyResult<()> {
2727 let abspath = path
2828 . getattr ( "abspath" ) ?
2929 . call1 ( pyo3:: types:: PyTuple :: new ( py, & [ dirname] ) ?) ?;
30+ let abspath = path. getattr ( "join" ) ?. call1 ( ( abspath, "assets" ) ) ?;
3031
31- println ! ( "DEBUG MOMENT OF SUCCESS: {}" , abspath) ;
32- // TODO: Pass this into Graphics for App init
33-
32+ m. add ( "_root_dir" , abspath) ?;
3433 m. add_class :: < Graphics > ( ) ?;
3534 m. add_function ( wrap_pyfunction ! ( size, m) ?) ?;
3635 m. add_function ( wrap_pyfunction ! ( run, m) ?) ?;
@@ -49,9 +48,8 @@ fn processing(m: &Bound<'_, PyModule>) -> PyResult<()> {
4948#[ pyfunction]
5049#[ pyo3( pass_module) ]
5150fn size ( module : & Bound < ' _ , PyModule > , width : u32 , height : u32 ) -> PyResult < ( ) > {
52- // would we get a directory here?
53-
54- let graphics = Graphics :: new ( width, height) ?;
51+ let asset_path: String = module. getattr ( "_root_dir" ) ?. extract ( ) ?;
52+ let graphics = Graphics :: new ( width, height, asset_path. as_str ( ) ) ?;
5553 module. setattr ( "_graphics" , graphics) ?;
5654 Ok ( ( ) )
5755}
0 commit comments