Auto merge of #356 - linkmauve:c-resources-path, r=pcwalton
Expose creating a resource loader from a path to C This is useful when Pathfinder is shipped by a Linux distribution, and not with everything bundled.
This commit is contained in:
commit
5e3fb5fed0
|
@ -34,6 +34,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;
|
||||||
|
|
||||||
|
@ -488,6 +489,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