mirror of
https://github.com/griffi-gh/kubi.git
synced 2024-11-22 06:48:43 -06:00
wip fix android
This commit is contained in:
parent
bc36bb8ce2
commit
06a49e1b93
217
Cargo.lock
generated
217
Cargo.lock
generated
|
@ -75,10 +75,10 @@ dependencies = [
|
|||
"jni-sys",
|
||||
"libc",
|
||||
"log",
|
||||
"ndk 0.8.0",
|
||||
"ndk",
|
||||
"ndk-context",
|
||||
"ndk-sys 0.5.0+25.2.9519653",
|
||||
"num_enum 0.7.1",
|
||||
"ndk-sys",
|
||||
"num_enum",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
|
@ -451,41 +451,6 @@ version = "1.1.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "96a6ac251f4a2aca6b3f91340350eab87ae57c3f127ffeb585e92bd336717991"
|
||||
|
||||
[[package]]
|
||||
name = "darling"
|
||||
version = "0.13.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a01d95850c592940db9b8194bc39f4bc0e89dee5c4265e4b1807c34a9aba453c"
|
||||
dependencies = [
|
||||
"darling_core",
|
||||
"darling_macro",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "darling_core"
|
||||
version = "0.13.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "859d65a907b6852c9361e3185c862aae7fafd2887876799fa55f5f99dc40d610"
|
||||
dependencies = [
|
||||
"fnv",
|
||||
"ident_case",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"strsim",
|
||||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "darling_macro"
|
||||
version = "0.13.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9c972679f83bdf9c42bd905396b6c3588a843a17f0f16dfcfa3e2c5d57441835"
|
||||
dependencies = [
|
||||
"darling_core",
|
||||
"quote",
|
||||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dispatch"
|
||||
version = "0.2.0"
|
||||
|
@ -603,7 +568,7 @@ checksum = "1a5c6c585bc94aaf2c7b51dd4c2ba22680844aba4c687be581871a6f518c5742"
|
|||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.39",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -855,12 +820,6 @@ dependencies = [
|
|||
"objc2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ident_case"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39"
|
||||
|
||||
[[package]]
|
||||
name = "image"
|
||||
version = "0.24.7"
|
||||
|
@ -982,6 +941,7 @@ checksum = "e2db585e1d738fc771bf08a151420d3ed193d9d895a36df7f6f8a9456b911ddc"
|
|||
name = "kubi"
|
||||
version = "0.0.0"
|
||||
dependencies = [
|
||||
"android-activity",
|
||||
"anyhow",
|
||||
"flume",
|
||||
"gilrs",
|
||||
|
@ -995,8 +955,7 @@ dependencies = [
|
|||
"kubi-ui",
|
||||
"log",
|
||||
"lz4_flex",
|
||||
"ndk 0.7.0",
|
||||
"ndk-glue",
|
||||
"ndk",
|
||||
"nohash-hasher",
|
||||
"postcard",
|
||||
"rayon",
|
||||
|
@ -1055,7 +1014,7 @@ dependencies = [
|
|||
"glam",
|
||||
"hashbrown",
|
||||
"nohash-hasher",
|
||||
"num_enum 0.7.1",
|
||||
"num_enum",
|
||||
"postcard",
|
||||
"rand",
|
||||
"rand_xoshiro",
|
||||
|
@ -1229,20 +1188,6 @@ dependencies = [
|
|||
"getrandom",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ndk"
|
||||
version = "0.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "451422b7e4718271c8b5b3aadf5adedba43dc76312454b387e98fae0fc951aa0"
|
||||
dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
"jni-sys",
|
||||
"ndk-sys 0.4.1+23.1.7779620",
|
||||
"num_enum 0.5.11",
|
||||
"raw-window-handle 0.5.2",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ndk"
|
||||
version = "0.8.0"
|
||||
|
@ -1252,8 +1197,8 @@ dependencies = [
|
|||
"bitflags 2.4.1",
|
||||
"jni-sys",
|
||||
"log",
|
||||
"ndk-sys 0.5.0+25.2.9519653",
|
||||
"num_enum 0.7.1",
|
||||
"ndk-sys",
|
||||
"num_enum",
|
||||
"raw-window-handle 0.5.2",
|
||||
"raw-window-handle 0.6.0",
|
||||
"thiserror",
|
||||
|
@ -1265,44 +1210,6 @@ version = "0.1.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "27b02d87554356db9e9a873add8782d4ea6e3e58ea071a9adb9a2e8ddb884a8b"
|
||||
|
||||
[[package]]
|
||||
name = "ndk-glue"
|
||||
version = "0.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0434fabdd2c15e0aab768ca31d5b7b333717f03cf02037d5a0a3ff3c278ed67f"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"log",
|
||||
"ndk 0.7.0",
|
||||
"ndk-context",
|
||||
"ndk-macro",
|
||||
"ndk-sys 0.4.1+23.1.7779620",
|
||||
"once_cell",
|
||||
"parking_lot",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ndk-macro"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0df7ac00c4672f9d5aece54ee3347520b7e20f158656c7db2e6de01902eb7a6c"
|
||||
dependencies = [
|
||||
"darling",
|
||||
"proc-macro-crate 1.3.1",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ndk-sys"
|
||||
version = "0.4.1+23.1.7779620"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3cf2aae958bd232cac5069850591667ad422d263686d75b52a065f9badeee5a3"
|
||||
dependencies = [
|
||||
"jni-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ndk-sys"
|
||||
version = "0.5.0+25.2.9519653"
|
||||
|
@ -1381,34 +1288,13 @@ dependencies = [
|
|||
"autocfg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num_enum"
|
||||
version = "0.5.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1f646caf906c20226733ed5b1374287eb97e3c2a5c227ce668c1f2ce20ae57c9"
|
||||
dependencies = [
|
||||
"num_enum_derive 0.5.11",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num_enum"
|
||||
version = "0.7.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "683751d591e6d81200c39fb0d1032608b77724f34114db54f571ff1317b337c0"
|
||||
dependencies = [
|
||||
"num_enum_derive 0.7.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num_enum_derive"
|
||||
version = "0.5.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dcbff9bc912032c62bf65ef1d5aea88983b420f4f839db1e9b0c281a25c9c799"
|
||||
dependencies = [
|
||||
"proc-macro-crate 1.3.1",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 1.0.109",
|
||||
"num_enum_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1417,10 +1303,10 @@ version = "0.7.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6c11e44798ad209ccdd91fc192f0526a369a01234f7373e1b141c96d7cee4f0e"
|
||||
dependencies = [
|
||||
"proc-macro-crate 2.0.0",
|
||||
"proc-macro-crate",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.39",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1488,29 +1374,6 @@ dependencies = [
|
|||
"libm",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "parking_lot"
|
||||
version = "0.12.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f"
|
||||
dependencies = [
|
||||
"lock_api",
|
||||
"parking_lot_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "parking_lot_core"
|
||||
version = "0.9.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"redox_syscall 0.4.1",
|
||||
"smallvec",
|
||||
"windows-targets 0.48.5",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "percent-encoding"
|
||||
version = "2.3.0"
|
||||
|
@ -1574,16 +1437,6 @@ version = "0.2.17"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro-crate"
|
||||
version = "1.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919"
|
||||
dependencies = [
|
||||
"once_cell",
|
||||
"toml_edit 0.19.15",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro-crate"
|
||||
version = "2.0.0"
|
||||
|
@ -1856,7 +1709,7 @@ checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3"
|
|||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.39",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1899,7 +1752,7 @@ source = "git+https://github.com/leudz/shipyard?rev=8ef90ea6c4d1eb6c9cb0988f0d2f
|
|||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.39",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1990,12 +1843,6 @@ version = "0.1.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6637bab7722d379c8b41ba849228d680cc12d0a45ba1fa2b48f2a30577a06731"
|
||||
|
||||
[[package]]
|
||||
name = "strsim"
|
||||
version = "0.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
|
||||
|
||||
[[package]]
|
||||
name = "strum"
|
||||
version = "0.25.0"
|
||||
|
@ -2015,18 +1862,7 @@ dependencies = [
|
|||
"proc-macro2",
|
||||
"quote",
|
||||
"rustversion",
|
||||
"syn 2.0.39",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "1.0.109"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-ident",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -2072,7 +1908,7 @@ checksum = "266b2e40bc00e5a6c09c3584011e08b06f123c00362c92b975ba9843aaaa14b8"
|
|||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.39",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -2130,17 +1966,6 @@ dependencies = [
|
|||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml_edit"
|
||||
version = "0.19.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421"
|
||||
dependencies = [
|
||||
"indexmap",
|
||||
"toml_datetime",
|
||||
"winnow",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml_edit"
|
||||
version = "0.20.7"
|
||||
|
@ -2263,7 +2088,7 @@ dependencies = [
|
|||
"once_cell",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.39",
|
||||
"syn",
|
||||
"wasm-bindgen-shared",
|
||||
]
|
||||
|
||||
|
@ -2297,7 +2122,7 @@ checksum = "c5353b8dab669f5e10f5bd76df26a9360c748f054f862ff5f3f8aae0c7fb3907"
|
|||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.39",
|
||||
"syn",
|
||||
"wasm-bindgen-backend",
|
||||
"wasm-bindgen-shared",
|
||||
]
|
||||
|
@ -2630,8 +2455,8 @@ dependencies = [
|
|||
"libc",
|
||||
"log",
|
||||
"memmap2",
|
||||
"ndk 0.8.0",
|
||||
"ndk-sys 0.5.0+25.2.9519653",
|
||||
"ndk",
|
||||
"ndk-sys",
|
||||
"objc2",
|
||||
"once_cell",
|
||||
"orbclient",
|
||||
|
@ -2755,5 +2580,5 @@ checksum = "dd7e48ccf166952882ca8bd778a43502c64f33bf94c12ebe2a7f08e5a0f6689f"
|
|||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.39",
|
||||
"syn",
|
||||
]
|
||||
|
|
|
@ -14,8 +14,8 @@ kubi-logging = { path = "../kubi-logging" }
|
|||
kubi-ui = { path = "../kubi-ui" }
|
||||
log = "0.4"
|
||||
glium = { git = "https://github.com/glium/glium", rev = "968fc92378caf" }
|
||||
glutin = "*"
|
||||
winit = "*"
|
||||
glutin = "0.31"
|
||||
winit = { version = "0.29", features = ["android-native-activity"] }
|
||||
glam = { version = "0.24", features = ["debug-glam-assert", "fast-math"] }
|
||||
image = { version = "0.24", default_features = false, features = ["png"] }
|
||||
strum = { version = "0.25", features = ["derive"] }
|
||||
|
@ -34,8 +34,8 @@ tinyset = "0.4"
|
|||
serde_json = { version = "1.0", optional = true } #only used for `generate_visualizer_data`
|
||||
|
||||
[target.'cfg(target_os = "android")'.dependencies]
|
||||
ndk = "0.7"
|
||||
ndk-glue = "0.7"
|
||||
android-activity = "0.5"
|
||||
ndk = "0.8"
|
||||
|
||||
[target.'cfg(target_os = "windows")'.dependencies]
|
||||
winapi = "0.3"
|
||||
|
|
|
@ -1,15 +1,22 @@
|
|||
use std::{fs::File, path::Path, io::{Read, Seek}};
|
||||
use anyhow::Result;
|
||||
use shipyard::{Unique, AllStoragesView};
|
||||
|
||||
pub trait ReadOnly: Read + Seek {}
|
||||
impl<T: Read + Seek> ReadOnly for T {}
|
||||
|
||||
pub fn open_asset(path: &Path) -> Result<Box<dyn ReadOnly>> {
|
||||
#[derive(Unique)]
|
||||
pub struct AssetManager {
|
||||
#[cfg(target_os = "android")]
|
||||
app: android_activity::AndroidApp,
|
||||
}
|
||||
|
||||
impl AssetManager {
|
||||
pub fn open_asset(&self, path: &Path) -> Result<Box<dyn ReadOnly>> {
|
||||
#[cfg(target_os = "android")] {
|
||||
use anyhow::Context;
|
||||
use std::ffi::CString;
|
||||
|
||||
let asset_manager = ndk_glue::native_activity().asset_manager();
|
||||
let asset_manager = self.app.asset_manager();
|
||||
let path_cstr = CString::new(path.to_string_lossy().as_bytes())?;
|
||||
let handle = asset_manager.open(&path_cstr).context("Asset doesn't exist")?;
|
||||
Ok(Box::new(handle))
|
||||
|
@ -19,3 +26,4 @@ pub fn open_asset(path: &Path) -> Result<Box<dyn ReadOnly>> {
|
|||
Ok(Box::new(File::open(asset_path)?))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -80,6 +80,7 @@ use legacy_gui::{render_gui, init_gui, update_gui};
|
|||
use loading_screen::update_loading_screen;
|
||||
use connecting_screen::switch_to_loading_if_connected;
|
||||
use fixed_timestamp::init_fixed_timestamp_storage;
|
||||
use filesystem::AssetManager;
|
||||
|
||||
/// stuff required to init the renderer and other basic systems
|
||||
fn pre_startup() -> Workload {
|
||||
|
@ -169,8 +170,13 @@ fn attach_console() {
|
|||
}
|
||||
|
||||
#[no_mangle]
|
||||
#[cfg_attr(target_os = "android", ndk_glue::main(backtrace = "on"))]
|
||||
pub fn kubi_main() {
|
||||
#[cfg(target_os = "android")]
|
||||
pub fn android_main(app: android_activity::AndroidApp) {
|
||||
kubi_main(app)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub fn kubi_main(#[cfg(target_os = "android")] app: android_activity::AndroidApp) {
|
||||
//Attach console on release builds on windows
|
||||
#[cfg(all(windows, not(debug_assertions)))] attach_console();
|
||||
|
||||
|
@ -183,6 +189,11 @@ pub fn kubi_main() {
|
|||
//Create a shipyard world
|
||||
let mut world = World::new();
|
||||
|
||||
//Init assman
|
||||
world.add_unique(AssetManager {
|
||||
#[cfg(target_os = "android")] app
|
||||
});
|
||||
|
||||
//Register workloads
|
||||
world.add_workload(pre_startup);
|
||||
world.add_workload(startup);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use shipyard::{NonSendSync, UniqueView, Unique, AllStoragesView};
|
||||
use glium::{texture::{SrgbTexture2dArray, MipmapsOption}, Program};
|
||||
use kubi_shared::block::BlockTexture;
|
||||
use crate::rendering::Renderer;
|
||||
use crate::{rendering::Renderer, filesystem::AssetManager};
|
||||
|
||||
mod texture;
|
||||
mod shaders;
|
||||
|
@ -54,11 +54,13 @@ pub struct ProgressbarShaderPrefab(pub Program);
|
|||
|
||||
pub fn load_prefabs(
|
||||
storages: AllStoragesView,
|
||||
renderer: NonSendSync<UniqueView<Renderer>>
|
||||
renderer: NonSendSync<UniqueView<Renderer>>,
|
||||
assman: UniqueView<AssetManager>
|
||||
) {
|
||||
log::info!("Loading textures...");
|
||||
storages.add_unique_non_send_sync(BlockTexturesPrefab(
|
||||
load_texture2darray_prefab::<BlockTexture, _>(
|
||||
&assman,
|
||||
"blocks".into(),
|
||||
&renderer.display,
|
||||
MipmapsOption::AutoGeneratedMipmaps
|
||||
|
|
|
@ -2,13 +2,14 @@ use strum::IntoEnumIterator;
|
|||
use rayon::prelude::*;
|
||||
use std::{path::PathBuf, io::BufReader};
|
||||
use glium::{texture::{SrgbTexture2dArray, RawImage2d, MipmapsOption}, backend::Facade};
|
||||
use crate::filesystem::open_asset;
|
||||
use crate::filesystem::AssetManager;
|
||||
use super::AssetPaths;
|
||||
|
||||
pub fn load_texture2darray_prefab<
|
||||
T: AssetPaths + IntoEnumIterator,
|
||||
E: Facade
|
||||
>(
|
||||
assman: &AssetManager,
|
||||
directory: PathBuf,
|
||||
facade: &E,
|
||||
mipmaps: MipmapsOption,
|
||||
|
@ -21,7 +22,7 @@ pub fn load_texture2darray_prefab<
|
|||
//Get path to the image and open the file
|
||||
let reader = {
|
||||
let path = directory.join(file_name);
|
||||
BufReader::new(open_asset(&path).expect("Failed to open texture file"))
|
||||
BufReader::new(assman.open_asset(&path).expect("Failed to open texture file"))
|
||||
};
|
||||
//Parse image data
|
||||
let (image_data, dimensions) = {
|
||||
|
|
Loading…
Reference in a new issue