Expose creating a resource loader from a path to C
This commit is contained in:
parent
0f35009215
commit
5e8c20e78c
|
@ -35,6 +35,7 @@ use pathfinder_renderer::scene::Scene;
|
||||||
use pathfinder_simd::default::F32x4;
|
use pathfinder_simd::default::F32x4;
|
||||||
use std::ffi::CString;
|
use std::ffi::CString;
|
||||||
use std::os::raw::{c_char, c_void};
|
use std::os::raw::{c_char, c_void};
|
||||||
|
use std::path::PathBuf;
|
||||||
use std::slice;
|
use std::slice;
|
||||||
use std::str;
|
use std::str;
|
||||||
|
|
||||||
|
@ -487,6 +488,14 @@ pub unsafe extern "C" fn PFFilesystemResourceLoaderLocate() -> PFResourceLoaderR
|
||||||
Box::into_raw(Box::new(ResourceLoaderWrapper(loader as Box<dyn ResourceLoader>)))
|
Box::into_raw(Box::new(ResourceLoaderWrapper(loader as Box<dyn ResourceLoader>)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub unsafe extern "C" fn PFFilesystemResourceLoaderFromPath(path: *const c_char) -> PFResourceLoaderRef {
|
||||||
|
let string = to_rust_string(&path, 0);
|
||||||
|
let directory = PathBuf::from(string);
|
||||||
|
let loader = Box::new(FilesystemResourceLoader { directory });
|
||||||
|
Box::into_raw(Box::new(ResourceLoaderWrapper(loader as Box<dyn ResourceLoader>)))
|
||||||
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn PFGLLoadWith(loader: PFGLFunctionLoader, userdata: *mut c_void) {
|
pub unsafe extern "C" fn PFGLLoadWith(loader: PFGLFunctionLoader, userdata: *mut c_void) {
|
||||||
gl::load_with(|name| {
|
gl::load_with(|name| {
|
||||||
|
|
Loading…
Reference in New Issue